@novasamatech/host-container 0.5.4 → 0.5.5
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 +75 -12
- package/dist/createContainer.js +96 -36
- package/dist/types.d.ts +26 -21
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -49,10 +49,10 @@ document.body.appendChild(webview);
|
|
|
49
49
|
|
|
50
50
|
## API reference
|
|
51
51
|
|
|
52
|
-
###
|
|
52
|
+
### handleFeatureSupported
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
|
-
container.
|
|
55
|
+
container.handleFeatureSupported((params, { ok, err }) => {
|
|
56
56
|
if (params.tag === 'Chat') {
|
|
57
57
|
return ok(supportedChains.has(params.value));
|
|
58
58
|
}
|
|
@@ -60,6 +60,48 @@ container.handleFeature((params, { ok, err }) => {
|
|
|
60
60
|
});
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
### handleDevicePermission
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
container.handleDevicePermission(async (request, { ok, err }) => {
|
|
67
|
+
const granted = await requestDevicePermission(request);
|
|
68
|
+
return ok(granted);
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### handlePermission
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
container.handlePermission(async (request, { ok, err }) => {
|
|
76
|
+
if (request.tag === 'ExternalRequest') {
|
|
77
|
+
const allowed = await checkExternalRequestPermission(request.value);
|
|
78
|
+
return ok(allowed);
|
|
79
|
+
}
|
|
80
|
+
if (request.tag === 'TransactionSubmit') {
|
|
81
|
+
return ok(true);
|
|
82
|
+
}
|
|
83
|
+
return ok(false);
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### handlePushNotification
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
container.handlePushNotification(async (notification, { ok, err }) => {
|
|
91
|
+
await showNotification(notification);
|
|
92
|
+
return ok(undefined);
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### handleNavigateTo
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
container.handleNavigateTo(async (url, { ok, err }) => {
|
|
100
|
+
await navigate(url);
|
|
101
|
+
return ok(undefined);
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
63
105
|
### handleLocalStorageRead
|
|
64
106
|
|
|
65
107
|
```ts
|
|
@@ -198,7 +240,14 @@ container.handleChatCreateRoom(async (room, { ok, err }) => {
|
|
|
198
240
|
});
|
|
199
241
|
```
|
|
200
242
|
|
|
201
|
-
|
|
243
|
+
### handleChatBotRegistration
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
container.handleChatBotRegistration(async (bot, { ok, err }) => {
|
|
247
|
+
await chatService.registerBot(bot);
|
|
248
|
+
return ok(undefined);
|
|
249
|
+
});
|
|
250
|
+
```
|
|
202
251
|
|
|
203
252
|
### handleChatListSubscribe
|
|
204
253
|
|
|
@@ -229,15 +278,6 @@ container.handleChatActionSubscribe((_, send, interrupt) => {
|
|
|
229
278
|
});
|
|
230
279
|
```
|
|
231
280
|
|
|
232
|
-
### handleStatementStoreQuery
|
|
233
|
-
|
|
234
|
-
```ts
|
|
235
|
-
container.handleStatementStoreQuery(async (query, { ok, err }) => {
|
|
236
|
-
const statements = await statementStore.query(query);
|
|
237
|
-
return ok(statements);
|
|
238
|
-
});
|
|
239
|
-
```
|
|
240
|
-
|
|
241
281
|
### handleStatementStoreSubscribe
|
|
242
282
|
|
|
243
283
|
```ts
|
|
@@ -274,6 +314,29 @@ container.handleStatementStoreSubmit(async (statement, { ok, err }) => {
|
|
|
274
314
|
});
|
|
275
315
|
```
|
|
276
316
|
|
|
317
|
+
### handlePreimageLookupSubscribe
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
container.handlePreimageLookupSubscribe((key, send, interrupt) => {
|
|
321
|
+
const listener = (value) => send(value);
|
|
322
|
+
preimageService.subscribe(key, listener);
|
|
323
|
+
return () => preimageService.unsubscribe(key, listener);
|
|
324
|
+
});
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### handlePreimageSubmit
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
container.handlePreimageSubmit(async (preimage, { ok, err }) => {
|
|
331
|
+
try {
|
|
332
|
+
const key = await preimageService.submit(preimage);
|
|
333
|
+
return ok(key);
|
|
334
|
+
} catch (e) {
|
|
335
|
+
return err({ tag: 'Unknown', value: { reason: e.message } });
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
```
|
|
339
|
+
|
|
277
340
|
### handleChainConnection
|
|
278
341
|
|
|
279
342
|
```ts
|
package/dist/createContainer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChatBotRegistrationErr, ChatMessagePostingErr, ChatRoomRegistrationErr, CreateProofErr, CreateTransactionErr, GenericError, RequestCredentialsErr, SigningErr, StatementProofErr, StorageErr, assertEnumVariant, createTransport, enumValue, isEnumVariant, resultErr, resultOk, } from '@novasamatech/host-api';
|
|
1
|
+
import { ChatBotRegistrationErr, ChatMessagePostingErr, ChatRoomRegistrationErr, CreateProofErr, CreateTransactionErr, GenericError, NavigateToErr, PreimageSubmitErr, RequestCredentialsErr, SigningErr, StatementProofErr, StorageErr, assertEnumVariant, createTransport, enumValue, isEnumVariant, resultErr, resultOk, } from '@novasamatech/host-api';
|
|
2
2
|
import { err, errAsync, ok, okAsync } from 'neverthrow';
|
|
3
3
|
const UNSUPPORTED_MESSAGE_FORMAT_ERROR = 'Unsupported message format';
|
|
4
4
|
function guardVersion(value, tag, error) {
|
|
@@ -17,9 +17,9 @@ export function createContainer(provider) {
|
|
|
17
17
|
transport.isReady();
|
|
18
18
|
}
|
|
19
19
|
return {
|
|
20
|
-
|
|
20
|
+
handleFeatureSupported(handler) {
|
|
21
21
|
init();
|
|
22
|
-
return transport.handleRequest('
|
|
22
|
+
return transport.handleRequest('host_feature_supported', async (message) => {
|
|
23
23
|
const version = 'v1';
|
|
24
24
|
const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
25
25
|
return guardVersion(message, version, error)
|
|
@@ -29,9 +29,57 @@ export function createContainer(provider) {
|
|
|
29
29
|
.unwrapOr(enumValue(version, resultErr(error)));
|
|
30
30
|
});
|
|
31
31
|
},
|
|
32
|
+
handleDevicePermission(handler) {
|
|
33
|
+
init();
|
|
34
|
+
return transport.handleRequest('host_device_permission', async (message) => {
|
|
35
|
+
const version = 'v1';
|
|
36
|
+
const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
37
|
+
return guardVersion(message, version, error)
|
|
38
|
+
.asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
|
|
39
|
+
.andThen(r => r.map(r => enumValue(version, resultOk(r))))
|
|
40
|
+
.orElse(r => ok(enumValue(version, resultErr(r))))
|
|
41
|
+
.unwrapOr(enumValue(version, resultErr(error)));
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
handlePermission(handler) {
|
|
45
|
+
init();
|
|
46
|
+
return transport.handleRequest('remote_permission', async (message) => {
|
|
47
|
+
const version = 'v1';
|
|
48
|
+
const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
49
|
+
return guardVersion(message, version, error)
|
|
50
|
+
.asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
|
|
51
|
+
.andThen(r => r.map(r => enumValue(version, resultOk(r))))
|
|
52
|
+
.orElse(r => ok(enumValue(version, resultErr(r))))
|
|
53
|
+
.unwrapOr(enumValue(version, resultErr(error)));
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
handlePushNotification(handler) {
|
|
57
|
+
init();
|
|
58
|
+
return transport.handleRequest('host_push_notification', async (message) => {
|
|
59
|
+
const version = 'v1';
|
|
60
|
+
const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
61
|
+
return guardVersion(message, version, error)
|
|
62
|
+
.asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
|
|
63
|
+
.andThen(r => r.map(r => enumValue(version, resultOk(r))))
|
|
64
|
+
.orElse(r => ok(enumValue(version, resultErr(r))))
|
|
65
|
+
.unwrapOr(enumValue(version, resultErr(error)));
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
handleNavigateTo(handler) {
|
|
69
|
+
init();
|
|
70
|
+
return transport.handleRequest('host_navigate_to', async (message) => {
|
|
71
|
+
const version = 'v1';
|
|
72
|
+
const error = new NavigateToErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
73
|
+
return guardVersion(message, version, error)
|
|
74
|
+
.asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
|
|
75
|
+
.andThen(r => r.map(r => enumValue(version, resultOk(r))))
|
|
76
|
+
.orElse(r => ok(enumValue(version, resultErr(r))))
|
|
77
|
+
.unwrapOr(enumValue(version, resultErr(error)));
|
|
78
|
+
});
|
|
79
|
+
},
|
|
32
80
|
handleLocalStorageRead(handler) {
|
|
33
81
|
init();
|
|
34
|
-
return transport.handleRequest('
|
|
82
|
+
return transport.handleRequest('host_local_storage_read', async (message) => {
|
|
35
83
|
const version = 'v1';
|
|
36
84
|
const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
37
85
|
return guardVersion(message, version, error)
|
|
@@ -43,7 +91,7 @@ export function createContainer(provider) {
|
|
|
43
91
|
},
|
|
44
92
|
handleLocalStorageWrite(handler) {
|
|
45
93
|
init();
|
|
46
|
-
return transport.handleRequest('
|
|
94
|
+
return transport.handleRequest('host_local_storage_write', async (message) => {
|
|
47
95
|
const version = 'v1';
|
|
48
96
|
const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
49
97
|
return guardVersion(message, version, error)
|
|
@@ -55,7 +103,7 @@ export function createContainer(provider) {
|
|
|
55
103
|
},
|
|
56
104
|
handleLocalStorageClear(handler) {
|
|
57
105
|
init();
|
|
58
|
-
return transport.handleRequest('
|
|
106
|
+
return transport.handleRequest('host_local_storage_clear', async (params) => {
|
|
59
107
|
const version = 'v1';
|
|
60
108
|
const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
61
109
|
return guardVersion(params, version, error)
|
|
@@ -67,7 +115,7 @@ export function createContainer(provider) {
|
|
|
67
115
|
},
|
|
68
116
|
handleAccountGet(handler) {
|
|
69
117
|
init();
|
|
70
|
-
return transport.handleRequest('
|
|
118
|
+
return transport.handleRequest('host_account_get', async (params) => {
|
|
71
119
|
const version = 'v1';
|
|
72
120
|
const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
73
121
|
return guardVersion(params, version, error)
|
|
@@ -79,7 +127,7 @@ export function createContainer(provider) {
|
|
|
79
127
|
},
|
|
80
128
|
handleAccountGetAlias(handler) {
|
|
81
129
|
init();
|
|
82
|
-
return transport.handleRequest('
|
|
130
|
+
return transport.handleRequest('host_account_get_alias', async (params) => {
|
|
83
131
|
const version = 'v1';
|
|
84
132
|
const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
85
133
|
return guardVersion(params, version, error)
|
|
@@ -91,7 +139,7 @@ export function createContainer(provider) {
|
|
|
91
139
|
},
|
|
92
140
|
handleAccountCreateProof(handler) {
|
|
93
141
|
init();
|
|
94
|
-
return transport.handleRequest('
|
|
142
|
+
return transport.handleRequest('host_account_create_proof', async (params) => {
|
|
95
143
|
const version = 'v1';
|
|
96
144
|
const error = new CreateProofErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
97
145
|
return guardVersion(params, version, error)
|
|
@@ -103,7 +151,7 @@ export function createContainer(provider) {
|
|
|
103
151
|
},
|
|
104
152
|
handleGetNonProductAccounts(handler) {
|
|
105
153
|
init();
|
|
106
|
-
return transport.handleRequest('
|
|
154
|
+
return transport.handleRequest('host_get_non_product_accounts', async (params) => {
|
|
107
155
|
const version = 'v1';
|
|
108
156
|
const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
109
157
|
return guardVersion(params, version, error)
|
|
@@ -115,7 +163,7 @@ export function createContainer(provider) {
|
|
|
115
163
|
},
|
|
116
164
|
handleCreateTransaction(handler) {
|
|
117
165
|
init();
|
|
118
|
-
return transport.handleRequest('
|
|
166
|
+
return transport.handleRequest('host_create_transaction', async (params) => {
|
|
119
167
|
const version = 'v1';
|
|
120
168
|
const error = new CreateTransactionErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
121
169
|
return guardVersion(params, version, error)
|
|
@@ -127,7 +175,7 @@ export function createContainer(provider) {
|
|
|
127
175
|
},
|
|
128
176
|
handleCreateTransactionWithNonProductAccount(handler) {
|
|
129
177
|
init();
|
|
130
|
-
return transport.handleRequest('
|
|
178
|
+
return transport.handleRequest('host_create_transaction_with_non_product_account', async (params) => {
|
|
131
179
|
const version = 'v1';
|
|
132
180
|
const error = new CreateTransactionErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
133
181
|
return guardVersion(params, version, error)
|
|
@@ -139,7 +187,7 @@ export function createContainer(provider) {
|
|
|
139
187
|
},
|
|
140
188
|
handleSignRaw(handler) {
|
|
141
189
|
init();
|
|
142
|
-
return transport.handleRequest('
|
|
190
|
+
return transport.handleRequest('host_sign_raw', async (params) => {
|
|
143
191
|
const version = 'v1';
|
|
144
192
|
const error = new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
145
193
|
return guardVersion(params, version, error)
|
|
@@ -151,7 +199,7 @@ export function createContainer(provider) {
|
|
|
151
199
|
},
|
|
152
200
|
handleSignPayload(handler) {
|
|
153
201
|
init();
|
|
154
|
-
return transport.handleRequest('
|
|
202
|
+
return transport.handleRequest('host_sign_payload', async (params) => {
|
|
155
203
|
const version = 'v1';
|
|
156
204
|
const error = new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
157
205
|
return guardVersion(params, version, error)
|
|
@@ -163,7 +211,7 @@ export function createContainer(provider) {
|
|
|
163
211
|
},
|
|
164
212
|
handleChatCreateRoom(handler) {
|
|
165
213
|
init();
|
|
166
|
-
return transport.handleRequest('
|
|
214
|
+
return transport.handleRequest('host_chat_create_room', async (params) => {
|
|
167
215
|
const version = 'v1';
|
|
168
216
|
const error = new ChatRoomRegistrationErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
169
217
|
return guardVersion(params, version, error)
|
|
@@ -175,7 +223,7 @@ export function createContainer(provider) {
|
|
|
175
223
|
},
|
|
176
224
|
handleChatBotRegistration(handler) {
|
|
177
225
|
init();
|
|
178
|
-
return transport.handleRequest('
|
|
226
|
+
return transport.handleRequest('host_chat_register_bot', async (params) => {
|
|
179
227
|
const version = 'v1';
|
|
180
228
|
const error = new ChatBotRegistrationErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
181
229
|
return guardVersion(params, version, error)
|
|
@@ -187,7 +235,7 @@ export function createContainer(provider) {
|
|
|
187
235
|
},
|
|
188
236
|
handleChatListSubscribe(handler) {
|
|
189
237
|
init();
|
|
190
|
-
return transport.handleSubscription('
|
|
238
|
+
return transport.handleSubscription('host_chat_list_subscribe', (params, send, interrupt) => {
|
|
191
239
|
const version = 'v1';
|
|
192
240
|
return guardVersion(params, version, null)
|
|
193
241
|
.map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
|
|
@@ -199,7 +247,7 @@ export function createContainer(provider) {
|
|
|
199
247
|
},
|
|
200
248
|
handleChatPostMessage(handler) {
|
|
201
249
|
init();
|
|
202
|
-
return transport.handleRequest('
|
|
250
|
+
return transport.handleRequest('host_chat_post_message', async (params) => {
|
|
203
251
|
const version = 'v1';
|
|
204
252
|
const error = new ChatMessagePostingErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
205
253
|
return guardVersion(params, version, error)
|
|
@@ -211,7 +259,7 @@ export function createContainer(provider) {
|
|
|
211
259
|
},
|
|
212
260
|
handleChatActionSubscribe(handler) {
|
|
213
261
|
init();
|
|
214
|
-
return transport.handleSubscription('
|
|
262
|
+
return transport.handleSubscription('host_chat_action_subscribe', (params, send, interrupt) => {
|
|
215
263
|
const version = 'v1';
|
|
216
264
|
return guardVersion(params, version, null)
|
|
217
265
|
.map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
|
|
@@ -221,21 +269,9 @@ export function createContainer(provider) {
|
|
|
221
269
|
});
|
|
222
270
|
});
|
|
223
271
|
},
|
|
224
|
-
handleStatementStoreQuery(handler) {
|
|
225
|
-
init();
|
|
226
|
-
return transport.handleRequest('statement_store_query', async (params) => {
|
|
227
|
-
const version = 'v1';
|
|
228
|
-
const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
229
|
-
return guardVersion(params, version, error)
|
|
230
|
-
.asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
|
|
231
|
-
.andThen(r => r.map(r => enumValue(version, resultOk(r))))
|
|
232
|
-
.orElse(r => ok(enumValue(version, resultErr(r))))
|
|
233
|
-
.unwrapOr(enumValue(version, resultErr(error)));
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
272
|
handleStatementStoreSubscribe(handler) {
|
|
237
273
|
init();
|
|
238
|
-
return transport.handleSubscription('
|
|
274
|
+
return transport.handleSubscription('remote_statement_store_subscribe', (params, send, interrupt) => {
|
|
239
275
|
const version = 'v1';
|
|
240
276
|
return guardVersion(params, version, null)
|
|
241
277
|
.map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
|
|
@@ -247,7 +283,7 @@ export function createContainer(provider) {
|
|
|
247
283
|
},
|
|
248
284
|
handleStatementStoreCreateProof(handler) {
|
|
249
285
|
init();
|
|
250
|
-
return transport.handleRequest('
|
|
286
|
+
return transport.handleRequest('remote_statement_store_create_proof', async (params) => {
|
|
251
287
|
const version = 'v1';
|
|
252
288
|
const error = new StatementProofErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
253
289
|
return guardVersion(params, version, error)
|
|
@@ -259,7 +295,7 @@ export function createContainer(provider) {
|
|
|
259
295
|
},
|
|
260
296
|
handleStatementStoreSubmit(handler) {
|
|
261
297
|
init();
|
|
262
|
-
return transport.handleRequest('
|
|
298
|
+
return transport.handleRequest('remote_statement_store_submit', async (params) => {
|
|
263
299
|
const version = 'v1';
|
|
264
300
|
const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
265
301
|
return guardVersion(params, version, error)
|
|
@@ -269,9 +305,33 @@ export function createContainer(provider) {
|
|
|
269
305
|
.unwrapOr(enumValue(version, resultErr(error)));
|
|
270
306
|
});
|
|
271
307
|
},
|
|
308
|
+
handlePreimageLookupSubscribe(handler) {
|
|
309
|
+
init();
|
|
310
|
+
return transport.handleSubscription('remote_preimage_lookup_subscribe', (params, send, interrupt) => {
|
|
311
|
+
const version = 'v1';
|
|
312
|
+
return guardVersion(params, version, null)
|
|
313
|
+
.map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
|
|
314
|
+
.orTee(interrupt)
|
|
315
|
+
.unwrapOr(() => {
|
|
316
|
+
/* empty */
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
handlePreimageSubmit(handler) {
|
|
321
|
+
init();
|
|
322
|
+
return transport.handleRequest('remote_preimage_submit', async (params) => {
|
|
323
|
+
const version = 'v1';
|
|
324
|
+
const error = new PreimageSubmitErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
|
|
325
|
+
return guardVersion(params, version, error)
|
|
326
|
+
.asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
|
|
327
|
+
.andThen(r => r.map(r => enumValue(version, resultOk(r))))
|
|
328
|
+
.orElse(r => ok(enumValue(version, resultErr(r))))
|
|
329
|
+
.unwrapOr(enumValue(version, resultErr(error)));
|
|
330
|
+
});
|
|
331
|
+
},
|
|
272
332
|
handleChainConnection(factory) {
|
|
273
333
|
init();
|
|
274
|
-
return transport.handleSubscription('
|
|
334
|
+
return transport.handleSubscription('host_jsonrpc_message_subscribe', (params, send) => {
|
|
275
335
|
assertEnumVariant(params, 'v1', UNSUPPORTED_MESSAGE_FORMAT_ERROR);
|
|
276
336
|
const genesisHash = params.value;
|
|
277
337
|
const provider = factory(params.value);
|
|
@@ -286,7 +346,7 @@ export function createContainer(provider) {
|
|
|
286
346
|
unsubscribeDestroy();
|
|
287
347
|
connection.disconnect();
|
|
288
348
|
});
|
|
289
|
-
const unsubRequests = transport.handleRequest('
|
|
349
|
+
const unsubRequests = transport.handleRequest('host_jsonrpc_message_send', async (message) => {
|
|
290
350
|
assertEnumVariant(message, 'v1', UNSUPPORTED_MESSAGE_FORMAT_ERROR);
|
|
291
351
|
const [requestedGenesisHash, payload] = message.value;
|
|
292
352
|
if (requestedGenesisHash === genesisHash) {
|
package/dist/types.d.ts
CHANGED
|
@@ -50,27 +50,32 @@ type InferRequestHandler<V extends string, T extends VersionedProtocolRequest> =
|
|
|
50
50
|
type InferSubscribeHandler<V extends string, T extends VersionedProtocolSubscription> = (callback: (params: WithVersion<V, Value<T['start']>>, send: (payload: WithVersion<V, Value<T['receive']>>) => void, interrupt: VoidFunction) => VoidFunction) => VoidFunction;
|
|
51
51
|
type InferHandler<V extends string, T extends VersionedProtocolRequest | VersionedProtocolSubscription> = T extends VersionedProtocolRequest ? InferRequestHandler<V, T> : T extends VersionedProtocolSubscription ? InferSubscribeHandler<V, T> : never;
|
|
52
52
|
export type Container = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
handleFeatureSupported: InferHandler<'v1', HostApiProtocol['host_feature_supported']>;
|
|
54
|
+
handleDevicePermission: InferHandler<'v1', HostApiProtocol['host_device_permission']>;
|
|
55
|
+
handlePermission: InferHandler<'v1', HostApiProtocol['remote_permission']>;
|
|
56
|
+
handlePushNotification: InferHandler<'v1', HostApiProtocol['host_push_notification']>;
|
|
57
|
+
handleNavigateTo: InferHandler<'v1', HostApiProtocol['host_navigate_to']>;
|
|
58
|
+
handleLocalStorageRead: InferHandler<'v1', HostApiProtocol['host_local_storage_read']>;
|
|
59
|
+
handleLocalStorageWrite: InferHandler<'v1', HostApiProtocol['host_local_storage_write']>;
|
|
60
|
+
handleLocalStorageClear: InferHandler<'v1', HostApiProtocol['host_local_storage_clear']>;
|
|
61
|
+
handleAccountGet: InferHandler<'v1', HostApiProtocol['host_account_get']>;
|
|
62
|
+
handleAccountGetAlias: InferHandler<'v1', HostApiProtocol['host_account_get_alias']>;
|
|
63
|
+
handleAccountCreateProof: InferHandler<'v1', HostApiProtocol['host_account_create_proof']>;
|
|
64
|
+
handleGetNonProductAccounts: InferHandler<'v1', HostApiProtocol['host_get_non_product_accounts']>;
|
|
65
|
+
handleCreateTransaction: InferHandler<'v1', HostApiProtocol['host_create_transaction']>;
|
|
66
|
+
handleCreateTransactionWithNonProductAccount: InferHandler<'v1', HostApiProtocol['host_create_transaction_with_non_product_account']>;
|
|
67
|
+
handleSignRaw: InferHandler<'v1', HostApiProtocol['host_sign_raw']>;
|
|
68
|
+
handleSignPayload: InferHandler<'v1', HostApiProtocol['host_sign_payload']>;
|
|
69
|
+
handleChatCreateRoom: InferHandler<'v1', HostApiProtocol['host_chat_create_room']>;
|
|
70
|
+
handleChatBotRegistration: InferHandler<'v1', HostApiProtocol['host_chat_register_bot']>;
|
|
71
|
+
handleChatListSubscribe: InferHandler<'v1', HostApiProtocol['host_chat_list_subscribe']>;
|
|
72
|
+
handleChatPostMessage: InferHandler<'v1', HostApiProtocol['host_chat_post_message']>;
|
|
73
|
+
handleChatActionSubscribe: InferHandler<'v1', HostApiProtocol['host_chat_action_subscribe']>;
|
|
74
|
+
handleStatementStoreSubscribe: InferHandler<'v1', HostApiProtocol['remote_statement_store_subscribe']>;
|
|
75
|
+
handleStatementStoreCreateProof: InferHandler<'v1', HostApiProtocol['remote_statement_store_create_proof']>;
|
|
76
|
+
handleStatementStoreSubmit: InferHandler<'v1', HostApiProtocol['remote_statement_store_submit']>;
|
|
77
|
+
handlePreimageLookupSubscribe: InferHandler<'v1', HostApiProtocol['remote_preimage_lookup_subscribe']>;
|
|
78
|
+
handlePreimageSubmit: InferHandler<'v1', HostApiProtocol['remote_preimage_submit']>;
|
|
74
79
|
handleChainConnection: (factory: (genesisHash: HexString) => JsonRpcProvider | null) => VoidFunction;
|
|
75
80
|
isReady(): Promise<boolean>;
|
|
76
81
|
dispose(): void;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-container",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.5",
|
|
5
5
|
"description": "Host container for hosting and managing products within the Polkadot ecosystem.",
|
|
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
|
"keywords": [
|
|
12
12
|
"polkadot",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@polkadot-api/utils": "^0.2.0",
|
|
30
30
|
"@polkadot-api/json-rpc-provider": "^0.0.4",
|
|
31
|
-
"@novasamatech/host-api": "0.5.
|
|
31
|
+
"@novasamatech/host-api": "0.5.5",
|
|
32
32
|
"nanoid": "5.1.6"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|