@hsuite/native-connect-types 1.0.0 โ†’ 2.1.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.
@@ -0,0 +1,37 @@
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
+ * Represents a deterministic emoji avatar generated from a wallet address.
12
+ */
13
+ export interface EmojiAvatar {
14
+ /** The emoji character representing this address */
15
+ emoji: string;
16
+ /** Dark background color (hex) */
17
+ backgroundColor: string;
18
+ /** Neon accent color for borders/effects (hex) */
19
+ accentColor: string;
20
+ }
21
+ /**
22
+ * Generate a deterministic emoji avatar from a wallet address.
23
+ *
24
+ * The same address will always produce the same emoji and colors,
25
+ * making it useful for consistent visual identification across the app.
26
+ *
27
+ * @param address - The wallet address (Hedera, XRPL, or Ethereum format)
28
+ * @returns An EmojiAvatar object with emoji and color information
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const avatar = emojiAvatarForAddress('0.0.12345');
33
+ * // { emoji: '๐Ÿš€', backgroundColor: '#1a1a2e', accentColor: '#00d4ff' }
34
+ * ```
35
+ */
36
+ export declare function emojiAvatarForAddress(address: string): EmojiAvatar;
37
+ //# sourceMappingURL=emoji-avatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emoji-avatar.d.ts","sourceRoot":"","sources":["../src/emoji-avatar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;CACrB;AAgFD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAalE"}
@@ -0,0 +1,111 @@
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
+ * Tech/crypto themed emojis (30 total)
12
+ */
13
+ const EMOJIS = [
14
+ // Crypto/blockchain
15
+ '๐Ÿ’Ž',
16
+ 'โ›“๏ธ',
17
+ '๐Ÿช™',
18
+ '๐Ÿ’ฐ',
19
+ '๐Ÿฆ',
20
+ '๐Ÿ“Š',
21
+ // Tech/digital
22
+ 'โšก',
23
+ '๐Ÿ”',
24
+ '๐Ÿ›ก๏ธ',
25
+ '๐Ÿ”‘',
26
+ '๐ŸŒ',
27
+ '๐Ÿ’ป',
28
+ // Space/futuristic
29
+ '๐Ÿš€',
30
+ '๐Ÿ›ธ',
31
+ '๐ŸŒŒ',
32
+ '๐Ÿ”ฎ',
33
+ 'โœจ',
34
+ 'โ˜„๏ธ',
35
+ // Abstract/symbols
36
+ '๐ŸŽฏ',
37
+ '๐Ÿ’ก',
38
+ '๐Ÿงฉ',
39
+ '๐ŸŽฒ',
40
+ '๐Ÿ”ท',
41
+ '๐Ÿ’ ',
42
+ // Science/innovation
43
+ '๐Ÿงฌ',
44
+ 'โš›๏ธ',
45
+ '๐Ÿ”ฌ',
46
+ '๐Ÿ“ก',
47
+ '๐Ÿค–',
48
+ '๐Ÿ‘พ',
49
+ ];
50
+ /**
51
+ * Dark/neon color pairs (15 total)
52
+ * Each pair has a dark background and a neon accent color
53
+ */
54
+ const COLOR_PAIRS = [
55
+ { bg: '#1a1a2e', accent: '#00d4ff' }, // Deep blue + cyan neon
56
+ { bg: '#16213e', accent: '#0f4c75' }, // Navy + electric blue
57
+ { bg: '#1b1b2f', accent: '#e94560' }, // Dark purple + pink neon
58
+ { bg: '#0d1117', accent: '#58a6ff' }, // GitHub dark + blue
59
+ { bg: '#1a1a1a', accent: '#00ff88' }, // Black + green neon
60
+ { bg: '#2d132c', accent: '#ee4540' }, // Dark wine + red neon
61
+ { bg: '#1f1f1f', accent: '#f39c12' }, // Charcoal + orange neon
62
+ { bg: '#0f0e17', accent: '#ff8906' }, // Deep black + amber
63
+ { bg: '#1a1a2e', accent: '#a855f7' }, // Deep blue + purple neon
64
+ { bg: '#0d1b2a', accent: '#00ffff' }, // Dark teal + cyan
65
+ { bg: '#1b0a1a', accent: '#ff00ff' }, // Deep purple + magenta
66
+ { bg: '#0a192f', accent: '#64ffda' }, // Navy + mint neon
67
+ { bg: '#141414', accent: '#ffd700' }, // Black + gold
68
+ { bg: '#1a1a2e', accent: '#ff6b6b' }, // Deep blue + coral
69
+ { bg: '#0f0f0f', accent: '#39ff14' }, // Black + matrix green
70
+ ];
71
+ /**
72
+ * Generate a numeric hash from a string.
73
+ * Uses the same algorithm as RainbowKit for consistency.
74
+ * @param str
75
+ */
76
+ function hashCode(str) {
77
+ let hash = 0;
78
+ for (let i = 0; i < str.length; i++) {
79
+ const chr = str.charCodeAt(i);
80
+ hash = (hash << 5) - hash + chr;
81
+ hash |= 0; // Convert to 32bit integer
82
+ }
83
+ return hash;
84
+ }
85
+ /**
86
+ * Generate a deterministic emoji avatar from a wallet address.
87
+ *
88
+ * The same address will always produce the same emoji and colors,
89
+ * making it useful for consistent visual identification across the app.
90
+ *
91
+ * @param address - The wallet address (Hedera, XRPL, or Ethereum format)
92
+ * @returns An EmojiAvatar object with emoji and color information
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const avatar = emojiAvatarForAddress('0.0.12345');
97
+ * // { emoji: '๐Ÿš€', backgroundColor: '#1a1a2e', accentColor: '#00d4ff' }
98
+ * ```
99
+ */
100
+ export function emojiAvatarForAddress(address) {
101
+ const hash = Math.abs(hashCode(address.toLowerCase()));
102
+ const emojiIndex = hash % EMOJIS.length;
103
+ const colorIndex = hash % COLOR_PAIRS.length;
104
+ const colorPair = COLOR_PAIRS[colorIndex];
105
+ return {
106
+ emoji: EMOJIS[emojiIndex],
107
+ backgroundColor: colorPair.bg,
108
+ accentColor: colorPair.accent,
109
+ };
110
+ }
111
+ //# sourceMappingURL=emoji-avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emoji-avatar.js","sourceRoot":"","sources":["../src/emoji-avatar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,oBAAoB;IACpB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,eAAe;IACf,GAAG;IACH,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,mBAAmB;IACnB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,mBAAmB;IACnB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,qBAAqB;IACrB,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACI,CAAC;AAEX;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,wBAAwB;IAC9D,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,uBAAuB;IAC7D,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,0BAA0B;IAChE,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,qBAAqB;IAC3D,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,qBAAqB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qB,CAAC,OAAe;IACnD,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAEvD,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,MAAM,UAAU,GAAG,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC;IAE7C,MAAM,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAE1C,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC;QACzB,eAAe,EAAE,SAAS,CAAC,EAAE;QAC7B,WAAW,EAAE,SAAS,CAAC,MAAM;KAC9B,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -40,4 +40,6 @@ export { avatarForAddress, marbleShapeTransform, MARBLE_AVATAR_SIZE, type Marble
40
40
  export type { MemberIdentity } from './identity.js';
41
41
  export { normalizeIdentityKey, matchesMemberIdentity } from './identity.js';
42
42
  export { HEDERA_NODE_ACCOUNTS, HEDERA_FEE_COLLECTOR_ACCOUNTS, HEDERA_SYSTEM_ACCOUNTS, } from './hedera-system-accounts.js';
43
+ export { XRPL_ENDPOINTS, endpointsFor } from './xrpl-endpoints.js';
44
+ export { HSUITE_IPFS_CDN_BASE, HSUITE_IPFS_CDN_HOST, NFT_IMAGE_WIDTH, withImageOptimizer, } from './ipfs-cdn.js';
43
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AAMH,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAIrB,YAAY,EACV,QAAQ,EACR,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,w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yB,CAAC;AAKjC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC;AAS7B,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAO5E,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAQrC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQnE,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -49,4 +49,18 @@ export { normalizeIdentityKey, matchesMemberIdentity } from './identity.js';
49
49
  // filtering / fee-breakdown labeling). Importing from one place keeps the
50
50
  // filter and labeler from drifting apart.
51
51
  export { HEDERA_NODE_ACCOUNTS, HEDERA_FEE_COLLECTOR_ACCOUNTS, HEDERA_SYSTEM_ACCOUNTS, } from './hedera-system-accounts.js';
52
+ // === XRPL Endpoints ===
53
+ // Canonical, ordered rippled endpoint lists per network (primary first, rest
54
+ // are failover). Imported by the ledger-xrpl adapter (WS clients, account
55
+ // checks, manifest) and the native-wallet-sdk (token discovery, import
56
+ // validation) so every XRPL read path fails over across the same nodes and the
57
+ // endpoint set never drifts across packages.
58
+ export { XRPL_ENDPOINTS, endpointsFor } from './xrpl-endpoints.js';
59
+ // === IPFS CDN primitives ===
60
+ // Single source of truth for the HSuite Bunny CDN host/base URL and the
61
+ // per-surface image-optimizer helper. Imported by the SDK gateway layer
62
+ // (the `convertIpfsUrl` default), the wallet app's image getters, and the UI
63
+ // render surfaces so the CDN domain and the optimizer query format never
64
+ // drift across packages.
65
+ export { HSUITE_IPFS_CDN_BASE, HSUITE_IPFS_CDN_HOST, NFT_IMAGE_WIDTH, withImageOptimizer, } from './ipfs-cdn.js';
52
66
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AAEH,mEAAmE;AACnE,kEAAkE;AAClE,oEAAoE;AACpE,6DAA6D;AAC7D,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,0BAA0B,EAC1B,yBAAyB,EACzB,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAwCrB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,EACrB,2BAA2B;AAC3B,6GAA6G;EAC9G,MAAM,eAAe,CAAC;AAcvB,cAAc,YAAY,CAAC;AAC3B,2FAA2F;AAC3F,4DAA4D;AAC5D,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAiBlC,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAYhF,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAoB/B,iCAAiC;AACjC,2EAA2E;AAC3E,mEAAmE;AACnE,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,GAGnB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE5E,iCAAiC;AACjC,4EAA4E;AAC5E,0EAA0E;AAC1E,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C5E,0EAA0E;AAC1E,0EAA0E;AAC1E,0CAA0C;AAC1C,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AAErC,yBAAyB;AACzB,6EAA6E;AAC7E,0EAA0E;AAC1E,uEAAuE;AACvE,+EAA+E;AAC/E,6CAA6C;AAC7C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnE,8BAA8B;AAC9B,wEAAwE;AACxE,wEAAwE;AACxE,6EAA6E;AAC7E,yEAAyE;AACzE,yBAAyB;AACzB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,82 @@
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 Shared HSuite IPFS CDN primitives.
12
+ *
13
+ * The wallet resolves all NFT media (`ipfs://โ€ฆ`) through HSuite's own Bunny
14
+ * CDN, which fronts an IPFS gateway and ships a built-in image optimizer.
15
+ * This module is the single source of truth for:
16
+ *
17
+ * - the CDN host / base URL (so the SDK gateway, the wallet app, and the UI
18
+ * never hardcode the domain independently and drift apart), and
19
+ * - {@link withImageOptimizer}, which appends the Bunny optimizer query
20
+ * (`?optimizer=image&width=N`) so each surface fetches a right-sized
21
+ * variant instead of downloading a full-resolution master for a thumbnail.
22
+ *
23
+ * It lives in `@hsuite/native-connect-types` because that is the only package
24
+ * the SDK, the UI library, and the app all already depend on โ€” the UI does
25
+ * not (and should not) depend on the SDK's channel-protocol/crypto stack.
26
+ *
27
+ * @module ipfs-cdn
28
+ */
29
+ /**
30
+ * Host of HSuite's Bunny IPFS CDN. Used for an exact-match host check in
31
+ * {@link withImageOptimizer} so the optimizer is never appended to
32
+ * third-party hosts (Arweave, DaVinciGraph, public IPFS gateways).
33
+ */
34
+ export declare const HSUITE_IPFS_CDN_HOST = "hsuite-wallet.b-cdn.net";
35
+ /**
36
+ * Base URL for IPFS content on the HSuite CDN. `convertIpfsUrl` rewrites
37
+ * `ipfs://CID/path` to `${HSUITE_IPFS_CDN_BASE}CID/path`. Derived from
38
+ * {@link HSUITE_IPFS_CDN_HOST} so the host and base can never drift apart.
39
+ */
40
+ export declare const HSUITE_IPFS_CDN_BASE: "https://hsuite-wallet.b-cdn.net/ipfs/";
41
+ /**
42
+ * Logical request widths per render surface, in CSS pixels (already ~2ร— the
43
+ * display size to cover retina). Bunny returns a variant resized to this
44
+ * width. Tunable in one place; every surface imports from here.
45
+ *
46
+ * - `THUMB` (200): tiny previews โ€” account-overview cover, send NFT picker,
47
+ * approval/transfer hero cards.
48
+ * - `GRID` (350): collection grids and collection cover images.
49
+ * - `DETAIL` (800): the NFT detail-page hero.
50
+ */
51
+ export declare const NFT_IMAGE_WIDTH: {
52
+ readonly THUMB: 200;
53
+ readonly GRID: 350;
54
+ readonly DETAIL: 800;
55
+ };
56
+ /**
57
+ * Append the Bunny image-optimizer query to an HSuite-CDN raster image URL.
58
+ *
59
+ * The transform is intentionally conservative โ€” it returns the input
60
+ * **unchanged** in every case where optimizing would be wrong or unsafe:
61
+ *
62
+ * - empty / `undefined` input,
63
+ * - malformed or relative URLs (cannot be parsed),
64
+ * - any host other than {@link HSUITE_IPFS_CDN_HOST} (Arweave, DaVinci,
65
+ * public IPFS gateways, base64/data URIs),
66
+ * - non-raster or extensionless paths (SVG, GIF, video, audio, 3D, โ€ฆ),
67
+ * - URLs that already carry an `optimizer` param (idempotent โ€” no double
68
+ * append, so re-wrapping is a no-op).
69
+ *
70
+ * Only when the URL is a CDN-hosted raster image does it append
71
+ * `?optimizer=image&width=<width>` (joining with `&` if a query already
72
+ * exists). This makes the helper safe to call from every image getter: it is
73
+ * a guaranteed no-op for non-image media and third-party hosts.
74
+ *
75
+ * @param url - The (already gateway-resolved) image URL, or `undefined`.
76
+ * @param width - Target width in pixels; defaults to {@link NFT_IMAGE_WIDTH}.GRID.
77
+ * Non-finite or non-positive values fall back to GRID; fractional values are
78
+ * rounded.
79
+ * @returns The optimized URL, or the original input unchanged.
80
+ */
81
+ export declare function withImageOptimizer(url: string | undefined, width?: number): string | undefined;
82
+ //# sourceMappingURL=ipfs-cdn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipfs-cdn.d.ts","sourceRoot":"","sources":["../src/ipfs-cdn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,yCAAmD,CAAC;AAErF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AA6BX;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,KAAK,GAAE,MAA6B,GACnC,MAAM,GAAG,SAAS,CAoCpB"}
@@ -0,0 +1,138 @@
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 Shared HSuite IPFS CDN primitives.
12
+ *
13
+ * The wallet resolves all NFT media (`ipfs://โ€ฆ`) through HSuite's own Bunny
14
+ * CDN, which fronts an IPFS gateway and ships a built-in image optimizer.
15
+ * This module is the single source of truth for:
16
+ *
17
+ * - the CDN host / base URL (so the SDK gateway, the wallet app, and the UI
18
+ * never hardcode the domain independently and drift apart), and
19
+ * - {@link withImageOptimizer}, which appends the Bunny optimizer query
20
+ * (`?optimizer=image&width=N`) so each surface fetches a right-sized
21
+ * variant instead of downloading a full-resolution master for a thumbnail.
22
+ *
23
+ * It lives in `@hsuite/native-connect-types` because that is the only package
24
+ * the SDK, the UI library, and the app all already depend on โ€” the UI does
25
+ * not (and should not) depend on the SDK's channel-protocol/crypto stack.
26
+ *
27
+ * @module ipfs-cdn
28
+ */
29
+ /**
30
+ * Host of HSuite's Bunny IPFS CDN. Used for an exact-match host check in
31
+ * {@link withImageOptimizer} so the optimizer is never appended to
32
+ * third-party hosts (Arweave, DaVinciGraph, public IPFS gateways).
33
+ */
34
+ export const HSUITE_IPFS_CDN_HOST = 'hsuite-wallet.b-cdn.net';
35
+ /**
36
+ * Base URL for IPFS content on the HSuite CDN. `convertIpfsUrl` rewrites
37
+ * `ipfs://CID/path` to `${HSUITE_IPFS_CDN_BASE}CID/path`. Derived from
38
+ * {@link HSUITE_IPFS_CDN_HOST} so the host and base can never drift apart.
39
+ */
40
+ export const HSUITE_IPFS_CDN_BASE = `https://${HSUITE_IPFS_CDN_HOST}/ipfs/`;
41
+ /**
42
+ * Logical request widths per render surface, in CSS pixels (already ~2ร— the
43
+ * display size to cover retina). Bunny returns a variant resized to this
44
+ * width. Tunable in one place; every surface imports from here.
45
+ *
46
+ * - `THUMB` (200): tiny previews โ€” account-overview cover, send NFT picker,
47
+ * approval/transfer hero cards.
48
+ * - `GRID` (350): collection grids and collection cover images.
49
+ * - `DETAIL` (800): the NFT detail-page hero.
50
+ */
51
+ export const NFT_IMAGE_WIDTH = {
52
+ THUMB: 200,
53
+ GRID: 350,
54
+ DETAIL: 800,
55
+ };
56
+ /**
57
+ * Raster formats the Bunny optimizer can safely resize. SVG (vector) and GIF
58
+ * (animation) are deliberately excluded โ€” optimizing them would rasterize the
59
+ * vector or flatten the animation. Anything else (video/audio/3D, or no
60
+ * extension) is left untouched as well.
61
+ */
62
+ const OPTIMIZABLE_RASTER_EXTENSIONS = new Set([
63
+ 'png',
64
+ 'jpg',
65
+ 'jpeg',
66
+ 'webp',
67
+ 'avif',
68
+ 'bmp',
69
+ ]);
70
+ /**
71
+ * Extract the lowercased file extension from a URL pathname, or `''` when the
72
+ * last path segment has none.
73
+ * @param pathname - The URL pathname (already decoded by the URL parser).
74
+ */
75
+ function fileExtension(pathname) {
76
+ const lastSlash = pathname.lastIndexOf('/');
77
+ const filename = lastSlash >= 0 ? pathname.slice(lastSlash + 1) : pathname;
78
+ const lastDot = filename.lastIndexOf('.');
79
+ return lastDot >= 0 ? filename.slice(lastDot + 1).toLowerCase() : '';
80
+ }
81
+ /**
82
+ * Append the Bunny image-optimizer query to an HSuite-CDN raster image URL.
83
+ *
84
+ * The transform is intentionally conservative โ€” it returns the input
85
+ * **unchanged** in every case where optimizing would be wrong or unsafe:
86
+ *
87
+ * - empty / `undefined` input,
88
+ * - malformed or relative URLs (cannot be parsed),
89
+ * - any host other than {@link HSUITE_IPFS_CDN_HOST} (Arweave, DaVinci,
90
+ * public IPFS gateways, base64/data URIs),
91
+ * - non-raster or extensionless paths (SVG, GIF, video, audio, 3D, โ€ฆ),
92
+ * - URLs that already carry an `optimizer` param (idempotent โ€” no double
93
+ * append, so re-wrapping is a no-op).
94
+ *
95
+ * Only when the URL is a CDN-hosted raster image does it append
96
+ * `?optimizer=image&width=<width>` (joining with `&` if a query already
97
+ * exists). This makes the helper safe to call from every image getter: it is
98
+ * a guaranteed no-op for non-image media and third-party hosts.
99
+ *
100
+ * @param url - The (already gateway-resolved) image URL, or `undefined`.
101
+ * @param width - Target width in pixels; defaults to {@link NFT_IMAGE_WIDTH}.GRID.
102
+ * Non-finite or non-positive values fall back to GRID; fractional values are
103
+ * rounded.
104
+ * @returns The optimized URL, or the original input unchanged.
105
+ */
106
+ export function withImageOptimizer(url, width = NFT_IMAGE_WIDTH.GRID) {
107
+ // Empty string and undefined pass straight through.
108
+ if (!url) {
109
+ return url;
110
+ }
111
+ let parsed;
112
+ try {
113
+ parsed = new URL(url);
114
+ }
115
+ catch {
116
+ // Relative or malformed URLs are never CDN raster images.
117
+ return url;
118
+ }
119
+ // Exact host match only (host includes any port) โ€” never rewrite
120
+ // third-party hosts, look-alike subdomains, or the CDN host reached
121
+ // on a non-standard port.
122
+ if (parsed.host !== HSUITE_IPFS_CDN_HOST) {
123
+ return url;
124
+ }
125
+ // Only resize raster formats; leave SVG/GIF/video/extensionless alone.
126
+ if (!OPTIMIZABLE_RASTER_EXTENSIONS.has(fileExtension(parsed.pathname))) {
127
+ return url;
128
+ }
129
+ // Idempotent: if it's already optimized, return the original untouched.
130
+ if (parsed.searchParams.has('optimizer')) {
131
+ return url;
132
+ }
133
+ const safeWidth = Number.isFinite(width) && width > 0 ? Math.round(width) : NFT_IMAGE_WIDTH.GRID;
134
+ parsed.searchParams.set('optimizer', 'image');
135
+ parsed.searchParams.set('width', String(safeWidth));
136
+ return parsed.toString();
137
+ }
138
+ //# sourceMappingURL=ipfs-cdn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipfs-cdn.js","sourceRoot":"","sources":["../src/ipfs-cdn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,yBAAyB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,oBAAoB,QAAiB,CAAC;AAErF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,GAAG;IACT,MAAM,EAAE,GAAG;CACH,CAAC;AAEX;;;;;GAKG;AACH,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACjE,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;CACN,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAS,aAAa,CAAC,Q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GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC;IAEjG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC"}
@@ -25,6 +25,7 @@
25
25
  * @module types/messages
26
26
  */
27
27
  import { z } from 'zod';
28
+ import { type KeyAlgorithm } from './vault.js';
28
29
  /**
29
30
  * @description Schema for dApp session request payload
30
31
  */
@@ -199,6 +200,24 @@ export declare const SignPayloadSchema: z.ZodObject<{
199
200
  addressIndex?: number;
200
201
  }>>;
201
202
  context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
203
+ /**
204
+ * Optional cryptographic-algorithm hint for raw-scalar keys (e.g. an imported
205
+ * Hedera ECDSA key). This is the typed home for the algorithm on the sign
206
+ * surface; signing chokepoints populate it from the account's VaultKey and the
207
+ * Hedera adapter prefers it over the legacy `context.keyType` fallback.
208
+ */
209
+ keyType: z.ZodOptional<z.ZodEnum<["ed25519", "ecdsa"]>>;
210
+ /**
211
+ * Optional account public key (raw or DER hex) for the fail-safe pre-sign
212
+ * assertion. Populated by {@link WalletCore.signDirect} from the account's
213
+ * VaultKey; the Hedera adapter refuses to sign if the reconstructed key's
214
+ * public key does not match. Best-effort โ€” absent on legacy baselines.
215
+ * Mirrors `SignMessagePayload.expectedPublicKey` so both signing surfaces
216
+ * carry the algorithm fail-safe input in a typed field rather than `context`.
217
+ *
218
+ * @security SOC2-CC6.1 โ€” enables wrong-algorithm signature prevention.
219
+ */
220
+ expectedPublicKey: z.ZodOptional<z.ZodString>;
202
221
  nonce: z.ZodOptional<z.ZodString>;
203
222
  isBatch: z.ZodOptional<z.ZodBoolean>;
204
223
  batchKey: z.ZodOptional<z.ZodString>;
@@ -218,9 +237,6 @@ export declare const SignPayloadSchema: z.ZodObject<{
218
237
  }, "strip", z.ZodTypeAny, {
219
238
  ledgerId?: string;
220
239
  networkId?: string;
221
- nonce?: string;
222
- payload?: string | Uint8Array<ArrayBuffer>;
223
- accountAddress?: string;
224
240
  derivationPath?: {
225
241
  purpose?: number;
226
242
  coinType?: number;
@@ -228,7 +244,12 @@ export declare const SignPayloadSchema: z.ZodObject<{
228
244
  change?: number;
229
245
  addressIndex?: number;
230
246
  };
247
+ keyType?: "ed25519" | "ecdsa";
248
+ payload?: string | Uint8Array<ArrayBuffer>;
249
+ nonce?: string;
250
+ accountAddress?: string;
231
251
  context?: Record<string, unknown>;
252
+ expectedPublicKey?: string;
232
253
  isBatch?: boolean;
233
254
  batchKey?: string;
234
255
  innerTransactions?: {
@@ -239,9 +260,6 @@ export declare const SignPayloadSchema: z.ZodObject<{
239
260
  }, {
240
261
  ledgerId?: string;
241
262
  networkId?: string;
242
- nonce?: string;
243
- payload?: string | Uint8Array<ArrayBuffer>;
244
- accountAddress?: string;
245
263
  derivationPath?: {
246
264
  purpose?: number;
247
265
  coinType?: number;
@@ -249,7 +267,12 @@ export declare const SignPayloadSchema: z.ZodObject<{
249
267
  change?: number;
250
268
  addressIndex?: number;
251
269
  };
270
+ keyType?: "ed25519" | "ecdsa";
271
+ payload?: string | Uint8Array<ArrayBuffer>;
272
+ nonce?: string;
273
+ accountAddress?: string;
252
274
  context?: Record<string, unknown>;
275
+ expectedPublicKey?: string;
253
276
  isBatch?: boolean;
254
277
  batchKey?: string;
255
278
  innerTransactions?: {
@@ -308,11 +331,11 @@ export declare const SignResultSchema: z.ZodObject<{
308
331
  }, "strip", z.ZodTypeAny, {
309
332
  status?: string;
310
333
  publicKey?: string;
334
+ algorithm?: string;
311
335
  signature?: string;
312
336
  signedPayload?: string;
313
337
  transactionId?: string;
314
338
  payloadHash?: string;
315
- algorithm?: string;
316
339
  signedInnerTransactions?: {
317
340
  signedPayload?: string;
318
341
  transactionId?: string;
@@ -321,11 +344,11 @@ export declare const SignResultSchema: z.ZodObject<{
321
344
  }, {
322
345
  status?: string;
323
346
  publicKey?: string;
347
+ algorithm?: string;
324
348
  signature?: string;
325
349
  signedPayload?: string;
326
350
  transactionId?: string;
327
351
  payloadHash?: string;
328
- algorithm?: string;
329
352
  signedInnerTransactions?: {
330
353
  signedPayload?: string;
331
354
  transactionId?: string;
@@ -359,6 +382,22 @@ export interface SignMessagePayload {
359
382
  * Must match `/^[a-z0-9]+:[a-z0-9]+$/` (CAIP-2 lower-kebab-case shape).
360
383
  */
361
384
  caipChainId: string;
385
+ /**
386
+ * Optional cryptographic-algorithm hint for raw-scalar keys (e.g. an imported
387
+ * Hedera ECDSA key). Populated by {@link WalletCore.signMessageDirect} from the
388
+ * account's VaultKey so the adapter reconstructs the correct PrivateKey instead
389
+ * of defaulting a raw 32-byte key to Ed25519. Mirrors `SignPayload.keyType`.
390
+ */
391
+ keyType?: KeyAlgorithm;
392
+ /**
393
+ * Optional account public key (raw or DER hex) for the fail-safe pre-sign
394
+ * assertion. Populated by {@link WalletCore.signMessageDirect} from the
395
+ * account's VaultKey; the adapter refuses to sign if the reconstructed key's
396
+ * public key does not match. Best-effort โ€” absent on legacy baselines.
397
+ *
398
+ * @security SOC2-CC6.1 โ€” enables wrong-algorithm signature prevention.
399
+ */
400
+ expectedPublicKey?: string;
362
401
  }
363
402
  /**
364
403
  * @description Schema for message-signing result (ยง21.3).
@@ -399,15 +438,15 @@ export declare const MessageSignResultSchema: z.ZodObject<{
399
438
  messageLength: z.ZodNumber;
400
439
  }, "strip", z.ZodTypeAny, {
401
440
  publicKey?: string;
402
- signature?: string;
403
441
  algorithm?: "ed25519" | "ecdsa_secp256k1" | "secp256k1";
442
+ signature?: string;
404
443
  encoding?: "utf-8" | "base64";
405
444
  caipChainId?: string;
406
445
  messageLength?: number;
407
446
  }, {
408
447
  publicKey?: string;
409
- signature?: string;
410
448
  algorithm?: "ed25519" | "ecdsa_secp256k1" | "secp256k1";
449
+ signature?: string;
411
450
  encoding?: "utf-8" | "base64";
412
451
  caipChainId?: string;
413
452
  messageLength?: number;
@@ -453,15 +492,15 @@ export declare const MessageEnvelopeSchema: z.ZodObject<{
453
492
  id?: string;
454
493
  createdAt?: number;
455
494
  version?: string;
456
- signature?: string;
457
495
  payload?: unknown;
496
+ signature?: string;
458
497
  topic?: string;
459
498
  }, {
460
499
  id?: string;
461
500
  createdAt?: number;
462
501
  version?: string;
463
- signature?: string;
464
502
  payload?: unknown;
503
+ signature?: string;
465
504
  topic?: string;
466
505
  }>;
467
506
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW/B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMhC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;EAItC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;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AAC,OAAO,eAAe,CAAC,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B,qCAAqC;;IAErC,+CAA+C;;IAE/C,iDAAiD;;;;;;;;;;;;;;;;;IAEjD,kDAAkD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAElD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,kDAAkD;;IAElD,gDAAgD;;;;;;;;EAEhD,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAG,CAAU,CAAC;AAIlD;;;;;;GAMG;AACH,eAAO,MAAM,8BAA8B,EAAG,MAAe,CAAC"}
package/dist/messages.js CHANGED
@@ -26,6 +26,7 @@
26
26
  */
27
27
  import { z } from 'zod';
28
28
  import { DerivationPathSchema, LedgerAccountSchema, LedgerIdSchema, NetworkIdSchema, } from './ledger.js';
29
+ import { KeyAlgorithmSchema } from './vault.js';
29
30
  /**
30
31
  * @description Schema for dApp session request payload
31
32
  */
@@ -70,6 +71,24 @@ export const SignPayloadSchema = z.object({
70
71
  payload: z.union([z.string(), z.instanceof(Uint8Array)]),
71
72
  derivationPath: DerivationPathSchema.optional(),
72
73
  context: z.record(z.unknown()).optional(),
74
+ /**
75
+ * Optional cryptographic-algorithm hint for raw-scalar keys (e.g. an imported
76
+ * Hedera ECDSA key). This is the typed home for the algorithm on the sign
77
+ * surface; signing chokepoints populate it from the account's VaultKey and the
78
+ * Hedera adapter prefers it over the legacy `context.keyType` fallback.
79
+ */
80
+ keyType: KeyAlgorithmSchema.optional(),
81
+ /**
82
+ * Optional account public key (raw or DER hex) for the fail-safe pre-sign
83
+ * assertion. Populated by {@link WalletCore.signDirect} from the account's
84
+ * VaultKey; the Hedera adapter refuses to sign if the reconstructed key's
85
+ * public key does not match. Best-effort โ€” absent on legacy baselines.
86
+ * Mirrors `SignMessagePayload.expectedPublicKey` so both signing surfaces
87
+ * carry the algorithm fail-safe input in a typed field rather than `context`.
88
+ *
89
+ * @security SOC2-CC6.1 โ€” enables wrong-algorithm signature prevention.
90
+ */
91
+ expectedPublicKey: z.string().optional(),
73
92
  nonce: z.string().uuid().optional(),
74
93
  // Batch transaction support
75
94
  isBatch: z.boolean().optional(),