@sidhujag/sysweb3-keyring 2.1.11 → 2.1.13

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 (44) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/cjs/host-keyring.js +3 -1
  3. package/cjs/host-keyring.js.map +1 -1
  4. package/cjs/index.js +3 -1
  5. package/cjs/index.js.map +1 -1
  6. package/cjs/keyring-core.js +609 -36
  7. package/cjs/keyring-core.js.map +1 -1
  8. package/cjs/keyring-host.js +9 -2
  9. package/cjs/keyring-host.js.map +1 -1
  10. package/cjs/private-records.js +291 -9
  11. package/cjs/private-records.js.map +1 -1
  12. package/cjs/public-session.js +72 -0
  13. package/cjs/public-session.js.map +1 -0
  14. package/cjs/software.js +3 -1
  15. package/cjs/software.js.map +1 -1
  16. package/cjs/transactions/syscoin-core.js +161 -97
  17. package/cjs/transactions/syscoin-core.js.map +1 -1
  18. package/cjs/types.js.map +1 -1
  19. package/cjs/utils/utxo-fee-rate.js +26 -0
  20. package/cjs/utils/utxo-fee-rate.js.map +1 -0
  21. package/esm/keyring-core.js +611 -38
  22. package/esm/keyring-core.js.map +1 -1
  23. package/esm/keyring-host.js +9 -2
  24. package/esm/keyring-host.js.map +1 -1
  25. package/esm/private-records.js +284 -9
  26. package/esm/private-records.js.map +1 -1
  27. package/esm/public-session.js +65 -0
  28. package/esm/public-session.js.map +1 -0
  29. package/esm/transactions/syscoin-core.js +161 -97
  30. package/esm/transactions/syscoin-core.js.map +1 -1
  31. package/esm/types.js.map +1 -1
  32. package/esm/utils/utxo-fee-rate.js +23 -0
  33. package/esm/utils/utxo-fee-rate.js.map +1 -0
  34. package/package.json +7 -1
  35. package/types/host-keyring.d.ts +4 -0
  36. package/types/index.d.ts +3 -1
  37. package/types/keyring-core.d.ts +37 -5
  38. package/types/keyring-host.d.ts +4 -0
  39. package/types/private-records.d.ts +30 -0
  40. package/types/public-session.d.ts +19 -0
  41. package/types/software.d.ts +5 -0
  42. package/types/transactions/syscoin-core.d.ts +13 -1
  43. package/types/types.d.ts +9 -1
  44. package/types/utils/utxo-fee-rate.d.ts +5 -0
@@ -19,7 +19,10 @@ type BoundHost = {
19
19
  export declare function createKeyringHost(storage: KeyringStoragePort, options?: {
20
20
  deviceUnlock?: DeviceUnlockPort;
21
21
  }): KeyringHost;
22
+ export type SecretLifetimePolicy = 'session' | 'operation';
22
23
  export type KeyringOptions = {
24
+ /** Session is the existing extension policy. Mobile must explicitly select operation. */
25
+ secretLifetime?: SecretLifetimePolicy;
23
26
  captureEvmSubmission: CaptureEvmSubmission | null;
24
27
  receiveDeviceUnlock?(controls: DeviceUnlockControls): void;
25
28
  };
@@ -30,6 +33,7 @@ export interface KeyringHostBinding {
30
33
  type PreparedHost = Omit<BoundHost, 'deviceUnlockPort'> & {
31
34
  authority: KeyringHost;
32
35
  captureEvmSubmission: CaptureEvmSubmission | null;
36
+ secretLifetime: SecretLifetimePolicy;
33
37
  deviceUnlock?: {
34
38
  port: DeviceUnlockPort;
35
39
  receive(controls: DeviceUnlockControls): void;
@@ -17,10 +17,40 @@ export interface IDecryptPrivateRecordParams {
17
17
  envelope: IEncryptedPrivateRecord;
18
18
  recordId: string;
19
19
  }
20
+ export interface PrivateRecordAccessOptions {
21
+ /** Move this grant with trusted public-session transfer; otherwise transfer retires it. */
22
+ transferable: boolean;
23
+ }
24
+ export interface IPrivateRecordAccess {
25
+ getPrivateRecordProfileId(): Promise<string>;
26
+ encryptPrivateRecord(params: IEncryptPrivateRecordParams): Promise<IEncryptedPrivateRecord>;
27
+ decryptPrivateRecord(params: IDecryptPrivateRecordParams): Promise<Uint8Array>;
28
+ dispose(): void;
29
+ }
20
30
  export declare const MAX_PRIVATE_RECORD_BYTES: number;
21
31
  export declare const MAX_PRIVATE_RECORD_LABEL_BYTES = 128;
22
32
  type Guard = () => void;
23
33
  export declare function privateRecordProfileId(secret: Uint8Array, guard: Guard): Promise<string>;
24
34
  export declare function encryptPrivateRecordBytes(secret: Uint8Array, params: IEncryptPrivateRecordParams, guard: Guard): Promise<IEncryptedPrivateRecord>;
25
35
  export declare function decryptPrivateRecordBytes(secret: Uint8Array, params: IDecryptPrivateRecordParams, guard: Guard): Promise<Uint8Array>;
36
+ /** Canonical exact set, used only to retrieve a previously granted capability. */
37
+ export declare function privateRecordDomainSet(domains: readonly string[]): string;
38
+ /** Internal cache inspection; key material is never returned. */
39
+ export declare function activePrivateRecordDomainSet(access: IPrivateRecordAccess, authority: object): string | null;
40
+ /** Internal transfer policy; callers cannot upgrade an existing grant. */
41
+ export declare function privateRecordAccessCanTransfer(access: IPrivateRecordAccess, authority: object): boolean;
42
+ /** Internal trusted SDK transfer. Old methods/dispose cannot affect the moved keys. */
43
+ export declare function transferPrivateRecordAccess(access: IPrivateRecordAccess, sourceAuthority: object, targetAuthority: object, guard: Guard): IPrivateRecordAccess;
44
+ /** Derive only the named record keys, then release the root. No key export or derivation surface escapes. */
45
+ export declare function createPrivateRecordAccess(secret: Uint8Array, domains: readonly string[], options: PrivateRecordAccessOptions, guard: Guard, authority: object): Promise<IPrivateRecordAccess>;
46
+ type PublicRecordCheckpointContext = Readonly<{
47
+ walletBindingId: string;
48
+ pairFingerprint: string;
49
+ stateDigest: Uint8Array;
50
+ domains: readonly string[];
51
+ }>;
52
+ /** Internal sealing only. No record key or extractable CryptoKey leaves this module. */
53
+ export declare function sealPublicRecordCheckpoint(rootSecret: Uint8Array, wrappingSecret: Uint8Array, context: PublicRecordCheckpointContext, guard: Guard): Promise<IEncryptedPrivateRecord>;
54
+ /** Internal restore imports only the sealed exact domain set as non-extractable keys. */
55
+ export declare function restorePublicRecordCheckpoint(wrappingSecret: Uint8Array, envelope: IEncryptedPrivateRecord, context: PublicRecordCheckpointContext, guard: Guard, authority: object): Promise<IPrivateRecordAccess>;
26
56
  export {};
@@ -0,0 +1,19 @@
1
+ import type { IEncryptedPrivateRecord } from './private-records';
2
+ /** Public state is supplied as one canonical, immutable host manifest. */
3
+ export type PublicSessionCheckpointRequest = Readonly<{
4
+ walletBindingId: string;
5
+ publicState: Uint8Array;
6
+ recordDomains: readonly string[];
7
+ }>;
8
+ export type PublicSessionRestoreRequest = PublicSessionCheckpointRequest & Readonly<{
9
+ checkpoint: IEncryptedPrivateRecord;
10
+ }>;
11
+ /** A dedicated public-view key; it must never be a vault password or vault key. */
12
+ export type PublicSessionCredentialPort = Readonly<{
13
+ withKey(assertCurrent: () => void, consume: (key: Uint8Array) => Promise<void>): Promise<void>;
14
+ }>;
15
+ export declare const MAX_PUBLIC_SESSION_STATE_BYTES: number;
16
+ export declare function capturePublicSessionKey(value: Uint8Array): Uint8Array;
17
+ export declare function capturePublicSessionRequest(input: PublicSessionCheckpointRequest): PublicSessionCheckpointRequest;
18
+ export declare function capturePublicSessionCheckpoint(input: PublicSessionRestoreRequest): IEncryptedPrivateRecord;
19
+ export declare function publicSessionStateDigest(state: Uint8Array, guard: () => void): Promise<Uint8Array>;
@@ -17,3 +17,8 @@ export type { PreparedEvmSigningOptions, PreparedSoftwareEvmSigningRequest, Sign
17
17
  export type { EncryptedEvmHdRuntimeAccount, EvmHdRuntimeAccountOptions, EvmHdRuntimeAccountRequest, } from './software-hd-account';
18
18
  export { captureEvmSubmission, submitSignedEvmTransaction, evmSubmissionFailure, } from './transactions/evm-submission';
19
19
  export type { CaptureEvmSubmission, EvmSubmissionContext, EvmSubmissionLifecycle, EvmSignedSubmission, EvmSubmissionBoundary, } from './transactions/evm-submission';
20
+ export type { SecretOperationCredentialPort, SecretOperationOptions, } from './keyring-core';
21
+ export type { SecretLifetimePolicy } from './keyring-host';
22
+ export type { IPrivateRecordAccess, PrivateRecordAccessOptions, } from './private-records';
23
+ export type { PublicSessionCheckpointRequest, PublicSessionCredentialPort, PublicSessionRestoreRequest, } from './public-session';
24
+ export { MAX_PUBLIC_SESSION_STATE_BYTES } from './public-session';
@@ -69,6 +69,8 @@ export declare class SyscoinTransactionsCore implements ISyscoinTransactions {
69
69
  private hardwareSigners;
70
70
  private getState;
71
71
  private captureSigningContext;
72
+ private readonly secretLifetime;
73
+ private readonly assertPublicPreparation;
72
74
  constructor(getSyscoinSigner: () => {
73
75
  hd: SyscoinHDSigner;
74
76
  main: any;
@@ -82,7 +84,7 @@ export declare class SyscoinTransactionsCore implements ISyscoinTransactions {
82
84
  activeAccountId: number;
83
85
  activeAccountType: KeyringAccountType;
84
86
  activeNetwork: INetwork;
85
- }, hardwareSigners: ISyscoinHardwareSigners, captureSigningContext: (bindSessionRevision: boolean) => () => void);
87
+ }, hardwareSigners: ISyscoinHardwareSigners, captureSigningContext: (bindSessionRevision: boolean) => () => void, secretLifetime: 'session' | 'operation', assertPublicPreparation: () => void);
86
88
  private getTransactionPSBT;
87
89
  decodeRawTransaction: (psbtOrHex: any, isRawHex?: boolean) => any;
88
90
  private captureOwnedRead;
@@ -90,6 +92,8 @@ export declare class SyscoinTransactionsCore implements ISyscoinTransactions {
90
92
  private signPSBTWithSigner;
91
93
  private createNativeSweepPSBT;
92
94
  private createUnsignedPSBT;
95
+ /** Resolve public signing hints without loading a software signer. */
96
+ private prepareSoftwareSigningPaths;
93
97
  private signPSBTWithMethod;
94
98
  getEstimateSysTransactionFee: ({ txOptions, isMax, nativeSweep, amount, receivingAddress, feeRate, token, excludedOutpoints, }: {
95
99
  amount: number | string;
@@ -109,6 +113,14 @@ export declare class SyscoinTransactionsCore implements ISyscoinTransactions {
109
113
  fee: number;
110
114
  psbt: any;
111
115
  }>;
116
+ /**
117
+ * Public metadata preparation for operation-scoped software signing. The
118
+ * returned PSBT preserves the unsigned transaction and existing cosigner data;
119
+ * signing still performs the normal account/scope checks.
120
+ */
121
+ preparePSBTForSigning: ({ psbt }: {
122
+ psbt: any;
123
+ }, ownedRead: SyscoinOwnedReadOptions) => Promise<any>;
112
124
  signPSBT: ({ psbt }: {
113
125
  isLedger?: boolean;
114
126
  isTrezor?: boolean;
package/types/types.d.ts CHANGED
@@ -4,7 +4,7 @@ import { ITxid } from '@sidhujag/sysweb3-utils';
4
4
  import { CustomJsonRpcProvider } from 'providers';
5
5
  import { BigNumber, BigNumberish, BytesLike, TransactionResponse } from './ethers-v6';
6
6
  import { LedgerKeyring } from './ledger';
7
- import { IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams } from './private-records';
7
+ import { IPrivateRecordAccess, PrivateRecordAccessOptions, IDecryptPrivateRecordParams, IEncryptedPrivateRecord, IEncryptPrivateRecordParams } from './private-records';
8
8
  import { SyscoinHDSigner } from './signers';
9
9
  import { TrezorKeyring } from './trezor';
10
10
  import type { KeyringCore, PreparedSessionTransfer } from './keyring-core';
@@ -225,6 +225,10 @@ export interface ISyscoinTransactions {
225
225
  decodeRawTransaction: (psbtOrHex: any, isRawHex?: boolean) => any;
226
226
  sendTransaction: (rawTransaction: string, authority: SyscoinOwnedSubmissionOptions) => Promise<ITxid>;
227
227
  replayRetainedTransaction: (txid: string, authority: SyscoinRetainedSubmissionOptions) => Promise<ITxid>;
228
+ /** Resolve public signing paths before entering an operation-scoped lease. */
229
+ preparePSBTForSigning: (input: {
230
+ psbt: any;
231
+ }, ownedRead: SyscoinOwnedReadOptions) => Promise<any>;
228
232
  signPSBT: ({ psbt, isTrezor, isLedger, }: {
229
233
  isLedger?: boolean;
230
234
  isTrezor?: boolean;
@@ -255,6 +259,10 @@ export interface IKeyringManager {
255
259
  syscoinTransaction: ISyscoinTransactions;
256
260
  isSeedValid: (seedPhrase: string) => boolean;
257
261
  getSeed: (pwd: string) => Promise<string>;
262
+ createPublicSessionCheckpoint: (input: import('./public-session').PublicSessionCheckpointRequest, wrappingKey: Uint8Array, assertCurrent: () => void) => Promise<import('./private-records').IEncryptedPrivateRecord>;
263
+ restorePublicSession: <T>(credential: import('./public-session').PublicSessionCredentialPort, input: import('./public-session').PublicSessionRestoreRequest, options: import('./keyring-core').SecretOperationOptions, work: (authenticatedPublicState: Uint8Array) => T | Promise<T>) => Promise<T>;
264
+ createPrivateRecordAccess: (domains: readonly string[], options: PrivateRecordAccessOptions) => Promise<IPrivateRecordAccess>;
265
+ getPrivateRecordAccess: (domains: readonly string[]) => IPrivateRecordAccess;
258
266
  getPrivateRecordProfileId: () => Promise<string>;
259
267
  encryptPrivateRecord: (params: IEncryptPrivateRecordParams) => Promise<IEncryptedPrivateRecord>;
260
268
  decryptPrivateRecord: (params: IDecryptPrivateRecordParams) => Promise<Uint8Array>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The public rate is coins/vbyte. Convert its decimal representation exactly:
3
+ * multiplying a binary Number first can make 7e-8 round up to 8 atomic units.
4
+ */
5
+ export declare function utxoFeeRateUnits(rate: number): number;