@hsuite/native-connect-types 1.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/emoji-avatar.d.ts +37 -0
  2. package/dist/emoji-avatar.d.ts.map +1 -0
  3. package/dist/emoji-avatar.js +111 -0
  4. package/dist/emoji-avatar.js.map +1 -0
  5. package/dist/index.d.ts +3 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +15 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/ipfs-cdn.d.ts +82 -0
  10. package/dist/ipfs-cdn.d.ts.map +1 -0
  11. package/dist/ipfs-cdn.js +138 -0
  12. package/dist/ipfs-cdn.js.map +1 -0
  13. package/dist/ledger.d.ts +30 -0
  14. package/dist/ledger.d.ts.map +1 -1
  15. package/dist/ledger.js +24 -0
  16. package/dist/ledger.js.map +1 -1
  17. package/dist/messages.d.ts +51 -12
  18. package/dist/messages.d.ts.map +1 -1
  19. package/dist/messages.js +19 -0
  20. package/dist/messages.js.map +1 -1
  21. package/dist/rpc.d.ts +28 -18
  22. package/dist/rpc.d.ts.map +1 -1
  23. package/dist/transaction-approval.d.ts +18 -1
  24. package/dist/transaction-approval.d.ts.map +1 -1
  25. package/dist/vault.d.ts +56 -12
  26. package/dist/vault.d.ts.map +1 -1
  27. package/dist/vault.js +25 -0
  28. package/dist/vault.js.map +1 -1
  29. package/dist/xrpl-endpoints.d.ts +48 -0
  30. package/dist/xrpl-endpoints.d.ts.map +1 -0
  31. package/dist/xrpl-endpoints.js +54 -0
  32. package/dist/xrpl-endpoints.js.map +1 -0
  33. package/package.json +1 -1
  34. package/src/index.ts +22 -0
  35. package/src/ipfs-cdn.spec.ts +163 -0
  36. package/src/ipfs-cdn.ts +152 -0
  37. package/src/ledger.spec.ts +51 -0
  38. package/src/ledger.ts +25 -0
  39. package/src/messages.ts +35 -0
  40. package/src/transaction-approval.ts +30 -0
  41. package/src/vault.spec.ts +36 -0
  42. package/src/vault.ts +31 -0
  43. package/src/xrpl-endpoints.spec.ts +46 -0
  44. package/src/xrpl-endpoints.ts +56 -0
  45. package/tsconfig.build.tsbuildinfo +1 -0
package/dist/vault.d.ts CHANGED
@@ -120,6 +120,23 @@ export declare const VaultRecoverySchema: z.ZodObject<{
120
120
  * @description Type representing recovery configuration
121
121
  */
122
122
  export type VaultRecovery = z.infer<typeof VaultRecoverySchema>;
123
+ /**
124
+ * @description Canonical key algorithm token for Hedera (and any ledger using
125
+ * raw scalar keys). The same 32-byte scalar is valid under both Ed25519 and
126
+ * ECDSA secp256k1, producing different public keys and signatures, so the
127
+ * algorithm must be carried alongside the key.
128
+ *
129
+ * The codebase also uses 'secp256k1' (export service) and 'ecdsa_secp256k1'
130
+ * (message-sign result); those are mapped at their boundaries. The
131
+ * vault/sign/import surface standardizes on this pair.
132
+ *
133
+ * @security SOC2-CC6.1 - enables fail-safe pre-sign algorithm verification.
134
+ */
135
+ export declare const KeyAlgorithmSchema: z.ZodEnum<["ed25519", "ecdsa"]>;
136
+ /**
137
+ * @description Type representing a key algorithm
138
+ */
139
+ export type KeyAlgorithm = z.infer<typeof KeyAlgorithmSchema>;
123
140
  /**
124
141
  * @description Schema for derived vault key
125
142
  * Moved before VaultRecoveryBundleSchema to avoid forward reference.
@@ -151,6 +168,13 @@ export declare const VaultKeySchema: z.ZodObject<{
151
168
  addressIndex?: number;
152
169
  }>;
153
170
  protection: z.ZodEnum<["none", "passphrase", "hardware", "biometric", "kms"]>;
171
+ /**
172
+ * Cryptographic algorithm of the underlying key. Optional for back-compat:
173
+ * legacy records (written before this field existed) are all Ed25519, since
174
+ * ECDSA import never worked. Read by the signing chokepoints to reconstruct
175
+ * the correct PrivateKey and to assert against the stored public key.
176
+ */
177
+ keyType: z.ZodOptional<z.ZodEnum<["ed25519", "ecdsa"]>>;
154
178
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
155
179
  }, "strip", z.ZodTypeAny, {
156
180
  ledgerId?: string;
@@ -159,6 +183,7 @@ export declare const VaultKeySchema: z.ZodObject<{
159
183
  publicKey?: string;
160
184
  metadata?: Record<string, unknown>;
161
185
  id?: string;
186
+ seedId?: string;
162
187
  derivationPath?: {
163
188
  purpose?: number;
164
189
  coinType?: number;
@@ -166,8 +191,8 @@ export declare const VaultKeySchema: z.ZodObject<{
166
191
  change?: number;
167
192
  addressIndex?: number;
168
193
  };
169
- seedId?: string;
170
194
  protection?: "passphrase" | "none" | "hardware" | "biometric" | "kms";
195
+ keyType?: "ed25519" | "ecdsa";
171
196
  }, {
172
197
  ledgerId?: string;
173
198
  networkId?: string;
@@ -175,6 +200,7 @@ export declare const VaultKeySchema: z.ZodObject<{
175
200
  publicKey?: string;
176
201
  metadata?: Record<string, unknown>;
177
202
  id?: string;
203
+ seedId?: string;
178
204
  derivationPath?: {
179
205
  purpose?: number;
180
206
  coinType?: number;
@@ -182,8 +208,8 @@ export declare const VaultKeySchema: z.ZodObject<{
182
208
  change?: number;
183
209
  addressIndex?: number;
184
210
  };
185
- seedId?: string;
186
211
  protection?: "passphrase" | "none" | "hardware" | "biometric" | "kms";
212
+ keyType?: "ed25519" | "ecdsa";
187
213
  }>;
188
214
  /**
189
215
  * @description Type representing vault key
@@ -263,6 +289,13 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
263
289
  addressIndex?: number;
264
290
  }>;
265
291
  protection: z.ZodEnum<["none", "passphrase", "hardware", "biometric", "kms"]>;
292
+ /**
293
+ * Cryptographic algorithm of the underlying key. Optional for back-compat:
294
+ * legacy records (written before this field existed) are all Ed25519, since
295
+ * ECDSA import never worked. Read by the signing chokepoints to reconstruct
296
+ * the correct PrivateKey and to assert against the stored public key.
297
+ */
298
+ keyType: z.ZodOptional<z.ZodEnum<["ed25519", "ecdsa"]>>;
266
299
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
267
300
  }, "strip", z.ZodTypeAny, {
268
301
  ledgerId?: string;
@@ -271,6 +304,7 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
271
304
  publicKey?: string;
272
305
  metadata?: Record<string, unknown>;
273
306
  id?: string;
307
+ seedId?: string;
274
308
  derivationPath?: {
275
309
  purpose?: number;
276
310
  coinType?: number;
@@ -278,8 +312,8 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
278
312
  change?: number;
279
313
  addressIndex?: number;
280
314
  };
281
- seedId?: string;
282
315
  protection?: "passphrase" | "none" | "hardware" | "biometric" | "kms";
316
+ keyType?: "ed25519" | "ecdsa";
283
317
  }, {
284
318
  ledgerId?: string;
285
319
  networkId?: string;
@@ -287,6 +321,7 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
287
321
  publicKey?: string;
288
322
  metadata?: Record<string, unknown>;
289
323
  id?: string;
324
+ seedId?: string;
290
325
  derivationPath?: {
291
326
  purpose?: number;
292
327
  coinType?: number;
@@ -294,8 +329,8 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
294
329
  change?: number;
295
330
  addressIndex?: number;
296
331
  };
297
- seedId?: string;
298
332
  protection?: "passphrase" | "none" | "hardware" | "biometric" | "kms";
333
+ keyType?: "ed25519" | "ecdsa";
299
334
  }>, "many">>;
300
335
  /** Address book contacts to restore with the seed */
301
336
  addressBook: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
@@ -339,6 +374,7 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
339
374
  publicKey?: string;
340
375
  metadata?: Record<string, unknown>;
341
376
  id?: string;
377
+ seedId?: string;
342
378
  derivationPath?: {
343
379
  purpose?: number;
344
380
  coinType?: number;
@@ -346,15 +382,15 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
346
382
  change?: number;
347
383
  addressIndex?: number;
348
384
  };
349
- seedId?: string;
350
385
  protection?: "passphrase" | "none" | "hardware" | "biometric" | "kms";
386
+ keyType?: "ed25519" | "ecdsa";
351
387
  }[];
352
388
  metadata?: Record<string, unknown>;
353
389
  id?: string;
354
390
  createdAt?: number;
355
- payload?: string;
356
- algorithm?: "AES-GCM";
357
391
  seedId?: string;
392
+ algorithm?: "AES-GCM";
393
+ payload?: string;
358
394
  key?: string;
359
395
  checksum?: string;
360
396
  addressBook?: unknown[];
@@ -378,6 +414,7 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
378
414
  publicKey?: string;
379
415
  metadata?: Record<string, unknown>;
380
416
  id?: string;
417
+ seedId?: string;
381
418
  derivationPath?: {
382
419
  purpose?: number;
383
420
  coinType?: number;
@@ -385,15 +422,15 @@ export declare const VaultRecoveryBundleSchema: z.ZodObject<{
385
422
  change?: number;
386
423
  addressIndex?: number;
387
424
  };
388
- seedId?: string;
389
425
  protection?: "passphrase" | "none" | "hardware" | "biometric" | "kms";
426
+ keyType?: "ed25519" | "ecdsa";
390
427
  }[];
391
428
  metadata?: Record<string, unknown>;
392
429
  id?: string;
393
430
  createdAt?: number;
394
- payload?: string;
395
- algorithm?: "AES-GCM";
396
431
  seedId?: string;
432
+ algorithm?: "AES-GCM";
433
+ payload?: string;
397
434
  key?: string;
398
435
  checksum?: string;
399
436
  addressBook?: unknown[];
@@ -447,6 +484,11 @@ export declare const VaultSeedSchema: z.ZodObject<{
447
484
  lastUnlockedAt?: number;
448
485
  kmsKeyId?: string;
449
486
  }>;
487
+ /**
488
+ * Cryptographic algorithm of the stored seed/key when it is a raw scalar
489
+ * (imported Hedera key). Optional for back-compat. See {@link KeyAlgorithm}.
490
+ */
491
+ keyType: z.ZodOptional<z.ZodEnum<["ed25519", "ecdsa"]>>;
450
492
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
451
493
  recovery: z.ZodOptional<z.ZodObject<{
452
494
  hint: z.ZodOptional<z.ZodString>;
@@ -489,6 +531,7 @@ export declare const VaultSeedSchema: z.ZodObject<{
489
531
  lastUnlockedAt?: number;
490
532
  kmsKeyId?: string;
491
533
  };
534
+ keyType?: "ed25519" | "ecdsa";
492
535
  encryptedSeed?: string;
493
536
  encryptedMnemonic?: string;
494
537
  kdfSalt?: string;
@@ -514,6 +557,7 @@ export declare const VaultSeedSchema: z.ZodObject<{
514
557
  lastUnlockedAt?: number;
515
558
  kmsKeyId?: string;
516
559
  };
560
+ keyType?: "ed25519" | "ecdsa";
517
561
  encryptedSeed?: string;
518
562
  encryptedMnemonic?: string;
519
563
  kdfSalt?: string;
@@ -603,7 +647,7 @@ export declare const VaultConfigSchema: z.ZodObject<{
603
647
  allowBiometric?: boolean;
604
648
  allowRecoveryBundles?: boolean;
605
649
  allowKms?: boolean;
606
- credentialMode?: "password" | "pin";
650
+ credentialMode?: "pin" | "password";
607
651
  encryptionSalt?: string;
608
652
  kdfAlgorithm?: "argon2id" | "pbkdf2";
609
653
  authAttempts?: number;
@@ -638,7 +682,7 @@ export declare const VaultConfigSchema: z.ZodObject<{
638
682
  allowBiometric?: boolean;
639
683
  allowRecoveryBundles?: boolean;
640
684
  allowKms?: boolean;
641
- credentialMode?: "password" | "pin";
685
+ credentialMode?: "pin" | "password";
642
686
  encryptionSalt?: string;
643
687
  kdfAlgorithm?: "argon2id" | "pbkdf2";
644
688
  authAttempts?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,eAAO,MAAM,yBAAyB,mEAMpC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;EAOhC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,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),
69
69
  note: z.string().optional(),
70
70
  });
71
+ /**
72
+ * @description Canonical key algorithm token for Hedera (and any ledger using
73
+ * raw scalar keys). The same 32-byte scalar is valid under both Ed25519 and
74
+ * ECDSA secp256k1, producing different public keys and signatures, so the
75
+ * algorithm must be carried alongside the key.
76
+ *
77
+ * The codebase also uses 'secp256k1' (export service) and 'ecdsa_secp256k1'
78
+ * (message-sign result); those are mapped at their boundaries. The
79
+ * vault/sign/import surface standardizes on this pair.
80
+ *
81
+ * @security SOC2-CC6.1 - enables fail-safe pre-sign algorithm verification.
82
+ */
83
+ export const KeyAlgorithmSchema = z.enum(['ed25519', 'ecdsa']);
71
84
  /**
72
85
  * @description Schema for derived vault key
73
86
  * Moved before VaultRecoveryBundleSchema to avoid forward reference.
@@ -81,6 +94,13 @@ export const VaultKeySchema = z.object({
81
94
  publicKey: z.string(),
82
95
  derivationPath: DerivationPathSchema,
83
96
  protection: VaultProtectionModeSchema,
97
+ /**
98
+ * Cryptographic algorithm of the underlying key. Optional for back-compat:
99
+ * legacy records (written before this field existed) are all Ed25519, since
100
+ * ECDSA import never worked. Read by the signing chokepoints to reconstruct
101
+ * the correct PrivateKey and to assert against the stored public key.
102
+ */
103
+ keyType: KeyAlgorithmSchema.optional(),
84
104
  metadata: z.record(z.unknown()).optional(),
85
105
  });
86
106
  /**
@@ -134,6 +154,11 @@ export const VaultSeedSchema = z.object({
134
154
  kdfSalt: z.string(),
135
155
  derivationScheme: z.string(),
136
156
  protection: VaultProtectionSchema,
157
+ /**
158
+ * Cryptographic algorithm of the stored seed/key when it is a raw scalar
159
+ * (imported Hedera key). Optional for back-compat. See {@link KeyAlgorithm}.
160
+ */
161
+ keyType: KeyAlgorithmSchema.optional(),
137
162
  metadata: z.record(z.unknown()).optional(),
138
163
  recovery: VaultRecoverySchema.optional(),
139
164
  });
package/dist/vault.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AA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,qBAAqB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9D,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACzC,uBAAuB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACnD,sBAAsB,EAAE,0BAA0B,CAAC,QAAQ,EAAE;IAC7D,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACtC,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5C,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;CACpD,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * HSuite Native Connect
3
+ * Copyright 2024-2025 HSuite (https://hsuite.finance)
4
+ *
5
+ * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
6
+ *
7
+ * This file is part of HSuite Native Connect. For commercial licensing,
8
+ * visit https://hsuite.finance/licensing
9
+ */
10
+ /**
11
+ * @file Canonical, ordered XRPL endpoint lists per network.
12
+ *
13
+ * @description
14
+ * Single source of truth for the rippled endpoints the wallet talks to. The
15
+ * first entry in each list is the primary node; the rest are failover targets
16
+ * tried in order when the primary cannot be reached. Mainnet carries multiple
17
+ * endpoints so a single unreachable node (network/VPN/proxy blocking the WSS
18
+ * handshake, or a public-cluster IP rate-limit) does not take down the whole
19
+ * XRPL read path. Testnet/devnet stay single-entry.
20
+ *
21
+ * Cross-package consumers — the `ledger-xrpl` adapter (WS clients,
22
+ * account-existence checks, the ledger manifest) and the `native-wallet-sdk`
23
+ * (token discovery, account import validation) — MUST import these from
24
+ * `@hsuite/native-connect-types` rather than re-declaring the URLs, so the list
25
+ * stays in lock-step everywhere. `ledger-xrpl` re-exports them through its own
26
+ * `endpoints` module for local ergonomics.
27
+ *
28
+ * Any endpoint added here for mainnet must ALSO be whitelisted in the wallet
29
+ * app's CSP surfaces (`index.html` meta + `_headers`) or the browser blocks the
30
+ * connection — `xrplcluster.com`, `s1.ripple.com`, and `s2.ripple.com` are
31
+ * already present in both.
32
+ */
33
+ /**
34
+ * Ordered XRPL endpoints per network; primary first, the rest are failover.
35
+ *
36
+ * @constant
37
+ */
38
+ export declare const XRPL_ENDPOINTS: Record<string, readonly string[]>;
39
+ /**
40
+ * Resolve the ordered endpoint list for a network id.
41
+ *
42
+ * @param networkId - Network identifier (e.g. `xrpl:mainnet`).
43
+ * @returns The ordered endpoint list (primary first), or an empty list when the
44
+ * network is unknown. Callers treat an empty list as "no endpoints
45
+ * configured" and surface a retryable error rather than connecting.
46
+ */
47
+ export declare function endpointsFor(networkId: string): readonly string[];
48
+ //# sourceMappingURL=xrpl-endpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrpl-endpoints.d.ts","sourceRoot":"","sources":["../src/xrpl-endpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAI5D,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAEjE"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * HSuite Native Connect
3
+ * Copyright 2024-2025 HSuite (https://hsuite.finance)
4
+ *
5
+ * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
6
+ *
7
+ * This file is part of HSuite Native Connect. For commercial licensing,
8
+ * visit https://hsuite.finance/licensing
9
+ */
10
+ /**
11
+ * @file Canonical, ordered XRPL endpoint lists per network.
12
+ *
13
+ * @description
14
+ * Single source of truth for the rippled endpoints the wallet talks to. The
15
+ * first entry in each list is the primary node; the rest are failover targets
16
+ * tried in order when the primary cannot be reached. Mainnet carries multiple
17
+ * endpoints so a single unreachable node (network/VPN/proxy blocking the WSS
18
+ * handshake, or a public-cluster IP rate-limit) does not take down the whole
19
+ * XRPL read path. Testnet/devnet stay single-entry.
20
+ *
21
+ * Cross-package consumers — the `ledger-xrpl` adapter (WS clients,
22
+ * account-existence checks, the ledger manifest) and the `native-wallet-sdk`
23
+ * (token discovery, account import validation) — MUST import these from
24
+ * `@hsuite/native-connect-types` rather than re-declaring the URLs, so the list
25
+ * stays in lock-step everywhere. `ledger-xrpl` re-exports them through its own
26
+ * `endpoints` module for local ergonomics.
27
+ *
28
+ * Any endpoint added here for mainnet must ALSO be whitelisted in the wallet
29
+ * app's CSP surfaces (`index.html` meta + `_headers`) or the browser blocks the
30
+ * connection — `xrplcluster.com`, `s1.ripple.com`, and `s2.ripple.com` are
31
+ * already present in both.
32
+ */
33
+ /**
34
+ * Ordered XRPL endpoints per network; primary first, the rest are failover.
35
+ *
36
+ * @constant
37
+ */
38
+ export const XRPL_ENDPOINTS = {
39
+ 'xrpl:mainnet': ['wss://xrplcluster.com', 'wss://s1.ripple.com', 'wss://s2.ripple.com'],
40
+ 'xrpl:testnet': ['wss://s.altnet.rippletest.net:51233'],
41
+ 'xrpl:devnet': ['wss://s.devnet.rippletest.net:51233'],
42
+ };
43
+ /**
44
+ * Resolve the ordered endpoint list for a network id.
45
+ *
46
+ * @param networkId - Network identifier (e.g. `xrpl:mainnet`).
47
+ * @returns The ordered endpoint list (primary first), or an empty list when the
48
+ * network is unknown. Callers treat an empty list as "no endpoints
49
+ * configured" and surface a retryable error rather than connecting.
50
+ */
51
+ export function endpointsFor(networkId) {
52
+ return XRPL_ENDPOINTS[networkId] ?? [];
53
+ }
54
+ //# sourceMappingURL=xrpl-endpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xrpl-endpoints.js","sourceRoot":"","sources":["../src/xrpl-endpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAsC;IAC/D,cAAc,EAAE,CAAC,uBAAuB,EAAE,qBAAqB,EAAE,qBAAqB,CAAC;IACvF,cAAc,EAAE,CAAC,qCAAqC,CAAC;IACvD,aAAa,EAAE,CAAC,qCAAqC,CAAC;CACvD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,OAAO,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AACzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsuite/native-connect-types",
3
- "version": "1.0.0",
3
+ "version": "2.1.1",
4
4
  "license": "PolyForm-Noncommercial-1.0.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -28,6 +28,7 @@
28
28
  // .d.ts as JS and choked on the mixed value+type re-export).
29
29
  export {
30
30
  LedgerIdSchema,
31
+ LedgerIds,
31
32
  NetworkIdSchema,
32
33
  LedgerAccountSchema,
33
34
  LedgerPluginManifestSchema,
@@ -195,3 +196,24 @@ export {
195
196
  HEDERA_FEE_COLLECTOR_ACCOUNTS,
196
197
  HEDERA_SYSTEM_ACCOUNTS,
197
198
  } from './hedera-system-accounts.js';
199
+
200
+ // === XRPL Endpoints ===
201
+ // Canonical, ordered rippled endpoint lists per network (primary first, rest
202
+ // are failover). Imported by the ledger-xrpl adapter (WS clients, account
203
+ // checks, manifest) and the native-wallet-sdk (token discovery, import
204
+ // validation) so every XRPL read path fails over across the same nodes and the
205
+ // endpoint set never drifts across packages.
206
+ export { XRPL_ENDPOINTS, endpointsFor } from './xrpl-endpoints.js';
207
+
208
+ // === IPFS CDN primitives ===
209
+ // Single source of truth for the HSuite Bunny CDN host/base URL and the
210
+ // per-surface image-optimizer helper. Imported by the SDK gateway layer
211
+ // (the `convertIpfsUrl` default), the wallet app's image getters, and the UI
212
+ // render surfaces so the CDN domain and the optimizer query format never
213
+ // drift across packages.
214
+ export {
215
+ HSUITE_IPFS_CDN_BASE,
216
+ HSUITE_IPFS_CDN_HOST,
217
+ NFT_IMAGE_WIDTH,
218
+ withImageOptimizer,
219
+ } from './ipfs-cdn.js';
@@ -0,0 +1,163 @@
1
+ /**
2
+ * HSuite Native Connect
3
+ * Copyright 2024-2025 HSuite (https://hsuite.finance)
4
+ *
5
+ * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
6
+ *
7
+ * This file is part of HSuite Native Connect. For commercial licensing,
8
+ * visit https://hsuite.finance/licensing
9
+ */
10
+
11
+ /**
12
+ * @fileoverview Tests for the shared HSuite IPFS CDN primitives.
13
+ *
14
+ * `withImageOptimizer` is the single source of truth for appending the Bunny
15
+ * image-optimizer query (`?optimizer=image&width=N`) to NFT image URLs. It is
16
+ * imported by the SDK gateway layer, the wallet app getters, and the UI render
17
+ * surfaces, so its contract must be airtight: it MUST only rewrite raster
18
+ * images served from the HSuite CDN host, MUST never touch SVG/GIF/video or
19
+ * third-party hosts (Arweave, DaVinci, public gateways), and MUST be
20
+ * idempotent so re-wrapping an already-optimized URL is a no-op.
21
+ */
22
+
23
+ import { describe, it, expect } from 'vitest';
24
+ import {
25
+ HSUITE_IPFS_CDN_BASE,
26
+ HSUITE_IPFS_CDN_HOST,
27
+ NFT_IMAGE_WIDTH,
28
+ withImageOptimizer,
29
+ } from './ipfs-cdn.js';
30
+
31
+ const CID = 'bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi';
32
+
33
+ describe('CDN constants', () => {
34
+ it('exposes the HSuite Bunny CDN host', () => {
35
+ expect(HSUITE_IPFS_CDN_HOST).toBe('hsuite-wallet.b-cdn.net');
36
+ });
37
+
38
+ it('exposes the /ipfs/ base URL on that host', () => {
39
+ expect(HSUITE_IPFS_CDN_BASE).toBe('https://hsuite-wallet.b-cdn.net/ipfs/');
40
+ });
41
+
42
+ it('keeps base and host in sync (no drift)', () => {
43
+ expect(new URL(HSUITE_IPFS_CDN_BASE).hostname).toBe(HSUITE_IPFS_CDN_HOST);
44
+ });
45
+
46
+ it('defines the three surface width tiers', () => {
47
+ expect(NFT_IMAGE_WIDTH.THUMB).toBe(200);
48
+ expect(NFT_IMAGE_WIDTH.GRID).toBe(350);
49
+ expect(NFT_IMAGE_WIDTH.DETAIL).toBe(800);
50
+ });
51
+ });
52
+
53
+ describe('withImageOptimizer — CDN-host raster images', () => {
54
+ it('appends the optimizer query at the default (GRID) width', () => {
55
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/art.png`;
56
+ expect(withImageOptimizer(input)).toBe(`${input}?optimizer=image&width=350`);
57
+ });
58
+
59
+ it('honors a caller-supplied width', () => {
60
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/art.png`;
61
+ expect(withImageOptimizer(input, NFT_IMAGE_WIDTH.DETAIL)).toBe(
62
+ `${input}?optimizer=image&width=800`,
63
+ );
64
+ });
65
+
66
+ it('optimizes every supported raster extension', () => {
67
+ for (const ext of ['png', 'jpg', 'jpeg', 'webp', 'avif', 'bmp']) {
68
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/art.${ext}`;
69
+ expect(withImageOptimizer(input, 200)).toBe(`${input}?optimizer=image&width=200`);
70
+ }
71
+ });
72
+
73
+ it('treats extensions case-insensitively', () => {
74
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/ART.PNG`;
75
+ expect(withImageOptimizer(input, 200)).toBe(`${input}?optimizer=image&width=200`);
76
+ });
77
+
78
+ it('preserves a path-bearing CID and joins with & when a query already exists', () => {
79
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/25.png?v=2`;
80
+ expect(withImageOptimizer(input, 350)).toBe(`${input}&optimizer=image&width=350`);
81
+ });
82
+ });
83
+
84
+ describe('withImageOptimizer — must NOT rewrite', () => {
85
+ it('leaves SVG untouched (optimizer would rasterize vectors)', () => {
86
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/logo.svg`;
87
+ expect(withImageOptimizer(input)).toBe(input);
88
+ });
89
+
90
+ it('leaves GIF untouched (optimizer would flatten animation)', () => {
91
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/loop.gif`;
92
+ expect(withImageOptimizer(input)).toBe(input);
93
+ });
94
+
95
+ it('leaves video/3D/audio extensions untouched', () => {
96
+ for (const ext of ['mp4', 'webm', 'glb', 'mp3']) {
97
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/media.${ext}`;
98
+ expect(withImageOptimizer(input)).toBe(input);
99
+ }
100
+ });
101
+
102
+ it('leaves extensionless CDN URLs untouched (cannot prove raster)', () => {
103
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}`;
104
+ expect(withImageOptimizer(input)).toBe(input);
105
+ });
106
+
107
+ it('leaves Arweave images untouched (different host)', () => {
108
+ const input = 'https://arweave.net/abc123/art.png';
109
+ expect(withImageOptimizer(input)).toBe(input);
110
+ });
111
+
112
+ it('leaves DaVinciGraph token images untouched (different host)', () => {
113
+ const input = 'https://s1.pics.davincigraph.io/0.0.123/icon.png';
114
+ expect(withImageOptimizer(input)).toBe(input);
115
+ });
116
+
117
+ it('leaves public IPFS gateway URLs untouched (different host)', () => {
118
+ const input = 'https://ipfs.io/ipfs/QmHash/art.png';
119
+ expect(withImageOptimizer(input)).toBe(input);
120
+ });
121
+
122
+ it('does not match a look-alike host that merely contains the CDN host', () => {
123
+ const input = 'https://hsuite-wallet.b-cdn.net.evil.example/art.png';
124
+ expect(withImageOptimizer(input)).toBe(input);
125
+ });
126
+
127
+ it('does not match the CDN host on a non-standard port (host comparison includes port)', () => {
128
+ const input = `https://${HSUITE_IPFS_CDN_HOST}:9999/ipfs/${CID}/art.png`;
129
+ expect(withImageOptimizer(input)).toBe(input);
130
+ });
131
+ });
132
+
133
+ describe('withImageOptimizer — idempotency & invalid input', () => {
134
+ it('does not double-append when already optimized', () => {
135
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/art.png?optimizer=image&width=350`;
136
+ expect(withImageOptimizer(input, 800)).toBe(input);
137
+ });
138
+
139
+ it('returns undefined unchanged', () => {
140
+ expect(withImageOptimizer(undefined)).toBeUndefined();
141
+ });
142
+
143
+ it('returns an empty string unchanged', () => {
144
+ expect(withImageOptimizer('')).toBe('');
145
+ });
146
+
147
+ it('returns malformed / relative URLs unchanged', () => {
148
+ expect(withImageOptimizer('not a url')).toBe('not a url');
149
+ expect(withImageOptimizer('/ipfs/Qm/art.png')).toBe('/ipfs/Qm/art.png');
150
+ });
151
+
152
+ it('falls back to the GRID width for non-positive / non-finite widths', () => {
153
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/art.png`;
154
+ expect(withImageOptimizer(input, 0)).toBe(`${input}?optimizer=image&width=350`);
155
+ expect(withImageOptimizer(input, Number.NaN)).toBe(`${input}?optimizer=image&width=350`);
156
+ expect(withImageOptimizer(input, -100)).toBe(`${input}?optimizer=image&width=350`);
157
+ });
158
+
159
+ it('rounds fractional widths to an integer', () => {
160
+ const input = `${HSUITE_IPFS_CDN_BASE}${CID}/art.png`;
161
+ expect(withImageOptimizer(input, 199.6)).toBe(`${input}?optimizer=image&width=200`);
162
+ });
163
+ });