decane-connect-kit 2.19.0 → 2.21.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/dist/index.d.cts CHANGED
@@ -92,7 +92,7 @@ interface DecaneConnectConfig {
92
92
  appId: string;
93
93
  apiKey: string;
94
94
  chains: Chain[];
95
- authMethods: Array<'google' | 'email' | 'phone' | 'kingschat'>;
95
+ authMethods: Array<'google' | 'email' | 'phone' | 'kingschat' | 'x'>;
96
96
  /**
97
97
  * Scopes requested from KingsChat at sign-in. Defaults to
98
98
  * `['send_chat_message']`, which is what KingsChat's own SDK asks for and is
@@ -229,6 +229,8 @@ interface ConnectResult {
229
229
  isNewUser: boolean;
230
230
  /** Present when the provider released a profile — see {@link AuthProfile}. */
231
231
  profile?: AuthProfile;
232
+ /** See {@link AuthResult.providerSubject}. */
233
+ providerSubject?: string;
232
234
  }
233
235
  /** A recorded on-chain transaction in the user's history. */
234
236
  interface TransactionRecord {
@@ -303,6 +305,23 @@ interface DecaneConnect {
303
305
  * Decane session; it is never treated as one on its own.
304
306
  */
305
307
  connectWithKingsChat(): Promise<ConnectResult>;
308
+ /**
309
+ * Sign in with X (Twitter).
310
+ *
311
+ * A redirect, like Google and unlike KingsChat's popup: calling it navigates
312
+ * away, and the promise never resolves. Call it again on the page X returns
313
+ * to and it finishes the sign-in from the URL instead of starting a new one.
314
+ *
315
+ * X releases no email address, so `result.profile` carries a name and a
316
+ * picture and nothing else. Anything that needs an address must ask the user
317
+ * for one.
318
+ */
319
+ connectWithX(): Promise<ConnectResult>;
320
+ /**
321
+ * Finish a redirect sign-in already present in the URL, whichever provider
322
+ * started it. Throws when there is nothing to finish — it never starts one.
323
+ */
324
+ completeRedirectSignIn(): Promise<ConnectResult>;
306
325
  /**
307
326
  * Sign in with a KingsChat access token the app already holds — from
308
327
  * kingschat-web-sdk, a native SDK, or any other flow. Use when you want to
@@ -530,6 +549,16 @@ interface AuthProfile {
530
549
  name?: string;
531
550
  email?: string;
532
551
  picture?: string;
552
+ /**
553
+ * The handle the user signs in under, where the provider has one. X sets it
554
+ * and releases no email at all, so for those accounts this is the only
555
+ * human-readable thing there is.
556
+ *
557
+ * Display only. A handle can be released by its owner and registered by
558
+ * somebody else, so never key an account, a lookup or access on it — use
559
+ * {@link AuthResult.providerSubject}, which cannot move.
560
+ */
561
+ username?: string;
533
562
  }
534
563
  interface AuthResult {
535
564
  jwt: string;
@@ -537,6 +566,15 @@ interface AuthResult {
537
566
  hasShare: boolean;
538
567
  userId: string;
539
568
  profile?: AuthProfile;
569
+ /**
570
+ * The provider's own stable id for this user — X's numeric user id, for
571
+ * instance. Present only where the provider gives one.
572
+ *
573
+ * Unlike a handle or an email this cannot be reassigned, which is what makes
574
+ * it safe to match an account against: the same value identifies the same
575
+ * person on both sides of a migration.
576
+ */
577
+ providerSubject?: string;
540
578
  }
541
579
 
542
580
  declare class ApiClient {
@@ -548,6 +586,14 @@ declare class ApiClient {
548
586
  getGoogleInitUrl(): Promise<{
549
587
  url: string;
550
588
  }>;
589
+ /**
590
+ * The X consent URL. Same contract as Google's: the backend holds the client
591
+ * secret and the PKCE verifier, and answers 503 X_NOT_CONFIGURED when the
592
+ * deployment has no X credentials.
593
+ */
594
+ getXInitUrl(): Promise<{
595
+ url: string;
596
+ }>;
551
597
  /**
552
598
  * Exchange a Google ID token the app already holds for a Decane session.
553
599
  * Resolves to the SAME identity as the redirect flow, so one Google account
@@ -755,7 +801,7 @@ interface DecaneProvider {
755
801
  type ConnectMode = "all" | "social" | "wallets" | "evm" | "solana" | "tron" | "evm+social" | "solana+social" | "tron+social" | "evm+tron" | "evm+tron+social";
756
802
  interface SocialConfig {
757
803
  apiKey: string;
758
- authMethods?: ("google" | "email" | "phone" | "kingschat")[];
804
+ authMethods?: ("google" | "email" | "phone" | "kingschat" | "x")[];
759
805
  /**
760
806
  * Scopes requested from KingsChat. Defaults to `['send_chat_message']`, which
761
807
  * is what KingsChat's own SDK asks for and is enough to establish identity.
@@ -1159,9 +1205,10 @@ interface WalletSelectorProps {
1159
1205
  theme?: "light" | "dark" | "auto";
1160
1206
  networks?: "evm" | "solana" | "tron" | "bitcoin" | "all";
1161
1207
  mode?: ConnectMode;
1162
- socialAuthMethods?: ("google" | "email" | "phone" | "kingschat")[];
1208
+ socialAuthMethods?: ("google" | "email" | "phone" | "kingschat" | "x")[];
1163
1209
  onGoogleSignIn?: () => Promise<void>;
1164
1210
  onKingsChatSignIn?: () => Promise<void>;
1211
+ onXSignIn?: () => Promise<void>;
1165
1212
  onEmailStart?: (email: string) => Promise<{
1166
1213
  codeRequired: true;
1167
1214
  }>;
@@ -1179,7 +1226,7 @@ interface WalletSelectorProps {
1179
1226
  passkeyAddress?: string | null;
1180
1227
  onPasskeySignIn?: () => Promise<unknown>;
1181
1228
  }
1182
- declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, mode, socialAuthMethods, onGoogleSignIn, onKingsChatSignIn, onEmailStart, onEmailVerify, onPhoneStart, onPhoneVerify, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, }: WalletSelectorProps): React.ReactPortal | null;
1229
+ declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, mode, socialAuthMethods, onGoogleSignIn, onKingsChatSignIn, onXSignIn, onEmailStart, onEmailVerify, onPhoneStart, onPhoneVerify, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, }: WalletSelectorProps): React.ReactPortal | null;
1183
1230
 
1184
1231
  type Theme = "light" | "dark" | "auto";
1185
1232
  interface SocialAuthState {
@@ -1203,6 +1250,15 @@ interface SocialAuthState {
1203
1250
  * you need it in that state.
1204
1251
  */
1205
1252
  profile: AuthProfile | null;
1253
+ /**
1254
+ * The provider's own stable id for this user, where it gives one — X's
1255
+ * numeric user id, for instance. Null for providers that do not.
1256
+ *
1257
+ * Unlike a handle or an email this cannot be reassigned, so it is the value
1258
+ * to match an account against. Like `profile` it comes from the sign-in and
1259
+ * cannot be re-fetched, so copy it if you need it after a reload.
1260
+ */
1261
+ providerSubject: string | null;
1206
1262
  isUnlocked: boolean;
1207
1263
  sessionExpiresAt: number | null;
1208
1264
  /**
@@ -1243,6 +1299,7 @@ interface SocialWalletModalProps {
1243
1299
  onDisconnect: () => Promise<void>;
1244
1300
  onGoogleSignIn: () => Promise<void>;
1245
1301
  onKingsChatSignIn?: () => Promise<void>;
1302
+ onXSignIn?: () => Promise<void>;
1246
1303
  onEmailStart: (email: string) => Promise<{
1247
1304
  codeRequired: true;
1248
1305
  }>;
@@ -1251,7 +1308,7 @@ interface SocialWalletModalProps {
1251
1308
  codeRequired: true;
1252
1309
  }>;
1253
1310
  onPhoneVerify?: (phone: string, code: string) => Promise<void>;
1254
- authMethods?: Array<"google" | "email" | "phone" | "kingschat">;
1311
+ authMethods?: Array<"google" | "email" | "phone" | "kingschat" | "x">;
1255
1312
  customAuthLabel?: string;
1256
1313
  onCustomAuthSignIn?: () => Promise<void>;
1257
1314
  canUsePasskey?: boolean;
@@ -1295,11 +1352,13 @@ declare function useSocialAuth(): {
1295
1352
  sessionExpiresAt: number | null;
1296
1353
  canUsePasskey: boolean;
1297
1354
  profile: AuthProfile | null;
1355
+ providerSubject: string | null;
1298
1356
  phase: "creating" | "unlocking" | null;
1299
1357
  isCreatingWallet: boolean;
1300
1358
  needsReconnect: boolean;
1301
1359
  googleLoading: boolean;
1302
1360
  kingschatLoading: boolean;
1361
+ xLoading: boolean;
1303
1362
  emailLoading: boolean;
1304
1363
  phoneLoading: boolean;
1305
1364
  tokenLoading: boolean;
@@ -1309,6 +1368,7 @@ declare function useSocialAuth(): {
1309
1368
  clearError: () => void;
1310
1369
  signInWithGoogle: () => Promise<void>;
1311
1370
  signInWithKingsChat: () => Promise<void>;
1371
+ signInWithX: () => Promise<void>;
1312
1372
  sendEmailCode: (email: string) => Promise<{
1313
1373
  codeRequired: true;
1314
1374
  }>;
package/dist/index.d.ts CHANGED
@@ -92,7 +92,7 @@ interface DecaneConnectConfig {
92
92
  appId: string;
93
93
  apiKey: string;
94
94
  chains: Chain[];
95
- authMethods: Array<'google' | 'email' | 'phone' | 'kingschat'>;
95
+ authMethods: Array<'google' | 'email' | 'phone' | 'kingschat' | 'x'>;
96
96
  /**
97
97
  * Scopes requested from KingsChat at sign-in. Defaults to
98
98
  * `['send_chat_message']`, which is what KingsChat's own SDK asks for and is
@@ -229,6 +229,8 @@ interface ConnectResult {
229
229
  isNewUser: boolean;
230
230
  /** Present when the provider released a profile — see {@link AuthProfile}. */
231
231
  profile?: AuthProfile;
232
+ /** See {@link AuthResult.providerSubject}. */
233
+ providerSubject?: string;
232
234
  }
233
235
  /** A recorded on-chain transaction in the user's history. */
234
236
  interface TransactionRecord {
@@ -303,6 +305,23 @@ interface DecaneConnect {
303
305
  * Decane session; it is never treated as one on its own.
304
306
  */
305
307
  connectWithKingsChat(): Promise<ConnectResult>;
308
+ /**
309
+ * Sign in with X (Twitter).
310
+ *
311
+ * A redirect, like Google and unlike KingsChat's popup: calling it navigates
312
+ * away, and the promise never resolves. Call it again on the page X returns
313
+ * to and it finishes the sign-in from the URL instead of starting a new one.
314
+ *
315
+ * X releases no email address, so `result.profile` carries a name and a
316
+ * picture and nothing else. Anything that needs an address must ask the user
317
+ * for one.
318
+ */
319
+ connectWithX(): Promise<ConnectResult>;
320
+ /**
321
+ * Finish a redirect sign-in already present in the URL, whichever provider
322
+ * started it. Throws when there is nothing to finish — it never starts one.
323
+ */
324
+ completeRedirectSignIn(): Promise<ConnectResult>;
306
325
  /**
307
326
  * Sign in with a KingsChat access token the app already holds — from
308
327
  * kingschat-web-sdk, a native SDK, or any other flow. Use when you want to
@@ -530,6 +549,16 @@ interface AuthProfile {
530
549
  name?: string;
531
550
  email?: string;
532
551
  picture?: string;
552
+ /**
553
+ * The handle the user signs in under, where the provider has one. X sets it
554
+ * and releases no email at all, so for those accounts this is the only
555
+ * human-readable thing there is.
556
+ *
557
+ * Display only. A handle can be released by its owner and registered by
558
+ * somebody else, so never key an account, a lookup or access on it — use
559
+ * {@link AuthResult.providerSubject}, which cannot move.
560
+ */
561
+ username?: string;
533
562
  }
534
563
  interface AuthResult {
535
564
  jwt: string;
@@ -537,6 +566,15 @@ interface AuthResult {
537
566
  hasShare: boolean;
538
567
  userId: string;
539
568
  profile?: AuthProfile;
569
+ /**
570
+ * The provider's own stable id for this user — X's numeric user id, for
571
+ * instance. Present only where the provider gives one.
572
+ *
573
+ * Unlike a handle or an email this cannot be reassigned, which is what makes
574
+ * it safe to match an account against: the same value identifies the same
575
+ * person on both sides of a migration.
576
+ */
577
+ providerSubject?: string;
540
578
  }
541
579
 
542
580
  declare class ApiClient {
@@ -548,6 +586,14 @@ declare class ApiClient {
548
586
  getGoogleInitUrl(): Promise<{
549
587
  url: string;
550
588
  }>;
589
+ /**
590
+ * The X consent URL. Same contract as Google's: the backend holds the client
591
+ * secret and the PKCE verifier, and answers 503 X_NOT_CONFIGURED when the
592
+ * deployment has no X credentials.
593
+ */
594
+ getXInitUrl(): Promise<{
595
+ url: string;
596
+ }>;
551
597
  /**
552
598
  * Exchange a Google ID token the app already holds for a Decane session.
553
599
  * Resolves to the SAME identity as the redirect flow, so one Google account
@@ -755,7 +801,7 @@ interface DecaneProvider {
755
801
  type ConnectMode = "all" | "social" | "wallets" | "evm" | "solana" | "tron" | "evm+social" | "solana+social" | "tron+social" | "evm+tron" | "evm+tron+social";
756
802
  interface SocialConfig {
757
803
  apiKey: string;
758
- authMethods?: ("google" | "email" | "phone" | "kingschat")[];
804
+ authMethods?: ("google" | "email" | "phone" | "kingschat" | "x")[];
759
805
  /**
760
806
  * Scopes requested from KingsChat. Defaults to `['send_chat_message']`, which
761
807
  * is what KingsChat's own SDK asks for and is enough to establish identity.
@@ -1159,9 +1205,10 @@ interface WalletSelectorProps {
1159
1205
  theme?: "light" | "dark" | "auto";
1160
1206
  networks?: "evm" | "solana" | "tron" | "bitcoin" | "all";
1161
1207
  mode?: ConnectMode;
1162
- socialAuthMethods?: ("google" | "email" | "phone" | "kingschat")[];
1208
+ socialAuthMethods?: ("google" | "email" | "phone" | "kingschat" | "x")[];
1163
1209
  onGoogleSignIn?: () => Promise<void>;
1164
1210
  onKingsChatSignIn?: () => Promise<void>;
1211
+ onXSignIn?: () => Promise<void>;
1165
1212
  onEmailStart?: (email: string) => Promise<{
1166
1213
  codeRequired: true;
1167
1214
  }>;
@@ -1179,7 +1226,7 @@ interface WalletSelectorProps {
1179
1226
  passkeyAddress?: string | null;
1180
1227
  onPasskeySignIn?: () => Promise<unknown>;
1181
1228
  }
1182
- declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, mode, socialAuthMethods, onGoogleSignIn, onKingsChatSignIn, onEmailStart, onEmailVerify, onPhoneStart, onPhoneVerify, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, }: WalletSelectorProps): React.ReactPortal | null;
1229
+ declare function WalletSelector({ provider, open, onClose, onConnect, theme, networks, mode, socialAuthMethods, onGoogleSignIn, onKingsChatSignIn, onXSignIn, onEmailStart, onEmailVerify, onPhoneStart, onPhoneVerify, customAuthLabel, onCustomAuthSignIn, canUsePasskey, passkeyAddress, onPasskeySignIn, }: WalletSelectorProps): React.ReactPortal | null;
1183
1230
 
1184
1231
  type Theme = "light" | "dark" | "auto";
1185
1232
  interface SocialAuthState {
@@ -1203,6 +1250,15 @@ interface SocialAuthState {
1203
1250
  * you need it in that state.
1204
1251
  */
1205
1252
  profile: AuthProfile | null;
1253
+ /**
1254
+ * The provider's own stable id for this user, where it gives one — X's
1255
+ * numeric user id, for instance. Null for providers that do not.
1256
+ *
1257
+ * Unlike a handle or an email this cannot be reassigned, so it is the value
1258
+ * to match an account against. Like `profile` it comes from the sign-in and
1259
+ * cannot be re-fetched, so copy it if you need it after a reload.
1260
+ */
1261
+ providerSubject: string | null;
1206
1262
  isUnlocked: boolean;
1207
1263
  sessionExpiresAt: number | null;
1208
1264
  /**
@@ -1243,6 +1299,7 @@ interface SocialWalletModalProps {
1243
1299
  onDisconnect: () => Promise<void>;
1244
1300
  onGoogleSignIn: () => Promise<void>;
1245
1301
  onKingsChatSignIn?: () => Promise<void>;
1302
+ onXSignIn?: () => Promise<void>;
1246
1303
  onEmailStart: (email: string) => Promise<{
1247
1304
  codeRequired: true;
1248
1305
  }>;
@@ -1251,7 +1308,7 @@ interface SocialWalletModalProps {
1251
1308
  codeRequired: true;
1252
1309
  }>;
1253
1310
  onPhoneVerify?: (phone: string, code: string) => Promise<void>;
1254
- authMethods?: Array<"google" | "email" | "phone" | "kingschat">;
1311
+ authMethods?: Array<"google" | "email" | "phone" | "kingschat" | "x">;
1255
1312
  customAuthLabel?: string;
1256
1313
  onCustomAuthSignIn?: () => Promise<void>;
1257
1314
  canUsePasskey?: boolean;
@@ -1295,11 +1352,13 @@ declare function useSocialAuth(): {
1295
1352
  sessionExpiresAt: number | null;
1296
1353
  canUsePasskey: boolean;
1297
1354
  profile: AuthProfile | null;
1355
+ providerSubject: string | null;
1298
1356
  phase: "creating" | "unlocking" | null;
1299
1357
  isCreatingWallet: boolean;
1300
1358
  needsReconnect: boolean;
1301
1359
  googleLoading: boolean;
1302
1360
  kingschatLoading: boolean;
1361
+ xLoading: boolean;
1303
1362
  emailLoading: boolean;
1304
1363
  phoneLoading: boolean;
1305
1364
  tokenLoading: boolean;
@@ -1309,6 +1368,7 @@ declare function useSocialAuth(): {
1309
1368
  clearError: () => void;
1310
1369
  signInWithGoogle: () => Promise<void>;
1311
1370
  signInWithKingsChat: () => Promise<void>;
1371
+ signInWithX: () => Promise<void>;
1312
1372
  sendEmailCode: (email: string) => Promise<{
1313
1373
  codeRequired: true;
1314
1374
  }>;