@parity/product-sdk 0.0.0-dev.312.0 → 0.0.0-dev.329.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.
Files changed (57) hide show
  1. package/dist/address/index.d.ts +3 -1
  2. package/dist/{chunk-BRZNHTLQ.js → chunk-7GM3HUZF.js} +2 -2
  3. package/dist/chunk-7GM3HUZF.js.map +1 -0
  4. package/dist/chunk-TUXU2VPS.js +14 -0
  5. package/dist/chunk-TUXU2VPS.js.map +1 -0
  6. package/dist/{chunk-DHRCWMY5.js → chunk-VWD6HK2C.js} +29 -20
  7. package/dist/chunk-VWD6HK2C.js.map +1 -0
  8. package/dist/core/index.d.ts +50 -3
  9. package/dist/core/index.js +3 -2
  10. package/dist/{dotns-bswWAmR2.d.ts → dotns-CtmOwVQW.d.ts} +2 -2
  11. package/dist/identity/index.d.ts +118 -89
  12. package/dist/identity/index.js +200 -78
  13. package/dist/identity/index.js.map +1 -1
  14. package/dist/index.d.ts +3 -53
  15. package/dist/index.js +3 -2
  16. package/dist/nfts/index.d.ts +1 -0
  17. package/dist/nfts/index.js +3 -0
  18. package/dist/nfts/index.js.map +1 -0
  19. package/dist/react/index.d.ts +5 -5
  20. package/dist/react/index.js +4 -3
  21. package/dist/react/index.js.map +1 -1
  22. package/dist/renderer/index.d.ts +1 -0
  23. package/dist/renderer/index.js +3 -0
  24. package/dist/renderer/index.js.map +1 -0
  25. package/dist/testing/index.d.ts +2 -2
  26. package/dist/testing/index.js +3 -5
  27. package/dist/testing/index.js.map +1 -1
  28. package/dist/{types-B5Zx4RNq.d.ts → types-BpWw-OJl.d.ts} +19 -9
  29. package/package.json +23 -12
  30. package/src/core/createApp.test.ts +194 -0
  31. package/src/core/createApp.ts +35 -22
  32. package/src/core/local-storage-api.ts +74 -0
  33. package/src/core/types.ts +18 -7
  34. package/src/identity/dotns-abis.ts +44 -9
  35. package/src/identity/dotns-addresses.test.ts +536 -0
  36. package/src/identity/dotns-addresses.ts +320 -0
  37. package/src/identity/dotns-errors.ts +2 -0
  38. package/src/identity/dotns-namehash.ts +2 -2
  39. package/src/identity/dotns-registry.test.ts +158 -3
  40. package/src/identity/dotns-registry.ts +71 -73
  41. package/src/identity/dotns.ts +2 -2
  42. package/src/identity/index.test.ts +43 -0
  43. package/src/identity/index.ts +10 -6
  44. package/src/identity/types.ts +0 -19
  45. package/src/index.ts +3 -2
  46. package/src/individuality/contract.test.ts +426 -2
  47. package/src/nfts/contract.test.ts +58 -0
  48. package/src/nfts/index.ts +8 -0
  49. package/src/react/context.ts +1 -1
  50. package/src/react/index.ts +1 -1
  51. package/src/react/provider.tsx +3 -3
  52. package/src/renderer/index.ts +10 -0
  53. package/src/testing.ts +14 -11
  54. package/dist/chunk-BRZNHTLQ.js.map +0 -1
  55. package/dist/chunk-DHRCWMY5.js.map +0 -1
  56. package/src/identity/product-account.test.ts +0 -130
  57. package/src/identity/product-account.ts +0 -115
@@ -1,9 +1,11 @@
1
1
  export * from '@parity/product-sdk-address';
2
- import '@parity/product-sdk-cloud-storage';
3
2
  import '@parity/product-sdk-chain-client';
3
+ import '@parity/product-sdk-cloud-storage';
4
4
  import '@parity/product-sdk-contracts';
5
5
  import '@parity/product-sdk-crypto';
6
6
  import '@parity/product-sdk-host';
7
7
  import '@parity/product-sdk-individuality';
8
8
  import '@parity/product-sdk-local-storage';
9
+ import '@parity/product-sdk-nfts';
10
+ import '@parity/product-sdk-renderer';
9
11
  import '@parity/product-sdk-signer';
@@ -85,5 +85,5 @@ function accountIdToHex(address) {
85
85
  }
86
86
 
87
87
  export { DOT_NODE, DOT_TLD, accountIdBytesToHex, accountIdHexToBytes, accountIdToHex, dotNsTld, isConsistentDotNsTld, isResolvableDotNsName, isValidDotNsName, namehash, normalizeDotNsName, resolvePeopleUsernameOwner, stripSuffix };
88
- //# sourceMappingURL=chunk-BRZNHTLQ.js.map
89
- //# sourceMappingURL=chunk-BRZNHTLQ.js.map
88
+ //# sourceMappingURL=chunk-7GM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I,KAAA,CAAM,CAAA,qCAAA,EAAwC,KAAK,CAAA,CAAE,CAAA;AAAA,EACnE;AACA,EAAA,OAAO,KAAA;AACX;AAEO,SAAS,oBAAoB,SAAA,EAAsC;AACtE,EAAA,MAAM,QAAQA,UAAAA,CAAW,SAAA,CAAU,SAAS,CAAA,CAAE,KAAA,CAAM,CAAC,CAAC,CAAA;AACtD,EAAA,IAAI,KAAA,CAAM,WAAW,EAAA,EAAI;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,gCAAA,EAAmC,KAAA,CAAM,MAAM,CAAA,MAAA,CAAQ,CAAA;AAAA,EAC3E;AACA,EAAA,OAAO,KAAA;AACX;AAGO,SAAS,oBAAoB,KAAA,EAAkC;AAClE,EAAA,IAAI,KAAA,CAAM,WAAW,EAAA,EAAI;AACrB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,gCAAA,EAAmC,KAAA,CAAM,MAAM,CAAA,MAAA,CAAQ,CAAA;AAAA,EAC3E;AACA,EAAA,OAAO,CAAA,EAAA,EAAKC,UAAAA,CAAW,KAAK,CAAC,CAAA,CAAA;AACjC;AAQO,SAAS,eAAe,OAAA,EAAgC;AAC3D,EAAA,OAAO,mBAAA,CAAoB,cAAA,CAAe,OAAO,CAAC,CAAA;AACtD","file":"chunk-7GM3HUZF.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * DotNS namehash.\n *\n * ENS-style recursive hashing, but rooted at the network's TLD node rather than\n * the empty root — matching `DotnsRegistry` (`contracts/registry/DotnsRegistry.sol`\n * `_namehash`) and `LabelUtils.namehashUnder`.\n *\n * labelhash(l) = keccak256(utf8(l))\n * node(parent, l) = keccak256(parent ‖ labelhash(l))\n * node(\"alice.paseo\") = node(tldNode, \"alice\")\n * node(\"bob.alice.paseo\") = node(node(tldNode, \"alice\"), \"bob\")\n *\n * The root is **per network**, not a constant. `DotnsProtocolRegistry.initialize`\n * fixes it once from a deploy-time label — `.paseo` on Paseo Asset Hub Next V2,\n * `.test` on Previewnet — and publishes it as `tld()` / `tldNode()`. Hashing under\n * the wrong root yields a node the chain has never written to, so every lookup\n * reports \"unregistered\" with no error anywhere. That is why {@link namehash}\n * takes the root rather than assuming one; `resolveTld` in `./dotns-registry.js`\n * is what asks the chain for it.\n */\nimport { bytesToHex, hexToBytes, keccak256 } from \"@parity/product-sdk-crypto\";\n\n/**\n * A network's DotNS top-level domain: the suffix names are spelled with, and\n * the node every one of its names hashes onto.\n *\n * The two must agree — `node` is `namehash(0, labelhash(label))` of `suffix`'s\n * label — so build one with {@link dotNsTld} rather than by hand, and check an\n * externally supplied pair with {@link isConsistentDotNsTld}. A `.paseo` suffix\n * carrying the `.dot` node is exactly the defect this type exists to prevent.\n */\nexport interface DotNsTld {\n /** Suffix including the leading dot, as `protocolRegistry.tld()` returns it. */\n suffix: string;\n /** Namehash of the TLD label, as `protocolRegistry.tldNode()` returns it. */\n node: `0x${string}`;\n}\n\n/** The `.dot` TLD node. Mirrors the `DotnsConstants.DOT_NODE` the contracts removed in `b4096968`. */\nexport const DOT_NODE = \"0x3fce7d1364a893e213bc4212792b517ffc88f5b13b86c8ef9c8d390c3a1370ce\";\n\nconst ZERO_NODE = `0x${\"00\".repeat(32)}`;\n\nconst utf8 = (s: string): Uint8Array => new TextEncoder().encode(s);\n\n/** `keccak256(parent ‖ labelhash(label))`, the one hash step every node is built from. */\nfunction nodeUnder(parent: Uint8Array, label: string): Uint8Array {\n const combined = new Uint8Array(64);\n combined.set(parent, 0);\n combined.set(keccak256(utf8(label)), 32);\n return keccak256(combined);\n}\n\n/**\n * Build a {@link DotNsTld} from a TLD suffix, deriving the node the same way the\n * contract does.\n *\n * Mirrors `DotnsProtocolRegistry.initialize`, which sets\n * `_tldNode = namehashUnder(bytes32(0), labelhash(tldLabel))`. Because the node\n * is a pure function of the label, a client only ever needs the suffix — reading\n * `tldNode()` is a cross-check, never the source.\n *\n * Accepts `\".paseo\"` or `\"paseo\"`: `tld()` returns the dotted form while\n * `initialize` and the deploy pipeline speak the bare label.\n */\nexport function dotNsTld(suffix: string): DotNsTld {\n const label = suffix.startsWith(\".\") ? suffix.slice(1) : suffix;\n return {\n suffix: `.${label}`,\n node: `0x${bytesToHex(nodeUnder(hexToBytes(ZERO_NODE.slice(2)), label))}`,\n };\n}\n\n/**\n * Whether a {@link DotNsTld} could have come from a real deployment.\n *\n * Three ways a pair fails, all of which produce silently wrong nodes rather\n * than errors if they reach {@link namehash}:\n *\n * - the node is not the derivation of the suffix (a caller mixing `.paseo`\n * with `DOT_NODE`);\n * - the suffix is empty, or the node is zero — what a pre-`b4096968` registry\n * proxy reports after an upgrade with no reinitializer, since `_tld` and\n * `_tldNode` are then still at their defaults and *both getters succeed*;\n * - the suffix is not a single label, which `initialize` rejects outright.\n *\n * Returns a boolean rather than a `Result` to keep this module free of the\n * error type; callers with an error channel (`resolveTld`) map `false` to an\n * `err` carrying the offending value.\n */\nexport function isConsistentDotNsTld(tld: DotNsTld): boolean {\n const label = tld.suffix.startsWith(\".\") ? tld.suffix.slice(1) : tld.suffix;\n if (label.length === 0 || label.includes(\".\")) return false;\n if (tld.node.toLowerCase() === ZERO_NODE) return false;\n return dotNsTld(label).node.toLowerCase() === tld.node.toLowerCase();\n}\n\n/** The `.dot` TLD, for a deployment that uses it. Not a default: pass it explicitly. */\nexport const DOT_TLD: DotNsTld = { suffix: \".dot\", node: DOT_NODE };\n\n/**\n * Drop `suffix` from the end of `name`, leaving the labels beneath it.\n *\n * Strips by the suffix's own length, which is the whole point: the same logic\n * written as `slice(0, -4)` turns `alice.paseo` into `alice.pa`, and every\n * lookup for that name then asks about a subname nobody registered. A name that\n * does not carry the suffix is returned unchanged, so a foreign suffix stays\n * visible to whatever validates next.\n *\n * Lives here rather than in `./dotns.js` so the one copy is reachable from this\n * module without pulling its heavier imports in.\n */\nexport function stripSuffix(name: string, suffix: string): string {\n return name.endsWith(suffix) ? name.slice(0, -suffix.length) : name;\n}\n\n/**\n * Compute the DotNS node hash for a name like `\"alice.paseo\"` or\n * `\"bob.alice.paseo\"`, rooted at `tld`.\n *\n * The trailing suffix is the TLD (folded into `tld.node`); remaining labels are\n * hashed most-significant-last, so `bob.alice.paseo` layers `bob` on top of\n * `alice` on top of the TLD. Input is used as-is — normalize with\n * `normalizeDotNsName` first if needed.\n *\n * `tld` is required rather than defaulted, because a default that is correct on\n * one deployment is the defect this module was fixed for. It is also not\n * validated here: a name whose suffix belongs to another deployment hashes to a\n * node under `tld` instead of being refused, since this function returns a hash\n * and has nowhere to report a complaint. The entry points in\n * `./dotns-registry.js` do that check, where there is an error channel.\n *\n * @returns the 32-byte node as a `0x`-prefixed hex string.\n */\nexport function namehash(name: string, tld: DotNsTld): `0x${string}` {\n const trimmed = stripSuffix(name, tld.suffix);\n // \"\" → the bare TLD node; otherwise split into labels.\n const labels = trimmed === \"\" ? [] : trimmed.split(\".\");\n // Layer from the TLD outward: labels are given left-most-first\n // (bob.alice), but must be applied right-to-left onto the parent.\n // Annotated: hexToBytes yields ArrayBufferLike, keccak256 yields ArrayBuffer.\n let node: Uint8Array = hexToBytes(tld.node.slice(2));\n for (let i = labels.length - 1; i >= 0; i--) {\n node = nodeUnder(node, labels[i]);\n }\n return `0x${bytesToHex(node)}`;\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * DotNS (Polkadot Name Service) utilities\n *\n * Name validation and normalization. Every helper here takes the deployment's\n * TLD suffix rather than assuming `.dot`: the TLD is fixed per network when the\n * contracts initialise, so the same string is a valid name on one deployment\n * and meaningless on another. `resolveTld` in `./dotns-registry.js` is what\n * asks the chain which suffix is in play.\n */\n\nimport { accountIdBytes } from \"@parity/product-sdk-address\";\nimport { bytesToHex, hexToBytes } from \"@parity/product-sdk-crypto\";\nimport { stripSuffix } from \"./dotns-namehash.js\";\nimport type {\n ChainDefinition,\n PalletsTypedef,\n PlainDescriptor,\n RuntimeDescriptor,\n SS58String,\n StorageDescriptor,\n TxDescriptor,\n} from \"polkadot-api\";\n\ntype AnyDescriptorEntry<T> = Record<string, Record<string, T>>;\n\ntype PeopleUsernameStorage = {\n Resources: {\n UsernameOwnerOf: StorageDescriptor<[Uint8Array], SS58String, true, never>;\n };\n};\n\ntype PeopleUsernamePallets = PalletsTypedef<\n PeopleUsernameStorage,\n AnyDescriptorEntry<TxDescriptor<any>>,\n AnyDescriptorEntry<PlainDescriptor<any>>,\n AnyDescriptorEntry<PlainDescriptor<any>>,\n AnyDescriptorEntry<PlainDescriptor<any>>,\n AnyDescriptorEntry<RuntimeDescriptor<any, any>>\n>;\n\n/**\n * Descriptor narrowed to \"any chain that exposes `Resources.UsernameOwnerOf`\".\n *\n * Used as the input to `signMessageWithDotNsIdentity` so the SDK doesn't pin\n * a specific People-chain genesis — anything with the right storage shape\n * (paseo-individuality today, future People Lite, etc.) is accepted.\n */\nexport type PeopleUsernameChain = ChainDefinition & {\n descriptors: Promise<unknown> & {\n pallets: PeopleUsernamePallets;\n };\n};\n\n/**\n * Minimal typed-api shape required to resolve a username on a People chain.\n *\n * This is a narrow structural type — anything with the right\n * `query.Resources.UsernameOwnerOf.getValue` shape works, including a real\n * `TypedApi<PeopleUsernameChain>` slice of a `ChainClient` or a hand-rolled\n * test double.\n */\nexport type PeopleUsernameQueryApi = {\n query: {\n Resources: {\n UsernameOwnerOf: {\n getValue: (key: Uint8Array) => Promise<SS58String | undefined>;\n };\n };\n };\n};\n\n/**\n * Whether `name` is a single registrable label under `suffix`.\n *\n * `suffix` is the deployment's own TLD, including its leading dot, as\n * `resolveTld` reports it — `\".paseo\"` on Paseo Asset Hub Next V2, `\".test\"`\n * on Previewnet. It is required rather than defaulted, because a name is only\n * valid *relative to a deployment*: `alice.dot` is registrable on one network\n * and meaningless on the other, and a default would silently pick one.\n *\n * @param name - Name to validate, already normalized by {@link normalizeDotNsName}\n * @param suffix - The deployment's TLD suffix, e.g. `\".paseo\"`\n */\nexport function isValidDotNsName(name: string, suffix: string): boolean {\n if (!name.endsWith(suffix)) return false;\n return isValidLabel(stripSuffix(name, suffix));\n}\n\n/**\n * One canonical DNS label, matching the on-chain rule.\n *\n * `StringUtils.isSingleLabel` allows lowercase ASCII, digits and non-edge\n * hyphens up to 63 characters, and the registrar additionally requires 3.\n */\nfunction isValidLabel(label: string): boolean {\n if (label.length < 3 || label.length > 63) return false;\n return /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(label);\n}\n\n/**\n * Whether a name can be resolved: one or more valid labels under `suffix`.\n *\n * Broader than {@link isValidDotNsName} on purpose. The registrar only mints\n * single labels, so registration keeps the stricter rule, but the registry\n * supports subnodes and `namehash` hashes them, so `bob.alice.paseo` is\n * resolvable even though it is not registrable.\n *\n * @param name - Name to check, already normalized by {@link normalizeDotNsName}\n * @param suffix - The deployment's TLD suffix, e.g. `\".paseo\"`\n */\nexport function isResolvableDotNsName(name: string, suffix: string): boolean {\n if (!name.endsWith(suffix)) return false;\n const labels = stripSuffix(name, suffix).split(\".\");\n return labels.length > 0 && labels.every(isValidLabel);\n}\n\n/**\n * Normalize a DotNS name for the deployment identified by `suffix`.\n *\n * Case-folds, applies NFC, trims surrounding whitespace, and drops a single\n * trailing root dot, so `Alice.PASEO.` keys the same as `alice.paseo`. This\n * mirrors `normalize_host` in truapi-server, which is what turns a URL into a\n * dotNS identifier — a name arriving from navigation has to key identically\n * here or the two layers disagree about the same input.\n *\n * The NFC step is defensive only: {@link isValidLabel} and the on-chain\n * `StringUtils.isSingleLabel` both allow lowercase ASCII alone, so no name that\n * survives validation can differ between its composed and decomposed spellings.\n * It costs nothing and it keeps this function honest if the label rule ever\n * widens.\n *\n * **The suffix is appended only when `name` contains no dot at all.** A bare\n * label is the friendly path and gets the deployment's suffix; anything already\n * carrying a dot is left exactly as written, so a name from another deployment\n * survives to be refused by validation rather than being buried under our own\n * suffix. Appending on `!endsWith(suffix)` instead would turn `alice.dot` into\n * `alice.dot.paseo`, which is a well-formed subname and would resolve silently\n * to a node nobody owns.\n *\n * The cost of that rule: a bare multi-label name such as `bob.alice` is no\n * longer completed to `bob.alice.paseo`. Distinguishing it from `alice.dot`\n * would require a hardcoded list of every network's TLD, and there are already\n * more TLDs deployed than any such list contains.\n *\n * @param name - Name to normalize\n * @param suffix - The deployment's TLD suffix, e.g. `\".paseo\"`\n */\nexport function normalizeDotNsName(name: string, suffix: string): string {\n const folded = name.trim().normalize(\"NFC\").toLowerCase();\n const normalized = folded.endsWith(\".\") ? folded.slice(0, -1) : folded;\n return normalized.includes(\".\") ? normalized : normalized + suffix;\n}\n\n// `resolveDotNs` / `reverseDotNs` / `isDotNsAvailable` now live in\n// `./dotns-registry.ts` (real `Result`-returning registry calls), replacing the\n// throwing skeletons that used to sit here. See that module + the design doc.\n\n/**\n * Resolve a People / People Lite username to its owning account.\n *\n * Queries `Resources.UsernameOwnerOf` on the caller-supplied typed-api fragment.\n * The returned value is the SS58 address the storage yields, or `null` when no\n * owner is registered for that username.\n *\n * Returns SS58 rather than hex because that is both the form the storage yields\n * and the form `Resources.Consumers` is keyed by, so reading an account's\n * usernames from this result needs no conversion. Callers that want the raw\n * 32-byte key use `accountIdBytes` from `@parity/product-sdk-address`, and\n * {@link accountIdToHex} for the hex form.\n *\n * The `username` is UTF-8 encoded as-is — no normalization is applied. Pass\n * the exact byte string the chain stores (typically with the `.dot` suffix).\n *\n * @internal Exposed for unit testing. Consumers should use\n * `wallet.signMessageWithDotNsIdentity` instead, which orchestrates the\n * chain-connection lifecycle.\n */\nexport async function resolvePeopleUsernameOwner(\n username: string,\n peopleApi: PeopleUsernameQueryApi,\n): Promise<SS58String | null> {\n const owner = await peopleApi.query.Resources.UsernameOwnerOf.getValue(\n new TextEncoder().encode(username),\n );\n return owner ?? null;\n}\n\nfunction assertHex(value: string): `0x${string}` {\n if (!/^0x[0-9a-fA-F]*$/.test(value)) {\n throw new Error(`Expected 0x-prefixed hex string, got ${value}`);\n }\n return value as `0x${string}`;\n}\n\nexport function accountIdHexToBytes(accountId: `0x${string}`): Uint8Array {\n const bytes = hexToBytes(assertHex(accountId).slice(2));\n if (bytes.length !== 32) {\n throw new Error(`Expected 32-byte AccountId, got ${bytes.length} bytes`);\n }\n return bytes;\n}\n\n/** Throws on any input that is not exactly 32 bytes, rather than padding it. */\nexport function accountIdBytesToHex(bytes: Uint8Array): `0x${string}` {\n if (bytes.length !== 32) {\n throw new Error(`Expected 32-byte AccountId, got ${bytes.length} bytes`);\n }\n return `0x${bytesToHex(bytes)}`;\n}\n\n/**\n * The inverse of {@link accountIdHexToBytes}.\n *\n * No in-repo caller: this is the migration path for consumers, after\n * `resolvePeopleUsernameOwner` changed from hex to SS58. Not dead code.\n */\nexport function accountIdToHex(address: string): `0x${string}` {\n return accountIdBytesToHex(accountIdBytes(address));\n}\n"]}
@@ -0,0 +1,14 @@
1
+ // src/core/local-storage-api.ts
2
+ function createLocalStorageApi(kv) {
3
+ return {
4
+ get: (key) => kv.get(key),
5
+ set: (key, value) => kv.set(key, value),
6
+ getJSON: (key) => kv.getJSON(key),
7
+ setJSON: (key, value) => kv.setJSON(key, value),
8
+ remove: (key) => kv.remove(key)
9
+ };
10
+ }
11
+
12
+ export { createLocalStorageApi };
13
+ //# sourceMappingURL=chunk-TUXU2VPS.js.map
14
+ //# sourceMappingURL=chunk-TUXU2VPS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/local-storage-api.ts"],"names":[],"mappings":";AAgBO,SAAS,sBAAsB,EAAA,EAAmC;AACrE,EAAA,OAAO;AAAA,IACH,GAAA,EAAK,CAAC,GAAA,KAAQ,EAAA,CAAG,IAAI,GAAG,CAAA;AAAA,IACxB,KAAK,CAAC,GAAA,EAAK,UAAU,EAAA,CAAG,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,IACtC,OAAA,EAAS,CAAI,GAAA,KAAgB,EAAA,CAAG,QAAW,GAAG,CAAA;AAAA,IAC9C,SAAS,CAAI,GAAA,EAAa,UAAa,EAAA,CAAG,OAAA,CAAQ,KAAK,KAAK,CAAA;AAAA,IAC5D,MAAA,EAAQ,CAAC,GAAA,KAAQ,EAAA,CAAG,OAAO,GAAG;AAAA,GAClC;AACJ","file":"chunk-TUXU2VPS.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * The one adapter from a {@link LocalKvStore} to the SDK's {@link LocalStorageApi}.\n *\n * Both `createApp` (host-backed store) and `createFakeApp` (in-memory store)\n * build their `localStorage` through here, so the shipped adapter and the test\n * fake cannot drift — which is exactly how `clear()` came to be a no-op in\n * production while the fake emptied (#344). The in-source test below drives one\n * assertion set through this factory over an in-memory store; anything the fake\n * exposes, the real path exposes the same way.\n */\nimport type { LocalKvStore } from \"@parity/product-sdk-local-storage\";\nimport type { LocalStorageApi } from \"./types.js\";\n\n/** Wrap a {@link LocalKvStore} as the SDK's {@link LocalStorageApi}. */\nexport function createLocalStorageApi(kv: LocalKvStore): LocalStorageApi {\n return {\n get: (key) => kv.get(key),\n set: (key, value) => kv.set(key, value),\n getJSON: <T>(key: string) => kv.getJSON<T>(key),\n setJSON: <T>(key: string, value: T) => kv.setJSON(key, value),\n remove: (key) => kv.remove(key),\n };\n}\n\nif (import.meta.vitest) {\n const { describe, test, expect } = import.meta.vitest;\n\n /** A minimal in-memory {@link LocalKvStore}, string- and JSON-aware. */\n function memoryKvStore(): LocalKvStore {\n const store = new Map<string, string>();\n return {\n async get(key) {\n return store.get(key) ?? null;\n },\n async set(key, value) {\n store.set(key, value);\n },\n async remove(key) {\n store.delete(key);\n },\n async getJSON<T>(key: string) {\n const raw = store.get(key);\n return raw === undefined ? null : (JSON.parse(raw) as T);\n },\n async setJSON(key, value) {\n store.set(key, JSON.stringify(value));\n },\n };\n }\n\n describe(\"createLocalStorageApi\", () => {\n test(\"round-trips strings and JSON, and remove deletes one key\", async () => {\n const api = createLocalStorageApi(memoryKvStore());\n\n await api.set(\"k\", \"v\");\n await api.setJSON(\"o\", { n: 1 });\n expect(await api.get(\"k\")).toBe(\"v\");\n expect(await api.getJSON(\"o\")).toEqual({ n: 1 });\n expect(await api.get(\"missing\")).toBeNull();\n\n await api.remove(\"k\");\n expect(await api.get(\"k\")).toBeNull();\n // No clear-all: an untouched key stays.\n expect(await api.getJSON(\"o\")).toEqual({ n: 1 });\n });\n\n test(\"exposes exactly the LocalStorageApi surface — no clear()\", () => {\n const api = createLocalStorageApi(memoryKvStore());\n expect(Object.keys(api).sort()).toEqual([\"get\", \"getJSON\", \"remove\", \"set\", \"setJSON\"]);\n });\n });\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { resolvePeopleUsernameOwner, accountIdBytesToHex } from './chunk-BRZNHTLQ.js';
1
+ import { resolvePeopleUsernameOwner, accountIdBytesToHex } from './chunk-7GM3HUZF.js';
2
+ import { createLocalStorageApi } from './chunk-TUXU2VPS.js';
2
3
  import { createLogger, configure } from '@parity/product-sdk-logger';
3
4
  import { createLocalKvStore } from '@parity/product-sdk-local-storage';
4
5
  import { SignerManager } from '@parity/product-sdk-signer';
@@ -6,17 +7,34 @@ import { CloudStorageClient, createLazySigner, calculateCid, ProductCloudStorage
6
7
  import { err, ok } from '@parity/result';
7
8
  import { isConnected, getClient, createChainClient, destroyAll } from '@parity/product-sdk-chain-client';
8
9
  import { accountIdBytes } from '@parity/product-sdk-address';
9
- import { getAccountsProvider } from '@parity/product-sdk-host';
10
+ import { getTruApi, HostUnavailableError, HostCallFailedError, getAccountsProvider } from '@parity/product-sdk-host';
10
11
 
11
12
  var log = createLogger("app");
12
- async function createApp(config) {
13
+ async function createApp(config = {}) {
13
14
  if (config.logLevel) {
14
15
  configure({ level: config.logLevel });
15
16
  }
16
- log.info("Creating Product SDK app", { name: config.name });
17
- const localKvStore = await createLocalKvStore({ prefix: config.name });
17
+ if (config.name !== void 0) {
18
+ log.warn(
19
+ "createApp: name is deprecated and ignored. Remove the name option. The SDK resolves the app name from system.getProductContext(), dropping the product ID's final domain suffix (my-app.dot -> my-app). Local development IDs stay unchanged."
20
+ );
21
+ }
22
+ const truApi = await getTruApi();
23
+ if (!truApi) {
24
+ throw new HostUnavailableError("createApp requires a host product context");
25
+ }
26
+ const { productId } = await truApi.system.getProductContext().match(
27
+ (context) => context,
28
+ (error) => {
29
+ throw new HostCallFailedError("system.getProductContext", error);
30
+ }
31
+ );
32
+ const isLocalHost = /^(?:localhost|127\.0\.0\.1|[^:]+\.localhost)(?::\d+)?$/i.test(productId);
33
+ const name = isLocalHost ? productId : productId.replace(/\.[^.]+$/, "");
34
+ log.info("Creating Product SDK app", { name });
35
+ const localKvStore = await createLocalKvStore({ prefix: name });
18
36
  const signerManager = new SignerManager({
19
- dappName: config.name
37
+ dappName: productId
20
38
  });
21
39
  const cloudStorageEnabled = config.cloudStorage !== false;
22
40
  const cloudStorageEnvironment = typeof config.cloudStorage === "object" ? config.cloudStorage.environment : "paseo";
@@ -31,16 +49,7 @@ async function createApp(config) {
31
49
  } else {
32
50
  log.debug("Cloud Storage client disabled");
33
51
  }
34
- const localStorageApi = {
35
- get: (key) => localKvStore.get(key),
36
- set: (key, value) => localKvStore.set(key, value),
37
- getJSON: (key) => localKvStore.getJSON(key),
38
- setJSON: (key, value) => localKvStore.setJSON(key, value),
39
- remove: (key) => localKvStore.remove(key),
40
- clear: async () => {
41
- log.debug("clear() is not supported in container storage mode");
42
- }
43
- };
52
+ const localStorageApi = createLocalStorageApi(localKvStore);
44
53
  const walletApi = createWalletApi(signerManager);
45
54
  const chainApi = {
46
55
  getClient(descriptor) {
@@ -90,7 +99,7 @@ async function createApp(config) {
90
99
  }
91
100
  } : null;
92
101
  log.info("Product SDK app created", {
93
- name: config.name,
102
+ name,
94
103
  cloudStorage: cloudStorageEnabled ? cloudStorageEnvironment : "disabled"
95
104
  });
96
105
  return {
@@ -98,7 +107,7 @@ async function createApp(config) {
98
107
  localStorage: localStorageApi,
99
108
  chain: chainApi,
100
109
  cloudStorage: cloudStorageApi,
101
- getAppInfo: () => ({ ...config })
110
+ getAppInfo: () => ({ ...config, name })
102
111
  };
103
112
  }
104
113
  function createWalletApi(signerManager) {
@@ -236,5 +245,5 @@ async function getPrimaryUsername(accountsProvider) {
236
245
  }
237
246
 
238
247
  export { createApp };
239
- //# sourceMappingURL=chunk-DHRCWMY5.js.map
240
- //# sourceMappingURL=chunk-DHRCWMY5.js.map
248
+ //# sourceMappingURL=chunk-VWD6HK2C.js.map
249
+ //# sourceMappingURL=chunk-VWD6HK2C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/createApp.ts"],"names":["err"],"mappings":";;;;;;;;;;;AAgDA,IAAM,GAAA,GAAM,aAAa,KAAK,CAAA;AAuC9B,eAAsB,SAAA,CAAU,MAAA,GAAoB,EAAC,EAAiB;AAElE,EAAA,IAAI,OAAO,QAAA,EAAU;AACjB,IAAA,SAAA,CAAU,EAAE,KAAA,EAAO,MAAA,CAAO,QAAA,EAAU,CAAA;AAAA,EACxC;AAEA,EAAA,IAAI,MAAA,CAAO,SAAS,MAAA,EAAW;AAC3B,IAAA,GAAA,CAAI,IAAA;AAAA,MACA;AAAA,KACJ;AAAA,EACJ;AAEA,EAAA,MAAM,MAAA,GAAS,MAAM,SAAA,EAAU;AAC/B,EAAA,IAAI,CAAC,MAAA,EAAQ;AACT,IAAA,MAAM,IAAI,qBAAqB,2CAA2C,CAAA;AAAA,EAC9E;AACA,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,MAAM,MAAA,CAAO,MAAA,CAAO,mBAAkB,CAAE,KAAA;AAAA,IAC1D,CAAC,OAAA,KAAY,OAAA;AAAA,IACb,CAAC,KAAA,KAAU;AACP,MAAA,MAAM,IAAI,mBAAA,CAAoB,0BAAA,EAA4B,KAAK,CAAA;AAAA,IACnE;AAAA,GACJ;AAEA,EAAA,MAAM,WAAA,GAAc,yDAAA,CAA0D,IAAA,CAAK,SAAS,CAAA;AAC5F,EAAA,MAAM,OAAO,WAAA,GAAc,SAAA,GAAY,SAAA,CAAU,OAAA,CAAQ,YAAY,EAAE,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AA;AAAA,IACX,CAAA;AAAA,IAEA,MAAM,YAAY,QAAA,EAA2C;AAEzD,MAAA,MAAM,IAAI,KAAA;AAAA,QACN;AAAA,OAEJ;AAAA,IACJ;AAAA,GACJ;AACJ;AAIA,eAAe,uBAAA,GAAyD;AACpE,EAAA,MAAM,QAAA,GAAW,MAAM,mBAAA,EAAoB;AAC3C,EAAA,IAAI,CAAC,QAAA,EAAU;AACX,IAAA,MAAM,IAAI,MAAM,yCAAyC,CAAA;AAAA,EAC7D;AACA,EAAA,OAAO,QAAA;AACX;AAEA,eAAe,mBAAmB,gBAAA,EAAyD;AACvF,EAAA,MAAM,MAAA,GAAS,MAAM,gBAAA,CAAiB,SAAA,EAAU,CAAE,KAAA;AAAA,IAC9C,CAAC,KAAA,KAAU,KAAA;AAAA,IACX,CAACA,IAAAA,KAAQ;AACL,MAAA,MAAMA,IAAAA;AAAA,IACV;AAAA,GACJ;AACA,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,eAAA,CAAgB,IAAA,EAAK;AAC7C,EAAA,IAAI,CAAC,QAAA,EAAU;AACX,IAAA,MAAM,IAAI,MAAM,wDAAwD,CAAA;AAAA,EAC5E;AACA,EAAA,OAAO,QAAA;AACX","file":"chunk-VWD6HK2C.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * createApp - Main entry point for the Product SDK\n *\n * Creates an App instance with wallet, storage, chain, and cloud storage APIs.\n */\n\nimport type { ChainDefinition } from \"polkadot-api\";\nimport type {\n App,\n AppConfig,\n WalletApi,\n ChainApi,\n Account,\n CloudStorageApi,\n LocalStorageApi,\n} from \"./types.js\";\nimport { createLocalStorageApi } from \"./local-storage-api.js\";\nimport { configure, createLogger } from \"@parity/product-sdk-logger\";\nimport { createLocalKvStore } from \"@parity/product-sdk-local-storage\";\nimport { SignerManager } from \"@parity/product-sdk-signer\";\nimport {\n CloudStorageClient,\n ProductCloudStorageError,\n calculateCid,\n createLazySigner,\n} from \"@parity/product-sdk-cloud-storage\";\nimport { err, ok } from \"@parity/result\";\nimport {\n createChainClient,\n getClient,\n isConnected,\n destroyAll,\n} from \"@parity/product-sdk-chain-client\";\nimport { accountIdBytes } from \"@parity/product-sdk-address\";\nimport {\n getAccountsProvider,\n getTruApi,\n HostCallFailedError,\n HostUnavailableError,\n} from \"@parity/product-sdk-host\";\nimport {\n accountIdBytesToHex,\n type PeopleUsernameQueryApi,\n resolvePeopleUsernameOwner,\n} from \"../identity/dotns.js\";\n\nconst log = createLogger(\"app\");\n\n/**\n * Create a new Product SDK app instance\n *\n * @param config - Application configuration\n * @returns App instance with all APIs\n *\n * @example\n * ```ts\n * import { createApp } from '@parity/product-sdk';\n *\n * // Default: cloud storage enabled with paseo environment\n * const app = await createApp({\n * logLevel: 'info',\n * });\n *\n * // Custom cloud storage environment\n * const prodApp = await createApp({\n * cloudStorage: { environment: 'polkadot' },\n * });\n *\n * // Disable cloud storage entirely\n * const noCloudStorageApp = await createApp({\n * cloudStorage: false,\n * });\n *\n * // Connect wallet\n * const { accounts } = await app.wallet.connect();\n *\n * // Use storage\n * await app.localStorage.set('key', 'value');\n *\n * // Use cloud storage (check for null if it might be disabled)\n * if (app.cloudStorage) {\n * const cid = await app.cloudStorage.upload('hello world');\n * }\n * ```\n */\nexport async function createApp(config: AppConfig = {}): Promise<App> {\n // Set log level if specified\n if (config.logLevel) {\n configure({ level: config.logLevel });\n }\n\n if (config.name !== undefined) {\n log.warn(\n \"createApp: name is deprecated and ignored. Remove the name option. The SDK resolves the app name from system.getProductContext(), dropping the product ID's final domain suffix (my-app.dot -> my-app). Local development IDs stay unchanged.\",\n );\n }\n\n const truApi = await getTruApi();\n if (!truApi) {\n throw new HostUnavailableError(\"createApp requires a host product context\");\n }\n const { productId } = await truApi.system.getProductContext().match(\n (context) => context,\n (error) => {\n throw new HostCallFailedError(\"system.getProductContext\", error);\n },\n );\n\n const isLocalHost = /^(?:localhost|127\\.0\\.0\\.1|[^:]+\\.localhost)(?::\\d+)?$/i.test(productId);\n const name = isLocalHost ? productId : productId.replace(/\\.[^.]+$/, \"\");\n\n log.info(\"Creating Product SDK app\", { name });\n\n // Initialize storage (container-only - will throw if not in container)\n const localKvStore = await createLocalKvStore({ prefix: name });\n\n // Initialize signer manager\n const signerManager = new SignerManager({\n dappName: productId,\n });\n\n // Initialize cloud storage client (configurable, defaults to paseo).\n //\n // The signer is wrapped lazily so the cloud storage client can be built before\n // an account is selected. Uploads will throw a clear error if no signer\n // is available at submission time. Reads (fetch / fetchJson) don't need\n // a signer, so they work regardless of whether an account is selected --\n // but they are container-only and throw CloudStorageHostUnavailableError\n // outside a host container (no IPFS-gateway fallback).\n const cloudStorageEnabled = config.cloudStorage !== false;\n const cloudStorageEnvironment =\n typeof config.cloudStorage === \"object\" ? config.cloudStorage.environment : \"paseo\";\n const cloudStorageClient = cloudStorageEnabled\n ? await CloudStorageClient.create({\n environment: cloudStorageEnvironment,\n signer: createLazySigner(() => signerManager.getSigner()),\n })\n : null;\n\n if (cloudStorageEnabled) {\n log.debug(\"Cloud Storage client (Bulletin) initialized\", {\n environment: cloudStorageEnvironment,\n });\n } else {\n log.debug(\"Cloud Storage client disabled\");\n }\n\n // Storage API adapter — shared with `createFakeApp` so the two cannot drift.\n const localStorageApi: LocalStorageApi = createLocalStorageApi(localKvStore);\n\n // Create wallet API adapter\n const walletApi = createWalletApi(signerManager);\n\n // Create chain API\n const chainApi: ChainApi = {\n getClient(descriptor) {\n log.debug(\"getClient called\", { genesis: descriptor.genesis });\n const client = getClient(descriptor);\n return client.getTypedApi(descriptor);\n },\n\n getRawClient(descriptor) {\n log.debug(\"getRawClient called\", { genesis: descriptor.genesis });\n return getClient(descriptor);\n },\n\n async connect<T extends Record<string, ChainDefinition>>(chains: T) {\n log.debug(\"connect called\", { chains: Object.keys(chains) });\n return createChainClient({ chains });\n },\n\n isConnected(descriptor) {\n return isConnected(descriptor);\n },\n\n destroyAll() {\n log.debug(\"destroyAll called\");\n destroyAll();\n },\n };\n\n // Create Cloud Storage API adapter (null if disabled)\n const cloudStorageApi: CloudStorageApi | null = cloudStorageClient\n ? {\n upload: async (data) => {\n const bytes = typeof data === \"string\" ? new TextEncoder().encode(data) : data;\n try {\n // Explicitly request a DAG-PB manifest so chunked uploads always\n // resolve to a single root CID. Without this, AsyncBulletinClient\n // can return `result.cid: undefined` for chunked-without-manifest\n // uploads — but app consumers expect a CID they can hand to\n // `fetch(cid)`, so treat a missing CID as an error.\n const uploaded = await cloudStorageClient\n .store(bytes)\n .withManifest(true)\n .send();\n if (!uploaded.cid) {\n return err(\n new ProductCloudStorageError(\n \"Cloud storage upload returned no CID despite .withManifest(true). Upstream contract may have shifted — file an issue.\",\n ),\n );\n }\n return ok(uploaded.cid.toString());\n } catch (cause) {\n const message = cause instanceof Error ? cause.message : String(cause);\n return err(new ProductCloudStorageError(message, { cause }));\n }\n },\n fetch: (cid) => cloudStorageClient.fetchBytes(cid),\n computeCid: async (data) => {\n const bytes = typeof data === \"string\" ? new TextEncoder().encode(data) : data;\n const cid = await calculateCid(bytes);\n return cid.toString();\n },\n }\n : null;\n\n log.info(\"Product SDK app created\", {\n name,\n cloudStorage: cloudStorageEnabled ? cloudStorageEnvironment : \"disabled\",\n });\n\n return {\n wallet: walletApi,\n localStorage: localStorageApi,\n chain: chainApi,\n cloudStorage: cloudStorageApi,\n getAppInfo: () => ({ ...config, name }),\n };\n}\n\n/**\n * Create wallet API adapter using SignerManager from leaf package\n */\nfunction createWalletApi(signerManager: SignerManager): WalletApi {\n // Track account change subscribers\n const accountChangeSubscribers = new Set<(account: Account | null) => void>();\n\n // Subscribe to signer manager state changes\n signerManager.subscribe((state) => {\n const account = state.selectedAccount\n ? {\n address: state.selectedAccount.address,\n name: state.selectedAccount.name ?? undefined,\n source: state.selectedAccount.source,\n }\n : null;\n for (const callback of accountChangeSubscribers) {\n try {\n callback(account);\n } catch (e) {\n log.warn(\"Account change callback threw\", { error: e });\n }\n }\n });\n\n return {\n async connect(): Promise<{ accounts: Account[] }> {\n const result = await signerManager.connect();\n if (!result.ok) {\n throw new Error(result.error.message);\n }\n return {\n accounts: result.value.map((a) => ({\n address: a.address,\n name: a.name ?? undefined,\n source: a.source,\n })),\n };\n },\n\n async disconnect(): Promise<void> {\n signerManager.disconnect();\n },\n\n getAccounts(): Account[] {\n return signerManager.getState().accounts.map((a) => ({\n address: a.address,\n name: a.name ?? undefined,\n source: a.source,\n }));\n },\n\n getSelectedAccount(): Account | null {\n const selected = signerManager.getState().selectedAccount;\n if (!selected) return null;\n return {\n address: selected.address,\n name: selected.name ?? undefined,\n source: selected.source,\n };\n },\n\n selectAccount(address: string): void {\n signerManager.selectAccount(address);\n },\n\n async signMessage(message: string | Uint8Array): Promise<Uint8Array> {\n const bytes = typeof message === \"string\" ? new TextEncoder().encode(message) : message;\n const result = await signerManager.signRaw(bytes);\n if (!result.ok) {\n throw new Error(result.error.message);\n }\n return result.value;\n },\n\n async signMessageWithDotNsIdentity(args) {\n const message =\n typeof args.message === \"string\"\n ? new TextEncoder().encode(args.message)\n : args.message;\n const accountsProvider = await getHostAccountsProvider();\n const username = args.username ?? (await getPrimaryUsername(accountsProvider));\n\n // Reuse an already-connected People chain when the caller has\n // wired one up via `app.chain.connect({ ..., <name>: peopleChain })`.\n // Fall back to opening a transient connection so first-time users\n // don't have to think about chain lifecycles. The chain-client\n // module caches by genesis fingerprint, so subsequent\n // signMessageWithDotNsIdentity calls share whichever connection\n // got established first.\n const peopleClient = isConnected(args.peopleChain)\n ? getClient(args.peopleChain)\n : await createChainClient({ chains: { people: args.peopleChain } }).then(\n (c) => c.raw.people,\n );\n // PAPI's `TypedApi.query.X.Y.getValue` is variadic\n // (`...args: [...WithCallOptions<Args>]`) so it's not assignable\n // to our deliberately-narrow `(key) => Promise<...>` shape. The\n // resolver only ever passes the storage key; the cast adapts the\n // wider PAPI surface to the minimum we depend on.\n const peopleApi = peopleClient.getTypedApi(\n args.peopleChain,\n ) as unknown as PeopleUsernameQueryApi;\n const owner = await resolvePeopleUsernameOwner(username, peopleApi);\n if (!owner) {\n throw new Error(`No account owns DotNS username \"${username}\"`);\n }\n\n const publicKey = accountIdBytes(owner);\n // This field is hex, not the SS58 the resolver now returns. Converted\n // here and not in the try, so an address failure is not reported as a\n // signing failure.\n const accountId = accountIdBytesToHex(publicKey);\n const signer = accountsProvider.getLegacyAccountSigner({ publicKey, name: username });\n\n try {\n return {\n username,\n accountId,\n signature: await signer.signBytes(message),\n };\n } catch (cause) {\n throw new Error(\n `Failed to sign with DotNS username \"${username}\": ${\n cause instanceof Error ? cause.message : String(cause)\n }`,\n { cause },\n );\n }\n },\n\n onAccountChange(callback: (account: Account | null) => void): () => void {\n accountChangeSubscribers.add(callback);\n return () => accountChangeSubscribers.delete(callback);\n },\n\n getProductAccount(): Account | null {\n // Product accounts require async call - this sync API can't support it properly\n // Users should use SignerManager.getProductAccount() directly\n log.warn(\n \"getProductAccount() is deprecated - use SignerManager.getProductAccount() directly\",\n );\n return null;\n },\n\n getAnonymousAlias(): string | null {\n // Anonymous aliases require async call - this sync API can't support it properly\n // Users should use SignerManager.getProductAccountAlias() directly\n log.warn(\n \"getAnonymousAlias() is deprecated - use SignerManager.getProductAccountAlias() directly\",\n );\n return null;\n },\n\n async createProof(_message: Uint8Array): Promise<Uint8Array> {\n // Ring VRF proofs require SignerManager.createRingVRFProof() directly\n throw new Error(\n \"createProof() is not implemented in the App API. \" +\n \"Use SignerManager.createRingVRFProof() directly.\",\n );\n },\n };\n}\n\ntype HostAccountsProvider = NonNullable<Awaited<ReturnType<typeof getAccountsProvider>>>;\n\nasync function getHostAccountsProvider(): Promise<HostAccountsProvider> {\n const provider = await getAccountsProvider();\n if (!provider) {\n throw new Error(\"Host accounts provider is not available\");\n }\n return provider;\n}\n\nasync function getPrimaryUsername(accountsProvider: HostAccountsProvider): Promise<string> {\n const result = await accountsProvider.getUserId().match(\n (value) => value,\n (err) => {\n throw err;\n },\n );\n const username = result.primaryUsername.trim();\n if (!username) {\n throw new Error(\"Host identity did not provide a primary DotNS username\");\n }\n return username;\n}\n"]}
@@ -1,6 +1,6 @@
1
- export { createApp } from '../index.js';
2
1
  export { LogEntry, LogHandler, LogLevel, Logger, LoggerConfig, configure, createLogger } from '@parity/product-sdk-logger';
3
- export { A as Account, b as App, c as AppConfig, C as ChainApi, a as CloudStorageApi, d as CloudStorageConfig, D as DotNsIdentitySignature, L as LocalStorageApi, S as SignMessageWithDotNsIdentityArgs, W as WalletApi } from '../types-B5Zx4RNq.js';
2
+ import { c as AppConfig, b as App } from '../types-BpWw-OJl.js';
3
+ export { A as Account, d as AppInfo, C as ChainApi, a as CloudStorageApi, e as CloudStorageConfig, D as DotNsIdentitySignature, L as LocalStorageApi, S as SignMessageWithDotNsIdentityArgs, W as WalletApi } from '../types-BpWw-OJl.js';
4
4
  export { ChainClient } from '@parity/product-sdk-chain-client';
5
5
  export { ChainDefinition, PolkadotClient, TypedApi } from 'polkadot-api';
6
6
  import '@parity/result';
@@ -9,4 +9,51 @@ import '@parity/product-sdk-host';
9
9
  import '@parity/product-sdk-signer';
10
10
  import '@parity/product-sdk-local-storage';
11
11
  import '@parity/product-sdk-cloud-storage';
12
- import '../dotns-bswWAmR2.js';
12
+ import '../dotns-CtmOwVQW.js';
13
+
14
+ /**
15
+ * createApp - Main entry point for the Product SDK
16
+ *
17
+ * Creates an App instance with wallet, storage, chain, and cloud storage APIs.
18
+ */
19
+
20
+ /**
21
+ * Create a new Product SDK app instance
22
+ *
23
+ * @param config - Application configuration
24
+ * @returns App instance with all APIs
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { createApp } from '@parity/product-sdk';
29
+ *
30
+ * // Default: cloud storage enabled with paseo environment
31
+ * const app = await createApp({
32
+ * logLevel: 'info',
33
+ * });
34
+ *
35
+ * // Custom cloud storage environment
36
+ * const prodApp = await createApp({
37
+ * cloudStorage: { environment: 'polkadot' },
38
+ * });
39
+ *
40
+ * // Disable cloud storage entirely
41
+ * const noCloudStorageApp = await createApp({
42
+ * cloudStorage: false,
43
+ * });
44
+ *
45
+ * // Connect wallet
46
+ * const { accounts } = await app.wallet.connect();
47
+ *
48
+ * // Use storage
49
+ * await app.localStorage.set('key', 'value');
50
+ *
51
+ * // Use cloud storage (check for null if it might be disabled)
52
+ * if (app.cloudStorage) {
53
+ * const cid = await app.cloudStorage.upload('hello world');
54
+ * }
55
+ * ```
56
+ */
57
+ declare function createApp(config?: AppConfig): Promise<App>;
58
+
59
+ export { App, AppConfig, createApp };
@@ -1,5 +1,6 @@
1
1
  export { configure, createLogger } from '../chunk-JVJ552RU.js';
2
- export { createApp } from '../chunk-DHRCWMY5.js';
3
- import '../chunk-BRZNHTLQ.js';
2
+ export { createApp } from '../chunk-VWD6HK2C.js';
3
+ import '../chunk-7GM3HUZF.js';
4
+ import '../chunk-TUXU2VPS.js';
4
5
  //# sourceMappingURL=index.js.map
5
6
  //# sourceMappingURL=index.js.map
@@ -50,8 +50,8 @@ type PeopleUsernameQueryApi = {
50
50
  * Whether `name` is a single registrable label under `suffix`.
51
51
  *
52
52
  * `suffix` is the deployment's own TLD, including its leading dot, as
53
- * `resolveTld` reports it — `".dot"` on Paseo Asset Hub Previewnet, `".paseo"`
54
- * on Next V2. It is required rather than defaulted, because a name is only
53
+ * `resolveTld` reports it — `".paseo"` on Paseo Asset Hub Next V2, `".test"`
54
+ * on Previewnet. It is required rather than defaulted, because a name is only
55
55
  * valid *relative to a deployment*: `alice.dot` is registrable on one network
56
56
  * and meaningless on the other, and a default would silently pick one.
57
57
  *
@@ -1,4 +1,4 @@
1
- export { P as PeopleUsernameChain, a as PeopleUsernameQueryApi, b as accountIdHexToBytes, c as accountIdToHex, i as isResolvableDotNsName, d as isValidDotNsName, n as normalizeDotNsName, r as resolvePeopleUsernameOwner } from '../dotns-bswWAmR2.js';
1
+ export { P as PeopleUsernameChain, a as PeopleUsernameQueryApi, b as accountIdHexToBytes, c as accountIdToHex, i as isResolvableDotNsName, d as isValidDotNsName, n as normalizeDotNsName, r as resolvePeopleUsernameOwner } from '../dotns-CtmOwVQW.js';
2
2
  import { Result } from '@parity/result';
3
3
  import { ContractRuntime, BatchableCall } from '@parity/product-sdk-contracts';
4
4
  import { SS58String } from 'polkadot-api';
@@ -11,7 +11,7 @@ import { SdkError } from '@parity/product-sdk-errors';
11
11
  * `reason` distinguishes the failure kind so callers can branch without string
12
12
  * matching.
13
13
  */
14
- type DotNsErrorReason = "InvalidName" | "InvalidTld" | "TldMismatch" | "MissingOrigin" | "InvalidOrigin" | "NameUnavailable" | "NameReserved" | "OwnerStatusInsufficient" | "RegistryCall" | "Decode";
14
+ type DotNsErrorReason = "InvalidName" | "InvalidTld" | "TldMismatch" | "MissingOrigin" | "InvalidOrigin" | "NameUnavailable" | "NameReserved" | "OwnerStatusInsufficient" | "AddressDiscovery" | "AddressMismatch" | "RegistryCall" | "Decode";
15
15
  declare class DotNsError extends Error implements SdkError {
16
16
  readonly isSdkError: true;
17
17
  readonly source = "dotns";
@@ -19,6 +19,79 @@ declare class DotNsError extends Error implements SdkError {
19
19
  constructor(reason: DotNsErrorReason, message: string, options?: ErrorOptions);
20
20
  }
21
21
 
22
+ /**
23
+ * Where the DotNS contract addresses come from.
24
+ *
25
+ * Every entry point in `./dotns-registry.js` asks {@link resolveDotNsAddresses}
26
+ * rather than reaching for a constant, so "which address do I call?" has one
27
+ * answer and the gateway walk can plug in behind it without touching them.
28
+ */
29
+
30
+ type HexString$1 = `0x${string}`;
31
+ interface DotNsAddresses {
32
+ registry: HexString$1;
33
+ reverseResolver: HexString$1;
34
+ resolver: HexString$1;
35
+ registrarController: HexString$1;
36
+ popRules: HexString$1;
37
+ protocolRegistry: HexString$1;
38
+ }
39
+ /**
40
+ * The `DotnsProtocolRegistry.get(bytes32)` key each role answers under, from
41
+ * `DotnsConstants`. Solidity's `bytes32("name")` is the UTF-8 bytes
42
+ * right-padded with zeros, which is what these literals are.
43
+ *
44
+ * Two are not the name you would guess, and guessing wrong is silent: `get`
45
+ * answers with a live address for the contract you did not want, and it
46
+ * surfaces much later as a revert. `registrarController` is the commit-reveal
47
+ * controller, key `controller` — `registrar` is the ERC-721 holding name
48
+ * ownership. `resolver` is the forward address resolver — `contentResolver`
49
+ * holds contenthash and text records, which nothing here calls.
50
+ *
51
+ * `protocolRegistry` has no key at all, so it cannot be looked up in the
52
+ * registry it is. The walk reaches it via `popController.protocolRegistry()`.
53
+ */
54
+ declare const DOTNS_REGISTRY_KEYS: {
55
+ readonly registry: "0x7265676973747279000000000000000000000000000000000000000000000000";
56
+ readonly registrarController: "0x636f6e74726f6c6c657200000000000000000000000000000000000000000000";
57
+ readonly reverseResolver: "0x726576657273655265736f6c7665720000000000000000000000000000000000";
58
+ readonly resolver: "0x7265736f6c766572000000000000000000000000000000000000000000000000";
59
+ readonly popRules: "0x706f7052756c6573000000000000000000000000000000000000000000000000";
60
+ };
61
+ declare function resolveDotNsAddresses(opts: DotNsClientOptions): Promise<Result<DotNsAddresses, DotNsError>>;
62
+ /**
63
+ * Reads `DotnsGateway.DispatcherAddress`, the pallet storage the walk starts
64
+ * from. Structural because `ContractRuntime` does not declare it.
65
+ */
66
+ type DotNsGatewayQueryApi = {
67
+ query: {
68
+ DotnsGateway: {
69
+ DispatcherAddress: {
70
+ getValue: () => Promise<{
71
+ asHex(): string;
72
+ } | string | undefined>;
73
+ };
74
+ };
75
+ };
76
+ };
77
+ /**
78
+ * Locate the live deployment from chain state, trusting nothing pinned here.
79
+ *
80
+ * Pallet -> `dispatcher.TARGET()` -> `popController.protocolRegistry()` ->
81
+ * `get(key)` per role. The first three are sequential because each answer is
82
+ * the next call's address; the role reads are not, so they go together.
83
+ *
84
+ * A failed or zero read is always an error: falling back to the pinned table
85
+ * would recreate the situation this exists to detect, and hide it better.
86
+ */
87
+ declare function discoverDotNsAddresses(opts: DotNsClientOptions): Promise<Result<DotNsAddresses, DotNsError>>;
88
+ /**
89
+ * Walk the gateway and report every role whose live address differs from the
90
+ * one this client would call. Meant for startup: it fails loudly once, rather
91
+ * than making every later read pay for the check.
92
+ */
93
+ declare function verifyDotNsAddresses(opts: DotNsClientOptions): Promise<Result<DotNsAddresses, DotNsError>>;
94
+
22
95
  /**
23
96
  * A network's DotNS top-level domain: the suffix names are spelled with, and
24
97
  * the node every one of its names hashes onto.
@@ -104,8 +177,6 @@ declare function namehash(name: string, tld: DotNsTld): `0x${string}`;
104
177
 
105
178
  /**
106
179
  * Identity module types
107
- *
108
- * Types for DotNS name resolution and context-alias derivation
109
180
  */
110
181
  /** DotNS name resolution result */
111
182
  interface DotNsRecord {
@@ -141,22 +212,6 @@ interface DotNsRecord {
141
212
  */
142
213
  expiresAt?: number;
143
214
  }
144
- /**
145
- * Context alias info: a deterministic, context-bound alias derived from a parent account
146
- *
147
- * @deprecated Returned by `deriveContextAlias`, whose addresses no key can spend.
148
- * Removal: `@parity/product-sdk` 0.23.0.
149
- */
150
- interface ContextAliasInfo {
151
- /** Alias SS58 address */
152
- address: string;
153
- /** H160 EVM address */
154
- h160Address: `0x${string}`;
155
- /** Parent account address */
156
- parentAddress: string;
157
- /** Context string used for derivation */
158
- context: string;
159
- }
160
215
  /** Identity verification result */
161
216
  interface VerificationResult {
162
217
  /** Whether identity is verified */
@@ -196,7 +251,7 @@ interface OnChainIdentity {
196
251
  *
197
252
  * **Names are rooted at the network's TLD, which is per deployment.** It is
198
253
  * fixed when `DotnsProtocolRegistry.initialize` runs, has no setter, and is
199
- * published as `tld()`. `.paseo` on Paseo Asset Hub Next V2, `.dot` on
254
+ * published as `tld()`. `.paseo` on Paseo Asset Hub Next V2, `.test` on
200
255
  * Previewnet, and operators can choose others. Every entry point that hashes a
201
256
  * name therefore asks the chain first, through {@link resolveTld}, and callers
202
257
  * can supply `opts.tld` to skip the read. Hashing under the wrong root returns a
@@ -257,6 +312,36 @@ interface DotNsClientOptions {
257
312
  * the whole set is CREATE3-deterministic.
258
313
  */
259
314
  protocolRegistryAddress?: HexString;
315
+ /**
316
+ * Where the addresses come from. `"pinned"` (the default) uses the
317
+ * {@link DOTNS_ADDRESSES} table; `"discovered"` walks the gateway on the
318
+ * chain `runtime` points at, so nothing is trusted from this bundle.
319
+ *
320
+ * Pinned is the default because the table is currently correct and a walk
321
+ * costs four round trips on the first call. Discovery is the honest choice
322
+ * once a deployment has moved, and its trust root is
323
+ * `DotnsGateway.DispatcherAddress` — a governance-set value on the chain the
324
+ * caller already trusts for every name read. Per-field address overrides win
325
+ * over either source.
326
+ *
327
+ * Discovery also selects the address `setDotNsRecord` and
328
+ * `prepareDotNsRegistration` build calls against, so it decides where a
329
+ * signed transaction goes, not only where a read comes from. A pinned
330
+ * address constrains that destination even against a hostile RPC; a
331
+ * discovered one does not. Use {@link verifyDotNsAddresses} at startup if
332
+ * that matters.
333
+ */
334
+ addressSource?: "pinned" | "discovered";
335
+ /**
336
+ * Typed API for the chain hosting the `DotnsGateway` pallet, needed only by
337
+ * `"discovered"`.
338
+ *
339
+ * Optional because `runtime.api` is usually the same chain and is used when
340
+ * it carries the pallet. `ContractRuntime` does not declare that storage, so
341
+ * it is probed rather than assumed; on a chain without the pallet, discovery
342
+ * fails with `AddressDiscovery` instead of throwing.
343
+ */
344
+ gatewayApi?: DotNsGatewayQueryApi;
260
345
  /**
261
346
  * The deployment's TLD, when you already know it.
262
347
  *
@@ -405,21 +490,23 @@ declare const POP_STATUS: {
405
490
  *
406
491
  * Not a per-network table, despite what the old name (`PASEO_ASSETHUB_DOTNS`)
407
492
  * implied: every DotNS network is deployed through the same CREATE3 factory, so
408
- * the addresses are identical everywhere and **only the TLD differs**. Verified
409
- * on both Paseo Asset Hub Next V2 and Previewnet — `protocolRegistry.get(...)`
410
- * returns the same registry on each, and all six addresses hold contracts on
411
- * both. `paritytech/dotns` `DEPLOYMENTS.md` states the mechanism, and
493
+ * the addresses are identical everywhere and **only the TLD differs**, `.paseo`
494
+ * on Paseo Asset Hub Next V2 and `.test` on Previewnet. Verified on both:
495
+ * `protocolRegistry.get(...)` returns the same registry on each, and all six
496
+ * addresses hold contracts on both. `paritytech/dotns` `DEPLOYMENTS.md` states the mechanism, and
412
497
  * `preview-net-v1` confirms it from the deploy side: the TLD is passed only as
413
498
  * registry init calldata, so it moves no address.
414
499
  *
415
500
  * So extending this module to another network means resolving its TLD, which
416
501
  * `resolveTld` already does — not adding a second address table.
417
502
  *
418
- * Each address answers `DotnsProtocolRegistry.get(bytes32)` under its
419
- * `DotnsConstants` key (the name below, right-padded to 32 bytes) and has a
420
- * `Revive.AccountInfoOf` entry. They are pinned rather than resolved at runtime,
421
- * so re-verify after a redeploy; `protocolRegistry` is the address to walk from
422
- * if we ever resolve the rest dynamically.
503
+ * Five answer `DotnsProtocolRegistry.get(bytes32)` under the keys in
504
+ * `DOTNS_REGISTRY_KEYS`, two of which differ from the field name used here.
505
+ * `protocolRegistry` has no key and comes from the gateway walk. All six have a
506
+ * `Revive.AccountInfoOf` entry.
507
+ *
508
+ * Pinned, not resolved at runtime: re-verify after a redeploy, or have the
509
+ * client do it with `verifyDotNsAddresses`.
423
510
  */
424
511
  declare const DOTNS_ADDRESSES: {
425
512
  readonly registry: "0xf34054fd76BbF85f216cf9908226D5f0A72E50CA";
@@ -430,62 +517,4 @@ declare const DOTNS_ADDRESSES: {
430
517
  readonly protocolRegistry: "0xD19e3D0C97CF501125a04A97405e3e6592fa846E";
431
518
  };
432
519
 
433
- /**
434
- * Context alias derivation (deprecated, removal in 0.23.0)
435
- *
436
- * Derives a deterministic, context-bound alias from a parent account using blake2b-256.
437
- *
438
- * The output is a hash, not a key, so no signing key exists for the addresses
439
- * returned here. See the notes on each function for what to use instead.
440
- *
441
- * NOTE: this is NOT the canonical sr25519 product-account derivation used by
442
- * mobile, desktop, and dotli hosts. For that, use
443
- * `@parity/product-sdk-keys::deriveProductAccountPublicKey`.
444
- */
445
-
446
- /**
447
- * Derive a context-bound alias from a parent account.
448
- *
449
- * The alias is deterministically derived using:
450
- * aliasPublicKey = blake2b256(parentPublicKey || context)
451
- *
452
- * @deprecated Returns addresses that no key can spend. The alias public key is a
453
- * blake2b-256 hash rather than a derived key, so no secret corresponds to the
454
- * SS58 address or to the H160: both can receive value and neither can ever
455
- * send it. Removal: `@parity/product-sdk` 0.23.0. Replace by intent:
456
- *
457
- * - An account that holds or spends value:
458
- * `SignerManager.getProductAccount(dotNsIdentifier, index)` from
459
- * `@parity/product-sdk-signer`. Host-backed and actually signable.
460
- * - The address offline, with no host: `deriveProductAccountPublicKey` from
461
- * `@parity/product-sdk-keys`, the canonical sr25519 soft derivation.
462
- * - An unlinkable per-context alias: select a registered ring-VRF key, then call
463
- * `SignerManager.getProductAccountAlias(keyHandle, context, location)` or
464
- * `createRingVRFProof(keyHandle, context, location, message)`.
465
- * - A context-scoped identifier, never used as an account: `blake2b256` from
466
- * `@parity/product-sdk/crypto`. Same bytes, without address packaging that
467
- * invites the mistake.
468
- *
469
- * @param parentAddress - Parent account SS58 address
470
- * @param context - Context string for derivation (e.g. an app id or scope label)
471
- * @param ss58Prefix - SS58 prefix (default: 42)
472
- * @returns Context alias info
473
- */
474
- declare function deriveContextAlias(parentAddress: string, context: string, ss58Prefix?: number): ContextAliasInfo;
475
- /**
476
- * Verify that a context alias was derived from a parent account.
477
- *
478
- * @deprecated Recomputes {@link deriveContextAlias} from two public values and
479
- * compares the result, so it confirms a derivation relationship and nothing
480
- * more. No secret enters the operation at any point, which means there is
481
- * nothing here to authenticate: a passing result does not show that anyone
482
- * controls either account. Removal: `@parity/product-sdk` 0.23.0.
483
- *
484
- * @param aliasAddress - Context alias SS58 address
485
- * @param parentAddress - Claimed parent address
486
- * @param context - Context string used for derivation
487
- * @returns True if derivation is valid
488
- */
489
- declare function verifyContextAlias(aliasAddress: string, parentAddress: string, context: string): boolean;
490
-
491
- export { type ContextAliasInfo, DOTNS_ADDRESSES, DOT_NODE, DOT_TLD, type DotNsClientOptions, DotNsError, type DotNsErrorReason, type DotNsRecord, type DotNsRegistration, type DotNsTld, type OnChainIdentity, POP_STATUS, type RegisterDotNsArgs, type SetRecordArgs, type VerificationResult, deriveContextAlias, dotNsTld, isConsistentDotNsTld, isDotNsAvailable, namehash, prepareDotNsRegistration, resolveDotNs, reverseDotNs, setDotNsRecord, stripSuffix, verifyContextAlias };
520
+ export { DOTNS_ADDRESSES, DOTNS_REGISTRY_KEYS, DOT_NODE, DOT_TLD, type DotNsAddresses, type DotNsClientOptions, DotNsError, type DotNsErrorReason, type DotNsGatewayQueryApi, type DotNsRecord, type DotNsRegistration, type DotNsTld, type OnChainIdentity, POP_STATUS, type RegisterDotNsArgs, type SetRecordArgs, type VerificationResult, discoverDotNsAddresses, dotNsTld, isConsistentDotNsTld, isDotNsAvailable, namehash, prepareDotNsRegistration, resolveDotNs, resolveDotNsAddresses, reverseDotNs, setDotNsRecord, stripSuffix, verifyDotNsAddresses };