How to use the @tanker/types.getConstructorName function in @tanker/types

To help you get started, we’ve selected a few @tanker/types 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 TankerHQ / sdk-js / packages / functional-tests / src / encrypt.js View on Github external
args.resources[size].forEach(({ type: transientType }) => {
          it(`can encrypt a ${size} ${getConstructorName(originalType)} into a ${getConstructorName(transientType)} and decrypt back a ${getConstructorName(originalType)}`, async () => {
            const encrypted = await aliceLaptop.encryptData(clear, { type: transientType });
            expectType(encrypted, transientType);

            const outputOptions = {};
            outputOptions.type = originalType;

            if (global.Blob && outputOptions.type === Blob) {
              outputOptions.mime = clear.type;
            }
            if (global.File && outputOptions.type === File) {
              outputOptions.mime = clear.type;
              outputOptions.name = clear.name;
              outputOptions.lastModified = clear.lastModified;
            }

            const decrypted = await aliceLaptop.decryptData(encrypted, outputOptions);
github TankerHQ / sdk-js / packages / functional-tests / src / encrypt.js View on Github external
args.resources[size].forEach(({ type, resource: clear }) => {
        it(`can encrypt and decrypt a ${size} ${getConstructorName(type)}`, async () => {
          const onProgress = sinon.spy();

          const encrypted = await aliceLaptop.encryptData(clear, { onProgress });
          expectSameType(encrypted, clear);
          expectProgressReport(onProgress, getDataLength(encrypted));
          onProgress.resetHistory();

          const decrypted = await aliceLaptop.decryptData(encrypted, { onProgress });
          expectSameType(decrypted, clear);
          expectDeepEqual(decrypted, clear);
          expectProgressReport(onProgress, getDataLength(decrypted), encryptionV4.defaultMaxEncryptedChunkSize - encryptionV4.overhead);
        });
      });
    });
github TankerHQ / sdk-js / packages / stream / base / src / __tests__ / MergerStream.spec.js View on Github external
testOptions.forEach(options => {
    const { type } = options;

    it(`can merge binary chunks into a ${getConstructorName(type)}`, async () => {
      const stream = new MergerStream(options);

      const output: Array = [];
      stream.on('data', (data) => { output.push(data); });

      const testPromise = new Promise((resolve, reject) => {
        stream.on('error', reject);
        stream.on('end', async () => {
          try {
            expect(output).to.have.lengthOf(1);
            expect(output[0]).to.be.an.instanceOf(type);

            const outputBytes = await castData(output[0], { type: Uint8Array });
            expect(outputBytes).to.deep.equal(bytes);

            if (global.Blob && output[0] instanceof global.Blob) {

@tanker/types

Tanker SDK (types)

Apache-2.0
Latest version published 5 months ago

Package Health Score

65 / 100
Full package analysis

Similar packages