@block-auth.io/core 0.11.1 → 0.13.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
@@ -103,6 +103,7 @@ declare class WsClient {
103
103
  private _roles;
104
104
  private _logs;
105
105
  private _kycIssuerByAddress;
106
+ private _connecting;
106
107
  /**
107
108
  * @param url - the wss:// endpoint to connect to.
108
109
  * @param reconnect - allow socket.io to auto-reconnect.
@@ -127,6 +128,7 @@ declare class WsClient {
127
128
  * @returns Promise<void>
128
129
  */
129
130
  connect(url?: string, waitMs?: number, retries?: number): Promise<void>;
131
+ private _doConnect;
130
132
  /**
131
133
  * Re-authenticates the CURRENT connection in place: fetches a fresh
132
134
  * ws-ticket and sends it over the already-open socket, so the server
@@ -618,6 +620,7 @@ interface UiState {
618
620
  isSigned: boolean;
619
621
  isSigningLoader: boolean;
620
622
  isAcceptingTxn: boolean;
623
+ isRejectingTxn: boolean;
621
624
  acceptTxnError: string | null;
622
625
  waitingForSuccessLogInSince: number;
623
626
  isOtpRequired: boolean;
@@ -637,6 +640,7 @@ declare const setIsSigning: (v: boolean) => void;
637
640
  declare const setIsSigned: (v: boolean) => void;
638
641
  declare const setIsSigningLoader: (v: boolean) => void;
639
642
  declare const setIsAcceptingTxn: (v: boolean) => void;
643
+ declare const setIsRejectingTxn: (v: boolean) => void;
640
644
  declare const setAcceptTxnError: (v: string | null) => void;
641
645
  declare const setWaitingForSuccessLogInSince: (v: number) => void;
642
646
  declare const setIsOtpRequired: (v: boolean) => void;
@@ -735,6 +739,30 @@ type Locale = 'en' | 'es';
735
739
  declare const $locale: nanostores.WritableAtom<Locale>;
736
740
  declare const setLocale: (l: Locale) => void;
737
741
 
742
+ interface PopupLoginOptions {
743
+ apiKey: string;
744
+ wsUrl?: string;
745
+ }
746
+ /**
747
+ * A code the page hands to its own backend instead of redeeming it: the
748
+ * backend redeems it at POST /api/auth/token with its apiSecret plus this
749
+ * codeVerifier and redirectUri, so the address comes from BlockAuth, not from
750
+ * the browser.
751
+ */
752
+ interface PopupAuthCode {
753
+ code: string;
754
+ codeVerifier: string;
755
+ redirectUri: string;
756
+ }
757
+ interface PopupLoginResult {
758
+ address: string;
759
+ did: string;
760
+ signedNonce: number;
761
+ signedAt: string;
762
+ signedExpiredAt: string;
763
+ roles: BlockAuthUserRole[];
764
+ }
765
+
738
766
  type GoogleFlow = 'auth-code' | 'implicit';
739
767
  interface GoogleConfig {
740
768
  clientId: string;
@@ -824,10 +852,10 @@ interface BlockAuthClientConfig {
824
852
  * deja apiSecret vacío para que el secreto nunca llegue al cliente. */
825
853
  browserToken?: string;
826
854
  wsUrl?: string;
827
- /** Backend base url used for the session-cookie bridge (POST
828
- * /auth/session), logout (POST /auth/logout) and the WS connect ticket
829
- * (GET /auth/ws-ticket). Defaults to https://api.block-auth.io, mirroring
830
- * how `wsUrl` defaults to wss://wss.block-auth.io. */
855
+ /** blockauth-api base url, first-party apps only (its CORS admits no other
856
+ * origin). With it, the session lives in the httpOnly cookie
857
+ * (POST /auth/session, POST /auth/logout, GET /auth/ws-ticket). Without
858
+ * it, the SDK never calls blockauth-api. */
831
859
  apiUrl?: string;
832
860
  /** Timeout (ms) por intento del connect inicial del WS. Default 300 —
833
861
  * puede quedarse corto en orígenes con más latencia (p.ej. PRE sin CDN). */
@@ -849,6 +877,8 @@ interface BlockAuthClientConfig {
849
877
  redirectUri?: string;
850
878
  };
851
879
  }
880
+ /** Who logged in through the hosted login, for the page's UI only. */
881
+ type HostedLoginUser = Pick<PopupLoginResult, 'address'> & Partial<Pick<PopupLoginResult, 'did' | 'roles'>>;
852
882
  declare function createBlockAuthClient(config: BlockAuthClientConfig): {
853
883
  state: {
854
884
  $ws: nanostores.MapStore<WsState>;
@@ -856,6 +886,7 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
856
886
  $wallet: nanostores.MapStore<WalletState>;
857
887
  $openModals: nanostores.WritableAtom<ModalName[]>;
858
888
  $user: nanostores.MapStore<UserState>;
889
+ $extension: nanostores.MapStore<ExtensionState>;
859
890
  };
860
891
  /** App apiKey from client config (also seeded into $ws). */
861
892
  apiKey: string;
@@ -1187,6 +1218,9 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
1187
1218
  signup: (providerSlug: string) => Promise<void>;
1188
1219
  };
1189
1220
  connectBlockAuth: () => void;
1221
+ loginWithPopup: () => Promise<PopupLoginResult>;
1222
+ authorizeWithPopup: () => Promise<PopupAuthCode>;
1223
+ rememberHostedLogin: (user: HostedLoginUser) => void;
1190
1224
  oauth: {
1191
1225
  signupGoogle: (flow?: "auth-code" | "implicit") => Promise<void>;
1192
1226
  signupMicrosoft: () => Promise<void>;
@@ -1205,6 +1239,7 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
1205
1239
  userParams?: Record<string, string>;
1206
1240
  grantedParams?: string[];
1207
1241
  revokedParams?: string[];
1242
+ sharedEmailId?: number;
1208
1243
  }) => void;
1209
1244
  dataRequest: (txnId: number | string) => Promise<TxnDataRequest | null>;
1210
1245
  report: (slug: string) => void;
@@ -1215,6 +1250,10 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
1215
1250
  openModal: (name: ModalName) => void;
1216
1251
  closeModal: (name?: ModalName) => void;
1217
1252
  closeAllModals: () => void;
1253
+ registerRuntime: (bridge: {
1254
+ switchAccount: () => Promise<void>;
1255
+ } | null) => void;
1256
+ switchAccount: () => Promise<void>;
1218
1257
  wsConnectTimeout: number;
1219
1258
  wsConnectRetries: number;
1220
1259
  apiUrl: string | undefined;
@@ -1224,11 +1263,22 @@ type BlockAuthClient = ReturnType<typeof createBlockAuthClient>;
1224
1263
 
1225
1264
  type TxnDataMode = 'required' | 'optional';
1226
1265
  type TxnDataStatus = 'shared' | 'granted' | 'consent' | 'missing';
1266
+ interface TxnDataEmail {
1267
+ id: number;
1268
+ label: string;
1269
+ email: string;
1270
+ isDefault: boolean;
1271
+ verified?: boolean;
1272
+ }
1227
1273
  interface TxnDataParam {
1228
1274
  slug: string;
1229
1275
  mode: TxnDataMode;
1230
1276
  status: TxnDataStatus;
1231
1277
  value: string | null;
1278
+ emails?: TxnDataEmail[];
1279
+ selectedEmailId?: number | null;
1280
+ emailsMax?: number;
1281
+ emailsManageUrl?: string | null;
1232
1282
  }
1233
1283
  interface TxnDataRequest {
1234
1284
  txnId: number | string;
@@ -1308,6 +1358,10 @@ declare const TEXTS: {
1308
1358
  readonly es: "ACEPTAR";
1309
1359
  readonly en: "ACCEPT";
1310
1360
  };
1361
+ readonly useAnotherAccount: {
1362
+ readonly es: "Usar otra cuenta";
1363
+ readonly en: "Use another account";
1364
+ };
1311
1365
  readonly iAuthorizeThe: {
1312
1366
  readonly es: "Autorizo la";
1313
1367
  readonly en: "I authorize the";
@@ -1360,6 +1414,18 @@ declare const TEXTS: {
1360
1414
  readonly es: "Guardar";
1361
1415
  readonly en: "Save";
1362
1416
  };
1417
+ readonly emailUnverified: {
1418
+ readonly es: "no verificado";
1419
+ readonly en: "not verified";
1420
+ };
1421
+ readonly emailNoneVerified: {
1422
+ readonly es: "Ningún correo verificado";
1423
+ readonly en: "No verified email";
1424
+ };
1425
+ readonly emailsManage: {
1426
+ readonly es: "Añadir o gestionar correos en Identity";
1427
+ readonly en: "Add or manage emails in Identity";
1428
+ };
1363
1429
  readonly undoChange: {
1364
1430
  readonly es: "Deshacer";
1365
1431
  readonly en: "Undo";
@@ -1384,6 +1450,10 @@ declare const TEXTS: {
1384
1450
  readonly es: "Aceptar";
1385
1451
  readonly en: "Accept";
1386
1452
  };
1453
+ readonly cancelData: {
1454
+ readonly es: "Cancelar";
1455
+ readonly en: "Cancel";
1456
+ };
1387
1457
  readonly noTransactionsFound: {
1388
1458
  readonly es: "No se encontraron transacciones";
1389
1459
  readonly en: "No transactions found";
@@ -1510,13 +1580,16 @@ declare const formatParamValue: (slug: string, value: string) => string;
1510
1580
  declare const normalizeParamValue: (slug: string, value: string) => string;
1511
1581
  declare const PARAM_ERROR_KEYS: Record<string, TextKey>;
1512
1582
  type SolicitedParam = TxnDataParam;
1583
+ type SolicitedEmailChoice = number | null;
1513
1584
  interface SolicitedDataForm {
1514
1585
  values: Record<string, string>;
1515
1586
  shared: Record<string, boolean>;
1516
1587
  saved: Record<string, string>;
1588
+ emailChoice?: SolicitedEmailChoice;
1517
1589
  }
1518
1590
  declare const EMPTY_SOLICITED_DATA_FORM: SolicitedDataForm;
1519
1591
  interface SolicitedField extends SolicitedParam {
1592
+ emailChoice?: SolicitedEmailChoice;
1520
1593
  profileValue: string;
1521
1594
  inputValue: string;
1522
1595
  isEmpty: boolean;
@@ -1530,7 +1603,16 @@ interface SolicitedAcceptParams {
1530
1603
  userParams: Record<string, string>;
1531
1604
  grantedParams: string[];
1532
1605
  revokedParams: string[];
1606
+ sharedEmailId?: number;
1533
1607
  }
1608
+ declare const isSolicitedEmailSelectable: (email: {
1609
+ verified?: boolean;
1610
+ }) => boolean;
1611
+ declare const formatSolicitedEmailOption: (email: {
1612
+ label: string;
1613
+ email: string;
1614
+ verified?: boolean;
1615
+ }, unverifiedText?: string) => string;
1534
1616
  declare const isValidParamValue: (slug: string, value: string) => boolean;
1535
1617
  declare function getSolicitedParams({ params, requiredParams, optionalParams, }: {
1536
1618
  params?: TxnDataParam[] | null;
@@ -1546,6 +1628,22 @@ declare const setSolicitedValue: (form: SolicitedDataForm, item: SolicitedParam,
1546
1628
  declare const setSolicitedShared: (form: SolicitedDataForm, slug: string, shared: boolean) => SolicitedDataForm;
1547
1629
  declare const saveSolicitedValue: (form: SolicitedDataForm, slug: string) => SolicitedDataForm;
1548
1630
  declare const undoSolicitedValue: (form: SolicitedDataForm, item: SolicitedParam) => SolicitedDataForm;
1631
+ declare const setSolicitedEmailChoice: (form: SolicitedDataForm, emailChoice: SolicitedEmailChoice) => SolicitedDataForm;
1632
+
1633
+ interface LoginPopupResult {
1634
+ code: string;
1635
+ state: string;
1636
+ }
1637
+ interface OpenLoginPopupOptions {
1638
+ url: string;
1639
+ expectedOrigin: string;
1640
+ timeoutMs?: number;
1641
+ windowName?: string;
1642
+ windowFeatures?: string;
1643
+ width?: number;
1644
+ height?: number;
1645
+ }
1646
+ declare function openLoginPopup({ url, expectedOrigin, timeoutMs, windowName, windowFeatures, width, height, }: OpenLoginPopupOptions): Promise<LoginPopupResult>;
1549
1647
 
1550
1648
  type PhoneCountryCode = CountryCode;
1551
1649
  interface PhoneCountry {
@@ -1581,11 +1679,13 @@ interface AuthRuntimeCallbacks {
1581
1679
  onSuccess?: (address: string) => void | Promise<void>;
1582
1680
  onError?: () => void | Promise<void>;
1583
1681
  onLogout?: () => void | Promise<void>;
1682
+ onCancel?: () => void | Promise<void>;
1584
1683
  }
1585
1684
  declare function createAuthRuntime(client: BlockAuthClient, callbacks?: AuthRuntimeCallbacks): {
1586
1685
  start: () => Promise<void>;
1587
1686
  stop: () => void;
1588
1687
  logout: () => Promise<void>;
1688
+ switchAccount: () => Promise<void>;
1589
1689
  };
1590
1690
  type AuthRuntime = ReturnType<typeof createAuthRuntime>;
1591
1691
 
@@ -2117,4 +2217,4 @@ declare function resetExtensionSyncModuleState(): void;
2117
2217
  */
2118
2218
  declare function startExtensionSync(): () => void;
2119
2219
 
2120
- export { $extension, $locale, $openModals, $ui, $user, $wallet, $web3, $ws, type AuthRuntime, type AuthRuntimeCallbacks, type BlockAuthClient, type BlockAuthClientConfig, BlockAuthProvider, type BlockAuthProviderOptions, type BlockAuthUserProfile, type BlockAuthUserRole, DEFAULT_PHONE_COUNTRY, DISCOVERY_TIMEOUT_MS, type DeletionServiceDeps, EMPTY_SOLICITED_DATA_FORM, type EvmOptions, type EvmWallet, type ExtensionState, type Locale, type ModalName, PARAM_DISPLAY_FORMATTERS, PARAM_DISPLAY_ORDER, PARAM_ERROR_KEYS, PARAM_INPUT_TYPE, PARAM_LABEL_KEYS, PARAM_NORMALIZERS, PARAM_VALIDATORS, type PhoneCountry, type PhoneCountryCode, type PhoneDraft, type PhoneParts, type RestoreResult, RpcClient, SDK_PAGE_MARKER, SYNC_TIMEOUT_MS, type SolanaWallet, type SolicitedAcceptParams, type SolicitedDataForm, type SolicitedField, type SolicitedParam, TEXTS, type TextKey, type TxnDataMode, type TxnDataParam, type TxnDataRequest, type TxnDataStatus, type TxnRequest, type UiState, type UserProfileProvider, type UserState, type WalletKind, type WalletState, type Web3SignupState, WsClient, type WsState, appearsExtensionInstalled, buildPhoneE164, buildPhoneValue, clearExtensionDomMarkers, clearRemainingAuthData, clearSdkPresence, closeAllModals, closeModal, confirmExtensionPresence, createAuthRuntime, createBlockAuthClient, createDeletionService, createEvmWallet, createSolanaWallet, deepLinkFor, discoverExtensionOnce, fetchUserProfile, finalizeAfterRestorationExpired, formatParamValue, formatPhoneForDisplay, getDefaultPhoneCountry, getExtensionStoreUrl, getPhoneCountries, getPhoneCountryFlag, getPhoneDialCode, getSolicitedAcceptParams, getSolicitedFields, getSolicitedHintKey, getSolicitedParams, getUserRoleNames, getUserRoleSlugs, getUserRoles, handleRestorationExpired, handleRestoreFailure, hasAnyRole, hasAnyRoleBySlug, hasRole, hasRoleBySlug, isExtensionPresent, isExtensionStateComplete, isFirefox, isModalOpen, isPhoneCountry, isRestorationExpiredMessage, isSdkPage, isShowSignin, isSolicitedDataComplete, isSolicitedHintSuccess, isValidParamValue, isValidPhoneValue, loadUserProfile, makeQrDataUrl, markSdkPresence, needsExtensionUnlock, normalizeParamValue, index$1 as oauth, onExtensionRemoved, onExtensionStatePublished, openExtensionOnTxn, openModal, parsePhoneValue, probeExtensionPresence, reconcileExtensionState, requestExtensionRefresh, requestExtensionStateSync, requestSdkRestore, resetExtension, resetExtensionAbsentState, resetExtensionSyncModuleState, resetUi, resetUser, resetWallet, resetWeb3, resetWs, resolvePhoneDraft, saveSolicitedValue, searchPhoneCountries, setAcceptTxnError, setApiKey, setBackendMessage, setDeletionAddress, setDid, setExtensionInstalled, setExtensionIsLocked, setExtensionIsUser, setExtensionIsUserActive, setIsAcceptingTxn, setIsAppActive, setIsCheckingAppActive, setIsLoadingUser, setIsOnDeletion, setIsOtpRequired, setIsSdkSignedIn, setIsServiceConnected, setIsSigned, setIsSignedFirstCheck, setIsSigning, setIsSigningLoader, setLocale, setReady, setRequests, setServiceIcon, setServiceName, setSignature, setSignedBy, setSolicitedShared, setSolicitedValue, setToken, setUiConfig, setUser, setWaitingForSuccessLogInSince, startExtensionSync, syncExtensionStateFromStorage, t, toPhoneE164, undoSolicitedValue, updatePhoneDraft, index as utils };
2220
+ export { $extension, $locale, $openModals, $ui, $user, $wallet, $web3, $ws, type AuthRuntime, type AuthRuntimeCallbacks, type BlockAuthClient, type BlockAuthClientConfig, BlockAuthProvider, type BlockAuthProviderOptions, type BlockAuthUserProfile, type BlockAuthUserRole, DEFAULT_PHONE_COUNTRY, DISCOVERY_TIMEOUT_MS, type DeletionServiceDeps, EMPTY_SOLICITED_DATA_FORM, type EvmOptions, type EvmWallet, type ExtensionState, type HostedLoginUser, type Locale, type LoginPopupResult, type ModalName, type OpenLoginPopupOptions, PARAM_DISPLAY_FORMATTERS, PARAM_DISPLAY_ORDER, PARAM_ERROR_KEYS, PARAM_INPUT_TYPE, PARAM_LABEL_KEYS, PARAM_NORMALIZERS, PARAM_VALIDATORS, type PhoneCountry, type PhoneCountryCode, type PhoneDraft, type PhoneParts, type PopupAuthCode, type PopupLoginOptions, type PopupLoginResult, type RestoreResult, RpcClient, SDK_PAGE_MARKER, SYNC_TIMEOUT_MS, type SolanaWallet, type SolicitedAcceptParams, type SolicitedDataForm, type SolicitedEmailChoice, type SolicitedField, type SolicitedParam, TEXTS, type TextKey, type TxnDataEmail, type TxnDataMode, type TxnDataParam, type TxnDataRequest, type TxnDataStatus, type TxnRequest, type UiState, type UserProfileProvider, type UserState, type WalletKind, type WalletState, type Web3SignupState, WsClient, type WsState, appearsExtensionInstalled, buildPhoneE164, buildPhoneValue, clearExtensionDomMarkers, clearRemainingAuthData, clearSdkPresence, closeAllModals, closeModal, confirmExtensionPresence, createAuthRuntime, createBlockAuthClient, createDeletionService, createEvmWallet, createSolanaWallet, deepLinkFor, discoverExtensionOnce, fetchUserProfile, finalizeAfterRestorationExpired, formatParamValue, formatPhoneForDisplay, formatSolicitedEmailOption, getDefaultPhoneCountry, getExtensionStoreUrl, getPhoneCountries, getPhoneCountryFlag, getPhoneDialCode, getSolicitedAcceptParams, getSolicitedFields, getSolicitedHintKey, getSolicitedParams, getUserRoleNames, getUserRoleSlugs, getUserRoles, handleRestorationExpired, handleRestoreFailure, hasAnyRole, hasAnyRoleBySlug, hasRole, hasRoleBySlug, isExtensionPresent, isExtensionStateComplete, isFirefox, isModalOpen, isPhoneCountry, isRestorationExpiredMessage, isSdkPage, isShowSignin, isSolicitedDataComplete, isSolicitedEmailSelectable, isSolicitedHintSuccess, isValidParamValue, isValidPhoneValue, loadUserProfile, makeQrDataUrl, markSdkPresence, needsExtensionUnlock, normalizeParamValue, index$1 as oauth, onExtensionRemoved, onExtensionStatePublished, openExtensionOnTxn, openLoginPopup, openModal, parsePhoneValue, probeExtensionPresence, reconcileExtensionState, requestExtensionRefresh, requestExtensionStateSync, requestSdkRestore, resetExtension, resetExtensionAbsentState, resetExtensionSyncModuleState, resetUi, resetUser, resetWallet, resetWeb3, resetWs, resolvePhoneDraft, saveSolicitedValue, searchPhoneCountries, setAcceptTxnError, setApiKey, setBackendMessage, setDeletionAddress, setDid, setExtensionInstalled, setExtensionIsLocked, setExtensionIsUser, setExtensionIsUserActive, setIsAcceptingTxn, setIsAppActive, setIsCheckingAppActive, setIsLoadingUser, setIsOnDeletion, setIsOtpRequired, setIsRejectingTxn, setIsSdkSignedIn, setIsServiceConnected, setIsSigned, setIsSignedFirstCheck, setIsSigning, setIsSigningLoader, setLocale, setReady, setRequests, setServiceIcon, setServiceName, setSignature, setSignedBy, setSolicitedEmailChoice, setSolicitedShared, setSolicitedValue, setToken, setUiConfig, setUser, setWaitingForSuccessLogInSince, startExtensionSync, syncExtensionStateFromStorage, t, toPhoneE164, undoSolicitedValue, updatePhoneDraft, index as utils };
package/dist/index.d.ts CHANGED
@@ -103,6 +103,7 @@ declare class WsClient {
103
103
  private _roles;
104
104
  private _logs;
105
105
  private _kycIssuerByAddress;
106
+ private _connecting;
106
107
  /**
107
108
  * @param url - the wss:// endpoint to connect to.
108
109
  * @param reconnect - allow socket.io to auto-reconnect.
@@ -127,6 +128,7 @@ declare class WsClient {
127
128
  * @returns Promise<void>
128
129
  */
129
130
  connect(url?: string, waitMs?: number, retries?: number): Promise<void>;
131
+ private _doConnect;
130
132
  /**
131
133
  * Re-authenticates the CURRENT connection in place: fetches a fresh
132
134
  * ws-ticket and sends it over the already-open socket, so the server
@@ -618,6 +620,7 @@ interface UiState {
618
620
  isSigned: boolean;
619
621
  isSigningLoader: boolean;
620
622
  isAcceptingTxn: boolean;
623
+ isRejectingTxn: boolean;
621
624
  acceptTxnError: string | null;
622
625
  waitingForSuccessLogInSince: number;
623
626
  isOtpRequired: boolean;
@@ -637,6 +640,7 @@ declare const setIsSigning: (v: boolean) => void;
637
640
  declare const setIsSigned: (v: boolean) => void;
638
641
  declare const setIsSigningLoader: (v: boolean) => void;
639
642
  declare const setIsAcceptingTxn: (v: boolean) => void;
643
+ declare const setIsRejectingTxn: (v: boolean) => void;
640
644
  declare const setAcceptTxnError: (v: string | null) => void;
641
645
  declare const setWaitingForSuccessLogInSince: (v: number) => void;
642
646
  declare const setIsOtpRequired: (v: boolean) => void;
@@ -735,6 +739,30 @@ type Locale = 'en' | 'es';
735
739
  declare const $locale: nanostores.WritableAtom<Locale>;
736
740
  declare const setLocale: (l: Locale) => void;
737
741
 
742
+ interface PopupLoginOptions {
743
+ apiKey: string;
744
+ wsUrl?: string;
745
+ }
746
+ /**
747
+ * A code the page hands to its own backend instead of redeeming it: the
748
+ * backend redeems it at POST /api/auth/token with its apiSecret plus this
749
+ * codeVerifier and redirectUri, so the address comes from BlockAuth, not from
750
+ * the browser.
751
+ */
752
+ interface PopupAuthCode {
753
+ code: string;
754
+ codeVerifier: string;
755
+ redirectUri: string;
756
+ }
757
+ interface PopupLoginResult {
758
+ address: string;
759
+ did: string;
760
+ signedNonce: number;
761
+ signedAt: string;
762
+ signedExpiredAt: string;
763
+ roles: BlockAuthUserRole[];
764
+ }
765
+
738
766
  type GoogleFlow = 'auth-code' | 'implicit';
739
767
  interface GoogleConfig {
740
768
  clientId: string;
@@ -824,10 +852,10 @@ interface BlockAuthClientConfig {
824
852
  * deja apiSecret vacío para que el secreto nunca llegue al cliente. */
825
853
  browserToken?: string;
826
854
  wsUrl?: string;
827
- /** Backend base url used for the session-cookie bridge (POST
828
- * /auth/session), logout (POST /auth/logout) and the WS connect ticket
829
- * (GET /auth/ws-ticket). Defaults to https://api.block-auth.io, mirroring
830
- * how `wsUrl` defaults to wss://wss.block-auth.io. */
855
+ /** blockauth-api base url, first-party apps only (its CORS admits no other
856
+ * origin). With it, the session lives in the httpOnly cookie
857
+ * (POST /auth/session, POST /auth/logout, GET /auth/ws-ticket). Without
858
+ * it, the SDK never calls blockauth-api. */
831
859
  apiUrl?: string;
832
860
  /** Timeout (ms) por intento del connect inicial del WS. Default 300 —
833
861
  * puede quedarse corto en orígenes con más latencia (p.ej. PRE sin CDN). */
@@ -849,6 +877,8 @@ interface BlockAuthClientConfig {
849
877
  redirectUri?: string;
850
878
  };
851
879
  }
880
+ /** Who logged in through the hosted login, for the page's UI only. */
881
+ type HostedLoginUser = Pick<PopupLoginResult, 'address'> & Partial<Pick<PopupLoginResult, 'did' | 'roles'>>;
852
882
  declare function createBlockAuthClient(config: BlockAuthClientConfig): {
853
883
  state: {
854
884
  $ws: nanostores.MapStore<WsState>;
@@ -856,6 +886,7 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
856
886
  $wallet: nanostores.MapStore<WalletState>;
857
887
  $openModals: nanostores.WritableAtom<ModalName[]>;
858
888
  $user: nanostores.MapStore<UserState>;
889
+ $extension: nanostores.MapStore<ExtensionState>;
859
890
  };
860
891
  /** App apiKey from client config (also seeded into $ws). */
861
892
  apiKey: string;
@@ -1187,6 +1218,9 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
1187
1218
  signup: (providerSlug: string) => Promise<void>;
1188
1219
  };
1189
1220
  connectBlockAuth: () => void;
1221
+ loginWithPopup: () => Promise<PopupLoginResult>;
1222
+ authorizeWithPopup: () => Promise<PopupAuthCode>;
1223
+ rememberHostedLogin: (user: HostedLoginUser) => void;
1190
1224
  oauth: {
1191
1225
  signupGoogle: (flow?: "auth-code" | "implicit") => Promise<void>;
1192
1226
  signupMicrosoft: () => Promise<void>;
@@ -1205,6 +1239,7 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
1205
1239
  userParams?: Record<string, string>;
1206
1240
  grantedParams?: string[];
1207
1241
  revokedParams?: string[];
1242
+ sharedEmailId?: number;
1208
1243
  }) => void;
1209
1244
  dataRequest: (txnId: number | string) => Promise<TxnDataRequest | null>;
1210
1245
  report: (slug: string) => void;
@@ -1215,6 +1250,10 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
1215
1250
  openModal: (name: ModalName) => void;
1216
1251
  closeModal: (name?: ModalName) => void;
1217
1252
  closeAllModals: () => void;
1253
+ registerRuntime: (bridge: {
1254
+ switchAccount: () => Promise<void>;
1255
+ } | null) => void;
1256
+ switchAccount: () => Promise<void>;
1218
1257
  wsConnectTimeout: number;
1219
1258
  wsConnectRetries: number;
1220
1259
  apiUrl: string | undefined;
@@ -1224,11 +1263,22 @@ type BlockAuthClient = ReturnType<typeof createBlockAuthClient>;
1224
1263
 
1225
1264
  type TxnDataMode = 'required' | 'optional';
1226
1265
  type TxnDataStatus = 'shared' | 'granted' | 'consent' | 'missing';
1266
+ interface TxnDataEmail {
1267
+ id: number;
1268
+ label: string;
1269
+ email: string;
1270
+ isDefault: boolean;
1271
+ verified?: boolean;
1272
+ }
1227
1273
  interface TxnDataParam {
1228
1274
  slug: string;
1229
1275
  mode: TxnDataMode;
1230
1276
  status: TxnDataStatus;
1231
1277
  value: string | null;
1278
+ emails?: TxnDataEmail[];
1279
+ selectedEmailId?: number | null;
1280
+ emailsMax?: number;
1281
+ emailsManageUrl?: string | null;
1232
1282
  }
1233
1283
  interface TxnDataRequest {
1234
1284
  txnId: number | string;
@@ -1308,6 +1358,10 @@ declare const TEXTS: {
1308
1358
  readonly es: "ACEPTAR";
1309
1359
  readonly en: "ACCEPT";
1310
1360
  };
1361
+ readonly useAnotherAccount: {
1362
+ readonly es: "Usar otra cuenta";
1363
+ readonly en: "Use another account";
1364
+ };
1311
1365
  readonly iAuthorizeThe: {
1312
1366
  readonly es: "Autorizo la";
1313
1367
  readonly en: "I authorize the";
@@ -1360,6 +1414,18 @@ declare const TEXTS: {
1360
1414
  readonly es: "Guardar";
1361
1415
  readonly en: "Save";
1362
1416
  };
1417
+ readonly emailUnverified: {
1418
+ readonly es: "no verificado";
1419
+ readonly en: "not verified";
1420
+ };
1421
+ readonly emailNoneVerified: {
1422
+ readonly es: "Ningún correo verificado";
1423
+ readonly en: "No verified email";
1424
+ };
1425
+ readonly emailsManage: {
1426
+ readonly es: "Añadir o gestionar correos en Identity";
1427
+ readonly en: "Add or manage emails in Identity";
1428
+ };
1363
1429
  readonly undoChange: {
1364
1430
  readonly es: "Deshacer";
1365
1431
  readonly en: "Undo";
@@ -1384,6 +1450,10 @@ declare const TEXTS: {
1384
1450
  readonly es: "Aceptar";
1385
1451
  readonly en: "Accept";
1386
1452
  };
1453
+ readonly cancelData: {
1454
+ readonly es: "Cancelar";
1455
+ readonly en: "Cancel";
1456
+ };
1387
1457
  readonly noTransactionsFound: {
1388
1458
  readonly es: "No se encontraron transacciones";
1389
1459
  readonly en: "No transactions found";
@@ -1510,13 +1580,16 @@ declare const formatParamValue: (slug: string, value: string) => string;
1510
1580
  declare const normalizeParamValue: (slug: string, value: string) => string;
1511
1581
  declare const PARAM_ERROR_KEYS: Record<string, TextKey>;
1512
1582
  type SolicitedParam = TxnDataParam;
1583
+ type SolicitedEmailChoice = number | null;
1513
1584
  interface SolicitedDataForm {
1514
1585
  values: Record<string, string>;
1515
1586
  shared: Record<string, boolean>;
1516
1587
  saved: Record<string, string>;
1588
+ emailChoice?: SolicitedEmailChoice;
1517
1589
  }
1518
1590
  declare const EMPTY_SOLICITED_DATA_FORM: SolicitedDataForm;
1519
1591
  interface SolicitedField extends SolicitedParam {
1592
+ emailChoice?: SolicitedEmailChoice;
1520
1593
  profileValue: string;
1521
1594
  inputValue: string;
1522
1595
  isEmpty: boolean;
@@ -1530,7 +1603,16 @@ interface SolicitedAcceptParams {
1530
1603
  userParams: Record<string, string>;
1531
1604
  grantedParams: string[];
1532
1605
  revokedParams: string[];
1606
+ sharedEmailId?: number;
1533
1607
  }
1608
+ declare const isSolicitedEmailSelectable: (email: {
1609
+ verified?: boolean;
1610
+ }) => boolean;
1611
+ declare const formatSolicitedEmailOption: (email: {
1612
+ label: string;
1613
+ email: string;
1614
+ verified?: boolean;
1615
+ }, unverifiedText?: string) => string;
1534
1616
  declare const isValidParamValue: (slug: string, value: string) => boolean;
1535
1617
  declare function getSolicitedParams({ params, requiredParams, optionalParams, }: {
1536
1618
  params?: TxnDataParam[] | null;
@@ -1546,6 +1628,22 @@ declare const setSolicitedValue: (form: SolicitedDataForm, item: SolicitedParam,
1546
1628
  declare const setSolicitedShared: (form: SolicitedDataForm, slug: string, shared: boolean) => SolicitedDataForm;
1547
1629
  declare const saveSolicitedValue: (form: SolicitedDataForm, slug: string) => SolicitedDataForm;
1548
1630
  declare const undoSolicitedValue: (form: SolicitedDataForm, item: SolicitedParam) => SolicitedDataForm;
1631
+ declare const setSolicitedEmailChoice: (form: SolicitedDataForm, emailChoice: SolicitedEmailChoice) => SolicitedDataForm;
1632
+
1633
+ interface LoginPopupResult {
1634
+ code: string;
1635
+ state: string;
1636
+ }
1637
+ interface OpenLoginPopupOptions {
1638
+ url: string;
1639
+ expectedOrigin: string;
1640
+ timeoutMs?: number;
1641
+ windowName?: string;
1642
+ windowFeatures?: string;
1643
+ width?: number;
1644
+ height?: number;
1645
+ }
1646
+ declare function openLoginPopup({ url, expectedOrigin, timeoutMs, windowName, windowFeatures, width, height, }: OpenLoginPopupOptions): Promise<LoginPopupResult>;
1549
1647
 
1550
1648
  type PhoneCountryCode = CountryCode;
1551
1649
  interface PhoneCountry {
@@ -1581,11 +1679,13 @@ interface AuthRuntimeCallbacks {
1581
1679
  onSuccess?: (address: string) => void | Promise<void>;
1582
1680
  onError?: () => void | Promise<void>;
1583
1681
  onLogout?: () => void | Promise<void>;
1682
+ onCancel?: () => void | Promise<void>;
1584
1683
  }
1585
1684
  declare function createAuthRuntime(client: BlockAuthClient, callbacks?: AuthRuntimeCallbacks): {
1586
1685
  start: () => Promise<void>;
1587
1686
  stop: () => void;
1588
1687
  logout: () => Promise<void>;
1688
+ switchAccount: () => Promise<void>;
1589
1689
  };
1590
1690
  type AuthRuntime = ReturnType<typeof createAuthRuntime>;
1591
1691
 
@@ -2117,4 +2217,4 @@ declare function resetExtensionSyncModuleState(): void;
2117
2217
  */
2118
2218
  declare function startExtensionSync(): () => void;
2119
2219
 
2120
- export { $extension, $locale, $openModals, $ui, $user, $wallet, $web3, $ws, type AuthRuntime, type AuthRuntimeCallbacks, type BlockAuthClient, type BlockAuthClientConfig, BlockAuthProvider, type BlockAuthProviderOptions, type BlockAuthUserProfile, type BlockAuthUserRole, DEFAULT_PHONE_COUNTRY, DISCOVERY_TIMEOUT_MS, type DeletionServiceDeps, EMPTY_SOLICITED_DATA_FORM, type EvmOptions, type EvmWallet, type ExtensionState, type Locale, type ModalName, PARAM_DISPLAY_FORMATTERS, PARAM_DISPLAY_ORDER, PARAM_ERROR_KEYS, PARAM_INPUT_TYPE, PARAM_LABEL_KEYS, PARAM_NORMALIZERS, PARAM_VALIDATORS, type PhoneCountry, type PhoneCountryCode, type PhoneDraft, type PhoneParts, type RestoreResult, RpcClient, SDK_PAGE_MARKER, SYNC_TIMEOUT_MS, type SolanaWallet, type SolicitedAcceptParams, type SolicitedDataForm, type SolicitedField, type SolicitedParam, TEXTS, type TextKey, type TxnDataMode, type TxnDataParam, type TxnDataRequest, type TxnDataStatus, type TxnRequest, type UiState, type UserProfileProvider, type UserState, type WalletKind, type WalletState, type Web3SignupState, WsClient, type WsState, appearsExtensionInstalled, buildPhoneE164, buildPhoneValue, clearExtensionDomMarkers, clearRemainingAuthData, clearSdkPresence, closeAllModals, closeModal, confirmExtensionPresence, createAuthRuntime, createBlockAuthClient, createDeletionService, createEvmWallet, createSolanaWallet, deepLinkFor, discoverExtensionOnce, fetchUserProfile, finalizeAfterRestorationExpired, formatParamValue, formatPhoneForDisplay, getDefaultPhoneCountry, getExtensionStoreUrl, getPhoneCountries, getPhoneCountryFlag, getPhoneDialCode, getSolicitedAcceptParams, getSolicitedFields, getSolicitedHintKey, getSolicitedParams, getUserRoleNames, getUserRoleSlugs, getUserRoles, handleRestorationExpired, handleRestoreFailure, hasAnyRole, hasAnyRoleBySlug, hasRole, hasRoleBySlug, isExtensionPresent, isExtensionStateComplete, isFirefox, isModalOpen, isPhoneCountry, isRestorationExpiredMessage, isSdkPage, isShowSignin, isSolicitedDataComplete, isSolicitedHintSuccess, isValidParamValue, isValidPhoneValue, loadUserProfile, makeQrDataUrl, markSdkPresence, needsExtensionUnlock, normalizeParamValue, index$1 as oauth, onExtensionRemoved, onExtensionStatePublished, openExtensionOnTxn, openModal, parsePhoneValue, probeExtensionPresence, reconcileExtensionState, requestExtensionRefresh, requestExtensionStateSync, requestSdkRestore, resetExtension, resetExtensionAbsentState, resetExtensionSyncModuleState, resetUi, resetUser, resetWallet, resetWeb3, resetWs, resolvePhoneDraft, saveSolicitedValue, searchPhoneCountries, setAcceptTxnError, setApiKey, setBackendMessage, setDeletionAddress, setDid, setExtensionInstalled, setExtensionIsLocked, setExtensionIsUser, setExtensionIsUserActive, setIsAcceptingTxn, setIsAppActive, setIsCheckingAppActive, setIsLoadingUser, setIsOnDeletion, setIsOtpRequired, setIsSdkSignedIn, setIsServiceConnected, setIsSigned, setIsSignedFirstCheck, setIsSigning, setIsSigningLoader, setLocale, setReady, setRequests, setServiceIcon, setServiceName, setSignature, setSignedBy, setSolicitedShared, setSolicitedValue, setToken, setUiConfig, setUser, setWaitingForSuccessLogInSince, startExtensionSync, syncExtensionStateFromStorage, t, toPhoneE164, undoSolicitedValue, updatePhoneDraft, index as utils };
2220
+ export { $extension, $locale, $openModals, $ui, $user, $wallet, $web3, $ws, type AuthRuntime, type AuthRuntimeCallbacks, type BlockAuthClient, type BlockAuthClientConfig, BlockAuthProvider, type BlockAuthProviderOptions, type BlockAuthUserProfile, type BlockAuthUserRole, DEFAULT_PHONE_COUNTRY, DISCOVERY_TIMEOUT_MS, type DeletionServiceDeps, EMPTY_SOLICITED_DATA_FORM, type EvmOptions, type EvmWallet, type ExtensionState, type HostedLoginUser, type Locale, type LoginPopupResult, type ModalName, type OpenLoginPopupOptions, PARAM_DISPLAY_FORMATTERS, PARAM_DISPLAY_ORDER, PARAM_ERROR_KEYS, PARAM_INPUT_TYPE, PARAM_LABEL_KEYS, PARAM_NORMALIZERS, PARAM_VALIDATORS, type PhoneCountry, type PhoneCountryCode, type PhoneDraft, type PhoneParts, type PopupAuthCode, type PopupLoginOptions, type PopupLoginResult, type RestoreResult, RpcClient, SDK_PAGE_MARKER, SYNC_TIMEOUT_MS, type SolanaWallet, type SolicitedAcceptParams, type SolicitedDataForm, type SolicitedEmailChoice, type SolicitedField, type SolicitedParam, TEXTS, type TextKey, type TxnDataEmail, type TxnDataMode, type TxnDataParam, type TxnDataRequest, type TxnDataStatus, type TxnRequest, type UiState, type UserProfileProvider, type UserState, type WalletKind, type WalletState, type Web3SignupState, WsClient, type WsState, appearsExtensionInstalled, buildPhoneE164, buildPhoneValue, clearExtensionDomMarkers, clearRemainingAuthData, clearSdkPresence, closeAllModals, closeModal, confirmExtensionPresence, createAuthRuntime, createBlockAuthClient, createDeletionService, createEvmWallet, createSolanaWallet, deepLinkFor, discoverExtensionOnce, fetchUserProfile, finalizeAfterRestorationExpired, formatParamValue, formatPhoneForDisplay, formatSolicitedEmailOption, getDefaultPhoneCountry, getExtensionStoreUrl, getPhoneCountries, getPhoneCountryFlag, getPhoneDialCode, getSolicitedAcceptParams, getSolicitedFields, getSolicitedHintKey, getSolicitedParams, getUserRoleNames, getUserRoleSlugs, getUserRoles, handleRestorationExpired, handleRestoreFailure, hasAnyRole, hasAnyRoleBySlug, hasRole, hasRoleBySlug, isExtensionPresent, isExtensionStateComplete, isFirefox, isModalOpen, isPhoneCountry, isRestorationExpiredMessage, isSdkPage, isShowSignin, isSolicitedDataComplete, isSolicitedEmailSelectable, isSolicitedHintSuccess, isValidParamValue, isValidPhoneValue, loadUserProfile, makeQrDataUrl, markSdkPresence, needsExtensionUnlock, normalizeParamValue, index$1 as oauth, onExtensionRemoved, onExtensionStatePublished, openExtensionOnTxn, openLoginPopup, openModal, parsePhoneValue, probeExtensionPresence, reconcileExtensionState, requestExtensionRefresh, requestExtensionStateSync, requestSdkRestore, resetExtension, resetExtensionAbsentState, resetExtensionSyncModuleState, resetUi, resetUser, resetWallet, resetWeb3, resetWs, resolvePhoneDraft, saveSolicitedValue, searchPhoneCountries, setAcceptTxnError, setApiKey, setBackendMessage, setDeletionAddress, setDid, setExtensionInstalled, setExtensionIsLocked, setExtensionIsUser, setExtensionIsUserActive, setIsAcceptingTxn, setIsAppActive, setIsCheckingAppActive, setIsLoadingUser, setIsOnDeletion, setIsOtpRequired, setIsRejectingTxn, setIsSdkSignedIn, setIsServiceConnected, setIsSigned, setIsSignedFirstCheck, setIsSigning, setIsSigningLoader, setLocale, setReady, setRequests, setServiceIcon, setServiceName, setSignature, setSignedBy, setSolicitedEmailChoice, setSolicitedShared, setSolicitedValue, setToken, setUiConfig, setUser, setWaitingForSuccessLogInSince, startExtensionSync, syncExtensionStateFromStorage, t, toPhoneE164, undoSolicitedValue, updatePhoneDraft, index as utils };