@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,10 +1,11 @@
|
|
|
1
|
+
import { resolvePeopleUsernameOwner, accountIdHexToBytes } from './chunk-BIKT6X54.js';
|
|
1
2
|
import { createLogger, configure } from '@parity/product-sdk-logger';
|
|
2
3
|
import { createLocalKvStore } from '@parity/product-sdk-local-storage';
|
|
3
4
|
import { SignerManager } from '@parity/product-sdk-signer';
|
|
4
5
|
import { CloudStorageClient, createLazySigner, calculateCid } from '@parity/product-sdk-cloud-storage';
|
|
5
|
-
import {
|
|
6
|
+
import { isConnected, getClient, createChainClient, destroyAll } from '@parity/product-sdk-chain-client';
|
|
7
|
+
import { getAccountsProvider } from '@parity/product-sdk-host';
|
|
6
8
|
|
|
7
|
-
// src/core/createApp.ts
|
|
8
9
|
var log = createLogger("app");
|
|
9
10
|
async function createApp(config) {
|
|
10
11
|
if (config.logLevel) {
|
|
@@ -151,6 +152,38 @@ function createWalletApi(signerManager) {
|
|
|
151
152
|
}
|
|
152
153
|
return result.value;
|
|
153
154
|
},
|
|
155
|
+
async signMessageWithDotNsIdentity(args) {
|
|
156
|
+
const message = typeof args.message === "string" ? new TextEncoder().encode(args.message) : args.message;
|
|
157
|
+
const accountsProvider = await getHostAccountsProvider();
|
|
158
|
+
const username = args.username ?? await getPrimaryUsername(accountsProvider);
|
|
159
|
+
const peopleClient = isConnected(args.peopleChain) ? getClient(args.peopleChain) : await createChainClient({ chains: { people: args.peopleChain } }).then(
|
|
160
|
+
(c) => c.raw.people
|
|
161
|
+
);
|
|
162
|
+
const peopleApi = peopleClient.getTypedApi(
|
|
163
|
+
args.peopleChain
|
|
164
|
+
);
|
|
165
|
+
const accountId = await resolvePeopleUsernameOwner(username, peopleApi);
|
|
166
|
+
if (!accountId) {
|
|
167
|
+
throw new Error(`No account owns DotNS username "${username}"`);
|
|
168
|
+
}
|
|
169
|
+
const owner = accountIdHexToBytes(accountId);
|
|
170
|
+
const signer = accountsProvider.getLegacyAccountSigner({
|
|
171
|
+
publicKey: owner,
|
|
172
|
+
name: username
|
|
173
|
+
});
|
|
174
|
+
try {
|
|
175
|
+
return {
|
|
176
|
+
username,
|
|
177
|
+
accountId,
|
|
178
|
+
signature: await signer.signBytes(message)
|
|
179
|
+
};
|
|
180
|
+
} catch (cause) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
`Failed to sign with DotNS username "${username}": ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
183
|
+
{ cause }
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
154
187
|
onAccountChange(callback) {
|
|
155
188
|
accountChangeSubscribers.add(callback);
|
|
156
189
|
return () => accountChangeSubscribers.delete(callback);
|
|
@@ -174,7 +207,27 @@ function createWalletApi(signerManager) {
|
|
|
174
207
|
}
|
|
175
208
|
};
|
|
176
209
|
}
|
|
210
|
+
async function getHostAccountsProvider() {
|
|
211
|
+
const provider = await getAccountsProvider();
|
|
212
|
+
if (!provider) {
|
|
213
|
+
throw new Error("Host accounts provider is not available");
|
|
214
|
+
}
|
|
215
|
+
return provider;
|
|
216
|
+
}
|
|
217
|
+
async function getPrimaryUsername(accountsProvider) {
|
|
218
|
+
const result = await accountsProvider.getUserId().match(
|
|
219
|
+
(value) => value,
|
|
220
|
+
(err) => {
|
|
221
|
+
throw err;
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
const username = result.primaryUsername.trim();
|
|
225
|
+
if (!username) {
|
|
226
|
+
throw new Error("Host identity did not provide a primary DotNS username");
|
|
227
|
+
}
|
|
228
|
+
return username;
|
|
229
|
+
}
|
|
177
230
|
|
|
178
231
|
export { createApp };
|
|
179
|
-
//# sourceMappingURL=chunk-
|
|
180
|
-
//# sourceMappingURL=chunk-
|
|
232
|
+
//# sourceMappingURL=chunk-6MNKFIU6.js.map
|
|
233
|
+
//# sourceMappingURL=chunk-6MNKFIU6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/createApp.ts"],"names":[],"mappings":";;;;;;;;AAuCA,IAAM,GAAA,GAAM,aAAa,KAAK,CAAA;AA0C9B,eAAsB,UAAU,MAAA,EAAiC;AAE7D,EAAA,IAAI,OAAO,QAAA,EAAU;AACjB,IAAA,SAAA,CAAU,EAAE,KAAA,EAAO,MAAA,CAAO,QAAA,EAAU,CAAA;AAAA,EACxC;AAEA,EAAA,GAAA,CAAI,KAAK,0BAAA,EAA4B,EAAE,IAAA,EAAM,MAAA,CAAO,MAAM,CAAA;AAG1D,EAAA,MAAM,eAAe,MAAM,kBAAA,CAAmB,EAAE,MAAA,EAAQ,MAAA,CAAO,MAAM,CAAA;AAGrE,EAAA,MAAM,aAAA,GAAgB,IAAI,aAAA,CAAc;AAAA,IACpC,UAAU,MAAA,CAAO;AAAA,GACpB,CAAA;AAUD,EAAA,MAAM,mBAAA,GAA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A,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,CAAC,GAAA,KAAQ;AACL,MAAA,MAAM,GAAA;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-6MNKFIU6.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 { 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 calculateCid,\n createLazySigner,\n} from \"@parity/product-sdk-cloud-storage\";\nimport {\n createChainClient,\n getClient,\n isConnected,\n destroyAll,\n} from \"@parity/product-sdk-chain-client\";\nimport { getAccountsProvider } from \"@parity/product-sdk-host\";\nimport {\n accountIdHexToBytes,\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 * name: 'my-app',\n * logLevel: 'info',\n * });\n *\n * // Custom cloud storage environment\n * const prodApp = await createApp({\n * name: 'my-app',\n * cloudStorage: { environment: 'polkadot' },\n * });\n *\n * // Disable cloud storage entirely\n * const noCloudStorageApp = await createApp({\n * name: 'my-app',\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 log.info(\"Creating Product SDK app\", { name: config.name });\n\n // Initialize storage (container-only - will throw if not in container)\n const localKvStore = await createLocalKvStore({ prefix: config.name });\n\n // Initialize signer manager\n const signerManager = new SignerManager({\n dappName: config.name,\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 // Create storage API adapter\n const localStorageApi: LocalStorageApi = {\n get: (key) => localKvStore.get(key),\n set: (key, value) => localKvStore.set(key, value),\n getJSON: <T>(key: string) => localKvStore.getJSON<T>(key),\n setJSON: <T>(key: string, value: T) => localKvStore.setJSON(key, value),\n remove: (key) => localKvStore.remove(key),\n clear: async () => {\n // LocalKvStore doesn't have clear - this is a no-op\n log.debug(\"clear() is not supported in container storage mode\");\n },\n };\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 // 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 CloudStorageApi.upload promises a string return, and\n // app consumers expect a CID they can hand to `fetch(cid)`. Keep\n // the defensive null-check below as belt-and-braces in case the\n // upstream contract shifts.\n const result = await cloudStorageClient.store(bytes).withManifest(true).send();\n if (!result.cid) {\n throw new Error(\n \"Cloud storage upload returned no CID despite .withManifest(true). Upstream contract may have shifted — file an issue.\",\n );\n }\n return result.cid.toString();\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: config.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 }),\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 accountId = await resolvePeopleUsernameOwner(username, peopleApi);\n if (!accountId) {\n throw new Error(`No account owns DotNS username \"${username}\"`);\n }\n\n const owner = accountIdHexToBytes(accountId);\n const signer = accountsProvider.getLegacyAccountSigner({\n publicKey: owner,\n name: username,\n });\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"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { accountIdBytes } from '@parity/product-sdk-address';
|
|
2
|
+
import { hexToBytes, bytesToHex } from '@parity/product-sdk-crypto';
|
|
3
|
+
import { createLogger } from '@parity/product-sdk-logger';
|
|
4
|
+
|
|
5
|
+
// src/identity/dotns.ts
|
|
6
|
+
var log = createLogger("identity");
|
|
7
|
+
function isValidDotNsName(name) {
|
|
8
|
+
if (!name.endsWith(".dot")) return false;
|
|
9
|
+
const label = name.slice(0, -4);
|
|
10
|
+
if (label.length < 3 || label.length > 63) return false;
|
|
11
|
+
return /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(label);
|
|
12
|
+
}
|
|
13
|
+
function normalizeDotNsName(name) {
|
|
14
|
+
let normalized = name.toLowerCase().trim();
|
|
15
|
+
if (!normalized.endsWith(".dot")) {
|
|
16
|
+
normalized += ".dot";
|
|
17
|
+
}
|
|
18
|
+
return normalized;
|
|
19
|
+
}
|
|
20
|
+
async function resolveDotNs(name) {
|
|
21
|
+
const normalized = normalizeDotNsName(name);
|
|
22
|
+
if (!isValidDotNsName(normalized)) {
|
|
23
|
+
log.warn("Invalid DotNS name", { name });
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
log.debug("Resolving DotNS name", { name: normalized });
|
|
27
|
+
throw new Error(
|
|
28
|
+
"resolveDotNs() is not yet implemented. This is a skeleton for the Product SDK structure."
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
async function reverseDotNs(address) {
|
|
32
|
+
log.debug("Reverse resolving address", { address });
|
|
33
|
+
throw new Error(
|
|
34
|
+
"reverseDotNs() is not yet implemented. This is a skeleton for the Product SDK structure."
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
async function isDotNsAvailable(name) {
|
|
38
|
+
const record = await resolveDotNs(name).catch(() => null);
|
|
39
|
+
return record === null;
|
|
40
|
+
}
|
|
41
|
+
async function resolvePeopleUsernameOwner(username, peopleApi) {
|
|
42
|
+
const owner = await peopleApi.query.Resources.UsernameOwnerOf.getValue(
|
|
43
|
+
new TextEncoder().encode(username)
|
|
44
|
+
);
|
|
45
|
+
if (!owner) return null;
|
|
46
|
+
return accountIdBytesToHex(accountIdBytes(owner));
|
|
47
|
+
}
|
|
48
|
+
function assertHex(value) {
|
|
49
|
+
if (!/^0x[0-9a-fA-F]*$/.test(value)) {
|
|
50
|
+
throw new Error(`Expected 0x-prefixed hex string, got ${value}`);
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
function accountIdHexToBytes(accountId) {
|
|
55
|
+
const bytes = hexToBytes(assertHex(accountId).slice(2));
|
|
56
|
+
if (bytes.length !== 32) {
|
|
57
|
+
throw new Error(`Expected 32-byte AccountId, got ${bytes.length} bytes`);
|
|
58
|
+
}
|
|
59
|
+
return bytes;
|
|
60
|
+
}
|
|
61
|
+
function accountIdBytesToHex(bytes) {
|
|
62
|
+
if (bytes.length !== 32) {
|
|
63
|
+
throw new Error(`Expected 32-byte AccountId, got ${bytes.length} bytes`);
|
|
64
|
+
}
|
|
65
|
+
return `0x${bytesToHex(bytes)}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { accountIdHexToBytes, isDotNsAvailable, isValidDotNsName, normalizeDotNsName, resolveDotNs, resolvePeopleUsernameOwner, reverseDotNs };
|
|
69
|
+
//# sourceMappingURL=chunk-BIKT6X54.js.map
|
|
70
|
+
//# sourceMappingURL=chunk-BIKT6X54.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/identity/dotns.ts"],"names":[],"mappings":";;;;;AAsBA,IAAM,GAAA,GAAM,aAAa,UAAU,CAAA;AAwD5B,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;AACvD;AAQO,SAAS,mBAAmB,IAAA,EAAsB;AACrD,EAAA,IAAI,UAAA,GAAa,IAAA,CAAK,WAAA,EAAY,CAAE,IAAA,EAAK;AACzC,EAAA,IAAI,CAAC,UAAA,CAAW,QAAA,CAAS,MAAM,CAAA,EAAG;AAC9B,IAAA,UAAA,IAAc,MAAA;AAAA,EAClB;AACA,EAAA,OAAO,UAAA;AACX;AAaA,eAAsB,aAAa,IAAA,EAA2C;AAC1E,EAAA,MAAM,UAAA,GAAa,mBAAmB,IAAI,CAAA;AAE1C,EAAA,IAAI,CAAC,gBAAA,CAAiB,UAAU,CAAA,EAAG;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AM,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;AAEA,SAAS,oBAAoB,KAAA,EAAkC;AAC3D,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,EAAK,UAAA,CAAW,KAAK,CAAC,CAAA,CAAA;AACjC","file":"chunk-BIKT6X54.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 { accountIdBytes } from \"@parity/product-sdk-address\";\nimport { bytesToHex, hexToBytes } from \"@parity/product-sdk-crypto\";\nimport { createLogger } from \"@parity/product-sdk-logger\";\nimport type {\n ChainDefinition,\n PalletsTypedef,\n PlainDescriptor,\n RuntimeDescriptor,\n SS58String,\n StorageDescriptor,\n TxDescriptor,\n} from \"polkadot-api\";\nimport type { DotNsRecord } from \"./types.js\";\n\nconst log = createLogger(\"identity\");\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 * 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 * @deprecated Not implemented — throws at runtime. Use\n * `wallet.signMessageWithDotNsIdentity({ peopleChain, username })` (which\n * internally calls {@link resolvePeopleUsernameOwner}) for the supported\n * People-chain username flow.\n *\n * @param name - DotNS name (e.g., \"alice.dot\")\n * @returns Resolved record or null if not found\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 * @deprecated Not implemented — throws at runtime. Reverse lookup will land\n * alongside future identity work; for now resolve forward via\n * `wallet.signMessageWithDotNsIdentity`.\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 * @deprecated Not implemented — depends on {@link resolveDotNs} which throws.\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\n/**\n * Resolve a People / People Lite username to its owning `AccountId32`.\n *\n * Queries `Resources.UsernameOwnerOf` on the caller-supplied typed-api fragment.\n * The returned value is the raw 32-byte account id as a `0x`-prefixed hex\n * string, or `null` when no owner is registered for that username.\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<`0x${string}` | null> {\n const owner = await peopleApi.query.Resources.UsernameOwnerOf.getValue(\n new TextEncoder().encode(username),\n );\n if (!owner) return null;\n\n return accountIdBytesToHex(accountIdBytes(owner));\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\nfunction 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"]}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { createApp } from '../index.js';
|
|
2
2
|
export { LogEntry, LogHandler, LogLevel, Logger, LoggerConfig, configure, createLogger } from '@parity/product-sdk-logger';
|
|
3
|
-
export { a as Account, A as App, b as AppConfig, C as ChainApi, c as CloudStorageApi, d as CloudStorageConfig, L as LocalStorageApi, W as WalletApi } from '../types-
|
|
3
|
+
export { a as Account, A as App, b as AppConfig, C as ChainApi, c as CloudStorageApi, d as CloudStorageConfig, D as DotNsIdentitySignature, L as LocalStorageApi, S as SignMessageWithDotNsIdentityArgs, W as WalletApi } from '../types-DsMUguUr.js';
|
|
4
4
|
export { ChainClient } from '@parity/product-sdk-chain-client';
|
|
5
5
|
export { ChainDefinition, PolkadotClient, TypedApi } from 'polkadot-api';
|
|
6
6
|
import '@parity/product-sdk-host';
|
|
7
7
|
import '@parity/product-sdk-signer';
|
|
8
8
|
import '@parity/product-sdk-local-storage';
|
|
9
9
|
import '@parity/product-sdk-cloud-storage';
|
|
10
|
+
import '../dotns-hLSvmo6u.js';
|
package/dist/core/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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
|
//# sourceMappingURL=index.js.map
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { ChainDefinition, PalletsTypedef, StorageDescriptor, SS58String, TxDescriptor, PlainDescriptor, RuntimeDescriptor } from 'polkadot-api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Identity module types
|
|
5
|
+
*
|
|
6
|
+
* Types for DotNS name resolution and context-alias derivation
|
|
7
|
+
*/
|
|
8
|
+
/** DotNS name resolution result */
|
|
9
|
+
interface DotNsRecord {
|
|
10
|
+
/** Resolved SS58 address */
|
|
11
|
+
address: string;
|
|
12
|
+
/** Name that was resolved */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Owner address */
|
|
15
|
+
owner: string;
|
|
16
|
+
/** Expiration timestamp (if applicable) */
|
|
17
|
+
expiresAt?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Context alias info: a deterministic, context-bound alias derived from a parent account */
|
|
20
|
+
interface ContextAliasInfo {
|
|
21
|
+
/** Alias SS58 address */
|
|
22
|
+
address: string;
|
|
23
|
+
/** H160 EVM address */
|
|
24
|
+
h160Address: `0x${string}`;
|
|
25
|
+
/** Parent account address */
|
|
26
|
+
parentAddress: string;
|
|
27
|
+
/** Context string used for derivation */
|
|
28
|
+
context: string;
|
|
29
|
+
}
|
|
30
|
+
/** Ring VRF alias info */
|
|
31
|
+
interface AnonymousAliasInfo {
|
|
32
|
+
/** Anonymous alias identifier */
|
|
33
|
+
alias: string;
|
|
34
|
+
/** Ring location for proof generation */
|
|
35
|
+
ringLocation: RingLocation;
|
|
36
|
+
/** Context used for alias derivation */
|
|
37
|
+
context: string;
|
|
38
|
+
}
|
|
39
|
+
/** Ring location for VRF proofs */
|
|
40
|
+
interface RingLocation {
|
|
41
|
+
/** Ring index */
|
|
42
|
+
ringIndex: number;
|
|
43
|
+
/** Member index within ring */
|
|
44
|
+
memberIndex: number;
|
|
45
|
+
}
|
|
46
|
+
/** Identity verification result */
|
|
47
|
+
interface VerificationResult {
|
|
48
|
+
/** Whether identity is verified */
|
|
49
|
+
verified: boolean;
|
|
50
|
+
/** Verification method used */
|
|
51
|
+
method: "on-chain" | "judgement" | "social";
|
|
52
|
+
/** Verification details */
|
|
53
|
+
details?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/** On-chain identity info */
|
|
56
|
+
interface OnChainIdentity {
|
|
57
|
+
/** Display name */
|
|
58
|
+
display?: string;
|
|
59
|
+
/** Legal name */
|
|
60
|
+
legal?: string;
|
|
61
|
+
/** Web URL */
|
|
62
|
+
web?: string;
|
|
63
|
+
/** Email */
|
|
64
|
+
email?: string;
|
|
65
|
+
/** Twitter handle */
|
|
66
|
+
twitter?: string;
|
|
67
|
+
/** Riot/Matrix handle */
|
|
68
|
+
riot?: string;
|
|
69
|
+
/** Additional fields */
|
|
70
|
+
additional: Array<[string, string]>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* DotNS (Polkadot Name Service) utilities
|
|
75
|
+
*
|
|
76
|
+
* Provides name resolution for .dot domains
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
type AnyDescriptorEntry<T> = Record<string, Record<string, T>>;
|
|
80
|
+
type PeopleUsernameStorage = {
|
|
81
|
+
Resources: {
|
|
82
|
+
UsernameOwnerOf: StorageDescriptor<[Uint8Array], SS58String, true, never>;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
type PeopleUsernamePallets = PalletsTypedef<PeopleUsernameStorage, AnyDescriptorEntry<TxDescriptor<any>>, AnyDescriptorEntry<PlainDescriptor<any>>, AnyDescriptorEntry<PlainDescriptor<any>>, AnyDescriptorEntry<PlainDescriptor<any>>, AnyDescriptorEntry<RuntimeDescriptor<any, any>>>;
|
|
86
|
+
/**
|
|
87
|
+
* Descriptor narrowed to "any chain that exposes `Resources.UsernameOwnerOf`".
|
|
88
|
+
*
|
|
89
|
+
* Used as the input to `signMessageWithDotNsIdentity` so the SDK doesn't pin
|
|
90
|
+
* a specific People-chain genesis — anything with the right storage shape
|
|
91
|
+
* (paseo-individuality today, future People Lite, etc.) is accepted.
|
|
92
|
+
*/
|
|
93
|
+
type PeopleUsernameChain = ChainDefinition & {
|
|
94
|
+
descriptors: Promise<unknown> & {
|
|
95
|
+
pallets: PeopleUsernamePallets;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Minimal typed-api shape required to resolve a username on a People chain.
|
|
100
|
+
*
|
|
101
|
+
* This is a narrow structural type — anything with the right
|
|
102
|
+
* `query.Resources.UsernameOwnerOf.getValue` shape works, including a real
|
|
103
|
+
* `TypedApi<PeopleUsernameChain>` slice of a `ChainClient` or a hand-rolled
|
|
104
|
+
* test double.
|
|
105
|
+
*/
|
|
106
|
+
type PeopleUsernameQueryApi = {
|
|
107
|
+
query: {
|
|
108
|
+
Resources: {
|
|
109
|
+
UsernameOwnerOf: {
|
|
110
|
+
getValue: (key: Uint8Array) => Promise<SS58String | undefined>;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Check if a string is a valid DotNS name
|
|
117
|
+
*
|
|
118
|
+
* @param name - Name to validate
|
|
119
|
+
* @returns True if valid DotNS name
|
|
120
|
+
*/
|
|
121
|
+
declare function isValidDotNsName(name: string): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Normalize a DotNS name (lowercase, trim whitespace)
|
|
124
|
+
*
|
|
125
|
+
* @param name - Name to normalize
|
|
126
|
+
* @returns Normalized name
|
|
127
|
+
*/
|
|
128
|
+
declare function normalizeDotNsName(name: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Resolve a DotNS name to an address.
|
|
131
|
+
*
|
|
132
|
+
* @deprecated Not implemented — throws at runtime. Use
|
|
133
|
+
* `wallet.signMessageWithDotNsIdentity({ peopleChain, username })` (which
|
|
134
|
+
* internally calls {@link resolvePeopleUsernameOwner}) for the supported
|
|
135
|
+
* People-chain username flow.
|
|
136
|
+
*
|
|
137
|
+
* @param name - DotNS name (e.g., "alice.dot")
|
|
138
|
+
* @returns Resolved record or null if not found
|
|
139
|
+
*/
|
|
140
|
+
declare function resolveDotNs(name: string): Promise<DotNsRecord | null>;
|
|
141
|
+
/**
|
|
142
|
+
* Reverse resolve an address to a DotNS name.
|
|
143
|
+
*
|
|
144
|
+
* @deprecated Not implemented — throws at runtime. Reverse lookup will land
|
|
145
|
+
* alongside future identity work; for now resolve forward via
|
|
146
|
+
* `wallet.signMessageWithDotNsIdentity`.
|
|
147
|
+
*
|
|
148
|
+
* @param address - SS58 address
|
|
149
|
+
* @returns Primary name or null if none set
|
|
150
|
+
*/
|
|
151
|
+
declare function reverseDotNs(address: string): Promise<string | null>;
|
|
152
|
+
/**
|
|
153
|
+
* Check if a DotNS name is available for registration.
|
|
154
|
+
*
|
|
155
|
+
* @deprecated Not implemented — depends on {@link resolveDotNs} which throws.
|
|
156
|
+
*
|
|
157
|
+
* @param name - Name to check
|
|
158
|
+
* @returns True if available
|
|
159
|
+
*/
|
|
160
|
+
declare function isDotNsAvailable(name: string): Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* Resolve a People / People Lite username to its owning `AccountId32`.
|
|
163
|
+
*
|
|
164
|
+
* Queries `Resources.UsernameOwnerOf` on the caller-supplied typed-api fragment.
|
|
165
|
+
* The returned value is the raw 32-byte account id as a `0x`-prefixed hex
|
|
166
|
+
* string, or `null` when no owner is registered for that username.
|
|
167
|
+
*
|
|
168
|
+
* The `username` is UTF-8 encoded as-is — no normalization is applied. Pass
|
|
169
|
+
* the exact byte string the chain stores (typically with the `.dot` suffix).
|
|
170
|
+
*
|
|
171
|
+
* @internal Exposed for unit testing. Consumers should use
|
|
172
|
+
* `wallet.signMessageWithDotNsIdentity` instead, which orchestrates the
|
|
173
|
+
* chain-connection lifecycle.
|
|
174
|
+
*/
|
|
175
|
+
declare function resolvePeopleUsernameOwner(username: string, peopleApi: PeopleUsernameQueryApi): Promise<`0x${string}` | null>;
|
|
176
|
+
declare function accountIdHexToBytes(accountId: `0x${string}`): Uint8Array;
|
|
177
|
+
|
|
178
|
+
export { type AnonymousAliasInfo as A, type ContextAliasInfo as C, type DotNsRecord as D, type OnChainIdentity as O, type PeopleUsernameChain as P, type RingLocation as R, type VerificationResult as V, type PeopleUsernameQueryApi as a, accountIdHexToBytes as b, isValidDotNsName as c, resolvePeopleUsernameOwner as d, reverseDotNs as e, isDotNsAvailable as i, normalizeDotNsName as n, resolveDotNs as r };
|
package/dist/identity/index.d.ts
CHANGED
|
@@ -1,122 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Types for DotNS name resolution and context-alias derivation
|
|
5
|
-
*/
|
|
6
|
-
/** DotNS name resolution result */
|
|
7
|
-
interface DotNsRecord {
|
|
8
|
-
/** Resolved SS58 address */
|
|
9
|
-
address: string;
|
|
10
|
-
/** Name that was resolved */
|
|
11
|
-
name: string;
|
|
12
|
-
/** Owner address */
|
|
13
|
-
owner: string;
|
|
14
|
-
/** Expiration timestamp (if applicable) */
|
|
15
|
-
expiresAt?: number;
|
|
16
|
-
}
|
|
17
|
-
/** Context alias info: a deterministic, context-bound alias derived from a parent account */
|
|
18
|
-
interface ContextAliasInfo {
|
|
19
|
-
/** Alias SS58 address */
|
|
20
|
-
address: string;
|
|
21
|
-
/** H160 EVM address */
|
|
22
|
-
h160Address: `0x${string}`;
|
|
23
|
-
/** Parent account address */
|
|
24
|
-
parentAddress: string;
|
|
25
|
-
/** Context string used for derivation */
|
|
26
|
-
context: string;
|
|
27
|
-
}
|
|
28
|
-
/** Ring VRF alias info */
|
|
29
|
-
interface AnonymousAliasInfo {
|
|
30
|
-
/** Anonymous alias identifier */
|
|
31
|
-
alias: string;
|
|
32
|
-
/** Ring location for proof generation */
|
|
33
|
-
ringLocation: RingLocation;
|
|
34
|
-
/** Context used for alias derivation */
|
|
35
|
-
context: string;
|
|
36
|
-
}
|
|
37
|
-
/** Ring location for VRF proofs */
|
|
38
|
-
interface RingLocation {
|
|
39
|
-
/** Ring index */
|
|
40
|
-
ringIndex: number;
|
|
41
|
-
/** Member index within ring */
|
|
42
|
-
memberIndex: number;
|
|
43
|
-
}
|
|
44
|
-
/** Identity verification result */
|
|
45
|
-
interface VerificationResult {
|
|
46
|
-
/** Whether identity is verified */
|
|
47
|
-
verified: boolean;
|
|
48
|
-
/** Verification method used */
|
|
49
|
-
method: "on-chain" | "judgement" | "social";
|
|
50
|
-
/** Verification details */
|
|
51
|
-
details?: Record<string, unknown>;
|
|
52
|
-
}
|
|
53
|
-
/** On-chain identity info */
|
|
54
|
-
interface OnChainIdentity {
|
|
55
|
-
/** Display name */
|
|
56
|
-
display?: string;
|
|
57
|
-
/** Legal name */
|
|
58
|
-
legal?: string;
|
|
59
|
-
/** Web URL */
|
|
60
|
-
web?: string;
|
|
61
|
-
/** Email */
|
|
62
|
-
email?: string;
|
|
63
|
-
/** Twitter handle */
|
|
64
|
-
twitter?: string;
|
|
65
|
-
/** Riot/Matrix handle */
|
|
66
|
-
riot?: string;
|
|
67
|
-
/** Additional fields */
|
|
68
|
-
additional: Array<[string, string]>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* DotNS (Polkadot Name Service) utilities
|
|
73
|
-
*
|
|
74
|
-
* Provides name resolution for .dot domains
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Check if a string is a valid DotNS name
|
|
79
|
-
*
|
|
80
|
-
* @param name - Name to validate
|
|
81
|
-
* @returns True if valid DotNS name
|
|
82
|
-
*/
|
|
83
|
-
declare function isValidDotNsName(name: string): boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Normalize a DotNS name (lowercase, trim whitespace)
|
|
86
|
-
*
|
|
87
|
-
* @param name - Name to normalize
|
|
88
|
-
* @returns Normalized name
|
|
89
|
-
*/
|
|
90
|
-
declare function normalizeDotNsName(name: string): string;
|
|
91
|
-
/**
|
|
92
|
-
* Resolve a DotNS name to an address
|
|
93
|
-
*
|
|
94
|
-
* @param name - DotNS name (e.g., "alice.dot")
|
|
95
|
-
* @returns Resolved record or null if not found
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```ts
|
|
99
|
-
* const record = await resolveDotNs('alice.dot');
|
|
100
|
-
* if (record) {
|
|
101
|
-
* console.log('Address:', record.address);
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
declare function resolveDotNs(name: string): Promise<DotNsRecord | null>;
|
|
106
|
-
/**
|
|
107
|
-
* Reverse resolve an address to a DotNS name
|
|
108
|
-
*
|
|
109
|
-
* @param address - SS58 address
|
|
110
|
-
* @returns Primary name or null if none set
|
|
111
|
-
*/
|
|
112
|
-
declare function reverseDotNs(address: string): Promise<string | null>;
|
|
113
|
-
/**
|
|
114
|
-
* Check if a DotNS name is available for registration
|
|
115
|
-
*
|
|
116
|
-
* @param name - Name to check
|
|
117
|
-
* @returns True if available
|
|
118
|
-
*/
|
|
119
|
-
declare function isDotNsAvailable(name: string): Promise<boolean>;
|
|
1
|
+
import { R as RingLocation, A as AnonymousAliasInfo, C as ContextAliasInfo } from '../dotns-hLSvmo6u.js';
|
|
2
|
+
export { D as DotNsRecord, O as OnChainIdentity, P as PeopleUsernameChain, a as PeopleUsernameQueryApi, V as VerificationResult, b as accountIdHexToBytes, i as isDotNsAvailable, c as isValidDotNsName, n as normalizeDotNsName, r as resolveDotNs, d as resolvePeopleUsernameOwner, e as reverseDotNs } from '../dotns-hLSvmo6u.js';
|
|
3
|
+
import 'polkadot-api';
|
|
120
4
|
|
|
121
5
|
/**
|
|
122
6
|
* Context alias derivation
|
|
@@ -187,4 +71,4 @@ declare function createRingProof(message: Uint8Array, ringLocation: RingLocation
|
|
|
187
71
|
*/
|
|
188
72
|
declare function verifyRingProof(message: Uint8Array, proof: Uint8Array, alias: string): Promise<boolean>;
|
|
189
73
|
|
|
190
|
-
export {
|
|
74
|
+
export { AnonymousAliasInfo, ContextAliasInfo, RingLocation, createRingProof, deriveAnonymousAlias, deriveContextAlias, verifyContextAlias, verifyRingProof };
|
package/dist/identity/index.js
CHANGED
|
@@ -1,44 +1,9 @@
|
|
|
1
|
+
export { accountIdHexToBytes, isDotNsAvailable, isValidDotNsName, normalizeDotNsName, resolveDotNs, resolvePeopleUsernameOwner, reverseDotNs } from '../chunk-BIKT6X54.js';
|
|
1
2
|
import { createLogger } from '@parity/product-sdk-logger';
|
|
2
3
|
import { blake2b256 } from '@parity/product-sdk-crypto';
|
|
3
4
|
import { ss58Decode, ss58Encode, deriveH160 } from '@parity/product-sdk-address';
|
|
4
5
|
|
|
5
|
-
// src/identity/dotns.ts
|
|
6
6
|
var log = createLogger("identity");
|
|
7
|
-
function isValidDotNsName(name) {
|
|
8
|
-
if (!name.endsWith(".dot")) return false;
|
|
9
|
-
const label = name.slice(0, -4);
|
|
10
|
-
if (label.length < 3 || label.length > 63) return false;
|
|
11
|
-
return /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(label);
|
|
12
|
-
}
|
|
13
|
-
function normalizeDotNsName(name) {
|
|
14
|
-
let normalized = name.toLowerCase().trim();
|
|
15
|
-
if (!normalized.endsWith(".dot")) {
|
|
16
|
-
normalized += ".dot";
|
|
17
|
-
}
|
|
18
|
-
return normalized;
|
|
19
|
-
}
|
|
20
|
-
async function resolveDotNs(name) {
|
|
21
|
-
const normalized = normalizeDotNsName(name);
|
|
22
|
-
if (!isValidDotNsName(normalized)) {
|
|
23
|
-
log.warn("Invalid DotNS name", { name });
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
log.debug("Resolving DotNS name", { name: normalized });
|
|
27
|
-
throw new Error(
|
|
28
|
-
"resolveDotNs() is not yet implemented. This is a skeleton for the Product SDK structure."
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
async function reverseDotNs(address) {
|
|
32
|
-
log.debug("Reverse resolving address", { address });
|
|
33
|
-
throw new Error(
|
|
34
|
-
"reverseDotNs() is not yet implemented. This is a skeleton for the Product SDK structure."
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
async function isDotNsAvailable(name) {
|
|
38
|
-
const record = await resolveDotNs(name).catch(() => null);
|
|
39
|
-
return record === null;
|
|
40
|
-
}
|
|
41
|
-
var log2 = createLogger("identity");
|
|
42
7
|
function deriveContextAlias(parentAddress, context, ss58Prefix = 42) {
|
|
43
8
|
const { publicKey: parentPublicKey } = ss58Decode(parentAddress);
|
|
44
9
|
const contextBytes = new TextEncoder().encode(context);
|
|
@@ -48,7 +13,7 @@ function deriveContextAlias(parentAddress, context, ss58Prefix = 42) {
|
|
|
48
13
|
const aliasPublicKey = blake2b256(combined);
|
|
49
14
|
const address = ss58Encode(aliasPublicKey, ss58Prefix);
|
|
50
15
|
const h160Address = deriveH160(aliasPublicKey);
|
|
51
|
-
|
|
16
|
+
log.debug("Derived context alias", {
|
|
52
17
|
parentAddress,
|
|
53
18
|
context,
|
|
54
19
|
address
|
|
@@ -75,24 +40,24 @@ function verifyContextAlias(aliasAddress, parentAddress, context) {
|
|
|
75
40
|
}
|
|
76
41
|
}
|
|
77
42
|
function deriveAnonymousAlias(context, ringLocation) {
|
|
78
|
-
|
|
43
|
+
log.debug("Deriving anonymous alias", { context, ringLocation });
|
|
79
44
|
throw new Error(
|
|
80
45
|
"deriveAnonymousAlias() is not yet implemented. This requires container mode with Ring VRF support."
|
|
81
46
|
);
|
|
82
47
|
}
|
|
83
48
|
async function createRingProof(message, ringLocation) {
|
|
84
|
-
|
|
49
|
+
log.debug("Creating ring proof", { ringLocation });
|
|
85
50
|
throw new Error(
|
|
86
51
|
"createRingProof() is not yet implemented. This requires container mode with Ring VRF support."
|
|
87
52
|
);
|
|
88
53
|
}
|
|
89
54
|
async function verifyRingProof(message, proof, alias) {
|
|
90
|
-
|
|
55
|
+
log.debug("Verifying ring proof");
|
|
91
56
|
throw new Error(
|
|
92
57
|
"verifyRingProof() is not yet implemented. This requires container mode with Ring VRF support."
|
|
93
58
|
);
|
|
94
59
|
}
|
|
95
60
|
|
|
96
|
-
export { createRingProof, deriveAnonymousAlias, deriveContextAlias,
|
|
61
|
+
export { createRingProof, deriveAnonymousAlias, deriveContextAlias, verifyContextAlias, verifyRingProof };
|
|
97
62
|
//# sourceMappingURL=index.js.map
|
|
98
63
|
//# sourceMappingURL=index.js.map
|