@block-auth.io/core 0.11.1 → 0.12.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.cjs +355 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -5
- package/dist/index.d.ts +68 -5
- package/dist/index.js +354 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
-
/**
|
|
828
|
-
*
|
|
829
|
-
* (GET /auth/ws-ticket).
|
|
830
|
-
*
|
|
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>;
|
|
@@ -1215,6 +1249,10 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
|
1215
1249
|
openModal: (name: ModalName) => void;
|
|
1216
1250
|
closeModal: (name?: ModalName) => void;
|
|
1217
1251
|
closeAllModals: () => void;
|
|
1252
|
+
registerRuntime: (bridge: {
|
|
1253
|
+
switchAccount: () => Promise<void>;
|
|
1254
|
+
} | null) => void;
|
|
1255
|
+
switchAccount: () => Promise<void>;
|
|
1218
1256
|
wsConnectTimeout: number;
|
|
1219
1257
|
wsConnectRetries: number;
|
|
1220
1258
|
apiUrl: string | undefined;
|
|
@@ -1308,6 +1346,10 @@ declare const TEXTS: {
|
|
|
1308
1346
|
readonly es: "ACEPTAR";
|
|
1309
1347
|
readonly en: "ACCEPT";
|
|
1310
1348
|
};
|
|
1349
|
+
readonly useAnotherAccount: {
|
|
1350
|
+
readonly es: "Usar otra cuenta";
|
|
1351
|
+
readonly en: "Use another account";
|
|
1352
|
+
};
|
|
1311
1353
|
readonly iAuthorizeThe: {
|
|
1312
1354
|
readonly es: "Autorizo la";
|
|
1313
1355
|
readonly en: "I authorize the";
|
|
@@ -1384,6 +1426,10 @@ declare const TEXTS: {
|
|
|
1384
1426
|
readonly es: "Aceptar";
|
|
1385
1427
|
readonly en: "Accept";
|
|
1386
1428
|
};
|
|
1429
|
+
readonly cancelData: {
|
|
1430
|
+
readonly es: "Cancelar";
|
|
1431
|
+
readonly en: "Cancel";
|
|
1432
|
+
};
|
|
1387
1433
|
readonly noTransactionsFound: {
|
|
1388
1434
|
readonly es: "No se encontraron transacciones";
|
|
1389
1435
|
readonly en: "No transactions found";
|
|
@@ -1547,6 +1593,21 @@ declare const setSolicitedShared: (form: SolicitedDataForm, slug: string, shared
|
|
|
1547
1593
|
declare const saveSolicitedValue: (form: SolicitedDataForm, slug: string) => SolicitedDataForm;
|
|
1548
1594
|
declare const undoSolicitedValue: (form: SolicitedDataForm, item: SolicitedParam) => SolicitedDataForm;
|
|
1549
1595
|
|
|
1596
|
+
interface LoginPopupResult {
|
|
1597
|
+
code: string;
|
|
1598
|
+
state: string;
|
|
1599
|
+
}
|
|
1600
|
+
interface OpenLoginPopupOptions {
|
|
1601
|
+
url: string;
|
|
1602
|
+
expectedOrigin: string;
|
|
1603
|
+
timeoutMs?: number;
|
|
1604
|
+
windowName?: string;
|
|
1605
|
+
windowFeatures?: string;
|
|
1606
|
+
width?: number;
|
|
1607
|
+
height?: number;
|
|
1608
|
+
}
|
|
1609
|
+
declare function openLoginPopup({ url, expectedOrigin, timeoutMs, windowName, windowFeatures, width, height, }: OpenLoginPopupOptions): Promise<LoginPopupResult>;
|
|
1610
|
+
|
|
1550
1611
|
type PhoneCountryCode = CountryCode;
|
|
1551
1612
|
interface PhoneCountry {
|
|
1552
1613
|
iso2: PhoneCountryCode;
|
|
@@ -1581,11 +1642,13 @@ interface AuthRuntimeCallbacks {
|
|
|
1581
1642
|
onSuccess?: (address: string) => void | Promise<void>;
|
|
1582
1643
|
onError?: () => void | Promise<void>;
|
|
1583
1644
|
onLogout?: () => void | Promise<void>;
|
|
1645
|
+
onCancel?: () => void | Promise<void>;
|
|
1584
1646
|
}
|
|
1585
1647
|
declare function createAuthRuntime(client: BlockAuthClient, callbacks?: AuthRuntimeCallbacks): {
|
|
1586
1648
|
start: () => Promise<void>;
|
|
1587
1649
|
stop: () => void;
|
|
1588
1650
|
logout: () => Promise<void>;
|
|
1651
|
+
switchAccount: () => Promise<void>;
|
|
1589
1652
|
};
|
|
1590
1653
|
type AuthRuntime = ReturnType<typeof createAuthRuntime>;
|
|
1591
1654
|
|
|
@@ -2117,4 +2180,4 @@ declare function resetExtensionSyncModuleState(): void;
|
|
|
2117
2180
|
*/
|
|
2118
2181
|
declare function startExtensionSync(): () => void;
|
|
2119
2182
|
|
|
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 };
|
|
2183
|
+
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 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, 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, 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
|
-
/**
|
|
828
|
-
*
|
|
829
|
-
* (GET /auth/ws-ticket).
|
|
830
|
-
*
|
|
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>;
|
|
@@ -1215,6 +1249,10 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
|
1215
1249
|
openModal: (name: ModalName) => void;
|
|
1216
1250
|
closeModal: (name?: ModalName) => void;
|
|
1217
1251
|
closeAllModals: () => void;
|
|
1252
|
+
registerRuntime: (bridge: {
|
|
1253
|
+
switchAccount: () => Promise<void>;
|
|
1254
|
+
} | null) => void;
|
|
1255
|
+
switchAccount: () => Promise<void>;
|
|
1218
1256
|
wsConnectTimeout: number;
|
|
1219
1257
|
wsConnectRetries: number;
|
|
1220
1258
|
apiUrl: string | undefined;
|
|
@@ -1308,6 +1346,10 @@ declare const TEXTS: {
|
|
|
1308
1346
|
readonly es: "ACEPTAR";
|
|
1309
1347
|
readonly en: "ACCEPT";
|
|
1310
1348
|
};
|
|
1349
|
+
readonly useAnotherAccount: {
|
|
1350
|
+
readonly es: "Usar otra cuenta";
|
|
1351
|
+
readonly en: "Use another account";
|
|
1352
|
+
};
|
|
1311
1353
|
readonly iAuthorizeThe: {
|
|
1312
1354
|
readonly es: "Autorizo la";
|
|
1313
1355
|
readonly en: "I authorize the";
|
|
@@ -1384,6 +1426,10 @@ declare const TEXTS: {
|
|
|
1384
1426
|
readonly es: "Aceptar";
|
|
1385
1427
|
readonly en: "Accept";
|
|
1386
1428
|
};
|
|
1429
|
+
readonly cancelData: {
|
|
1430
|
+
readonly es: "Cancelar";
|
|
1431
|
+
readonly en: "Cancel";
|
|
1432
|
+
};
|
|
1387
1433
|
readonly noTransactionsFound: {
|
|
1388
1434
|
readonly es: "No se encontraron transacciones";
|
|
1389
1435
|
readonly en: "No transactions found";
|
|
@@ -1547,6 +1593,21 @@ declare const setSolicitedShared: (form: SolicitedDataForm, slug: string, shared
|
|
|
1547
1593
|
declare const saveSolicitedValue: (form: SolicitedDataForm, slug: string) => SolicitedDataForm;
|
|
1548
1594
|
declare const undoSolicitedValue: (form: SolicitedDataForm, item: SolicitedParam) => SolicitedDataForm;
|
|
1549
1595
|
|
|
1596
|
+
interface LoginPopupResult {
|
|
1597
|
+
code: string;
|
|
1598
|
+
state: string;
|
|
1599
|
+
}
|
|
1600
|
+
interface OpenLoginPopupOptions {
|
|
1601
|
+
url: string;
|
|
1602
|
+
expectedOrigin: string;
|
|
1603
|
+
timeoutMs?: number;
|
|
1604
|
+
windowName?: string;
|
|
1605
|
+
windowFeatures?: string;
|
|
1606
|
+
width?: number;
|
|
1607
|
+
height?: number;
|
|
1608
|
+
}
|
|
1609
|
+
declare function openLoginPopup({ url, expectedOrigin, timeoutMs, windowName, windowFeatures, width, height, }: OpenLoginPopupOptions): Promise<LoginPopupResult>;
|
|
1610
|
+
|
|
1550
1611
|
type PhoneCountryCode = CountryCode;
|
|
1551
1612
|
interface PhoneCountry {
|
|
1552
1613
|
iso2: PhoneCountryCode;
|
|
@@ -1581,11 +1642,13 @@ interface AuthRuntimeCallbacks {
|
|
|
1581
1642
|
onSuccess?: (address: string) => void | Promise<void>;
|
|
1582
1643
|
onError?: () => void | Promise<void>;
|
|
1583
1644
|
onLogout?: () => void | Promise<void>;
|
|
1645
|
+
onCancel?: () => void | Promise<void>;
|
|
1584
1646
|
}
|
|
1585
1647
|
declare function createAuthRuntime(client: BlockAuthClient, callbacks?: AuthRuntimeCallbacks): {
|
|
1586
1648
|
start: () => Promise<void>;
|
|
1587
1649
|
stop: () => void;
|
|
1588
1650
|
logout: () => Promise<void>;
|
|
1651
|
+
switchAccount: () => Promise<void>;
|
|
1589
1652
|
};
|
|
1590
1653
|
type AuthRuntime = ReturnType<typeof createAuthRuntime>;
|
|
1591
1654
|
|
|
@@ -2117,4 +2180,4 @@ declare function resetExtensionSyncModuleState(): void;
|
|
|
2117
2180
|
*/
|
|
2118
2181
|
declare function startExtensionSync(): () => void;
|
|
2119
2182
|
|
|
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 };
|
|
2183
|
+
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 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, 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, setSolicitedShared, setSolicitedValue, setToken, setUiConfig, setUser, setWaitingForSuccessLogInSince, startExtensionSync, syncExtensionStateFromStorage, t, toPhoneE164, undoSolicitedValue, updatePhoneDraft, index as utils };
|