@hsuite/native-connect-types 1.0.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 (87) hide show
  1. package/README.md +50 -0
  2. package/dist/address-avatar.d.ts +67 -0
  3. package/dist/address-avatar.d.ts.map +1 -0
  4. package/dist/address-avatar.js +130 -0
  5. package/dist/address-avatar.js.map +1 -0
  6. package/dist/addressbook.d.ts +289 -0
  7. package/dist/addressbook.d.ts.map +1 -0
  8. package/dist/addressbook.js +82 -0
  9. package/dist/addressbook.js.map +1 -0
  10. package/dist/enrichment.d.ts +88 -0
  11. package/dist/enrichment.d.ts.map +1 -0
  12. package/dist/enrichment.js +47 -0
  13. package/dist/enrichment.js.map +1 -0
  14. package/dist/hedera-system-accounts.d.ts +49 -0
  15. package/dist/hedera-system-accounts.d.ts.map +1 -0
  16. package/dist/hedera-system-accounts.js +56 -0
  17. package/dist/hedera-system-accounts.js.map +1 -0
  18. package/dist/identity.d.ts +94 -0
  19. package/dist/identity.d.ts.map +1 -0
  20. package/dist/identity.js +190 -0
  21. package/dist/identity.js.map +1 -0
  22. package/dist/index.d.ts +43 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +52 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/ledger.d.ts +848 -0
  27. package/dist/ledger.d.ts.map +1 -0
  28. package/dist/ledger.js +152 -0
  29. package/dist/ledger.js.map +1 -0
  30. package/dist/messages.d.ts +726 -0
  31. package/dist/messages.d.ts.map +1 -0
  32. package/dist/messages.js +252 -0
  33. package/dist/messages.js.map +1 -0
  34. package/dist/multisig-account.d.ts +419 -0
  35. package/dist/multisig-account.d.ts.map +1 -0
  36. package/dist/multisig-account.js +201 -0
  37. package/dist/multisig-account.js.map +1 -0
  38. package/dist/private-key-export.d.ts +112 -0
  39. package/dist/private-key-export.d.ts.map +1 -0
  40. package/dist/private-key-export.js +11 -0
  41. package/dist/private-key-export.js.map +1 -0
  42. package/dist/rpc.d.ts +872 -0
  43. package/dist/rpc.d.ts.map +1 -0
  44. package/dist/rpc.js +143 -0
  45. package/dist/rpc.js.map +1 -0
  46. package/dist/transaction-approval.d.ts +895 -0
  47. package/dist/transaction-approval.d.ts.map +1 -0
  48. package/dist/transaction-approval.js +11 -0
  49. package/dist/transaction-approval.js.map +1 -0
  50. package/dist/transaction-parser.d.ts +93 -0
  51. package/dist/transaction-parser.d.ts.map +1 -0
  52. package/dist/transaction-parser.js +11 -0
  53. package/dist/transaction-parser.js.map +1 -0
  54. package/dist/vault.d.ts +673 -0
  55. package/dist/vault.d.ts.map +1 -0
  56. package/dist/vault.js +188 -0
  57. package/dist/vault.js.map +1 -0
  58. package/dist/widget.types.d.ts +323 -0
  59. package/dist/widget.types.d.ts.map +1 -0
  60. package/dist/widget.types.js +140 -0
  61. package/dist/widget.types.js.map +1 -0
  62. package/package.json +43 -0
  63. package/src/address-avatar.ts +181 -0
  64. package/src/addressbook.spec.ts +220 -0
  65. package/src/addressbook.ts +115 -0
  66. package/src/enrichment.ts +97 -0
  67. package/src/hedera-system-accounts.ts +60 -0
  68. package/src/identity.spec.ts +243 -0
  69. package/src/identity.ts +244 -0
  70. package/src/index.ts +197 -0
  71. package/src/ledger.spec.ts +366 -0
  72. package/src/ledger.ts +567 -0
  73. package/src/messages.ts +381 -0
  74. package/src/multisig-account.spec.ts +362 -0
  75. package/src/multisig-account.ts +310 -0
  76. package/src/private-key-export.ts +117 -0
  77. package/src/rpc.spec.ts +396 -0
  78. package/src/rpc.ts +257 -0
  79. package/src/transaction-approval.ts +1033 -0
  80. package/src/transaction-parser.ts +98 -0
  81. package/src/vault.spec.ts +268 -0
  82. package/src/vault.ts +256 -0
  83. package/src/widget.types.spec.ts +337 -0
  84. package/src/widget.types.ts +501 -0
  85. package/tsconfig.build.json +17 -0
  86. package/tsconfig.json +11 -0
  87. package/vitest.config.ts +36 -0
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @hsuite/native-connect-types
2
+
3
+ Canonical TypeScript definitions and Zod schemas for the HSuite Native Connect ecosystem. Provides type safety and runtime validation for all SDK packages.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @hsuite/native-connect-types
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import {
15
+ SessionRequest,
16
+ SessionRequestSchema,
17
+ LedgerId,
18
+ NetworkId,
19
+ } from '@hsuite/native-connect-types';
20
+
21
+ // Type-safe usage
22
+ const request: SessionRequest = {
23
+ appId: 'my-dapp',
24
+ appName: 'My dApp',
25
+ ledgerId: 'hedera',
26
+ networkId: 'hedera:testnet',
27
+ };
28
+
29
+ // Runtime validation with Zod
30
+ const validated = SessionRequestSchema.parse(request);
31
+ ```
32
+
33
+ ## Features
34
+
35
+ - Channel types - ChannelInvite, ChannelMessage, ChannelState, TransportState
36
+ - Session types - UnifiedSession, SessionRequest, SessionApproval
37
+ - Ledger types - LedgerId, NetworkId, Account, LedgerPluginManifest
38
+ - RPC types - RpcRequest, RpcResponse, RpcError
39
+ - Vault types - VaultSeed, VaultKey, VaultProtection, VaultRecoveryBundle
40
+ - Transaction types - TransactionPayload, SignResult, SubmitResult
41
+ - Zod schemas - Runtime validation for all types
42
+
43
+ ## Documentation
44
+
45
+ - [Full Documentation](../../docs/packages/types.md)
46
+ - [RPC Versioning](../../docs/protocol/rpc-versioning.md)
47
+
48
+ ## License
49
+
50
+ Apache-2.0 - See [LICENSE](../../LICENSE)
@@ -0,0 +1,67 @@
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
+ * Deterministic "marble" avatar generator for wallet addresses.
12
+ *
13
+ * Visual model is the Marble variant from boring-avatars
14
+ * (https://boringavatars.com — MIT licensed): three colors blended via
15
+ * gaussian-blurred organic shapes, all clipped to a circle. The path data
16
+ * and transform algorithm are ported verbatim; only the color palette is
17
+ * re-tinted to the HSuite brand so account avatars stay coherent with the
18
+ * rest of the wallet (purple-cyan family) instead of injecting unrelated
19
+ * cyber-neon colors per address.
20
+ *
21
+ * Replaces the previous emoji-based avatar (💎🚀🛸 etc.) which:
22
+ * - rendered differently on every OS (Apple emoji vs Windows Segoe etc.)
23
+ * - carried "degen NFT 2021" cultural baggage that clashed with the
24
+ * wallet's data-terminal aesthetic
25
+ * - had only 30 × 15 = 450 unique combinations
26
+ */
27
+ /**
28
+ * Per-shape transform derived from the address hash. The two non-base
29
+ * shapes get independent translate / rotate / scale so the marble
30
+ * composition feels organic rather than repetitive.
31
+ */
32
+ export interface MarbleShape {
33
+ translateX: number;
34
+ translateY: number;
35
+ rotate: number;
36
+ scale: number;
37
+ }
38
+ /**
39
+ * Resolved avatar data — three colors plus the transforms for the two
40
+ * blurred shapes that float over the base color.
41
+ */
42
+ export interface MarbleAvatar {
43
+ /** Base color, then two overlay shape colors. */
44
+ colors: [string, string, string];
45
+ /** Transforms for the two overlay shapes (base has no transform). */
46
+ shapes: [MarbleShape, MarbleShape];
47
+ }
48
+ /**
49
+ * Generate the marble avatar parameters for a given address.
50
+ *
51
+ * Deterministic: same address (case-insensitive) always returns the same
52
+ * avatar. Pass a different `palette` to tint avatars for non-HSuite
53
+ * contexts (e.g., a partner-branded variant).
54
+ * @param address
55
+ * @param palette
56
+ */
57
+ export declare function avatarForAddress(address: string, palette?: readonly string[]): MarbleAvatar;
58
+ /**
59
+ * Build the SVG `transform` attribute string for a marble shape. Splits
60
+ * the avatar viewport size in half so rotation pivots from the center.
61
+ * @param shape
62
+ * @param size
63
+ */
64
+ export declare function marbleShapeTransform(shape: MarbleShape, size?: number): string;
65
+ /** Default avatar viewport size for use in templates. */
66
+ export declare const MARBLE_AVATAR_SIZE = 80;
67
+ //# sourceMappingURL=address-avatar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-avatar.d.ts","sourceRoot":"","sources":["../src/address-avatar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,iDAAiD;IACjD,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,qEAAqE;IACrE,MAAM,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;CACpC;AAwED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAmC3F;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,SAAO,GAAG,MAAM,CAI5E;AAED,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,KAAO,CAAC"}
@@ -0,0 +1,130 @@
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
+ * Curated HSuite brand palette. All colors live in the purple-cyan family
12
+ * so any combination feels on-brand. Order matters only for determinism;
13
+ * the hash function reads from the array uniformly.
14
+ */
15
+ const HSUITE_PALETTE = [
16
+ '#8B7FFF', // primary purple
17
+ '#00D9FF', // secondary cyan
18
+ '#A855F7', // accent purple
19
+ '#7C3AED', // deep purple
20
+ '#06B6D4', // teal cyan
21
+ '#3B82F6', // electric blue
22
+ '#22D3EE', // cyan
23
+ '#6366F1', // indigo
24
+ ];
25
+ /** Reference SVG viewport size — boring-avatars marble is built around 80x80. */
26
+ const SIZE = 80;
27
+ const ELEMENTS = 3;
28
+ /**
29
+ * Same string-hash as the previous emoji implementation (RainbowKit's
30
+ * algorithm), kept so existing addresses don't dramatically reshuffle
31
+ * their avatars on rollout — they just get the new visual treatment.
32
+ * @param str
33
+ */
34
+ function hashCode(str) {
35
+ let hash = 0;
36
+ for (let i = 0; i < str.length; i++) {
37
+ const chr = str.charCodeAt(i);
38
+ hash = (hash << 5) - hash + chr;
39
+ hash |= 0;
40
+ }
41
+ return Math.abs(hash);
42
+ }
43
+ /**
44
+ * Extract the n-th decimal digit of `num`.
45
+ * @param num
46
+ * @param ntn
47
+ */
48
+ function getDigit(num, ntn) {
49
+ return Math.floor((num / Math.pow(10, ntn)) % 10);
50
+ }
51
+ /**
52
+ * Bounded random unit derived from the hash. `range` controls magnitude;
53
+ * `index` (when provided) flips the sign on odd digits — gives the marble
54
+ * shapes asymmetric drift instead of always-positive offsets.
55
+ * @param num
56
+ * @param range
57
+ * @param index
58
+ */
59
+ function getUnit(num, range, index) {
60
+ const value = num % range;
61
+ if (index !== undefined && getDigit(num, index) % 2 === 0) {
62
+ return -value;
63
+ }
64
+ return value;
65
+ }
66
+ /**
67
+ * Pick the n-th palette entry (mod length) for deterministic color selection.
68
+ * @param num
69
+ * @param palette
70
+ */
71
+ function pickColor(num, palette) {
72
+ return palette[num % palette.length];
73
+ }
74
+ /**
75
+ * Generate the marble avatar parameters for a given address.
76
+ *
77
+ * Deterministic: same address (case-insensitive) always returns the same
78
+ * avatar. Pass a different `palette` to tint avatars for non-HSuite
79
+ * contexts (e.g., a partner-branded variant).
80
+ * @param address
81
+ * @param palette
82
+ */
83
+ export function avatarForAddress(address, palette) {
84
+ // Fall back to the HSuite default if no palette is supplied or the caller
85
+ // accidentally passed an empty array (defensive — modulo into a 0-length
86
+ // array yields NaN, which would crash color lookup downstream).
87
+ const colors = palette && palette.length > 0 ? palette : HSUITE_PALETTE;
88
+ const seed = hashCode(address.toLowerCase());
89
+ const props = Array.from({ length: ELEMENTS }, (_unused, i) => {
90
+ const n = seed * (i + 1);
91
+ return {
92
+ color: pickColor(seed + i, colors),
93
+ translateX: getUnit(n, SIZE / 10, 1),
94
+ translateY: getUnit(n, SIZE / 10, 2),
95
+ scale: 1.2 + getUnit(n, SIZE / 20) / 10,
96
+ rotate: getUnit(n, 360, 1),
97
+ };
98
+ });
99
+ return {
100
+ colors: [props[0].color, props[1].color, props[2].color],
101
+ shapes: [
102
+ {
103
+ translateX: props[1].translateX,
104
+ translateY: props[1].translateY,
105
+ rotate: props[1].rotate,
106
+ scale: props[2].scale,
107
+ },
108
+ {
109
+ translateX: props[2].translateX,
110
+ translateY: props[2].translateY,
111
+ rotate: props[2].rotate,
112
+ scale: props[2].scale,
113
+ },
114
+ ],
115
+ };
116
+ }
117
+ /**
118
+ * Build the SVG `transform` attribute string for a marble shape. Splits
119
+ * the avatar viewport size in half so rotation pivots from the center.
120
+ * @param shape
121
+ * @param size
122
+ */
123
+ export function marbleShapeTransform(shape, size = SIZE) {
124
+ const cx = size / 2;
125
+ const cy = size / 2;
126
+ return `translate(${shape.translateX} ${shape.translateY}) rotate(${shape.rotate} ${cx} ${cy}) scale(${shape.scale})`;
127
+ }
128
+ /** Default avatar viewport size for use in templates. */
129
+ export const MARBLE_AVATAR_SIZE = SIZE;
130
+ //# sourceMappingURL=address-avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-avatar.js","sourceRoot":"","sources":["../src/address-avatar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA2CH;;;;GAIG;AACH,MAAM,cAAc,GAAG;IACrB,SAAS,EAAE,iBAAiB;IAC5B,SAAS,EAAE,iBAAiB;IAC5B,SAAS,EAAE,gBAAgB;IAC3B,SAAS,EAAE,cAAc;IACzB,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,gBAAgB;IAC3B,S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EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;gBACvB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;aACtB;YACD;gBACE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU;gBAC/B,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU;gBAC/B,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;gBACvB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;aACtB;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAkB,EAAE,IAAI,GAAG,IAAI;IAClE,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC;IACpB,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC;IACpB,OAAO,aAAa,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,YAAY,KAAK,CAAC,MAAM,IAAI,EAAE,IAAI,EAAE,WAAW,KAAK,CAAC,KAAK,GAAG,CAAC;AACxH,CAAC;AAED,yDAAyD;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC"}
@@ -0,0 +1,289 @@
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
+ * @fileoverview Address book types for contact management across ledgers.
12
+ *
13
+ * This module defines the data structures for the wallet's address book,
14
+ * which stores contacts with multiple blockchain addresses across different
15
+ * ledgers (Hedera, XRPL, etc.).
16
+ *
17
+ * Features:
18
+ * - Multiple addresses per contact (cross-chain support)
19
+ * - Primary address designation per ledger
20
+ * - Tags and notes for organization
21
+ * - Search and filter capabilities
22
+ *
23
+ * @module types/addressbook
24
+ */
25
+ import { z } from 'zod';
26
+ /**
27
+ * @description Schema for a single address entry within a contact
28
+ * Represents one blockchain address for a contact (contacts can have multiple addresses)
29
+ */
30
+ export declare const ContactAddressSchema: z.ZodObject<{
31
+ /** Blockchain address */
32
+ address: z.ZodString;
33
+ /** Ledger/blockchain identifier (hedera, xrpl, etc.) */
34
+ ledgerId: z.ZodString;
35
+ /** Network identifier (mainnet, testnet, etc.) */
36
+ networkId: z.ZodOptional<z.ZodString>;
37
+ /** Optional label for this specific address (e.g., "Main Account", "Savings") */
38
+ label: z.ZodOptional<z.ZodString>;
39
+ /** Whether this is the primary/default address for this ledger */
40
+ isPrimary: z.ZodOptional<z.ZodBoolean>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ ledgerId?: string;
43
+ networkId?: string;
44
+ address?: string;
45
+ label?: string;
46
+ isPrimary?: boolean;
47
+ }, {
48
+ ledgerId?: string;
49
+ networkId?: string;
50
+ address?: string;
51
+ label?: string;
52
+ isPrimary?: boolean;
53
+ }>;
54
+ /**
55
+ * @description Type representing a contact address
56
+ */
57
+ export type ContactAddress = z.infer<typeof ContactAddressSchema>;
58
+ /**
59
+ * @description Schema for address book contact entry
60
+ * A contact represents a person/entity with one or more blockchain addresses.
61
+ * Supports multiple addresses across different ledgers (Hedera, XRPL, etc.)
62
+ */
63
+ export declare const AddressBookContactSchema: z.ZodObject<{
64
+ /** Unique identifier for the contact */
65
+ id: z.ZodString;
66
+ /** Display name for the contact */
67
+ name: z.ZodString;
68
+ /** Array of blockchain addresses for this contact */
69
+ addresses: z.ZodArray<z.ZodObject<{
70
+ /** Blockchain address */
71
+ address: z.ZodString;
72
+ /** Ledger/blockchain identifier (hedera, xrpl, etc.) */
73
+ ledgerId: z.ZodString;
74
+ /** Network identifier (mainnet, testnet, etc.) */
75
+ networkId: z.ZodOptional<z.ZodString>;
76
+ /** Optional label for this specific address (e.g., "Main Account", "Savings") */
77
+ label: z.ZodOptional<z.ZodString>;
78
+ /** Whether this is the primary/default address for this ledger */
79
+ isPrimary: z.ZodOptional<z.ZodBoolean>;
80
+ }, "strip", z.ZodTypeAny, {
81
+ ledgerId?: string;
82
+ networkId?: string;
83
+ address?: string;
84
+ label?: string;
85
+ isPrimary?: boolean;
86
+ }, {
87
+ ledgerId?: string;
88
+ networkId?: string;
89
+ address?: string;
90
+ label?: string;
91
+ isPrimary?: boolean;
92
+ }>, "many">;
93
+ /** Optional notes or description */
94
+ notes: z.ZodOptional<z.ZodString>;
95
+ /** Optional tags for categorization */
96
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
97
+ /** Optional avatar/icon URL */
98
+ avatar: z.ZodOptional<z.ZodString>;
99
+ /** When the contact was added */
100
+ createdAt: z.ZodNumber;
101
+ /** Last time the contact was modified */
102
+ updatedAt: z.ZodNumber;
103
+ /** Additional metadata */
104
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
105
+ }, "strip", z.ZodTypeAny, {
106
+ metadata?: Record<string, unknown>;
107
+ id?: string;
108
+ name?: string;
109
+ addresses?: {
110
+ ledgerId?: string;
111
+ networkId?: string;
112
+ address?: string;
113
+ label?: string;
114
+ isPrimary?: boolean;
115
+ }[];
116
+ notes?: string;
117
+ tags?: string[];
118
+ avatar?: string;
119
+ createdAt?: number;
120
+ updatedAt?: number;
121
+ }, {
122
+ metadata?: Record<string, unknown>;
123
+ id?: string;
124
+ name?: string;
125
+ addresses?: {
126
+ ledgerId?: string;
127
+ networkId?: string;
128
+ address?: string;
129
+ label?: string;
130
+ isPrimary?: boolean;
131
+ }[];
132
+ notes?: string;
133
+ tags?: string[];
134
+ avatar?: string;
135
+ createdAt?: number;
136
+ updatedAt?: number;
137
+ }>;
138
+ /**
139
+ * @description Type representing an address book contact
140
+ */
141
+ export type AddressBookContact = z.infer<typeof AddressBookContactSchema>;
142
+ /**
143
+ * @description Schema for address book storage
144
+ * The address book contains all saved contacts
145
+ */
146
+ export declare const AddressBookSchema: z.ZodObject<{
147
+ /** Version for schema evolution */
148
+ version: z.ZodLiteral<"2.0">;
149
+ /** All contacts in the address book */
150
+ contacts: z.ZodArray<z.ZodObject<{
151
+ /** Unique identifier for the contact */
152
+ id: z.ZodString;
153
+ /** Display name for the contact */
154
+ name: z.ZodString;
155
+ /** Array of blockchain addresses for this contact */
156
+ addresses: z.ZodArray<z.ZodObject<{
157
+ /** Blockchain address */
158
+ address: z.ZodString;
159
+ /** Ledger/blockchain identifier (hedera, xrpl, etc.) */
160
+ ledgerId: z.ZodString;
161
+ /** Network identifier (mainnet, testnet, etc.) */
162
+ networkId: z.ZodOptional<z.ZodString>;
163
+ /** Optional label for this specific address (e.g., "Main Account", "Savings") */
164
+ label: z.ZodOptional<z.ZodString>;
165
+ /** Whether this is the primary/default address for this ledger */
166
+ isPrimary: z.ZodOptional<z.ZodBoolean>;
167
+ }, "strip", z.ZodTypeAny, {
168
+ ledgerId?: string;
169
+ networkId?: string;
170
+ address?: string;
171
+ label?: string;
172
+ isPrimary?: boolean;
173
+ }, {
174
+ ledgerId?: string;
175
+ networkId?: string;
176
+ address?: string;
177
+ label?: string;
178
+ isPrimary?: boolean;
179
+ }>, "many">;
180
+ /** Optional notes or description */
181
+ notes: z.ZodOptional<z.ZodString>;
182
+ /** Optional tags for categorization */
183
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
184
+ /** Optional avatar/icon URL */
185
+ avatar: z.ZodOptional<z.ZodString>;
186
+ /** When the contact was added */
187
+ createdAt: z.ZodNumber;
188
+ /** Last time the contact was modified */
189
+ updatedAt: z.ZodNumber;
190
+ /** Additional metadata */
191
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
192
+ }, "strip", z.ZodTypeAny, {
193
+ metadata?: Record<string, unknown>;
194
+ id?: string;
195
+ name?: string;
196
+ addresses?: {
197
+ ledgerId?: string;
198
+ networkId?: string;
199
+ address?: string;
200
+ label?: string;
201
+ isPrimary?: boolean;
202
+ }[];
203
+ notes?: string;
204
+ tags?: string[];
205
+ avatar?: string;
206
+ createdAt?: number;
207
+ updatedAt?: number;
208
+ }, {
209
+ metadata?: Record<string, unknown>;
210
+ id?: string;
211
+ name?: string;
212
+ addresses?: {
213
+ ledgerId?: string;
214
+ networkId?: string;
215
+ address?: string;
216
+ label?: string;
217
+ isPrimary?: boolean;
218
+ }[];
219
+ notes?: string;
220
+ tags?: string[];
221
+ avatar?: string;
222
+ createdAt?: number;
223
+ updatedAt?: number;
224
+ }>, "many">;
225
+ /** When the address book was created */
226
+ createdAt: z.ZodNumber;
227
+ /** Last time unknown contact was modified */
228
+ updatedAt: z.ZodNumber;
229
+ }, "strip", z.ZodTypeAny, {
230
+ createdAt?: number;
231
+ updatedAt?: number;
232
+ version?: "2.0";
233
+ contacts?: {
234
+ metadata?: Record<string, unknown>;
235
+ id?: string;
236
+ name?: string;
237
+ addresses?: {
238
+ ledgerId?: string;
239
+ networkId?: string;
240
+ address?: string;
241
+ label?: string;
242
+ isPrimary?: boolean;
243
+ }[];
244
+ notes?: string;
245
+ tags?: string[];
246
+ avatar?: string;
247
+ createdAt?: number;
248
+ updatedAt?: number;
249
+ }[];
250
+ }, {
251
+ createdAt?: number;
252
+ updatedAt?: number;
253
+ version?: "2.0";
254
+ contacts?: {
255
+ metadata?: Record<string, unknown>;
256
+ id?: string;
257
+ name?: string;
258
+ addresses?: {
259
+ ledgerId?: string;
260
+ networkId?: string;
261
+ address?: string;
262
+ label?: string;
263
+ isPrimary?: boolean;
264
+ }[];
265
+ notes?: string;
266
+ tags?: string[];
267
+ avatar?: string;
268
+ createdAt?: number;
269
+ updatedAt?: number;
270
+ }[];
271
+ }>;
272
+ /**
273
+ * @description Type representing the address book
274
+ */
275
+ export type AddressBook = z.infer<typeof AddressBookSchema>;
276
+ /**
277
+ * @description Filter options for searching contacts
278
+ */
279
+ export interface AddressBookFilter {
280
+ /** Filter by ledger ID */
281
+ ledgerId?: string;
282
+ /** Filter by network ID */
283
+ networkId?: string;
284
+ /** Filter by tag */
285
+ tag?: string;
286
+ /** Search query for name or address */
287
+ query?: string;
288
+ }
289
+ //# sourceMappingURL=addressbook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressbook.d.ts","sourceRoot":"","sources":["../src/addressbook.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;GAGG;AACH,eAAO,MAAM,oBAAoB;IAC/B,yBAAyB;;IAEzB,wDAAwD;;IAExD,kDAAkD;;IAElD,iFAAiF;;IAEjF,kEAAkE;;;;;;;;;;;;;;EAElE,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;IACnC,wCAAwC;;IAExC,mCAAmC;;IAEnC,qDAAqD;;QA3BrD,yBAAyB;;QAEzB,wDAAwD;;QAExD,kDAAkD;;QAElD,iFAAiF;;QAEjF,kEAAkE;;;;;;;;;;;;;;;IAqBlE,oCAAoC;;IAEpC,uCAAuC;;IAEvC,+BAA+B;;IAE/B,iCAAiC;;IAEjC,yCAAyC;;IAEzC,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE1B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,iBAAiB;IAC5B,mCAAmC;;IAEnC,uCAAuC;;QAhCvC,wCAAwC;;QAExC,mCAAmC;;QAEnC,qDAAqD;;YA3BrD,yBAAyB;;YAEzB,wDAAwD;;YAExD,kDAAkD;;YAElD,iFAAiF;;YAEjF,kEAAkE;;;;;;;;;;;;;;;QAqBlE,oCAAoC;;QAEpC,uCAAuC;;QAEvC,+BAA+B;;QAE/B,iCAAiC;;QAEjC,yCAAyC;;QAEzC,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkB1B,wCAAwC;;IAExC,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE7C,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -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
+ * @fileoverview Address book types for contact management across ledgers.
12
+ *
13
+ * This module defines the data structures for the wallet's address book,
14
+ * which stores contacts with multiple blockchain addresses across different
15
+ * ledgers (Hedera, XRPL, etc.).
16
+ *
17
+ * Features:
18
+ * - Multiple addresses per contact (cross-chain support)
19
+ * - Primary address designation per ledger
20
+ * - Tags and notes for organization
21
+ * - Search and filter capabilities
22
+ *
23
+ * @module types/addressbook
24
+ */
25
+ import { z } from 'zod';
26
+ import { LedgerIdSchema, NetworkIdSchema } from './ledger.js';
27
+ /**
28
+ * @description Schema for a single address entry within a contact
29
+ * Represents one blockchain address for a contact (contacts can have multiple addresses)
30
+ */
31
+ export const ContactAddressSchema = z.object({
32
+ /** Blockchain address */
33
+ address: z.string(),
34
+ /** Ledger/blockchain identifier (hedera, xrpl, etc.) */
35
+ ledgerId: LedgerIdSchema,
36
+ /** Network identifier (mainnet, testnet, etc.) */
37
+ networkId: NetworkIdSchema.optional(),
38
+ /** Optional label for this specific address (e.g., "Main Account", "Savings") */
39
+ label: z.string().max(50).optional(),
40
+ /** Whether this is the primary/default address for this ledger */
41
+ isPrimary: z.boolean().optional(),
42
+ });
43
+ /**
44
+ * @description Schema for address book contact entry
45
+ * A contact represents a person/entity with one or more blockchain addresses.
46
+ * Supports multiple addresses across different ledgers (Hedera, XRPL, etc.)
47
+ */
48
+ export const AddressBookContactSchema = z.object({
49
+ /** Unique identifier for the contact */
50
+ id: z.string().uuid(),
51
+ /** Display name for the contact */
52
+ name: z.string().min(1).max(100),
53
+ /** Array of blockchain addresses for this contact */
54
+ addresses: z.array(ContactAddressSchema).min(1),
55
+ /** Optional notes or description */
56
+ notes: z.string().max(500).optional(),
57
+ /** Optional tags for categorization */
58
+ tags: z.array(z.string()).optional(),
59
+ /** Optional avatar/icon URL */
60
+ avatar: z.string().url().optional(),
61
+ /** When the contact was added */
62
+ createdAt: z.number(),
63
+ /** Last time the contact was modified */
64
+ updatedAt: z.number(),
65
+ /** Additional metadata */
66
+ metadata: z.record(z.unknown()).optional(),
67
+ });
68
+ /**
69
+ * @description Schema for address book storage
70
+ * The address book contains all saved contacts
71
+ */
72
+ export const AddressBookSchema = z.object({
73
+ /** Version for schema evolution */
74
+ version: z.literal('2.0'),
75
+ /** All contacts in the address book */
76
+ contacts: z.array(AddressBookContactSchema),
77
+ /** When the address book was created */
78
+ createdAt: z.number(),
79
+ /** Last time unknown contact was modified */
80
+ updatedAt: z.number(),
81
+ });
82
+ //# sourceMappingURL=addressbook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressbook.js","sourceRoot":"","sources":["../src/addressbook.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC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