@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.
- package/README.md +50 -0
- package/dist/address-avatar.d.ts +67 -0
- package/dist/address-avatar.d.ts.map +1 -0
- package/dist/address-avatar.js +130 -0
- package/dist/address-avatar.js.map +1 -0
- package/dist/addressbook.d.ts +289 -0
- package/dist/addressbook.d.ts.map +1 -0
- package/dist/addressbook.js +82 -0
- package/dist/addressbook.js.map +1 -0
- package/dist/enrichment.d.ts +88 -0
- package/dist/enrichment.d.ts.map +1 -0
- package/dist/enrichment.js +47 -0
- package/dist/enrichment.js.map +1 -0
- package/dist/hedera-system-accounts.d.ts +49 -0
- package/dist/hedera-system-accounts.d.ts.map +1 -0
- package/dist/hedera-system-accounts.js +56 -0
- package/dist/hedera-system-accounts.js.map +1 -0
- package/dist/identity.d.ts +94 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +190 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger.d.ts +848 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +152 -0
- package/dist/ledger.js.map +1 -0
- package/dist/messages.d.ts +726 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +252 -0
- package/dist/messages.js.map +1 -0
- package/dist/multisig-account.d.ts +419 -0
- package/dist/multisig-account.d.ts.map +1 -0
- package/dist/multisig-account.js +201 -0
- package/dist/multisig-account.js.map +1 -0
- package/dist/private-key-export.d.ts +112 -0
- package/dist/private-key-export.d.ts.map +1 -0
- package/dist/private-key-export.js +11 -0
- package/dist/private-key-export.js.map +1 -0
- package/dist/rpc.d.ts +872 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +143 -0
- package/dist/rpc.js.map +1 -0
- package/dist/transaction-approval.d.ts +895 -0
- package/dist/transaction-approval.d.ts.map +1 -0
- package/dist/transaction-approval.js +11 -0
- package/dist/transaction-approval.js.map +1 -0
- package/dist/transaction-parser.d.ts +93 -0
- package/dist/transaction-parser.d.ts.map +1 -0
- package/dist/transaction-parser.js +11 -0
- package/dist/transaction-parser.js.map +1 -0
- package/dist/vault.d.ts +673 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +188 -0
- package/dist/vault.js.map +1 -0
- package/dist/widget.types.d.ts +323 -0
- package/dist/widget.types.d.ts.map +1 -0
- package/dist/widget.types.js +140 -0
- package/dist/widget.types.js.map +1 -0
- package/package.json +43 -0
- package/src/address-avatar.ts +181 -0
- package/src/addressbook.spec.ts +220 -0
- package/src/addressbook.ts +115 -0
- package/src/enrichment.ts +97 -0
- package/src/hedera-system-accounts.ts +60 -0
- package/src/identity.spec.ts +243 -0
- package/src/identity.ts +244 -0
- package/src/index.ts +197 -0
- package/src/ledger.spec.ts +366 -0
- package/src/ledger.ts +567 -0
- package/src/messages.ts +381 -0
- package/src/multisig-account.spec.ts +362 -0
- package/src/multisig-account.ts +310 -0
- package/src/private-key-export.ts +117 -0
- package/src/rpc.spec.ts +396 -0
- package/src/rpc.ts +257 -0
- package/src/transaction-approval.ts +1033 -0
- package/src/transaction-parser.ts +98 -0
- package/src/vault.spec.ts +268 -0
- package/src/vault.ts +256 -0
- package/src/widget.types.spec.ts +337 -0
- package/src/widget.types.ts +501 -0
- package/tsconfig.build.json +17 -0
- package/tsconfig.json +11 -0
- package/vitest.config.ts +36 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HSuite Native Connect
|
|
3
|
+
* Copyright 2024-2025 HSuite (https://hsuite.finance)
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
|
|
6
|
+
*
|
|
7
|
+
* This file is part of HSuite Native Connect. For commercial licensing,
|
|
8
|
+
* visit https://hsuite.finance/licensing
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @module WidgetTypes
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
* Type definitions for the HSuite Wallet widget system.
|
|
15
|
+
* Widgets are Angular components that extend wallet functionality through a secure,
|
|
16
|
+
* permission-based architecture with support for free, subscription, and one-time purchase models.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @type WidgetType
|
|
21
|
+
* Widget monetization model
|
|
22
|
+
* - `freemium`: Free with optional donations (legacy, prefer 'free')
|
|
23
|
+
* - `free`: Completely free, no restrictions
|
|
24
|
+
* - `subscription`: Requires active subscription (recurring)
|
|
25
|
+
* - `one-time`: Single purchase, permanent access
|
|
26
|
+
*/
|
|
27
|
+
export type WidgetType = 'freemium' | 'free' | 'subscription' | 'one-time';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @type WidgetSize
|
|
31
|
+
* Widget display size in dashboard grid
|
|
32
|
+
*
|
|
33
|
+
* - `icon`: 100px square (app launcher shortcuts that open modals)
|
|
34
|
+
* - `small`: 300px max height (compact widgets, single stat displays)
|
|
35
|
+
* - `medium`: 500px max height (default, news feeds, price charts)
|
|
36
|
+
* - `large`: 700px max height (detailed analytics, transaction lists)
|
|
37
|
+
* - `full-width`: No height limit (expandable widgets, complex UIs)
|
|
38
|
+
*/
|
|
39
|
+
export type WidgetSize = 'icon' | 'small' | 'medium' | 'large' | 'full-width';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @interface GridCell
|
|
43
|
+
* Grid position and span for widget placement in the dashboard
|
|
44
|
+
*/
|
|
45
|
+
export interface GridCell {
|
|
46
|
+
/** Column index (0-based) */
|
|
47
|
+
column: number;
|
|
48
|
+
/** Row index (0-based) */
|
|
49
|
+
row: number;
|
|
50
|
+
/** Number of columns this item spans */
|
|
51
|
+
columnSpan: number;
|
|
52
|
+
/** Number of rows this item spans */
|
|
53
|
+
rowSpan: number;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @type WidgetCategory
|
|
58
|
+
* Widget functional category for organization and filtering
|
|
59
|
+
*/
|
|
60
|
+
export type WidgetCategory =
|
|
61
|
+
| 'defi'
|
|
62
|
+
| 'nft'
|
|
63
|
+
| 'analytics'
|
|
64
|
+
| 'security'
|
|
65
|
+
| 'news'
|
|
66
|
+
| 'tools'
|
|
67
|
+
| 'gaming';
|
|
68
|
+
|
|
69
|
+
// ─── V2 Experience Types ─────────────────────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @type ExperienceType
|
|
73
|
+
* Experience type classification for the unified Apps system.
|
|
74
|
+
* Defines what kind of experience this is from a UX perspective.
|
|
75
|
+
*
|
|
76
|
+
* - `widget`: Standalone embeddable component for the dashboard grid
|
|
77
|
+
* - `smart-app`: Fullscreen application that runs inside the wallet
|
|
78
|
+
* - `app-widget`: Mini-widget provided by a SmartApp (requires parentAppId)
|
|
79
|
+
* - `external-app`: Application that opens in a new browser tab
|
|
80
|
+
* - `b2b-service`: Backend-as-a-Service for developers (API only)
|
|
81
|
+
*/
|
|
82
|
+
export type ExperienceType = 'widget' | 'smart-app' | 'app-widget' | 'external-app' | 'b2b-service';
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @type ExecutionContext
|
|
86
|
+
* Where and how the experience runs.
|
|
87
|
+
*
|
|
88
|
+
* - `wallet-embedded`: Renders inside the wallet dashboard grid
|
|
89
|
+
* - `wallet-fullscreen`: Opens as a fullscreen modal inside the wallet
|
|
90
|
+
* - `external-tab`: Opens in a new browser tab
|
|
91
|
+
* - `api-only`: No UI, backend service only (for B2B services)
|
|
92
|
+
*/
|
|
93
|
+
export type ExecutionContext =
|
|
94
|
+
| 'wallet-embedded'
|
|
95
|
+
| 'wallet-fullscreen'
|
|
96
|
+
| 'external-tab'
|
|
97
|
+
| 'api-only';
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @type TargetAudience
|
|
101
|
+
* Target audience classification for marketplace filtering.
|
|
102
|
+
*
|
|
103
|
+
* - `end-user`: Personal wallet users
|
|
104
|
+
* - `organization`: Business/DAO accounts
|
|
105
|
+
* - `developer`: Builder tools, SDKs, and APIs
|
|
106
|
+
*/
|
|
107
|
+
export type TargetAudience = 'end-user' | 'organization' | 'developer';
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Infer the default execution context from an experience type.
|
|
111
|
+
* @param type - The experience type
|
|
112
|
+
* @returns The default execution context for that experience type
|
|
113
|
+
*/
|
|
114
|
+
export function inferExecutionContext(type: ExperienceType): ExecutionContext {
|
|
115
|
+
const contextMap: Record<ExperienceType, ExecutionContext> = {
|
|
116
|
+
widget: 'wallet-embedded',
|
|
117
|
+
'smart-app': 'wallet-fullscreen',
|
|
118
|
+
'app-widget': 'wallet-embedded',
|
|
119
|
+
'external-app': 'external-tab',
|
|
120
|
+
'b2b-service': 'api-only',
|
|
121
|
+
};
|
|
122
|
+
return contextMap[type];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @type WidgetPermission
|
|
127
|
+
* Permission types that widgets can request (similar to Android/iOS app permissions)
|
|
128
|
+
*/
|
|
129
|
+
export type WidgetPermission =
|
|
130
|
+
| 'read:accounts' // View account addresses and balances
|
|
131
|
+
| 'read:balances' // Read token/NFT balances
|
|
132
|
+
| 'read:transactions' // Access transaction history
|
|
133
|
+
| 'read:portfolio' // Access portfolio data (aggregated)
|
|
134
|
+
| 'sign:transactions' // Request transaction signing (always requires user approval)
|
|
135
|
+
| 'sign:messages' // Request message signing (always requires user approval)
|
|
136
|
+
| 'network:external' // Make external API calls
|
|
137
|
+
| 'storage:local' // Store data in local storage
|
|
138
|
+
| 'notifications:send' // Send browser notifications
|
|
139
|
+
| 'clipboard:write' // Write to clipboard
|
|
140
|
+
| 'camera:access' // Access camera (for QR scanning)
|
|
141
|
+
| 'write:themes'; // Create and save custom wallet themes
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @interface WidgetPermissionRequest
|
|
145
|
+
* Permission request with explanation for user consent
|
|
146
|
+
*/
|
|
147
|
+
export interface WidgetPermissionRequest {
|
|
148
|
+
/** Permission being requested */
|
|
149
|
+
permission: WidgetPermission;
|
|
150
|
+
/** Human-readable explanation of why this permission is needed */
|
|
151
|
+
reason: string;
|
|
152
|
+
/** Whether the widget can function without this permission */
|
|
153
|
+
optional: boolean;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @interface WidgetManifest
|
|
158
|
+
* Complete widget metadata and configuration
|
|
159
|
+
*/
|
|
160
|
+
export interface WidgetManifest {
|
|
161
|
+
/** Unique identifier (kebab-case, e.g., 'portfolio-tracker') */
|
|
162
|
+
id: string;
|
|
163
|
+
/** Display name */
|
|
164
|
+
name: string;
|
|
165
|
+
/** Short description (2-3 sentences) */
|
|
166
|
+
description: string;
|
|
167
|
+
/** Semantic version (e.g., '1.0.0') */
|
|
168
|
+
version: string;
|
|
169
|
+
/** GitHub username or contributor name */
|
|
170
|
+
author: string;
|
|
171
|
+
/** Monetization model */
|
|
172
|
+
type: WidgetType;
|
|
173
|
+
/** Functional category */
|
|
174
|
+
category: WidgetCategory;
|
|
175
|
+
/** Default display size */
|
|
176
|
+
size: WidgetSize;
|
|
177
|
+
/** Ionicon name (e.g., 'analytics-outline') or SVG path */
|
|
178
|
+
icon: string;
|
|
179
|
+
|
|
180
|
+
// Permission system
|
|
181
|
+
/** Required and optional permissions with explanations */
|
|
182
|
+
permissions: WidgetPermissionRequest[];
|
|
183
|
+
/** Account access level */
|
|
184
|
+
accountAccess: 'none' | 'single' | 'multiple' | 'all';
|
|
185
|
+
|
|
186
|
+
// Monetization
|
|
187
|
+
/** Optional donation address for free widgets */
|
|
188
|
+
donationAddress?: string;
|
|
189
|
+
/** SmartApp ID from marketplace registry (required for subscription widgets) */
|
|
190
|
+
smartAppId?: string;
|
|
191
|
+
|
|
192
|
+
// API permissions
|
|
193
|
+
/** Whitelisted API endpoints widget can access */
|
|
194
|
+
apiEndpoints: string[];
|
|
195
|
+
/** Whether widget makes external network calls */
|
|
196
|
+
networkAccess: boolean;
|
|
197
|
+
|
|
198
|
+
// Display assets
|
|
199
|
+
/** Preview image path (e.g., 'assets/widget-previews/portfolio-tracker.png') */
|
|
200
|
+
previewImage: string;
|
|
201
|
+
/** Array of screenshot paths (minimum 2) */
|
|
202
|
+
screenshots: string[];
|
|
203
|
+
/** Tags for search and filtering (lowercase) */
|
|
204
|
+
tags: string[];
|
|
205
|
+
|
|
206
|
+
// Metadata
|
|
207
|
+
/** ISO date string (e.g., '2025-01-15') */
|
|
208
|
+
dateCreated: string;
|
|
209
|
+
/** Whether widget respects theme CSS variables */
|
|
210
|
+
themeCompatible: boolean;
|
|
211
|
+
/** Whether widget supports responsive breakpoints */
|
|
212
|
+
responsive: boolean;
|
|
213
|
+
/** Whether widget can register a full-page route */
|
|
214
|
+
hasFullPage?: boolean;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ─── V2 Extended Manifest ────────────────────────────────────────────────────
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @interface WidgetManifestV2
|
|
221
|
+
* Extended widget manifest with V2 experience type classification.
|
|
222
|
+
* All new fields are optional for backwards compatibility with existing widgets.
|
|
223
|
+
*/
|
|
224
|
+
export interface WidgetManifestV2 extends WidgetManifest {
|
|
225
|
+
/**
|
|
226
|
+
* Experience type classification.
|
|
227
|
+
* Defaults to 'widget' if not specified.
|
|
228
|
+
*/
|
|
229
|
+
experienceType?: ExperienceType;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Execution context - where/how the experience runs.
|
|
233
|
+
* If not specified, will be inferred from experienceType using inferExecutionContext().
|
|
234
|
+
*/
|
|
235
|
+
executionContext?: ExecutionContext;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Target audience classification.
|
|
239
|
+
* Defaults to 'end-user' if not specified.
|
|
240
|
+
*/
|
|
241
|
+
targetAudience?: TargetAudience;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Parent SmartApp ID.
|
|
245
|
+
* Required for 'app-widget' experience type to establish parent relationship.
|
|
246
|
+
*/
|
|
247
|
+
parentAppId?: string;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* External URL for external-app experience type.
|
|
251
|
+
* The URL that will be opened in a new browser tab.
|
|
252
|
+
*/
|
|
253
|
+
externalUrl?: string;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* API endpoint for B2B services.
|
|
257
|
+
* Base URL for the service's API documentation or integration endpoint.
|
|
258
|
+
*/
|
|
259
|
+
serviceEndpoint?: string;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Whether this app is featured in the marketplace.
|
|
263
|
+
* Featured apps appear prominently in marketplace listings.
|
|
264
|
+
*/
|
|
265
|
+
featured?: boolean;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Sort priority for marketplace display.
|
|
269
|
+
* Higher values appear first. Defaults to 0.
|
|
270
|
+
*/
|
|
271
|
+
sortPriority?: number;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Price in USD cents for one-time purchase.
|
|
275
|
+
* Only applicable when type is 'one-time'.
|
|
276
|
+
* Example: 4999 = $49.99
|
|
277
|
+
*/
|
|
278
|
+
priceUsdCents?: number;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Monthly subscription price in USD cents.
|
|
282
|
+
* Only applicable when type is 'subscription'.
|
|
283
|
+
* Example: 999 = $9.99/month
|
|
284
|
+
*/
|
|
285
|
+
subscriptionPriceUsdCents?: number;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Widget IDs that are included with this smart-app.
|
|
289
|
+
* When the parent app is installed, these widgets become available.
|
|
290
|
+
*/
|
|
291
|
+
includedWidgetIds?: string[];
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Supported ledger IDs for this widget.
|
|
295
|
+
* If specified, the widget will only be available for accounts on these ledgers.
|
|
296
|
+
* Format: ledger ID (e.g., 'hedera', 'xrpl')
|
|
297
|
+
*/
|
|
298
|
+
supportedLedgers?: string[];
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Supported network IDs for this widget.
|
|
302
|
+
* If specified, the widget will only be available for accounts on these networks.
|
|
303
|
+
* Format: 'ledger:network' (e.g., 'xrpl:mainnet', 'hedera:mainnet', 'xrpl:testnet')
|
|
304
|
+
*/
|
|
305
|
+
supportedNetworks?: string[];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Type guard to check if a manifest is V2 (has experience type fields).
|
|
310
|
+
* @param manifest - The manifest to check
|
|
311
|
+
* @returns True if the manifest has V2 experience type fields
|
|
312
|
+
*/
|
|
313
|
+
export function isManifestV2(manifest: WidgetManifest): manifest is WidgetManifestV2 {
|
|
314
|
+
return (
|
|
315
|
+
'experienceType' in manifest || 'executionContext' in manifest || 'targetAudience' in manifest
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Normalize a manifest to V2 format with sensible defaults.
|
|
321
|
+
* This function is non-destructive and returns a new object.
|
|
322
|
+
* @param manifest - The manifest to normalize
|
|
323
|
+
* @returns A WidgetManifestV2 with all V2 fields populated
|
|
324
|
+
*/
|
|
325
|
+
export function normalizeManifestToV2(manifest: WidgetManifest): WidgetManifestV2 {
|
|
326
|
+
const v2 = { ...manifest } as WidgetManifestV2;
|
|
327
|
+
|
|
328
|
+
// Infer experienceType from hasFullPage if not set
|
|
329
|
+
if (!v2.experienceType) {
|
|
330
|
+
v2.experienceType = v2.hasFullPage ? 'smart-app' : 'widget';
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Infer executionContext from experienceType if not set
|
|
334
|
+
if (!v2.executionContext) {
|
|
335
|
+
v2.executionContext = inferExecutionContext(v2.experienceType);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Default audience to end-user
|
|
339
|
+
if (!v2.targetAudience) {
|
|
340
|
+
v2.targetAudience = 'end-user';
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Default sort priority
|
|
344
|
+
if (v2.sortPriority === undefined) {
|
|
345
|
+
v2.sortPriority = 0;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Default featured to false
|
|
349
|
+
if (v2.featured === undefined) {
|
|
350
|
+
v2.featured = false;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return v2;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @interface HsuiteWidget
|
|
358
|
+
* Complete widget definition combining manifest and component
|
|
359
|
+
* Note: component is 'unknown' type to avoid Angular dependency in types package
|
|
360
|
+
*/
|
|
361
|
+
export interface HsuiteWidget {
|
|
362
|
+
/** Widget metadata and configuration (supports V2 fields like experienceType) */
|
|
363
|
+
manifest: WidgetManifestV2;
|
|
364
|
+
/** Angular component class */
|
|
365
|
+
component: unknown; // Type<unknown> from @angular/core, but we don't import Angular here
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @interface WidgetInstallation
|
|
370
|
+
* User's installed widget instance with permissions
|
|
371
|
+
*/
|
|
372
|
+
export interface WidgetInstallation {
|
|
373
|
+
/** Widget ID */
|
|
374
|
+
widgetId: string;
|
|
375
|
+
/** Granted permissions */
|
|
376
|
+
grantedPermissions: WidgetPermission[];
|
|
377
|
+
/** Allowed account addresses */
|
|
378
|
+
allowedAccounts: string[];
|
|
379
|
+
/** Installation timestamp */
|
|
380
|
+
installedAt: number;
|
|
381
|
+
/** Current size override */
|
|
382
|
+
currentSize: WidgetSize;
|
|
383
|
+
/** Dashboard position (for grid layout) */
|
|
384
|
+
gridPosition?: {
|
|
385
|
+
row: number;
|
|
386
|
+
column: number;
|
|
387
|
+
};
|
|
388
|
+
/** Display order for sorting (lower values appear first) */
|
|
389
|
+
displayOrder?: number;
|
|
390
|
+
/** Whether this item is shown in the app dock (for smart-apps/external-apps) */
|
|
391
|
+
inDock?: boolean;
|
|
392
|
+
/** Explicit grid span override (calculated from size if not provided) */
|
|
393
|
+
gridSpan?: {
|
|
394
|
+
columnSpan: number;
|
|
395
|
+
rowSpan: number;
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* @interface WidgetSettings
|
|
401
|
+
* Widget-specific user settings stored in IndexedDB
|
|
402
|
+
*/
|
|
403
|
+
export interface WidgetSettings {
|
|
404
|
+
/** Widget ID */
|
|
405
|
+
widgetId: string;
|
|
406
|
+
/** User-configurable settings (widget-defined schema) */
|
|
407
|
+
settings: Record<string, unknown>;
|
|
408
|
+
/** Last updated timestamp */
|
|
409
|
+
updatedAt: number;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* @interface WidgetRegistry
|
|
414
|
+
* Registry of all available widgets in the application
|
|
415
|
+
*/
|
|
416
|
+
export interface WidgetRegistry {
|
|
417
|
+
/** Map of widget ID to widget definition */
|
|
418
|
+
widgets: Map<string, HsuiteWidget>;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Whitelisted API endpoints for free widgets
|
|
423
|
+
* @deprecated Use FREE_API_WHITELIST instead
|
|
424
|
+
*/
|
|
425
|
+
export const FREEMIUM_API_WHITELIST = [
|
|
426
|
+
'api.coingecko.com',
|
|
427
|
+
'pro-api.coinmarketcap.com',
|
|
428
|
+
'min-api.cryptocompare.com',
|
|
429
|
+
'cryptopanic.com/api',
|
|
430
|
+
'data.messari.io/api',
|
|
431
|
+
'api.alternative.me',
|
|
432
|
+
] as const;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Permission display metadata
|
|
436
|
+
*/
|
|
437
|
+
export const PERMISSION_METADATA: Record<
|
|
438
|
+
WidgetPermission,
|
|
439
|
+
{ label: string; icon: string; risk: 'low' | 'medium' | 'high' }
|
|
440
|
+
> = {
|
|
441
|
+
'read:accounts': {
|
|
442
|
+
label: 'View your account addresses',
|
|
443
|
+
icon: 'person-outline',
|
|
444
|
+
risk: 'low',
|
|
445
|
+
},
|
|
446
|
+
'read:balances': {
|
|
447
|
+
label: 'View your token balances',
|
|
448
|
+
icon: 'wallet-outline',
|
|
449
|
+
risk: 'low',
|
|
450
|
+
},
|
|
451
|
+
'read:transactions': {
|
|
452
|
+
label: 'View your transaction history',
|
|
453
|
+
icon: 'list-outline',
|
|
454
|
+
risk: 'low',
|
|
455
|
+
},
|
|
456
|
+
'read:portfolio': {
|
|
457
|
+
label: 'View your portfolio summary',
|
|
458
|
+
icon: 'pie-chart-outline',
|
|
459
|
+
risk: 'low',
|
|
460
|
+
},
|
|
461
|
+
'sign:transactions': {
|
|
462
|
+
label: 'Request transaction signatures',
|
|
463
|
+
icon: 'create-outline',
|
|
464
|
+
risk: 'high',
|
|
465
|
+
},
|
|
466
|
+
'sign:messages': {
|
|
467
|
+
label: 'Request message signatures',
|
|
468
|
+
icon: 'document-text-outline',
|
|
469
|
+
risk: 'medium',
|
|
470
|
+
},
|
|
471
|
+
'network:external': {
|
|
472
|
+
label: 'Connect to external services',
|
|
473
|
+
icon: 'globe-outline',
|
|
474
|
+
risk: 'medium',
|
|
475
|
+
},
|
|
476
|
+
'storage:local': {
|
|
477
|
+
label: 'Store widget settings',
|
|
478
|
+
icon: 'save-outline',
|
|
479
|
+
risk: 'low',
|
|
480
|
+
},
|
|
481
|
+
'notifications:send': {
|
|
482
|
+
label: 'Send notifications',
|
|
483
|
+
icon: 'notifications-outline',
|
|
484
|
+
risk: 'low',
|
|
485
|
+
},
|
|
486
|
+
'clipboard:write': {
|
|
487
|
+
label: 'Copy to clipboard',
|
|
488
|
+
icon: 'clipboard-outline',
|
|
489
|
+
risk: 'low',
|
|
490
|
+
},
|
|
491
|
+
'camera:access': {
|
|
492
|
+
label: 'Access camera for QR codes',
|
|
493
|
+
icon: 'camera-outline',
|
|
494
|
+
risk: 'medium',
|
|
495
|
+
},
|
|
496
|
+
'write:themes': {
|
|
497
|
+
label: 'Create and save custom themes',
|
|
498
|
+
icon: 'brush-outline',
|
|
499
|
+
risk: 'low',
|
|
500
|
+
},
|
|
501
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"declarationMap": true,
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"module": "ESNext",
|
|
10
|
+
"target": "ES2022",
|
|
11
|
+
"lib": ["ES2022", "DOM"],
|
|
12
|
+
"rootDir": "src",
|
|
13
|
+
"skipLibCheck": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*.ts"],
|
|
16
|
+
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
17
|
+
}
|
package/tsconfig.json
ADDED
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
import { defineConfig } from 'vitest/config';
|
|
12
|
+
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
test: {
|
|
15
|
+
environment: 'node',
|
|
16
|
+
globals: true,
|
|
17
|
+
include: ['src/**/*.spec.ts'],
|
|
18
|
+
coverage: {
|
|
19
|
+
provider: 'v8',
|
|
20
|
+
reporter: ['text', 'lcov', 'html', 'json-summary'],
|
|
21
|
+
// Types package with Zod validation - maintain high coverage
|
|
22
|
+
statements: 80,
|
|
23
|
+
branches: 75,
|
|
24
|
+
functions: 80,
|
|
25
|
+
lines: 80,
|
|
26
|
+
exclude: [
|
|
27
|
+
'**/node_modules/**',
|
|
28
|
+
'**/dist/**',
|
|
29
|
+
'**/*.spec.ts',
|
|
30
|
+
'**/*.test.ts',
|
|
31
|
+
'**/test/**',
|
|
32
|
+
'**/index.ts',
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|