@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,88 @@
|
|
|
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
|
+
* @description Result wrapper for async-enriched values.
|
|
12
|
+
*
|
|
13
|
+
* The wallet's approval UI surfaces values that are derived from network
|
|
14
|
+
* sources (Mirror Node token metadata, NFT thumbnails, account labels,
|
|
15
|
+
* fee schedules, etc). These fetches can fail; they can return stale
|
|
16
|
+
* cached data; they can be in-flight when the consumer needs to render.
|
|
17
|
+
*
|
|
18
|
+
* Wrapping every enriched value in a {@link EnrichmentResult} forces every
|
|
19
|
+
* consumer to handle all four states explicitly, instead of getting
|
|
20
|
+
* surprised by undefined data mid-render:
|
|
21
|
+
*
|
|
22
|
+
* - `fresh` — the value was just fetched and is current.
|
|
23
|
+
* - `cached` — the value is from a previous fetch; may be stale.
|
|
24
|
+
* - `missing` — the cache has no entry yet; a fetch is fired but the
|
|
25
|
+
* caller gets a safe-default value to render immediately.
|
|
26
|
+
* - `error` — fetch failed (timeout, 4xx, 5xx). Safe-default value
|
|
27
|
+
* still present so the UI degrades gracefully.
|
|
28
|
+
*
|
|
29
|
+
* The wrapper always carries a `value` — never `undefined`. Pipes and
|
|
30
|
+
* templates can render unconditionally; the `status` drives any optional
|
|
31
|
+
* "verified / pending / error" decoration.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam T - The enriched payload type (e.g., token metadata).
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const result = tokenCache.get(tokenId, networkId);
|
|
38
|
+
* switch (result.status) {
|
|
39
|
+
* case 'fresh':
|
|
40
|
+
* case 'cached':
|
|
41
|
+
* return `${result.value.symbol} (${result.value.decimals} decimals)`;
|
|
42
|
+
* case 'missing':
|
|
43
|
+
* return `${tokenId} (loading…)`;
|
|
44
|
+
* case 'error':
|
|
45
|
+
* return `${tokenId} (unverified)`;
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export interface EnrichmentResult<T> {
|
|
50
|
+
/** The enriched value. Always defined; for non-fresh statuses, a safe default. */
|
|
51
|
+
value: T;
|
|
52
|
+
/** Current state of the enrichment for this entry. */
|
|
53
|
+
status: 'fresh' | 'cached' | 'missing' | 'error';
|
|
54
|
+
/** Unix ms when the value was last fetched. Undefined for `missing` entries. */
|
|
55
|
+
fetchedAt?: number;
|
|
56
|
+
/** Optional error message when `status === 'error'`. */
|
|
57
|
+
error?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Factory helpers for {@link EnrichmentResult}. Use these in cache
|
|
61
|
+
* services and tests to keep construction consistent across the
|
|
62
|
+
* codebase — never construct the object literally.
|
|
63
|
+
*/
|
|
64
|
+
export declare const enrichmentResult: {
|
|
65
|
+
/**
|
|
66
|
+
* Returns a `fresh` result with the current timestamp.
|
|
67
|
+
* @param value
|
|
68
|
+
*/
|
|
69
|
+
readonly fresh: <T>(value: T) => EnrichmentResult<T>;
|
|
70
|
+
/**
|
|
71
|
+
* Returns a `cached` result; supply the original fetch timestamp.
|
|
72
|
+
* @param value
|
|
73
|
+
* @param fetchedAt
|
|
74
|
+
*/
|
|
75
|
+
readonly cached: <T>(value: T, fetchedAt: number) => EnrichmentResult<T>;
|
|
76
|
+
/**
|
|
77
|
+
* Returns a `missing` result with the caller-supplied safe default.
|
|
78
|
+
* @param safeDefault
|
|
79
|
+
*/
|
|
80
|
+
readonly missing: <T>(safeDefault: T) => EnrichmentResult<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Returns an `error` result with the caller-supplied safe default + message.
|
|
83
|
+
* @param safeDefault
|
|
84
|
+
* @param message
|
|
85
|
+
*/
|
|
86
|
+
readonly error: <T>(safeDefault: T, message: string) => EnrichmentResult<T>;
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=enrichment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.d.ts","sourceRoot":"","sources":["../src/enrichment.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,kFAAkF;IAClF,KAAK,EAAE,CAAC,CAAC;IACT,sDAAsD;IACtD,MAAM,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;;OAGG;qBACG,CAAC,SAAS,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAAC;IAGvC;;;;OAIG;sBACI,CAAC,SAAS,CAAC,aAAa,MAAM,KAAG,gBAAgB,CAAC,CAAC,CAAC;IAG3D;;;OAGG;uBACK,CAAC,eAAe,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAAC;IAG/C;;;;OAIG;qBACG,CAAC,eAAe,CAAC,WAAW,MAAM,KAAG,gBAAgB,CAAC,CAAC,CAAC;CAGtD,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
* Factory helpers for {@link EnrichmentResult}. Use these in cache
|
|
12
|
+
* services and tests to keep construction consistent across the
|
|
13
|
+
* codebase — never construct the object literally.
|
|
14
|
+
*/
|
|
15
|
+
export const enrichmentResult = {
|
|
16
|
+
/**
|
|
17
|
+
* Returns a `fresh` result with the current timestamp.
|
|
18
|
+
* @param value
|
|
19
|
+
*/
|
|
20
|
+
fresh(value) {
|
|
21
|
+
return { value, status: 'fresh', fetchedAt: Date.now() };
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Returns a `cached` result; supply the original fetch timestamp.
|
|
25
|
+
* @param value
|
|
26
|
+
* @param fetchedAt
|
|
27
|
+
*/
|
|
28
|
+
cached(value, fetchedAt) {
|
|
29
|
+
return { value, status: 'cached', fetchedAt };
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Returns a `missing` result with the caller-supplied safe default.
|
|
33
|
+
* @param safeDefault
|
|
34
|
+
*/
|
|
35
|
+
missing(safeDefault) {
|
|
36
|
+
return { value: safeDefault, status: 'missing' };
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Returns an `error` result with the caller-supplied safe default + message.
|
|
40
|
+
* @param safeDefault
|
|
41
|
+
* @param message
|
|
42
|
+
*/
|
|
43
|
+
error(safeDefault, message) {
|
|
44
|
+
return { value: safeDefault, status: 'error', error: message };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=enrichment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.js","sourceRoot":"","sources":["../src/enrichment.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoDH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B;;;OAGG;IACH,KAAK,CAAI,KAAQ;QACf,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAC3D,CAAC;IACD;;;;OAIG;IACH,MAAM,CAAI,KAAQ,EAAE,SAAiB;QACnC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAChD,CAAC;IACD;;;OAGG;IACH,OAAO,CAAI,WAAc;QACvB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACnD,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAI,WAAc,EAAE,OAAe;QACtC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACjE,CAAC;CACO,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
* Hedera node accounts that receive node-fee debits.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Hedera mainnet has ~32 active consensus nodes whose account IDs run from
|
|
15
|
+
* `0.0.3` through `0.0.34`. Every transaction's node-fee component is paid
|
|
16
|
+
* to whichever node submitted the transaction — so any of these account IDs
|
|
17
|
+
* may appear as a positive-amount transfer in a transaction's HBAR transfer
|
|
18
|
+
* list.
|
|
19
|
+
*
|
|
20
|
+
* Filter against this set when you need to distinguish "node fee" debits
|
|
21
|
+
* from genuine user transfers.
|
|
22
|
+
*/
|
|
23
|
+
export declare const HEDERA_NODE_ACCOUNTS: ReadonlySet<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Hedera fee/reward collector accounts (non-node).
|
|
26
|
+
*
|
|
27
|
+
* @description
|
|
28
|
+
* - `0.0.98` — main Hedera fee collection treasury.
|
|
29
|
+
* - `0.0.800` — staking reward distribution account.
|
|
30
|
+
* - `0.0.801` — node reward distribution account.
|
|
31
|
+
*/
|
|
32
|
+
export declare const HEDERA_FEE_COLLECTOR_ACCOUNTS: ReadonlySet<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Union of all Hedera system accounts: nodes + explicit fee/reward collectors.
|
|
35
|
+
*
|
|
36
|
+
* @description
|
|
37
|
+
* Canonical set used to filter system-level transfers out of user-facing
|
|
38
|
+
* displays (transaction history, transfer breakdowns, etc.). These accounts
|
|
39
|
+
* receive node fees, Hedera fees, and staking/node rewards — they appear in
|
|
40
|
+
* every transaction's transfer list but are noise from a wallet UX
|
|
41
|
+
* perspective.
|
|
42
|
+
*
|
|
43
|
+
* Cross-package consumers (the wallet UI, the ledger-hedera adapter) MUST
|
|
44
|
+
* import this set from `@hsuite/native-connect-types` so the filter stays in
|
|
45
|
+
* lock-step with the parser. Any new system account must be added here, not
|
|
46
|
+
* forked locally.
|
|
47
|
+
*/
|
|
48
|
+
export declare const HEDERA_SYSTEM_ACCOUNTS: ReadonlySet<string>;
|
|
49
|
+
//# sourceMappingURL=hedera-system-accounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera-system-accounts.d.ts","sourceRoot":"","sources":["../src/hedera-system-accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAEpD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,MAAM,CAI5D,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAGrD,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
* Hedera node accounts that receive node-fee debits.
|
|
12
|
+
*
|
|
13
|
+
* @description
|
|
14
|
+
* Hedera mainnet has ~32 active consensus nodes whose account IDs run from
|
|
15
|
+
* `0.0.3` through `0.0.34`. Every transaction's node-fee component is paid
|
|
16
|
+
* to whichever node submitted the transaction — so any of these account IDs
|
|
17
|
+
* may appear as a positive-amount transfer in a transaction's HBAR transfer
|
|
18
|
+
* list.
|
|
19
|
+
*
|
|
20
|
+
* Filter against this set when you need to distinguish "node fee" debits
|
|
21
|
+
* from genuine user transfers.
|
|
22
|
+
*/
|
|
23
|
+
export const HEDERA_NODE_ACCOUNTS = new Set(Array.from({ length: 32 }, (_, i) => `0.0.${i + 3}`));
|
|
24
|
+
/**
|
|
25
|
+
* Hedera fee/reward collector accounts (non-node).
|
|
26
|
+
*
|
|
27
|
+
* @description
|
|
28
|
+
* - `0.0.98` — main Hedera fee collection treasury.
|
|
29
|
+
* - `0.0.800` — staking reward distribution account.
|
|
30
|
+
* - `0.0.801` — node reward distribution account.
|
|
31
|
+
*/
|
|
32
|
+
export const HEDERA_FEE_COLLECTOR_ACCOUNTS = new Set([
|
|
33
|
+
'0.0.98',
|
|
34
|
+
'0.0.800',
|
|
35
|
+
'0.0.801',
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* Union of all Hedera system accounts: nodes + explicit fee/reward collectors.
|
|
39
|
+
*
|
|
40
|
+
* @description
|
|
41
|
+
* Canonical set used to filter system-level transfers out of user-facing
|
|
42
|
+
* displays (transaction history, transfer breakdowns, etc.). These accounts
|
|
43
|
+
* receive node fees, Hedera fees, and staking/node rewards — they appear in
|
|
44
|
+
* every transaction's transfer list but are noise from a wallet UX
|
|
45
|
+
* perspective.
|
|
46
|
+
*
|
|
47
|
+
* Cross-package consumers (the wallet UI, the ledger-hedera adapter) MUST
|
|
48
|
+
* import this set from `@hsuite/native-connect-types` so the filter stays in
|
|
49
|
+
* lock-step with the parser. Any new system account must be added here, not
|
|
50
|
+
* forked locally.
|
|
51
|
+
*/
|
|
52
|
+
export const HEDERA_SYSTEM_ACCOUNTS = new Set([
|
|
53
|
+
...HEDERA_NODE_ACCOUNTS,
|
|
54
|
+
...HEDERA_FEE_COLLECTOR_ACCOUNTS,
|
|
55
|
+
]);
|
|
56
|
+
//# sourceMappingURL=hedera-system-accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hedera-system-accounts.js","sourceRoot":"","sources":["../src/hedera-system-accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAC9D,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CACrD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAwB,IAAI,GAAG,CAAC;IACxE,QAAQ;IACR,SAAS;IACT,SAAS;CACV,CAAC,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC;IACjE,GAAG,oBAAoB;IACvB,GAAG,6BAA6B;CACjC,CAAC,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
* A reference to a party member, carrying either the member's on-chain
|
|
12
|
+
* address (Hedera account id, XRPL rAddress, etc.) or the member's
|
|
13
|
+
* cryptographic public key, or both.
|
|
14
|
+
*
|
|
15
|
+
* Both fields are optional because different ledgers and different
|
|
16
|
+
* lookup paths surface different combinations:
|
|
17
|
+
*
|
|
18
|
+
* - **Hedera multisig signers** typically carry only a `publicKey` (the
|
|
19
|
+
* account is materialized from the key).
|
|
20
|
+
* - **XRPL multisig signers** carry both an `address` (the rAddress, the
|
|
21
|
+
* on-chain identity) and a `publicKey` (the secp256k1 / Ed25519 pubkey
|
|
22
|
+
* used to verify signatures).
|
|
23
|
+
* - **Wallet-local signers** carry an `address` (the local account's
|
|
24
|
+
* primary identifier) and usually a `publicKey` derived at key-import
|
|
25
|
+
* time.
|
|
26
|
+
*
|
|
27
|
+
* The matcher {@link matchesMemberIdentity} accepts any of these
|
|
28
|
+
* combinations and resolves them against a canonical id string by trying
|
|
29
|
+
* each populated field independently.
|
|
30
|
+
*
|
|
31
|
+
* Empty-string fields are treated as absent — they carry no useful
|
|
32
|
+
* information and must not collapse to a normalized empty string that
|
|
33
|
+
* happens to match another empty-string identity.
|
|
34
|
+
*/
|
|
35
|
+
export interface MemberIdentity {
|
|
36
|
+
/** On-chain address for the member, if known. */
|
|
37
|
+
address?: string;
|
|
38
|
+
/** Public key for the member (any supported wire format), if known. */
|
|
39
|
+
publicKey?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Normalize a member-identity field (address OR publicKey) to its raw
|
|
43
|
+
* canonical hex / lowercase form so two callers with the same underlying
|
|
44
|
+
* key in different wire formats compare equal.
|
|
45
|
+
*
|
|
46
|
+
* @param value - Hex pubkey (with or without DER / XRPL / `0x` wrappers)
|
|
47
|
+
* or an on-chain address (Hedera account id, XRPL rAddress, anything
|
|
48
|
+
* else opaque). Empty string is accepted and returns empty string.
|
|
49
|
+
* @returns Normalized lowercase string. Returns empty string only for
|
|
50
|
+
* empty input. Two distinct keys remain distinct after normalization;
|
|
51
|
+
* the function only strips wrappers whose semantics are "this is the
|
|
52
|
+
* same key in a different encoding."
|
|
53
|
+
*/
|
|
54
|
+
export declare function normalizeIdentityKey(value: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Does the given `canonicalId` (an SDK-derived signature-store key)
|
|
57
|
+
* refer to the given `identity`?
|
|
58
|
+
*
|
|
59
|
+
* Tries each populated identity field independently against the
|
|
60
|
+
* canonical id, normalized through {@link normalizeIdentityKey}. Returns
|
|
61
|
+
* true if EITHER the `publicKey` field or the `address` field — after
|
|
62
|
+
* normalization — equals the canonical id.
|
|
63
|
+
*
|
|
64
|
+
* ## Why "either" is correct
|
|
65
|
+
*
|
|
66
|
+
* The SDK's `canonicalMemberId(member)` prefers `member.publicKey` when
|
|
67
|
+
* present, falling back to `member.address`. Wallets that resolve "this
|
|
68
|
+
* is the local pilot" might end up with an identity carrying only the
|
|
69
|
+
* address (e.g. legacy XRPL invitations) or only the publicKey (Hedera
|
|
70
|
+
* raw key import), or both. The matcher must succeed in all three cases
|
|
71
|
+
* — otherwise a legitimate filter silently no-ops and the UI lies about
|
|
72
|
+
* signature progress.
|
|
73
|
+
*
|
|
74
|
+
* ## Empty / unusable identity guard
|
|
75
|
+
*
|
|
76
|
+
* Returns false when:
|
|
77
|
+
*
|
|
78
|
+
* - The canonical id is empty (defensive — an empty canonical id should
|
|
79
|
+
* never appear in practice, but guarding here prevents a stray empty
|
|
80
|
+
* entry from matching every empty identity).
|
|
81
|
+
* - The identity has neither field populated.
|
|
82
|
+
* - The identity has only empty-string fields.
|
|
83
|
+
*
|
|
84
|
+
* This guarantees that "I don't know who the pilot is" never silently
|
|
85
|
+
* matches arbitrary members.
|
|
86
|
+
*
|
|
87
|
+
* @param canonicalId - SDK-derived signature-store key (output of
|
|
88
|
+
* `canonicalMemberId(member)` on the SDK side).
|
|
89
|
+
* @param identity - Wallet-resolved identity (address and/or publicKey)
|
|
90
|
+
* to test against the canonical id.
|
|
91
|
+
* @returns True if the identity refers to the canonical id, false otherwise.
|
|
92
|
+
*/
|
|
93
|
+
export declare function matchesMemberIdentity(canonicalId: string, identity: MemberIdentity): boolean;
|
|
94
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8FH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,cAAc;IAC7B,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA6B1D;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAmB5F"}
|
package/dist/identity.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
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 Cross-package member identity contract for multisig flows.
|
|
12
|
+
* @module @hsuite/native-connect-types/identity
|
|
13
|
+
*
|
|
14
|
+
* @description
|
|
15
|
+
* Defines the small, pure surface that ties the SDK's
|
|
16
|
+
* `canonicalMemberId(member)` output (the strings the SDK uses as keys in
|
|
17
|
+
* `proposal.progress.members`) to the wallet UI's pilot-filter logic.
|
|
18
|
+
*
|
|
19
|
+
* ## Why this lives in `wallet-connect-types`
|
|
20
|
+
*
|
|
21
|
+
* The SDK owns the canonical id derivation (see
|
|
22
|
+
* `packages/native-wallet-sdk/src/multisig/member-identity.ts`). The UI
|
|
23
|
+
* package owns the rendering of "X of Y member signatures" and needs to
|
|
24
|
+
* compare a wallet-resolved "this is the pilot" identity against the
|
|
25
|
+
* SDK-populated `members[]` strings. Putting the matcher in a heavyweight
|
|
26
|
+
* package (SDK) would either drag SDK runtime deps into the UI bundle or
|
|
27
|
+
* force a duplicate normalize implementation in the UI — both DRY
|
|
28
|
+
* violations. `wallet-connect-types` is the no-runtime-deps shared
|
|
29
|
+
* boundary both packages already depend on, so the matcher lives here.
|
|
30
|
+
*
|
|
31
|
+
* The SDK re-exports {@link MemberIdentity} and {@link matchesMemberIdentity}
|
|
32
|
+
* from its own `multisig/index.ts` so SDK consumers can also pick them up
|
|
33
|
+
* via `@hsuite/native-connect-sdk` without learning a second package name.
|
|
34
|
+
*
|
|
35
|
+
* ## The bug this prevents
|
|
36
|
+
*
|
|
37
|
+
* Before this contract existed, the wallet UI compared the pilot's
|
|
38
|
+
* rAddress (e.g. `rEQn…`) against `progress.members[0] = '02c9742b…'`
|
|
39
|
+
* (XRPL secp256k1 pubkey, populated by the SDK via `canonicalMemberId`
|
|
40
|
+
* which prefers `publicKey`). The `!==` filter was a no-op on XRPL and
|
|
41
|
+
* the UI rendered "1 of 1 — Ready! You can now sign & submit." for a
|
|
42
|
+
* 2-of-2 multisig where no cosigner had signed. See the live incident at
|
|
43
|
+
* `multisig-update:.multisig-p2p/evidence/sign-progress-1of1-bug.md`.
|
|
44
|
+
*
|
|
45
|
+
* ## Normalization algorithm
|
|
46
|
+
*
|
|
47
|
+
* The same algorithm the SDK uses for its canonical id derivation, minus
|
|
48
|
+
* the SDK-specific PKCS#8 private-key leak detection (which is a separate
|
|
49
|
+
* security concern handled at key-loading boundaries, not comparison
|
|
50
|
+
* boundaries). Strips, in order:
|
|
51
|
+
*
|
|
52
|
+
* 1. `0x` / `0X` hex prefix.
|
|
53
|
+
* 2. Case (lowercased).
|
|
54
|
+
* 3. XRPL Ed25519 `ed` byte prefix when length is exactly 66 hex chars
|
|
55
|
+
* (33 bytes — XRPL's wire encoding for Ed25519 pubkeys).
|
|
56
|
+
* 4. Ed25519 DER wrapper (`302a300506032b6570032100` + 32 raw bytes)
|
|
57
|
+
* when length is exactly 88 hex chars.
|
|
58
|
+
* 5. ECDSA secp256k1 uncompressed DER wrapper
|
|
59
|
+
* (`3056301006072a8648ce3d020106052b8104000a034200` + 65 raw bytes)
|
|
60
|
+
* when length is exactly 176 hex chars.
|
|
61
|
+
*
|
|
62
|
+
* Anything not matching one of those wrappers is returned unchanged
|
|
63
|
+
* (lowercase). Two genuinely different keys remain different after
|
|
64
|
+
* normalization — the function only strips wrappers whose semantics are
|
|
65
|
+
* "same key in a different encoding", never rewrites key material.
|
|
66
|
+
*/
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Wire-format prefixes
|
|
69
|
+
// ============================================================================
|
|
70
|
+
/**
|
|
71
|
+
* Ed25519 DER-wrapped public key prefix.
|
|
72
|
+
*
|
|
73
|
+
* Hex representation: `302a300506032b6570032100` (12 bytes / 24 hex chars).
|
|
74
|
+
* Followed by 32 bytes (64 hex chars) of raw key → total 88 hex chars.
|
|
75
|
+
*/
|
|
76
|
+
const ED25519_DER_PREFIX = '302a300506032b6570032100';
|
|
77
|
+
/**
|
|
78
|
+
* ECDSA secp256k1 uncompressed DER public key prefix.
|
|
79
|
+
*
|
|
80
|
+
* Hex representation: `3056301006072a8648ce3d020106052b8104000a034200`
|
|
81
|
+
* (23 bytes / 46 hex chars). Followed by 65 bytes (130 hex chars) of
|
|
82
|
+
* uncompressed key → total 176 hex chars.
|
|
83
|
+
*/
|
|
84
|
+
const ECDSA_DER_PREFIX = '3056301006072a8648ce3d020106052b8104000a034200';
|
|
85
|
+
/** Hex length (chars) of an XRPL-encoded Ed25519 pubkey (1 byte `ed` prefix + 32 raw bytes). */
|
|
86
|
+
const XRPL_ED25519_HEX_LEN = 66;
|
|
87
|
+
/** Hex length (chars) of an Ed25519 DER-wrapped pubkey (24 prefix + 64 raw). */
|
|
88
|
+
const ED25519_DER_HEX_LEN = 88;
|
|
89
|
+
/** Hex length (chars) of an ECDSA secp256k1 uncompressed DER pubkey (46 prefix + 130 raw). */
|
|
90
|
+
const ECDSA_DER_HEX_LEN = 176;
|
|
91
|
+
// ============================================================================
|
|
92
|
+
// Normalization
|
|
93
|
+
// ============================================================================
|
|
94
|
+
/**
|
|
95
|
+
* Normalize a member-identity field (address OR publicKey) to its raw
|
|
96
|
+
* canonical hex / lowercase form so two callers with the same underlying
|
|
97
|
+
* key in different wire formats compare equal.
|
|
98
|
+
*
|
|
99
|
+
* @param value - Hex pubkey (with or without DER / XRPL / `0x` wrappers)
|
|
100
|
+
* or an on-chain address (Hedera account id, XRPL rAddress, anything
|
|
101
|
+
* else opaque). Empty string is accepted and returns empty string.
|
|
102
|
+
* @returns Normalized lowercase string. Returns empty string only for
|
|
103
|
+
* empty input. Two distinct keys remain distinct after normalization;
|
|
104
|
+
* the function only strips wrappers whose semantics are "this is the
|
|
105
|
+
* same key in a different encoding."
|
|
106
|
+
*/
|
|
107
|
+
export function normalizeIdentityKey(value) {
|
|
108
|
+
if (value.length === 0)
|
|
109
|
+
return '';
|
|
110
|
+
// Strip 0x / 0X prefix and lowercase. After this, every subsequent
|
|
111
|
+
// length check uses the prefix-stripped hex length.
|
|
112
|
+
let hex = value.replace(/^0x/i, '').toLowerCase();
|
|
113
|
+
// XRPL Ed25519 keys are encoded as a single `ed` byte (2 hex chars)
|
|
114
|
+
// followed by 32 raw bytes (64 hex chars). Strip the prefix ONLY when
|
|
115
|
+
// the total length matches — a plain 64-char hex that happens to start
|
|
116
|
+
// with `ed` is a different key and must not be silently rewritten.
|
|
117
|
+
if (hex.startsWith('ed') && hex.length === XRPL_ED25519_HEX_LEN) {
|
|
118
|
+
hex = hex.slice(2);
|
|
119
|
+
}
|
|
120
|
+
// Ed25519 DER wrapper: full DER-encoded SubjectPublicKeyInfo, total
|
|
121
|
+
// length is exactly 88 hex chars (24 prefix + 64 raw).
|
|
122
|
+
if (hex.startsWith(ED25519_DER_PREFIX) && hex.length === ED25519_DER_HEX_LEN) {
|
|
123
|
+
hex = hex.slice(ED25519_DER_PREFIX.length);
|
|
124
|
+
}
|
|
125
|
+
// ECDSA secp256k1 uncompressed DER wrapper: total length is exactly
|
|
126
|
+
// 176 hex chars (46 prefix + 130 raw). The compressed form (66 chars,
|
|
127
|
+
// `02`/`03` prefix) is already canonical and not unwrapped.
|
|
128
|
+
if (hex.startsWith(ECDSA_DER_PREFIX) && hex.length === ECDSA_DER_HEX_LEN) {
|
|
129
|
+
hex = hex.slice(ECDSA_DER_PREFIX.length);
|
|
130
|
+
}
|
|
131
|
+
return hex;
|
|
132
|
+
}
|
|
133
|
+
// ============================================================================
|
|
134
|
+
// Matcher
|
|
135
|
+
// ============================================================================
|
|
136
|
+
/**
|
|
137
|
+
* Does the given `canonicalId` (an SDK-derived signature-store key)
|
|
138
|
+
* refer to the given `identity`?
|
|
139
|
+
*
|
|
140
|
+
* Tries each populated identity field independently against the
|
|
141
|
+
* canonical id, normalized through {@link normalizeIdentityKey}. Returns
|
|
142
|
+
* true if EITHER the `publicKey` field or the `address` field — after
|
|
143
|
+
* normalization — equals the canonical id.
|
|
144
|
+
*
|
|
145
|
+
* ## Why "either" is correct
|
|
146
|
+
*
|
|
147
|
+
* The SDK's `canonicalMemberId(member)` prefers `member.publicKey` when
|
|
148
|
+
* present, falling back to `member.address`. Wallets that resolve "this
|
|
149
|
+
* is the local pilot" might end up with an identity carrying only the
|
|
150
|
+
* address (e.g. legacy XRPL invitations) or only the publicKey (Hedera
|
|
151
|
+
* raw key import), or both. The matcher must succeed in all three cases
|
|
152
|
+
* — otherwise a legitimate filter silently no-ops and the UI lies about
|
|
153
|
+
* signature progress.
|
|
154
|
+
*
|
|
155
|
+
* ## Empty / unusable identity guard
|
|
156
|
+
*
|
|
157
|
+
* Returns false when:
|
|
158
|
+
*
|
|
159
|
+
* - The canonical id is empty (defensive — an empty canonical id should
|
|
160
|
+
* never appear in practice, but guarding here prevents a stray empty
|
|
161
|
+
* entry from matching every empty identity).
|
|
162
|
+
* - The identity has neither field populated.
|
|
163
|
+
* - The identity has only empty-string fields.
|
|
164
|
+
*
|
|
165
|
+
* This guarantees that "I don't know who the pilot is" never silently
|
|
166
|
+
* matches arbitrary members.
|
|
167
|
+
*
|
|
168
|
+
* @param canonicalId - SDK-derived signature-store key (output of
|
|
169
|
+
* `canonicalMemberId(member)` on the SDK side).
|
|
170
|
+
* @param identity - Wallet-resolved identity (address and/or publicKey)
|
|
171
|
+
* to test against the canonical id.
|
|
172
|
+
* @returns True if the identity refers to the canonical id, false otherwise.
|
|
173
|
+
*/
|
|
174
|
+
export function matchesMemberIdentity(canonicalId, identity) {
|
|
175
|
+
const target = normalizeIdentityKey(canonicalId);
|
|
176
|
+
if (target.length === 0)
|
|
177
|
+
return false;
|
|
178
|
+
const candidatePubKey = identity.publicKey && identity.publicKey.length > 0
|
|
179
|
+
? normalizeIdentityKey(identity.publicKey)
|
|
180
|
+
: '';
|
|
181
|
+
if (candidatePubKey.length > 0 && candidatePubKey === target) {
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
const candidateAddress = identity.address && identity.address.length > 0 ? normalizeIdentityKey(identity.address) : '';
|
|
185
|
+
if (candidateAddress.length > 0 && candidateAddress === target) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,gDAAgD,CAAC;AAE1E,gGAAgG;AAChG,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,gFAAgF;AAChF,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,8FAA8F;AAC9F,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAsC9B,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAElC,mEAAmE;IACnE,oDAAoD;IACpD,IAAI,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAElD,oEAAoE;IACpE,sEAAsE;IACtE,uEAAuE;IACvE,mEAAmE;IACnE,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,oBAAoB,EAAE,CAAC;QAChE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAED,oEAAoE;IACpE,uDAAuD;IACvD,IAAI,GAAG,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,mBAAmB,EAAE,CAAC;QAC7E,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,oEAAoE;IACpE,sEAAsE;IACtE,4DAA4D;IAC5D,IAAI,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,iBAAiB,EAAE,CAAC;QACzE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAmB,EAAE,QAAwB;IACjF,MAAM,MAAM,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IACjD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAEtC,MAAM,eAAe,GACnB,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;QACjD,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC1C,CAAC,CAAC,EAAE,CAAC;IACT,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,IAAI,eAAe,KAAK,MAAM,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,gBAAgB,GACpB,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChG,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,gBAAgB,KAAK,MAAM,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
* @packageDocumentation
|
|
12
|
+
* @module @hsuite/native-connect-types
|
|
13
|
+
*
|
|
14
|
+
* Shared TypeScript type definitions and Zod schemas used across the HSuite wallet ecosystem.
|
|
15
|
+
*
|
|
16
|
+
* This package provides:
|
|
17
|
+
* - Ledger account and network schemas
|
|
18
|
+
* - Session request/approval types
|
|
19
|
+
* - Signing payload structures
|
|
20
|
+
* - Vault configuration schemas
|
|
21
|
+
* - JSON-RPC protocol types
|
|
22
|
+
*/
|
|
23
|
+
export { LedgerIdSchema, NetworkIdSchema, LedgerAccountSchema, LedgerPluginManifestSchema, LedgerAdapterHealthSchema, LedgerAdapterDiagnosticsSchema, DerivationPathSchema, } from './ledger.js';
|
|
24
|
+
export type { LedgerId, LedgerAccount, LedgerPluginManifest, LedgerAdapterHealth, LedgerAdapterDiagnostics, DerivationPath, DerivedAccount, FungibleTokenRef, NftRef, FungibleTokenInfo, NftInfo, IssuedTokenInfo, AssetKind, AssetId, AssetBalance, AssetPriceInfo, PortfolioAccount, Portfolio, NftCollection, TransactionStatus, LedgerTransaction, TransactionQueryOptions, PagedTransactionResult, AccountValidationResult, ActivationStatus, AccountActivationResult, ActivationInstructions, } from './ledger.js';
|
|
25
|
+
export { SessionRequestSchema, SessionApprovalSchema, SignPayloadSchema, SignResultSchema, MessageSignResultSchema, SignedInnerTransactionSchema, BatchInnerTransactionSchema, MessageEnvelopeSchema, TransactionSubmissionSchema, } from './messages.js';
|
|
26
|
+
export type { SessionRequest, SessionApproval, SignPayload, SignResult, SignMessagePayload, MessageSignResult, SignedInnerTransaction, BatchInnerTransaction, TransactionSubmission, MessageEnvelope, } from './messages.js';
|
|
27
|
+
export * from './vault.js';
|
|
28
|
+
export * from './rpc.js';
|
|
29
|
+
export * from './addressbook.js';
|
|
30
|
+
export * from './transaction-approval.js';
|
|
31
|
+
export * from './enrichment.js';
|
|
32
|
+
export * from './widget.types.js';
|
|
33
|
+
export type { WidgetType, WidgetSize, WidgetCategory, WidgetPermission, WidgetPermissionRequest, WidgetManifest, HsuiteWidget, WidgetInstallation, WidgetSettings, WidgetRegistry, GridCell, } from './widget.types.js';
|
|
34
|
+
export { FREEMIUM_API_WHITELIST, PERMISSION_METADATA } from './widget.types.js';
|
|
35
|
+
export type { AccountType, MultisigSigner, MultisigAccountConfig, MultisigAccountStatus, MultisigInfo, UnifiedAccountMetadata, } from './multisig-account.js';
|
|
36
|
+
export { AccountTypeSchema, MultisigSignerSchema, MultisigInfoSchema, UnifiedAccountMetadataSchema, isMultisigAccount, getMultisigInfo, createMultisigMetadata, convertSinglesigToMultisig, } from './multisig-account.js';
|
|
37
|
+
export type { TransactionRiskLevel, TransactionDisplayField, ParsedTransactionInfo, TransactionParserOptions, TransactionParser, } from './transaction-parser.js';
|
|
38
|
+
export type { PrivateKeyExportFormat, PrivateKeyExportRequest, PrivateKeyExportFormats, PrivateKeyExportResult, PrivateKeyExportAuditEvent, } from './private-key-export.js';
|
|
39
|
+
export { avatarForAddress, marbleShapeTransform, MARBLE_AVATAR_SIZE, type MarbleAvatar, type MarbleShape, } from './address-avatar.js';
|
|
40
|
+
export type { MemberIdentity } from './identity.js';
|
|
41
|
+
export { normalizeIdentityKey, matchesMemberIdentity } from './identity.js';
|
|
42
|
+
export { HEDERA_NODE_ACCOUNTS, HEDERA_FEE_COLLECTOR_ACCOUNTS, HEDERA_SYSTEM_ACCOUNTS, } from './hedera-system-accounts.js';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,wBAAwB,EACxB,cAAc,EACd,cAAc,EAEd,gBAAgB,EAChB,MAAM,EAEN,iBAAiB,EACjB,OAAO,EAEP,eAAe,EAEf,SAAS,EACT,OAAO,EACP,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EAEb,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EAEtB,uBAAuB,EAEvB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,qBAAqB,EACrB,2BAA2B,GAE5B,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,GAEhB,MAAM,eAAe,CAAC;AACvB,cAAc,YAAY,CAAC;AAG3B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAGlC,YAAY,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGhF,YAAY,EACV,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EACV,oBAAoB,EACpB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,GAC3B,MAAM,yBAAyB,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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
* @packageDocumentation
|
|
12
|
+
* @module @hsuite/native-connect-types
|
|
13
|
+
*
|
|
14
|
+
* Shared TypeScript type definitions and Zod schemas used across the HSuite wallet ecosystem.
|
|
15
|
+
*
|
|
16
|
+
* This package provides:
|
|
17
|
+
* - Ledger account and network schemas
|
|
18
|
+
* - Session request/approval types
|
|
19
|
+
* - Signing payload structures
|
|
20
|
+
* - Vault configuration schemas
|
|
21
|
+
* - JSON-RPC protocol types
|
|
22
|
+
*/
|
|
23
|
+
// Runtime exports (Zod schemas) — keep separate from the type-only
|
|
24
|
+
// re-exports below so the emitted dist/index.js + dist/index.d.ts
|
|
25
|
+
// stay consistent under tsx/esm (which previously tried to load the
|
|
26
|
+
// .d.ts as JS and choked on the mixed value+type re-export).
|
|
27
|
+
export { LedgerIdSchema, NetworkIdSchema, LedgerAccountSchema, LedgerPluginManifestSchema, LedgerAdapterHealthSchema, LedgerAdapterDiagnosticsSchema, DerivationPathSchema, } from './ledger.js';
|
|
28
|
+
export { SessionRequestSchema, SessionApprovalSchema, SignPayloadSchema, SignResultSchema, MessageSignResultSchema, SignedInnerTransactionSchema, BatchInnerTransactionSchema, MessageEnvelopeSchema, TransactionSubmissionSchema,
|
|
29
|
+
// Note: RpcRequestSchema, RpcSuccessSchema, RpcErrorSchema are exported from rpc.js (JSON-RPC 2.0 compliant)
|
|
30
|
+
} from './messages.js';
|
|
31
|
+
export * from './vault.js';
|
|
32
|
+
// RPC types come from rpc.js - exports RpcRequestSchema, RpcSuccessSchema, RpcErrorSchema,
|
|
33
|
+
// RpcRequest, RpcResponse<T>, RpcSuccess<T>, RpcError, etc.
|
|
34
|
+
export * from './rpc.js';
|
|
35
|
+
export * from './addressbook.js';
|
|
36
|
+
export * from './transaction-approval.js';
|
|
37
|
+
export * from './enrichment.js';
|
|
38
|
+
export * from './widget.types.js';
|
|
39
|
+
export { FREEMIUM_API_WHITELIST, PERMISSION_METADATA } from './widget.types.js';
|
|
40
|
+
export { AccountTypeSchema, MultisigSignerSchema, MultisigInfoSchema, UnifiedAccountMetadataSchema, isMultisigAccount, getMultisigInfo, createMultisigMetadata, convertSinglesigToMultisig, } from './multisig-account.js';
|
|
41
|
+
// === Address Avatar Utility ===
|
|
42
|
+
// Deterministic marble-style avatars (boring-avatars style, HSuite-tinted)
|
|
43
|
+
// derived from wallet addresses. Replaced the prior emoji avatars.
|
|
44
|
+
export { avatarForAddress, marbleShapeTransform, MARBLE_AVATAR_SIZE, } from './address-avatar.js';
|
|
45
|
+
export { normalizeIdentityKey, matchesMemberIdentity } from './identity.js';
|
|
46
|
+
// === Hedera System Accounts ===
|
|
47
|
+
// Canonical sets of node, fee-collector, and combined system accounts. Used
|
|
48
|
+
// by ledger-hedera (transaction parsing) and the wallet UI (transfer-list
|
|
49
|
+
// filtering / fee-breakdown labeling). Importing from one place keeps the
|
|
50
|
+
// filter and labeler from drifting apart.
|
|
51
|
+
export { HEDERA_NODE_ACCOUNTS, HEDERA_FEE_COLLECTOR_ACCOUNTS, HEDERA_SYSTEM_ACCOUNTS, } from './hedera-system-accounts.js';
|
|
52
|
+
//# sourceMappingURL=index.js.map
|