@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/dist/vault.js ADDED
@@ -0,0 +1,188 @@
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 Vault types for secure key storage and wallet configuration.
12
+ *
13
+ * This module defines the data structures for the wallet's secure vault system,
14
+ * which manages encrypted seed phrases, derived keys, and recovery mechanisms.
15
+ *
16
+ * Vault Architecture:
17
+ * - {@link VaultSeed} - Encrypted seed phrase storage with KDF parameters
18
+ * - {@link VaultKey} - Derived key with address and derivation path
19
+ * - {@link VaultProtection} - Protection mode (passphrase, biometric, hardware, KMS)
20
+ * - {@link VaultRecoveryBundle} - Encrypted backup for wallet restoration
21
+ * - {@link VaultConfig} - Global vault configuration and policies
22
+ *
23
+ * Protection Modes:
24
+ * - `none` - No additional protection (development only)
25
+ * - `passphrase` - User-provided passphrase with PBKDF2/Argon2
26
+ * - `biometric` - Device biometric authentication
27
+ * - `hardware` - Hardware security module (HSM/TPM)
28
+ * - `kms` - Cloud key management service
29
+ *
30
+ * @module types/vault
31
+ * @security SOC2-CC6.1 - Encryption at rest for seed phrases
32
+ */
33
+ import { z } from 'zod';
34
+ import { LedgerIdSchema, NetworkIdSchema, DerivationPathSchema } from './ledger.js';
35
+ /**
36
+ * @description Schema for vault protection mode enum
37
+ */
38
+ export const VaultProtectionModeSchema = z.enum([
39
+ 'none',
40
+ 'passphrase',
41
+ 'hardware',
42
+ 'biometric',
43
+ 'kms',
44
+ ]);
45
+ /**
46
+ * @description Schema for vault protection configuration
47
+ */
48
+ export const VaultProtectionSchema = z.object({
49
+ mode: VaultProtectionModeSchema,
50
+ hint: z.string().optional(),
51
+ hardwareId: z.string().optional(),
52
+ biometricId: z.string().optional(),
53
+ lastUnlockedAt: z.number().optional(),
54
+ kmsKeyId: z.string().optional(),
55
+ });
56
+ /**
57
+ * @description Schema for recovery contact information
58
+ */
59
+ export const VaultRecoveryContactSchema = z.object({
60
+ name: z.string(),
61
+ contact: z.string(),
62
+ });
63
+ /**
64
+ * @description Schema for recovery metadata and hints
65
+ */
66
+ export const VaultRecoverySchema = z.object({
67
+ hint: z.string().optional(),
68
+ contacts: z.array(VaultRecoveryContactSchema).optional(),
69
+ note: z.string().optional(),
70
+ });
71
+ /**
72
+ * @description Schema for derived vault key
73
+ * Moved before VaultRecoveryBundleSchema to avoid forward reference.
74
+ */
75
+ export const VaultKeySchema = z.object({
76
+ id: z.string().uuid(),
77
+ seedId: z.string().uuid(),
78
+ ledgerId: LedgerIdSchema,
79
+ networkId: NetworkIdSchema,
80
+ address: z.string(),
81
+ publicKey: z.string(),
82
+ derivationPath: DerivationPathSchema,
83
+ protection: VaultProtectionModeSchema,
84
+ metadata: z.record(z.unknown()).optional(),
85
+ });
86
+ /**
87
+ * @description Schema for user preferences stored in recovery bundle
88
+ */
89
+ export const BundleUserSettingsSchema = z.object({
90
+ language: z.string().optional(),
91
+ currency: z.string().optional(),
92
+ autoLockSeconds: z.number().optional(),
93
+ navigationMode: z.enum(['menu', 'tabs']).optional(),
94
+ desktopNavMode: z.enum(['classic', 'sidebar']).optional(),
95
+ telemetryDestination: z.enum(['console', 'server', 'analytics']).optional(),
96
+ telemetryEndpoint: z.string().optional(),
97
+ });
98
+ /**
99
+ * @description Schema for encrypted recovery bundle
100
+ * Extended to include VaultKey objects for complete wallet restoration.
101
+ * The `keys` field contains all derived and imported accounts associated with the seed.
102
+ */
103
+ export const VaultRecoveryBundleSchema = z.object({
104
+ id: z.string().uuid(),
105
+ seedId: z.string().uuid(),
106
+ createdAt: z.number(),
107
+ algorithm: z.literal('AES-GCM'),
108
+ payload: z.string(),
109
+ key: z.string(),
110
+ metadata: z.record(z.unknown()).optional(),
111
+ checksum: z.string().optional(),
112
+ /** VaultKey objects (derived and imported accounts) to restore with the seed */
113
+ keys: z.array(VaultKeySchema).optional(),
114
+ /** Address book contacts to restore with the seed */
115
+ addressBook: z.array(z.unknown()).optional(),
116
+ /** User preferences (language, currency, auto-lock, etc.) */
117
+ userSettings: BundleUserSettingsSchema.optional(),
118
+ /** Current theme ID */
119
+ currentTheme: z.string().optional(),
120
+ /** Custom imported themes (full theme objects) */
121
+ customThemes: z.array(z.unknown()).optional(),
122
+ /** Multisig party states for restoration */
123
+ multisigParties: z.array(z.unknown()).optional(),
124
+ });
125
+ /**
126
+ * @description Schema for encrypted seed storage
127
+ */
128
+ export const VaultSeedSchema = z.object({
129
+ id: z.string().uuid(),
130
+ label: z.string().optional(),
131
+ createdAt: z.number(),
132
+ encryptedSeed: z.string(),
133
+ encryptedMnemonic: z.string().optional(),
134
+ kdfSalt: z.string(),
135
+ derivationScheme: z.string(),
136
+ protection: VaultProtectionSchema,
137
+ metadata: z.record(z.unknown()).optional(),
138
+ recovery: VaultRecoverySchema.optional(),
139
+ });
140
+ /**
141
+ * @description Schema for credential mode — determines whether the vault
142
+ * is protected by a numeric PIN (legacy) or a full password.
143
+ */
144
+ export const CredentialModeSchema = z.enum(['pin', 'password']);
145
+ /**
146
+ * @description Schema for KDF algorithm used to derive encryption keys
147
+ * from the user credential (PIN or password).
148
+ */
149
+ export const KdfAlgorithmSchema = z.enum(['argon2id', 'pbkdf2']);
150
+ /**
151
+ * @description Schema for wallet vault configuration
152
+ */
153
+ export const VaultConfigSchema = z.object({
154
+ defaultLedgerId: LedgerIdSchema.optional(),
155
+ defaultNetworkId: NetworkIdSchema.optional(),
156
+ autoLockIntervalSeconds: z.number().min(30).default(300),
157
+ allowHardware: z.boolean().default(true),
158
+ allowBiometric: z.boolean().default(true),
159
+ allowRecoveryBundles: z.boolean().default(true),
160
+ allowKms: z.boolean().default(false),
161
+ credentialMode: CredentialModeSchema.default('pin'),
162
+ encryptionSalt: z.string().optional(),
163
+ kdfAlgorithm: KdfAlgorithmSchema.default('argon2id'),
164
+ authAttempts: z.number().min(1).max(10).default(5),
165
+ authLockIntervalSeconds: z.number().min(30).default(300),
166
+ /** @deprecated Legacy alias for authAttempts — kept for migration compatibility, remove in future version */
167
+ pinAttempts: z.number().min(1).max(10).optional(),
168
+ /** @deprecated Legacy alias for authLockIntervalSeconds — kept for migration compatibility, remove in future version */
169
+ pinLockIntervalSeconds: z.number().min(30).optional(),
170
+ recoverWithPassphrase: z.boolean().default(true),
171
+ recoverWithHardware: z.boolean().default(true),
172
+ recoverWithBiometric: z.boolean().default(true),
173
+ recoveryExportFormats: z.array(z.enum(['json', 'qr', 'mnemonic'])).default(['json']),
174
+ pinDigest: z.string().optional(),
175
+ pinSalt: z.string().optional(),
176
+ pinUpdatedAt: z.number().optional(),
177
+ passphraseDigest: z.string().optional(),
178
+ passphraseSalt: z.string().optional(),
179
+ biometricRequired: z.boolean().default(false),
180
+ auditLogRetentionDays: z.number().int().positive().default(30),
181
+ metricsEnabled: z.boolean().default(true),
182
+ recoveryContactRequired: z.boolean().default(false),
183
+ defaultRecoveryContact: VaultRecoveryContactSchema.optional(),
184
+ kmsDefaultKeyId: z.string().optional(),
185
+ kmsAllowRotation: z.boolean().default(false),
186
+ kmsProviderConfig: z.record(z.unknown()).optional(),
187
+ });
188
+ //# sourceMappingURL=vault.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault.js","sourceRoot":"","sources":["../src/vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEpF;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC9C,MAAM;IACN,YAAY;IACZ,UAAU;IACV,WAAW;IACX,KAAK;CACN,CAAC,CAAC;AAOH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,yBAAyB;IAC/B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nD,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,323 @@
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
+ * @module WidgetTypes
12
+ * @packageDocumentation
13
+ * Type definitions for the HSuite Wallet widget system.
14
+ * Widgets are Angular components that extend wallet functionality through a secure,
15
+ * permission-based architecture with support for free, subscription, and one-time purchase models.
16
+ */
17
+ /**
18
+ * @type WidgetType
19
+ * Widget monetization model
20
+ * - `freemium`: Free with optional donations (legacy, prefer 'free')
21
+ * - `free`: Completely free, no restrictions
22
+ * - `subscription`: Requires active subscription (recurring)
23
+ * - `one-time`: Single purchase, permanent access
24
+ */
25
+ export type WidgetType = 'freemium' | 'free' | 'subscription' | 'one-time';
26
+ /**
27
+ * @type WidgetSize
28
+ * Widget display size in dashboard grid
29
+ *
30
+ * - `icon`: 100px square (app launcher shortcuts that open modals)
31
+ * - `small`: 300px max height (compact widgets, single stat displays)
32
+ * - `medium`: 500px max height (default, news feeds, price charts)
33
+ * - `large`: 700px max height (detailed analytics, transaction lists)
34
+ * - `full-width`: No height limit (expandable widgets, complex UIs)
35
+ */
36
+ export type WidgetSize = 'icon' | 'small' | 'medium' | 'large' | 'full-width';
37
+ /**
38
+ * @interface GridCell
39
+ * Grid position and span for widget placement in the dashboard
40
+ */
41
+ export interface GridCell {
42
+ /** Column index (0-based) */
43
+ column: number;
44
+ /** Row index (0-based) */
45
+ row: number;
46
+ /** Number of columns this item spans */
47
+ columnSpan: number;
48
+ /** Number of rows this item spans */
49
+ rowSpan: number;
50
+ }
51
+ /**
52
+ * @type WidgetCategory
53
+ * Widget functional category for organization and filtering
54
+ */
55
+ export type WidgetCategory = 'defi' | 'nft' | 'analytics' | 'security' | 'news' | 'tools' | 'gaming';
56
+ /**
57
+ * @type ExperienceType
58
+ * Experience type classification for the unified Apps system.
59
+ * Defines what kind of experience this is from a UX perspective.
60
+ *
61
+ * - `widget`: Standalone embeddable component for the dashboard grid
62
+ * - `smart-app`: Fullscreen application that runs inside the wallet
63
+ * - `app-widget`: Mini-widget provided by a SmartApp (requires parentAppId)
64
+ * - `external-app`: Application that opens in a new browser tab
65
+ * - `b2b-service`: Backend-as-a-Service for developers (API only)
66
+ */
67
+ export type ExperienceType = 'widget' | 'smart-app' | 'app-widget' | 'external-app' | 'b2b-service';
68
+ /**
69
+ * @type ExecutionContext
70
+ * Where and how the experience runs.
71
+ *
72
+ * - `wallet-embedded`: Renders inside the wallet dashboard grid
73
+ * - `wallet-fullscreen`: Opens as a fullscreen modal inside the wallet
74
+ * - `external-tab`: Opens in a new browser tab
75
+ * - `api-only`: No UI, backend service only (for B2B services)
76
+ */
77
+ export type ExecutionContext = 'wallet-embedded' | 'wallet-fullscreen' | 'external-tab' | 'api-only';
78
+ /**
79
+ * @type TargetAudience
80
+ * Target audience classification for marketplace filtering.
81
+ *
82
+ * - `end-user`: Personal wallet users
83
+ * - `organization`: Business/DAO accounts
84
+ * - `developer`: Builder tools, SDKs, and APIs
85
+ */
86
+ export type TargetAudience = 'end-user' | 'organization' | 'developer';
87
+ /**
88
+ * Infer the default execution context from an experience type.
89
+ * @param type - The experience type
90
+ * @returns The default execution context for that experience type
91
+ */
92
+ export declare function inferExecutionContext(type: ExperienceType): ExecutionContext;
93
+ /**
94
+ * @type WidgetPermission
95
+ * Permission types that widgets can request (similar to Android/iOS app permissions)
96
+ */
97
+ export type WidgetPermission = 'read:accounts' | 'read:balances' | 'read:transactions' | 'read:portfolio' | 'sign:transactions' | 'sign:messages' | 'network:external' | 'storage:local' | 'notifications:send' | 'clipboard:write' | 'camera:access' | 'write:themes';
98
+ /**
99
+ * @interface WidgetPermissionRequest
100
+ * Permission request with explanation for user consent
101
+ */
102
+ export interface WidgetPermissionRequest {
103
+ /** Permission being requested */
104
+ permission: WidgetPermission;
105
+ /** Human-readable explanation of why this permission is needed */
106
+ reason: string;
107
+ /** Whether the widget can function without this permission */
108
+ optional: boolean;
109
+ }
110
+ /**
111
+ * @interface WidgetManifest
112
+ * Complete widget metadata and configuration
113
+ */
114
+ export interface WidgetManifest {
115
+ /** Unique identifier (kebab-case, e.g., 'portfolio-tracker') */
116
+ id: string;
117
+ /** Display name */
118
+ name: string;
119
+ /** Short description (2-3 sentences) */
120
+ description: string;
121
+ /** Semantic version (e.g., '1.0.0') */
122
+ version: string;
123
+ /** GitHub username or contributor name */
124
+ author: string;
125
+ /** Monetization model */
126
+ type: WidgetType;
127
+ /** Functional category */
128
+ category: WidgetCategory;
129
+ /** Default display size */
130
+ size: WidgetSize;
131
+ /** Ionicon name (e.g., 'analytics-outline') or SVG path */
132
+ icon: string;
133
+ /** Required and optional permissions with explanations */
134
+ permissions: WidgetPermissionRequest[];
135
+ /** Account access level */
136
+ accountAccess: 'none' | 'single' | 'multiple' | 'all';
137
+ /** Optional donation address for free widgets */
138
+ donationAddress?: string;
139
+ /** SmartApp ID from marketplace registry (required for subscription widgets) */
140
+ smartAppId?: string;
141
+ /** Whitelisted API endpoints widget can access */
142
+ apiEndpoints: string[];
143
+ /** Whether widget makes external network calls */
144
+ networkAccess: boolean;
145
+ /** Preview image path (e.g., 'assets/widget-previews/portfolio-tracker.png') */
146
+ previewImage: string;
147
+ /** Array of screenshot paths (minimum 2) */
148
+ screenshots: string[];
149
+ /** Tags for search and filtering (lowercase) */
150
+ tags: string[];
151
+ /** ISO date string (e.g., '2025-01-15') */
152
+ dateCreated: string;
153
+ /** Whether widget respects theme CSS variables */
154
+ themeCompatible: boolean;
155
+ /** Whether widget supports responsive breakpoints */
156
+ responsive: boolean;
157
+ /** Whether widget can register a full-page route */
158
+ hasFullPage?: boolean;
159
+ }
160
+ /**
161
+ * @interface WidgetManifestV2
162
+ * Extended widget manifest with V2 experience type classification.
163
+ * All new fields are optional for backwards compatibility with existing widgets.
164
+ */
165
+ export interface WidgetManifestV2 extends WidgetManifest {
166
+ /**
167
+ * Experience type classification.
168
+ * Defaults to 'widget' if not specified.
169
+ */
170
+ experienceType?: ExperienceType;
171
+ /**
172
+ * Execution context - where/how the experience runs.
173
+ * If not specified, will be inferred from experienceType using inferExecutionContext().
174
+ */
175
+ executionContext?: ExecutionContext;
176
+ /**
177
+ * Target audience classification.
178
+ * Defaults to 'end-user' if not specified.
179
+ */
180
+ targetAudience?: TargetAudience;
181
+ /**
182
+ * Parent SmartApp ID.
183
+ * Required for 'app-widget' experience type to establish parent relationship.
184
+ */
185
+ parentAppId?: string;
186
+ /**
187
+ * External URL for external-app experience type.
188
+ * The URL that will be opened in a new browser tab.
189
+ */
190
+ externalUrl?: string;
191
+ /**
192
+ * API endpoint for B2B services.
193
+ * Base URL for the service's API documentation or integration endpoint.
194
+ */
195
+ serviceEndpoint?: string;
196
+ /**
197
+ * Whether this app is featured in the marketplace.
198
+ * Featured apps appear prominently in marketplace listings.
199
+ */
200
+ featured?: boolean;
201
+ /**
202
+ * Sort priority for marketplace display.
203
+ * Higher values appear first. Defaults to 0.
204
+ */
205
+ sortPriority?: number;
206
+ /**
207
+ * Price in USD cents for one-time purchase.
208
+ * Only applicable when type is 'one-time'.
209
+ * Example: 4999 = $49.99
210
+ */
211
+ priceUsdCents?: number;
212
+ /**
213
+ * Monthly subscription price in USD cents.
214
+ * Only applicable when type is 'subscription'.
215
+ * Example: 999 = $9.99/month
216
+ */
217
+ subscriptionPriceUsdCents?: number;
218
+ /**
219
+ * Widget IDs that are included with this smart-app.
220
+ * When the parent app is installed, these widgets become available.
221
+ */
222
+ includedWidgetIds?: string[];
223
+ /**
224
+ * Supported ledger IDs for this widget.
225
+ * If specified, the widget will only be available for accounts on these ledgers.
226
+ * Format: ledger ID (e.g., 'hedera', 'xrpl')
227
+ */
228
+ supportedLedgers?: string[];
229
+ /**
230
+ * Supported network IDs for this widget.
231
+ * If specified, the widget will only be available for accounts on these networks.
232
+ * Format: 'ledger:network' (e.g., 'xrpl:mainnet', 'hedera:mainnet', 'xrpl:testnet')
233
+ */
234
+ supportedNetworks?: string[];
235
+ }
236
+ /**
237
+ * Type guard to check if a manifest is V2 (has experience type fields).
238
+ * @param manifest - The manifest to check
239
+ * @returns True if the manifest has V2 experience type fields
240
+ */
241
+ export declare function isManifestV2(manifest: WidgetManifest): manifest is WidgetManifestV2;
242
+ /**
243
+ * Normalize a manifest to V2 format with sensible defaults.
244
+ * This function is non-destructive and returns a new object.
245
+ * @param manifest - The manifest to normalize
246
+ * @returns A WidgetManifestV2 with all V2 fields populated
247
+ */
248
+ export declare function normalizeManifestToV2(manifest: WidgetManifest): WidgetManifestV2;
249
+ /**
250
+ * @interface HsuiteWidget
251
+ * Complete widget definition combining manifest and component
252
+ * Note: component is 'unknown' type to avoid Angular dependency in types package
253
+ */
254
+ export interface HsuiteWidget {
255
+ /** Widget metadata and configuration (supports V2 fields like experienceType) */
256
+ manifest: WidgetManifestV2;
257
+ /** Angular component class */
258
+ component: unknown;
259
+ }
260
+ /**
261
+ * @interface WidgetInstallation
262
+ * User's installed widget instance with permissions
263
+ */
264
+ export interface WidgetInstallation {
265
+ /** Widget ID */
266
+ widgetId: string;
267
+ /** Granted permissions */
268
+ grantedPermissions: WidgetPermission[];
269
+ /** Allowed account addresses */
270
+ allowedAccounts: string[];
271
+ /** Installation timestamp */
272
+ installedAt: number;
273
+ /** Current size override */
274
+ currentSize: WidgetSize;
275
+ /** Dashboard position (for grid layout) */
276
+ gridPosition?: {
277
+ row: number;
278
+ column: number;
279
+ };
280
+ /** Display order for sorting (lower values appear first) */
281
+ displayOrder?: number;
282
+ /** Whether this item is shown in the app dock (for smart-apps/external-apps) */
283
+ inDock?: boolean;
284
+ /** Explicit grid span override (calculated from size if not provided) */
285
+ gridSpan?: {
286
+ columnSpan: number;
287
+ rowSpan: number;
288
+ };
289
+ }
290
+ /**
291
+ * @interface WidgetSettings
292
+ * Widget-specific user settings stored in IndexedDB
293
+ */
294
+ export interface WidgetSettings {
295
+ /** Widget ID */
296
+ widgetId: string;
297
+ /** User-configurable settings (widget-defined schema) */
298
+ settings: Record<string, unknown>;
299
+ /** Last updated timestamp */
300
+ updatedAt: number;
301
+ }
302
+ /**
303
+ * @interface WidgetRegistry
304
+ * Registry of all available widgets in the application
305
+ */
306
+ export interface WidgetRegistry {
307
+ /** Map of widget ID to widget definition */
308
+ widgets: Map<string, HsuiteWidget>;
309
+ }
310
+ /**
311
+ * Whitelisted API endpoints for free widgets
312
+ * @deprecated Use FREE_API_WHITELIST instead
313
+ */
314
+ export declare const FREEMIUM_API_WHITELIST: readonly ["api.coingecko.com", "pro-api.coinmarketcap.com", "min-api.cryptocompare.com", "cryptopanic.com/api", "data.messari.io/api", "api.alternative.me"];
315
+ /**
316
+ * Permission display metadata
317
+ */
318
+ export declare const PERMISSION_METADATA: Record<WidgetPermission, {
319
+ label: string;
320
+ icon: string;
321
+ risk: 'low' | 'medium' | 'high';
322
+ }>;
323
+ //# sourceMappingURL=widget.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget.types.d.ts","sourceRoot":"","sources":["../src/widget.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,MAAM,GAAG,cAAc,GAAG,UAAU,CAAC;AAE3E;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,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AC;KAChB,CAAC;IACF,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,yEAAyE;IACzE,QAAQ,CAAC,EAAE;QACT,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,8JAOzB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,gBAAgB,EAChB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;CAAE,CA8DjE,CAAC"}
@@ -0,0 +1,140 @@
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
+ * Infer the default execution context from an experience type.
12
+ * @param type - The experience type
13
+ * @returns The default execution context for that experience type
14
+ */
15
+ export function inferExecutionContext(type) {
16
+ const contextMap = {
17
+ widget: 'wallet-embedded',
18
+ 'smart-app': 'wallet-fullscreen',
19
+ 'app-widget': 'wallet-embedded',
20
+ 'external-app': 'external-tab',
21
+ 'b2b-service': 'api-only',
22
+ };
23
+ return contextMap[type];
24
+ }
25
+ /**
26
+ * Type guard to check if a manifest is V2 (has experience type fields).
27
+ * @param manifest - The manifest to check
28
+ * @returns True if the manifest has V2 experience type fields
29
+ */
30
+ export function isManifestV2(manifest) {
31
+ return ('experienceType' in manifest || 'executionContext' in manifest || 'targetAudience' in manifest);
32
+ }
33
+ /**
34
+ * Normalize a manifest to V2 format with sensible defaults.
35
+ * This function is non-destructive and returns a new object.
36
+ * @param manifest - The manifest to normalize
37
+ * @returns A WidgetManifestV2 with all V2 fields populated
38
+ */
39
+ export function normalizeManifestToV2(manifest) {
40
+ const v2 = { ...manifest };
41
+ // Infer experienceType from hasFullPage if not set
42
+ if (!v2.experienceType) {
43
+ v2.experienceType = v2.hasFullPage ? 'smart-app' : 'widget';
44
+ }
45
+ // Infer executionContext from experienceType if not set
46
+ if (!v2.executionContext) {
47
+ v2.executionContext = inferExecutionContext(v2.experienceType);
48
+ }
49
+ // Default audience to end-user
50
+ if (!v2.targetAudience) {
51
+ v2.targetAudience = 'end-user';
52
+ }
53
+ // Default sort priority
54
+ if (v2.sortPriority === undefined) {
55
+ v2.sortPriority = 0;
56
+ }
57
+ // Default featured to false
58
+ if (v2.featured === undefined) {
59
+ v2.featured = false;
60
+ }
61
+ return v2;
62
+ }
63
+ /**
64
+ * Whitelisted API endpoints for free widgets
65
+ * @deprecated Use FREE_API_WHITELIST instead
66
+ */
67
+ export const FREEMIUM_API_WHITELIST = [
68
+ 'api.coingecko.com',
69
+ 'pro-api.coinmarketcap.com',
70
+ 'min-api.cryptocompare.com',
71
+ 'cryptopanic.com/api',
72
+ 'data.messari.io/api',
73
+ 'api.alternative.me',
74
+ ];
75
+ /**
76
+ * Permission display metadata
77
+ */
78
+ export const PERMISSION_METADATA = {
79
+ 'read:accounts': {
80
+ label: 'View your account addresses',
81
+ icon: 'person-outline',
82
+ risk: 'low',
83
+ },
84
+ 'read:balances': {
85
+ label: 'View your token balances',
86
+ icon: 'wallet-outline',
87
+ risk: 'low',
88
+ },
89
+ 'read:transactions': {
90
+ label: 'View your transaction history',
91
+ icon: 'list-outline',
92
+ risk: 'low',
93
+ },
94
+ 'read:portfolio': {
95
+ label: 'View your portfolio summary',
96
+ icon: 'pie-chart-outline',
97
+ risk: 'low',
98
+ },
99
+ 'sign:transactions': {
100
+ label: 'Request transaction signatures',
101
+ icon: 'create-outline',
102
+ risk: 'high',
103
+ },
104
+ 'sign:messages': {
105
+ label: 'Request message signatures',
106
+ icon: 'document-text-outline',
107
+ risk: 'medium',
108
+ },
109
+ 'network:external': {
110
+ label: 'Connect to external services',
111
+ icon: 'globe-outline',
112
+ risk: 'medium',
113
+ },
114
+ 'storage:local': {
115
+ label: 'Store widget settings',
116
+ icon: 'save-outline',
117
+ risk: 'low',
118
+ },
119
+ 'notifications:send': {
120
+ label: 'Send notifications',
121
+ icon: 'notifications-outline',
122
+ risk: 'low',
123
+ },
124
+ 'clipboard:write': {
125
+ label: 'Copy to clipboard',
126
+ icon: 'clipboard-outline',
127
+ risk: 'low',
128
+ },
129
+ 'camera:access': {
130
+ label: 'Access camera for QR codes',
131
+ icon: 'camera-outline',
132
+ risk: 'medium',
133
+ },
134
+ 'write:themes': {
135
+ label: 'Create and save custom themes',
136
+ icon: 'brush-outline',
137
+ risk: 'low',
138
+ },
139
+ };
140
+ //# sourceMappingURL=widget.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget.types.js","sourceRoot":"","sources":["../src/widget.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoGH;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAoB;IACxD,MAAM,UAAU,GAA6C;QAC3D,MAAM,EAAE,iBAAiB;QACzB,WAAW,EAAE,mBAAmB;QAChC,YAAY,EAAE,iBAAiB;QAC/B,cAAc,EAAE,cAAc;QAC9B,aAAa,EAAE,UAAU;KAC1B,CAAC;IACF,OAAO,UAAU,CAAC,I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