decane-connect-kit 2.11.0 → 2.12.1
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/dist/index.cjs +357 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -1
- package/dist/index.d.ts +77 -1
- package/dist/index.js +351 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -104,6 +104,18 @@ interface DecaneConnectConfig {
|
|
|
104
104
|
apiBaseUrl?: string;
|
|
105
105
|
sessionDurationMinutes?: number;
|
|
106
106
|
promptPin?: () => Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Prompts for the device unlock password. Required on any device that has
|
|
109
|
+
* one — both to set it (`kind: 'set'`, ask twice and confirm) and to use it
|
|
110
|
+
* (`kind: 'unlock'`).
|
|
111
|
+
*
|
|
112
|
+
* Unlike promptPin, this secret can open a session on its own, so treat it
|
|
113
|
+
* with the care a password deserves: never log it, never persist it, and let
|
|
114
|
+
* a password manager fill it.
|
|
115
|
+
*/
|
|
116
|
+
promptUnlockPassword?: (ctx: {
|
|
117
|
+
kind: 'set' | 'unlock';
|
|
118
|
+
}) => Promise<string>;
|
|
107
119
|
/**
|
|
108
120
|
* Require a fresh WebAuthn assertion for every signature, instead of letting
|
|
109
121
|
* an unlocked session sign freely until it expires. The TEE session stays
|
|
@@ -359,6 +371,18 @@ interface DecaneConnect {
|
|
|
359
371
|
signInWithPasskey(): Promise<ConnectResult>;
|
|
360
372
|
/** Whether THIS device's share is wrapped by a passkey rather than a PIN. */
|
|
361
373
|
hasPasskey(): Promise<boolean>;
|
|
374
|
+
/**
|
|
375
|
+
* Turn on "unlock with your password": re-wraps the device share under the
|
|
376
|
+
* password and stores an unlock token beside it. Needs a live session.
|
|
377
|
+
* Throws WeakPasswordError if the password is too weak to carry a session.
|
|
378
|
+
*/
|
|
379
|
+
setUnlockPassword(password: string): Promise<void>;
|
|
380
|
+
/** True when this device can open a session from a password alone. */
|
|
381
|
+
canUnlockWithPassword(): Promise<boolean>;
|
|
382
|
+
/** Open a session from the password alone — no provider, no passkey. */
|
|
383
|
+
unlockWithPassword(password: string): Promise<ConnectResult>;
|
|
384
|
+
/** Turn the password path off, revoking the token account-wide. */
|
|
385
|
+
removeUnlockPassword(): Promise<void>;
|
|
362
386
|
/**
|
|
363
387
|
* Add a passkey to this device after the fact, re-wrapping its device share
|
|
364
388
|
* under it.
|
|
@@ -581,6 +605,22 @@ declare class ApiClient {
|
|
|
581
605
|
*/
|
|
582
606
|
getWebAuthnLoginOptions(userId: string, rpId: string): Promise<_simplewebauthn_browser.PublicKeyCredentialRequestOptionsJSON | null>;
|
|
583
607
|
postWebAuthnLogin(userId: string, response: _simplewebauthn_browser.AuthenticationResponseJSON, origin: string): Promise<AuthResult>;
|
|
608
|
+
/**
|
|
609
|
+
* Issue this device an unlock token. Returned in the clear once and never
|
|
610
|
+
* again — the backend stores only its hash — so the caller must encrypt and
|
|
611
|
+
* persist it before the value is dropped.
|
|
612
|
+
*/
|
|
613
|
+
issueUnlockToken(jwt: string): Promise<{
|
|
614
|
+
token: string;
|
|
615
|
+
expiresInDays: number;
|
|
616
|
+
}>;
|
|
617
|
+
/** Redeem a decrypted unlock token for a session. */
|
|
618
|
+
exchangeUnlockToken(token: string): Promise<{
|
|
619
|
+
jwt: string;
|
|
620
|
+
userId: string;
|
|
621
|
+
}>;
|
|
622
|
+
/** Turn the password path off account-wide, so a lost device stops working. */
|
|
623
|
+
revokeUnlockTokens(jwt: string): Promise<void>;
|
|
584
624
|
revoke(jwt: string): Promise<void>;
|
|
585
625
|
hasRecoveryBackup(jwt: string): Promise<boolean>;
|
|
586
626
|
getRecoveryBackup(jwt: string): Promise<{
|
|
@@ -715,6 +755,17 @@ interface SocialConfig {
|
|
|
715
755
|
*/
|
|
716
756
|
kingsChatScopes?: string[];
|
|
717
757
|
promptPin?: () => Promise<string>;
|
|
758
|
+
/**
|
|
759
|
+
* Called when the SDK needs the device unlock password — to choose one
|
|
760
|
+
* (`kind: 'set'`, ask twice) or to enter it (`kind: 'unlock'`).
|
|
761
|
+
*
|
|
762
|
+
* Required on any device using "unlock with your password". Unlike promptPin,
|
|
763
|
+
* this secret can open a session on its own, so never log or persist it and
|
|
764
|
+
* let a password manager fill it.
|
|
765
|
+
*/
|
|
766
|
+
promptUnlockPassword?: (ctx: {
|
|
767
|
+
kind: 'set' | 'unlock';
|
|
768
|
+
}) => Promise<string>;
|
|
718
769
|
apiBaseUrl?: string;
|
|
719
770
|
chains?: string[];
|
|
720
771
|
rpcUrls?: Record<string, string>;
|
|
@@ -977,6 +1028,15 @@ declare class StaleDeviceShareError extends DecaneConnectError {
|
|
|
977
1028
|
declare class PromptPinNotConfiguredError extends DecaneConnectError {
|
|
978
1029
|
constructor();
|
|
979
1030
|
}
|
|
1031
|
+
declare class PromptPasswordNotConfiguredError extends DecaneConnectError {
|
|
1032
|
+
constructor();
|
|
1033
|
+
}
|
|
1034
|
+
declare class WrongUnlockPasswordError extends DecaneConnectError {
|
|
1035
|
+
constructor();
|
|
1036
|
+
}
|
|
1037
|
+
declare class UnlockTokenRejectedError extends DecaneConnectError {
|
|
1038
|
+
constructor();
|
|
1039
|
+
}
|
|
980
1040
|
declare class AttestationError extends DecaneConnectError {
|
|
981
1041
|
constructor(msg: string);
|
|
982
1042
|
}
|
|
@@ -1313,6 +1373,10 @@ declare function useSocialWallet(): {
|
|
|
1313
1373
|
getAccessToken: () => string | null;
|
|
1314
1374
|
hasPasskey: () => Promise<boolean>;
|
|
1315
1375
|
addPasskey: () => Promise<void>;
|
|
1376
|
+
setUnlockPassword: (password: string) => Promise<void>;
|
|
1377
|
+
canUnlockWithPassword: () => Promise<boolean>;
|
|
1378
|
+
unlockWithPassword: (password: string) => Promise<void>;
|
|
1379
|
+
removeUnlockPassword: () => Promise<void>;
|
|
1316
1380
|
rotateShares: (opts: {
|
|
1317
1381
|
password: string;
|
|
1318
1382
|
passwordHint?: string;
|
|
@@ -1409,4 +1473,16 @@ declare function useSignTypedData(): {
|
|
|
1409
1473
|
reset: () => void;
|
|
1410
1474
|
};
|
|
1411
1475
|
|
|
1412
|
-
|
|
1476
|
+
declare const MIN_PASSWORD_LENGTH = 12;
|
|
1477
|
+
declare class WeakPasswordError extends Error {
|
|
1478
|
+
constructor(message: string);
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Reject what cannot carry the weight this secret now bears.
|
|
1482
|
+
*
|
|
1483
|
+
* Intentionally not a strength meter: a score shown to a user is advice, and
|
|
1484
|
+
* this is a floor. Anything above the floor is the user's call.
|
|
1485
|
+
*/
|
|
1486
|
+
declare function validateUnlockPassword(password: string): void;
|
|
1487
|
+
|
|
1488
|
+
export { type ActiveSession, AttestationError, type AuthProfile, type AuthResult, BUILT_IN_CHAINS, type BalanceResult, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, DecaneLogo, DecaneMark, type DecaneProvider, DecaneWordmark, type Eip1193Provider, type EthereumProviderOptions, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, type KingsChatTokens, MIN_PASSWORD_LENGTH, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPasswordNotConfiguredError, PromptPinNotConfiguredError, ProvisioningTimeoutError, ReconnectRequiredError, type RecordTransactionInput, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SignTypedDataRequest, type SignedAuthorization, type SocialAuthState, type SocialConfig, SocialWalletModal, StaleDeviceShareError, type Theme, type TransactionRecord, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UnlockTokenRejectedError, UserCancelledError, WalletSelector, WeakPasswordError, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, WrongUnlockPasswordError, createDecane, createDecaneConnect, createEthereumProvider, loginWithKingsChatPopup, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, validateUnlockPassword, verifyEmailCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -104,6 +104,18 @@ interface DecaneConnectConfig {
|
|
|
104
104
|
apiBaseUrl?: string;
|
|
105
105
|
sessionDurationMinutes?: number;
|
|
106
106
|
promptPin?: () => Promise<string>;
|
|
107
|
+
/**
|
|
108
|
+
* Prompts for the device unlock password. Required on any device that has
|
|
109
|
+
* one — both to set it (`kind: 'set'`, ask twice and confirm) and to use it
|
|
110
|
+
* (`kind: 'unlock'`).
|
|
111
|
+
*
|
|
112
|
+
* Unlike promptPin, this secret can open a session on its own, so treat it
|
|
113
|
+
* with the care a password deserves: never log it, never persist it, and let
|
|
114
|
+
* a password manager fill it.
|
|
115
|
+
*/
|
|
116
|
+
promptUnlockPassword?: (ctx: {
|
|
117
|
+
kind: 'set' | 'unlock';
|
|
118
|
+
}) => Promise<string>;
|
|
107
119
|
/**
|
|
108
120
|
* Require a fresh WebAuthn assertion for every signature, instead of letting
|
|
109
121
|
* an unlocked session sign freely until it expires. The TEE session stays
|
|
@@ -359,6 +371,18 @@ interface DecaneConnect {
|
|
|
359
371
|
signInWithPasskey(): Promise<ConnectResult>;
|
|
360
372
|
/** Whether THIS device's share is wrapped by a passkey rather than a PIN. */
|
|
361
373
|
hasPasskey(): Promise<boolean>;
|
|
374
|
+
/**
|
|
375
|
+
* Turn on "unlock with your password": re-wraps the device share under the
|
|
376
|
+
* password and stores an unlock token beside it. Needs a live session.
|
|
377
|
+
* Throws WeakPasswordError if the password is too weak to carry a session.
|
|
378
|
+
*/
|
|
379
|
+
setUnlockPassword(password: string): Promise<void>;
|
|
380
|
+
/** True when this device can open a session from a password alone. */
|
|
381
|
+
canUnlockWithPassword(): Promise<boolean>;
|
|
382
|
+
/** Open a session from the password alone — no provider, no passkey. */
|
|
383
|
+
unlockWithPassword(password: string): Promise<ConnectResult>;
|
|
384
|
+
/** Turn the password path off, revoking the token account-wide. */
|
|
385
|
+
removeUnlockPassword(): Promise<void>;
|
|
362
386
|
/**
|
|
363
387
|
* Add a passkey to this device after the fact, re-wrapping its device share
|
|
364
388
|
* under it.
|
|
@@ -581,6 +605,22 @@ declare class ApiClient {
|
|
|
581
605
|
*/
|
|
582
606
|
getWebAuthnLoginOptions(userId: string, rpId: string): Promise<_simplewebauthn_browser.PublicKeyCredentialRequestOptionsJSON | null>;
|
|
583
607
|
postWebAuthnLogin(userId: string, response: _simplewebauthn_browser.AuthenticationResponseJSON, origin: string): Promise<AuthResult>;
|
|
608
|
+
/**
|
|
609
|
+
* Issue this device an unlock token. Returned in the clear once and never
|
|
610
|
+
* again — the backend stores only its hash — so the caller must encrypt and
|
|
611
|
+
* persist it before the value is dropped.
|
|
612
|
+
*/
|
|
613
|
+
issueUnlockToken(jwt: string): Promise<{
|
|
614
|
+
token: string;
|
|
615
|
+
expiresInDays: number;
|
|
616
|
+
}>;
|
|
617
|
+
/** Redeem a decrypted unlock token for a session. */
|
|
618
|
+
exchangeUnlockToken(token: string): Promise<{
|
|
619
|
+
jwt: string;
|
|
620
|
+
userId: string;
|
|
621
|
+
}>;
|
|
622
|
+
/** Turn the password path off account-wide, so a lost device stops working. */
|
|
623
|
+
revokeUnlockTokens(jwt: string): Promise<void>;
|
|
584
624
|
revoke(jwt: string): Promise<void>;
|
|
585
625
|
hasRecoveryBackup(jwt: string): Promise<boolean>;
|
|
586
626
|
getRecoveryBackup(jwt: string): Promise<{
|
|
@@ -715,6 +755,17 @@ interface SocialConfig {
|
|
|
715
755
|
*/
|
|
716
756
|
kingsChatScopes?: string[];
|
|
717
757
|
promptPin?: () => Promise<string>;
|
|
758
|
+
/**
|
|
759
|
+
* Called when the SDK needs the device unlock password — to choose one
|
|
760
|
+
* (`kind: 'set'`, ask twice) or to enter it (`kind: 'unlock'`).
|
|
761
|
+
*
|
|
762
|
+
* Required on any device using "unlock with your password". Unlike promptPin,
|
|
763
|
+
* this secret can open a session on its own, so never log or persist it and
|
|
764
|
+
* let a password manager fill it.
|
|
765
|
+
*/
|
|
766
|
+
promptUnlockPassword?: (ctx: {
|
|
767
|
+
kind: 'set' | 'unlock';
|
|
768
|
+
}) => Promise<string>;
|
|
718
769
|
apiBaseUrl?: string;
|
|
719
770
|
chains?: string[];
|
|
720
771
|
rpcUrls?: Record<string, string>;
|
|
@@ -977,6 +1028,15 @@ declare class StaleDeviceShareError extends DecaneConnectError {
|
|
|
977
1028
|
declare class PromptPinNotConfiguredError extends DecaneConnectError {
|
|
978
1029
|
constructor();
|
|
979
1030
|
}
|
|
1031
|
+
declare class PromptPasswordNotConfiguredError extends DecaneConnectError {
|
|
1032
|
+
constructor();
|
|
1033
|
+
}
|
|
1034
|
+
declare class WrongUnlockPasswordError extends DecaneConnectError {
|
|
1035
|
+
constructor();
|
|
1036
|
+
}
|
|
1037
|
+
declare class UnlockTokenRejectedError extends DecaneConnectError {
|
|
1038
|
+
constructor();
|
|
1039
|
+
}
|
|
980
1040
|
declare class AttestationError extends DecaneConnectError {
|
|
981
1041
|
constructor(msg: string);
|
|
982
1042
|
}
|
|
@@ -1313,6 +1373,10 @@ declare function useSocialWallet(): {
|
|
|
1313
1373
|
getAccessToken: () => string | null;
|
|
1314
1374
|
hasPasskey: () => Promise<boolean>;
|
|
1315
1375
|
addPasskey: () => Promise<void>;
|
|
1376
|
+
setUnlockPassword: (password: string) => Promise<void>;
|
|
1377
|
+
canUnlockWithPassword: () => Promise<boolean>;
|
|
1378
|
+
unlockWithPassword: (password: string) => Promise<void>;
|
|
1379
|
+
removeUnlockPassword: () => Promise<void>;
|
|
1316
1380
|
rotateShares: (opts: {
|
|
1317
1381
|
password: string;
|
|
1318
1382
|
passwordHint?: string;
|
|
@@ -1409,4 +1473,16 @@ declare function useSignTypedData(): {
|
|
|
1409
1473
|
reset: () => void;
|
|
1410
1474
|
};
|
|
1411
1475
|
|
|
1412
|
-
|
|
1476
|
+
declare const MIN_PASSWORD_LENGTH = 12;
|
|
1477
|
+
declare class WeakPasswordError extends Error {
|
|
1478
|
+
constructor(message: string);
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Reject what cannot carry the weight this secret now bears.
|
|
1482
|
+
*
|
|
1483
|
+
* Intentionally not a strength meter: a score shown to a user is advice, and
|
|
1484
|
+
* this is a floor. Anything above the floor is the user's call.
|
|
1485
|
+
*/
|
|
1486
|
+
declare function validateUnlockPassword(password: string): void;
|
|
1487
|
+
|
|
1488
|
+
export { type ActiveSession, AttestationError, type AuthProfile, type AuthResult, BUILT_IN_CHAINS, type BalanceResult, type CAIP25Method, type CAIP25SessionRequest, type CAIP25SessionResult, CHAINS, CallSequenceError, type Chain, type ChainDescriptor, type ChainId, type ChainScope, type ChainSupport, type ChainType, type ConnectMode, type ConnectResult, type DecaneConfig, type DecaneConnect, type DecaneConnectConfig, DecaneConnectError, DecaneError, DecaneErrorCode, DecaneKit, DecaneLogo, DecaneMark, type DecaneProvider, DecaneWordmark, type Eip1193Provider, type EthereumProviderOptions, ExportNotAuthorizedError, InvalidApiKeyError, InvalidPinError, InvalidRecoveryFileError, type KingsChatTokens, MIN_PASSWORD_LENGTH, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPasswordNotConfiguredError, PromptPinNotConfiguredError, ProvisioningTimeoutError, ReconnectRequiredError, type RecordTransactionInput, RecoveryFailedError, type RecoveryProgress, type RecoveryShareFile, RecoveryWalletMismatchError, type SdkEvent, type SendTransactionRequest, SessionExpiredError, ShareCorruptedError, type SignMessageRequest, type SignTypedDataRequest, type SignedAuthorization, type SocialAuthState, type SocialConfig, SocialWalletModal, StaleDeviceShareError, type Theme, type TransactionRecord, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UnlockTokenRejectedError, UserCancelledError, WalletSelector, WeakPasswordError, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, WrongUnlockPasswordError, createDecane, createDecaneConnect, createEthereumProvider, loginWithKingsChatPopup, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, validateUnlockPassword, verifyEmailCode };
|