@orangecheck/auth-client 2.24.1 → 2.25.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.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +40 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -254,5 +254,9 @@ declare function handleSudoRequired(body: {
|
|
|
254
254
|
} | null | undefined, args?: Omit<RedirectToSudoArgs, 'returnTo'> & {
|
|
255
255
|
returnTo?: string;
|
|
256
256
|
}): boolean;
|
|
257
|
+
declare const SUDO_ACCOUNT_MISMATCH_MESSAGE = "Switch this tab to that account first \u2014 the confirmation on file is for a different one.";
|
|
258
|
+
declare function isSudoAccountMismatch(body: {
|
|
259
|
+
reason?: string;
|
|
260
|
+
} | null | undefined): boolean;
|
|
257
261
|
|
|
258
|
-
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, familyReturnTarget, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, readTabSession, redirectToSudo, safeReturnTo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
|
|
262
|
+
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, SUDO_ACCOUNT_MISMATCH_MESSAGE, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, familyReturnTarget, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, isSudoAccountMismatch, readTabSession, redirectToSudo, safeReturnTo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
|
package/dist/index.d.ts
CHANGED
|
@@ -254,5 +254,9 @@ declare function handleSudoRequired(body: {
|
|
|
254
254
|
} | null | undefined, args?: Omit<RedirectToSudoArgs, 'returnTo'> & {
|
|
255
255
|
returnTo?: string;
|
|
256
256
|
}): boolean;
|
|
257
|
+
declare const SUDO_ACCOUNT_MISMATCH_MESSAGE = "Switch this tab to that account first \u2014 the confirmation on file is for a different one.";
|
|
258
|
+
declare function isSudoAccountMismatch(body: {
|
|
259
|
+
reason?: string;
|
|
260
|
+
} | null | undefined): boolean;
|
|
257
261
|
|
|
258
|
-
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, familyReturnTarget, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, readTabSession, redirectToSudo, safeReturnTo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
|
|
262
|
+
export { DEFAULT_CONFIG, DISPLAY_IDENTITY_KINDS, type DisplayIdentity, type DisplayIdentityKind, type OcAccount, OcAccountChip, type OcAccountChipProps, OcAccountPill, type OcAccountPillProps, type OcAccountSummary, OcAddressInput, type OcAddressInputProps, type OcAuthConfig, OcLinkedIdentities, type OcLinkedIdentitiesProps, type OcLinkedIdentity, OcSessionProvider, type OcSessionState, type OcSessionStatus, OcSignIn, OcSignInButton, type OcSignInButtonProps, type OcSignInProps, type OcSignOutScope, type OcTabSession, type RedirectToSudoArgs, SUDO_ACCOUNT_MISMATCH_MESSAGE, TAB_ACCOUNT_HINT_KEY, TAB_ADOPT_HASH, TAB_SESSION_HEADER, TAB_SESSION_STORAGE_KEY, type UseOcAddressSuggestionOptions, type UseOcAddressSuggestionReturn, type UseStepUpAuthReturn, type UseWebAuthnListReturn, type UseWebAuthnRegisterReturn, type WebAuthnAssertionStatus, type WebAuthnCredentialPublic, type WebAuthnListStatus, type WebAuthnRegisterResult, type WebAuthnRegisterStatus, type WebAuthnRemoveResult, type WebAuthnRenameResult, type WebAuthnStepUpResult, buildAddAccountUrl, buildSignInUrl, clearTabSession, consumeTabAccountHint, consumeTabAdoptMarker, familyReturnTarget, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, isSudoAccountMismatch, readTabSession, redirectToSudo, safeReturnTo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
|
package/dist/index.js
CHANGED
|
@@ -1154,6 +1154,32 @@ var OcAddressInput = React3__namespace.forwardRef(
|
|
|
1154
1154
|
);
|
|
1155
1155
|
}
|
|
1156
1156
|
);
|
|
1157
|
+
|
|
1158
|
+
// src/sudo.tsx
|
|
1159
|
+
function redirectToSudo(args = {}) {
|
|
1160
|
+
if (typeof window === "undefined") {
|
|
1161
|
+
throw new Error(
|
|
1162
|
+
"[@orangecheck/auth-client] redirectToSudo() requires a browser environment"
|
|
1163
|
+
);
|
|
1164
|
+
}
|
|
1165
|
+
const cfg = resolveConfig(args.config);
|
|
1166
|
+
const url = new URL("/sudo", cfg.authOrigin);
|
|
1167
|
+
const returnTo = args.returnTo ?? window.location.href;
|
|
1168
|
+
if (returnTo) url.searchParams.set("return_to", returnTo);
|
|
1169
|
+
if (args.purpose) url.searchParams.set("purpose", args.purpose);
|
|
1170
|
+
window.location.assign(url.toString());
|
|
1171
|
+
}
|
|
1172
|
+
function handleSudoRequired(body, args = {}) {
|
|
1173
|
+
if (body && body.reason === "sudo_required") {
|
|
1174
|
+
redirectToSudo(args);
|
|
1175
|
+
return true;
|
|
1176
|
+
}
|
|
1177
|
+
return false;
|
|
1178
|
+
}
|
|
1179
|
+
var SUDO_ACCOUNT_MISMATCH_MESSAGE = "Switch this tab to that account first \u2014 the confirmation on file is for a different one.";
|
|
1180
|
+
function isSudoAccountMismatch(body) {
|
|
1181
|
+
return body?.reason === "sudo_account_mismatch";
|
|
1182
|
+
}
|
|
1157
1183
|
var DEFAULT_AUTH_ORIGIN = "https://ochk.io";
|
|
1158
1184
|
async function fetchOcLinkedIdentities(opts) {
|
|
1159
1185
|
const authOrigin = opts?.authOrigin ?? DEFAULT_AUTH_ORIGIN;
|
|
@@ -1580,6 +1606,12 @@ function EmailLinkForm({
|
|
|
1580
1606
|
setBusy(false);
|
|
1581
1607
|
return;
|
|
1582
1608
|
}
|
|
1609
|
+
if (handleSudoRequired(j, { purpose: "link an email" })) return;
|
|
1610
|
+
if (isSudoAccountMismatch(j)) {
|
|
1611
|
+
setErr(SUDO_ACCOUNT_MISMATCH_MESSAGE);
|
|
1612
|
+
setBusy(false);
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1583
1615
|
if (!r.ok || !j.ok) throw new Error(j.reason ?? `http_${r.status}`);
|
|
1584
1616
|
onDone();
|
|
1585
1617
|
} catch (e) {
|
|
@@ -1722,6 +1754,12 @@ function BtcLinkForm({
|
|
|
1722
1754
|
setBusy(false);
|
|
1723
1755
|
return;
|
|
1724
1756
|
}
|
|
1757
|
+
if (handleSudoRequired(j, { purpose: "link a Bitcoin address" })) return;
|
|
1758
|
+
if (isSudoAccountMismatch(j)) {
|
|
1759
|
+
setErr(SUDO_ACCOUNT_MISMATCH_MESSAGE);
|
|
1760
|
+
setBusy(false);
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1725
1763
|
if (!r.ok || !j.ok) throw new Error(j.reason ?? `http_${r.status}`);
|
|
1726
1764
|
onDone();
|
|
1727
1765
|
} catch (e) {
|
|
@@ -3112,28 +3150,6 @@ function useStepUpAuth(opts) {
|
|
|
3112
3150
|
return { status, error, stepUp, reset };
|
|
3113
3151
|
}
|
|
3114
3152
|
|
|
3115
|
-
// src/sudo.tsx
|
|
3116
|
-
function redirectToSudo(args = {}) {
|
|
3117
|
-
if (typeof window === "undefined") {
|
|
3118
|
-
throw new Error(
|
|
3119
|
-
"[@orangecheck/auth-client] redirectToSudo() requires a browser environment"
|
|
3120
|
-
);
|
|
3121
|
-
}
|
|
3122
|
-
const cfg = resolveConfig(args.config);
|
|
3123
|
-
const url = new URL("/sudo", cfg.authOrigin);
|
|
3124
|
-
const returnTo = args.returnTo ?? window.location.href;
|
|
3125
|
-
if (returnTo) url.searchParams.set("return_to", returnTo);
|
|
3126
|
-
if (args.purpose) url.searchParams.set("purpose", args.purpose);
|
|
3127
|
-
window.location.assign(url.toString());
|
|
3128
|
-
}
|
|
3129
|
-
function handleSudoRequired(body, args = {}) {
|
|
3130
|
-
if (body && body.reason === "sudo_required") {
|
|
3131
|
-
redirectToSudo(args);
|
|
3132
|
-
return true;
|
|
3133
|
-
}
|
|
3134
|
-
return false;
|
|
3135
|
-
}
|
|
3136
|
-
|
|
3137
3153
|
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
3138
3154
|
exports.DISPLAY_IDENTITY_KINDS = DISPLAY_IDENTITY_KINDS;
|
|
3139
3155
|
exports.OcAccountChip = OcAccountChip;
|
|
@@ -3143,6 +3159,7 @@ exports.OcLinkedIdentities = OcLinkedIdentities;
|
|
|
3143
3159
|
exports.OcSessionProvider = OcSessionProvider;
|
|
3144
3160
|
exports.OcSignIn = OcSignIn;
|
|
3145
3161
|
exports.OcSignInButton = OcSignInButton;
|
|
3162
|
+
exports.SUDO_ACCOUNT_MISMATCH_MESSAGE = SUDO_ACCOUNT_MISMATCH_MESSAGE;
|
|
3146
3163
|
exports.TAB_ACCOUNT_HINT_KEY = TAB_ACCOUNT_HINT_KEY;
|
|
3147
3164
|
exports.TAB_ADOPT_HASH = TAB_ADOPT_HASH;
|
|
3148
3165
|
exports.TAB_SESSION_HEADER = TAB_SESSION_HEADER;
|
|
@@ -3157,6 +3174,7 @@ exports.fetchOcLinkedIdentities = fetchOcLinkedIdentities;
|
|
|
3157
3174
|
exports.handleSudoRequired = handleSudoRequired;
|
|
3158
3175
|
exports.installTabFetchInterceptor = installTabFetchInterceptor;
|
|
3159
3176
|
exports.installTabLinkDecorator = installTabLinkDecorator;
|
|
3177
|
+
exports.isSudoAccountMismatch = isSudoAccountMismatch;
|
|
3160
3178
|
exports.readTabSession = readTabSession;
|
|
3161
3179
|
exports.redirectToSudo = redirectToSudo;
|
|
3162
3180
|
exports.safeReturnTo = safeReturnTo;
|