@novasamatech/host-container 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
@@ -181,23 +181,25 @@ container.handleThemeSubscribe((_, send, interrupt) => {
181
181
  });
182
182
  ```
183
183
 
184
- ### handleAccountGetRoot
184
+ ### handleGetUserId
185
185
 
186
- Called when a product requests the user's root (primary) account. Show a permission prompt on first call; cache the grant for the session. Return `NotFound` if the user has no DotNS username.
186
+ Called when a product requests the user's primary DotNS username (RFC-0014). Show a disclosure prompt on first call; the host decides what counts as "primary" for the calling product. Return `NotConnected` without prompting if no user is connected; return `PermissionDenied` if the user denies disclosure.
187
187
 
188
188
  ```ts
189
- import { RequestCredentialsErr } from '@novasamatech/host-api';
189
+ import { GetUserIdErr } from '@novasamatech/host-api';
190
190
 
191
- container.handleAccountGetRoot(async (_, { ok, err }) => {
192
- const granted = await promptUserForRootAccountAccess();
193
- if (!granted) {
194
- return err(new RequestCredentialsErr.Rejected());
191
+ container.handleGetUserId(async (_, { ok, err }) => {
192
+ const username = await pickPrimaryUsernameForCallingProduct();
193
+ if (!username) {
194
+ return err(new GetUserIdErr.NotConnected());
195
195
  }
196
- const rootAccount = await getRootAccount();
197
- if (!rootAccount) {
198
- return err(new RequestCredentialsErr.NotConnected());
196
+
197
+ const granted = await promptUserForUsernameDisclosure();
198
+ if (!granted) {
199
+ return err(new GetUserIdErr.PermissionDenied());
199
200
  }
200
- return ok({ publicKey: rootAccount.publicKey, name: rootAccount.name ?? undefined });
201
+
202
+ return ok({ primaryUsername: username });
201
203
  });
202
204
  ```
203
205
 
@@ -225,7 +227,7 @@ container.handleRequestLogin(async (reason, { ok, err }) => {
225
227
  container.handleAccountGet(async ([dotnsId, derivationIndex], { ok, err }) => {
226
228
  const account = await getProductAccount(dotnsId, derivationIndex);
227
229
  if (account) {
228
- return ok({ publicKey: account.publicKey, name: account.name ?? null });
230
+ return ok({ publicKey: account.publicKey });
229
231
  }
230
232
  return err({ tag: 'NotConnected' });
231
233
  });
@@ -1,4 +1,4 @@
1
- import { ChatBotRegistrationErr, ChatMessagePostingErr, ChatRoomRegistrationErr, CreateProofErr, CreateTransactionErr, DeriveEntropyErr, DevicePermission, GenericError, LoginErr, NavigateToErr, PaymentBalanceErr, PaymentRequestErr, PaymentStatusErr, PaymentTopUpErr, PreimageSubmitErr, RemotePermission, RequestCredentialsErr, SigningErr, StatementProofErr, StorageErr, createTransport, enumValue, isEnumVariant, resultErr, resultOk, } from '@novasamatech/host-api';
1
+ import { ChatBotRegistrationErr, ChatMessagePostingErr, ChatRoomRegistrationErr, CreateProofErr, CreateTransactionErr, DeriveEntropyErr, DevicePermission, GenericError, GetUserIdErr, LoginErr, NavigateToErr, PaymentBalanceErr, PaymentRequestErr, PaymentStatusErr, PaymentTopUpErr, PreimageSubmitErr, RemotePermission, 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';
@@ -154,7 +154,7 @@ export function createContainer(provider) {
154
154
  return slot.update(slotHandler);
155
155
  }
156
156
  // account slots
157
- const handleAccountGetRootSlot = makeNotImplementedSlot('host_account_get_root', () => new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED }));
157
+ const handleGetUserIdSlot = makeNotImplementedSlot('host_get_user_id', () => new GetUserIdErr.Unknown({ reason: NOT_IMPLEMENTED }));
158
158
  const handleRequestLoginSlot = makeNotImplementedSlot('host_request_login', () => new LoginErr.Unknown({ reason: NOT_IMPLEMENTED }));
159
159
  const handleAccountGetSlot = makeNotImplementedSlot('host_account_get', () => new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED }));
160
160
  const handleAccountGetAliasSlot = makeNotImplementedSlot('host_account_get_alias', () => new RequestCredentialsErr.Unknown({ reason: NOT_IMPLEMENTED }));
@@ -228,8 +228,8 @@ export function createContainer(provider) {
228
228
  handleThemeSubscribe(handler) {
229
229
  return handleV1Subscription(handleThemeSubscribeSlot, handler);
230
230
  },
231
- handleAccountGetRoot(handler) {
232
- return handleV1Request(handleAccountGetRootSlot, () => new RequestCredentialsErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
231
+ handleGetUserId(handler) {
232
+ return handleV1Request(handleGetUserIdSlot, () => new GetUserIdErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
233
233
  },
234
234
  handleRequestLogin(handler) {
235
235
  return handleV1Request(handleRequestLoginSlot, () => new LoginErr.Unknown({ reason: UNSUPPORTED_MESSAGE_FORMAT_ERROR }), handler);
package/dist/types.d.ts CHANGED
@@ -62,7 +62,7 @@ export type Container = {
62
62
  handleLocalStorageRead: InferHandler<'v1', HostApiProtocol['host_local_storage_read']>;
63
63
  handleLocalStorageWrite: InferHandler<'v1', HostApiProtocol['host_local_storage_write']>;
64
64
  handleLocalStorageClear: InferHandler<'v1', HostApiProtocol['host_local_storage_clear']>;
65
- handleAccountGetRoot: InferHandler<'v1', HostApiProtocol['host_account_get_root']>;
65
+ handleGetUserId: InferHandler<'v1', HostApiProtocol['host_get_user_id']>;
66
66
  handleRequestLogin: InferHandler<'v1', HostApiProtocol['host_request_login']>;
67
67
  handleAccountConnectionStatusSubscribe: InferHandler<'v1', HostApiProtocol['host_account_connection_status_subscribe']>;
68
68
  handleThemeSubscribe: InferHandler<'v1', HostApiProtocol['host_theme_subscribe']>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/host-container",
3
3
  "type": "module",
4
- "version": "0.7.3",
4
+ "version": "0.7.4",
5
5
  "description": "Host container for hosting and managing products within the Polkadot ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "dependencies": {
28
28
  "@noble/hashes": "2.2.0",
29
29
  "polkadot-api": ">=2",
30
- "@novasamatech/host-api": "0.7.3",
30
+ "@novasamatech/host-api": "0.7.4",
31
31
  "nanoid": "5.1.9",
32
32
  "neverthrow": "^8.2.0"
33
33
  },