@sidhujag/sysweb3-keyring 2.1.1 → 2.1.3
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/CHANGELOG.md +5 -2
- package/README.md +8 -0
- package/cjs/current-vault-refusal.js +6 -0
- package/cjs/current-vault-refusal.js.map +1 -0
- package/cjs/evm-fees.js +29 -1
- package/cjs/evm-fees.js.map +1 -1
- package/cjs/keyring-core.js +349 -84
- package/cjs/keyring-core.js.map +1 -1
- package/cjs/keyring-manager.js +100 -4
- package/cjs/keyring-manager.js.map +1 -1
- package/cjs/software.js +14 -1
- package/cjs/software.js.map +1 -1
- package/cjs/storage-core.js +44 -4
- package/cjs/storage-core.js.map +1 -1
- package/cjs/transactions/ethereum.js +138 -82
- package/cjs/transactions/ethereum.js.map +1 -1
- package/cjs/transactions/evm-cancellation.js +43 -0
- package/cjs/transactions/evm-cancellation.js.map +1 -0
- package/cjs/transactions/evm-local-signer.js +4 -2
- package/cjs/transactions/evm-local-signer.js.map +1 -1
- package/cjs/transactions/evm-submission.js +23 -2
- package/cjs/transactions/evm-submission.js.map +1 -1
- package/cjs/transactions/prepared-evm.js +3 -6
- package/cjs/transactions/prepared-evm.js.map +1 -1
- package/esm/ledger/dmk-host.js +31 -0
- package/esm/ledger/dmk-host.js.map +1 -0
- package/esm/ledger/dmk-selected-host.js +6 -0
- package/esm/ledger/dmk-selected-host.js.map +1 -0
- package/esm/ledger/dmk-session.js +153 -34
- package/esm/ledger/dmk-session.js.map +1 -1
- package/esm/ledger-host.js +3 -27
- package/esm/ledger-host.js.map +1 -1
- package/package.json +13 -1
- package/types/current-vault-refusal.d.ts +2 -0
- package/types/evm-fees.d.ts +25 -0
- package/types/keyring-core.d.ts +36 -3
- package/types/keyring-manager.d.ts +15 -3
- package/types/ledger/dmk-host.d.ts +7 -0
- package/types/ledger/dmk-selected-host.d.ts +7 -0
- package/types/ledger/dmk-session.d.ts +10 -2
- package/types/ledger-host.d.ts +6 -2
- package/types/software.d.ts +4 -3
- package/types/storage-core.d.ts +3 -1
- package/types/storage.d.ts +1 -1
- package/types/transactions/evm-cancellation.d.ts +10 -0
- package/types/transactions/evm-submission.d.ts +4 -1
package/types/keyring-core.d.ts
CHANGED
|
@@ -15,7 +15,32 @@ export interface KeyringStoragePort extends VaultStoragePort {
|
|
|
15
15
|
deleteItem(key: string): Promise<void>;
|
|
16
16
|
/** Legacy adapter capability; fixed native hosts can omit it. */
|
|
17
17
|
setClient?(client: any): void;
|
|
18
|
+
/** Atomically read this authority's current encrypted vault and salt. */
|
|
19
|
+
readDeviceUnlockVaultPair?(): Promise<DeviceUnlockVaultPair | null>;
|
|
18
20
|
}
|
|
21
|
+
export type DeviceUnlockVaultPair = Readonly<{
|
|
22
|
+
vault: string;
|
|
23
|
+
keys: unknown;
|
|
24
|
+
pairFingerprint: string;
|
|
25
|
+
}>;
|
|
26
|
+
export type DeviceUnlockCredential = Readonly<{
|
|
27
|
+
pairFingerprint: string;
|
|
28
|
+
key: Uint8Array;
|
|
29
|
+
}>;
|
|
30
|
+
/** Only a trusted software host may supply this protected credential I/O. */
|
|
31
|
+
export type DeviceUnlockPort = Readonly<{
|
|
32
|
+
/** Transfer ownership of the returned key bytes to the SDK. */
|
|
33
|
+
readCredential(pairFingerprint: string): Promise<DeviceUnlockCredential | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Consume the bytes and check the guard before saving. The SDK clears the
|
|
36
|
+
* bytes on settlement. Publish enrollment only after issue returns true.
|
|
37
|
+
*/
|
|
38
|
+
writeCredential(credential: DeviceUnlockCredential, assertCurrent: () => void): Promise<void>;
|
|
39
|
+
}>;
|
|
40
|
+
export type DeviceUnlockControls = Readonly<{
|
|
41
|
+
issue(password: string, assertCurrent: () => void): Promise<boolean>;
|
|
42
|
+
resume(assertCurrent: () => void): Promise<boolean>;
|
|
43
|
+
}>;
|
|
19
44
|
/** Only the device capabilities consumed by the wallet authority. */
|
|
20
45
|
export interface KeyringLedgerSigner {
|
|
21
46
|
destroy: LedgerKeyring['destroy'];
|
|
@@ -24,6 +49,10 @@ export interface KeyringLedgerSigner {
|
|
|
24
49
|
verifyUtxoAddress: LedgerKeyring['verifyUtxoAddress'];
|
|
25
50
|
}
|
|
26
51
|
export type KeyringTrezorSigner = Pick<TrezorKeyring, 'destroy' | 'getAccountInfo' | 'getPublicKey' | 'signTypedData' | 'signMessage' | 'signEthTransaction' | 'verifyUtxoAddress'>;
|
|
52
|
+
type SessionOwner = {
|
|
53
|
+
current?: symbol;
|
|
54
|
+
epoch: number;
|
|
55
|
+
};
|
|
27
56
|
export interface KeyringCoreDependencies<TLedger extends KeyringLedgerSigner | undefined, TTrezor extends KeyringTrezorSigner | undefined> {
|
|
28
57
|
/** Immutable identity shared only by keyrings in the same wallet authority. */
|
|
29
58
|
authority: object;
|
|
@@ -36,6 +65,12 @@ export interface KeyringCoreDependencies<TLedger extends KeyringLedgerSigner | u
|
|
|
36
65
|
syscoinHardwareSigners?: ISyscoinHardwareSigners;
|
|
37
66
|
/** Trusted host lifecycle, captured before each locally signed EVM submission. */
|
|
38
67
|
captureEvmSubmission?: CaptureEvmSubmission;
|
|
68
|
+
/** Shared only by software keyrings of the same opted-in host. */
|
|
69
|
+
sessionOwner?: SessionOwner;
|
|
70
|
+
deviceUnlock?: {
|
|
71
|
+
port: DeviceUnlockPort;
|
|
72
|
+
receive(controls: DeviceUnlockControls): void;
|
|
73
|
+
};
|
|
39
74
|
}
|
|
40
75
|
export interface ISysAccount {
|
|
41
76
|
address: string;
|
|
@@ -57,6 +92,7 @@ declare class SecureBuffer {
|
|
|
57
92
|
isCleared(): boolean;
|
|
58
93
|
}
|
|
59
94
|
export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined = KeyringLedgerSigner | undefined, TTrezor extends KeyringTrezorSigner | undefined = KeyringTrezorSigner | undefined> {
|
|
95
|
+
#private;
|
|
60
96
|
trezorSigner: TTrezor;
|
|
61
97
|
ledgerSigner: TLedger;
|
|
62
98
|
initialTrezorAccountState: IKeyringAccountState;
|
|
@@ -86,9 +122,7 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
|
|
|
86
122
|
isUnlocked: () => boolean;
|
|
87
123
|
lockWallet: () => Promise<void>;
|
|
88
124
|
transferSessionTo: (targetKeyring: Pick<KeyringCore, "receiveSessionOwnership">) => void;
|
|
89
|
-
private acceptSessionFrom;
|
|
90
125
|
receiveSessionOwnership: (sessionPassword: SecureBuffer, sessionMnemonic: SecureBuffer) => void;
|
|
91
|
-
private replaceSessionBuffers;
|
|
92
126
|
addNewAccount: (label?: string) => Promise<IKeyringAccountState>;
|
|
93
127
|
createSmartAccount: ({ address, deriveAccount, label, metadata, }: ICreateSmartAccountParams) => Promise<IKeyringAccountState>;
|
|
94
128
|
/**
|
|
@@ -228,7 +262,6 @@ export declare class KeyringCore<TLedger extends KeyringLedgerSigner | undefined
|
|
|
228
262
|
private setDerivedWeb3Accounts;
|
|
229
263
|
private setSignerEVM;
|
|
230
264
|
private clearTemporaryLocalKeys;
|
|
231
|
-
private recreateSessionFromVault;
|
|
232
265
|
private _getPrivateKeyAccountInfos;
|
|
233
266
|
/**
|
|
234
267
|
* Common method to decrypt mnemonic from session
|
|
@@ -2,15 +2,27 @@ import { HardwareWalletManager } from './hardware-wallet-manager';
|
|
|
2
2
|
import { KeyringCore } from './keyring-core';
|
|
3
3
|
import { LedgerKeyring } from './ledger';
|
|
4
4
|
import { TrezorKeyring } from './trezor';
|
|
5
|
+
import type { DeviceUnlockControls, DeviceUnlockPort, KeyringStoragePort } from './keyring-core';
|
|
5
6
|
import type { LedgerHost } from './ledger/host-types';
|
|
6
7
|
import type { CaptureEvmSubmission } from './transactions/evm-submission';
|
|
7
8
|
import type { IKeyringManager } from './types';
|
|
8
9
|
export type { ISysAccount } from './keyring-core';
|
|
10
|
+
export type { DeviceUnlockControls, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, } from './keyring-core';
|
|
11
|
+
declare const keyringManagerHostBrand: unique symbol;
|
|
12
|
+
/** Opaque identity for one explicitly configured browser wallet authority. */
|
|
13
|
+
export interface KeyringManagerHost {
|
|
14
|
+
readonly [keyringManagerHostBrand]: true;
|
|
15
|
+
}
|
|
16
|
+
/** Create once for a fixed wallet store and share across replacement managers. */
|
|
17
|
+
export declare function createKeyringManagerHost(storage: KeyringStoragePort, deviceUnlock: DeviceUnlockPort): KeyringManagerHost;
|
|
18
|
+
export type KeyringManagerOptions = {
|
|
19
|
+
captureEvmSubmission?: CaptureEvmSubmission;
|
|
20
|
+
host?: KeyringManagerHost;
|
|
21
|
+
receiveDeviceUnlock?(controls: DeviceUnlockControls): void;
|
|
22
|
+
};
|
|
9
23
|
/** Existing browser entry. Native/software hosts must use the software entry. */
|
|
10
24
|
export declare class KeyringManager extends KeyringCore<LedgerKeyring, TrezorKeyring> implements IKeyringManager {
|
|
11
|
-
constructor(sharedHardwareWalletManager?: HardwareWalletManager, ledgerHost?: LedgerHost, options?:
|
|
12
|
-
captureEvmSubmission?: CaptureEvmSubmission;
|
|
13
|
-
});
|
|
25
|
+
constructor(sharedHardwareWalletManager?: HardwareWalletManager, ledgerHost?: LedgerHost, options?: KeyringManagerOptions);
|
|
14
26
|
static createInitialized(seed: string, password: string, vaultStateGetter: () => any, options?: {
|
|
15
27
|
captureEvmSubmission?: CaptureEvmSubmission;
|
|
16
28
|
}): Promise<KeyringManager>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type LedgerEvmConfig, type LedgerHost } from './host-types';
|
|
2
|
+
export interface LedgerDmkHost extends LedgerHost {
|
|
3
|
+
/** Start before enumerating. The returned capability is single use. */
|
|
4
|
+
beginDeviceSelection(signal?: AbortSignal): (candidate: object) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/** Shared implementation; the default browser host supplies its own transport. */
|
|
7
|
+
export declare function createLedgerHostForDmk(candidate: object, config: LedgerEvmConfig, requireDeviceSelection?: boolean): LedgerDmkHost;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type LedgerDmkHost } from './dmk-host';
|
|
2
|
+
import type { LedgerEvmConfig } from './host-types';
|
|
3
|
+
/** A platform-owned transport and explicit user selection are required. */
|
|
4
|
+
export declare function createSelectedLedgerDmkHost(config: LedgerEvmConfig & {
|
|
5
|
+
dmk: object;
|
|
6
|
+
}): LedgerDmkHost;
|
|
7
|
+
export type { LedgerDmkHost } from './dmk-host';
|
|
@@ -30,8 +30,9 @@ export interface LedgerDmkOperation {
|
|
|
30
30
|
/** One owner and one semantic operation at a time, across EVM and UTXO apps. */
|
|
31
31
|
export declare class LedgerDmkSession {
|
|
32
32
|
readonly dmk: DeviceManagementKit;
|
|
33
|
+
private requireDeviceSelection;
|
|
33
34
|
private generation;
|
|
34
|
-
private
|
|
35
|
+
private connection;
|
|
35
36
|
private queue;
|
|
36
37
|
private activeCancel;
|
|
37
38
|
private activeAbort;
|
|
@@ -39,17 +40,24 @@ export declare class LedgerDmkSession {
|
|
|
39
40
|
private stateSubscription;
|
|
40
41
|
private connectionAttempt;
|
|
41
42
|
private connectionAbort;
|
|
43
|
+
private deviceSelection;
|
|
42
44
|
private readonly invalidationListeners;
|
|
43
|
-
constructor(dmk: DeviceManagementKit);
|
|
45
|
+
constructor(dmk: DeviceManagementKit, requireDeviceSelection?: boolean);
|
|
46
|
+
private get readyConnection();
|
|
44
47
|
getStatus(): {
|
|
45
48
|
connected: boolean;
|
|
46
49
|
};
|
|
47
50
|
onInvalidated(listener: () => void): () => void;
|
|
48
51
|
private invalidate;
|
|
52
|
+
/** The platform passes one candidate from its own current DMK picker. */
|
|
53
|
+
beginDeviceSelection(signal?: AbortSignal): (candidate: object) => Promise<void>;
|
|
49
54
|
/** Device selection belongs to the visible host, never to a dapp request. */
|
|
50
55
|
connect(request?: {
|
|
51
56
|
useGrantedDevices?: boolean;
|
|
52
57
|
}, options?: LedgerOperationOptions): Promise<void>;
|
|
58
|
+
private connectionBusy;
|
|
59
|
+
private startConnection;
|
|
60
|
+
private discoverDevice;
|
|
53
61
|
private connectDevice;
|
|
54
62
|
/** Cancel revokes the result and closes I/O; it cannot undo on-device approval. */
|
|
55
63
|
disconnect(): Promise<void>;
|
package/types/ledger-host.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type LedgerDmkHost } from './ledger/dmk-host';
|
|
2
|
+
import type { LedgerEvmConfig } from './ledger/host-types';
|
|
2
3
|
export interface LedgerDmkHostConfig extends LedgerEvmConfig {
|
|
3
4
|
/** Platform-owned DMK, allowing a future host to register its own transports. */
|
|
4
5
|
dmk?: object;
|
|
6
|
+
/** Disable automatic discovery until the platform selects a device. */
|
|
7
|
+
requireDeviceSelection?: boolean;
|
|
5
8
|
}
|
|
6
|
-
export declare function createLedgerDmkHost(config?: LedgerDmkHostConfig):
|
|
9
|
+
export declare function createLedgerDmkHost(config?: LedgerDmkHostConfig): LedgerDmkHost;
|
|
10
|
+
export type { LedgerDmkHost } from './ledger/dmk-host';
|
|
7
11
|
export type { LedgerEvmConfig, LedgerBlindSigningIntent, LedgerHost, LedgerEvmHost, LedgerUtxoHost, LedgerUtxoAccount, LedgerPartialSignature, LedgerTypedData, LedgerOperationOptions, LedgerProgress, } from './ledger/host-types';
|
package/types/software.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Software-only entry: explicit host storage, no browser/device initialization. */
|
|
2
2
|
import { KeyringCore } from './keyring-core';
|
|
3
|
-
import type { KeyringStoragePort } from './keyring-core';
|
|
3
|
+
import type { DeviceUnlockControls, DeviceUnlockPort, KeyringStoragePort } from './keyring-core';
|
|
4
4
|
import type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest } from './software-hd-account';
|
|
5
5
|
import type { CaptureEvmSubmission } from './transactions/evm-submission';
|
|
6
6
|
import type { PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction } from './transactions/prepared-evm';
|
|
@@ -12,9 +12,10 @@ export interface SoftwareKeyringHost {
|
|
|
12
12
|
/** Create once per wallet authority, then share with its per-network keyrings. */
|
|
13
13
|
export declare const createSoftwareKeyringHost: (storage: KeyringStoragePort, options?: {
|
|
14
14
|
captureEvmSubmission?: CaptureEvmSubmission;
|
|
15
|
+
deviceUnlock?: DeviceUnlockPort;
|
|
15
16
|
}) => SoftwareKeyringHost;
|
|
16
17
|
export declare class SoftwareKeyring extends KeyringCore<undefined, undefined> {
|
|
17
|
-
constructor(host: SoftwareKeyringHost);
|
|
18
|
+
constructor(host: SoftwareKeyringHost, receiveDeviceUnlock?: (controls: DeviceUnlockControls) => void);
|
|
18
19
|
/**
|
|
19
20
|
* Derive a fixed-path Ethereum HD runtime account without network or storage
|
|
20
21
|
* writes. The returned password-encrypted xprv is internal runtime state,
|
|
@@ -36,7 +37,7 @@ export declare class SoftwareKeyring extends KeyringCore<undefined, undefined> {
|
|
|
36
37
|
export { KeyringAccountType } from './types';
|
|
37
38
|
export { INetworkType } from '@sidhujag/sysweb3-network';
|
|
38
39
|
export type { INetwork } from '@sidhujag/sysweb3-network';
|
|
39
|
-
export type { KeyringStoragePort } from './keyring-core';
|
|
40
|
+
export type { DeviceUnlockControls, DeviceUnlockCredential, DeviceUnlockPort, DeviceUnlockVaultPair, KeyringStoragePort, } from './keyring-core';
|
|
40
41
|
export type { IKeyringAccountState } from './types';
|
|
41
42
|
export type { PreparedEvmTransaction, PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, SignedPreparedEvmTransaction, } from './transactions/prepared-evm';
|
|
42
43
|
export type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest, } from './software-hd-account';
|
package/types/storage-core.d.ts
CHANGED
|
@@ -8,13 +8,15 @@ export interface VaultStoragePort {
|
|
|
8
8
|
export interface VaultPersistence {
|
|
9
9
|
setEncryptedVault(decryptedVault: any, pwd: string, freshVaultKeys?: {
|
|
10
10
|
salt: string;
|
|
11
|
-
}): Promise<void>;
|
|
11
|
+
}, assertCurrent?: () => void): Promise<void>;
|
|
12
12
|
getDecryptedVault(pwd: string, legacyPassword?: string): Promise<any>;
|
|
13
13
|
}
|
|
14
14
|
export declare class VaultAuthenticationError extends Error {
|
|
15
15
|
readonly code = "INVALID_PASSWORD";
|
|
16
16
|
constructor();
|
|
17
17
|
}
|
|
18
|
+
/** Authenticate a captured current-format vault. This path has no CBC fallback. */
|
|
19
|
+
export declare const decryptCurrentVault: (vault: string, key: string) => Promise<unknown>;
|
|
18
20
|
/**
|
|
19
21
|
* Create once per wallet authority and share across its network keyrings.
|
|
20
22
|
* The host owns storage durability and cross-context atomic creation.
|
package/types/storage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const setEncryptedVault: (decryptedVault: any, pwd: string, freshVaultKeys?: {
|
|
2
2
|
salt: string;
|
|
3
|
-
}) => Promise<void>;
|
|
3
|
+
}, assertCurrent?: () => void) => Promise<void>;
|
|
4
4
|
export declare const getDecryptedVault: (pwd: string, legacyPassword?: string) => Promise<any>;
|
|
5
5
|
export { VaultAuthenticationError } from './storage-core';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { planEvmCancellationFees } from '../evm-fees';
|
|
2
|
+
/** A host supplies the authenticated original identity and the captured fee plan. */
|
|
3
|
+
export type EvmCancellationEnvelopeIntent = Readonly<{
|
|
4
|
+
payer: string;
|
|
5
|
+
chainId: number | string;
|
|
6
|
+
nonce: number | string;
|
|
7
|
+
feePlan: ReturnType<typeof planEvmCancellationFees>;
|
|
8
|
+
}>;
|
|
9
|
+
/** Checks the exact unsigned bytes. Original eligibility and approval remain host checks. */
|
|
10
|
+
export declare function assertEvmCancellationEnvelope(unsigned: string, { payer, chainId, nonce, feePlan }: EvmCancellationEnvelopeIntent): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Transaction } from 'ethers/transaction';
|
|
1
2
|
export type EvmSubmissionContext = Readonly<{
|
|
2
3
|
account: Readonly<{
|
|
3
4
|
id: number;
|
|
@@ -44,5 +45,7 @@ export declare function evmSubmissionFailure(error: unknown): Readonly<{
|
|
|
44
45
|
}>;
|
|
45
46
|
/** Preserve local evidence when an existing public API wraps its Error object. */
|
|
46
47
|
export declare function copyEvmSubmissionFailure(source: unknown, target: Error): void;
|
|
48
|
+
/** Compare signed wire bytes with the complete envelope captured before signing. */
|
|
49
|
+
export declare function assertSignedEvmTransactionMatches(rawTransaction: string, expectedUnsignedTransaction: string, expectedFrom?: string): Transaction;
|
|
47
50
|
/** The sole local-signature dispatch boundary. No nonce/fee selection or retry. */
|
|
48
|
-
export declare function submitSignedEvmTransaction<T>(rawTransaction: string, broadcast: (rawTransaction: string) => Promise<T>, boundary?: EvmSubmissionBoundary, beforeBroadcast?: () => void): Promise<T>;
|
|
51
|
+
export declare function submitSignedEvmTransaction<T>(rawTransaction: string, broadcast: (rawTransaction: string) => Promise<T>, boundary?: EvmSubmissionBoundary, beforeBroadcast?: () => void, expectedUnsignedTransaction?: string): Promise<T>;
|