@novasamatech/host-container 0.6.16 → 0.7.0-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 CHANGED
@@ -102,6 +102,15 @@ container.handleNavigateTo(async (url, { ok, err }) => {
102
102
  });
103
103
  ```
104
104
 
105
+ ### handleDeriveEntropy
106
+
107
+ ```ts
108
+ container.handleDeriveEntropy(async (key, { ok, err }) => {
109
+ const entropy = await deriveEntropy(key);
110
+ return ok(entropy);
111
+ });
112
+ ```
113
+
105
114
  ### handleLocalStorageRead
106
115
 
107
116
  ```ts
@@ -143,6 +152,17 @@ container.handleAccountConnectionStatusSubscribe((_, send, interrupt) => {
143
152
  });
144
153
  ```
145
154
 
155
+ ### handleThemeSubscribe
156
+
157
+ ```ts
158
+ container.handleThemeSubscribe((_, send, interrupt) => {
159
+ const listener = (theme: 'light' | 'dark') => send(theme);
160
+ themeService.on('change', listener);
161
+ send(themeService.getCurrentTheme());
162
+ return () => themeService.off('change', listener);
163
+ });
164
+ ```
165
+
146
166
  ### handleAccountGet
147
167
 
148
168
  ```ts
@@ -359,6 +379,69 @@ container.handlePreimageSubmit(async (preimage, { ok, err }) => {
359
379
  });
360
380
  ```
361
381
 
382
+ ### handlePaymentBalanceSubscribe
383
+
384
+ Called when a product subscribes to balance updates. Host should prompt for user consent on the first call; interrupt the subscription to communicate denial.
385
+
386
+ ```ts
387
+ container.handlePaymentBalanceSubscribe((_params, send, interrupt) => {
388
+ const unsubscribe = balanceService.subscribe(balance => {
389
+ send({ available: balance.available, pending: balance.pending });
390
+ });
391
+
392
+ return () => unsubscribe();
393
+ });
394
+ ```
395
+
396
+ ### handlePaymentTopUp
397
+
398
+ Called when a product requests a balance top-up from a product-controlled source. Does not require user consent.
399
+
400
+ ```ts
401
+ container.handlePaymentTopUp(async ({ amount, source }, { ok, err }) => {
402
+ if (source.tag === 'ProductAccount') {
403
+ const [dotNsIdentifier, derivationIndex] = source.value;
404
+ await transferFromProductAccount(dotNsIdentifier, derivationIndex, amount);
405
+ return ok(undefined);
406
+ }
407
+ if (source.tag === 'PrivateKey') {
408
+ await transferFromPrivateKey(source.value, amount);
409
+ return ok(undefined);
410
+ }
411
+ return err(new PaymentTopUpErr.InvalidSource());
412
+ });
413
+ ```
414
+
415
+ ### handlePaymentRequest
416
+
417
+ Called when a product requests a payment from the user's balance. Host MUST show a confirmation UI. Returns a receipt immediately; settlement is asynchronous.
418
+
419
+ ```ts
420
+ container.handlePaymentRequest(async ({ amount, destination }, { ok, err }) => {
421
+ const approved = await showPaymentConfirmation({ amount, destination });
422
+ if (!approved) return err(new PaymentRequestErr.Denied());
423
+
424
+ const paymentId = await paymentService.submit(amount, destination);
425
+ return ok({ id: paymentId });
426
+ });
427
+ ```
428
+
429
+ ### handlePaymentStatusSubscribe
430
+
431
+ Called when a product subscribes to the status of a previously requested payment.
432
+
433
+ ```ts
434
+ container.handlePaymentStatusSubscribe((paymentId, send, interrupt) => {
435
+ const unsubscribe = paymentService.trackStatus(paymentId, status => {
436
+ if (status === 'processing') send({ tag: 'Processing', value: undefined });
437
+ if (status === 'completed') send({ tag: 'Completed', value: undefined });
438
+ if (status === 'failed') send({ tag: 'Failed', value: 'settlement failed' });
439
+ });
440
+
441
+ return () => unsubscribe();
442
+ });
443
+ ```
444
+
362
445
  ### handleChainConnection
363
446
 
364
447
  ```ts
@@ -1,9 +1,12 @@
1
- import { ChatBotRegistrationErr, ChatMessagePostingErr, ChatRoomRegistrationErr, CreateProofErr, CreateTransactionErr, GenericError, NavigateToErr, PreimageSubmitErr, RequestCredentialsErr, SigningErr, StatementProofErr, StorageErr, createTransport, enumValue, isEnumVariant, resultErr, resultOk, } from '@novasamatech/host-api';
1
+ import { ChatBotRegistrationErr, ChatMessagePostingErr, ChatRoomRegistrationErr, CreateProofErr, CreateTransactionErr, DeriveEntropyErr, GenericError, NavigateToErr, PaymentRequestErr, PaymentTopUpErr, PreimageSubmitErr, RequestCredentialsErr, SigningErr, StatementProofErr, StorageErr, createTransport, enumValue, isEnumVariant, resultErr, resultOk, } from '@novasamatech/host-api';
2
2
  import { err, errAsync, ok, okAsync } from 'neverthrow';
3
3
  import { createChainConnectionManager } from './chainConnectionManager.js';
4
4
  const UNSUPPORTED_MESSAGE_FORMAT_ERROR = 'Unsupported message format';
5
5
  const NOT_IMPLEMENTED = 'Not implemented';
6
6
  function guardVersion(value, tag, error) {
7
+ if (!value) {
8
+ return err(error);
9
+ }
7
10
  if (isEnumVariant(value, tag)) {
8
11
  return ok(value.value);
9
12
  }
@@ -51,393 +54,168 @@ export function createContainer(provider) {
51
54
  };
52
55
  };
53
56
  }
57
+ function makeNotImplementedSlot(method, makeError) {
58
+ // Cast needed: async () returns a fixed v1 error shape that TypeScript can't verify
59
+ // matches the generic Method's response type without evaluating template literal types.
60
+ const handler = async () => enumValue('v1', resultErr(makeError()));
61
+ return makeRequestSlot(method, handler);
62
+ }
63
+ function makeInterruptSlot(method) {
64
+ // Cast needed: the default handler ignores typed params/send which TypeScript can't verify
65
+ // matches the generic Method's subscription type without evaluating template literal types.
66
+ const defaultHandler = ((_params, _send, interrupt) => {
67
+ queueMicrotask(interrupt);
68
+ return () => {
69
+ /* nothing to clean up */
70
+ };
71
+ });
72
+ return makeSubscriptionSlot(method, defaultHandler);
73
+ }
74
+ function handleV1Request(slot, makeError, handler) {
75
+ init();
76
+ const version = 'v1';
77
+ return slot.update(async (params) => {
78
+ const error = makeError();
79
+ return guardVersion(params, version, error)
80
+ .asyncMap(async (p) => await handler(p, { ok: (okAsync), err: (errAsync) }))
81
+ .andThen(r => r.map(v => enumValue(version, resultOk(v))))
82
+ .orElse(r => ok(enumValue(version, resultErr(r))))
83
+ .unwrapOr(enumValue(version, resultErr(error)));
84
+ });
85
+ }
86
+ function handleV1Subscription(slot, handler) {
87
+ init();
88
+ const version = 'v1';
89
+ const slotHandler = ((params, send, interrupt) => {
90
+ return guardVersion(params, version, null)
91
+ .map(p => handler(p, ((payload) => send(enumValue(version, payload))), interrupt))
92
+ .orTee(interrupt)
93
+ .unwrapOr(() => {
94
+ /* empty */
95
+ });
96
+ });
97
+ return slot(slotHandler);
98
+ }
54
99
  // account slots
55
- const handleAccountGetSlot = makeRequestSlot('host_account_get', async () => {
56
- const error = new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED });
57
- return enumValue('v1', resultErr(error));
58
- });
59
- const handleAccountGetAliasSlot = makeRequestSlot('host_account_get_alias', async () => {
60
- const error = new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED });
61
- return enumValue('v1', resultErr(error));
62
- });
63
- const handleGetNonProductAccountsSlot = makeRequestSlot('host_get_non_product_accounts', async () => {
64
- const error = new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED });
65
- return enumValue('v1', resultErr(error));
66
- });
67
- const handleAccountCreateProofSlot = makeRequestSlot('host_account_create_proof', async () => {
68
- const error = new CreateProofErr.Unknown({ reason: NOT_IMPLEMENTED });
69
- return enumValue('v1', resultErr(error));
70
- });
100
+ const handleAccountGetSlot = makeNotImplementedSlot('host_account_get', () => new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED }));
101
+ const handleAccountGetAliasSlot = makeNotImplementedSlot('host_account_get_alias', () => new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED }));
102
+ const handleGetNonProductAccountsSlot = makeNotImplementedSlot('host_get_non_product_accounts', () => new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED }));
103
+ const handleAccountCreateProofSlot = makeNotImplementedSlot('host_account_create_proof', () => new CreateProofErr.Unknown({ reason: NOT_IMPLEMENTED }));
104
+ // entropy derivation slot
105
+ const handleDeriveEntropySlot = makeNotImplementedSlot('host_derive_entropy', () => new DeriveEntropyErr.Unknown({ reason: NOT_IMPLEMENTED }));
71
106
  // storage slots
72
- const handleLocalStorageReadSlot = makeRequestSlot('host_local_storage_read', async () => {
73
- const error = new StorageErr.Unknown({ reason: NOT_IMPLEMENTED });
74
- return enumValue('v1', resultErr(error));
75
- });
76
- const handleLocalStorageWriteSlot = makeRequestSlot('host_local_storage_write', async () => {
77
- const error = new StorageErr.Unknown({ reason: NOT_IMPLEMENTED });
78
- return enumValue('v1', resultErr(error));
79
- });
80
- const handleLocalStorageClearSlot = makeRequestSlot('host_local_storage_clear', async () => {
81
- const error = new StorageErr.Unknown({ reason: NOT_IMPLEMENTED });
82
- return enumValue('v1', resultErr(error));
83
- });
107
+ const handleLocalStorageReadSlot = makeNotImplementedSlot('host_local_storage_read', () => new StorageErr.Unknown({ reason: NOT_IMPLEMENTED }));
108
+ const handleLocalStorageWriteSlot = makeNotImplementedSlot('host_local_storage_write', () => new StorageErr.Unknown({ reason: NOT_IMPLEMENTED }));
109
+ const handleLocalStorageClearSlot = makeNotImplementedSlot('host_local_storage_clear', () => new StorageErr.Unknown({ reason: NOT_IMPLEMENTED }));
84
110
  // signing slots
85
- const handleSignRawSlot = makeRequestSlot('host_sign_raw', async () => {
86
- const error = new SigningErr.Unknown({ reason: NOT_IMPLEMENTED });
87
- return enumValue('v1', resultErr(error));
88
- });
89
- const handleSignPayloadSlot = makeRequestSlot('host_sign_payload', async () => {
90
- const error = new SigningErr.Unknown({ reason: NOT_IMPLEMENTED });
91
- return enumValue('v1', resultErr(error));
92
- });
93
- const handleCreateTransactionSlot = makeRequestSlot('host_create_transaction', async () => {
94
- const error = new CreateTransactionErr.Unknown({ reason: NOT_IMPLEMENTED });
95
- return enumValue('v1', resultErr(error));
96
- });
97
- const handleCreateTransactionWithNonProductAccountSlot = makeRequestSlot('host_create_transaction_with_non_product_account', async () => {
98
- const error = new CreateTransactionErr.Unknown({ reason: NOT_IMPLEMENTED });
99
- return enumValue('v1', resultErr(error));
100
- });
101
- const handleFeatureSupportedSlot = makeRequestSlot('host_feature_supported', async () => {
102
- const error = new GenericError({ reason: NOT_IMPLEMENTED });
103
- return enumValue('v1', resultErr(error));
104
- });
105
- const handleDevicePermissionSlot = makeRequestSlot('host_device_permission', async () => {
106
- const error = new GenericError({ reason: NOT_IMPLEMENTED });
107
- return enumValue('v1', resultErr(error));
108
- });
109
- const handleRemotePermissionSlot = makeRequestSlot('remote_permission', async () => {
110
- const error = new GenericError({ reason: NOT_IMPLEMENTED });
111
- return enumValue('v1', resultErr(error));
112
- });
113
- const handlePushNotificationSlot = makeRequestSlot('host_push_notification', async () => {
114
- const error = new GenericError({ reason: NOT_IMPLEMENTED });
115
- return enumValue('v1', resultErr(error));
116
- });
117
- const handleNavigateToSlot = makeRequestSlot('host_navigate_to', async () => {
118
- const error = new NavigateToErr.Unknown({ reason: NOT_IMPLEMENTED });
119
- return enumValue('v1', resultErr(error));
120
- });
121
- const handleChatCreateRoomSlot = makeRequestSlot('host_chat_create_room', async () => {
122
- const error = new ChatRoomRegistrationErr.Unknown({ reason: NOT_IMPLEMENTED });
123
- return enumValue('v1', resultErr(error));
124
- });
125
- const handleChatBotRegistrationSlot = makeRequestSlot('host_chat_register_bot', async () => {
126
- const error = new ChatBotRegistrationErr.Unknown({ reason: NOT_IMPLEMENTED });
127
- return enumValue('v1', resultErr(error));
128
- });
129
- const handleChatPostMessageSlot = makeRequestSlot('host_chat_post_message', async () => {
130
- const error = new ChatMessagePostingErr.Unknown({ reason: NOT_IMPLEMENTED });
131
- return enumValue('v1', resultErr(error));
132
- });
133
- const handleStatementStoreSubmitSlot = makeRequestSlot('remote_statement_store_submit', async () => {
134
- const error = new GenericError({ reason: NOT_IMPLEMENTED });
135
- return enumValue('v1', resultErr(error));
136
- });
137
- const handleStatementStoreCreateProofSlot = makeRequestSlot('remote_statement_store_create_proof', async () => {
138
- const error = new StatementProofErr.Unknown({ reason: NOT_IMPLEMENTED });
139
- return enumValue('v1', resultErr(error));
140
- });
141
- const handlePreimageSubmitSlot = makeRequestSlot('remote_preimage_submit', async () => {
142
- const error = new PreimageSubmitErr.Unknown({ reason: NOT_IMPLEMENTED });
143
- return enumValue('v1', resultErr(error));
144
- });
111
+ const handleSignRawSlot = makeNotImplementedSlot('host_sign_raw', () => new SigningErr.Unknown({ reason: NOT_IMPLEMENTED }));
112
+ const handleSignPayloadSlot = makeNotImplementedSlot('host_sign_payload', () => new SigningErr.Unknown({ reason: NOT_IMPLEMENTED }));
113
+ const handleSignRawWithNonProductAccountSlot = makeNotImplementedSlot('host_sign_raw_with_non_product_account', () => new SigningErr.Unknown({ reason: NOT_IMPLEMENTED }));
114
+ const handleSignPayloadWithNonProductAccountSlot = makeNotImplementedSlot('host_sign_payload_with_non_product_account', () => new SigningErr.Unknown({ reason: NOT_IMPLEMENTED }));
115
+ const handleCreateTransactionSlot = makeNotImplementedSlot('host_create_transaction', () => new CreateTransactionErr.Unknown({ reason: NOT_IMPLEMENTED }));
116
+ const handleCreateTransactionWithNonProductAccountSlot = makeNotImplementedSlot('host_create_transaction_with_non_product_account', () => new CreateTransactionErr.Unknown({ reason: NOT_IMPLEMENTED }));
117
+ const handleFeatureSupportedSlot = makeNotImplementedSlot('host_feature_supported', () => new GenericError({ reason: NOT_IMPLEMENTED }));
118
+ const handleDevicePermissionSlot = makeNotImplementedSlot('host_device_permission', () => new GenericError({ reason: NOT_IMPLEMENTED }));
119
+ const handleRemotePermissionSlot = makeNotImplementedSlot('remote_permission', () => new GenericError({ reason: NOT_IMPLEMENTED }));
120
+ const handlePushNotificationSlot = makeNotImplementedSlot('host_push_notification', () => new GenericError({ reason: NOT_IMPLEMENTED }));
121
+ const handleNavigateToSlot = makeNotImplementedSlot('host_navigate_to', () => new NavigateToErr.Unknown({ reason: NOT_IMPLEMENTED }));
122
+ const handleChatCreateRoomSlot = makeNotImplementedSlot('host_chat_create_room', () => new ChatRoomRegistrationErr.Unknown({ reason: NOT_IMPLEMENTED }));
123
+ const handleChatBotRegistrationSlot = makeNotImplementedSlot('host_chat_register_bot', () => new ChatBotRegistrationErr.Unknown({ reason: NOT_IMPLEMENTED }));
124
+ const handleChatPostMessageSlot = makeNotImplementedSlot('host_chat_post_message', () => new ChatMessagePostingErr.Unknown({ reason: NOT_IMPLEMENTED }));
125
+ const handleStatementStoreSubmitSlot = makeNotImplementedSlot('remote_statement_store_submit', () => new GenericError({ reason: NOT_IMPLEMENTED }));
126
+ const handleStatementStoreCreateProofSlot = makeNotImplementedSlot('remote_statement_store_create_proof', () => new StatementProofErr.Unknown({ reason: NOT_IMPLEMENTED }));
127
+ const handlePreimageSubmitSlot = makeNotImplementedSlot('remote_preimage_submit', () => new PreimageSubmitErr.Unknown({ reason: NOT_IMPLEMENTED }));
128
+ // payment request slots
129
+ const handlePaymentTopUpSlot = makeNotImplementedSlot('host_payment_top_up', () => new PaymentTopUpErr.Unknown({ reason: NOT_IMPLEMENTED }));
130
+ const handlePaymentRequestSlot = makeNotImplementedSlot('host_payment_request', () => new PaymentRequestErr.Unknown({ reason: NOT_IMPLEMENTED }));
145
131
  // subscription slots — default interrupts on next microtask so that
146
132
  // the caller has a chance to register an onInterrupt listener first
147
- const handleAccountConnectionStatusSubscribeSlot = makeSubscriptionSlot('host_account_connection_status_subscribe', (_params, _send, interrupt) => {
148
- queueMicrotask(interrupt);
149
- return () => {
150
- /* nothing to clean up */
151
- };
152
- });
153
- const handleChatListSubscribeSlot = makeSubscriptionSlot('host_chat_list_subscribe', (_params, _send, interrupt) => {
154
- queueMicrotask(interrupt);
155
- return () => {
156
- /* nothing to clean up */
157
- };
158
- });
159
- const handleChatActionSubscribeSlot = makeSubscriptionSlot('host_chat_action_subscribe', (_params, _send, interrupt) => {
160
- queueMicrotask(interrupt);
161
- return () => {
162
- /* nothing to clean up */
163
- };
164
- });
165
- const handleStatementStoreSubscribeSlot = makeSubscriptionSlot('remote_statement_store_subscribe', (_params, _send, interrupt) => {
166
- queueMicrotask(interrupt);
167
- return () => {
168
- /* nothing to clean up */
169
- };
170
- });
171
- const handlePreimageLookupSubscribeSlot = makeSubscriptionSlot('remote_preimage_lookup_subscribe', (_params, _send, interrupt) => {
172
- queueMicrotask(interrupt);
173
- return () => {
174
- /* nothing to clean up */
175
- };
176
- });
133
+ const handleThemeSubscribeSlot = makeInterruptSlot('host_theme_subscribe');
134
+ const handleAccountConnectionStatusSubscribeSlot = makeInterruptSlot('host_account_connection_status_subscribe');
135
+ const handleChatListSubscribeSlot = makeInterruptSlot('host_chat_list_subscribe');
136
+ const handleChatActionSubscribeSlot = makeInterruptSlot('host_chat_action_subscribe');
137
+ const handleStatementStoreSubscribeSlot = makeInterruptSlot('remote_statement_store_subscribe');
138
+ const handlePreimageLookupSubscribeSlot = makeInterruptSlot('remote_preimage_lookup_subscribe');
139
+ const handlePaymentBalanceSubscribeSlot = makeInterruptSlot('host_payment_balance_subscribe');
140
+ const handlePaymentStatusSubscribeSlot = makeInterruptSlot('host_payment_status_subscribe');
177
141
  return {
178
142
  handleFeatureSupported(handler) {
179
- init();
180
- return handleFeatureSupportedSlot.update(async (message) => {
181
- const version = 'v1';
182
- const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
183
- return guardVersion(message, version, error)
184
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
185
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
186
- .orElse(r => ok(enumValue(version, resultErr(r))))
187
- .unwrapOr(enumValue(version, resultErr(error)));
188
- });
143
+ return handleV1Request(handleFeatureSupportedSlot, () => new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
189
144
  },
190
145
  handleDevicePermission(handler) {
191
- init();
192
- return handleDevicePermissionSlot.update(async (message) => {
193
- const version = 'v1';
194
- const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
195
- return guardVersion(message, version, error)
196
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
197
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
198
- .orElse(r => ok(enumValue(version, resultErr(r))))
199
- .unwrapOr(enumValue(version, resultErr(error)));
200
- });
146
+ return handleV1Request(handleDevicePermissionSlot, () => new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
201
147
  },
202
148
  handlePermission(handler) {
203
- init();
204
- return handleRemotePermissionSlot.update(async (message) => {
205
- const version = 'v1';
206
- const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
207
- return guardVersion(message, version, error)
208
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
209
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
210
- .orElse(r => ok(enumValue(version, resultErr(r))))
211
- .unwrapOr(enumValue(version, resultErr(error)));
212
- });
149
+ return handleV1Request(handleRemotePermissionSlot, () => new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
213
150
  },
214
151
  handlePushNotification(handler) {
215
- init();
216
- return handlePushNotificationSlot.update(async (message) => {
217
- const version = 'v1';
218
- const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
219
- return guardVersion(message, version, error)
220
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
221
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
222
- .orElse(r => ok(enumValue(version, resultErr(r))))
223
- .unwrapOr(enumValue(version, resultErr(error)));
224
- });
152
+ return handleV1Request(handlePushNotificationSlot, () => new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
225
153
  },
226
154
  handleNavigateTo(handler) {
227
- init();
228
- return handleNavigateToSlot.update(async (message) => {
229
- const version = 'v1';
230
- const error = new NavigateToErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
231
- return guardVersion(message, version, error)
232
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
233
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
234
- .orElse(r => ok(enumValue(version, resultErr(r))))
235
- .unwrapOr(enumValue(version, resultErr(error)));
236
- });
155
+ return handleV1Request(handleNavigateToSlot, () => new NavigateToErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
156
+ },
157
+ handleDeriveEntropy(handler) {
158
+ return handleV1Request(handleDeriveEntropySlot, () => new DeriveEntropyErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
237
159
  },
238
160
  handleLocalStorageRead(handler) {
239
- init();
240
- return handleLocalStorageReadSlot.update(async (message) => {
241
- const version = 'v1';
242
- const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
243
- return guardVersion(message, version, error)
244
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
245
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
246
- .orElse(r => ok(enumValue(version, resultErr(r))))
247
- .unwrapOr(enumValue(version, resultErr(error)));
248
- });
161
+ return handleV1Request(handleLocalStorageReadSlot, () => new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
249
162
  },
250
163
  handleLocalStorageWrite(handler) {
251
- init();
252
- return handleLocalStorageWriteSlot.update(async (message) => {
253
- const version = 'v1';
254
- const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
255
- return guardVersion(message, version, error)
256
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
257
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
258
- .orElse(r => ok(enumValue(version, resultErr(r))))
259
- .unwrapOr(enumValue(version, resultErr(error)));
260
- });
164
+ return handleV1Request(handleLocalStorageWriteSlot, () => new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
261
165
  },
262
166
  handleLocalStorageClear(handler) {
263
- init();
264
- return handleLocalStorageClearSlot.update(async (message) => {
265
- const version = 'v1';
266
- const error = new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
267
- return guardVersion(message, version, error)
268
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
269
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
270
- .orElse(r => ok(enumValue(version, resultErr(r))))
271
- .unwrapOr(enumValue(version, resultErr(error)));
272
- });
167
+ return handleV1Request(handleLocalStorageClearSlot, () => new StorageErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
168
+ },
169
+ handleThemeSubscribe(handler) {
170
+ return handleV1Subscription(handleThemeSubscribeSlot, handler);
273
171
  },
274
172
  handleAccountConnectionStatusSubscribe(handler) {
275
- init();
276
- return handleAccountConnectionStatusSubscribeSlot((params, send, interrupt) => {
277
- const version = 'v1';
278
- return guardVersion(params, version, null)
279
- .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
280
- .orTee(interrupt)
281
- .unwrapOr(() => {
282
- /* empty */
283
- });
284
- });
173
+ return handleV1Subscription(handleAccountConnectionStatusSubscribeSlot, handler);
285
174
  },
286
175
  handleAccountGet(handler) {
287
- init();
288
- return handleAccountGetSlot.update(async (params) => {
289
- const version = 'v1';
290
- const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
291
- return guardVersion(params, version, error)
292
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
293
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
294
- .orElse(r => ok(enumValue(version, resultErr(r))))
295
- .unwrapOr(enumValue(version, resultErr(error)));
296
- });
176
+ return handleV1Request(handleAccountGetSlot, () => new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
297
177
  },
298
178
  handleAccountGetAlias(handler) {
299
- init();
300
- return handleAccountGetAliasSlot.update(async (params) => {
301
- const version = 'v1';
302
- const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
303
- return guardVersion(params, version, error)
304
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
305
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
306
- .orElse(r => ok(enumValue(version, resultErr(r))))
307
- .unwrapOr(enumValue(version, resultErr(error)));
308
- });
179
+ return handleV1Request(handleAccountGetAliasSlot, () => new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
309
180
  },
310
181
  handleAccountCreateProof(handler) {
311
- init();
312
- return handleAccountCreateProofSlot.update(async (params) => {
313
- const version = 'v1';
314
- const error = new CreateProofErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
315
- return guardVersion(params, version, error)
316
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
317
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
318
- .orElse(r => ok(enumValue(version, resultErr(r))))
319
- .unwrapOr(enumValue(version, resultErr(error)));
320
- });
182
+ return handleV1Request(handleAccountCreateProofSlot, () => new CreateProofErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
321
183
  },
322
184
  handleGetNonProductAccounts(handler) {
323
- init();
324
- return handleGetNonProductAccountsSlot.update(async (params) => {
325
- const version = 'v1';
326
- const error = new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
327
- return guardVersion(params, version, error)
328
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
329
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
330
- .orElse(r => ok(enumValue(version, resultErr(r))))
331
- .unwrapOr(enumValue(version, resultErr(error)));
332
- });
185
+ return handleV1Request(handleGetNonProductAccountsSlot, () => new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
333
186
  },
334
187
  handleCreateTransaction(handler) {
335
- init();
336
- return handleCreateTransactionSlot.update(async (params) => {
337
- const version = 'v1';
338
- const error = new CreateTransactionErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
339
- return guardVersion(params, version, error)
340
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
341
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
342
- .orElse(r => ok(enumValue(version, resultErr(r))))
343
- .unwrapOr(enumValue(version, resultErr(error)));
344
- });
188
+ return handleV1Request(handleCreateTransactionSlot, () => new CreateTransactionErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
345
189
  },
346
190
  handleCreateTransactionWithNonProductAccount(handler) {
347
- init();
348
- return handleCreateTransactionWithNonProductAccountSlot.update(async (params) => {
349
- const version = 'v1';
350
- const error = new CreateTransactionErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
351
- return guardVersion(params, version, error)
352
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
353
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
354
- .orElse(r => ok(enumValue(version, resultErr(r))))
355
- .unwrapOr(enumValue(version, resultErr(error)));
356
- });
191
+ return handleV1Request(handleCreateTransactionWithNonProductAccountSlot, () => new CreateTransactionErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
357
192
  },
358
193
  handleSignRaw(handler) {
359
- init();
360
- return handleSignRawSlot.update(async (params) => {
361
- const version = 'v1';
362
- const error = new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
363
- return guardVersion(params, version, error)
364
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
365
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
366
- .orElse(r => ok(enumValue(version, resultErr(r))))
367
- .unwrapOr(enumValue(version, resultErr(error)));
368
- });
194
+ return handleV1Request(handleSignRawSlot, () => new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
369
195
  },
370
196
  handleSignPayload(handler) {
371
- init();
372
- return handleSignPayloadSlot.update(async (params) => {
373
- const version = 'v1';
374
- const error = new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
375
- return guardVersion(params, version, error)
376
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
377
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
378
- .orElse(r => ok(enumValue(version, resultErr(r))))
379
- .unwrapOr(enumValue(version, resultErr(error)));
380
- });
197
+ return handleV1Request(handleSignPayloadSlot, () => new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
198
+ },
199
+ handleSignRawWithNonProductAccount(handler) {
200
+ return handleV1Request(handleSignRawWithNonProductAccountSlot, () => new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
201
+ },
202
+ handleSignPayloadWithNonProductAccount(handler) {
203
+ return handleV1Request(handleSignPayloadWithNonProductAccountSlot, () => new SigningErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
381
204
  },
382
205
  handleChatCreateRoom(handler) {
383
- init();
384
- return handleChatCreateRoomSlot.update(async (params) => {
385
- const version = 'v1';
386
- const error = new ChatRoomRegistrationErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
387
- return guardVersion(params, version, error)
388
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
389
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
390
- .orElse(r => ok(enumValue(version, resultErr(r))))
391
- .unwrapOr(enumValue(version, resultErr(error)));
392
- });
206
+ return handleV1Request(handleChatCreateRoomSlot, () => new ChatRoomRegistrationErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
393
207
  },
394
208
  handleChatBotRegistration(handler) {
395
- init();
396
- return handleChatBotRegistrationSlot.update(async (params) => {
397
- const version = 'v1';
398
- const error = new ChatBotRegistrationErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
399
- return guardVersion(params, version, error)
400
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
401
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
402
- .orElse(r => ok(enumValue(version, resultErr(r))))
403
- .unwrapOr(enumValue(version, resultErr(error)));
404
- });
209
+ return handleV1Request(handleChatBotRegistrationSlot, () => new ChatBotRegistrationErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
405
210
  },
406
211
  handleChatListSubscribe(handler) {
407
- init();
408
- return handleChatListSubscribeSlot((params, send, interrupt) => {
409
- const version = 'v1';
410
- return guardVersion(params, version, null)
411
- .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
412
- .orTee(interrupt)
413
- .unwrapOr(() => {
414
- /* empty */
415
- });
416
- });
212
+ return handleV1Subscription(handleChatListSubscribeSlot, handler);
417
213
  },
418
214
  handleChatPostMessage(handler) {
419
- init();
420
- return handleChatPostMessageSlot.update(async (params) => {
421
- const version = 'v1';
422
- const error = new ChatMessagePostingErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
423
- return guardVersion(params, version, error)
424
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
425
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
426
- .orElse(r => ok(enumValue(version, resultErr(r))))
427
- .unwrapOr(enumValue(version, resultErr(error)));
428
- });
215
+ return handleV1Request(handleChatPostMessageSlot, () => new ChatMessagePostingErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
429
216
  },
430
217
  handleChatActionSubscribe(handler) {
431
- init();
432
- return handleChatActionSubscribeSlot((params, send, interrupt) => {
433
- const version = 'v1';
434
- return guardVersion(params, version, null)
435
- .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
436
- .orTee(interrupt)
437
- .unwrapOr(() => {
438
- /* empty */
439
- });
440
- });
218
+ return handleV1Subscription(handleChatActionSubscribeSlot, handler);
441
219
  },
442
220
  renderChatCustomMessage({ messageId, messageType, payload }, callback) {
443
221
  init();
@@ -448,64 +226,31 @@ export function createContainer(provider) {
448
226
  });
449
227
  },
450
228
  handleStatementStoreSubscribe(handler) {
451
- init();
452
- return handleStatementStoreSubscribeSlot((params, send, interrupt) => {
453
- const version = 'v1';
454
- return guardVersion(params, version, null)
455
- .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
456
- .orTee(interrupt)
457
- .unwrapOr(() => {
458
- /* empty */
459
- });
460
- });
229
+ return handleV1Subscription(handleStatementStoreSubscribeSlot, handler);
461
230
  },
462
231
  handleStatementStoreCreateProof(handler) {
463
- init();
464
- return handleStatementStoreCreateProofSlot.update(async (params) => {
465
- const version = 'v1';
466
- const error = new StatementProofErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
467
- return guardVersion(params, version, error)
468
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
469
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
470
- .orElse(r => ok(enumValue(version, resultErr(r))))
471
- .unwrapOr(enumValue(version, resultErr(error)));
472
- });
232
+ return handleV1Request(handleStatementStoreCreateProofSlot, () => new StatementProofErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
473
233
  },
474
234
  handleStatementStoreSubmit(handler) {
475
- init();
476
- return handleStatementStoreSubmitSlot.update(async (params) => {
477
- const version = 'v1';
478
- const error = new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
479
- return guardVersion(params, version, error)
480
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
481
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
482
- .orElse(r => ok(enumValue(version, resultErr(r))))
483
- .unwrapOr(enumValue(version, resultErr(error)));
484
- });
235
+ return handleV1Request(handleStatementStoreSubmitSlot, () => new GenericError({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
485
236
  },
486
237
  handlePreimageLookupSubscribe(handler) {
487
- init();
488
- return handlePreimageLookupSubscribeSlot((params, send, interrupt) => {
489
- const version = 'v1';
490
- return guardVersion(params, version, null)
491
- .map(params => handler(params, payload => send(enumValue(version, payload)), interrupt))
492
- .orTee(interrupt)
493
- .unwrapOr(() => {
494
- /* empty */
495
- });
496
- });
238
+ return handleV1Subscription(handlePreimageLookupSubscribeSlot, handler);
497
239
  },
498
240
  handlePreimageSubmit(handler) {
499
- init();
500
- return handlePreimageSubmitSlot.update(async (params) => {
501
- const version = 'v1';
502
- const error = new PreimageSubmitErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR });
503
- return guardVersion(params, version, error)
504
- .asyncMap(async (params) => handler(params, { ok: (okAsync), err: (errAsync) }))
505
- .andThen(r => r.map(r => enumValue(version, resultOk(r))))
506
- .orElse(r => ok(enumValue(version, resultErr(r))))
507
- .unwrapOr(enumValue(version, resultErr(error)));
508
- });
241
+ return handleV1Request(handlePreimageSubmitSlot, () => new PreimageSubmitErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
242
+ },
243
+ handlePaymentBalanceSubscribe(handler) {
244
+ return handleV1Subscription(handlePaymentBalanceSubscribeSlot, handler);
245
+ },
246
+ handlePaymentTopUp(handler) {
247
+ return handleV1Request(handlePaymentTopUpSlot, () => new PaymentTopUpErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
248
+ },
249
+ handlePaymentRequest(handler) {
250
+ return handleV1Request(handlePaymentRequestSlot, () => new PaymentRequestErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
251
+ },
252
+ handlePaymentStatusSubscribe(handler) {
253
+ return handleV1Subscription(handlePaymentStatusSubscribeSlot, handler);
509
254
  },
510
255
  // chain interaction
511
256
  handleChainConnection(factory) {
package/dist/index.d.ts CHANGED
@@ -2,5 +2,6 @@ export { createWebviewProvider } from './createWebviewProvider.js';
2
2
  export { createIframeProvider } from './createIframeProvider.js';
3
3
  export { createContainer } from './createContainer.js';
4
4
  export type { Container } from './types.js';
5
+ export { deriveProductEntropy } from './deriveEntropy.js';
5
6
  export { createRateLimiter } from './rateLimiter.js';
6
7
  export type { CreateRateLimiterConfig, RateLimiter, RateLimiterConfig, RateLimiterStrategy } from './rateLimiter.js';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { createWebviewProvider } from './createWebviewProvider.js';
2
2
  export { createIframeProvider } from './createIframeProvider.js';
3
3
  export { createContainer } from './createContainer.js';
4
+ export { deriveProductEntropy } from './deriveEntropy.js';
4
5
  export { createRateLimiter } from './rateLimiter.js';
@@ -25,7 +25,7 @@ function createQueueStrategy(config) {
25
25
  state.remainingTokens -= 1;
26
26
  try {
27
27
  const result = task.execute();
28
- if (result != null && typeof result.then === 'function') {
28
+ if (result instanceof Promise) {
29
29
  result.then(task.resolve).catch(task.reject);
30
30
  }
31
31
  else {
@@ -51,7 +51,7 @@ function createQueueStrategy(config) {
51
51
  state.remainingTokens -= 1;
52
52
  try {
53
53
  const result = execute();
54
- if (result != null && typeof result.then === 'function') {
54
+ if (result instanceof Promise) {
55
55
  return result;
56
56
  }
57
57
  return Promise.resolve(result);
@@ -103,7 +103,7 @@ function createDropStrategy(config) {
103
103
  state.remainingTokens -= 1;
104
104
  try {
105
105
  const result = execute();
106
- if (result != null && typeof result.then === 'function') {
106
+ if (result instanceof Promise) {
107
107
  return result;
108
108
  }
109
109
  return Promise.resolve(result);
package/dist/types.d.ts CHANGED
@@ -11,23 +11,23 @@ type ErrorResponse<T> = T extends {
11
11
  success: false;
12
12
  value: infer U;
13
13
  } ? U : never;
14
- type Value<T extends Codec<any> | Codec<never>> = T extends Codec<any> ? CodecType<T> : unknown;
14
+ export type CodecValue<T extends Codec<any> | Codec<never>> = T extends Codec<any> ? CodecType<T> : unknown;
15
15
  type OrPromise<T> = T | Promise<T>;
16
16
  type ExtractEnumValue<T> = T extends {
17
17
  tag: string;
18
18
  value: infer V;
19
19
  } ? V : never;
20
- type WithVersion<V extends string, T> = ExtractEnumValue<Extract<T, {
20
+ export type WithVersion<V extends string, T> = ExtractEnumValue<Extract<T, {
21
21
  tag: V;
22
22
  }>>;
23
- type UnwrapSuccessResponse<V extends string, T> = T extends {
23
+ export type UnwrapSuccessResponse<V extends string, T> = T extends {
24
24
  tag: infer Tag;
25
25
  value: infer Value;
26
26
  } ? WithVersion<V, {
27
27
  tag: Tag;
28
28
  value: SuccessResponse<Value>;
29
29
  }> : never;
30
- type UnwrapErrorResponse<V extends string, T> = T extends {
30
+ export type UnwrapErrorResponse<V extends string, T> = T extends {
31
31
  tag: infer Tag;
32
32
  value: infer Value;
33
33
  } ? WithVersion<V, {
@@ -44,11 +44,12 @@ type UnwrapVersionedResult<V extends string, T> = T extends {
44
44
  tag: Tag;
45
45
  value: ErrorResponse<Value>;
46
46
  }>> : never;
47
- type InferRequestHandler<V extends string, T extends VersionedProtocolRequest> = (callback: (params: WithVersion<V, Value<T['request']>>, helpers: {
48
- ok: typeof okAsync<UnwrapSuccessResponse<V, Value<T['response']>>>;
49
- err: typeof errAsync<never, UnwrapErrorResponse<V, Value<T['response']>>>;
50
- }) => OrPromise<UnwrapVersionedResult<V, Value<T['response']>>>) => VoidFunction;
51
- 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;
47
+ export type ContainerRequestHandler<V extends string, T extends VersionedProtocolRequest> = (params: WithVersion<V, CodecValue<T['request']>>, helpers: {
48
+ ok: typeof okAsync<UnwrapSuccessResponse<V, CodecValue<T['response']>>>;
49
+ err: typeof errAsync<never, UnwrapErrorResponse<V, CodecValue<T['response']>>>;
50
+ }) => OrPromise<UnwrapVersionedResult<V, CodecValue<T['response']>>>;
51
+ type InferRequestHandler<V extends string, T extends VersionedProtocolRequest> = (callback: ContainerRequestHandler<V, T>) => VoidFunction;
52
+ type InferSubscribeHandler<V extends string, T extends VersionedProtocolSubscription> = (callback: (params: WithVersion<V, CodecValue<T['start']>>, send: (payload: WithVersion<V, CodecValue<T['receive']>>) => void, interrupt: VoidFunction) => VoidFunction) => VoidFunction;
52
53
  type InferHandler<V extends string, T extends VersionedProtocolRequest | VersionedProtocolSubscription> = T extends VersionedProtocolRequest ? InferRequestHandler<V, T> : T extends VersionedProtocolSubscription ? InferSubscribeHandler<V, T> : never;
53
54
  export type Container = {
54
55
  handleFeatureSupported: InferHandler<'v1', HostApiProtocol['host_feature_supported']>;
@@ -56,10 +57,12 @@ export type Container = {
56
57
  handlePermission: InferHandler<'v1', HostApiProtocol['remote_permission']>;
57
58
  handlePushNotification: InferHandler<'v1', HostApiProtocol['host_push_notification']>;
58
59
  handleNavigateTo: InferHandler<'v1', HostApiProtocol['host_navigate_to']>;
60
+ handleDeriveEntropy: InferHandler<'v1', HostApiProtocol['host_derive_entropy']>;
59
61
  handleLocalStorageRead: InferHandler<'v1', HostApiProtocol['host_local_storage_read']>;
60
62
  handleLocalStorageWrite: InferHandler<'v1', HostApiProtocol['host_local_storage_write']>;
61
63
  handleLocalStorageClear: InferHandler<'v1', HostApiProtocol['host_local_storage_clear']>;
62
64
  handleAccountConnectionStatusSubscribe: InferHandler<'v1', HostApiProtocol['host_account_connection_status_subscribe']>;
65
+ handleThemeSubscribe: InferHandler<'v1', HostApiProtocol['host_theme_subscribe']>;
63
66
  handleAccountGet: InferHandler<'v1', HostApiProtocol['host_account_get']>;
64
67
  handleAccountGetAlias: InferHandler<'v1', HostApiProtocol['host_account_get_alias']>;
65
68
  handleAccountCreateProof: InferHandler<'v1', HostApiProtocol['host_account_create_proof']>;
@@ -68,6 +71,8 @@ export type Container = {
68
71
  handleCreateTransactionWithNonProductAccount: InferHandler<'v1', HostApiProtocol['host_create_transaction_with_non_product_account']>;
69
72
  handleSignRaw: InferHandler<'v1', HostApiProtocol['host_sign_raw']>;
70
73
  handleSignPayload: InferHandler<'v1', HostApiProtocol['host_sign_payload']>;
74
+ handleSignRawWithNonProductAccount: InferHandler<'v1', HostApiProtocol['host_sign_raw_with_non_product_account']>;
75
+ handleSignPayloadWithNonProductAccount: InferHandler<'v1', HostApiProtocol['host_sign_payload_with_non_product_account']>;
71
76
  handleChatCreateRoom: InferHandler<'v1', HostApiProtocol['host_chat_create_room']>;
72
77
  handleChatBotRegistration: InferHandler<'v1', HostApiProtocol['host_chat_register_bot']>;
73
78
  handleChatListSubscribe: InferHandler<'v1', HostApiProtocol['host_chat_list_subscribe']>;
@@ -83,6 +88,10 @@ export type Container = {
83
88
  handleStatementStoreSubmit: InferHandler<'v1', HostApiProtocol['remote_statement_store_submit']>;
84
89
  handlePreimageLookupSubscribe: InferHandler<'v1', HostApiProtocol['remote_preimage_lookup_subscribe']>;
85
90
  handlePreimageSubmit: InferHandler<'v1', HostApiProtocol['remote_preimage_submit']>;
91
+ handlePaymentBalanceSubscribe: InferHandler<'v1', HostApiProtocol['host_payment_balance_subscribe']>;
92
+ handlePaymentTopUp: InferHandler<'v1', HostApiProtocol['host_payment_top_up']>;
93
+ handlePaymentRequest: InferHandler<'v1', HostApiProtocol['host_payment_request']>;
94
+ handlePaymentStatusSubscribe: InferHandler<'v1', HostApiProtocol['host_payment_status_subscribe']>;
86
95
  handleChainConnection: (factory: (genesisHash: HexString) => JsonRpcProvider | null) => VoidFunction;
87
96
  isReady(): Promise<boolean>;
88
97
  dispose(): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-container",
3
3
  "type": "module",
4
- "version": "0.6.16",
4
+ "version": "0.7.0-0",
5
5
  "description": "Host container for hosting and managing products within the Polkadot ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -25,9 +25,10 @@
25
25
  "README.md"
26
26
  ],
27
27
  "dependencies": {
28
+ "@noble/hashes": "2.0.1",
28
29
  "@polkadot-api/utils": "^0.2.0",
29
30
  "@polkadot-api/json-rpc-provider": "^0.0.4",
30
- "@novasamatech/host-api": "0.6.16",
31
+ "@novasamatech/host-api": "0.7.0-0",
31
32
  "nanoid": "5.1.7"
32
33
  },
33
34
  "devDependencies": {