How to use @mattiasbuelens/web-streams-adapter - 1 common examples

To help you get started, we’ve selected a few @mattiasbuelens/web-streams-adapter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ProtonMail / proton-shared / lib / keys / driveKeys.ts View on Github external
getMessage,
    encryptMessage,
    generateKey,
    binaryStringToArray,
    signMessage,
    arrayToHexString
} from 'pmcrypto';
import { openpgp } from 'pmcrypto/lib/openpgp';
import { ReadableStream as PolyfillReadableStream } from 'web-streams-polyfill';
import { createReadableStreamWrapper } from '@mattiasbuelens/web-streams-adapter';
import { ENCRYPTION_CONFIGS, ENCRYPTION_TYPES } from '../constants';
import { generatePassphrase } from './calendarKeys';
import { createSessionKey, getEncryptedSessionKey } from '../calendar/encrypt';
import { serializeUint8Array } from '../helpers/serialization';

const toPolyfillReadable = createReadableStreamWrapper(PolyfillReadableStream);

interface UnsignedEncryptionPayload {
    message: string;
    privateKey: key.Key;
}

export const sign = async (data: string, privateKeys: key.Key | key.Key[]) => {
    const { signature } = await signMessage({
        data,
        privateKeys,
        armor: true,
        detached: true
    });
    return signature;
};

@mattiasbuelens/web-streams-adapter

Adapters for converting between different implementations of WHATWG Streams

MIT
Latest version published 3 years ago

Package Health Score

47 / 100
Full package analysis

Popular @mattiasbuelens/web-streams-adapter functions

Similar packages