decane-connect-kit 2.5.0 → 2.6.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 +368 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -7
- package/dist/index.d.ts +122 -7
- package/dist/index.js +366 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -76,7 +76,12 @@ interface DecaneProvider {
|
|
|
76
76
|
type ConnectMode = "all" | "social" | "wallets" | "evm" | "solana" | "tron" | "evm+social" | "solana+social" | "tron+social" | "evm+tron" | "evm+tron+social";
|
|
77
77
|
interface SocialConfig {
|
|
78
78
|
apiKey: string;
|
|
79
|
-
authMethods?: ("google" | "email")[];
|
|
79
|
+
authMethods?: ("google" | "email" | "kingschat")[];
|
|
80
|
+
/**
|
|
81
|
+
* Scopes requested from KingsChat. Defaults to `['send_chat_message']`, which
|
|
82
|
+
* is what KingsChat's own SDK asks for and is enough to establish identity.
|
|
83
|
+
*/
|
|
84
|
+
kingsChatScopes?: string[];
|
|
80
85
|
promptPin?: () => Promise<string>;
|
|
81
86
|
apiBaseUrl?: string;
|
|
82
87
|
chains?: string[];
|
|
@@ -170,6 +175,23 @@ declare class ApiClient {
|
|
|
170
175
|
getGoogleInitUrl(): Promise<{
|
|
171
176
|
url: string;
|
|
172
177
|
}>;
|
|
178
|
+
/**
|
|
179
|
+
* Exchange a Google ID token the app already holds for a Decane session.
|
|
180
|
+
* Resolves to the SAME identity as the redirect flow, so one Google account
|
|
181
|
+
* means one wallet across web and mobile.
|
|
182
|
+
*/
|
|
183
|
+
authGoogleToken(idToken: string): Promise<AuthResult>;
|
|
184
|
+
/** The project's KingsChat clientId, so the dApp never has to hardcode it. */
|
|
185
|
+
getKingsChatConfig(): Promise<{
|
|
186
|
+
clientId: string;
|
|
187
|
+
authorizationUrl: string;
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Exchange a KingsChat access token for a Decane session. The backend spends
|
|
191
|
+
* the token against KingsChat's own API to establish the identity — it is
|
|
192
|
+
* never trusted on its face, and never stored.
|
|
193
|
+
*/
|
|
194
|
+
authKingsChat(accessToken: string): Promise<AuthResult>;
|
|
173
195
|
authEmailStart(email: string): Promise<void>;
|
|
174
196
|
authEmailVerify(email: string, code: string): Promise<AuthResult>;
|
|
175
197
|
getAddresses(jwt: string): Promise<{
|
|
@@ -346,7 +368,15 @@ interface DecaneConnectConfig {
|
|
|
346
368
|
appId: string;
|
|
347
369
|
apiKey: string;
|
|
348
370
|
chains: Chain[];
|
|
349
|
-
authMethods: Array<'google' | 'email'>;
|
|
371
|
+
authMethods: Array<'google' | 'email' | 'kingschat'>;
|
|
372
|
+
/**
|
|
373
|
+
* Scopes requested from KingsChat at sign-in. Defaults to
|
|
374
|
+
* `['send_chat_message']`, which is what KingsChat's own SDK asks for and is
|
|
375
|
+
* enough to establish identity. Widen only if the app actually calls
|
|
376
|
+
* KingsChat APIs on the user's behalf — the consent screen lists every scope,
|
|
377
|
+
* so asking for more than you use costs conversions.
|
|
378
|
+
*/
|
|
379
|
+
kingsChatScopes?: string[];
|
|
350
380
|
apiBaseUrl?: string;
|
|
351
381
|
sessionDurationMinutes?: number;
|
|
352
382
|
promptPin?: () => Promise<string>;
|
|
@@ -412,6 +442,32 @@ interface DecaneConnectConfig {
|
|
|
412
442
|
}>;
|
|
413
443
|
/** Recovery stage callbacks, for dApp UI. */
|
|
414
444
|
onRecoveryProgress?: (event: RecoveryProgress) => void;
|
|
445
|
+
/**
|
|
446
|
+
* Rotate the whole share set whenever a NEW device recovers via passkey sync
|
|
447
|
+
* (Flow A) — the "every device holds a distinct share" model.
|
|
448
|
+
*
|
|
449
|
+
* Default false, which preserves the historical behaviour: every device
|
|
450
|
+
* synced to the same passkey caches the byte-identical wrapped share, so a
|
|
451
|
+
* device that is later lost keeps a share that stays valid until someone
|
|
452
|
+
* explicitly calls rotateShares(). There is no way to revoke one device
|
|
453
|
+
* without revoking all of them.
|
|
454
|
+
*
|
|
455
|
+
* With this on, joining a new device re-splits the master and issues that
|
|
456
|
+
* device its own share, which invalidates every other device's cached copy
|
|
457
|
+
* at the same instant. That is what makes per-device revocation possible,
|
|
458
|
+
* and it has three consequences worth accepting deliberately:
|
|
459
|
+
*
|
|
460
|
+
* - **Other devices are logged out, not just the lost one.** Each surviving
|
|
461
|
+
* device hits StaleDeviceShareError on its next unlock, clears its share,
|
|
462
|
+
* and silently re-recovers through Flow A (one passkey prompt). Expected,
|
|
463
|
+
* but it means a shared-family-device setup re-prompts more often.
|
|
464
|
+
* - **The user's recovery FILE dies too.** Rotation issues a new recovery
|
|
465
|
+
* share, so `onRecoveryRotated` MUST be configured to capture it —
|
|
466
|
+
* enabling this without that callback throws at connect time rather than
|
|
467
|
+
* stranding the user with a dead file.
|
|
468
|
+
* - **Adding a device costs a TEE round trip.** Recovery is slower.
|
|
469
|
+
*/
|
|
470
|
+
rotateOnNewDeviceRecovery?: boolean;
|
|
415
471
|
}
|
|
416
472
|
interface ConnectResult {
|
|
417
473
|
addresses: {
|
|
@@ -467,6 +523,30 @@ type SdkEvent = 'connected' | 'disconnected' | 'session-expired' | 'session-star
|
|
|
467
523
|
interface DecaneConnect {
|
|
468
524
|
connect(): Promise<ConnectResult>;
|
|
469
525
|
connectWithGoogle(): Promise<ConnectResult>;
|
|
526
|
+
/**
|
|
527
|
+
* Sign in with a Google ID token the app already obtained — native Google
|
|
528
|
+
* Sign-In on mobile, or Google Identity Services on the web.
|
|
529
|
+
*
|
|
530
|
+
* Resolves to the SAME wallet as connectWithGoogle(): both end at the
|
|
531
|
+
* backend's Google identity, so a user who signs in on your website and then
|
|
532
|
+
* on your app lands on one wallet, not two.
|
|
533
|
+
*/
|
|
534
|
+
connectWithGoogleToken(idToken: string): Promise<ConnectResult>;
|
|
535
|
+
/**
|
|
536
|
+
* Sign in with KingsChat.
|
|
537
|
+
*
|
|
538
|
+
* Opens KingsChat's consent screen in a popup, so this MUST be called
|
|
539
|
+
* directly from a click handler — a popup opened after an await is blocked by
|
|
540
|
+
* every browser. The resulting access token is exchanged server-side for a
|
|
541
|
+
* Decane session; it is never treated as one on its own.
|
|
542
|
+
*/
|
|
543
|
+
connectWithKingsChat(): Promise<ConnectResult>;
|
|
544
|
+
/**
|
|
545
|
+
* Sign in with a KingsChat access token the app already holds — from
|
|
546
|
+
* kingschat-web-sdk, a native SDK, or any other flow. Use when you want to
|
|
547
|
+
* own the consent step yourself; connectWithKingsChat() is the turnkey path.
|
|
548
|
+
*/
|
|
549
|
+
connectWithKingsChatToken(accessToken: string): Promise<ConnectResult>;
|
|
470
550
|
connectWithEmail(email: string): Promise<{
|
|
471
551
|
codeRequired: true;
|
|
472
552
|
}>;
|
|
@@ -640,6 +720,24 @@ declare function startEmailAuth(api: ApiClient, email: string): Promise<void>;
|
|
|
640
720
|
*/
|
|
641
721
|
declare function verifyEmailCode(api: ApiClient, email: string, code: string): Promise<AuthResult>;
|
|
642
722
|
|
|
723
|
+
interface KingsChatTokens {
|
|
724
|
+
accessToken: string;
|
|
725
|
+
refreshToken?: string;
|
|
726
|
+
expiresInMillis?: number;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Open the KingsChat consent popup and resolve with the tokens it returns.
|
|
730
|
+
*
|
|
731
|
+
* Must be called synchronously from a user gesture (a click handler) — popup
|
|
732
|
+
* blockers reject a window.open that happens after an await, which is why the
|
|
733
|
+
* clientId is fetched by the caller *before* this runs.
|
|
734
|
+
*/
|
|
735
|
+
declare function loginWithKingsChatPopup(opts: {
|
|
736
|
+
clientId: string;
|
|
737
|
+
scopes?: string[];
|
|
738
|
+
timeoutMs?: number;
|
|
739
|
+
}): Promise<KingsChatTokens>;
|
|
740
|
+
|
|
643
741
|
declare class DecaneConnectError extends Error {
|
|
644
742
|
code: string;
|
|
645
743
|
retryable: boolean;
|
|
@@ -694,6 +792,21 @@ declare class ShareCorruptedError extends DecaneConnectError {
|
|
|
694
792
|
declare class NewDeviceError extends DecaneConnectError {
|
|
695
793
|
constructor();
|
|
696
794
|
}
|
|
795
|
+
/**
|
|
796
|
+
* The device share this device just used no longer reconstructs the account's
|
|
797
|
+
* real key — almost always because another device recovered via passkey sync
|
|
798
|
+
* since and rotated the whole share set (see rotateOnNewDeviceRecovery in
|
|
799
|
+
* DecaneConnectConfig), silently invalidating every other device's cached
|
|
800
|
+
* copy. Thrown instead of signing: two mismatched shares from different
|
|
801
|
+
* share-set versions still combine to *something*, just not the user's real
|
|
802
|
+
* key, so continuing would risk operating on a wrong (though not
|
|
803
|
+
* attacker-chosen) address. The stale local share is cleared by the caller
|
|
804
|
+
* before this propagates, so the next connect() naturally falls through to
|
|
805
|
+
* recovery instead of repeating the same failure.
|
|
806
|
+
*/
|
|
807
|
+
declare class StaleDeviceShareError extends DecaneConnectError {
|
|
808
|
+
constructor();
|
|
809
|
+
}
|
|
697
810
|
declare class PromptPinNotConfiguredError extends DecaneConnectError {
|
|
698
811
|
constructor();
|
|
699
812
|
}
|
|
@@ -812,8 +925,9 @@ interface WalletSelectorProps {
|
|
|
812
925
|
theme?: "light" | "dark" | "auto";
|
|
813
926
|
networks?: "evm" | "solana" | "tron" | "bitcoin" | "all";
|
|
814
927
|
mode?: ConnectMode;
|
|
815
|
-
socialAuthMethods?: ("google" | "email")[];
|
|
928
|
+
socialAuthMethods?: ("google" | "email" | "kingschat")[];
|
|
816
929
|
onGoogleSignIn?: () => Promise<void>;
|
|
930
|
+
onKingsChatSignIn?: () => Promise<void>;
|
|
817
931
|
onEmailStart?: (email: string) => Promise<{
|
|
818
932
|
codeRequired: true;
|
|
819
933
|
}>;
|
|
@@ -827,7 +941,7 @@ interface WalletSelectorProps {
|
|
|
827
941
|
passkeyAddress?: string | null;
|
|
828
942
|
onPasskeySignIn?: () => Promise<unknown>;
|
|
829
943
|
}
|
|
830
|
-
declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, mode, socialAuthMethods, onGoogleSignIn, onEmailStart, onEmailVerify, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, }: WalletSelectorProps): React.ReactPortal | null;
|
|
944
|
+
declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, mode, socialAuthMethods, onGoogleSignIn, onKingsChatSignIn, onEmailStart, onEmailVerify, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, }: WalletSelectorProps): React.ReactPortal | null;
|
|
831
945
|
|
|
832
946
|
type Theme = "light" | "dark" | "auto";
|
|
833
947
|
interface SocialAuthState {
|
|
@@ -876,11 +990,12 @@ interface SocialWalletModalProps {
|
|
|
876
990
|
onUnlock: () => Promise<void>;
|
|
877
991
|
onDisconnect: () => Promise<void>;
|
|
878
992
|
onGoogleSignIn: () => Promise<void>;
|
|
993
|
+
onKingsChatSignIn?: () => Promise<void>;
|
|
879
994
|
onEmailStart: (email: string) => Promise<{
|
|
880
995
|
codeRequired: true;
|
|
881
996
|
}>;
|
|
882
997
|
onEmailVerify: (email: string, code: string) => Promise<void>;
|
|
883
|
-
authMethods?: Array<"google" | "email">;
|
|
998
|
+
authMethods?: Array<"google" | "email" | "kingschat">;
|
|
884
999
|
customAuthLabel?: string;
|
|
885
1000
|
onCustomAuthSignIn?: () => Promise<void>;
|
|
886
1001
|
canUsePasskey?: boolean;
|
|
@@ -897,7 +1012,7 @@ interface SocialWalletModalProps {
|
|
|
897
1012
|
rpcUrls?: Record<string, string>;
|
|
898
1013
|
chains?: string[];
|
|
899
1014
|
}
|
|
900
|
-
declare function SocialWalletModal({ open, onClose, theme, socialAuth, onUnlock, onDisconnect, onGoogleSignIn, onEmailStart, onEmailVerify, authMethods, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, onRotateShares, onExportPortableBackup, rpcUrls, chains, }: SocialWalletModalProps): React.ReactPortal | null;
|
|
1015
|
+
declare function SocialWalletModal({ open, onClose, theme, socialAuth, onUnlock, onDisconnect, onGoogleSignIn, onKingsChatSignIn, onEmailStart, onEmailVerify, authMethods, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, onRotateShares, onExportPortableBackup, rpcUrls, chains, }: SocialWalletModalProps): React.ReactPortal | null;
|
|
901
1016
|
|
|
902
1017
|
declare function DecaneMark({ size, muted }: {
|
|
903
1018
|
size?: number;
|
|
@@ -1095,4 +1210,4 @@ declare function useSignTypedData(): {
|
|
|
1095
1210
|
reset: () => void;
|
|
1096
1211
|
};
|
|
1097
1212
|
|
|
1098
|
-
export { type ActiveSession, AttestationError, 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, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, 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, type Theme, type TransactionRecord, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, createEthereumProvider, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, verifyEmailCode };
|
|
1213
|
+
export { type ActiveSession, AttestationError, 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, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, 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, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, createEthereumProvider, loginWithKingsChatPopup, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, verifyEmailCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -76,7 +76,12 @@ interface DecaneProvider {
|
|
|
76
76
|
type ConnectMode = "all" | "social" | "wallets" | "evm" | "solana" | "tron" | "evm+social" | "solana+social" | "tron+social" | "evm+tron" | "evm+tron+social";
|
|
77
77
|
interface SocialConfig {
|
|
78
78
|
apiKey: string;
|
|
79
|
-
authMethods?: ("google" | "email")[];
|
|
79
|
+
authMethods?: ("google" | "email" | "kingschat")[];
|
|
80
|
+
/**
|
|
81
|
+
* Scopes requested from KingsChat. Defaults to `['send_chat_message']`, which
|
|
82
|
+
* is what KingsChat's own SDK asks for and is enough to establish identity.
|
|
83
|
+
*/
|
|
84
|
+
kingsChatScopes?: string[];
|
|
80
85
|
promptPin?: () => Promise<string>;
|
|
81
86
|
apiBaseUrl?: string;
|
|
82
87
|
chains?: string[];
|
|
@@ -170,6 +175,23 @@ declare class ApiClient {
|
|
|
170
175
|
getGoogleInitUrl(): Promise<{
|
|
171
176
|
url: string;
|
|
172
177
|
}>;
|
|
178
|
+
/**
|
|
179
|
+
* Exchange a Google ID token the app already holds for a Decane session.
|
|
180
|
+
* Resolves to the SAME identity as the redirect flow, so one Google account
|
|
181
|
+
* means one wallet across web and mobile.
|
|
182
|
+
*/
|
|
183
|
+
authGoogleToken(idToken: string): Promise<AuthResult>;
|
|
184
|
+
/** The project's KingsChat clientId, so the dApp never has to hardcode it. */
|
|
185
|
+
getKingsChatConfig(): Promise<{
|
|
186
|
+
clientId: string;
|
|
187
|
+
authorizationUrl: string;
|
|
188
|
+
}>;
|
|
189
|
+
/**
|
|
190
|
+
* Exchange a KingsChat access token for a Decane session. The backend spends
|
|
191
|
+
* the token against KingsChat's own API to establish the identity — it is
|
|
192
|
+
* never trusted on its face, and never stored.
|
|
193
|
+
*/
|
|
194
|
+
authKingsChat(accessToken: string): Promise<AuthResult>;
|
|
173
195
|
authEmailStart(email: string): Promise<void>;
|
|
174
196
|
authEmailVerify(email: string, code: string): Promise<AuthResult>;
|
|
175
197
|
getAddresses(jwt: string): Promise<{
|
|
@@ -346,7 +368,15 @@ interface DecaneConnectConfig {
|
|
|
346
368
|
appId: string;
|
|
347
369
|
apiKey: string;
|
|
348
370
|
chains: Chain[];
|
|
349
|
-
authMethods: Array<'google' | 'email'>;
|
|
371
|
+
authMethods: Array<'google' | 'email' | 'kingschat'>;
|
|
372
|
+
/**
|
|
373
|
+
* Scopes requested from KingsChat at sign-in. Defaults to
|
|
374
|
+
* `['send_chat_message']`, which is what KingsChat's own SDK asks for and is
|
|
375
|
+
* enough to establish identity. Widen only if the app actually calls
|
|
376
|
+
* KingsChat APIs on the user's behalf — the consent screen lists every scope,
|
|
377
|
+
* so asking for more than you use costs conversions.
|
|
378
|
+
*/
|
|
379
|
+
kingsChatScopes?: string[];
|
|
350
380
|
apiBaseUrl?: string;
|
|
351
381
|
sessionDurationMinutes?: number;
|
|
352
382
|
promptPin?: () => Promise<string>;
|
|
@@ -412,6 +442,32 @@ interface DecaneConnectConfig {
|
|
|
412
442
|
}>;
|
|
413
443
|
/** Recovery stage callbacks, for dApp UI. */
|
|
414
444
|
onRecoveryProgress?: (event: RecoveryProgress) => void;
|
|
445
|
+
/**
|
|
446
|
+
* Rotate the whole share set whenever a NEW device recovers via passkey sync
|
|
447
|
+
* (Flow A) — the "every device holds a distinct share" model.
|
|
448
|
+
*
|
|
449
|
+
* Default false, which preserves the historical behaviour: every device
|
|
450
|
+
* synced to the same passkey caches the byte-identical wrapped share, so a
|
|
451
|
+
* device that is later lost keeps a share that stays valid until someone
|
|
452
|
+
* explicitly calls rotateShares(). There is no way to revoke one device
|
|
453
|
+
* without revoking all of them.
|
|
454
|
+
*
|
|
455
|
+
* With this on, joining a new device re-splits the master and issues that
|
|
456
|
+
* device its own share, which invalidates every other device's cached copy
|
|
457
|
+
* at the same instant. That is what makes per-device revocation possible,
|
|
458
|
+
* and it has three consequences worth accepting deliberately:
|
|
459
|
+
*
|
|
460
|
+
* - **Other devices are logged out, not just the lost one.** Each surviving
|
|
461
|
+
* device hits StaleDeviceShareError on its next unlock, clears its share,
|
|
462
|
+
* and silently re-recovers through Flow A (one passkey prompt). Expected,
|
|
463
|
+
* but it means a shared-family-device setup re-prompts more often.
|
|
464
|
+
* - **The user's recovery FILE dies too.** Rotation issues a new recovery
|
|
465
|
+
* share, so `onRecoveryRotated` MUST be configured to capture it —
|
|
466
|
+
* enabling this without that callback throws at connect time rather than
|
|
467
|
+
* stranding the user with a dead file.
|
|
468
|
+
* - **Adding a device costs a TEE round trip.** Recovery is slower.
|
|
469
|
+
*/
|
|
470
|
+
rotateOnNewDeviceRecovery?: boolean;
|
|
415
471
|
}
|
|
416
472
|
interface ConnectResult {
|
|
417
473
|
addresses: {
|
|
@@ -467,6 +523,30 @@ type SdkEvent = 'connected' | 'disconnected' | 'session-expired' | 'session-star
|
|
|
467
523
|
interface DecaneConnect {
|
|
468
524
|
connect(): Promise<ConnectResult>;
|
|
469
525
|
connectWithGoogle(): Promise<ConnectResult>;
|
|
526
|
+
/**
|
|
527
|
+
* Sign in with a Google ID token the app already obtained — native Google
|
|
528
|
+
* Sign-In on mobile, or Google Identity Services on the web.
|
|
529
|
+
*
|
|
530
|
+
* Resolves to the SAME wallet as connectWithGoogle(): both end at the
|
|
531
|
+
* backend's Google identity, so a user who signs in on your website and then
|
|
532
|
+
* on your app lands on one wallet, not two.
|
|
533
|
+
*/
|
|
534
|
+
connectWithGoogleToken(idToken: string): Promise<ConnectResult>;
|
|
535
|
+
/**
|
|
536
|
+
* Sign in with KingsChat.
|
|
537
|
+
*
|
|
538
|
+
* Opens KingsChat's consent screen in a popup, so this MUST be called
|
|
539
|
+
* directly from a click handler — a popup opened after an await is blocked by
|
|
540
|
+
* every browser. The resulting access token is exchanged server-side for a
|
|
541
|
+
* Decane session; it is never treated as one on its own.
|
|
542
|
+
*/
|
|
543
|
+
connectWithKingsChat(): Promise<ConnectResult>;
|
|
544
|
+
/**
|
|
545
|
+
* Sign in with a KingsChat access token the app already holds — from
|
|
546
|
+
* kingschat-web-sdk, a native SDK, or any other flow. Use when you want to
|
|
547
|
+
* own the consent step yourself; connectWithKingsChat() is the turnkey path.
|
|
548
|
+
*/
|
|
549
|
+
connectWithKingsChatToken(accessToken: string): Promise<ConnectResult>;
|
|
470
550
|
connectWithEmail(email: string): Promise<{
|
|
471
551
|
codeRequired: true;
|
|
472
552
|
}>;
|
|
@@ -640,6 +720,24 @@ declare function startEmailAuth(api: ApiClient, email: string): Promise<void>;
|
|
|
640
720
|
*/
|
|
641
721
|
declare function verifyEmailCode(api: ApiClient, email: string, code: string): Promise<AuthResult>;
|
|
642
722
|
|
|
723
|
+
interface KingsChatTokens {
|
|
724
|
+
accessToken: string;
|
|
725
|
+
refreshToken?: string;
|
|
726
|
+
expiresInMillis?: number;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Open the KingsChat consent popup and resolve with the tokens it returns.
|
|
730
|
+
*
|
|
731
|
+
* Must be called synchronously from a user gesture (a click handler) — popup
|
|
732
|
+
* blockers reject a window.open that happens after an await, which is why the
|
|
733
|
+
* clientId is fetched by the caller *before* this runs.
|
|
734
|
+
*/
|
|
735
|
+
declare function loginWithKingsChatPopup(opts: {
|
|
736
|
+
clientId: string;
|
|
737
|
+
scopes?: string[];
|
|
738
|
+
timeoutMs?: number;
|
|
739
|
+
}): Promise<KingsChatTokens>;
|
|
740
|
+
|
|
643
741
|
declare class DecaneConnectError extends Error {
|
|
644
742
|
code: string;
|
|
645
743
|
retryable: boolean;
|
|
@@ -694,6 +792,21 @@ declare class ShareCorruptedError extends DecaneConnectError {
|
|
|
694
792
|
declare class NewDeviceError extends DecaneConnectError {
|
|
695
793
|
constructor();
|
|
696
794
|
}
|
|
795
|
+
/**
|
|
796
|
+
* The device share this device just used no longer reconstructs the account's
|
|
797
|
+
* real key — almost always because another device recovered via passkey sync
|
|
798
|
+
* since and rotated the whole share set (see rotateOnNewDeviceRecovery in
|
|
799
|
+
* DecaneConnectConfig), silently invalidating every other device's cached
|
|
800
|
+
* copy. Thrown instead of signing: two mismatched shares from different
|
|
801
|
+
* share-set versions still combine to *something*, just not the user's real
|
|
802
|
+
* key, so continuing would risk operating on a wrong (though not
|
|
803
|
+
* attacker-chosen) address. The stale local share is cleared by the caller
|
|
804
|
+
* before this propagates, so the next connect() naturally falls through to
|
|
805
|
+
* recovery instead of repeating the same failure.
|
|
806
|
+
*/
|
|
807
|
+
declare class StaleDeviceShareError extends DecaneConnectError {
|
|
808
|
+
constructor();
|
|
809
|
+
}
|
|
697
810
|
declare class PromptPinNotConfiguredError extends DecaneConnectError {
|
|
698
811
|
constructor();
|
|
699
812
|
}
|
|
@@ -812,8 +925,9 @@ interface WalletSelectorProps {
|
|
|
812
925
|
theme?: "light" | "dark" | "auto";
|
|
813
926
|
networks?: "evm" | "solana" | "tron" | "bitcoin" | "all";
|
|
814
927
|
mode?: ConnectMode;
|
|
815
|
-
socialAuthMethods?: ("google" | "email")[];
|
|
928
|
+
socialAuthMethods?: ("google" | "email" | "kingschat")[];
|
|
816
929
|
onGoogleSignIn?: () => Promise<void>;
|
|
930
|
+
onKingsChatSignIn?: () => Promise<void>;
|
|
817
931
|
onEmailStart?: (email: string) => Promise<{
|
|
818
932
|
codeRequired: true;
|
|
819
933
|
}>;
|
|
@@ -827,7 +941,7 @@ interface WalletSelectorProps {
|
|
|
827
941
|
passkeyAddress?: string | null;
|
|
828
942
|
onPasskeySignIn?: () => Promise<unknown>;
|
|
829
943
|
}
|
|
830
|
-
declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, mode, socialAuthMethods, onGoogleSignIn, onEmailStart, onEmailVerify, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, }: WalletSelectorProps): React.ReactPortal | null;
|
|
944
|
+
declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, mode, socialAuthMethods, onGoogleSignIn, onKingsChatSignIn, onEmailStart, onEmailVerify, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, }: WalletSelectorProps): React.ReactPortal | null;
|
|
831
945
|
|
|
832
946
|
type Theme = "light" | "dark" | "auto";
|
|
833
947
|
interface SocialAuthState {
|
|
@@ -876,11 +990,12 @@ interface SocialWalletModalProps {
|
|
|
876
990
|
onUnlock: () => Promise<void>;
|
|
877
991
|
onDisconnect: () => Promise<void>;
|
|
878
992
|
onGoogleSignIn: () => Promise<void>;
|
|
993
|
+
onKingsChatSignIn?: () => Promise<void>;
|
|
879
994
|
onEmailStart: (email: string) => Promise<{
|
|
880
995
|
codeRequired: true;
|
|
881
996
|
}>;
|
|
882
997
|
onEmailVerify: (email: string, code: string) => Promise<void>;
|
|
883
|
-
authMethods?: Array<"google" | "email">;
|
|
998
|
+
authMethods?: Array<"google" | "email" | "kingschat">;
|
|
884
999
|
customAuthLabel?: string;
|
|
885
1000
|
onCustomAuthSignIn?: () => Promise<void>;
|
|
886
1001
|
canUsePasskey?: boolean;
|
|
@@ -897,7 +1012,7 @@ interface SocialWalletModalProps {
|
|
|
897
1012
|
rpcUrls?: Record<string, string>;
|
|
898
1013
|
chains?: string[];
|
|
899
1014
|
}
|
|
900
|
-
declare function SocialWalletModal({ open, onClose, theme, socialAuth, onUnlock, onDisconnect, onGoogleSignIn, onEmailStart, onEmailVerify, authMethods, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, onRotateShares, onExportPortableBackup, rpcUrls, chains, }: SocialWalletModalProps): React.ReactPortal | null;
|
|
1015
|
+
declare function SocialWalletModal({ open, onClose, theme, socialAuth, onUnlock, onDisconnect, onGoogleSignIn, onKingsChatSignIn, onEmailStart, onEmailVerify, authMethods, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, onRotateShares, onExportPortableBackup, rpcUrls, chains, }: SocialWalletModalProps): React.ReactPortal | null;
|
|
901
1016
|
|
|
902
1017
|
declare function DecaneMark({ size, muted }: {
|
|
903
1018
|
size?: number;
|
|
@@ -1095,4 +1210,4 @@ declare function useSignTypedData(): {
|
|
|
1095
1210
|
reset: () => void;
|
|
1096
1211
|
};
|
|
1097
1212
|
|
|
1098
|
-
export { type ActiveSession, AttestationError, 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, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, 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, type Theme, type TransactionRecord, type TxParams, type UnifiedWalletAccount, UnlockRequiredError, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, createEthereumProvider, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, verifyEmailCode };
|
|
1213
|
+
export { type ActiveSession, AttestationError, 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, NetworkError, NewDeviceError, OriginNotAllowedError, type PortableBackup, PromptPinNotConfiguredError, 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, UserCancelledError, WalletSelector, WebAuthnNotSupportedError, type WrappedShareMeta, WrongPasswordError, createDecane, createDecaneConnect, createEthereumProvider, loginWithKingsChatPopup, startEmailAuth, useChainSwitch, useDecane, useEthereumProvider, useSendTransaction, useSignMessage, useSignTypedData, useSocialAuth, useSocialBalance, useSocialWallet, useWalletSelector, verifyEmailCode };
|