@novasamatech/host-papp 0.5.0-10 → 0.5.0-12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+ import type { CodecType } from 'scale-ts';
2
+ export type RemoteMessage = CodecType<typeof RemoteMessageCodec>;
1
3
  export declare const RemoteMessageCodec: import("scale-ts").Codec<{
2
4
  messageId: string;
3
5
  data: {
@@ -29,11 +31,8 @@ export declare const RemoteMessageCodec: import("scale-ts").Codec<{
29
31
  value: {
30
32
  respondingTo: string;
31
33
  payload: {
32
- tag: "signature";
33
- value: Uint8Array<ArrayBufferLike>;
34
- } | {
35
- tag: "signedTransaction";
36
- value: Uint8Array<ArrayBufferLike>;
34
+ signature: Uint8Array<ArrayBufferLike>;
35
+ signedTransaction: Uint8Array<ArrayBufferLike>;
37
36
  };
38
37
  };
39
38
  };
@@ -3,10 +3,7 @@ export type SignPayloadResponse = CodecType<typeof SignPayloadResponseCodec>;
3
3
  export declare const SignPayloadResponseCodec: import("scale-ts").Codec<{
4
4
  respondingTo: string;
5
5
  payload: {
6
- tag: "signature";
7
- value: Uint8Array<ArrayBufferLike>;
8
- } | {
9
- tag: "signedTransaction";
10
- value: Uint8Array<ArrayBufferLike>;
6
+ signature: Uint8Array<ArrayBufferLike>;
7
+ signedTransaction: Uint8Array<ArrayBufferLike>;
11
8
  };
12
9
  }>;
@@ -1,8 +1,8 @@
1
- import { Bytes, Enum, Struct, str } from 'scale-ts';
1
+ import { Bytes, Struct, str } from 'scale-ts';
2
2
  export const SignPayloadResponseCodec = Struct({
3
3
  // referencing to RemoteMessage.messageId
4
4
  respondingTo: str,
5
- payload: Enum({
5
+ payload: Struct({
6
6
  signature: Bytes(),
7
7
  signedTransaction: Bytes(),
8
8
  }),
@@ -9,7 +9,7 @@ import type { SignPayloadRequest } from './scale/signPayloadRequest.js';
9
9
  import type { SignPayloadResponse } from './scale/signPayloadResponse.js';
10
10
  export type UserSession = StoredUserSession & {
11
11
  sendDisconnectMessage(): ResultAsync<void, Error>;
12
- signPayload(payload: SignPayloadRequest): ResultAsync<SignPayloadResponse, Error>;
12
+ signPayload(payload: SignPayloadRequest): ResultAsync<SignPayloadResponse['payload'], Error>;
13
13
  subscribe(callback: Callback<CodecType<typeof RemoteMessageCodec>, ResultAsync<boolean, Error>>): VoidFunction;
14
14
  dispose(): void;
15
15
  };
@@ -39,15 +39,20 @@ export function createUserSession({ userSession, statementStore, encryption, sto
39
39
  },
40
40
  },
41
41
  });
42
+ const responseFilter = (message) => {
43
+ return (message.data.tag === 'v1' &&
44
+ message.data.value.tag === 'SignResponse' &&
45
+ message.data.value.value.respondingTo === messageId);
46
+ };
42
47
  return request
43
- .andThen(() => session.waitForRequestMessage(RemoteMessageCodec, message => message.messageId === messageId))
48
+ .andThen(() => session.waitForRequestMessage(RemoteMessageCodec, responseFilter))
44
49
  .andThen(message => {
45
50
  const { data } = message.payload;
46
51
  switch (data.tag) {
47
52
  case 'v1': {
48
53
  switch (data.value.tag) {
49
54
  case 'SignResponse':
50
- return ok(data.value.value);
55
+ return ok(data.value.value.payload);
51
56
  default:
52
57
  return err(new Error(`Incorrect sign response: ${data.value.tag}`));
53
58
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-papp",
3
3
  "type": "module",
4
- "version": "0.5.0-10",
4
+ "version": "0.5.0-12",
5
5
  "description": "Polkadot app integration",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -28,9 +28,9 @@
28
28
  "@noble/ciphers": "2.1.1",
29
29
  "@noble/curves": "2.0.1",
30
30
  "@noble/hashes": "2.0.1",
31
- "@novasamatech/host-api": "0.5.0-10",
32
- "@novasamatech/statement-store": "0.5.0-10",
33
- "@novasamatech/storage-adapter": "0.5.0-10",
31
+ "@novasamatech/host-api": "0.5.0-12",
32
+ "@novasamatech/statement-store": "0.5.0-12",
33
+ "@novasamatech/storage-adapter": "0.5.0-12",
34
34
  "@polkadot-api/substrate-bindings": "^0.16.5",
35
35
  "@polkadot-labs/hdkd-helpers": "^0.0.27",
36
36
  "@scure/sr25519": "1.0.0",