@orangecheck/auth-client 2.22.1 → 2.23.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 CHANGED
@@ -134,6 +134,8 @@ interface OcSignInProps {
134
134
  add?: boolean;
135
135
  className?: string;
136
136
  }
137
+ declare function safeReturnTo(input: string | undefined): string;
138
+ declare function familyReturnTarget(input: string | undefined | null): string | undefined;
137
139
  declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, providersFirst, paths, className, }: OcSignInProps): React.ReactElement;
138
140
 
139
141
  interface OcLinkedIdentity {
@@ -253,4 +255,4 @@ declare function handleSudoRequired(body: {
253
255
  returnTo?: string;
254
256
  }): boolean;
255
257
 
256
- 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, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, readTabSession, redirectToSudo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
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 };
package/dist/index.d.ts CHANGED
@@ -134,6 +134,8 @@ interface OcSignInProps {
134
134
  add?: boolean;
135
135
  className?: string;
136
136
  }
137
+ declare function safeReturnTo(input: string | undefined): string;
138
+ declare function familyReturnTarget(input: string | undefined | null): string | undefined;
137
139
  declare function OcSignIn({ audience, returnTo, onSuccess, resolveReturnTo, linkPrompt, add: addProp, authOrigin, initialPath, providersFirst, paths, className, }: OcSignInProps): React.ReactElement;
138
140
 
139
141
  interface OcLinkedIdentity {
@@ -253,4 +255,4 @@ declare function handleSudoRequired(body: {
253
255
  returnTo?: string;
254
256
  }): boolean;
255
257
 
256
- 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, fetchOcLinkedIdentities, handleSudoRequired, installTabFetchInterceptor, installTabLinkDecorator, readTabSession, redirectToSudo, tabSessionHeader, useOcAddressSuggestion, useOcSession, useOptionalOcSession, useStepUpAuth, useWebAuthnList, useWebAuthnRegister, writeTabSession };
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 };
package/dist/index.js CHANGED
@@ -2020,15 +2020,27 @@ var primaryChipStyle = {
2020
2020
  color: V.primary,
2021
2021
  border: `1px solid ${V.primary}`
2022
2022
  };
2023
+ function isSameOriginPath(candidate, origin) {
2024
+ try {
2025
+ return new URL(candidate, origin).origin === origin;
2026
+ } catch {
2027
+ return false;
2028
+ }
2029
+ }
2030
+ function resolutionOrigin() {
2031
+ return typeof window === "undefined" ? "https://ochk.io" : window.location.origin;
2032
+ }
2023
2033
  function safeReturnTo(input) {
2024
2034
  const candidate = input ?? "/";
2025
2035
  if (typeof candidate !== "string") return "/";
2026
- if (!candidate.startsWith("/") || candidate.startsWith("//")) return "/";
2027
- return candidate;
2036
+ if (!candidate.startsWith("/")) return "/";
2037
+ return isSameOriginPath(candidate, resolutionOrigin()) ? candidate : "/";
2028
2038
  }
2029
2039
  function familyReturnTarget(input) {
2030
2040
  if (typeof input !== "string" || input.length === 0) return void 0;
2031
- if (input.startsWith("/") && !input.startsWith("//")) return input;
2041
+ if (input.startsWith("/") && isSameOriginPath(input, resolutionOrigin())) {
2042
+ return input;
2043
+ }
2032
2044
  try {
2033
2045
  const u = new URL(input);
2034
2046
  if (u.protocol !== "https:") return void 0;
@@ -3140,12 +3152,14 @@ exports.buildSignInUrl = buildSignInUrl;
3140
3152
  exports.clearTabSession = clearTabSession;
3141
3153
  exports.consumeTabAccountHint = consumeTabAccountHint;
3142
3154
  exports.consumeTabAdoptMarker = consumeTabAdoptMarker;
3155
+ exports.familyReturnTarget = familyReturnTarget;
3143
3156
  exports.fetchOcLinkedIdentities = fetchOcLinkedIdentities;
3144
3157
  exports.handleSudoRequired = handleSudoRequired;
3145
3158
  exports.installTabFetchInterceptor = installTabFetchInterceptor;
3146
3159
  exports.installTabLinkDecorator = installTabLinkDecorator;
3147
3160
  exports.readTabSession = readTabSession;
3148
3161
  exports.redirectToSudo = redirectToSudo;
3162
+ exports.safeReturnTo = safeReturnTo;
3149
3163
  exports.tabSessionHeader = tabSessionHeader;
3150
3164
  exports.useOcAddressSuggestion = useOcAddressSuggestion;
3151
3165
  exports.useOcSession = useOcSession;