PageSourceSearch

https://app.clariumhealth.com/assets/types-CQ-ki0qK.js

js clariumhealth.com collected 2026-09-25 15:14:52 UTC 8,725 bytes, 149 lines download raw bytes

1import { S as AmplifyError, g as assert, h as AuthConfigurationErrorCode } from "./Amplify-ydFdTLPK.js";
2var getCrypto = () => {
3	if (typeof window === "object" && typeof window.crypto === "object") return window.crypto;
4	if (typeof crypto === "object") return crypto;
5	throw new AmplifyError({
6		name: "MissingPolyfill",
7		message: "Cannot resolve the `crypto` function from the environment."
8	});
9};
10var getBtoa = () => {
11	if (typeof window !== "undefined" && typeof window.btoa === "function") return window.btoa;
12	if (typeof btoa === "function") return btoa;
13	throw new AmplifyError({
14		name: "Base64EncoderError",
15		message: "Cannot resolve the `btoa` function from the environment."
16	});
17};
18var getAtob = () => {
19	if (typeof window !== "undefined" && typeof window.atob === "function") return window.atob;
20	if (typeof atob === "function") return atob;
21	throw new AmplifyError({
22		name: "Base64EncoderError",
23		message: "Cannot resolve the `atob` function from the environment."
24	});
25};
26var base64Decoder = { convert(input, options) {
27	let inputStr = input;
28	if (options === null || options === void 0 ? void 0 : options.urlSafe) inputStr = inputStr.replace(/-/g, "+").replace(/_/g, "/");
29	return getAtob()(inputStr);
30} };
31function assertTokenProviderConfig(cognitoConfig) {
32	let assertionValid = true;
33	if (!cognitoConfig) assertionValid = false;
34	else assertionValid = !!cognitoConfig.userPoolId && !!cognitoConfig.userPoolClientId;
35	assert(assertionValid, AuthConfigurationErrorCode.AuthUserPoolException);
36}
37function assertOAuthConfig(cognitoConfig) {
38	var _cognitoConfig$loginW, _cognitoConfig$loginW2, _cognitoConfig$loginW3, _cognitoConfig$loginW4;
39	assert(!!(cognitoConfig === null || cognitoConfig === void 0 || (_cognitoConfig$loginW = cognitoConfig.loginWith) === null || _cognitoConfig$loginW === void 0 || (_cognitoConfig$loginW = _cognitoConfig$loginW.oauth) === null || _cognitoConfig$loginW === void 0 ? void 0 : _cognitoConfig$loginW.domain) && !!(cognitoConfig === null || cognitoConfig === void 0 || (_cognitoConfig$loginW2 = cognitoConfig.loginWith) === null || _cognitoConfig$loginW2 === void 0 || (_cognitoConfig$loginW2 = _cognitoConfig$loginW2.oauth) === null || _cognitoConfig$loginW2 === void 0 ? void 0 : _cognitoConfig$loginW2.redirectSignOut) && !!(cognitoConfig === null || cognitoConfig === void 0 || (_cognitoConfig$loginW3 = cognitoConfig.loginWith) === null || _cognitoConfig$loginW3 === void 0 || (_cognitoConfig$loginW3 = _cognitoConfig$loginW3.oauth) === null || _cognitoConfig$loginW3 === void 0 ? void 0 : _cognitoConfig$loginW3.redirectSignIn) && !!(cognitoConfig === null || cognitoConfig === void 0 || (_cognitoConfig$loginW4 = cognitoConfig.loginWith) === null || _cognitoConfig$loginW4 === void 0 || (_cognitoConfig$loginW4 = _cognitoConfig$loginW4.oauth) === null || _cognitoConfig$loginW4 === void 0 ? void 0 : _cognitoConfig$loginW4.responseType), AuthConfigurationErrorCode.OAuthNotConfigureException);
40}
41function assertIdentityPoolIdConfig(cognitoConfig) {
42	assert(!!(cognitoConfig === null || cognitoConfig === void 0 ? void 0 : cognitoConfig.identityPoolId), AuthConfigurationErrorCode.InvalidIdentityPoolIdException);
43}
44function decodeJWT(token) {
45	const tokenParts = token.split(".");
46	if (tokenParts.length !== 3) throw new Error("Invalid token");
47	try {
48		const base64 = tokenParts[1].replace(/-/g, "+").replace(/_/g, "/");
49		const jsonStr = decodeURIComponent(base64Decoder.convert(base64).split("").map((char) => `%${`00${char.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));
50		return {
51			toString: () => token,
52			payload: JSON.parse(jsonStr)
53		};
54	} catch (err) {
55		throw new Error("Invalid token payload");
56	}
57}
58var AuthError = class AuthError extends AmplifyError {
59	constructor(params) {
60		super(params);
61		this.constructor = AuthError;
62		Object.setPrototypeOf(this, AuthError.prototype);
63	}
64};
65var USER_UNAUTHENTICATED_EXCEPTION = "UserUnAuthenticatedException";
66var USER_ALREADY_AUTHENTICATED_EXCEPTION = "UserAlreadyAuthenticatedException";
67var DEVICE_METADATA_NOT_FOUND_EXCEPTION = "DeviceMetadataNotFoundException";
68var AUTO_SIGN_IN_EXCEPTION = "AutoSignInException";
69var INVALID_REDIRECT_EXCEPTION = "InvalidRedirectException";
70var INVALID_APP_SCHEME_EXCEPTION = "InvalidAppSchemeException";
71var INVALID_PREFERRED_REDIRECT_EXCEPTION = "InvalidPreferredRedirectUrlException";
72var invalidRedirectException = new AuthError({
73	name: INVALID_REDIRECT_EXCEPTION,
74	message: "signInRedirect or signOutRedirect had an invalid format or was not found.",
75	recoverySuggestion: "Please make sure the signIn/Out redirect in your oauth config is valid."
76});
77new AuthError({
78	name: INVALID_APP_SCHEME_EXCEPTION,
79	message: "A valid non-http app scheme was not found in the config.",
80	recoverySuggestion: "Please make sure a valid custom app scheme is present in the config."
81});
82var invalidPreferredRedirectUrlException = new AuthError({
83	name: INVALID_PREFERRED_REDIRECT_EXCEPTION,
84	message: "The given preferredRedirectUrl does not match any items in the redirectSignOutUrls array from the config.",
85	recoverySuggestion: "Please make sure a matching preferredRedirectUrl is provided."
86});
87var invalidOriginException = new AuthError({
88	name: "InvalidOriginException",
89	message: "redirect is coming from a different origin. The oauth flow needs to be initiated from the same origin",
90	recoverySuggestion: "Please call signInWithRedirect from the same origin."
91});
92var OAUTH_SIGNOUT_EXCEPTION = "OAuthSignOutException";
93var TOKEN_REFRESH_EXCEPTION = "TokenRefreshException";
94var UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION = "UnexpectedSignInInterruptionException";
95function assertAuthTokens(tokens) {
96	if (!tokens || !tokens.accessToken) throw new AuthError({
97		name: USER_UNAUTHENTICATED_EXCEPTION,
98		message: "User needs to be authenticated to call this API.",
99		recoverySuggestion: "Sign in before calling this API again."
100	});
101}
102function assertIdTokenInAuthTokens(tokens) {
103	if (!tokens || !tokens.idToken) throw new AuthError({
104		name: USER_UNAUTHENTICATED_EXCEPTION,
105		message: "User needs to be authenticated to call this API.",
106		recoverySuggestion: "Sign in before calling this API again."
107	});
108}
109var oAuthTokenRefreshException = new AuthError({
110	name: TOKEN_REFRESH_EXCEPTION,
111	message: `Token refresh is not supported when authenticated with the 'implicit grant' (token) oauth flow. 
112	Please change your oauth configuration to use 'code grant' flow.`,
113	recoverySuggestion: `Please logout and change your Amplify configuration to use "code grant" flow. 
114	E.g { responseType: 'code' }`
115});
116var tokenRefreshException = new AuthError({
117	name: USER_UNAUTHENTICATED_EXCEPTION,
118	message: "User needs to be authenticated to call this API.",
119	recoverySuggestion: "Sign in before calling this API again."
120});
121function assertAuthTokensWithRefreshToken(tokens) {
122	if (isAuthenticatedWithImplicitOauthFlow(tokens)) throw oAuthTokenRefreshException;
123	if (!isAuthenticatedWithRefreshToken(tokens)) throw tokenRefreshException;
124}
125function assertDeviceMetadata(deviceMetadata) {
126	if (!deviceMetadata || !deviceMetadata.deviceKey || !deviceMetadata.deviceGroupKey || !deviceMetadata.randomPassword) throw new AuthError({
127		name: DEVICE_METADATA_NOT_FOUND_EXCEPTION,
128		message: "Either deviceKey, deviceGroupKey or secretPassword were not found during the sign-in process.",
129		recoverySuggestion: "Make sure to not clear storage after calling the signIn API."
130	});
131}
132var OAuthStorageKeys = {
133	inflightOAuth: "inflightOAuth",
134	oauthSignIn: "oauthSignIn",
135	oauthPKCE: "oauthPKCE",
136	oauthState: "oauthState"
137};
138function isAuthenticated(tokens) {
139	return (tokens === null || tokens === void 0 ? void 0 : tokens.accessToken) || (tokens === null || tokens === void 0 ? void 0 : tokens.idToken);
140}
141function isAuthenticatedWithRefreshToken(tokens) {
142	return isAuthenticated(tokens) && (tokens === null || tokens === void 0 ? void 0 : tokens.refreshToken);
143}
144function isAuthenticatedWithImplicitOauthFlow(tokens) {
145	return isAuthenticated(tokens) && !(tokens === null || tokens === void 0 ? void 0 : tokens.refreshToken);
146}
147export { assertTokenProviderConfig as _, assertIdTokenInAuthTokens as a, getBtoa as b, UNEXPECTED_SIGN_IN_INTERRUPTION_EXCEPTION as c, invalidOriginException as d, invalidPreferredRedirectUrlException as f, assertOAuthConfig as g, assertIdentityPoolIdConfig as h, assertDeviceMetadata as i, USER_ALREADY_AUTHENTICATED_EXCEPTION as l, AuthError as m, assertAuthTokens as n, AUTO_SIGN_IN_EXCEPTION as o, invalidRedirectException as p, assertAuthTokensWithRefreshToken as r, OAUTH_SIGNOUT_EXCEPTION as s, OAuthStorageKeys as t, USER_UNAUTHENTICATED_EXCEPTION as u, decodeJWT as v, getCrypto as x, base64Decoder as y };
148
149//# sourceMappingURL=types-CQ-ki0qK.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.