@parity/product-sdk 0.12.0 → 0.14.0
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/{chunk-TRTQ6KGE.js → chunk-6MNKFIU6.js} +57 -4
- package/dist/chunk-6MNKFIU6.js.map +1 -0
- package/dist/chunk-BIKT6X54.js +70 -0
- package/dist/chunk-BIKT6X54.js.map +1 -0
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +2 -1
- package/dist/dotns-hLSvmo6u.d.ts +178 -0
- package/dist/identity/index.d.ts +4 -120
- package/dist/identity/index.js +6 -41
- package/dist/identity/index.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/react/index.d.ts +4 -1
- package/dist/react/index.js +10 -2
- package/dist/react/index.js.map +1 -1
- package/dist/{types-AjDV1BTd.d.ts → types-DsMUguUr.d.ts} +53 -1
- package/package.json +9 -9
- package/src/core/createApp.ts +85 -0
- package/src/core/types.ts +56 -0
- package/src/identity/dotns.ts +121 -11
- package/src/identity/index.ts +3 -0
- package/src/index.ts +2 -0
- package/src/react/useWallet.ts +17 -1
- package/dist/chunk-TRTQ6KGE.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/identity/dotns.ts","../../src/identity/product-account.ts"],"names":["log","createLogger"],"mappings":";;;;;AAWA,IAAM,GAAA,GAAM,aAAa,UAAU,CAAA;AAQ5B,SAAS,iBAAiB,IAAA,EAAuB;AAEpD,EAAA,IAAI,CAAC,IAAA,CAAK,QAAA,CAAS,MAAM,GAAG,OAAO,KAAA;AACnC,EAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AAC9B,EAAA,IAAI,MAAM,MAAA,GAAS,CAAA,IAAK,KAAA,CAAM,MAAA,GAAS,IAAI,OAAO,KAAA;AAClD,EAAA,OAAO,iCAAA,CAAkC,KAAK,KAAK,CAAA;A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,IAAA,OAAO,KAAA;AAAA,EACX;AACJ;AAYO,SAAS,oBAAA,CACZ,SACA,YAAA,EACkB;AAClB,EAAAA,KAAI,KAAA,CAAM,0BAAA,EAA4B,EAAE,OAAA,EAAS,cAAc,CAAA;AAI/D,EAAA,MAAM,IAAI,KAAA;AAAA,IACN;AAAA,GAEJ;AACJ;AASA,eAAsB,eAAA,CAClB,SACA,YAAA,EACmB;AACnB,EAAAA,IAAAA,CAAI,KAAA,CAAM,qBAAA,EAAuB,EAAE,cAAc,CAAA;AAGjD,EAAA,MAAM,IAAI,KAAA;AAAA,IACN;AAAA,GAEJ;AACJ;AAUA,eAAsB,eAAA,CAClB,OAAA,EACA,KAAA,EACA,KAAA,EACgB;AAChB,EAAAA,IAAAA,CAAI,MAAM,sBAAsB,CAAA;AAGhC,EAAA,MAAM,IAAI,KAAA;AAAA,IACN;AAAA,GAEJ;AACJ","file":"index.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * DotNS (Polkadot Name Service) utilities\n *\n * Provides name resolution for .dot domains\n */\n\nimport { createLogger } from \"@parity/product-sdk-logger\";\nimport type { DotNsRecord } from \"./types.js\";\n\nconst log = createLogger(\"identity\");\n\n/**\n * Check if a string is a valid DotNS name\n *\n * @param name - Name to validate\n * @returns True if valid DotNS name\n */\nexport function isValidDotNsName(name: string): boolean {\n // Basic validation: alphanumeric, hyphens, ends with .dot\n if (!name.endsWith(\".dot\")) return false;\n const label = name.slice(0, -4);\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 * Normalize a DotNS name (lowercase, trim whitespace)\n *\n * @param name - Name to normalize\n * @returns Normalized name\n */\nexport function normalizeDotNsName(name: string): string {\n let normalized = name.toLowerCase().trim();\n if (!normalized.endsWith(\".dot\")) {\n normalized += \".dot\";\n }\n return normalized;\n}\n\n/**\n * Resolve a DotNS name to an address\n *\n * @param name - DotNS name (e.g., \"alice.dot\")\n * @returns Resolved record or null if not found\n *\n * @example\n * ```ts\n * const record = await resolveDotNs('alice.dot');\n * if (record) {\n * console.log('Address:', record.address);\n * }\n * ```\n */\nexport async function resolveDotNs(name: string): Promise<DotNsRecord | null> {\n const normalized = normalizeDotNsName(name);\n\n if (!isValidDotNsName(normalized)) {\n log.warn(\"Invalid DotNS name\", { name });\n return null;\n }\n\n log.debug(\"Resolving DotNS name\", { name: normalized });\n\n // TODO: Implement via PAPI query to DotNS pallet\n throw new Error(\n \"resolveDotNs() is not yet implemented. \" +\n \"This is a skeleton for the Product SDK structure.\",\n );\n}\n\n/**\n * Reverse resolve an address to a DotNS name\n *\n * @param address - SS58 address\n * @returns Primary name or null if none set\n */\nexport async function reverseDotNs(address: string): Promise<string | null> {\n log.debug(\"Reverse resolving address\", { address });\n\n // TODO: Implement via PAPI query to DotNS pallet\n throw new Error(\n \"reverseDotNs() is not yet implemented. \" +\n \"This is a skeleton for the Product SDK structure.\",\n );\n}\n\n/**\n * Check if a DotNS name is available for registration\n *\n * @param name - Name to check\n * @returns True if available\n */\nexport async function isDotNsAvailable(name: string): Promise<boolean> {\n const record = await resolveDotNs(name).catch(() => null);\n return record === null;\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Context alias derivation\n *\n * Derives a deterministic, context-bound alias from a parent account using blake2b-256.\n *\n * NOTE: this is NOT the canonical sr25519 product-account derivation used by\n * mobile, desktop, and dotli hosts. For that, use\n * `@parity/product-sdk-keys::deriveProductAccountPublicKey`.\n */\n\nimport { createLogger } from \"@parity/product-sdk-logger\";\nimport { blake2b256 } from \"@parity/product-sdk-crypto\";\nimport { ss58Encode, ss58Decode, deriveH160 } from \"@parity/product-sdk-address\";\nimport type { ContextAliasInfo, AnonymousAliasInfo, RingLocation } from \"./types.js\";\n\nconst log = createLogger(\"identity\");\n\n/**\n * Derive a context-bound alias from a parent account.\n *\n * The alias is deterministically derived using:\n * aliasPublicKey = blake2b256(parentPublicKey || context)\n *\n * @param parentAddress - Parent account SS58 address\n * @param context - Context string for derivation (e.g. an app id or scope label)\n * @param ss58Prefix - SS58 prefix (default: 42)\n * @returns Context alias info\n *\n * @example\n * ```ts\n * const alias = deriveContextAlias(\n * '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',\n * 'voting-round-1'\n * );\n * console.log('Alias address:', alias.address);\n * ```\n */\nexport function deriveContextAlias(\n parentAddress: string,\n context: string,\n ss58Prefix = 42,\n): ContextAliasInfo {\n const { publicKey: parentPublicKey } = ss58Decode(parentAddress);\n\n // Derive alias public key: blake2b-256(parentPublicKey || context)\n const contextBytes = new TextEncoder().encode(context);\n const combined = new Uint8Array(parentPublicKey.length + contextBytes.length);\n combined.set(parentPublicKey, 0);\n combined.set(contextBytes, parentPublicKey.length);\n\n const aliasPublicKey = blake2b256(combined);\n const address = ss58Encode(aliasPublicKey, ss58Prefix);\n const h160Address = deriveH160(aliasPublicKey);\n\n log.debug(\"Derived context alias\", {\n parentAddress,\n context,\n address,\n });\n\n return {\n address,\n h160Address,\n parentAddress,\n context,\n };\n}\n\n/**\n * Verify that a context alias was derived from a parent account.\n *\n * @param aliasAddress - Context alias SS58 address\n * @param parentAddress - Claimed parent address\n * @param context - Context string used for derivation\n * @returns True if derivation is valid\n */\nexport function verifyContextAlias(\n aliasAddress: string,\n parentAddress: string,\n context: string,\n): boolean {\n try {\n const derived = deriveContextAlias(parentAddress, context);\n const { publicKey: aliasKey } = ss58Decode(aliasAddress);\n const { publicKey: derivedKey } = ss58Decode(derived.address);\n\n // Compare public keys\n if (aliasKey.length !== derivedKey.length) return false;\n for (let i = 0; i < aliasKey.length; i++) {\n if (aliasKey[i] !== derivedKey[i]) return false;\n }\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Derive an anonymous alias using Ring VRF\n *\n * This creates a context-specific alias that cannot be linked\n * back to the original identity without the ring proof.\n *\n * @param context - Context for alias derivation (e.g., \"voting-round-1\")\n * @param ringLocation - Ring location for proof generation\n * @returns Anonymous alias info\n */\nexport function deriveAnonymousAlias(\n context: string,\n ringLocation: RingLocation,\n): AnonymousAliasInfo {\n log.debug(\"Deriving anonymous alias\", { context, ringLocation });\n\n // TODO: Implement Ring VRF alias derivation\n // This requires the Ring VRF implementation from TruAPI\n throw new Error(\n \"deriveAnonymousAlias() is not yet implemented. \" +\n \"This requires container mode with Ring VRF support.\",\n );\n}\n\n/**\n * Create a Ring VRF proof for a message\n *\n * @param message - Message to prove\n * @param ringLocation - Ring location\n * @returns Proof bytes\n */\nexport async function createRingProof(\n message: Uint8Array,\n ringLocation: RingLocation,\n): Promise<Uint8Array> {\n log.debug(\"Creating ring proof\", { ringLocation });\n\n // TODO: Implement Ring VRF proof creation via TruAPI\n throw new Error(\n \"createRingProof() is not yet implemented. \" +\n \"This requires container mode with Ring VRF support.\",\n );\n}\n\n/**\n * Verify a Ring VRF proof\n *\n * @param message - Original message\n * @param proof - Proof bytes\n * @param alias - Expected alias\n * @returns True if proof is valid\n */\nexport async function verifyRingProof(\n message: Uint8Array,\n proof: Uint8Array,\n alias: string,\n): Promise<boolean> {\n log.debug(\"Verifying ring proof\");\n\n // TODO: Implement Ring VRF proof verification\n throw new Error(\n \"verifyRingProof() is not yet implemented. \" +\n \"This requires container mode with Ring VRF support.\",\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/identity/product-account.ts"],"names":[],"mappings":";;;;;AAiBA,IAAM,GAAA,GAAM,aAAa,UAAU,CAAA;AAsB5B,SAAS,kBAAA,CACZ,aAAA,EACA,OAAA,EACA,UAAA,GAAa,EAAA,EACG;AAChB,EAAA,MAAM,EAAE,SAAA,EAAW,eAAA,EAAgB,GAAI,WAAW,aAAa,CAAA;AAG/D,EAAA,MAAM,YAAA,GAAe,IAAI,WAAA,EAAY,CAAE,OAAO,OAAO,CAAA;AACrD,EAAA,MAAM,WAAW,IAAI,UAAA,CAAW,eAAA,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SACA,YAAA,EACkB;AAClB,EAAA,GAAA,CAAI,KAAA,CAAM,0BAAA,EAA4B,EAAE,OAAA,EAAS,cAAc,CAAA;AAI/D,EAAA,MAAM,IAAI,KAAA;AAAA,IACN;AAAA,GAEJ;AACJ;AASA,eAAsB,eAAA,CAClB,SACA,YAAA,EACmB;AACnB,EAAA,GAAA,CAAI,KAAA,CAAM,qBAAA,EAAuB,EAAE,YAAA,EAAc,CAAA;AAGjD,EAAA,MAAM,IAAI,KAAA;AAAA,IACN;AAAA,GAEJ;AACJ;AAUA,eAAsB,eAAA,CAClB,OAAA,EACA,KAAA,EACA,KAAA,EACgB;AAChB,EAAA,GAAA,CAAI,MAAM,sBAAsB,CAAA;AAGhC,EAAA,MAAM,IAAI,KAAA;AAAA,IACN;AAAA,GAEJ;AACJ","file":"index.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * Context alias derivation\n *\n * Derives a deterministic, context-bound alias from a parent account using blake2b-256.\n *\n * NOTE: this is NOT the canonical sr25519 product-account derivation used by\n * mobile, desktop, and dotli hosts. For that, use\n * `@parity/product-sdk-keys::deriveProductAccountPublicKey`.\n */\n\nimport { createLogger } from \"@parity/product-sdk-logger\";\nimport { blake2b256 } from \"@parity/product-sdk-crypto\";\nimport { ss58Encode, ss58Decode, deriveH160 } from \"@parity/product-sdk-address\";\nimport type { ContextAliasInfo, AnonymousAliasInfo, RingLocation } from \"./types.js\";\n\nconst log = createLogger(\"identity\");\n\n/**\n * Derive a context-bound alias from a parent account.\n *\n * The alias is deterministically derived using:\n * aliasPublicKey = blake2b256(parentPublicKey || context)\n *\n * @param parentAddress - Parent account SS58 address\n * @param context - Context string for derivation (e.g. an app id or scope label)\n * @param ss58Prefix - SS58 prefix (default: 42)\n * @returns Context alias info\n *\n * @example\n * ```ts\n * const alias = deriveContextAlias(\n * '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',\n * 'voting-round-1'\n * );\n * console.log('Alias address:', alias.address);\n * ```\n */\nexport function deriveContextAlias(\n parentAddress: string,\n context: string,\n ss58Prefix = 42,\n): ContextAliasInfo {\n const { publicKey: parentPublicKey } = ss58Decode(parentAddress);\n\n // Derive alias public key: blake2b-256(parentPublicKey || context)\n const contextBytes = new TextEncoder().encode(context);\n const combined = new Uint8Array(parentPublicKey.length + contextBytes.length);\n combined.set(parentPublicKey, 0);\n combined.set(contextBytes, parentPublicKey.length);\n\n const aliasPublicKey = blake2b256(combined);\n const address = ss58Encode(aliasPublicKey, ss58Prefix);\n const h160Address = deriveH160(aliasPublicKey);\n\n log.debug(\"Derived context alias\", {\n parentAddress,\n context,\n address,\n });\n\n return {\n address,\n h160Address,\n parentAddress,\n context,\n };\n}\n\n/**\n * Verify that a context alias was derived from a parent account.\n *\n * @param aliasAddress - Context alias SS58 address\n * @param parentAddress - Claimed parent address\n * @param context - Context string used for derivation\n * @returns True if derivation is valid\n */\nexport function verifyContextAlias(\n aliasAddress: string,\n parentAddress: string,\n context: string,\n): boolean {\n try {\n const derived = deriveContextAlias(parentAddress, context);\n const { publicKey: aliasKey } = ss58Decode(aliasAddress);\n const { publicKey: derivedKey } = ss58Decode(derived.address);\n\n // Compare public keys\n if (aliasKey.length !== derivedKey.length) return false;\n for (let i = 0; i < aliasKey.length; i++) {\n if (aliasKey[i] !== derivedKey[i]) return false;\n }\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Derive an anonymous alias using Ring VRF\n *\n * This creates a context-specific alias that cannot be linked\n * back to the original identity without the ring proof.\n *\n * @param context - Context for alias derivation (e.g., \"voting-round-1\")\n * @param ringLocation - Ring location for proof generation\n * @returns Anonymous alias info\n */\nexport function deriveAnonymousAlias(\n context: string,\n ringLocation: RingLocation,\n): AnonymousAliasInfo {\n log.debug(\"Deriving anonymous alias\", { context, ringLocation });\n\n // TODO: Implement Ring VRF alias derivation\n // This requires the Ring VRF implementation from TruAPI\n throw new Error(\n \"deriveAnonymousAlias() is not yet implemented. \" +\n \"This requires container mode with Ring VRF support.\",\n );\n}\n\n/**\n * Create a Ring VRF proof for a message\n *\n * @param message - Message to prove\n * @param ringLocation - Ring location\n * @returns Proof bytes\n */\nexport async function createRingProof(\n message: Uint8Array,\n ringLocation: RingLocation,\n): Promise<Uint8Array> {\n log.debug(\"Creating ring proof\", { ringLocation });\n\n // TODO: Implement Ring VRF proof creation via TruAPI\n throw new Error(\n \"createRingProof() is not yet implemented. \" +\n \"This requires container mode with Ring VRF support.\",\n );\n}\n\n/**\n * Verify a Ring VRF proof\n *\n * @param message - Original message\n * @param proof - Proof bytes\n * @param alias - Expected alias\n * @returns True if proof is valid\n */\nexport async function verifyRingProof(\n message: Uint8Array,\n proof: Uint8Array,\n alias: string,\n): Promise<boolean> {\n log.debug(\"Verifying ring proof\");\n\n // TODO: Implement Ring VRF proof verification\n throw new Error(\n \"verifyRingProof() is not yet implemented. \" +\n \"This requires container mode with Ring VRF support.\",\n );\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export { LogEntry, LogHandler, LogLevel, Logger, LoggerConfig, configure, createLogger } from '@parity/product-sdk-logger';
|
|
2
|
-
import { b as AppConfig, A as App } from './types-
|
|
3
|
-
export { a as Account, C as ChainApi, c as CloudStorageApi, L as LocalStorageApi, W as WalletApi } from './types-
|
|
2
|
+
import { b as AppConfig, A as App } from './types-DsMUguUr.js';
|
|
3
|
+
export { a as Account, C as ChainApi, c as CloudStorageApi, D as DotNsIdentitySignature, L as LocalStorageApi, S as SignMessageWithDotNsIdentityArgs, W as WalletApi } from './types-DsMUguUr.js';
|
|
4
4
|
export { isInsideContainer, isInsideContainerSync } from '@parity/product-sdk-host';
|
|
5
5
|
export { ChainClient, createChainClient } from '@parity/product-sdk-chain-client';
|
|
6
6
|
export { SignerManager } from '@parity/product-sdk-signer';
|
|
7
7
|
export { createLocalKvStore } from '@parity/product-sdk-local-storage';
|
|
8
8
|
export { CloudStorageClient, calculateCid } from '@parity/product-sdk-cloud-storage';
|
|
9
9
|
export { ChainDefinition, PolkadotClient, TypedApi } from 'polkadot-api';
|
|
10
|
+
import './dotns-hLSvmo6u.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* createApp - Main entry point for the Product SDK
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { configure, createLogger } from './chunk-JVJ552RU.js';
|
|
2
|
-
export { createApp } from './chunk-
|
|
2
|
+
export { createApp } from './chunk-6MNKFIU6.js';
|
|
3
|
+
import './chunk-BIKT6X54.js';
|
|
3
4
|
export { isInsideContainer, isInsideContainerSync } from '@parity/product-sdk-host';
|
|
4
5
|
export { createChainClient } from '@parity/product-sdk-chain-client';
|
|
5
6
|
export { SignerManager } from '@parity/product-sdk-signer';
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { LogLevel } from '@parity/product-sdk-logger';
|
|
5
|
-
import { A as App, a as Account } from '../types-
|
|
5
|
+
import { A as App, S as SignMessageWithDotNsIdentityArgs, D as DotNsIdentitySignature, a as Account } from '../types-DsMUguUr.js';
|
|
6
6
|
import { ChainDefinition, TypedApi } from 'polkadot-api';
|
|
7
7
|
import '@parity/product-sdk-cloud-storage';
|
|
8
8
|
import '@parity/product-sdk-chain-client';
|
|
9
|
+
import '../dotns-hLSvmo6u.js';
|
|
9
10
|
|
|
10
11
|
/** Props for ProductSDKProvider */
|
|
11
12
|
interface ProductSDKProviderProps {
|
|
@@ -80,6 +81,8 @@ interface UseWalletActions {
|
|
|
80
81
|
selectAccount: (address: string) => void;
|
|
81
82
|
/** Sign a message */
|
|
82
83
|
signMessage: (message: string | Uint8Array) => Promise<Uint8Array>;
|
|
84
|
+
/** Sign a message with the account that owns a DotNS / People username identity. */
|
|
85
|
+
signMessageWithDotNsIdentity: (args: SignMessageWithDotNsIdentityArgs) => Promise<DotNsIdentitySignature>;
|
|
83
86
|
}
|
|
84
87
|
/** Return type of useWallet */
|
|
85
88
|
type UseWalletReturn = UseWalletState & UseWalletActions;
|
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createApp } from '../chunk-
|
|
1
|
+
import { createApp } from '../chunk-6MNKFIU6.js';
|
|
2
|
+
import '../chunk-BIKT6X54.js';
|
|
2
3
|
import { createContext, useContext, useState, useEffect, useCallback, useMemo } from 'react';
|
|
3
4
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
4
5
|
|
|
@@ -95,6 +96,12 @@ function useWallet() {
|
|
|
95
96
|
},
|
|
96
97
|
[app]
|
|
97
98
|
);
|
|
99
|
+
const signMessageWithDotNsIdentity = useCallback(
|
|
100
|
+
async (args) => {
|
|
101
|
+
return app.wallet.signMessageWithDotNsIdentity(args);
|
|
102
|
+
},
|
|
103
|
+
[app]
|
|
104
|
+
);
|
|
98
105
|
useEffect(() => {
|
|
99
106
|
const unsubscribe = app.wallet.onAccountChange((account) => {
|
|
100
107
|
setState((s) => ({ ...s, selectedAccount: account }));
|
|
@@ -106,7 +113,8 @@ function useWallet() {
|
|
|
106
113
|
connect,
|
|
107
114
|
disconnect,
|
|
108
115
|
selectAccount,
|
|
109
|
-
signMessage
|
|
116
|
+
signMessage,
|
|
117
|
+
signMessageWithDotNsIdentity
|
|
110
118
|
};
|
|
111
119
|
}
|
|
112
120
|
function useLocalStorage(key, defaultValue) {
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react/context.ts","../../src/react/provider.tsx","../../src/react/useWallet.ts","../../src/react/useLocalStorage.ts","../../src/react/useChain.ts"],"names":["useState","useEffect","useCallback"],"mappings":";;;;AAUO,IAAM,iBAAA,GAAoB,cAA0B,IAAI;AAexD,SAAS,aAAA,GAAqB;AACjC,EAAA,MAAM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M,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,GAAA,EAAK,QAAQ,CAAA;AACxC,MAAA,QAAA,CAAS,QAAQ,CAAA;AAAA,IACrB,CAAA;AAAA,IACA,CAAC,KAAK,GAAG;AAAA,GACb;AAEA,EAAA,OAAO,CAAC,KAAA,EAAO,cAAA,EAAgB,EAAE,SAAS,CAAA;AAC9C;AClGO,SAAS,SAAoC,KAAA,EAAuB;AACvE,EAAA,MAAM,MAAM,aAAA,EAAc;AAE1B,EAAA,OAAO,QAAQ,MAAM;AACjB,IAAA,OAAO,GAAA,CAAI,KAAA,CAAM,SAAA,CAAU,KAAK,CAAA;AAAA,EACpC,CAAA,EAAG,CAAC,GAAA,EAAK,KAAK,CAAC,CAAA;AACnB","file":"index.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * React context for Product SDK\n */\n\nimport { createContext, useContext } from \"react\";\nimport type { App } from \"../core/types.js\";\n\n/** Context for the Product SDK app instance */\nexport const ProductSDKContext = createContext<App | null>(null);\n\n/**\n * Hook to access the Product SDK app instance\n *\n * @throws If used outside of ProductSDKProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const app = useProductSDK();\n * // Use app.wallet, app.localStorage, etc.\n * }\n * ```\n */\nexport function useProductSDK(): App {\n const app = useContext(ProductSDKContext);\n if (!app) {\n throw new Error(\n \"useProductSDK must be used within a ProductSDKProvider. \" +\n 'Wrap your app with <ProductSDKProvider name=\"your-app\">.',\n );\n }\n return app;\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * ProductSDKProvider component\n */\n\nimport React, { useEffect, useState, type ReactNode } from \"react\";\nimport { ProductSDKContext } from \"./context.js\";\nimport { createApp } from \"../core/createApp.js\";\nimport type { App, LogLevel } from \"../core/types.js\";\n\n/** Props for ProductSDKProvider */\nexport interface ProductSDKProviderProps {\n /** Application name - used for storage namespacing and product account derivation */\n name: string;\n /** Log level (default: 'info') */\n logLevel?: LogLevel;\n /** Child components */\n children: ReactNode;\n /** Fallback to show while loading */\n fallback?: ReactNode;\n}\n\n/**\n * Provider component that initializes the Product SDK\n *\n * @example\n * ```tsx\n * import { ProductSDKProvider } from '@parity/product-sdk/react';\n *\n * function App() {\n * return (\n * <ProductSDKProvider name=\"my-app\" fallback={<Loading />}>\n * <MyApp />\n * </ProductSDKProvider>\n * );\n * }\n * ```\n */\nexport function ProductSDKProvider({\n name,\n logLevel = \"info\",\n children,\n fallback = null,\n}: ProductSDKProviderProps) {\n const [app, setApp] = useState<App | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n let mounted = true;\n\n createApp({ name, logLevel })\n .then((createdApp) => {\n if (mounted) {\n setApp(createdApp);\n }\n })\n .catch((e) => {\n if (mounted) {\n setError(e instanceof Error ? e : new Error(String(e)));\n }\n });\n\n return () => {\n mounted = false;\n };\n }, [name, logLevel]);\n\n if (error) {\n throw error;\n }\n\n if (!app) {\n return <>{fallback}</>;\n }\n\n return <ProductSDKContext.Provider value={app}>{children}</ProductSDKContext.Provider>;\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * useWallet hook\n */\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { useProductSDK } from \"./context.js\";\nimport type { Account } from \"../core/types.js\";\n\n/** Wallet hook state */\nexport interface UseWalletState {\n /** Whether wallet is connected */\n isConnected: boolean;\n /** Whether connection is in progress */\n isConnecting: boolean;\n /** Available accounts */\n accounts: Account[];\n /** Currently selected account */\n selectedAccount: Account | null;\n /** Last error */\n error: Error | null;\n}\n\n/** Wallet hook actions */\nexport interface UseWalletActions {\n /** Connect to wallet */\n connect: () => Promise<void>;\n /** Disconnect from wallet */\n disconnect: () => Promise<void>;\n /** Select an account */\n selectAccount: (address: string) => void;\n /** Sign a message */\n signMessage: (message: string | Uint8Array) => Promise<Uint8Array>;\n}\n\n/** Return type of useWallet */\nexport type UseWalletReturn = UseWalletState & UseWalletActions;\n\n/**\n * Hook for wallet connection and signing\n *\n * @example\n * ```tsx\n * function WalletButton() {\n * const { isConnected, accounts, connect, disconnect, selectAccount } = useWallet();\n *\n * if (!isConnected) {\n * return <button onClick={connect}>Connect Wallet</button>;\n * }\n *\n * return (\n * <div>\n * <select onChange={(e) => selectAccount(e.target.value)}>\n * {accounts.map((a) => (\n * <option key={a.address} value={a.address}>\n * {a.name || a.address}\n * </option>\n * ))}\n * </select>\n * <button onClick={disconnect}>Disconnect</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useWallet(): UseWalletReturn {\n const app = useProductSDK();\n\n const [state, setState] = useState<UseWalletState>({\n isConnected: false,\n isConnecting: false,\n accounts: [],\n selectedAccount: null,\n error: null,\n });\n\n const connect = useCallback(async () => {\n setState((s) => ({ ...s, isConnecting: true, error: null }));\n try {\n const result = await app.wallet.connect();\n setState((s) => ({\n ...s,\n isConnected: true,\n isConnecting: false,\n accounts: result.accounts,\n selectedAccount: result.accounts[0] || null,\n }));\n } catch (e) {\n setState((s) => ({\n ...s,\n isConnecting: false,\n error: e instanceof Error ? e : new Error(String(e)),\n }));\n }\n }, [app]);\n\n const disconnect = useCallback(async () => {\n await app.wallet.disconnect();\n setState({\n isConnected: false,\n isConnecting: false,\n accounts: [],\n selectedAccount: null,\n error: null,\n });\n }, [app]);\n\n const selectAccount = useCallback(\n (address: string) => {\n app.wallet.selectAccount(address);\n const account = state.accounts.find((a) => a.address === address) || null;\n setState((s) => ({ ...s, selectedAccount: account }));\n },\n [app, state.accounts],\n );\n\n const signMessage = useCallback(\n async (message: string | Uint8Array) => {\n return app.wallet.signMessage(message);\n },\n [app],\n );\n\n // Subscribe to account changes\n useEffect(() => {\n const unsubscribe = app.wallet.onAccountChange((account) => {\n setState((s) => ({ ...s, selectedAccount: account }));\n });\n return unsubscribe;\n }, [app]);\n\n return {\n ...state,\n connect,\n disconnect,\n selectAccount,\n signMessage,\n };\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * useLocalStorage hook\n */\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { useProductSDK } from \"./context.js\";\n\n/**\n * Hook for key-value storage operations\n *\n * @param key - Storage key\n * @param defaultValue - Default value if key doesn't exist\n *\n * @example\n * ```tsx\n * function ThemeToggle() {\n * const [theme, setTheme, { loading }] = useLocalStorage('theme', 'light');\n *\n * if (loading) return <div>Loading...</div>;\n *\n * return (\n * <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>\n * Current: {theme}\n * </button>\n * );\n * }\n * ```\n */\nexport function useLocalStorage<T = string>(\n key: string,\n defaultValue?: T,\n): [T | null, (value: T) => Promise<void>, { loading: boolean; error: Error | null }] {\n const app = useProductSDK();\n\n const [value, setValue] = useState<T | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n // Load initial value\n useEffect(() => {\n let mounted = true;\n\n const loadValue = async () => {\n try {\n setLoading(true);\n const stored = await app.localStorage.getJSON<T>(key);\n if (mounted) {\n setValue(stored ?? defaultValue ?? null);\n setLoading(false);\n }\n } catch (e) {\n if (mounted) {\n setError(e instanceof Error ? e : new Error(String(e)));\n setLoading(false);\n }\n }\n };\n\n loadValue();\n\n return () => {\n mounted = false;\n };\n }, [app, key, defaultValue]);\n\n const setStoredValue = useCallback(\n async (newValue: T) => {\n try {\n setError(null);\n await app.localStorage.setJSON(key, newValue);\n setValue(newValue);\n } catch (e) {\n setError(e instanceof Error ? e : new Error(String(e)));\n throw e;\n }\n },\n [app, key],\n );\n\n return [value, setStoredValue, { loading, error }];\n}\n\n/**\n * Hook for string storage (simpler API)\n *\n * @param key - Storage key\n * @param defaultValue - Default value\n */\nexport function useLocalStorageString(\n key: string,\n defaultValue?: string,\n): [string | null, (value: string) => Promise<void>, { loading: boolean }] {\n const app = useProductSDK();\n\n const [value, setValue] = useState<string | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n let mounted = true;\n\n const loadValue = async () => {\n const stored = await app.localStorage.get(key);\n if (mounted) {\n setValue(stored ?? defaultValue ?? null);\n setLoading(false);\n }\n };\n\n loadValue();\n\n return () => {\n mounted = false;\n };\n }, [app, key, defaultValue]);\n\n const setStoredValue = useCallback(\n async (newValue: string) => {\n await app.localStorage.set(key, newValue);\n setValue(newValue);\n },\n [app, key],\n );\n\n return [value, setStoredValue, { loading }];\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * useChain hook\n */\n\nimport { useMemo } from \"react\";\nimport { useProductSDK } from \"./context.js\";\nimport type { ChainDefinition, TypedApi } from \"../core/types.js\";\n\n/**\n * Hook to get a typed chain client\n *\n * @param chain - Chain descriptor (PAPI ChainDefinition)\n *\n * @example\n * ```tsx\n * import { paseo_asset_hub } from '@parity/product-sdk-descriptors/paseo-asset-hub';\n * import { useChain } from '@parity/product-sdk/react';\n *\n * function AssetHubBalance() {\n * const assetHub = useChain(paseo_asset_hub);\n *\n * // assetHub is typed for Asset Hub queries\n * const balance = await assetHub.query.System.Account.getValue(address);\n * }\n * ```\n */\nexport function useChain<T extends ChainDefinition>(chain: T): TypedApi<T> {\n const app = useProductSDK();\n\n return useMemo(() => {\n return app.chain.getClient(chain);\n }, [app, chain]);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/react/context.ts","../../src/react/provider.tsx","../../src/react/useWallet.ts","../../src/react/useLocalStorage.ts","../../src/react/useChain.ts"],"names":["useState","useEffect","useCallback"],"mappings":";;;;;AAUO,IAAM,iBAAA,GAAoB,cAA0B,IAAI;AAexD,SAAS,aAAA,GAAqB;AACjC,EAAA,MAAM,GAAA,GAAM,WAAW,iBAAiB,CAAA;AACxC,EAAA,IAAI,CAAC,GAAA,EAAK;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACN;AAAA,KAEJ;AAAA,EACJ;AACA,EAAA,OAAO,GAAA;AACX;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AAA,IACnB,OAAO,QAAA,KAAqB;AACxB,MAAA,MAAM,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,GAAA,EAAK,QAAQ,CAAA;AACxC,MAAA,QAAA,CAAS,QAAQ,CAAA;AAAA,IACrB,CAAA;AAAA,IACA,CAAC,KAAK,GAAG;AAAA,GACb;AAEA,EAAA,OAAO,CAAC,KAAA,EAAO,cAAA,EAAgB,EAAE,SAAS,CAAA;AAC9C;AClGO,SAAS,SAAoC,KAAA,EAAuB;AACvE,EAAA,MAAM,MAAM,aAAA,EAAc;AAE1B,EAAA,OAAO,QAAQ,MAAM;AACjB,IAAA,OAAO,GAAA,CAAI,KAAA,CAAM,SAAA,CAAU,KAAK,CAAA;AAAA,EACpC,CAAA,EAAG,CAAC,GAAA,EAAK,KAAK,CAAC,CAAA;AACnB","file":"index.js","sourcesContent":["// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * React context for Product SDK\n */\n\nimport { createContext, useContext } from \"react\";\nimport type { App } from \"../core/types.js\";\n\n/** Context for the Product SDK app instance */\nexport const ProductSDKContext = createContext<App | null>(null);\n\n/**\n * Hook to access the Product SDK app instance\n *\n * @throws If used outside of ProductSDKProvider\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const app = useProductSDK();\n * // Use app.wallet, app.localStorage, etc.\n * }\n * ```\n */\nexport function useProductSDK(): App {\n const app = useContext(ProductSDKContext);\n if (!app) {\n throw new Error(\n \"useProductSDK must be used within a ProductSDKProvider. \" +\n 'Wrap your app with <ProductSDKProvider name=\"your-app\">.',\n );\n }\n return app;\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * ProductSDKProvider component\n */\n\nimport React, { useEffect, useState, type ReactNode } from \"react\";\nimport { ProductSDKContext } from \"./context.js\";\nimport { createApp } from \"../core/createApp.js\";\nimport type { App, LogLevel } from \"../core/types.js\";\n\n/** Props for ProductSDKProvider */\nexport interface ProductSDKProviderProps {\n /** Application name - used for storage namespacing and product account derivation */\n name: string;\n /** Log level (default: 'info') */\n logLevel?: LogLevel;\n /** Child components */\n children: ReactNode;\n /** Fallback to show while loading */\n fallback?: ReactNode;\n}\n\n/**\n * Provider component that initializes the Product SDK\n *\n * @example\n * ```tsx\n * import { ProductSDKProvider } from '@parity/product-sdk/react';\n *\n * function App() {\n * return (\n * <ProductSDKProvider name=\"my-app\" fallback={<Loading />}>\n * <MyApp />\n * </ProductSDKProvider>\n * );\n * }\n * ```\n */\nexport function ProductSDKProvider({\n name,\n logLevel = \"info\",\n children,\n fallback = null,\n}: ProductSDKProviderProps) {\n const [app, setApp] = useState<App | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n let mounted = true;\n\n createApp({ name, logLevel })\n .then((createdApp) => {\n if (mounted) {\n setApp(createdApp);\n }\n })\n .catch((e) => {\n if (mounted) {\n setError(e instanceof Error ? e : new Error(String(e)));\n }\n });\n\n return () => {\n mounted = false;\n };\n }, [name, logLevel]);\n\n if (error) {\n throw error;\n }\n\n if (!app) {\n return <>{fallback}</>;\n }\n\n return <ProductSDKContext.Provider value={app}>{children}</ProductSDKContext.Provider>;\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * useWallet hook\n */\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { useProductSDK } from \"./context.js\";\nimport type {\n Account,\n DotNsIdentitySignature,\n SignMessageWithDotNsIdentityArgs,\n} from \"../core/types.js\";\n\n/** Wallet hook state */\nexport interface UseWalletState {\n /** Whether wallet is connected */\n isConnected: boolean;\n /** Whether connection is in progress */\n isConnecting: boolean;\n /** Available accounts */\n accounts: Account[];\n /** Currently selected account */\n selectedAccount: Account | null;\n /** Last error */\n error: Error | null;\n}\n\n/** Wallet hook actions */\nexport interface UseWalletActions {\n /** Connect to wallet */\n connect: () => Promise<void>;\n /** Disconnect from wallet */\n disconnect: () => Promise<void>;\n /** Select an account */\n selectAccount: (address: string) => void;\n /** Sign a message */\n signMessage: (message: string | Uint8Array) => Promise<Uint8Array>;\n /** Sign a message with the account that owns a DotNS / People username identity. */\n signMessageWithDotNsIdentity: (\n args: SignMessageWithDotNsIdentityArgs,\n ) => Promise<DotNsIdentitySignature>;\n}\n\n/** Return type of useWallet */\nexport type UseWalletReturn = UseWalletState & UseWalletActions;\n\n/**\n * Hook for wallet connection and signing\n *\n * @example\n * ```tsx\n * function WalletButton() {\n * const { isConnected, accounts, connect, disconnect, selectAccount } = useWallet();\n *\n * if (!isConnected) {\n * return <button onClick={connect}>Connect Wallet</button>;\n * }\n *\n * return (\n * <div>\n * <select onChange={(e) => selectAccount(e.target.value)}>\n * {accounts.map((a) => (\n * <option key={a.address} value={a.address}>\n * {a.name || a.address}\n * </option>\n * ))}\n * </select>\n * <button onClick={disconnect}>Disconnect</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useWallet(): UseWalletReturn {\n const app = useProductSDK();\n\n const [state, setState] = useState<UseWalletState>({\n isConnected: false,\n isConnecting: false,\n accounts: [],\n selectedAccount: null,\n error: null,\n });\n\n const connect = useCallback(async () => {\n setState((s) => ({ ...s, isConnecting: true, error: null }));\n try {\n const result = await app.wallet.connect();\n setState((s) => ({\n ...s,\n isConnected: true,\n isConnecting: false,\n accounts: result.accounts,\n selectedAccount: result.accounts[0] || null,\n }));\n } catch (e) {\n setState((s) => ({\n ...s,\n isConnecting: false,\n error: e instanceof Error ? e : new Error(String(e)),\n }));\n }\n }, [app]);\n\n const disconnect = useCallback(async () => {\n await app.wallet.disconnect();\n setState({\n isConnected: false,\n isConnecting: false,\n accounts: [],\n selectedAccount: null,\n error: null,\n });\n }, [app]);\n\n const selectAccount = useCallback(\n (address: string) => {\n app.wallet.selectAccount(address);\n const account = state.accounts.find((a) => a.address === address) || null;\n setState((s) => ({ ...s, selectedAccount: account }));\n },\n [app, state.accounts],\n );\n\n const signMessage = useCallback(\n async (message: string | Uint8Array) => {\n return app.wallet.signMessage(message);\n },\n [app],\n );\n\n const signMessageWithDotNsIdentity = useCallback(\n async (args: SignMessageWithDotNsIdentityArgs) => {\n return app.wallet.signMessageWithDotNsIdentity(args);\n },\n [app],\n );\n\n // Subscribe to account changes\n useEffect(() => {\n const unsubscribe = app.wallet.onAccountChange((account) => {\n setState((s) => ({ ...s, selectedAccount: account }));\n });\n return unsubscribe;\n }, [app]);\n\n return {\n ...state,\n connect,\n disconnect,\n selectAccount,\n signMessage,\n signMessageWithDotNsIdentity,\n };\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * useLocalStorage hook\n */\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { useProductSDK } from \"./context.js\";\n\n/**\n * Hook for key-value storage operations\n *\n * @param key - Storage key\n * @param defaultValue - Default value if key doesn't exist\n *\n * @example\n * ```tsx\n * function ThemeToggle() {\n * const [theme, setTheme, { loading }] = useLocalStorage('theme', 'light');\n *\n * if (loading) return <div>Loading...</div>;\n *\n * return (\n * <button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>\n * Current: {theme}\n * </button>\n * );\n * }\n * ```\n */\nexport function useLocalStorage<T = string>(\n key: string,\n defaultValue?: T,\n): [T | null, (value: T) => Promise<void>, { loading: boolean; error: Error | null }] {\n const app = useProductSDK();\n\n const [value, setValue] = useState<T | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n // Load initial value\n useEffect(() => {\n let mounted = true;\n\n const loadValue = async () => {\n try {\n setLoading(true);\n const stored = await app.localStorage.getJSON<T>(key);\n if (mounted) {\n setValue(stored ?? defaultValue ?? null);\n setLoading(false);\n }\n } catch (e) {\n if (mounted) {\n setError(e instanceof Error ? e : new Error(String(e)));\n setLoading(false);\n }\n }\n };\n\n loadValue();\n\n return () => {\n mounted = false;\n };\n }, [app, key, defaultValue]);\n\n const setStoredValue = useCallback(\n async (newValue: T) => {\n try {\n setError(null);\n await app.localStorage.setJSON(key, newValue);\n setValue(newValue);\n } catch (e) {\n setError(e instanceof Error ? e : new Error(String(e)));\n throw e;\n }\n },\n [app, key],\n );\n\n return [value, setStoredValue, { loading, error }];\n}\n\n/**\n * Hook for string storage (simpler API)\n *\n * @param key - Storage key\n * @param defaultValue - Default value\n */\nexport function useLocalStorageString(\n key: string,\n defaultValue?: string,\n): [string | null, (value: string) => Promise<void>, { loading: boolean }] {\n const app = useProductSDK();\n\n const [value, setValue] = useState<string | null>(null);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n let mounted = true;\n\n const loadValue = async () => {\n const stored = await app.localStorage.get(key);\n if (mounted) {\n setValue(stored ?? defaultValue ?? null);\n setLoading(false);\n }\n };\n\n loadValue();\n\n return () => {\n mounted = false;\n };\n }, [app, key, defaultValue]);\n\n const setStoredValue = useCallback(\n async (newValue: string) => {\n await app.localStorage.set(key, newValue);\n setValue(newValue);\n },\n [app, key],\n );\n\n return [value, setStoredValue, { loading }];\n}\n","// Copyright 2026 Parity Technologies (UK) Ltd.\n// SPDX-License-Identifier: Apache-2.0\n/**\n * useChain hook\n */\n\nimport { useMemo } from \"react\";\nimport { useProductSDK } from \"./context.js\";\nimport type { ChainDefinition, TypedApi } from \"../core/types.js\";\n\n/**\n * Hook to get a typed chain client\n *\n * @param chain - Chain descriptor (PAPI ChainDefinition)\n *\n * @example\n * ```tsx\n * import { paseo_asset_hub } from '@parity/product-sdk-descriptors/paseo-asset-hub';\n * import { useChain } from '@parity/product-sdk/react';\n *\n * function AssetHubBalance() {\n * const assetHub = useChain(paseo_asset_hub);\n *\n * // assetHub is typed for Asset Hub queries\n * const balance = await assetHub.query.System.Account.getValue(address);\n * }\n * ```\n */\nexport function useChain<T extends ChainDefinition>(chain: T): TypedApi<T> {\n const app = useProductSDK();\n\n return useMemo(() => {\n return app.chain.getClient(chain);\n }, [app, chain]);\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LogLevel } from '@parity/product-sdk-logger';
|
|
2
2
|
import { CloudStorageEnvironment } from '@parity/product-sdk-cloud-storage';
|
|
3
3
|
import { ChainClient } from '@parity/product-sdk-chain-client';
|
|
4
|
+
import { P as PeopleUsernameChain } from './dotns-hLSvmo6u.js';
|
|
4
5
|
import { ChainDefinition, TypedApi, PolkadotClient } from 'polkadot-api';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -41,6 +42,15 @@ interface WalletApi {
|
|
|
41
42
|
selectAccount(address: string): void;
|
|
42
43
|
/** Sign an arbitrary message */
|
|
43
44
|
signMessage(message: string | Uint8Array): Promise<Uint8Array>;
|
|
45
|
+
/**
|
|
46
|
+
* Sign a message with the account that owns a People / People Lite DotNS identity.
|
|
47
|
+
*
|
|
48
|
+
* Pass the People / Individuality chain descriptor used for username lookup.
|
|
49
|
+
* Pass `username` to choose a specific identity. When omitted, the SDK first
|
|
50
|
+
* asks the host for the user's primary DotNS name and signs with the account
|
|
51
|
+
* that owns that username.
|
|
52
|
+
*/
|
|
53
|
+
signMessageWithDotNsIdentity(args: SignMessageWithDotNsIdentityArgs): Promise<DotNsIdentitySignature>;
|
|
44
54
|
/** Subscribe to account changes */
|
|
45
55
|
onAccountChange(callback: (account: Account | null) => void): () => void;
|
|
46
56
|
/** Get product-scoped account (container mode only) */
|
|
@@ -147,5 +157,47 @@ interface Account {
|
|
|
147
157
|
/** Source of the account (host, dev signer, etc.) */
|
|
148
158
|
source: string;
|
|
149
159
|
}
|
|
160
|
+
/** Arguments for signing with a DotNS / People username identity. */
|
|
161
|
+
interface SignMessageWithDotNsIdentityArgs {
|
|
162
|
+
/**
|
|
163
|
+
* PAPI descriptor for the People / Individuality chain that exposes
|
|
164
|
+
* `Resources.UsernameOwnerOf`.
|
|
165
|
+
*
|
|
166
|
+
* The SDK reuses an already-connected client when one matches this
|
|
167
|
+
* descriptor's genesis. For long-running apps, call
|
|
168
|
+
* `app.chain.connect({ ..., <name>: peopleChain })` once at startup so
|
|
169
|
+
* every subsequent `signMessageWithDotNsIdentity` call reuses the same
|
|
170
|
+
* chainHead subscription. When the chain isn't already connected, the
|
|
171
|
+
* SDK opens a transient connection for the lookup; that connection then
|
|
172
|
+
* lives in the chain-client cache for the rest of the process.
|
|
173
|
+
*/
|
|
174
|
+
peopleChain: PeopleUsernameChain;
|
|
175
|
+
/**
|
|
176
|
+
* People / People Lite username to resolve before signing.
|
|
177
|
+
*
|
|
178
|
+
* If omitted, the SDK fetches the primary DotNS name associated with the
|
|
179
|
+
* connected user from the host identity API. Note: that fetch triggers a
|
|
180
|
+
* host identity-permission prompt, so callers who want to avoid the
|
|
181
|
+
* dialog on a likely-miss should resolve the username themselves first.
|
|
182
|
+
*
|
|
183
|
+
* The string is UTF-8 encoded and used as the storage key on
|
|
184
|
+
* `Resources.UsernameOwnerOf` exactly as supplied — no `.dot` suffix
|
|
185
|
+
* handling is applied. On paseo-individuality today usernames are
|
|
186
|
+
* stored as bare strings (e.g. `alice`, not `alice.dot`); pass the
|
|
187
|
+
* exact value the chain has registered.
|
|
188
|
+
*/
|
|
189
|
+
username?: string;
|
|
190
|
+
/** Message to sign. Strings are UTF-8 encoded before signing. */
|
|
191
|
+
message: string | Uint8Array;
|
|
192
|
+
}
|
|
193
|
+
/** Signature produced for a DotNS / People username identity. */
|
|
194
|
+
interface DotNsIdentitySignature {
|
|
195
|
+
/** Username used for the lookup. */
|
|
196
|
+
username: string;
|
|
197
|
+
/** Raw `AccountId32` owner resolved from `Resources.UsernameOwnerOf`. */
|
|
198
|
+
accountId: `0x${string}`;
|
|
199
|
+
/** Signature bytes returned by the host wallet. */
|
|
200
|
+
signature: Uint8Array;
|
|
201
|
+
}
|
|
150
202
|
|
|
151
|
-
export type { App as A, ChainApi as C, LocalStorageApi as L, WalletApi as W, Account as a, AppConfig as b, CloudStorageApi as c, CloudStorageConfig as d };
|
|
203
|
+
export type { App as A, ChainApi as C, DotNsIdentitySignature as D, LocalStorageApi as L, SignMessageWithDotNsIdentityArgs as S, WalletApi as W, Account as a, AppConfig as b, CloudStorageApi as c, CloudStorageConfig as d };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parity/product-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Unified SDK for building products in the Polkadot ecosystem - umbrella package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -64,16 +64,16 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"polkadot-api": "^2.1.5",
|
|
66
66
|
"@parity/product-sdk-address": "0.1.1",
|
|
67
|
-
"@parity/product-sdk-
|
|
68
|
-
"@parity/product-sdk-
|
|
67
|
+
"@parity/product-sdk-cloud-storage": "0.6.3",
|
|
68
|
+
"@parity/product-sdk-chain-client": "0.7.3",
|
|
69
69
|
"@parity/product-sdk-crypto": "0.1.1",
|
|
70
|
+
"@parity/product-sdk-contracts": "0.7.6",
|
|
71
|
+
"@parity/product-sdk-host": "0.10.1",
|
|
70
72
|
"@parity/product-sdk-logger": "0.1.1",
|
|
71
|
-
"@parity/product-sdk-
|
|
72
|
-
"@parity/product-sdk-
|
|
73
|
-
"@parity/product-sdk-
|
|
74
|
-
"@parity/product-sdk-
|
|
75
|
-
"@parity/product-sdk-tx": "0.2.11",
|
|
76
|
-
"@parity/product-sdk-signer": "0.6.4"
|
|
73
|
+
"@parity/product-sdk-keys": "0.3.9",
|
|
74
|
+
"@parity/product-sdk-local-storage": "0.2.8",
|
|
75
|
+
"@parity/product-sdk-tx": "0.2.13",
|
|
76
|
+
"@parity/product-sdk-signer": "0.8.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"react": "^18.0.0 || ^19.0.0"
|
package/src/core/createApp.ts
CHANGED
|
@@ -30,6 +30,12 @@ import {
|
|
|
30
30
|
isConnected,
|
|
31
31
|
destroyAll,
|
|
32
32
|
} from "@parity/product-sdk-chain-client";
|
|
33
|
+
import { getAccountsProvider } from "@parity/product-sdk-host";
|
|
34
|
+
import {
|
|
35
|
+
accountIdHexToBytes,
|
|
36
|
+
type PeopleUsernameQueryApi,
|
|
37
|
+
resolvePeopleUsernameOwner,
|
|
38
|
+
} from "../identity/dotns.js";
|
|
33
39
|
|
|
34
40
|
const log = createLogger("app");
|
|
35
41
|
|
|
@@ -277,6 +283,61 @@ function createWalletApi(signerManager: SignerManager): WalletApi {
|
|
|
277
283
|
return result.value;
|
|
278
284
|
},
|
|
279
285
|
|
|
286
|
+
async signMessageWithDotNsIdentity(args) {
|
|
287
|
+
const message =
|
|
288
|
+
typeof args.message === "string"
|
|
289
|
+
? new TextEncoder().encode(args.message)
|
|
290
|
+
: args.message;
|
|
291
|
+
const accountsProvider = await getHostAccountsProvider();
|
|
292
|
+
const username = args.username ?? (await getPrimaryUsername(accountsProvider));
|
|
293
|
+
|
|
294
|
+
// Reuse an already-connected People chain when the caller has
|
|
295
|
+
// wired one up via `app.chain.connect({ ..., <name>: peopleChain })`.
|
|
296
|
+
// Fall back to opening a transient connection so first-time users
|
|
297
|
+
// don't have to think about chain lifecycles. The chain-client
|
|
298
|
+
// module caches by genesis fingerprint, so subsequent
|
|
299
|
+
// signMessageWithDotNsIdentity calls share whichever connection
|
|
300
|
+
// got established first.
|
|
301
|
+
const peopleClient = isConnected(args.peopleChain)
|
|
302
|
+
? getClient(args.peopleChain)
|
|
303
|
+
: await createChainClient({ chains: { people: args.peopleChain } }).then(
|
|
304
|
+
(c) => c.raw.people,
|
|
305
|
+
);
|
|
306
|
+
// PAPI's `TypedApi.query.X.Y.getValue` is variadic
|
|
307
|
+
// (`...args: [...WithCallOptions<Args>]`) so it's not assignable
|
|
308
|
+
// to our deliberately-narrow `(key) => Promise<...>` shape. The
|
|
309
|
+
// resolver only ever passes the storage key; the cast adapts the
|
|
310
|
+
// wider PAPI surface to the minimum we depend on.
|
|
311
|
+
const peopleApi = peopleClient.getTypedApi(
|
|
312
|
+
args.peopleChain,
|
|
313
|
+
) as unknown as PeopleUsernameQueryApi;
|
|
314
|
+
const accountId = await resolvePeopleUsernameOwner(username, peopleApi);
|
|
315
|
+
if (!accountId) {
|
|
316
|
+
throw new Error(`No account owns DotNS username "${username}"`);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const owner = accountIdHexToBytes(accountId);
|
|
320
|
+
const signer = accountsProvider.getLegacyAccountSigner({
|
|
321
|
+
publicKey: owner,
|
|
322
|
+
name: username,
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
try {
|
|
326
|
+
return {
|
|
327
|
+
username,
|
|
328
|
+
accountId,
|
|
329
|
+
signature: await signer.signBytes(message),
|
|
330
|
+
};
|
|
331
|
+
} catch (cause) {
|
|
332
|
+
throw new Error(
|
|
333
|
+
`Failed to sign with DotNS username "${username}": ${
|
|
334
|
+
cause instanceof Error ? cause.message : String(cause)
|
|
335
|
+
}`,
|
|
336
|
+
{ cause },
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
|
|
280
341
|
onAccountChange(callback: (account: Account | null) => void): () => void {
|
|
281
342
|
accountChangeSubscribers.add(callback);
|
|
282
343
|
return () => accountChangeSubscribers.delete(callback);
|
|
@@ -309,3 +370,27 @@ function createWalletApi(signerManager: SignerManager): WalletApi {
|
|
|
309
370
|
},
|
|
310
371
|
};
|
|
311
372
|
}
|
|
373
|
+
|
|
374
|
+
type HostAccountsProvider = NonNullable<Awaited<ReturnType<typeof getAccountsProvider>>>;
|
|
375
|
+
|
|
376
|
+
async function getHostAccountsProvider(): Promise<HostAccountsProvider> {
|
|
377
|
+
const provider = await getAccountsProvider();
|
|
378
|
+
if (!provider) {
|
|
379
|
+
throw new Error("Host accounts provider is not available");
|
|
380
|
+
}
|
|
381
|
+
return provider;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
async function getPrimaryUsername(accountsProvider: HostAccountsProvider): Promise<string> {
|
|
385
|
+
const result = await accountsProvider.getUserId().match(
|
|
386
|
+
(value) => value,
|
|
387
|
+
(err) => {
|
|
388
|
+
throw err;
|
|
389
|
+
},
|
|
390
|
+
);
|
|
391
|
+
const username = result.primaryUsername.trim();
|
|
392
|
+
if (!username) {
|
|
393
|
+
throw new Error("Host identity did not provide a primary DotNS username");
|
|
394
|
+
}
|
|
395
|
+
return username;
|
|
396
|
+
}
|
package/src/core/types.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { LogLevel } from "@parity/product-sdk-logger";
|
|
8
8
|
import type { CloudStorageEnvironment } from "@parity/product-sdk-cloud-storage";
|
|
9
9
|
import type { ChainClient } from "@parity/product-sdk-chain-client";
|
|
10
|
+
import type { PeopleUsernameChain } from "../identity/dotns.js";
|
|
10
11
|
import type { ChainDefinition, TypedApi, PolkadotClient } from "polkadot-api";
|
|
11
12
|
|
|
12
13
|
export type { LogLevel };
|
|
@@ -46,6 +47,17 @@ export interface WalletApi {
|
|
|
46
47
|
selectAccount(address: string): void;
|
|
47
48
|
/** Sign an arbitrary message */
|
|
48
49
|
signMessage(message: string | Uint8Array): Promise<Uint8Array>;
|
|
50
|
+
/**
|
|
51
|
+
* Sign a message with the account that owns a People / People Lite DotNS identity.
|
|
52
|
+
*
|
|
53
|
+
* Pass the People / Individuality chain descriptor used for username lookup.
|
|
54
|
+
* Pass `username` to choose a specific identity. When omitted, the SDK first
|
|
55
|
+
* asks the host for the user's primary DotNS name and signs with the account
|
|
56
|
+
* that owns that username.
|
|
57
|
+
*/
|
|
58
|
+
signMessageWithDotNsIdentity(
|
|
59
|
+
args: SignMessageWithDotNsIdentityArgs,
|
|
60
|
+
): Promise<DotNsIdentitySignature>;
|
|
49
61
|
/** Subscribe to account changes */
|
|
50
62
|
onAccountChange(callback: (account: Account | null) => void): () => void;
|
|
51
63
|
/** Get product-scoped account (container mode only) */
|
|
@@ -162,5 +174,49 @@ export interface Account {
|
|
|
162
174
|
source: string;
|
|
163
175
|
}
|
|
164
176
|
|
|
177
|
+
/** Arguments for signing with a DotNS / People username identity. */
|
|
178
|
+
export interface SignMessageWithDotNsIdentityArgs {
|
|
179
|
+
/**
|
|
180
|
+
* PAPI descriptor for the People / Individuality chain that exposes
|
|
181
|
+
* `Resources.UsernameOwnerOf`.
|
|
182
|
+
*
|
|
183
|
+
* The SDK reuses an already-connected client when one matches this
|
|
184
|
+
* descriptor's genesis. For long-running apps, call
|
|
185
|
+
* `app.chain.connect({ ..., <name>: peopleChain })` once at startup so
|
|
186
|
+
* every subsequent `signMessageWithDotNsIdentity` call reuses the same
|
|
187
|
+
* chainHead subscription. When the chain isn't already connected, the
|
|
188
|
+
* SDK opens a transient connection for the lookup; that connection then
|
|
189
|
+
* lives in the chain-client cache for the rest of the process.
|
|
190
|
+
*/
|
|
191
|
+
peopleChain: PeopleUsernameChain;
|
|
192
|
+
/**
|
|
193
|
+
* People / People Lite username to resolve before signing.
|
|
194
|
+
*
|
|
195
|
+
* If omitted, the SDK fetches the primary DotNS name associated with the
|
|
196
|
+
* connected user from the host identity API. Note: that fetch triggers a
|
|
197
|
+
* host identity-permission prompt, so callers who want to avoid the
|
|
198
|
+
* dialog on a likely-miss should resolve the username themselves first.
|
|
199
|
+
*
|
|
200
|
+
* The string is UTF-8 encoded and used as the storage key on
|
|
201
|
+
* `Resources.UsernameOwnerOf` exactly as supplied — no `.dot` suffix
|
|
202
|
+
* handling is applied. On paseo-individuality today usernames are
|
|
203
|
+
* stored as bare strings (e.g. `alice`, not `alice.dot`); pass the
|
|
204
|
+
* exact value the chain has registered.
|
|
205
|
+
*/
|
|
206
|
+
username?: string;
|
|
207
|
+
/** Message to sign. Strings are UTF-8 encoded before signing. */
|
|
208
|
+
message: string | Uint8Array;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Signature produced for a DotNS / People username identity. */
|
|
212
|
+
export interface DotNsIdentitySignature {
|
|
213
|
+
/** Username used for the lookup. */
|
|
214
|
+
username: string;
|
|
215
|
+
/** Raw `AccountId32` owner resolved from `Resources.UsernameOwnerOf`. */
|
|
216
|
+
accountId: `0x${string}`;
|
|
217
|
+
/** Signature bytes returned by the host wallet. */
|
|
218
|
+
signature: Uint8Array;
|
|
219
|
+
}
|
|
220
|
+
|
|
165
221
|
// Re-export ChainDefinition from polkadot-api for convenience
|
|
166
222
|
export type { ChainDefinition, TypedApi, PolkadotClient } from "polkadot-api";
|