@block-auth.io/core 0.11.0 → 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 +357 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -5
- package/dist/index.d.ts +74 -5
- package/dist/index.js +355 -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;
|
|
@@ -713,6 +717,12 @@ declare const resetExtension: () => void;
|
|
|
713
717
|
* Mirrors `useStoreExtension.isShowSignin` from the React SDK.
|
|
714
718
|
*/
|
|
715
719
|
declare const isShowSignin: (state?: ExtensionState) => boolean;
|
|
720
|
+
/**
|
|
721
|
+
* The page is connected to the BlockAuth extension but has no session for it
|
|
722
|
+
* yet: the OTP has to be entered in the extension first (the `did` only
|
|
723
|
+
* arrives once the extension bridges its session).
|
|
724
|
+
*/
|
|
725
|
+
declare const needsExtensionUnlock: (serviceName: string | null | undefined, did: string | null | undefined, isLocked: boolean) => boolean;
|
|
716
726
|
|
|
717
727
|
interface Web3SignupState {
|
|
718
728
|
backendMessage: string | null;
|
|
@@ -729,6 +739,30 @@ type Locale = 'en' | 'es';
|
|
|
729
739
|
declare const $locale: nanostores.WritableAtom<Locale>;
|
|
730
740
|
declare const setLocale: (l: Locale) => void;
|
|
731
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
|
+
|
|
732
766
|
type GoogleFlow = 'auth-code' | 'implicit';
|
|
733
767
|
interface GoogleConfig {
|
|
734
768
|
clientId: string;
|
|
@@ -818,10 +852,10 @@ interface BlockAuthClientConfig {
|
|
|
818
852
|
* deja apiSecret vacío para que el secreto nunca llegue al cliente. */
|
|
819
853
|
browserToken?: string;
|
|
820
854
|
wsUrl?: string;
|
|
821
|
-
/**
|
|
822
|
-
*
|
|
823
|
-
* (GET /auth/ws-ticket).
|
|
824
|
-
*
|
|
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. */
|
|
825
859
|
apiUrl?: string;
|
|
826
860
|
/** Timeout (ms) por intento del connect inicial del WS. Default 300 —
|
|
827
861
|
* puede quedarse corto en orígenes con más latencia (p.ej. PRE sin CDN). */
|
|
@@ -843,6 +877,8 @@ interface BlockAuthClientConfig {
|
|
|
843
877
|
redirectUri?: string;
|
|
844
878
|
};
|
|
845
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'>>;
|
|
846
882
|
declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
847
883
|
state: {
|
|
848
884
|
$ws: nanostores.MapStore<WsState>;
|
|
@@ -850,6 +886,7 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
|
850
886
|
$wallet: nanostores.MapStore<WalletState>;
|
|
851
887
|
$openModals: nanostores.WritableAtom<ModalName[]>;
|
|
852
888
|
$user: nanostores.MapStore<UserState>;
|
|
889
|
+
$extension: nanostores.MapStore<ExtensionState>;
|
|
853
890
|
};
|
|
854
891
|
/** App apiKey from client config (also seeded into $ws). */
|
|
855
892
|
apiKey: string;
|
|
@@ -1181,6 +1218,9 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
|
1181
1218
|
signup: (providerSlug: string) => Promise<void>;
|
|
1182
1219
|
};
|
|
1183
1220
|
connectBlockAuth: () => void;
|
|
1221
|
+
loginWithPopup: () => Promise<PopupLoginResult>;
|
|
1222
|
+
authorizeWithPopup: () => Promise<PopupAuthCode>;
|
|
1223
|
+
rememberHostedLogin: (user: HostedLoginUser) => void;
|
|
1184
1224
|
oauth: {
|
|
1185
1225
|
signupGoogle: (flow?: "auth-code" | "implicit") => Promise<void>;
|
|
1186
1226
|
signupMicrosoft: () => Promise<void>;
|
|
@@ -1209,6 +1249,10 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
|
1209
1249
|
openModal: (name: ModalName) => void;
|
|
1210
1250
|
closeModal: (name?: ModalName) => void;
|
|
1211
1251
|
closeAllModals: () => void;
|
|
1252
|
+
registerRuntime: (bridge: {
|
|
1253
|
+
switchAccount: () => Promise<void>;
|
|
1254
|
+
} | null) => void;
|
|
1255
|
+
switchAccount: () => Promise<void>;
|
|
1212
1256
|
wsConnectTimeout: number;
|
|
1213
1257
|
wsConnectRetries: number;
|
|
1214
1258
|
apiUrl: string | undefined;
|
|
@@ -1302,6 +1346,10 @@ declare const TEXTS: {
|
|
|
1302
1346
|
readonly es: "ACEPTAR";
|
|
1303
1347
|
readonly en: "ACCEPT";
|
|
1304
1348
|
};
|
|
1349
|
+
readonly useAnotherAccount: {
|
|
1350
|
+
readonly es: "Usar otra cuenta";
|
|
1351
|
+
readonly en: "Use another account";
|
|
1352
|
+
};
|
|
1305
1353
|
readonly iAuthorizeThe: {
|
|
1306
1354
|
readonly es: "Autorizo la";
|
|
1307
1355
|
readonly en: "I authorize the";
|
|
@@ -1378,6 +1426,10 @@ declare const TEXTS: {
|
|
|
1378
1426
|
readonly es: "Aceptar";
|
|
1379
1427
|
readonly en: "Accept";
|
|
1380
1428
|
};
|
|
1429
|
+
readonly cancelData: {
|
|
1430
|
+
readonly es: "Cancelar";
|
|
1431
|
+
readonly en: "Cancel";
|
|
1432
|
+
};
|
|
1381
1433
|
readonly noTransactionsFound: {
|
|
1382
1434
|
readonly es: "No se encontraron transacciones";
|
|
1383
1435
|
readonly en: "No transactions found";
|
|
@@ -1541,6 +1593,21 @@ declare const setSolicitedShared: (form: SolicitedDataForm, slug: string, shared
|
|
|
1541
1593
|
declare const saveSolicitedValue: (form: SolicitedDataForm, slug: string) => SolicitedDataForm;
|
|
1542
1594
|
declare const undoSolicitedValue: (form: SolicitedDataForm, item: SolicitedParam) => SolicitedDataForm;
|
|
1543
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
|
+
|
|
1544
1611
|
type PhoneCountryCode = CountryCode;
|
|
1545
1612
|
interface PhoneCountry {
|
|
1546
1613
|
iso2: PhoneCountryCode;
|
|
@@ -1575,11 +1642,13 @@ interface AuthRuntimeCallbacks {
|
|
|
1575
1642
|
onSuccess?: (address: string) => void | Promise<void>;
|
|
1576
1643
|
onError?: () => void | Promise<void>;
|
|
1577
1644
|
onLogout?: () => void | Promise<void>;
|
|
1645
|
+
onCancel?: () => void | Promise<void>;
|
|
1578
1646
|
}
|
|
1579
1647
|
declare function createAuthRuntime(client: BlockAuthClient, callbacks?: AuthRuntimeCallbacks): {
|
|
1580
1648
|
start: () => Promise<void>;
|
|
1581
1649
|
stop: () => void;
|
|
1582
1650
|
logout: () => Promise<void>;
|
|
1651
|
+
switchAccount: () => Promise<void>;
|
|
1583
1652
|
};
|
|
1584
1653
|
type AuthRuntime = ReturnType<typeof createAuthRuntime>;
|
|
1585
1654
|
|
|
@@ -2111,4 +2180,4 @@ declare function resetExtensionSyncModuleState(): void;
|
|
|
2111
2180
|
*/
|
|
2112
2181
|
declare function startExtensionSync(): () => void;
|
|
2113
2182
|
|
|
2114
|
-
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, 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;
|
|
@@ -713,6 +717,12 @@ declare const resetExtension: () => void;
|
|
|
713
717
|
* Mirrors `useStoreExtension.isShowSignin` from the React SDK.
|
|
714
718
|
*/
|
|
715
719
|
declare const isShowSignin: (state?: ExtensionState) => boolean;
|
|
720
|
+
/**
|
|
721
|
+
* The page is connected to the BlockAuth extension but has no session for it
|
|
722
|
+
* yet: the OTP has to be entered in the extension first (the `did` only
|
|
723
|
+
* arrives once the extension bridges its session).
|
|
724
|
+
*/
|
|
725
|
+
declare const needsExtensionUnlock: (serviceName: string | null | undefined, did: string | null | undefined, isLocked: boolean) => boolean;
|
|
716
726
|
|
|
717
727
|
interface Web3SignupState {
|
|
718
728
|
backendMessage: string | null;
|
|
@@ -729,6 +739,30 @@ type Locale = 'en' | 'es';
|
|
|
729
739
|
declare const $locale: nanostores.WritableAtom<Locale>;
|
|
730
740
|
declare const setLocale: (l: Locale) => void;
|
|
731
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
|
+
|
|
732
766
|
type GoogleFlow = 'auth-code' | 'implicit';
|
|
733
767
|
interface GoogleConfig {
|
|
734
768
|
clientId: string;
|
|
@@ -818,10 +852,10 @@ interface BlockAuthClientConfig {
|
|
|
818
852
|
* deja apiSecret vacío para que el secreto nunca llegue al cliente. */
|
|
819
853
|
browserToken?: string;
|
|
820
854
|
wsUrl?: string;
|
|
821
|
-
/**
|
|
822
|
-
*
|
|
823
|
-
* (GET /auth/ws-ticket).
|
|
824
|
-
*
|
|
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. */
|
|
825
859
|
apiUrl?: string;
|
|
826
860
|
/** Timeout (ms) por intento del connect inicial del WS. Default 300 —
|
|
827
861
|
* puede quedarse corto en orígenes con más latencia (p.ej. PRE sin CDN). */
|
|
@@ -843,6 +877,8 @@ interface BlockAuthClientConfig {
|
|
|
843
877
|
redirectUri?: string;
|
|
844
878
|
};
|
|
845
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'>>;
|
|
846
882
|
declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
847
883
|
state: {
|
|
848
884
|
$ws: nanostores.MapStore<WsState>;
|
|
@@ -850,6 +886,7 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
|
850
886
|
$wallet: nanostores.MapStore<WalletState>;
|
|
851
887
|
$openModals: nanostores.WritableAtom<ModalName[]>;
|
|
852
888
|
$user: nanostores.MapStore<UserState>;
|
|
889
|
+
$extension: nanostores.MapStore<ExtensionState>;
|
|
853
890
|
};
|
|
854
891
|
/** App apiKey from client config (also seeded into $ws). */
|
|
855
892
|
apiKey: string;
|
|
@@ -1181,6 +1218,9 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
|
1181
1218
|
signup: (providerSlug: string) => Promise<void>;
|
|
1182
1219
|
};
|
|
1183
1220
|
connectBlockAuth: () => void;
|
|
1221
|
+
loginWithPopup: () => Promise<PopupLoginResult>;
|
|
1222
|
+
authorizeWithPopup: () => Promise<PopupAuthCode>;
|
|
1223
|
+
rememberHostedLogin: (user: HostedLoginUser) => void;
|
|
1184
1224
|
oauth: {
|
|
1185
1225
|
signupGoogle: (flow?: "auth-code" | "implicit") => Promise<void>;
|
|
1186
1226
|
signupMicrosoft: () => Promise<void>;
|
|
@@ -1209,6 +1249,10 @@ declare function createBlockAuthClient(config: BlockAuthClientConfig): {
|
|
|
1209
1249
|
openModal: (name: ModalName) => void;
|
|
1210
1250
|
closeModal: (name?: ModalName) => void;
|
|
1211
1251
|
closeAllModals: () => void;
|
|
1252
|
+
registerRuntime: (bridge: {
|
|
1253
|
+
switchAccount: () => Promise<void>;
|
|
1254
|
+
} | null) => void;
|
|
1255
|
+
switchAccount: () => Promise<void>;
|
|
1212
1256
|
wsConnectTimeout: number;
|
|
1213
1257
|
wsConnectRetries: number;
|
|
1214
1258
|
apiUrl: string | undefined;
|
|
@@ -1302,6 +1346,10 @@ declare const TEXTS: {
|
|
|
1302
1346
|
readonly es: "ACEPTAR";
|
|
1303
1347
|
readonly en: "ACCEPT";
|
|
1304
1348
|
};
|
|
1349
|
+
readonly useAnotherAccount: {
|
|
1350
|
+
readonly es: "Usar otra cuenta";
|
|
1351
|
+
readonly en: "Use another account";
|
|
1352
|
+
};
|
|
1305
1353
|
readonly iAuthorizeThe: {
|
|
1306
1354
|
readonly es: "Autorizo la";
|
|
1307
1355
|
readonly en: "I authorize the";
|
|
@@ -1378,6 +1426,10 @@ declare const TEXTS: {
|
|
|
1378
1426
|
readonly es: "Aceptar";
|
|
1379
1427
|
readonly en: "Accept";
|
|
1380
1428
|
};
|
|
1429
|
+
readonly cancelData: {
|
|
1430
|
+
readonly es: "Cancelar";
|
|
1431
|
+
readonly en: "Cancel";
|
|
1432
|
+
};
|
|
1381
1433
|
readonly noTransactionsFound: {
|
|
1382
1434
|
readonly es: "No se encontraron transacciones";
|
|
1383
1435
|
readonly en: "No transactions found";
|
|
@@ -1541,6 +1593,21 @@ declare const setSolicitedShared: (form: SolicitedDataForm, slug: string, shared
|
|
|
1541
1593
|
declare const saveSolicitedValue: (form: SolicitedDataForm, slug: string) => SolicitedDataForm;
|
|
1542
1594
|
declare const undoSolicitedValue: (form: SolicitedDataForm, item: SolicitedParam) => SolicitedDataForm;
|
|
1543
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
|
+
|
|
1544
1611
|
type PhoneCountryCode = CountryCode;
|
|
1545
1612
|
interface PhoneCountry {
|
|
1546
1613
|
iso2: PhoneCountryCode;
|
|
@@ -1575,11 +1642,13 @@ interface AuthRuntimeCallbacks {
|
|
|
1575
1642
|
onSuccess?: (address: string) => void | Promise<void>;
|
|
1576
1643
|
onError?: () => void | Promise<void>;
|
|
1577
1644
|
onLogout?: () => void | Promise<void>;
|
|
1645
|
+
onCancel?: () => void | Promise<void>;
|
|
1578
1646
|
}
|
|
1579
1647
|
declare function createAuthRuntime(client: BlockAuthClient, callbacks?: AuthRuntimeCallbacks): {
|
|
1580
1648
|
start: () => Promise<void>;
|
|
1581
1649
|
stop: () => void;
|
|
1582
1650
|
logout: () => Promise<void>;
|
|
1651
|
+
switchAccount: () => Promise<void>;
|
|
1583
1652
|
};
|
|
1584
1653
|
type AuthRuntime = ReturnType<typeof createAuthRuntime>;
|
|
1585
1654
|
|
|
@@ -2111,4 +2180,4 @@ declare function resetExtensionSyncModuleState(): void;
|
|
|
2111
2180
|
*/
|
|
2112
2181
|
declare function startExtensionSync(): () => void;
|
|
2113
2182
|
|
|
2114
|
-
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, 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 };
|