2021-11-16 15:12:22 +01:00
|
|
|
import { Crypto as WebCrypto } from 'next/dist/compiled/@peculiar/webcrypto'
|
|
|
|
import { CryptoKey } from 'next/dist/compiled/@peculiar/webcrypto'
|
2021-10-20 19:52:11 +02:00
|
|
|
import { v4 as uuid } from 'next/dist/compiled/uuid'
|
2022-02-04 18:52:53 +01:00
|
|
|
import { ReadableStream } from './readable-stream'
|
2022-01-19 13:36:06 +01:00
|
|
|
|
2021-10-20 19:52:11 +02:00
|
|
|
import crypto from 'crypto'
|
|
|
|
|
|
|
|
export function atob(b64Encoded: string) {
|
|
|
|
return Buffer.from(b64Encoded, 'base64').toString('binary')
|
|
|
|
}
|
|
|
|
|
|
|
|
export function btoa(str: string) {
|
|
|
|
return Buffer.from(str, 'binary').toString('base64')
|
|
|
|
}
|
|
|
|
|
2022-02-04 18:52:53 +01:00
|
|
|
export { CryptoKey, ReadableStream }
|
2021-10-20 19:52:11 +02:00
|
|
|
|
|
|
|
export class Crypto extends WebCrypto {
|
|
|
|
// @ts-ignore Remove once types are updated and we deprecate node 12
|
|
|
|
randomUUID = crypto.randomUUID || uuid
|
|
|
|
}
|