hd-wallet-ui 2.0.20 → 2.0.26

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 (39) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +101 -123
  3. package/data/common-passwords-sdn-v1.source.json +12 -0
  4. package/data/common-passwords-sdn-v1.txt +10000 -0
  5. package/dist/browser/sdn-wallet-callback.js +1 -0
  6. package/dist/browser/sdn-wallet-public-client.js +1 -0
  7. package/dist/browser/wallet-callback.html +6 -0
  8. package/dist/client/asset-review.d.ts +8 -0
  9. package/dist/client/asset-review.js +1570 -0
  10. package/dist/client/callback.d.ts +13 -0
  11. package/dist/client/callback.js +29 -0
  12. package/dist/client/index.d.ts +11 -0
  13. package/dist/client/index.js +1379 -0
  14. package/dist/client/sdn.d.ts +8 -0
  15. package/dist/client/sdn.js +1542 -0
  16. package/dist/client/style.css +32 -0
  17. package/dist/client/types.d.ts +278 -0
  18. package/dist/compat/index.d.ts +26 -0
  19. package/dist/compat/index.js +62 -0
  20. package/dist/wallet-origin/index.d.ts +21 -0
  21. package/dist/wallet-origin/index.js +4607 -0
  22. package/dist/wallet-origin-host/assets/wallet-origin.3d16729bf9aaca4517cc699bec526c7209be184cdbb0ba0dbf4063d36a091e1d.js +12463 -0
  23. package/dist/wallet-origin-host/assets/wallet-origin.e22071a3643a57055d29f2e6951c1a2f15e77c1b58b0f81bb7f2afed5bcfb0b4.wasm +0 -0
  24. package/dist/wallet-origin-host/assets/wallet-origin.f3273f7ea70bb494cda1fc02264b936f2e9b010dc07df15eed05fa3f7d1356de.css +1 -0
  25. package/dist/wallet-origin-host/index.html +10 -0
  26. package/dist/wallet-origin-host/integrity.json +1 -0
  27. package/package.json +46 -18
  28. package/src/address-derivation.js +0 -514
  29. package/src/app.js +0 -6008
  30. package/src/blockchain-trust.js +0 -752
  31. package/src/clipboard.js +0 -44
  32. package/src/constants.js +0 -66
  33. package/src/hash.js +0 -9
  34. package/src/lib.js +0 -66
  35. package/src/template.js +0 -626
  36. package/src/trust-ui.js +0 -745
  37. package/src/wallet-storage.js +0 -773
  38. package/styles/main.css +0 -6220
  39. package/styles/widget.css +0 -6212
@@ -0,0 +1,32 @@
1
+ .sdn-wallet-control {
2
+ align-items: center;
3
+ display: inline-flex;
4
+ gap: 0.5rem;
5
+ }
6
+
7
+ .sdn-wallet-control__button {
8
+ appearance: none;
9
+ background: #0b1f33;
10
+ border: 1px solid #5ea8ff;
11
+ border-radius: 0.375rem;
12
+ color: #fff;
13
+ cursor: pointer;
14
+ font: inherit;
15
+ min-height: 2.25rem;
16
+ padding: 0.375rem 0.75rem;
17
+ }
18
+
19
+ .sdn-wallet-control__button:disabled {
20
+ cursor: wait;
21
+ opacity: 0.65;
22
+ }
23
+
24
+ .sdn-wallet-control__button:focus-visible {
25
+ outline: 3px solid #f5b942;
26
+ outline-offset: 2px;
27
+ }
28
+
29
+ .sdn-wallet-control__status {
30
+ color: currentColor;
31
+ font-size: 0.875rem;
32
+ }
@@ -0,0 +1,278 @@
1
+ export type WalletRelayOperation =
2
+ | 'sdn.wallet.connect.v1'
3
+ | 'sdn.wallet.account.v1'
4
+ | 'sdn.auth.raw-challenge.v1'
5
+ | 'sdn.auth.jcs-envelope.v2'
6
+ | 'sdn.asset-review.authority-activation.v1'
7
+ | 'sdn.asset-review.decision.v1';
8
+
9
+ export type WalletClientStatus = 'dormant' | 'opening' | 'connected' | 'error';
10
+ export type WalletClientId =
11
+ | 'orbpro-pages-v1'
12
+ | 'sdn-asset-models-pages-v1'
13
+ | 'sdn-asset-review-v1'
14
+ | 'sdn-flatbuffers-pages-v1'
15
+ | 'sdn-flatsql-pages-v1'
16
+ | 'sdn-landing-web-v1'
17
+ | 'sdn-module-sdk-pages-v1'
18
+ | 'sdn-node-console-v1'
19
+ | 'sdn-standards-web-v1'
20
+ | 'spaceaware-web-v1';
21
+ export type WalletClientErrorCode =
22
+ | 'CALLBACK_ERROR'
23
+ | 'CRYPTO_UNAVAILABLE'
24
+ | 'DESTROYED'
25
+ | 'DISCONNECTED'
26
+ | 'EXPIRED'
27
+ | 'INVALID_CLIENT'
28
+ | 'INVALID_REQUEST'
29
+ | 'RELAY_ERROR'
30
+ | 'REPLACED'
31
+ | 'WALLET_NOT_COMPLETED';
32
+ export type SdnIdentityScheme = 'sdn-bip32-slip10-purpose-v1';
33
+ export type SdnSeedProfile = 'password-scrypt-v2';
34
+ export type Sha256KeyId = `sha256:${string}`;
35
+
36
+ export interface WalletKeyDescriptor {
37
+ readonly purpose:
38
+ | 'asset-review-approval'
39
+ | 'contact-encryption'
40
+ | 'sdn-authentication';
41
+ readonly identityScheme: SdnIdentityScheme;
42
+ readonly seedProfile: SdnSeedProfile;
43
+ readonly signatureProfile: 'ed25519-over-sha256-jcs-v1' | null;
44
+ readonly curve: 'ed25519' | 'x25519';
45
+ readonly derivation: 'slip10';
46
+ readonly path: string;
47
+ readonly encoding: 'raw';
48
+ readonly publicKeyHex: string;
49
+ readonly bip32Fingerprint: null;
50
+ readonly keyId: Sha256KeyId;
51
+ }
52
+
53
+ export interface WalletPublicIdentity {
54
+ readonly schemaVersion: 1;
55
+ readonly identityScheme: SdnIdentityScheme;
56
+ readonly seedProfile: SdnSeedProfile;
57
+ readonly accountIndex: 0;
58
+ readonly accountLabel: null;
59
+ readonly accountXpub: string;
60
+ readonly accountPeerId: string;
61
+ readonly accountFingerprint: string;
62
+ readonly keys: readonly WalletKeyDescriptor[];
63
+ }
64
+
65
+ export interface WalletClientError {
66
+ readonly code: WalletClientErrorCode;
67
+ readonly message: string;
68
+ }
69
+
70
+ export interface CreateWalletClientOptions {
71
+ readonly clientId: WalletClientId;
72
+ }
73
+
74
+ export type WalletClientErrorMessages =
75
+ Readonly<Record<WalletClientErrorCode, string>>;
76
+
77
+ export interface WalletCallbackLocation {
78
+ readonly hash: string;
79
+ readonly pathname: string;
80
+ readonly search: string;
81
+ }
82
+
83
+ export interface WalletCallbackStorage {
84
+ setItem(key: string, value: string): void;
85
+ }
86
+
87
+ export interface WalletCallbackHistory {
88
+ replaceState(data: unknown, unused: string, url: string): void;
89
+ }
90
+
91
+ export type WalletCallbackClose = () => void;
92
+
93
+ export interface WalletClientSnapshot {
94
+ readonly status: WalletClientStatus;
95
+ readonly identity: WalletPublicIdentity | null;
96
+ readonly connectionExpiresAt?: string;
97
+ readonly error?: WalletClientError;
98
+ }
99
+
100
+ export interface SdnLoginV1Request {
101
+ readonly protocolVersion: 1;
102
+ readonly challenge: Uint8Array;
103
+ }
104
+
105
+ export interface SdnLoginV1WireRequest {
106
+ readonly challengeBase64url: string;
107
+ readonly protocolVersion: 1;
108
+ }
109
+
110
+ export interface SdnLoginV2Request {
111
+ readonly protocolVersion: 2;
112
+ readonly audience: 'sdn-login:sdn.spaceaware.io';
113
+ readonly nonce: string;
114
+ readonly issuedAt: string;
115
+ readonly expiresAt: string;
116
+ readonly challenge: Uint8Array;
117
+ }
118
+
119
+ export interface SdnLoginV2WireRequest {
120
+ readonly audience: 'sdn-login:sdn.spaceaware.io';
121
+ readonly challengeBase64url: string;
122
+ readonly expiresAt: string;
123
+ readonly issuedAt: string;
124
+ readonly nonce: string;
125
+ readonly protocolVersion: 2;
126
+ }
127
+
128
+ export interface ReviewedTransform {
129
+ readonly translation: readonly [number, number, number];
130
+ readonly rotation: readonly [number, number, number, number];
131
+ readonly scale: readonly [number, number, number];
132
+ readonly upAxis: 'X_UP' | 'Y_UP' | 'Z_UP';
133
+ readonly sourceUnits: 'm' | 'cm' | 'mm' | 'km';
134
+ readonly metersPerSourceUnit: number;
135
+ }
136
+
137
+ export interface AssetReviewApprovalRequestBase {
138
+ readonly protocolVersion: 1;
139
+ readonly audience: 'asset-review:assets.ipfs.01';
140
+ readonly requestOrigin: 'https://review.spacedatanetwork.org';
141
+ readonly clientId: 'sdn-asset-review-v1';
142
+ readonly challengeId: string;
143
+ readonly nonce: string;
144
+ readonly issuedAt: string;
145
+ readonly expiresAt: string;
146
+ readonly candidateKey: string;
147
+ readonly modelCid: string;
148
+ readonly modelSha256: string;
149
+ readonly modelBytes: number;
150
+ readonly metadataSha256: string;
151
+ readonly previousDecisionHead: string | null;
152
+ }
153
+
154
+ export interface AssetReviewApproveRequest extends AssetReviewApprovalRequestBase {
155
+ readonly decision: 'approve';
156
+ readonly reviewedTransform: ReviewedTransform;
157
+ readonly note: string | null;
158
+ }
159
+
160
+ export interface AssetReviewDisapproveRequest extends AssetReviewApprovalRequestBase {
161
+ readonly decision: 'disapprove';
162
+ readonly reason: string;
163
+ }
164
+
165
+ export type AssetReviewApprovalRequest =
166
+ | AssetReviewApproveRequest
167
+ | AssetReviewDisapproveRequest;
168
+
169
+ export interface AssetReviewAuthorityActivationRequest {
170
+ readonly protocolVersion: 1;
171
+ readonly audience: 'asset-review-authority:assets.ipfs.01';
172
+ readonly requestOrigin: 'https://review.spacedatanetwork.org';
173
+ readonly clientId: 'sdn-asset-review-v1';
174
+ readonly serviceInstance: 'assets.ipfs.01/asset-review-attestation';
175
+ readonly purpose: 'asset-review-authority-activation';
176
+ readonly nonce: string;
177
+ readonly issuedAt: string;
178
+ readonly expiresAt: string;
179
+ readonly publicKeyHex: string;
180
+ readonly keyId: Sha256KeyId;
181
+ readonly identityScheme: SdnIdentityScheme;
182
+ readonly signatureProfile: 'ed25519-over-sha256-jcs-v1';
183
+ }
184
+
185
+ export interface WalletSignatureBase {
186
+ readonly schemaVersion: 1;
187
+ readonly keyId: Sha256KeyId;
188
+ readonly identityScheme:
189
+ | SdnIdentityScheme
190
+ | 'sdn-fast-password-auth-v1-legacy'
191
+ | 'sdn-bip39-auth-v1-legacy';
192
+ readonly algorithm: 'ed25519';
193
+ readonly encoding: 'raw';
194
+ readonly signatureHex: string;
195
+ }
196
+
197
+ export interface RawWalletSignature extends WalletSignatureBase {
198
+ readonly identityScheme:
199
+ | 'sdn-fast-password-auth-v1-legacy'
200
+ | 'sdn-bip39-auth-v1-legacy';
201
+ readonly signatureProfile: 'ed25519-raw-32-v1';
202
+ }
203
+
204
+ export interface CanonicalWalletSignature extends WalletSignatureBase {
205
+ readonly identityScheme: SdnIdentityScheme;
206
+ readonly signatureProfile: 'ed25519-over-sha256-jcs-v1';
207
+ readonly canonicalEnvelope: string;
208
+ readonly signedDigestSha256: string;
209
+ }
210
+
211
+ export interface WalletConnectionWireResult {
212
+ readonly connectionExpiresAt: string | null;
213
+ readonly event: 'connected' | 'disconnected';
214
+ readonly identity: WalletPublicIdentity | null;
215
+ readonly schemaVersion: 1;
216
+ }
217
+
218
+ export interface WalletPublicClient {
219
+ getSnapshot(): WalletClientSnapshot;
220
+ subscribe(listener: (value: WalletClientSnapshot) => void): () => void;
221
+ connect(): Promise<WalletPublicIdentity>;
222
+ openAccount(): Promise<void>;
223
+ disconnect(): Promise<void>;
224
+ destroy(): Promise<void>;
225
+ }
226
+
227
+ export interface SdnWalletClient extends WalletPublicClient {
228
+ requestSdnLoginV1(value: SdnLoginV1Request): Promise<RawWalletSignature>;
229
+ requestSdnLoginV2(value: SdnLoginV2Request): Promise<CanonicalWalletSignature>;
230
+ }
231
+
232
+ export interface AssetReviewWalletClient extends WalletPublicClient {
233
+ requestAuthorityActivation(value: AssetReviewAuthorityActivationRequest):
234
+ Promise<CanonicalWalletSignature>;
235
+ requestAssetReviewApproval(value: AssetReviewApprovalRequest):
236
+ Promise<CanonicalWalletSignature>;
237
+ }
238
+
239
+ export interface RegistryOperationBinding {
240
+ readonly operation: WalletRelayOperation;
241
+ readonly audience:
242
+ | 'sdn-login:sdn.spaceaware.io'
243
+ | 'asset-review-authority:assets.ipfs.01'
244
+ | 'asset-review:assets.ipfs.01'
245
+ | null;
246
+ readonly maxLifetimeSeconds: 300;
247
+ readonly registryRow:
248
+ | 'sdn-node-console-v2'
249
+ | 'asset-review-authority-activation-v1'
250
+ | 'asset-review-decision-v1'
251
+ | null;
252
+ readonly serviceInstance: 'assets.ipfs.01/asset-review-attestation' | null;
253
+ readonly serviceActivationState: 'activated' | 'unactivated' | null;
254
+ }
255
+
256
+ export interface WalletClientRegistryRow {
257
+ readonly clientDisplayName: string;
258
+ readonly clientId: string;
259
+ readonly requestOrigin: `https://${string}`;
260
+ readonly callbackUri: `https://${string}`;
261
+ readonly allowedOperations: readonly WalletRelayOperation[];
262
+ readonly audiences: readonly Exclude<RegistryOperationBinding['audience'], null>[];
263
+ readonly operationBindings: readonly RegistryOperationBinding[];
264
+ }
265
+
266
+ export interface WalletClientRegistryV1 {
267
+ readonly schemaVersion: 1;
268
+ readonly registryReleaseSha256: string;
269
+ readonly clients: readonly WalletClientRegistryRow[];
270
+ }
271
+
272
+ export interface ResolvedRegistryBinding extends RegistryOperationBinding {
273
+ readonly clientDisplayName: string;
274
+ readonly clientId: string;
275
+ readonly requestOrigin: `https://${string}`;
276
+ readonly callbackUri: `https://${string}`;
277
+ readonly registryReleaseSha256: string;
278
+ }
@@ -0,0 +1,26 @@
1
+ export interface WalletUiController {
2
+ readonly openLogin: () => Promise<unknown>;
3
+ readonly openAccount: () => Promise<unknown>;
4
+ readonly logout: () => Promise<unknown>;
5
+ readonly destroy: () => Promise<unknown>;
6
+ }
7
+ export interface CreateWalletUiOptions {
8
+ readonly element?: Node | null;
9
+ readonly document?: Document;
10
+ readonly window?: Window;
11
+ readonly wasm?: object;
12
+ readonly [name: string]: unknown;
13
+ }
14
+ export declare function normalizeTabHash(value: unknown): string | null;
15
+ export declare function normalizeCreateWalletUIArguments(
16
+ rootElementOrOptions?: Node | CreateWalletUiOptions | null,
17
+ options?: CreateWalletUiOptions,
18
+ ): { element: Node | null; options: CreateWalletUiOptions };
19
+ export declare function createWalletUI(
20
+ rootElementOrOptions?: Node | CreateWalletUiOptions | null,
21
+ options?: CreateWalletUiOptions,
22
+ ): Promise<WalletUiController>;
23
+ export declare function init(
24
+ rootElementOrOptions?: Node | CreateWalletUiOptions | null,
25
+ options?: CreateWalletUiOptions,
26
+ ): Promise<WalletUiController>;
@@ -0,0 +1,62 @@
1
+ import initHDWallet from 'hd-wallet-wasm';
2
+ import { createWalletOriginApp } from '../wallet-origin/index.js';
3
+
4
+ export function normalizeTabHash(value) {
5
+ if (typeof value !== 'string') return null;
6
+ const normalized = value.replace(/^#/, '').trim().toLowerCase();
7
+ return /^[a-z][a-z0-9-]{0,63}$/u.test(normalized) ? normalized : null;
8
+ }
9
+
10
+ export function normalizeCreateWalletUIArguments(rootElementOrOptions, options = {}) {
11
+ const NodeConstructor = globalThis.Node;
12
+ const isNode = typeof NodeConstructor === 'function'
13
+ && rootElementOrOptions instanceof NodeConstructor;
14
+ if (isNode || rootElementOrOptions === null || rootElementOrOptions === undefined) {
15
+ return { element: rootElementOrOptions ?? null, options: options ?? {} };
16
+ }
17
+ if (typeof rootElementOrOptions !== 'object' || Array.isArray(rootElementOrOptions)) {
18
+ throw new TypeError('createWalletUI expects an element or an options object');
19
+ }
20
+ const { element = null, ...objectOptions } = rootElementOrOptions;
21
+ if (element !== null
22
+ && !(typeof NodeConstructor === 'function' && element instanceof NodeConstructor)) {
23
+ throw new TypeError('createWalletUI element must be a DOM Node');
24
+ }
25
+ return { element, options: objectOptions };
26
+ }
27
+
28
+ export async function createWalletUI(rootElementOrOptions, options = {}) {
29
+ const normalized = normalizeCreateWalletUIArguments(rootElementOrOptions, options);
30
+ const configuration = normalized.options ?? {};
31
+ const documentObject = configuration.document
32
+ ?? normalized.element?.ownerDocument
33
+ ?? globalThis.document;
34
+ const windowObject = configuration.window
35
+ ?? documentObject?.defaultView
36
+ ?? globalThis.window;
37
+ const wasm = await (configuration.wasm ?? initHDWallet());
38
+ const app = createWalletOriginApp({
39
+ clipboard: configuration.clipboard,
40
+ credentialPrompt: configuration.credentialPrompt,
41
+ document: documentObject,
42
+ fetch: configuration.fetch,
43
+ location: configuration.location,
44
+ mount: normalized.element ?? documentObject?.body,
45
+ registry: configuration.registry,
46
+ relay: configuration.relay,
47
+ rng: configuration.rng,
48
+ wasm,
49
+ window: windowObject,
50
+ });
51
+ const open = () => app.start();
52
+ return Object.freeze({
53
+ openLogin: open,
54
+ openAccount: open,
55
+ logout: () => app.logout(),
56
+ destroy: () => app.stop('destroy'),
57
+ });
58
+ }
59
+
60
+ export async function init(rootElementOrOptions, options = {}) {
61
+ return createWalletUI(rootElementOrOptions, options);
62
+ }
@@ -0,0 +1,21 @@
1
+ export interface WalletOriginApplication {
2
+ readonly controller: object;
3
+ start(): Promise<unknown>;
4
+ stop(reason?: string): Promise<void>;
5
+ logout(): Promise<unknown>;
6
+ }
7
+ export interface WalletOriginConfiguration {
8
+ readonly wasm: object;
9
+ readonly document?: Document;
10
+ readonly window?: Window;
11
+ readonly mount?: Element;
12
+ readonly [name: string]: unknown;
13
+ }
14
+ export declare function createWalletOriginApp(
15
+ configuration: WalletOriginConfiguration,
16
+ ): WalletOriginApplication;
17
+ export declare function mountWalletOriginApp(
18
+ configuration: WalletOriginConfiguration,
19
+ ): Promise<WalletOriginApplication>;
20
+ export declare function transactionIdFromLocation(location: Location): string;
21
+ export declare function createPasswordCredentialPrompt(configuration: object): object;