@novasamatech/host-api 0.10.0 → 0.10.1
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/dist/hostApi.js +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/protocol/impl.d.ts +21 -0
- package/dist/protocol/impl.js +19 -3
- package/dist/protocol/messageCodec.d.ts +84 -1
- package/dist/protocol/v1/locale.d.ts +8 -0
- package/dist/protocol/v1/locale.js +7 -0
- package/dist/protocol/v1/system.d.ts +23 -0
- package/dist/protocol/v1/system.js +21 -0
- package/package.json +3 -3
package/dist/hostApi.js
CHANGED
|
@@ -35,6 +35,21 @@ export function createHostApi(transport) {
|
|
|
35
35
|
themeSubscribe(args, callback) {
|
|
36
36
|
return transport.subscribe('host_theme_subscribe', args, callback);
|
|
37
37
|
},
|
|
38
|
+
localeSubscribe(args, callback) {
|
|
39
|
+
return transport.subscribe('host_locale_subscribe', args, callback);
|
|
40
|
+
},
|
|
41
|
+
getProductContext(payload) {
|
|
42
|
+
return makeRequest(transport.request('host_get_product_context', payload), reason => ({
|
|
43
|
+
tag: payload.tag,
|
|
44
|
+
value: new GenericError({ reason }),
|
|
45
|
+
}));
|
|
46
|
+
},
|
|
47
|
+
info(payload) {
|
|
48
|
+
return makeRequest(transport.request('host_info', payload), reason => ({
|
|
49
|
+
tag: payload.tag,
|
|
50
|
+
value: new GenericError({ reason }),
|
|
51
|
+
}));
|
|
52
|
+
},
|
|
38
53
|
devicePermission(payload) {
|
|
39
54
|
return makeRequest(transport.request('host_device_permission', payload), reason => ({
|
|
40
55
|
tag: payload.tag,
|
package/dist/index.d.ts
CHANGED
|
@@ -35,4 +35,6 @@ export { PaymentBalance, PaymentBalanceErr, PaymentId, PaymentReceipt, PaymentRe
|
|
|
35
35
|
export { Arrangement, BorderStyle, ButtonVariant, ColorToken, ContentAlignment, CustomRendererNode, Dimensions, HorizontalAlignment, Modifier, Shape, Size, TypographyStyle, VerticalAlignment, } from './protocol/v1/customRenderer.js';
|
|
36
36
|
export { ChainHeadEvent, ChainHeadFollowV1_start, ChainIdentifier, ChainInfoErr, OperationStartedResult, RuntimeType, StorageQueryItem, StorageQueryType, StorageResultItem, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './protocol/v1/chainInteraction.js';
|
|
37
37
|
export { CoinPaymentBalance, CoinPaymentCheque, CoinPaymentErr, CoinPaymentListenForItem, CoinPaymentPurseId, CoinPaymentPurseInfo, CoinPaymentReceivable, CoinPaymentStatus, CoinPaymentTransmissionChannel, } from './protocol/v1/coinPayment.js';
|
|
38
|
+
export { HostLocale } from './protocol/v1/locale.js';
|
|
39
|
+
export { HostInfo, HostPlatform, ProductContext } from './protocol/v1/system.js';
|
|
38
40
|
export { Theme, ThemeName, ThemeVariant } from './protocol/v1/theme.js';
|
package/dist/index.js
CHANGED
|
@@ -27,4 +27,6 @@ export { PaymentBalance, PaymentBalanceErr, PaymentId, PaymentReceipt, PaymentRe
|
|
|
27
27
|
export { Arrangement, BorderStyle, ButtonVariant, ColorToken, ContentAlignment, CustomRendererNode, Dimensions, HorizontalAlignment, Modifier, Shape, Size, TypographyStyle, VerticalAlignment, } from './protocol/v1/customRenderer.js';
|
|
28
28
|
export { ChainHeadEvent, ChainHeadFollowV1_start, ChainIdentifier, ChainInfoErr, OperationStartedResult, RuntimeType, StorageQueryItem, StorageQueryType, StorageResultItem, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './protocol/v1/chainInteraction.js';
|
|
29
29
|
export { CoinPaymentBalance, CoinPaymentCheque, CoinPaymentErr, CoinPaymentListenForItem, CoinPaymentPurseId, CoinPaymentPurseInfo, CoinPaymentReceivable, CoinPaymentStatus, CoinPaymentTransmissionChannel, } from './protocol/v1/coinPayment.js';
|
|
30
|
+
export { HostLocale } from './protocol/v1/locale.js';
|
|
31
|
+
export { HostInfo, HostPlatform, ProductContext } from './protocol/v1/system.js';
|
|
30
32
|
export { Theme, ThemeName, ThemeVariant } from './protocol/v1/theme.js';
|
package/dist/protocol/impl.d.ts
CHANGED
|
@@ -1438,6 +1438,27 @@ export declare const hostApiProtocol: {
|
|
|
1438
1438
|
reason: string;
|
|
1439
1439
|
}, "RingVrfSignErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "RingVrfSignErr::KeyNotRegistered"> | import("@novasamatech/scale").CodecError<undefined, "RingVrfSignErr::NotAllowlisted">>>];
|
|
1440
1440
|
}>;
|
|
1441
|
+
readonly host_get_product_context: VersionedProtocolRequest<{
|
|
1442
|
+
readonly v1: [Codec<undefined>, Codec<import("./callError.js").CallResultValue<{
|
|
1443
|
+
productId: string;
|
|
1444
|
+
}, import("@novasamatech/scale").CodecError<{
|
|
1445
|
+
reason: string;
|
|
1446
|
+
}, "GenericError">>>];
|
|
1447
|
+
}>;
|
|
1448
|
+
readonly host_info: VersionedProtocolRequest<{
|
|
1449
|
+
readonly v1: [Codec<undefined>, Codec<import("./callError.js").CallResultValue<{
|
|
1450
|
+
platform: "Unknown" | "Web" | "Android" | "Ios" | "Desktop" | "Cli";
|
|
1451
|
+
name: string;
|
|
1452
|
+
version: string;
|
|
1453
|
+
}, import("@novasamatech/scale").CodecError<{
|
|
1454
|
+
reason: string;
|
|
1455
|
+
}, "GenericError">>>];
|
|
1456
|
+
}>;
|
|
1457
|
+
readonly host_locale_subscribe: VersionedProtocolSubscription<{
|
|
1458
|
+
readonly v1: [Codec<undefined>, Codec<{
|
|
1459
|
+
languageTag: string;
|
|
1460
|
+
}>, Codec<undefined>];
|
|
1461
|
+
}>;
|
|
1441
1462
|
readonly host_local_storage_subscribe: VersionedProtocolSubscription<{
|
|
1442
1463
|
readonly v1: [Codec<{
|
|
1443
1464
|
key: string;
|
package/dist/protocol/impl.js
CHANGED
|
@@ -11,6 +11,7 @@ import { DevicePermissionV1_request, DevicePermissionV1_response } from './v1/de
|
|
|
11
11
|
import { FeatureV1_request, FeatureV1_response } from './v1/feature.js';
|
|
12
12
|
import { HandshakeV1_request, HandshakeV1_response } from './v1/handshake.js';
|
|
13
13
|
import { StorageClearV1_request, StorageClearV1_response, StorageReadV1_request, StorageReadV1_response, StorageSubscribeV1_interrupt, StorageSubscribeV1_receive, StorageSubscribeV1_start, StorageWriteV1_request, StorageWriteV1_response, } from './v1/localStorage.js';
|
|
14
|
+
import { LocaleSubscribeV1_interrupt, LocaleSubscribeV1_receive, LocaleSubscribeV1_start } from './v1/locale.js';
|
|
14
15
|
import { NavigateToV1_request, NavigateToV1_response } from './v1/navigation.js';
|
|
15
16
|
import { PushNotificationCancelV1_request, PushNotificationCancelV1_response, PushNotificationV1_request, PushNotificationV1_response, } from './v1/notification.js';
|
|
16
17
|
import { PaymentBalanceSubscribeV1_interrupt, PaymentBalanceSubscribeV1_receive, PaymentBalanceSubscribeV1_start, PaymentRequestV1_request, PaymentRequestV1_response, PaymentStatusSubscribeV1_interrupt, PaymentStatusSubscribeV1_receive, PaymentStatusSubscribeV1_start, PaymentTopUpV1_request, PaymentTopUpV1_response, } from './v1/payments.js';
|
|
@@ -19,6 +20,7 @@ import { RemotePermissionV1_request, RemotePermissionV1_response } from './v1/re
|
|
|
19
20
|
import { RequestResourceAllocationV1_request, RequestResourceAllocationV1_response } from './v1/resourceAllocation.js';
|
|
20
21
|
import { SignPayloadV1_request, SignPayloadV1_response, SignPayloadWithLegacyAccountV1_request, SignPayloadWithLegacyAccountV1_response, SignRawV1_request, SignRawV1_response, SignRawWithLegacyAccountV1_request, SignRawWithLegacyAccountV1_response, } from './v1/sign.js';
|
|
21
22
|
import { StatementStoreCreateProofAuthorizedV1_request, StatementStoreCreateProofAuthorizedV1_response, StatementStoreCreateProofV1_request, StatementStoreCreateProofV1_response, StatementStoreSubmitV1_request, StatementStoreSubmitV1_response, StatementStoreSubscribeV1_interrupt, StatementStoreSubscribeV1_receive, StatementStoreSubscribeV1_start, } from './v1/statementStore.js';
|
|
23
|
+
import { GetProductContextV1_request, GetProductContextV1_response, HostInfoV1_request, HostInfoV1_response, } from './v1/system.js';
|
|
22
24
|
import { ThemeSubscribeV1_interrupt, ThemeSubscribeV1_receive, ThemeSubscribeV1_start } from './v1/theme.js';
|
|
23
25
|
import { WorkerBeginOperationV1_request, WorkerBeginOperationV1_response, WorkerEndOperationV1_request, WorkerEndOperationV1_response, } from './v1/worker.js';
|
|
24
26
|
const enumFromArg = (enumValues, n) => {
|
|
@@ -289,12 +291,26 @@ export const hostApiProtocol = {
|
|
|
289
291
|
host_account_ring_vrf_sign: versionedRequest(indexer.request(), {
|
|
290
292
|
v1: [AccountRingVrfSignV1_request, AccountRingVrfSignV1_response],
|
|
291
293
|
}),
|
|
292
|
-
// truapi
|
|
293
|
-
//
|
|
294
|
+
// truapi jumps from the ring-VRF block (…172) straight to request_id 190,
|
|
295
|
+
// leaving request_ids 174-188 unassigned. The prefix skips that gap so
|
|
296
|
+
// `get_product_context` lands on its truapi request_id 190.
|
|
297
|
+
host_get_product_context: versionedRequest(indexer.request(16), {
|
|
298
|
+
v1: [GetProductContextV1_request, GetProductContextV1_response],
|
|
299
|
+
}),
|
|
300
|
+
// truapi request_id 192.
|
|
301
|
+
host_info: versionedRequest(indexer.request(), {
|
|
302
|
+
v1: [HostInfoV1_request, HostInfoV1_response],
|
|
303
|
+
}),
|
|
304
|
+
// truapi start_id 194.
|
|
305
|
+
host_locale_subscribe: versionedSubscription(indexer.subscription(), {
|
|
306
|
+
v1: [LocaleSubscribeV1_start, LocaleSubscribeV1_receive, LocaleSubscribeV1_interrupt],
|
|
307
|
+
}),
|
|
308
|
+
// Not in truapi — SDK-only additions from the 0.10.0 release. They sit after
|
|
309
|
+
// every truapi-defined method so truapi keeps sole ownership of ids 0-197 and
|
|
310
|
+
// future truapi methods slot in without colliding with these.
|
|
294
311
|
host_local_storage_subscribe: versionedSubscription(indexer.subscription(), {
|
|
295
312
|
v1: [StorageSubscribeV1_start, StorageSubscribeV1_receive, StorageSubscribeV1_interrupt],
|
|
296
313
|
}),
|
|
297
|
-
// Worker background-operation keep-alive (truapi request_id 178 / 180).
|
|
298
314
|
host_worker_begin_operation: versionedRequest(indexer.request(), {
|
|
299
315
|
v1: [WorkerBeginOperationV1_request, WorkerBeginOperationV1_response],
|
|
300
316
|
}),
|
|
@@ -1523,7 +1523,33 @@ export declare const MessagePayload: EnumCodec<Record<"host_handshake_request",
|
|
|
1523
1523
|
readonly v1: Codec<import("./callError.js").CallResultValue<Uint8Array<ArrayBufferLike>, import("@novasamatech/scale").CodecError<undefined, "RingVrfSignErr::NotConnected"> | import("@novasamatech/scale").CodecError<undefined, "RingVrfSignErr::Rejected"> | import("@novasamatech/scale").CodecError<{
|
|
1524
1524
|
reason: string;
|
|
1525
1525
|
}, "RingVrfSignErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "RingVrfSignErr::KeyNotRegistered"> | import("@novasamatech/scale").CodecError<undefined, "RingVrfSignErr::NotAllowlisted">>>;
|
|
1526
|
-
}>> & Record<"
|
|
1526
|
+
}>> & Record<"host_get_product_context_request", EnumCodec<{
|
|
1527
|
+
readonly v1: Codec<undefined>;
|
|
1528
|
+
}>> & Record<"host_get_product_context_response", EnumCodec<{
|
|
1529
|
+
readonly v1: Codec<import("./callError.js").CallResultValue<{
|
|
1530
|
+
productId: string;
|
|
1531
|
+
}, import("@novasamatech/scale").CodecError<{
|
|
1532
|
+
reason: string;
|
|
1533
|
+
}, "GenericError">>>;
|
|
1534
|
+
}>> & Record<"host_info_request", EnumCodec<{
|
|
1535
|
+
readonly v1: Codec<undefined>;
|
|
1536
|
+
}>> & Record<"host_info_response", EnumCodec<{
|
|
1537
|
+
readonly v1: Codec<import("./callError.js").CallResultValue<{
|
|
1538
|
+
platform: "Unknown" | "Web" | "Android" | "Ios" | "Desktop" | "Cli";
|
|
1539
|
+
name: string;
|
|
1540
|
+
version: string;
|
|
1541
|
+
}, import("@novasamatech/scale").CodecError<{
|
|
1542
|
+
reason: string;
|
|
1543
|
+
}, "GenericError">>>;
|
|
1544
|
+
}>> & Record<"host_locale_subscribe_start", EnumCodec<{
|
|
1545
|
+
readonly v1: Codec<undefined>;
|
|
1546
|
+
}>> & Record<"host_locale_subscribe_receive", EnumCodec<{
|
|
1547
|
+
readonly v1: Codec<{
|
|
1548
|
+
languageTag: string;
|
|
1549
|
+
}>;
|
|
1550
|
+
}>> & Record<"host_locale_subscribe_interrupt", EnumCodec<{
|
|
1551
|
+
readonly v1: Codec<undefined>;
|
|
1552
|
+
}>> & Record<"host_locale_subscribe_stop", Codec<undefined>> & Record<"host_local_storage_subscribe_start", EnumCodec<{
|
|
1527
1553
|
readonly v1: Codec<{
|
|
1528
1554
|
key: string;
|
|
1529
1555
|
}>;
|
|
@@ -3614,6 +3640,63 @@ export declare const Message: Codec<{
|
|
|
3614
3640
|
reason: string;
|
|
3615
3641
|
}, "RingVrfSignErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "RingVrfSignErr::KeyNotRegistered"> | import("@novasamatech/scale").CodecError<undefined, "RingVrfSignErr::NotAllowlisted">>;
|
|
3616
3642
|
};
|
|
3643
|
+
} | {
|
|
3644
|
+
tag: "host_get_product_context_request";
|
|
3645
|
+
value: {
|
|
3646
|
+
tag: "v1";
|
|
3647
|
+
value: undefined;
|
|
3648
|
+
};
|
|
3649
|
+
} | {
|
|
3650
|
+
tag: "host_get_product_context_response";
|
|
3651
|
+
value: {
|
|
3652
|
+
tag: "v1";
|
|
3653
|
+
value: import("./callError.js").CallResultValue<{
|
|
3654
|
+
productId: string;
|
|
3655
|
+
}, import("@novasamatech/scale").CodecError<{
|
|
3656
|
+
reason: string;
|
|
3657
|
+
}, "GenericError">>;
|
|
3658
|
+
};
|
|
3659
|
+
} | {
|
|
3660
|
+
tag: "host_info_request";
|
|
3661
|
+
value: {
|
|
3662
|
+
tag: "v1";
|
|
3663
|
+
value: undefined;
|
|
3664
|
+
};
|
|
3665
|
+
} | {
|
|
3666
|
+
tag: "host_info_response";
|
|
3667
|
+
value: {
|
|
3668
|
+
tag: "v1";
|
|
3669
|
+
value: import("./callError.js").CallResultValue<{
|
|
3670
|
+
platform: "Unknown" | "Web" | "Android" | "Ios" | "Desktop" | "Cli";
|
|
3671
|
+
name: string;
|
|
3672
|
+
version: string;
|
|
3673
|
+
}, import("@novasamatech/scale").CodecError<{
|
|
3674
|
+
reason: string;
|
|
3675
|
+
}, "GenericError">>;
|
|
3676
|
+
};
|
|
3677
|
+
} | {
|
|
3678
|
+
tag: "host_locale_subscribe_start";
|
|
3679
|
+
value: {
|
|
3680
|
+
tag: "v1";
|
|
3681
|
+
value: undefined;
|
|
3682
|
+
};
|
|
3683
|
+
} | {
|
|
3684
|
+
tag: "host_locale_subscribe_receive";
|
|
3685
|
+
value: {
|
|
3686
|
+
tag: "v1";
|
|
3687
|
+
value: {
|
|
3688
|
+
languageTag: string;
|
|
3689
|
+
};
|
|
3690
|
+
};
|
|
3691
|
+
} | {
|
|
3692
|
+
tag: "host_locale_subscribe_interrupt";
|
|
3693
|
+
value: {
|
|
3694
|
+
tag: "v1";
|
|
3695
|
+
value: undefined;
|
|
3696
|
+
};
|
|
3697
|
+
} | {
|
|
3698
|
+
tag: "host_locale_subscribe_stop";
|
|
3699
|
+
value: undefined;
|
|
3617
3700
|
} | {
|
|
3618
3701
|
tag: "host_local_storage_subscribe_start";
|
|
3619
3702
|
value: {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const HostLocale: import("scale-ts").Codec<{
|
|
2
|
+
languageTag: string;
|
|
3
|
+
}>;
|
|
4
|
+
export declare const LocaleSubscribeV1_start: import("scale-ts").Codec<undefined>;
|
|
5
|
+
export declare const LocaleSubscribeV1_receive: import("scale-ts").Codec<{
|
|
6
|
+
languageTag: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const LocaleSubscribeV1_interrupt: import("scale-ts").Codec<undefined>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const HostPlatform: import("scale-ts").Codec<"Unknown" | "Web" | "Android" | "Ios" | "Desktop" | "Cli">;
|
|
2
|
+
export declare const HostInfo: import("scale-ts").Codec<{
|
|
3
|
+
platform: "Unknown" | "Web" | "Android" | "Ios" | "Desktop" | "Cli";
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const HostInfoV1_request: import("scale-ts").Codec<undefined>;
|
|
8
|
+
export declare const HostInfoV1_response: import("scale-ts").Codec<import("../callError.js").CallResultValue<{
|
|
9
|
+
platform: "Unknown" | "Web" | "Android" | "Ios" | "Desktop" | "Cli";
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
}, import("@novasamatech/scale").CodecError<{
|
|
13
|
+
reason: string;
|
|
14
|
+
}, "GenericError">>>;
|
|
15
|
+
export declare const ProductContext: import("scale-ts").Codec<{
|
|
16
|
+
productId: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const GetProductContextV1_request: import("scale-ts").Codec<undefined>;
|
|
19
|
+
export declare const GetProductContextV1_response: import("scale-ts").Codec<import("../callError.js").CallResultValue<{
|
|
20
|
+
productId: string;
|
|
21
|
+
}, import("@novasamatech/scale").CodecError<{
|
|
22
|
+
reason: string;
|
|
23
|
+
}, "GenericError">>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Status } from '@novasamatech/scale';
|
|
2
|
+
import { Struct, _void, str } from 'scale-ts';
|
|
3
|
+
import { CallResult } from '../callError.js';
|
|
4
|
+
import { GenericError } from '../commonCodecs.js';
|
|
5
|
+
// Platform category a host runs on. Variant order is the wire encoding — keep
|
|
6
|
+
// it aligned with truapi `HostPlatform`.
|
|
7
|
+
export const HostPlatform = Status('Web', 'Android', 'Ios', 'Desktop', 'Cli', 'Unknown');
|
|
8
|
+
// Identity and version of the host currently running the product.
|
|
9
|
+
export const HostInfo = Struct({
|
|
10
|
+
platform: HostPlatform,
|
|
11
|
+
name: str,
|
|
12
|
+
version: str,
|
|
13
|
+
});
|
|
14
|
+
export const HostInfoV1_request = _void;
|
|
15
|
+
export const HostInfoV1_response = CallResult(HostInfo, GenericError);
|
|
16
|
+
// Product context bound to the current host runtime.
|
|
17
|
+
export const ProductContext = Struct({
|
|
18
|
+
productId: str,
|
|
19
|
+
});
|
|
20
|
+
export const GetProductContextV1_request = _void;
|
|
21
|
+
export const GetProductContextV1_response = CallResult(ProductContext, GenericError);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@novasamatech/host-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.1",
|
|
5
5
|
"description": "Host API: transport implementation for host - product integration.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"README.md"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@novasamatech/scale": "0.10.
|
|
25
|
+
"@novasamatech/scale": "0.10.1",
|
|
26
26
|
"nanoevents": "10.0.0",
|
|
27
|
-
"nanoid": "6.0.
|
|
27
|
+
"nanoid": "6.0.1",
|
|
28
28
|
"neverthrow": "^8.2.0",
|
|
29
29
|
"scale-ts": "1.6.1"
|
|
30
30
|
},
|