How to use the @tanker/types.assertDataType 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 / stream / base / src / SlicerStream.js View on Github external
constructor(options: { source: ExternalSource, outputSize?: number }) {
    // $FlowIKnow Use of Object.prototype
    if (!options || typeof options !== 'object' || Object.getPrototypeOf(options) !== Object.prototype)
      throw new InvalidArgument('options', 'object', options);

    const { source, outputSize } = options;

    assertDataType(source, 'options.source');

    if (outputSize && typeof outputSize !== 'number')
      throw new InvalidArgument('options.outputSize', 'number', outputSize);

    super({
      // buffering a single output chunk
      objectMode: true,
      highWaterMark: 1,
    });

    this._outputSize = outputSize || 5 * 1024 * 1024; // 5MB

    if (source instanceof ArrayBuffer || source instanceof Uint8Array) { // also catches Buffer
      this._initBinaryMode(source);
    } else {
      this._initFileMode(source);
github TankerHQ / sdk-js / packages / core / src / Tanker.js View on Github external
async upload(clearData: Data, options?: $Shape & ProgressOptions> = {}): Promise {
    this.assert(statuses.READY, 'upload a file');
    assertDataType(clearData, 'clearData');

    const outputOptions = extractOutputOptions(options, clearData);
    const progressOptions = extractProgressOptions(options);
    const sharingOptions = extractSharingOptions(options);

    return this._session.upload(clearData, sharingOptions, outputOptions, progressOptions);
  }
github TankerHQ / sdk-js / packages / core / src / Tanker.js View on Github external
async encryptData(clearData: Data, options?: $Shape & ProgressOptions> = {}): Promise {
    this.assert(statuses.READY, 'encrypt data');
    assertDataType(clearData, 'clearData');

    const outputOptions = extractOutputOptions(options, clearData);
    const progressOptions = extractProgressOptions(options);
    const sharingOptions = extractSharingOptions(options);

    return this._session.encryptData(clearData, sharingOptions, outputOptions, progressOptions);
  }
github TankerHQ / sdk-js / packages / core / src / Tanker.js View on Github external
async decryptData(encryptedData: Data, options?: $Shape & ProgressOptions> = {}): Promise {
    this.assert(statuses.READY, 'decrypt data');
    assertDataType(encryptedData, 'encryptedData');

    const outputOptions = extractOutputOptions(options, encryptedData);
    const progressOptions = extractProgressOptions(options);

    return this._session.decryptData(encryptedData, outputOptions, progressOptions);
  }
github TankerHQ / sdk-js / packages / core / src / Tanker.js View on Github external
async getResourceId(encryptedData: Uint8Array): Promise {
    this.assert(statuses.READY, 'get a resource id');
    assertDataType(encryptedData, 'encryptedData');

    const castEncryptedData = await castData(encryptedData, { type: Uint8Array }, SAFE_EXTRACTION_LENGTH);

    const encryption = extractEncryptionFormat(castEncryptedData);

    return utils.toBase64(encryption.extractResourceId(castEncryptedData));
  }

@tanker/types

Tanker SDK (types)

Apache-2.0
Latest version published 5 months ago

Package Health Score

65 / 100
Full package analysis

Similar packages