@clerk/shared
Advanced tools
Comparing version 2.16.1 to 2.17.0-canary.v20241122170511
@@ -1,2 +0,2 @@ | ||
import { __experimental_ReverificationConfig } from '@clerk/types'; | ||
import { ReverificationConfig } from '@clerk/types'; | ||
@@ -15,3 +15,3 @@ type ClerkError<T> = { | ||
} & M>; | ||
declare const __experimental_reverificationError: <MC extends __experimental_ReverificationConfig>(missingConfig?: MC) => ReverificationError<{ | ||
declare const reverificationError: <MC extends ReverificationConfig>(missingConfig?: MC) => ReverificationError<{ | ||
metadata: { | ||
@@ -21,5 +21,5 @@ reverification?: MC; | ||
}>; | ||
declare const __experimental_reverificationErrorResponse: (missingConfig?: __experimental_ReverificationConfig | undefined) => Response; | ||
declare const __experimental_isReverificationHint: (result: any) => result is ReturnType<typeof __experimental_reverificationError>; | ||
declare const reverificationErrorResponse: (missingConfig?: ReverificationConfig | undefined) => Response; | ||
declare const isReverificationHint: (result: any) => result is ReturnType<typeof reverificationError>; | ||
export { __experimental_isReverificationHint, __experimental_reverificationError, __experimental_reverificationErrorResponse }; | ||
export { isReverificationHint, reverificationError, reverificationErrorResponse }; |
@@ -23,9 +23,9 @@ "use strict"; | ||
__export(authorization_errors_exports, { | ||
__experimental_isReverificationHint: () => __experimental_isReverificationHint, | ||
__experimental_reverificationError: () => __experimental_reverificationError, | ||
__experimental_reverificationErrorResponse: () => __experimental_reverificationErrorResponse | ||
isReverificationHint: () => isReverificationHint, | ||
reverificationError: () => reverificationError, | ||
reverificationErrorResponse: () => reverificationErrorResponse | ||
}); | ||
module.exports = __toCommonJS(authorization_errors_exports); | ||
var REVERIFICATION_REASON = "reverification-error"; | ||
var __experimental_reverificationError = (missingConfig) => ({ | ||
var reverificationError = (missingConfig) => ({ | ||
clerk_error: { | ||
@@ -39,6 +39,6 @@ type: "forbidden", | ||
}); | ||
var __experimental_reverificationErrorResponse = (...args) => new Response(JSON.stringify(__experimental_reverificationError(...args)), { | ||
var reverificationErrorResponse = (...args) => new Response(JSON.stringify(reverificationError(...args)), { | ||
status: 403 | ||
}); | ||
var __experimental_isReverificationHint = (result) => { | ||
var isReverificationHint = (result) => { | ||
var _a, _b; | ||
@@ -49,6 +49,6 @@ return result && typeof result === "object" && "clerk_error" in result && ((_a = result.clerk_error) == null ? void 0 : _a.type) === "forbidden" && ((_b = result.clerk_error) == null ? void 0 : _b.reason) === REVERIFICATION_REASON; | ||
0 && (module.exports = { | ||
__experimental_isReverificationHint, | ||
__experimental_reverificationError, | ||
__experimental_reverificationErrorResponse | ||
isReverificationHint, | ||
reverificationError, | ||
reverificationErrorResponse | ||
}); | ||
//# sourceMappingURL=authorization-errors.js.map |
import * as _clerk_types from '@clerk/types'; | ||
import { __experimental_ReverificationConfig, __experimental_SessionVerificationLevel, CheckAuthorizationWithCustomPermissions } from '@clerk/types'; | ||
import { ReverificationConfig, SessionVerificationLevel, CheckAuthorizationWithCustomPermissions } from '@clerk/types'; | ||
@@ -9,7 +9,7 @@ type AuthorizationOptions = { | ||
orgPermissions: string[] | null | undefined; | ||
__experimental_factorVerificationAge: [number, number] | null; | ||
factorVerificationAge: [number, number] | null; | ||
}; | ||
declare const validateReverificationConfig: (config: __experimental_ReverificationConfig | undefined) => false | (() => { | ||
level: __experimental_SessionVerificationLevel; | ||
afterMinutes: _clerk_types.__experimental_SessionVerificationAfterMinutes; | ||
declare const validateReverificationConfig: (config: ReverificationConfig | undefined) => false | (() => { | ||
level: SessionVerificationLevel; | ||
afterMinutes: _clerk_types.SessionVerificationAfterMinutes; | ||
}); | ||
@@ -16,0 +16,0 @@ /** |
@@ -45,7 +45,3 @@ "use strict"; | ||
}; | ||
var ALLOWED_LEVELS = /* @__PURE__ */ new Set([ | ||
"first_factor", | ||
"second_factor", | ||
"multi_factor" | ||
]); | ||
var ALLOWED_LEVELS = /* @__PURE__ */ new Set(["first_factor", "second_factor", "multi_factor"]); | ||
var ALLOWED_TYPES = /* @__PURE__ */ new Set(["strict_mfa", "strict", "moderate", "lax"]); | ||
@@ -85,7 +81,7 @@ var isValidMaxAge = (maxAge) => typeof maxAge === "number" && maxAge > 0; | ||
}; | ||
var checkStepUpAuthorization = (params, { __experimental_factorVerificationAge }) => { | ||
if (!params.__experimental_reverification || !__experimental_factorVerificationAge) { | ||
var checkStepUpAuthorization = (params, { factorVerificationAge }) => { | ||
if (!params.reverification || !factorVerificationAge) { | ||
return null; | ||
} | ||
const isValidReverification = validateReverificationConfig(params.__experimental_reverification); | ||
const isValidReverification = validateReverificationConfig(params.reverification); | ||
if (!isValidReverification) { | ||
@@ -95,3 +91,3 @@ return null; | ||
const { level, afterMinutes } = isValidReverification(); | ||
const [factor1Age, factor2Age] = __experimental_factorVerificationAge; | ||
const [factor1Age, factor2Age] = factorVerificationAge; | ||
const isValidFactor1 = factor1Age !== -1 ? afterMinutes > factor1Age : null; | ||
@@ -98,0 +94,0 @@ const isValidFactor2 = factor2Age !== -1 ? afterMinutes > factor2Age : null; |
@@ -18,5 +18,5 @@ import * as _clerk_types from '@clerk/types'; | ||
actor: _clerk_types.ActJWTClaim | null | undefined; | ||
__experimental_factorVerificationAge: [number, number] | null; | ||
factorVerificationAge: [number, number] | null; | ||
}; | ||
export { deriveState }; |
@@ -43,3 +43,3 @@ "use strict"; | ||
const actor = initialState.actor; | ||
const __experimental_factorVerificationAge = initialState.__experimental_factorVerificationAge; | ||
const factorVerificationAge = initialState.factorVerificationAge; | ||
return { | ||
@@ -56,3 +56,3 @@ userId, | ||
actor, | ||
__experimental_factorVerificationAge | ||
factorVerificationAge | ||
}; | ||
@@ -66,3 +66,3 @@ }; | ||
const session = state.session; | ||
const __experimental_factorVerificationAge = state.session ? state.session.__experimental_factorVerificationAge : null; | ||
const factorVerificationAge = state.session ? state.session.factorVerificationAge : null; | ||
const actor = session == null ? void 0 : session.actor; | ||
@@ -86,3 +86,3 @@ const organization = state.organization; | ||
actor, | ||
__experimental_factorVerificationAge | ||
factorVerificationAge | ||
}; | ||
@@ -89,0 +89,0 @@ }; |
@@ -754,3 +754,3 @@ "use strict"; | ||
const actor = initialState.actor; | ||
const __experimental_factorVerificationAge = initialState.__experimental_factorVerificationAge; | ||
const factorVerificationAge = initialState.factorVerificationAge; | ||
return { | ||
@@ -767,3 +767,3 @@ userId, | ||
actor, | ||
__experimental_factorVerificationAge | ||
factorVerificationAge | ||
}; | ||
@@ -777,3 +777,3 @@ }; | ||
const session = state.session; | ||
const __experimental_factorVerificationAge = state.session ? state.session.__experimental_factorVerificationAge : null; | ||
const factorVerificationAge = state.session ? state.session.factorVerificationAge : null; | ||
const actor = session == null ? void 0 : session.actor; | ||
@@ -797,3 +797,3 @@ const organization = state.organization; | ||
actor, | ||
__experimental_factorVerificationAge | ||
factorVerificationAge | ||
}; | ||
@@ -1190,3 +1190,3 @@ }; | ||
// src/versionSelector.ts | ||
var versionSelector = (clerkJSVersion, packageVersion = "5.34.6") => { | ||
var versionSelector = (clerkJSVersion, packageVersion = "5.35.0-canary.v20241122170511") => { | ||
if (clerkJSVersion) { | ||
@@ -1198,3 +1198,3 @@ return clerkJSVersion; | ||
if (prereleaseTag === "snapshot") { | ||
return "5.34.6"; | ||
return "5.35.0-canary.v20241122170511"; | ||
} | ||
@@ -1201,0 +1201,0 @@ return prereleaseTag; |
@@ -272,3 +272,3 @@ "use strict"; | ||
// src/versionSelector.ts | ||
var versionSelector = (clerkJSVersion, packageVersion = "5.34.6") => { | ||
var versionSelector = (clerkJSVersion, packageVersion = "5.35.0-canary.v20241122170511") => { | ||
if (clerkJSVersion) { | ||
@@ -280,3 +280,3 @@ return clerkJSVersion; | ||
if (prereleaseTag === "snapshot") { | ||
return "5.34.6"; | ||
return "5.35.0-canary.v20241122170511"; | ||
} | ||
@@ -283,0 +283,0 @@ return prereleaseTag; |
@@ -210,3 +210,3 @@ import React, { PropsWithChildren } from 'react'; | ||
*/ | ||
declare function __experimental_useReverification<Fetcher extends (...args: any[]) => Promise<any> | undefined, Options extends UseReverificationOptions>(fetcher: Fetcher, options?: Options): UseReverificationResult<Fetcher, Options>; | ||
declare function useReverification<Fetcher extends (...args: any[]) => Promise<any> | undefined, Options extends UseReverificationOptions>(fetcher: Fetcher, options?: Options): UseReverificationResult<Fetcher, Options>; | ||
@@ -242,2 +242,2 @@ declare const ClerkInstanceContext: React.Context<{ | ||
export { ClerkInstanceContext, ClientContext, OptionsContext, OrganizationProvider, SessionContext, UserContext, __experimental_useReverification, assertContextExists, createContextAndHook, isDeeplyEqual, useAssertWrappedByClerkProvider, useClerk, useClerkInstanceContext, useClientContext, useDeepEqualMemo, useOptionsContext, useOrganization, useOrganizationContext, useOrganizationList, useSafeLayoutEffect, useSession, useSessionContext, useSessionList, useUser, useUserContext }; | ||
export { ClerkInstanceContext, ClientContext, OptionsContext, OrganizationProvider, SessionContext, UserContext, assertContextExists, createContextAndHook, isDeeplyEqual, useAssertWrappedByClerkProvider, useClerk, useClerkInstanceContext, useClientContext, useDeepEqualMemo, useOptionsContext, useOrganization, useOrganizationContext, useOrganizationList, useReverification, useSafeLayoutEffect, useSession, useSessionContext, useSessionList, useUser, useUserContext }; |
@@ -40,3 +40,2 @@ "use strict"; | ||
UserContext: () => UserContext, | ||
__experimental_useReverification: () => __experimental_useReverification, | ||
assertContextExists: () => assertContextExists, | ||
@@ -54,2 +53,3 @@ createContextAndHook: () => createContextAndHook, | ||
useOrganizationList: () => useOrganizationList, | ||
useReverification: () => useReverification, | ||
useSafeLayoutEffect: () => useSafeLayoutEffect, | ||
@@ -713,7 +713,3 @@ useSession: () => useSession, | ||
}; | ||
var ALLOWED_LEVELS = /* @__PURE__ */ new Set([ | ||
"first_factor", | ||
"second_factor", | ||
"multi_factor" | ||
]); | ||
var ALLOWED_LEVELS = /* @__PURE__ */ new Set(["first_factor", "second_factor", "multi_factor"]); | ||
var ALLOWED_TYPES = /* @__PURE__ */ new Set(["strict_mfa", "strict", "moderate", "lax"]); | ||
@@ -740,3 +736,3 @@ var isValidMaxAge = (maxAge) => typeof maxAge === "number" && maxAge > 0; | ||
var REVERIFICATION_REASON = "reverification-error"; | ||
var __experimental_reverificationError = (missingConfig) => ({ | ||
var reverificationError = (missingConfig) => ({ | ||
clerk_error: { | ||
@@ -750,3 +746,3 @@ type: "forbidden", | ||
}); | ||
var __experimental_isReverificationHint = (result) => { | ||
var isReverificationHint = (result) => { | ||
var _a, _b; | ||
@@ -823,3 +819,3 @@ return result && typeof result === "object" && "clerk_error" in result && ((_a = result.clerk_error) == null ? void 0 : _a.type) === "forbidden" && ((_b = result.clerk_error) == null ? void 0 : _b.reason) === REVERIFICATION_REASON; | ||
if (isClerkAPIResponseError(e) && e.errors.find(({ code }) => code == "session_step_up_verification_required")) { | ||
return __experimental_reverificationError(); | ||
return reverificationError(); | ||
} | ||
@@ -834,3 +830,3 @@ throw e; | ||
let result = await resolveResult(fetcher(...args)); | ||
if (__experimental_isReverificationHint(result)) { | ||
if (isReverificationHint(result)) { | ||
const resolvers = createDeferredPromise(); | ||
@@ -869,4 +865,4 @@ const isValidMetadata = validateReverificationConfig(result.clerk_error.metadata.reverification); | ||
} | ||
function __experimental_useReverification(fetcher, options) { | ||
const { __experimental_openUserVerification } = useClerk(); | ||
function useReverification(fetcher, options) { | ||
const { __internal_openUserVerification } = useClerk(); | ||
const fetcherRef = (0, import_react6.useRef)(fetcher); | ||
@@ -876,7 +872,7 @@ const optionsRef = (0, import_react6.useRef)(options); | ||
const handler = createReverificationHandler({ | ||
openUIComponent: __experimental_openUserVerification, | ||
openUIComponent: __internal_openUserVerification, | ||
...optionsRef.current | ||
})(fetcherRef.current); | ||
return [handler]; | ||
}, [__experimental_openUserVerification, fetcherRef.current, optionsRef.current]); | ||
}, [__internal_openUserVerification, fetcherRef.current, optionsRef.current]); | ||
useSafeLayoutEffect(() => { | ||
@@ -896,3 +892,2 @@ fetcherRef.current = fetcher; | ||
UserContext, | ||
__experimental_useReverification, | ||
assertContextExists, | ||
@@ -910,2 +905,3 @@ createContextAndHook, | ||
useOrganizationList, | ||
useReverification, | ||
useSafeLayoutEffect, | ||
@@ -912,0 +908,0 @@ useSession, |
@@ -27,3 +27,3 @@ "use strict"; | ||
module.exports = __toCommonJS(versionSelector_exports); | ||
var versionSelector = (clerkJSVersion, packageVersion = "5.34.6") => { | ||
var versionSelector = (clerkJSVersion, packageVersion = "5.35.0-canary.v20241122170511") => { | ||
if (clerkJSVersion) { | ||
@@ -35,3 +35,3 @@ return clerkJSVersion; | ||
if (prereleaseTag === "snapshot") { | ||
return "5.34.6"; | ||
return "5.35.0-canary.v20241122170511"; | ||
} | ||
@@ -38,0 +38,0 @@ return prereleaseTag; |
{ | ||
"name": "@clerk/shared", | ||
"version": "2.16.1", | ||
"version": "2.17.0-canary.v20241122170511", | ||
"description": "Internal package utils used by the Clerk SDKs", | ||
@@ -123,3 +123,3 @@ "repository": { | ||
"swr": "^2.2.0", | ||
"@clerk/types": "4.34.2" | ||
"@clerk/types": "4.35.0-canary.v20241122170511" | ||
}, | ||
@@ -126,0 +126,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1091256
12119
2
+ Added@clerk/types@4.35.0-canary.v20241122170511(transitive)
- Removed@clerk/types@4.34.2(transitive)