@novasamatech/host-papp 0.5.0-15 → 0.5.0-17

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.
@@ -31,10 +31,10 @@ export declare const RemoteMessageCodec: import("scale-ts").Codec<{
31
31
  tag: "SignResponse";
32
32
  value: {
33
33
  respondingTo: string;
34
- payload: {
34
+ payload: import("scale-ts").ResultPayload<{
35
35
  signature: Uint8Array<ArrayBufferLike>;
36
36
  signedTransaction: Uint8Array<ArrayBufferLike> | undefined;
37
- };
37
+ }, string>;
38
38
  };
39
39
  };
40
40
  };
@@ -1,9 +1,14 @@
1
1
  import type { CodecType } from 'scale-ts';
2
+ export type SignPayloadResponseData = CodecType<typeof SignPayloadResponseDataCodec>;
3
+ export declare const SignPayloadResponseDataCodec: import("scale-ts").Codec<{
4
+ signature: Uint8Array<ArrayBufferLike>;
5
+ signedTransaction: Uint8Array<ArrayBufferLike> | undefined;
6
+ }>;
2
7
  export type SignPayloadResponse = CodecType<typeof SignPayloadResponseCodec>;
3
8
  export declare const SignPayloadResponseCodec: import("scale-ts").Codec<{
4
9
  respondingTo: string;
5
- payload: {
10
+ payload: import("scale-ts").ResultPayload<{
6
11
  signature: Uint8Array<ArrayBufferLike>;
7
12
  signedTransaction: Uint8Array<ArrayBufferLike> | undefined;
8
- };
13
+ }, string>;
9
14
  }>;
@@ -1,9 +1,10 @@
1
- import { Bytes, Option, Struct, str } from 'scale-ts';
1
+ import { Bytes, Option, Result, Struct, str } from 'scale-ts';
2
+ export const SignPayloadResponseDataCodec = Struct({
3
+ signature: Bytes(),
4
+ signedTransaction: Option(Bytes()),
5
+ });
2
6
  export const SignPayloadResponseCodec = Struct({
3
7
  // referencing to RemoteMessage.messageId
4
8
  respondingTo: str,
5
- payload: Struct({
6
- signature: Bytes(),
7
- signedTransaction: Option(Bytes()),
8
- }),
9
+ payload: Result(SignPayloadResponseDataCodec, str),
9
10
  });
@@ -6,10 +6,10 @@ import type { Callback } from '../../types.js';
6
6
  import type { StoredUserSession } from '../userSessionRepository.js';
7
7
  import { RemoteMessageCodec } from './scale/remoteMessage.js';
8
8
  import type { SignPayloadRequest } from './scale/signPayloadRequest.js';
9
- import type { SignPayloadResponse } from './scale/signPayloadResponse.js';
9
+ import type { SignPayloadResponseData } from './scale/signPayloadResponse.js';
10
10
  export type UserSession = StoredUserSession & {
11
11
  sendDisconnectMessage(): ResultAsync<void, Error>;
12
- signPayload(payload: SignPayloadRequest): ResultAsync<SignPayloadResponse['payload'], Error>;
12
+ signPayload(payload: SignPayloadRequest): ResultAsync<SignPayloadResponseData, Error>;
13
13
  subscribe(callback: Callback<CodecType<typeof RemoteMessageCodec>, ResultAsync<boolean, Error>>): VoidFunction;
14
14
  dispose(): void;
15
15
  };
@@ -52,7 +52,12 @@ export function createUserSession({ userSession, statementStore, encryption, sto
52
52
  case 'v1': {
53
53
  switch (data.value.tag) {
54
54
  case 'SignResponse':
55
- return ok(data.value.value.payload);
55
+ if (data.value.value.payload.success) {
56
+ return ok(data.value.value.payload.value);
57
+ }
58
+ else {
59
+ return err(new Error(data.value.value.payload.value));
60
+ }
56
61
  default:
57
62
  return err(new Error(`Incorrect sign response: ${data.value.tag}`));
58
63
  }
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-15",
4
+ "version": "0.5.0-17",
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-15",
32
- "@novasamatech/statement-store": "0.5.0-15",
33
- "@novasamatech/storage-adapter": "0.5.0-15",
31
+ "@novasamatech/host-api": "0.5.0-17",
32
+ "@novasamatech/statement-store": "0.5.0-17",
33
+ "@novasamatech/storage-adapter": "0.5.0-17",
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",