@parity/product-sdk 0.21.0 → 0.23.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.
Files changed (44) hide show
  1. package/dist/address/index.d.ts +1 -0
  2. package/dist/chunk-BRZNHTLQ.js +89 -0
  3. package/dist/chunk-BRZNHTLQ.js.map +1 -0
  4. package/dist/{chunk-6BI66XUJ.js → chunk-DHRCWMY5.js} +9 -10
  5. package/dist/chunk-DHRCWMY5.js.map +1 -0
  6. package/dist/core/index.d.ts +2 -2
  7. package/dist/core/index.js +2 -2
  8. package/dist/dotns-bswWAmR2.d.ts +136 -0
  9. package/dist/identity/index.d.ts +495 -49
  10. package/dist/identity/index.js +796 -46
  11. package/dist/identity/index.js.map +1 -1
  12. package/dist/index.d.ts +3 -3
  13. package/dist/index.js +2 -2
  14. package/dist/individuality/index.d.ts +1 -0
  15. package/dist/individuality/index.js +3 -0
  16. package/dist/individuality/index.js.map +1 -0
  17. package/dist/react/index.d.ts +2 -2
  18. package/dist/react/index.js +2 -2
  19. package/dist/testing/index.d.ts +2 -2
  20. package/dist/{types-CztPAgZT.d.ts → types-B5Zx4RNq.d.ts} +1 -1
  21. package/package.json +17 -12
  22. package/src/core/createApp.ts +10 -8
  23. package/src/identity/dotns-abis.test.ts +43 -0
  24. package/src/identity/dotns-abis.ts +309 -0
  25. package/src/identity/dotns-addresses.test.ts +536 -0
  26. package/src/identity/dotns-addresses.ts +320 -0
  27. package/src/identity/dotns-errors.ts +36 -0
  28. package/src/identity/dotns-namehash.test.ts +155 -0
  29. package/src/identity/dotns-namehash.ts +149 -0
  30. package/src/identity/dotns-owner.test.ts +92 -0
  31. package/src/identity/dotns-registry.test.ts +1309 -0
  32. package/src/identity/dotns-registry.ts +868 -0
  33. package/src/identity/dotns.test.ts +128 -0
  34. package/src/identity/dotns.ts +91 -78
  35. package/src/identity/index.test.ts +43 -0
  36. package/src/identity/index.ts +42 -16
  37. package/src/identity/types.ts +29 -38
  38. package/src/individuality/contract.test.ts +326 -0
  39. package/src/individuality/index.ts +8 -0
  40. package/dist/chunk-6BI66XUJ.js.map +0 -1
  41. package/dist/chunk-BIKT6X54.js +0 -70
  42. package/dist/chunk-BIKT6X54.js.map +0 -1
  43. package/dist/dotns-hLSvmo6u.d.ts +0 -178
  44. package/src/identity/product-account.ts +0 -164
@@ -1,164 +0,0 @@
1
- // Copyright 2026 Parity Technologies (UK) Ltd.
2
- // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * Context alias derivation
5
- *
6
- * Derives a deterministic, context-bound alias from a parent account using blake2b-256.
7
- *
8
- * NOTE: this is NOT the canonical sr25519 product-account derivation used by
9
- * mobile, desktop, and dotli hosts. For that, use
10
- * `@parity/product-sdk-keys::deriveProductAccountPublicKey`.
11
- */
12
-
13
- import { createLogger } from "@parity/product-sdk-logger";
14
- import { blake2b256 } from "@parity/product-sdk-crypto";
15
- import { ss58Encode, ss58Decode, deriveH160 } from "@parity/product-sdk-address";
16
- import type { ContextAliasInfo, AnonymousAliasInfo, RingLocation } from "./types.js";
17
-
18
- const log = createLogger("identity");
19
-
20
- /**
21
- * Derive a context-bound alias from a parent account.
22
- *
23
- * The alias is deterministically derived using:
24
- * aliasPublicKey = blake2b256(parentPublicKey || context)
25
- *
26
- * @param parentAddress - Parent account SS58 address
27
- * @param context - Context string for derivation (e.g. an app id or scope label)
28
- * @param ss58Prefix - SS58 prefix (default: 42)
29
- * @returns Context alias info
30
- *
31
- * @example
32
- * ```ts
33
- * const alias = deriveContextAlias(
34
- * '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY',
35
- * 'voting-round-1'
36
- * );
37
- * console.log('Alias address:', alias.address);
38
- * ```
39
- */
40
- export function deriveContextAlias(
41
- parentAddress: string,
42
- context: string,
43
- ss58Prefix = 42,
44
- ): ContextAliasInfo {
45
- const { publicKey: parentPublicKey } = ss58Decode(parentAddress);
46
-
47
- // Derive alias public key: blake2b-256(parentPublicKey || context)
48
- const contextBytes = new TextEncoder().encode(context);
49
- const combined = new Uint8Array(parentPublicKey.length + contextBytes.length);
50
- combined.set(parentPublicKey, 0);
51
- combined.set(contextBytes, parentPublicKey.length);
52
-
53
- const aliasPublicKey = blake2b256(combined);
54
- const address = ss58Encode(aliasPublicKey, ss58Prefix);
55
- const h160Address = deriveH160(aliasPublicKey);
56
-
57
- log.debug("Derived context alias", {
58
- parentAddress,
59
- context,
60
- address,
61
- });
62
-
63
- return {
64
- address,
65
- h160Address,
66
- parentAddress,
67
- context,
68
- };
69
- }
70
-
71
- /**
72
- * Verify that a context alias was derived from a parent account.
73
- *
74
- * @param aliasAddress - Context alias SS58 address
75
- * @param parentAddress - Claimed parent address
76
- * @param context - Context string used for derivation
77
- * @returns True if derivation is valid
78
- */
79
- export function verifyContextAlias(
80
- aliasAddress: string,
81
- parentAddress: string,
82
- context: string,
83
- ): boolean {
84
- try {
85
- const derived = deriveContextAlias(parentAddress, context);
86
- const { publicKey: aliasKey } = ss58Decode(aliasAddress);
87
- const { publicKey: derivedKey } = ss58Decode(derived.address);
88
-
89
- // Compare public keys
90
- if (aliasKey.length !== derivedKey.length) return false;
91
- for (let i = 0; i < aliasKey.length; i++) {
92
- if (aliasKey[i] !== derivedKey[i]) return false;
93
- }
94
- return true;
95
- } catch {
96
- return false;
97
- }
98
- }
99
-
100
- /**
101
- * Derive an anonymous alias using Ring VRF
102
- *
103
- * This creates a context-specific alias that cannot be linked
104
- * back to the original identity without the ring proof.
105
- *
106
- * @param context - Context for alias derivation (e.g., "voting-round-1")
107
- * @param ringLocation - Ring location for proof generation
108
- * @returns Anonymous alias info
109
- */
110
- export function deriveAnonymousAlias(
111
- context: string,
112
- ringLocation: RingLocation,
113
- ): AnonymousAliasInfo {
114
- log.debug("Deriving anonymous alias", { context, ringLocation });
115
-
116
- // TODO: Implement Ring VRF alias derivation
117
- // This requires the Ring VRF implementation from TruAPI
118
- throw new Error(
119
- "deriveAnonymousAlias() is not yet implemented. " +
120
- "This requires container mode with Ring VRF support.",
121
- );
122
- }
123
-
124
- /**
125
- * Create a Ring VRF proof for a message
126
- *
127
- * @param message - Message to prove
128
- * @param ringLocation - Ring location
129
- * @returns Proof bytes
130
- */
131
- export async function createRingProof(
132
- message: Uint8Array,
133
- ringLocation: RingLocation,
134
- ): Promise<Uint8Array> {
135
- log.debug("Creating ring proof", { ringLocation });
136
-
137
- // TODO: Implement Ring VRF proof creation via TruAPI
138
- throw new Error(
139
- "createRingProof() is not yet implemented. " +
140
- "This requires container mode with Ring VRF support.",
141
- );
142
- }
143
-
144
- /**
145
- * Verify a Ring VRF proof
146
- *
147
- * @param message - Original message
148
- * @param proof - Proof bytes
149
- * @param alias - Expected alias
150
- * @returns True if proof is valid
151
- */
152
- export async function verifyRingProof(
153
- message: Uint8Array,
154
- proof: Uint8Array,
155
- alias: string,
156
- ): Promise<boolean> {
157
- log.debug("Verifying ring proof");
158
-
159
- // TODO: Implement Ring VRF proof verification
160
- throw new Error(
161
- "verifyRingProof() is not yet implemented. " +
162
- "This requires container mode with Ring VRF support.",
163
- );
164
- }