@novasamatech/host-api 0.5.4 → 0.6.0
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.
- package/README.md +27 -2
- package/dist/hostApi.d.ts +2 -1
- package/dist/hostApi.js +117 -34
- package/dist/index.d.ts +8 -2
- package/dist/index.js +8 -2
- package/dist/protocol/impl.d.ts +80 -59
- package/dist/protocol/impl.js +64 -36
- package/dist/protocol/messageCodec.d.ts +307 -177
- package/dist/protocol/v1/accounts.d.ts +3 -0
- package/dist/protocol/v1/accounts.js +5 -1
- package/dist/protocol/v1/chat.d.ts +72 -31
- package/dist/protocol/v1/chat.js +9 -0
- package/dist/protocol/v1/customRenderer.d.ts +143 -0
- package/dist/protocol/v1/customRenderer.js +82 -0
- package/dist/protocol/v1/devicePermission.d.ts +5 -0
- package/dist/protocol/v1/devicePermission.js +6 -0
- package/dist/protocol/v1/localStorage.d.ts +31 -0
- package/dist/protocol/v1/localStorage.js +17 -0
- package/dist/protocol/v1/navigation.d.ts +21 -0
- package/dist/protocol/v1/navigation.js +9 -0
- package/dist/protocol/v1/notification.d.ts +11 -0
- package/dist/protocol/v1/notification.js +8 -0
- package/dist/protocol/v1/preimage.d.ts +24 -0
- package/dist/protocol/v1/preimage.js +12 -0
- package/dist/protocol/v1/remotePermission.d.ts +17 -0
- package/dist/protocol/v1/remotePermission.js +9 -0
- package/dist/protocol/v1/sign.js +5 -4
- package/dist/protocol/v1/statementStore.d.ts +0 -36
- package/dist/protocol/v1/statementStore.js +1 -3
- package/dist/transport.js +12 -4
- package/package.json +3 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const PreimageKey: import("scale-ts").Codec<`0x${string}`>;
|
|
2
|
+
export declare const PreimageValue: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
3
|
+
export declare const PreimageLookupSubscribeV1_start: import("scale-ts").Codec<`0x${string}`>;
|
|
4
|
+
export declare const PreimageLookupSubscribeV1_receive: import("scale-ts").Codec<Uint8Array<ArrayBufferLike> | null>;
|
|
5
|
+
export declare const PreimageSubmitErr: [import("scale-ts").Encoder<import("@novasamatech/scale").CodecError<{
|
|
6
|
+
reason: string;
|
|
7
|
+
}, "PreimageSubmitErr::Unknown">>, import("scale-ts").Decoder<import("@novasamatech/scale").CodecError<{
|
|
8
|
+
reason: string;
|
|
9
|
+
}, "PreimageSubmitErr::Unknown">>] & {
|
|
10
|
+
enc: import("scale-ts").Encoder<import("@novasamatech/scale").CodecError<{
|
|
11
|
+
reason: string;
|
|
12
|
+
}, "PreimageSubmitErr::Unknown">>;
|
|
13
|
+
dec: import("scale-ts").Decoder<import("@novasamatech/scale").CodecError<{
|
|
14
|
+
reason: string;
|
|
15
|
+
}, "PreimageSubmitErr::Unknown">>;
|
|
16
|
+
} & {
|
|
17
|
+
readonly Unknown: import("@novasamatech/scale").ErrCodec<{
|
|
18
|
+
reason: string;
|
|
19
|
+
}, "PreimageSubmitErr::Unknown">;
|
|
20
|
+
};
|
|
21
|
+
export declare const PreimageSubmitV1_request: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>>;
|
|
22
|
+
export declare const PreimageSubmitV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<`0x${string}`, import("@novasamatech/scale").CodecError<{
|
|
23
|
+
reason: string;
|
|
24
|
+
}, "PreimageSubmitErr::Unknown">>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ErrEnum, Hex, Nullable } from '@novasamatech/scale';
|
|
2
|
+
import { Bytes, Result } from 'scale-ts';
|
|
3
|
+
import { GenericErr } from '../commonCodecs.js';
|
|
4
|
+
export const PreimageKey = Hex();
|
|
5
|
+
export const PreimageValue = Bytes();
|
|
6
|
+
export const PreimageLookupSubscribeV1_start = PreimageKey;
|
|
7
|
+
export const PreimageLookupSubscribeV1_receive = Nullable(PreimageValue);
|
|
8
|
+
export const PreimageSubmitErr = ErrEnum('PreimageSubmitErr', {
|
|
9
|
+
Unknown: [GenericErr, 'Unknown error'],
|
|
10
|
+
});
|
|
11
|
+
export const PreimageSubmitV1_request = PreimageValue;
|
|
12
|
+
export const PreimageSubmitV1_response = Result(PreimageKey, PreimageSubmitErr);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const RemotePermissionRequest: import("scale-ts").Codec<{
|
|
2
|
+
tag: "ExternalRequest";
|
|
3
|
+
value: string;
|
|
4
|
+
} | {
|
|
5
|
+
tag: "TransactionSubmit";
|
|
6
|
+
value: undefined;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const RemotePermissionV1_request: import("scale-ts").Codec<{
|
|
9
|
+
tag: "ExternalRequest";
|
|
10
|
+
value: string;
|
|
11
|
+
} | {
|
|
12
|
+
tag: "TransactionSubmit";
|
|
13
|
+
value: undefined;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const RemotePermissionV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<boolean, import("@novasamatech/scale").CodecError<{
|
|
16
|
+
reason: string;
|
|
17
|
+
}, "GenericError">>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Enum } from '@novasamatech/scale';
|
|
2
|
+
import { Result, _void, bool, str } from 'scale-ts';
|
|
3
|
+
import { GenericError } from '../commonCodecs.js';
|
|
4
|
+
export const RemotePermissionRequest = Enum({
|
|
5
|
+
ExternalRequest: str, // URL
|
|
6
|
+
TransactionSubmit: _void,
|
|
7
|
+
});
|
|
8
|
+
export const RemotePermissionV1_request = RemotePermissionRequest;
|
|
9
|
+
export const RemotePermissionV1_response = Result(bool, GenericError);
|
package/dist/protocol/v1/sign.js
CHANGED
|
@@ -13,12 +13,13 @@ export const SigningResult = Struct({
|
|
|
13
13
|
signedTransaction: Option(Hex()),
|
|
14
14
|
});
|
|
15
15
|
// sign raw
|
|
16
|
+
const RawPayload = Enum({
|
|
17
|
+
Bytes: Bytes(),
|
|
18
|
+
Payload: str,
|
|
19
|
+
});
|
|
16
20
|
const SigningRawPayload = Struct({
|
|
17
21
|
address: str,
|
|
18
|
-
data:
|
|
19
|
-
Bytes: Bytes(),
|
|
20
|
-
Payload: str,
|
|
21
|
-
}),
|
|
22
|
+
data: RawPayload,
|
|
22
23
|
});
|
|
23
24
|
export const SignRawV1_request = SigningRawPayload;
|
|
24
25
|
export const SignRawV1_response = Result(SigningResult, SigningErr);
|
|
@@ -67,42 +67,6 @@ export declare const SignedStatement: import("scale-ts").Codec<{
|
|
|
67
67
|
topics: Uint8Array<ArrayBufferLike>[];
|
|
68
68
|
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
69
69
|
}>;
|
|
70
|
-
export declare const StatementStoreQueryV1_request: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>[]>;
|
|
71
|
-
export declare const StatementStoreQueryV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<{
|
|
72
|
-
proof: {
|
|
73
|
-
tag: "Sr25519";
|
|
74
|
-
value: {
|
|
75
|
-
signature: Uint8Array<ArrayBufferLike>;
|
|
76
|
-
signer: Uint8Array<ArrayBufferLike>;
|
|
77
|
-
};
|
|
78
|
-
} | {
|
|
79
|
-
tag: "Ed25519";
|
|
80
|
-
value: {
|
|
81
|
-
signature: Uint8Array<ArrayBufferLike>;
|
|
82
|
-
signer: Uint8Array<ArrayBufferLike>;
|
|
83
|
-
};
|
|
84
|
-
} | {
|
|
85
|
-
tag: "Ecdsa";
|
|
86
|
-
value: {
|
|
87
|
-
signature: Uint8Array<ArrayBufferLike>;
|
|
88
|
-
signer: Uint8Array<ArrayBufferLike>;
|
|
89
|
-
};
|
|
90
|
-
} | {
|
|
91
|
-
tag: "OnChain";
|
|
92
|
-
value: {
|
|
93
|
-
who: Uint8Array<ArrayBufferLike>;
|
|
94
|
-
blockHash: Uint8Array<ArrayBufferLike>;
|
|
95
|
-
event: bigint;
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
decryptionKey: Uint8Array<ArrayBufferLike> | undefined;
|
|
99
|
-
priority: number | undefined;
|
|
100
|
-
channel: Uint8Array<ArrayBufferLike> | undefined;
|
|
101
|
-
topics: Uint8Array<ArrayBufferLike>[];
|
|
102
|
-
data: Uint8Array<ArrayBufferLike> | undefined;
|
|
103
|
-
}[], import("@novasamatech/scale").CodecError<{
|
|
104
|
-
reason: string;
|
|
105
|
-
}, "GenericError">>>;
|
|
106
70
|
export declare const StatementStoreSubscribeV1_start: import("scale-ts").Codec<Uint8Array<ArrayBufferLike>[]>;
|
|
107
71
|
export declare const StatementStoreSubscribeV1_receive: import("scale-ts").Codec<{
|
|
108
72
|
proof: {
|
|
@@ -46,9 +46,7 @@ export const SignedStatement = Struct({
|
|
|
46
46
|
topics: Vector(Topic),
|
|
47
47
|
data: Option(Bytes()),
|
|
48
48
|
});
|
|
49
|
-
//
|
|
50
|
-
export const StatementStoreQueryV1_request = Vector(Topic);
|
|
51
|
-
export const StatementStoreQueryV1_response = Result(Vector(SignedStatement), GenericError);
|
|
49
|
+
// subscription
|
|
52
50
|
export const StatementStoreSubscribeV1_start = Vector(Topic);
|
|
53
51
|
export const StatementStoreSubscribeV1_receive = Vector(SignedStatement);
|
|
54
52
|
// creating proof
|
package/dist/transport.js
CHANGED
|
@@ -62,7 +62,7 @@ export function createTransport(provider) {
|
|
|
62
62
|
handshakeAbortController.signal.removeEventListener('abort', unsubscribe);
|
|
63
63
|
};
|
|
64
64
|
return new Promise(resolve => {
|
|
65
|
-
const unsubscribe = transport.listenMessages('
|
|
65
|
+
const unsubscribe = transport.listenMessages('host_handshake_response', responseId => {
|
|
66
66
|
if (responseId === id) {
|
|
67
67
|
cleanup(interval, unsubscribe);
|
|
68
68
|
resolved = true;
|
|
@@ -76,7 +76,7 @@ export function createTransport(provider) {
|
|
|
76
76
|
resolve(false);
|
|
77
77
|
return;
|
|
78
78
|
}
|
|
79
|
-
transport.postMessage(id, enumValue('
|
|
79
|
+
transport.postMessage(id, enumValue('host_handshake_request', enumValue('v1', codecVersion)));
|
|
80
80
|
}, HANDSHAKE_INTERVAL);
|
|
81
81
|
}).then(success => {
|
|
82
82
|
if (!success && !resolved) {
|
|
@@ -181,13 +181,21 @@ export function createTransport(provider) {
|
|
|
181
181
|
const unsubStart = transport.listenMessages(startAction, (requestId, payload) => {
|
|
182
182
|
if (subscriptions.has(requestId))
|
|
183
183
|
return;
|
|
184
|
+
let interrupted = false;
|
|
184
185
|
const unsubscribe = handler(payload.value, value => {
|
|
185
186
|
const receivePayload = enumValue(receiveAction, value);
|
|
186
187
|
transport.postMessage(requestId, receivePayload);
|
|
187
188
|
}, () => {
|
|
189
|
+
interrupted = true;
|
|
190
|
+
subscriptions.delete(requestId);
|
|
188
191
|
transport.postMessage(requestId, enumValue(interruptAction, undefined));
|
|
189
192
|
});
|
|
190
|
-
|
|
193
|
+
if (interrupted) {
|
|
194
|
+
unsubscribe();
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
subscriptions.set(requestId, unsubscribe);
|
|
198
|
+
}
|
|
191
199
|
});
|
|
192
200
|
const unsubStop = transport.listenMessages(stopAction, requestId => {
|
|
193
201
|
subscriptions.get(requestId)?.();
|
|
@@ -233,7 +241,7 @@ export function createTransport(provider) {
|
|
|
233
241
|
},
|
|
234
242
|
};
|
|
235
243
|
if (provider.isCorrectEnvironment()) {
|
|
236
|
-
transport.handleRequest('
|
|
244
|
+
transport.handleRequest('host_handshake', async (version) => {
|
|
237
245
|
switch (version.tag) {
|
|
238
246
|
case 'v1': {
|
|
239
247
|
codecVersion = version.value;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"description": "Host API: transport implementation for host - product integration.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/Polkadot-Community-Foundation/triangle-js-sdks.git"
|
|
10
10
|
},
|
|
11
11
|
"main": "dist/index.js",
|
|
12
12
|
"exports": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@novasamatech/scale": "0.
|
|
24
|
+
"@novasamatech/scale": "0.6.0",
|
|
25
25
|
"@polkadot-api/utils": "^0.2.0",
|
|
26
26
|
"nanoevents": "9.1.0",
|
|
27
27
|
"nanoid": "5.1.6",
|