How to use the @wireapp/protocol-messaging.Asset function in @wireapp/protocol-messaging

To help you get started, we’ve selected a few @wireapp/protocol-messaging 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 wireapp / wire-webapp / test / unit_tests / cryptography / CryptographyMapperSpec.js View on Github external
it('resolves with a mapped original asset message with audio meta data', () => {
      const audio_meta_data = new Asset.AudioMetaData({
        durationInMillis: 3 * 1000,
        normalizedLoudness: new Uint8Array([1, 2, 3]),
      });
      const original_asset = new Asset.Original({
        audio: audio_meta_data,
        mimeType: 'audio/mp3',
        name: 'foo.mp3',
        size: 1024,
      });
      const asset = new Asset({original: original_asset});

      const generic_message = new GenericMessage({
        [GENERIC_MESSAGE_TYPE.ASSET]: asset,
        messageId: createRandomUuid(),
      });

      return mapper.mapGenericMessage(generic_message, event).then(event_json => {
        expect(isObject(event_json)).toBeTruthy();
        expect(event_json.type).toBe(ClientEvent.CONVERSATION.ASSET_ADD);
        expect(event_json.conversation).toBe(event.conversation);
        expect(event_json.from).toBe(event.from);
        expect(event_json.time).toBe(event.time);
        expect(event_json.id).toBe(generic_message.messageId);
        expect(event_json.data.content_length).toEqual(
          original_asset.size.toNumber ? original_asset.size.toNumber() : original_asset.size,
        );
github wireapp / wire-webapp / src / script / assets / AssetService.js View on Github external
return this.postAsset(new Uint8Array(cipherText), options, xhrAccessorFunction).then(({key, token}) => {
        const assetRemoteData = new Asset.RemoteData({
          assetId: key,
          assetToken: token,
          otrKey: new Uint8Array(keyBytes),
          sha256: new Uint8Array(sha256),
        });

        const protoAsset = new Asset({
          [z.cryptography.PROTO_MESSAGE_TYPE.ASSET_UPLOADED]: assetRemoteData,
          [z.cryptography.PROTO_MESSAGE_TYPE.EXPECTS_READ_CONFIRMATION]: options.expectsReadConfirmation || false,
        });

        return protoAsset;
      });
    });
github wireapp / wire-webapp / src / script / assets / AssetService.ts View on Github external
return this.postAsset(new Uint8Array(cipherText), options, xhrAccessorFunction).then(({key, token}) => {
        const assetRemoteData = new Asset.RemoteData({
          assetId: key,
          assetToken: token,
          otrKey: new Uint8Array(keyBytes),
          sha256: new Uint8Array(sha256),
        });

        const protoAsset = new Asset({
          [PROTO_MESSAGE_TYPE.ASSET_UPLOADED]: assetRemoteData,
          [PROTO_MESSAGE_TYPE.EXPECTS_READ_CONFIRMATION]: options.expectsReadConfirmation,
          [PROTO_MESSAGE_TYPE.LEGAL_HOLD_STATUS]: options.legalHoldStatus,
        });

        return protoAsset;
      });
    });