@novasamatech/product-sdk 0.7.3 → 0.7.4

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
@@ -217,19 +217,19 @@ import type { ProductAccount } from '@novasamatech/product-sdk';
217
217
  // Create accounts provider instance
218
218
  const accountsProvider = createAccountsProvider();
219
219
 
220
- // Get the root (primary) account prompts for permission on first call
221
- const rootResult = await accountsProvider.getRootAccount();
220
+ // Get the user's primary DotNS username (RFC-0014)
221
+ // prompts for permission on first call
222
+ const userIdResult = await accountsProvider.getUserId();
222
223
 
223
- if (rootResult.isOk()) {
224
- const root = rootResult.value;
225
- console.log('Root account public key:', root.publicKey);
226
- console.log('Root DotNS name:', root.name);
224
+ if (userIdResult.isOk()) {
225
+ const { primaryUsername } = userIdResult.value;
226
+ console.log('Primary username:', primaryUsername);
227
227
  } else {
228
- const rootErr = rootResult.error;
229
- if (rootErr.tag === 'Rejected') {
230
- console.log('User denied access to root account');
231
- } else if (rootErr.tag === 'NotFound') {
232
- console.log('User has no DotNS account yet');
228
+ const err = userIdResult.error;
229
+ if (err.tag === 'NotConnected') {
230
+ console.log('User is not logged in');
231
+ } else if (err.tag === 'PermissionDenied') {
232
+ console.log('User denied disclosure of their primary username');
233
233
  }
234
234
  }
235
235
 
@@ -8,18 +8,16 @@ export type ProductAccount = {
8
8
  };
9
9
  export type AccountConnectionStatus = CodecType<typeof AccountConnectionStatusCodec>;
10
10
  export declare const createAccountsProvider: (transport?: Transport) => {
11
- getRootAccount(): import("neverthrow").ResultAsync<{
12
- publicKey: Uint8Array<ArrayBufferLike>;
13
- name: string | undefined;
14
- }, 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<{
11
+ getUserId(): import("neverthrow").ResultAsync<{
12
+ primaryUsername: string;
13
+ }, import("@novasamatech/scale").CodecError<undefined, "GetUserIdErr::NotConnected"> | import("@novasamatech/scale").CodecError<{
15
14
  reason: string;
16
- }, "RequestCredentialsErr::Unknown">>;
15
+ }, "GetUserIdErr::Unknown"> | import("@novasamatech/scale").CodecError<undefined, "GetUserIdErr::PermissionDenied">>;
17
16
  requestLogin(reason?: string): import("neverthrow").ResultAsync<"success" | "alreadyConnected" | "rejected", import("@novasamatech/scale").CodecError<{
18
17
  reason: string;
19
18
  }, "LoginErr::Unknown">>;
20
19
  getProductAccount(dotNsIdentifier: string, derivationIndex?: number): import("neverthrow").ResultAsync<{
21
20
  publicKey: Uint8Array<ArrayBufferLike>;
22
- name: string | undefined;
23
21
  }, 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<{
24
22
  reason: string;
25
23
  }, "RequestCredentialsErr::Unknown">>;
package/dist/accounts.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CreateProofErr, LoginErr, RequestCredentialsErr, RingLocation, SigningPayload, SigningPayloadWithoutAccount, SigningRawPayload, SigningRawPayloadWithoutAccount, assertEnumVariant, createHostApi, enumValue, fromHex, isEnumVariant, toHex, } from '@novasamatech/host-api';
1
+ import { CreateProofErr, GetUserIdErr, LoginErr, RequestCredentialsErr, RingLocation, SigningPayload, SigningPayloadWithoutAccount, SigningRawPayload, SigningRawPayloadWithoutAccount, assertEnumVariant, createHostApi, enumValue, fromHex, isEnumVariant, toHex, } from '@novasamatech/host-api';
2
2
  import { err, ok } from 'neverthrow';
3
3
  import { getPolkadotSignerFromPjs } from 'polkadot-api/pjs-signer';
4
4
  import { sandboxTransport } from './sandboxTransport.js';
@@ -6,16 +6,16 @@ const UNSUPPORTED_VERSION_ERROR = 'Unsupported message version';
6
6
  export const createAccountsProvider = (transport = sandboxTransport) => {
7
7
  const hostApi = createHostApi(transport);
8
8
  return {
9
- getRootAccount() {
9
+ getUserId() {
10
10
  return hostApi
11
- .accountGetRoot(enumValue('v1', undefined))
11
+ .getUserId(enumValue('v1', undefined))
12
12
  .mapErr(e => e.value)
13
13
  .andThen(response => {
14
14
  if (isEnumVariant(response, 'v1')) {
15
15
  return ok(response.value);
16
16
  }
17
17
  // @ts-expect-error response.tag is never here
18
- return err(new RequestCredentialsErr.Unknown({ reason: `Unsupported response version ${response.tag}` }));
18
+ return err(new GetUserIdErr.Unknown({ reason: `Unsupported response version ${response.tag}` }));
19
19
  });
20
20
  },
21
21
  requestLogin(reason) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/product-sdk",
3
3
  "type": "module",
4
- "version": "0.7.3",
4
+ "version": "0.7.4",
5
5
  "description": "Polkadot product SDK: integrate and run your product inside Polkadot browser.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@polkadot/extension-inject": "^0.63.1",
29
29
  "@polkadot-api/json-rpc-provider-proxy": "^0.4.0",
30
- "@novasamatech/host-api": "0.7.3",
30
+ "@novasamatech/host-api": "0.7.4",
31
31
  "polkadot-api": ">=2",
32
32
  "neverthrow": "^8.2.0"
33
33
  },