@novasamatech/host-api-wrapper 0.8.10 → 0.8.11

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
@@ -250,11 +250,28 @@ if (accountResult.isOk()) {
250
250
  console.log('Public key:', account.publicKey);
251
251
  }
252
252
 
253
- // Get account alias
254
- const aliasResult = await accounts.getProductAccountAlias('product.dot', 0);
253
+ // Ring VRF: a contextual alias and a proof are addressed by a product-scoped
254
+ // `context` (`[productId, suffix]`) and a `ring` location on a chain (RFC 0004).
255
+ const context: [string, string] = ['product.dot', '0x00']; // [productId, 0x-hex suffix]
256
+ const ring = {
257
+ chainId: '0x…', // 32-byte chain genesis hash
258
+ junctions: [{ tag: 'PalletInstance', value: 42 }],
259
+ };
260
+
261
+ // Get the contextual alias for that (context, ring).
262
+ const aliasResult = await accounts.getContextualAlias(context, ring);
255
263
 
256
264
  if (aliasResult.isOk()) {
257
- console.log('Alias:', aliasResult.value);
265
+ const { context: contextBytes, alias } = aliasResult.value;
266
+ console.log('Alias:', alias);
267
+ }
268
+
269
+ // Create a ring VRF proof binding `message`; the host selects the member key.
270
+ const proofResult = await accounts.createRingVRFProof(context, ring, new Uint8Array([0x48, 0x69]));
271
+
272
+ if (proofResult.isOk()) {
273
+ const { proof, contextualAlias, ringIndex, ringRevision } = proofResult.value;
274
+ console.log('Proof:', proof, 'at ring index', ringIndex, 'revision', ringRevision);
258
275
  }
259
276
 
260
277
  // Get legacy accounts (external wallets)
@@ -1,5 +1,5 @@
1
1
  import type { AccountConnectionStatus as AccountConnectionStatusCodec, CodecType, LegacyAccount as LegacyAccountCodec, ProductAccountId as ProductAccountIdCodec, Subscription, Transport } from '@novasamatech/host-api';
2
- import { RingLocation } from '@novasamatech/host-api';
2
+ import { ProductProofContext, RingLocation } from '@novasamatech/host-api';
3
3
  import type { PolkadotSigner } from 'polkadot-api';
4
4
  export type ProductAccountId = CodecType<typeof ProductAccountIdCodec>;
5
5
  export type ProductAccount = {
@@ -25,21 +25,29 @@ export declare const createAccountsProvider: (transport?: Transport) => {
25
25
  }, import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("@novasamatech/scale").CodecError<{
26
26
  reason: string;
27
27
  }, "RequestCredentialsErr::Unknown">>;
28
- getProductAccountAlias(dotNsIdentifier: string, derivationIndex?: number): import("neverthrow").ResultAsync<{
28
+ getContextualAlias(context: CodecType<typeof ProductProofContext>, ring: CodecType<typeof RingLocation>): import("neverthrow").ResultAsync<{
29
29
  context: Uint8Array<ArrayBufferLike>;
30
30
  alias: Uint8Array<ArrayBufferLike>;
31
- }, import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("@novasamatech/scale").CodecError<{
31
+ }, import("@novasamatech/scale").CodecError<undefined, "GetAliasErr::Rejected"> | import("@novasamatech/scale").CodecError<{
32
32
  reason: string;
33
- }, "RequestCredentialsErr::Unknown">>;
33
+ }, "GetAliasErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "GetAliasErr::RingNotFound"> | import("@novasamatech/scale").CodecError<undefined, "GetAliasErr::NotMember">>;
34
34
  getLegacyAccounts(): import("neverthrow").ResultAsync<{
35
35
  publicKey: Uint8Array<ArrayBufferLike>;
36
36
  name: string | undefined;
37
37
  }[], import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("@novasamatech/scale").CodecError<{
38
38
  reason: string;
39
39
  }, "RequestCredentialsErr::Unknown">>;
40
- createRingVRFProof(dotNsIdentifier: string, derivationIndex: number | undefined, location: CodecType<typeof RingLocation>, message: Uint8Array): import("neverthrow").ResultAsync<Uint8Array<ArrayBufferLike>, import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::Rejected"> | import("@novasamatech/scale").CodecError<{
40
+ createRingVRFProof(context: CodecType<typeof ProductProofContext>, ring: CodecType<typeof RingLocation>, message: Uint8Array): import("neverthrow").ResultAsync<{
41
+ proof: Uint8Array<ArrayBufferLike>;
42
+ contextualAlias: {
43
+ context: Uint8Array<ArrayBufferLike>;
44
+ alias: Uint8Array<ArrayBufferLike>;
45
+ };
46
+ ringIndex: number;
47
+ ringRevision: number;
48
+ }, import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::Rejected"> | import("@novasamatech/scale").CodecError<{
41
49
  reason: string;
42
- }, "CreateProofErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::RingNotFound">>;
50
+ }, "CreateProofErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::RingNotFound"> | import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::NotMember">>;
43
51
  /**
44
52
  * Builds a `PolkadotSigner` that delegates to the host via `host_create_transaction`.
45
53
  *
@@ -66,21 +74,29 @@ export declare const accounts: {
66
74
  }, import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("@novasamatech/scale").CodecError<{
67
75
  reason: string;
68
76
  }, "RequestCredentialsErr::Unknown">>;
69
- getProductAccountAlias(dotNsIdentifier: string, derivationIndex?: number): import("neverthrow").ResultAsync<{
77
+ getContextualAlias(context: CodecType<typeof ProductProofContext>, ring: CodecType<typeof RingLocation>): import("neverthrow").ResultAsync<{
70
78
  context: Uint8Array<ArrayBufferLike>;
71
79
  alias: Uint8Array<ArrayBufferLike>;
72
- }, import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("@novasamatech/scale").CodecError<{
80
+ }, import("@novasamatech/scale").CodecError<undefined, "GetAliasErr::Rejected"> | import("@novasamatech/scale").CodecError<{
73
81
  reason: string;
74
- }, "RequestCredentialsErr::Unknown">>;
82
+ }, "GetAliasErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "GetAliasErr::RingNotFound"> | import("@novasamatech/scale").CodecError<undefined, "GetAliasErr::NotMember">>;
75
83
  getLegacyAccounts(): import("neverthrow").ResultAsync<{
76
84
  publicKey: Uint8Array<ArrayBufferLike>;
77
85
  name: string | undefined;
78
86
  }[], import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::NotConnected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::Rejected"> | import("@novasamatech/scale").CodecError<undefined, "RequestCredentialsErr::DomainNotValid"> | import("@novasamatech/scale").CodecError<{
79
87
  reason: string;
80
88
  }, "RequestCredentialsErr::Unknown">>;
81
- createRingVRFProof(dotNsIdentifier: string, derivationIndex: number | undefined, location: CodecType<typeof RingLocation>, message: Uint8Array): import("neverthrow").ResultAsync<Uint8Array<ArrayBufferLike>, import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::Rejected"> | import("@novasamatech/scale").CodecError<{
89
+ createRingVRFProof(context: CodecType<typeof ProductProofContext>, ring: CodecType<typeof RingLocation>, message: Uint8Array): import("neverthrow").ResultAsync<{
90
+ proof: Uint8Array<ArrayBufferLike>;
91
+ contextualAlias: {
92
+ context: Uint8Array<ArrayBufferLike>;
93
+ alias: Uint8Array<ArrayBufferLike>;
94
+ };
95
+ ringIndex: number;
96
+ ringRevision: number;
97
+ }, import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::Rejected"> | import("@novasamatech/scale").CodecError<{
82
98
  reason: string;
83
- }, "CreateProofErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::RingNotFound">>;
99
+ }, "CreateProofErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::RingNotFound"> | import("@novasamatech/scale").CodecError<undefined, "CreateProofErr::NotMember">>;
84
100
  /**
85
101
  * Builds a `PolkadotSigner` that delegates to the host via `host_create_transaction`.
86
102
  *
package/dist/accounts.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CreateProofErr, GetUserIdErr, LoginErr, RequestCredentialsErr, RingLocation, SigningPayload, SigningPayloadWithoutAccount, SigningRawPayload, SigningRawPayloadWithoutAccount, assertEnumVariant, createHostApi, enumValue, fromHex, isEnumVariant, toHex, } from '@novasamatech/host-api';
1
+ import { CreateProofErr, GetAliasErr, GetUserIdErr, LoginErr, ProductProofContext, RequestCredentialsErr, RingLocation, SigningPayload, SigningPayloadWithoutAccount, SigningRawPayload, SigningRawPayloadWithoutAccount, assertEnumVariant, createHostApi, enumValue, fromHex, isEnumVariant, toHex, } from '@novasamatech/host-api';
2
2
  import { decAnyMetadata, unifyMetadata } from '@polkadot-api/substrate-bindings';
3
3
  import { err, ok } from 'neverthrow';
4
4
  import { AccountId } from 'polkadot-api';
@@ -48,16 +48,16 @@ export const createAccountsProvider = (transport = sandboxTransport) => {
48
48
  return err(new RequestCredentialsErr.Unknown({ reason: `Unsupported response version ${response.tag}` }));
49
49
  });
50
50
  },
51
- getProductAccountAlias(dotNsIdentifier, derivationIndex = 0) {
51
+ getContextualAlias(context, ring) {
52
52
  return hostApi
53
- .accountGetAlias(enumValue('v1', [dotNsIdentifier, derivationIndex]))
53
+ .accountGetAlias(enumValue('v1', [context, ring]))
54
54
  .mapErr(e => e.value)
55
55
  .andThen(response => {
56
56
  if (isEnumVariant(response, 'v1')) {
57
57
  return ok(response.value);
58
58
  }
59
59
  // @ts-expect-error response.tag is never here
60
- return err(new RequestCredentialsErr.Unknown({ reason: `Unsupported response version ${response.tag}` }));
60
+ return err(new GetAliasErr.Unknown({ reason: `Unsupported response version ${response.tag}` }));
61
61
  });
62
62
  },
63
63
  getLegacyAccounts() {
@@ -72,9 +72,9 @@ export const createAccountsProvider = (transport = sandboxTransport) => {
72
72
  return err(new RequestCredentialsErr.Unknown({ reason: `Unsupported response version ${response.tag}` }));
73
73
  });
74
74
  },
75
- createRingVRFProof(dotNsIdentifier, derivationIndex = 0, location, message) {
75
+ createRingVRFProof(context, ring, message) {
76
76
  return hostApi
77
- .accountCreateProof(enumValue('v1', [[dotNsIdentifier, derivationIndex], location, message]))
77
+ .accountCreateProof(enumValue('v1', [context, ring, message]))
78
78
  .mapErr(e => e.value)
79
79
  .andThen(response => {
80
80
  if (isEnumVariant(response, 'v1')) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-api-wrapper",
3
3
  "type": "module",
4
- "version": "0.8.10",
4
+ "version": "0.8.11",
5
5
  "description": "Host API wrapper: integrate and run your product inside Polkadot browser.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "@polkadot/extension-inject": "^0.63.1",
29
29
  "@polkadot-api/json-rpc-provider-proxy": "^0.4.0",
30
30
  "@polkadot-api/substrate-bindings": "^0.20.3",
31
- "@novasamatech/host-api": "0.8.10",
31
+ "@novasamatech/host-api": "0.8.11",
32
32
  "polkadot-api": ">=2",
33
33
  "neverthrow": "^8.2.0"
34
34
  },