@propelauth/nextjs 0.0.77 → 0.0.80
Sign up to get free protection for your applications and to get access to all the features.
package/dist/client/index.js
CHANGED
@@ -367,6 +367,7 @@ var initialAuthState = {
|
|
367
367
|
};
|
368
368
|
function authStateReducer(_state, action) {
|
369
369
|
const authChangeDetected = !_state.loading && !isEqual(action.user, _state.userAndAccessToken.user);
|
370
|
+
console.log("dispatching auth state reducer", { action, _state, authChangeDetected });
|
370
371
|
if (!action.user) {
|
371
372
|
return {
|
372
373
|
loading: false,
|
package/dist/client/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/client/index.ts","../../src/user.ts","../../src/client/AuthProvider.tsx","../../src/client/utils.ts","../../src/client/useUser.tsx","../../src/client/useHostedPageUrls.tsx","../../src/client/useLogoutFunction.ts","../../src/client/useRedirectFunctions.tsx","../../src/client/useRefreshAuth.ts"],"sourcesContent":["export type {OrgIdToOrgMemberInfo} from \"../user\"\nexport {UserFromToken, OrgMemberInfo} from \"../user\"\nexport {AuthProvider} from \"./AuthProvider\"\nexport type {AuthProviderProps} from \"./AuthProvider\"\nexport {useUser, User} from \"./useUser\"\nexport type {UseUser, UseUserLoading, UseUserLoggedIn, UseUserNotLoggedIn} from \"./useUser\"\nexport {useHostedPageUrls} from \"./useHostedPageUrls\"\nexport {useLogoutFunction} from \"./useLogoutFunction\"\nexport {useRedirectFunctions, RedirectToLogin, RedirectToSignup} from \"./useRedirectFunctions\"\nexport type {RedirectProps} from \"./useRedirectFunctions\"\nexport {useRefreshAuth} from \"./useRefreshAuth\"","export class UserFromToken {\n public userId: string\n public orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n\n // Metadata about the user\n public email: string\n public firstName?: string\n public lastName?: string\n public username?: string\n\n // If you used our migration APIs to migrate this user from a different system,\n // this is their original ID from that system.\n public legacyUserId?: string\n public impersonatorUserId?: string\n\n constructor(\n userId: string,\n email: string,\n orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo,\n firstName?: string,\n lastName?: string,\n username?: string,\n legacyUserId?: string,\n impersonatorUserId?: string\n ) {\n this.userId = userId\n this.orgIdToOrgMemberInfo = orgIdToOrgMemberInfo\n\n this.email = email\n this.firstName = firstName\n this.lastName = lastName\n this.username = username\n\n this.legacyUserId = legacyUserId\n this.impersonatorUserId = impersonatorUserId\n }\n\n public getOrg(orgId: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n return this.orgIdToOrgMemberInfo[orgId]\n }\n\n public getOrgByName(orgName: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n const urlSafeOrgName = orgName.toLowerCase().replace(/ /g, \"-\")\n for (const orgId in this.orgIdToOrgMemberInfo) {\n const orgMemberInfo = this.orgIdToOrgMemberInfo[orgId]\n if (orgMemberInfo.urlSafeOrgName === urlSafeOrgName) {\n return orgMemberInfo\n }\n }\n\n return undefined\n }\n\n public getOrgs(): OrgMemberInfo[] {\n if (!this.orgIdToOrgMemberInfo) {\n return []\n }\n\n return Object.values(this.orgIdToOrgMemberInfo)\n }\n\n public isImpersonating(): boolean {\n return !!this.impersonatorUserId\n }\n\n public static fromJSON(json: string): UserFromToken {\n const obj = JSON.parse(json)\n const orgIdToOrgMemberInfo: OrgIdToOrgMemberInfo = {}\n for (const orgId in obj.orgIdToOrgMemberInfo) {\n orgIdToOrgMemberInfo[orgId] = OrgMemberInfo.fromJSON(\n JSON.stringify(obj.orgIdToOrgMemberInfo[orgId])\n )\n }\n return new UserFromToken(\n obj.userId,\n obj.email,\n orgIdToOrgMemberInfo,\n obj.firstName,\n obj.lastName,\n obj.username,\n obj.legacyUserId,\n obj.impersonatorUserId\n )\n }\n}\n\nexport type OrgIdToOrgMemberInfo = {\n [orgId: string]: OrgMemberInfo\n}\n\nexport class OrgMemberInfo {\n public orgId: string\n public orgName: string\n public orgMetadata: { [key: string]: any }\n public urlSafeOrgName: string\n\n private userAssignedRole: string\n private userInheritedRolesPlusCurrentRole: string[]\n private userPermissions: string[]\n\n constructor(\n orgId: string,\n orgName: string,\n orgMetadata: { [key: string]: any },\n urlSafeOrgName: string,\n userAssignedRole: string,\n userInheritedRolesPlusCurrentRole: string[],\n userPermissions: string[]\n ) {\n this.orgId = orgId\n this.orgName = orgName\n this.orgMetadata = orgMetadata\n this.urlSafeOrgName = urlSafeOrgName\n\n this.userAssignedRole = userAssignedRole\n this.userInheritedRolesPlusCurrentRole = userInheritedRolesPlusCurrentRole\n this.userPermissions = userPermissions\n }\n\n // validation methods\n\n public isRole(role: string): boolean {\n return this.userAssignedRole === role\n }\n\n public isAtLeastRole(role: string): boolean {\n return this.userInheritedRolesPlusCurrentRole.includes(role)\n }\n\n public hasPermission(permission: string): boolean {\n return this.userPermissions.includes(permission)\n }\n\n public hasAllPermissions(permissions: string[]): boolean {\n return permissions.every((permission) => this.hasPermission(permission))\n }\n\n public static fromJSON(json: string): OrgMemberInfo {\n const obj = JSON.parse(json)\n return new OrgMemberInfo(\n obj.orgId,\n obj.orgName,\n obj.orgMetadata,\n obj.urlSafeOrgName,\n obj.userAssignedRole,\n obj.userInheritedRolesPlusCurrentRole,\n obj.userPermissions\n )\n }\n\n // getters for the private fields\n\n get assignedRole(): string {\n return this.userAssignedRole\n }\n\n get inheritedRolesPlusCurrentRole(): string[] {\n return this.userInheritedRolesPlusCurrentRole\n }\n\n get permissions(): string[] {\n return this.userPermissions\n }\n}\n\n// These Internal types exist since the server returns snake case, but typescript/javascript\n// convention is camelCase.\nexport type InternalOrgMemberInfo = {\n org_id: string\n org_name: string\n org_metadata: { [key: string]: any }\n url_safe_org_name: string\n user_role: string\n inherited_user_roles_plus_current_role: string[]\n user_permissions: string[]\n}\nexport type InternalUser = {\n user_id: string\n org_id_to_org_member_info?: { [org_id: string]: InternalOrgMemberInfo }\n\n email: string\n first_name?: string\n last_name?: string\n username?: string\n\n // If you used our migration APIs to migrate this user from a different system, this is their original ID from that system.\n legacy_user_id?: string\n impersonatorUserId?: string\n}\n\nexport function toUser(snake_case: InternalUser): UserFromToken {\n return new UserFromToken(\n snake_case.user_id,\n snake_case.email,\n toOrgIdToOrgMemberInfo(snake_case.org_id_to_org_member_info),\n snake_case.first_name,\n snake_case.last_name,\n snake_case.username,\n snake_case.legacy_user_id,\n snake_case.impersonatorUserId\n )\n}\n\nexport function toOrgIdToOrgMemberInfo(snake_case?: {\n [org_id: string]: InternalOrgMemberInfo\n}): OrgIdToOrgMemberInfo | undefined {\n if (snake_case === undefined) {\n return undefined\n }\n const camelCase: OrgIdToOrgMemberInfo = {}\n\n for (const key of Object.keys(snake_case)) {\n const snakeCaseValue = snake_case[key]\n if (snakeCaseValue) {\n camelCase[key] = new OrgMemberInfo(\n snakeCaseValue.org_id,\n snakeCaseValue.org_name,\n snakeCaseValue.org_metadata,\n snakeCaseValue.url_safe_org_name,\n snakeCaseValue.user_role,\n snakeCaseValue.inherited_user_roles_plus_current_role,\n snakeCaseValue.user_permissions\n )\n }\n }\n\n return camelCase\n}\n","'use client'\n\nimport React, {useCallback, useEffect, useReducer} from \"react\"\nimport {doesLocalStorageMatch, hasWindow, isEqual, saveUserToLocalStorage, USER_INFO_KEY} from \"./utils\";\nimport {useRouter} from \"next/navigation\";\nimport {User} from \"./useUser\";\nimport {toOrgIdToOrgMemberInfo} from \"../user\";\n\ninterface InternalAuthState {\n loading: boolean\n userAndAccessToken: UserAndAccessToken\n\n logout: () => Promise<void>\n\n redirectToLoginPage: () => void\n redirectToSignupPage: () => void\n redirectToAccountPage: () => void\n redirectToOrgPage: (orgId?: string) => void\n redirectToCreateOrgPage: () => void\n redirectToSetupSAMLPage: (orgId: string) => void\n\n getSignupPageUrl(): string\n\n getLoginPageUrl(): string\n\n getAccountPageUrl(): string\n\n getOrgPageUrl(orgId?: string): string\n\n getCreateOrgPageUrl(): string\n\n getSetupSAMLPageUrl(orgId: string): string\n\n refreshAuthInfo: () => Promise<User | undefined>\n}\n\nexport type AuthProviderProps = {\n authUrl: string\n children?: React.ReactNode\n}\n\nexport const AuthContext = React.createContext<InternalAuthState | undefined>(undefined)\n\ntype UserAndAccessToken = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\ntype AuthState = {\n loading: boolean\n userAndAccessToken: UserAndAccessToken\n\n // There's no good way to trigger server components to reload outside of router.refresh()\n // This is our workaround until the app router has something better\n authChangeDetected: boolean\n}\n\nconst initialAuthState = {\n loading: true,\n userAndAccessToken: {\n user: undefined,\n accessToken: undefined,\n },\n authChangeDetected: false,\n}\n\ntype AuthStateAction = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\nfunction authStateReducer(_state: AuthState, action: AuthStateAction): AuthState {\n const authChangeDetected = !_state.loading && !isEqual(action.user, _state.userAndAccessToken.user)\n\n if (!action.user) {\n return {\n loading: false,\n userAndAccessToken: {\n user: undefined,\n accessToken: undefined,\n },\n authChangeDetected,\n }\n } else if (_state.loading) {\n return {\n loading: false,\n userAndAccessToken: {\n user: action.user,\n accessToken: action.accessToken,\n },\n authChangeDetected,\n }\n } else {\n return {\n loading: false,\n userAndAccessToken: {\n user: action.user,\n accessToken: action.accessToken,\n },\n authChangeDetected\n }\n }\n}\n\nexport const AuthProvider = (props: AuthProviderProps) => {\n const [authState, dispatchInner] = useReducer(authStateReducer, initialAuthState)\n const router = useRouter()\n\n const dispatch = useCallback((action: AuthStateAction) => {\n dispatchInner(action)\n saveUserToLocalStorage(action.user)\n }, [dispatchInner])\n\n // This is because we don't have a good way to trigger server components to reload outside of router.refresh()\n // Once server actions isn't alpha, we can hopefully use that instead\n useEffect(() => {\n if (authState.authChangeDetected) {\n router.refresh()\n }\n }, [authState.authChangeDetected, router])\n\n // Trigger an initial refresh\n useEffect(() => {\n let didCancel = false\n\n async function refreshAuthInfo() {\n const action = await apiGetUserInfo()\n if (!didCancel) {\n dispatch(action)\n }\n }\n\n refreshAuthInfo()\n return () => {\n didCancel = true\n }\n }, [])\n\n\n // Periodically refresh the token\n useEffect(() => {\n let didCancel = false\n\n async function refreshToken() {\n const action = await apiGetUserInfo()\n if (!didCancel) {\n dispatch(action)\n }\n }\n\n async function onStorageEvent(event: StorageEvent) {\n if (event.key === USER_INFO_KEY && !doesLocalStorageMatch(event.newValue, authState.userAndAccessToken.user)) {\n await refreshToken()\n }\n }\n\n // TODO: Retry logic if the request fails\n const interval = setInterval(refreshToken, 5 * 60 * 1000)\n\n if (hasWindow()) {\n window.addEventListener(\"storage\", onStorageEvent)\n window.addEventListener(\"online\", refreshToken)\n window.addEventListener(\"focus\", refreshToken)\n }\n\n return () => {\n didCancel = true\n clearInterval(interval)\n if (hasWindow()) {\n window.removeEventListener(\"storage\", onStorageEvent)\n window.removeEventListener(\"online\", refreshToken)\n window.removeEventListener(\"focus\", refreshToken)\n }\n }\n }, [dispatch, authState.userAndAccessToken.user])\n\n\n const logout = useCallback(async () => {\n await fetch(\"/api/auth/logout\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n credentials: \"include\",\n })\n dispatch({user: undefined, accessToken: undefined})\n }, [dispatch])\n\n const getLoginPageUrl = () => \"/api/auth/login\"\n const getSignupPageUrl = () => \"/api/auth/signup\"\n const getAccountPageUrl = useCallback(() => {\n return `${props.authUrl}/account`\n }, [props.authUrl])\n const getOrgPageUrl = useCallback(\n (orgId?: string) => {\n if (orgId) {\n return `${props.authUrl}/org?id=${orgId}`\n } else {\n return `${props.authUrl}/org`\n }\n },\n [props.authUrl]\n )\n const getCreateOrgPageUrl = useCallback(() => {\n return `${props.authUrl}/create_org`\n }, [props.authUrl])\n\n const getSetupSAMLPageUrl = useCallback(\n (orgId: string) => {\n return `${props.authUrl}/saml?id=${orgId}`\n },\n [props.authUrl]\n )\n\n const redirectTo = (url: string) => {\n window.location.href = url\n }\n\n const redirectToLoginPage = () => redirectTo(getLoginPageUrl())\n const redirectToSignupPage = () => redirectTo(getSignupPageUrl())\n const redirectToAccountPage = () => redirectTo(getAccountPageUrl())\n const redirectToOrgPage = (orgId?: string) => redirectTo(getOrgPageUrl(orgId))\n const redirectToCreateOrgPage = () => redirectTo(getCreateOrgPageUrl())\n const redirectToSetupSAMLPage = (orgId: string) => redirectTo(getSetupSAMLPageUrl(orgId))\n\n const refreshAuthInfo = async () => {\n const action = await apiGetUserInfo()\n dispatch(action)\n return action.user\n }\n\n const value = {\n loading: authState.loading,\n userAndAccessToken: authState.userAndAccessToken,\n logout,\n redirectToLoginPage,\n redirectToSignupPage,\n redirectToAccountPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n redirectToSetupSAMLPage,\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n refreshAuthInfo,\n }\n return <AuthContext.Provider value={value}>{props.children}</AuthContext.Provider>\n}\n\ntype UserInfoResponse = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\nasync function apiGetUserInfo(): Promise<UserInfoResponse> {\n try {\n const userInfoResponse = await fetch(\"/api/auth/userinfo\", {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n credentials: \"include\",\n })\n\n if (userInfoResponse.ok) {\n const {userinfo, accessToken, impersonatorUserId} = await userInfoResponse.json()\n const user = new User({\n userId: userinfo.user_id,\n email: userinfo.email,\n emailConfirmed: userinfo.email_confirmed,\n hasPassword: userinfo.has_password,\n username: userinfo.username,\n firstName: userinfo.first_name,\n lastName: userinfo.last_name,\n pictureUrl: userinfo.picture_url,\n orgIdToOrgMemberInfo: toOrgIdToOrgMemberInfo(userinfo.org_id_to_org_info),\n mfaEnabled: userinfo.mfa_enabled,\n canCreateOrgs: userinfo.can_create_orgs,\n updatePasswordRequired: userinfo.update_password_required,\n createdAt: userinfo.created_at,\n lastActiveAt: userinfo.last_active_at,\n impersonatorUserId,\n })\n\n return {user, accessToken}\n } else if (userInfoResponse.status === 401) {\n return {user: undefined, accessToken: undefined}\n } else {\n console.log(\"Failed to refresh token\", userInfoResponse)\n }\n } catch (e) {\n console.log(\"Failed to refresh token\", e)\n }\n throw new Error(\"Failed to refresh token\")\n}\n","import {UserFromToken} from \"../user\";\nimport {User} from \"./useUser\";\n\nexport const USER_INFO_KEY = \"__PROPEL_AUTH_USER_INFO\"\n\nexport function hasWindow(): boolean {\n return typeof window !== \"undefined\"\n}\n\nexport function saveUserToLocalStorage(user: User | undefined) {\n if (user) {\n localStorage.setItem(USER_INFO_KEY, JSON.stringify(user))\n } else {\n localStorage.setItem(USER_INFO_KEY, \"{}\")\n }\n}\n\nexport function doesLocalStorageMatch(newValue: string | null, user: UserFromToken | undefined): boolean {\n if (!newValue) {\n return false\n } else if (!user) {\n return newValue === \"{}\"\n }\n\n const parsed = JSON.parse(newValue)\n if (!parsed) {\n return false\n }\n\n return isEqual(parsed, user)\n}\n\n\nexport function isEqual(a: any, b: any): boolean {\n if (typeof a !== typeof b) {\n return false\n }\n\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false\n }\n\n if (Array.isArray(a)) {\n const aArray = a as any[]\n const bArray = b as any[]\n if (aArray.length !== bArray.length) {\n return false\n }\n\n for (let i = 0; i < aArray.length; i++) {\n if (!isEqual(aArray[i], bArray[i])) {\n return false\n }\n }\n\n return true\n }\n\n if (typeof a === \"object\") {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length) {\n return false\n }\n\n for (const key of aKeys) {\n if (!isEqual(a[key], b[key])) {\n return false\n }\n }\n\n return true\n } else {\n return a === b\n }\n}","'use client'\n\nimport {useContext} from \"react\"\nimport {AuthContext} from \"./AuthProvider\"\nimport {OrgIdToOrgMemberInfo, OrgMemberInfo} from \"../user\";\n\nexport class User {\n public userId: string\n public email: string\n public emailConfirmed: boolean\n public hasPassword: boolean\n\n public username?: string\n public firstName?: string\n public lastName?: string\n public pictureUrl?: string\n\n public orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n\n public mfaEnabled: boolean\n public canCreateOrgs: boolean\n public updatePasswordRequired: boolean\n\n public createdAt: number\n public lastActiveAt: number\n\n public legacyUserId?: string\n public impersonatorUserId?: string\n\n constructor({\n userId,\n email,\n emailConfirmed,\n hasPassword,\n username,\n firstName,\n lastName,\n pictureUrl,\n orgIdToOrgMemberInfo,\n mfaEnabled,\n canCreateOrgs,\n updatePasswordRequired,\n createdAt,\n lastActiveAt,\n legacyUserId,\n impersonatorUserId,\n }: {\n userId: string\n email: string\n emailConfirmed: boolean\n hasPassword: boolean\n username?: string\n firstName?: string\n lastName?: string\n pictureUrl?: string\n orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n mfaEnabled: boolean\n canCreateOrgs: boolean\n updatePasswordRequired: boolean\n createdAt: number\n lastActiveAt: number\n legacyUserId?: string\n impersonatorUserId?: string\n }) {\n this.userId = userId\n this.email = email\n this.emailConfirmed = emailConfirmed\n this.hasPassword = hasPassword\n this.username = username\n this.firstName = firstName\n this.lastName = lastName\n this.pictureUrl = pictureUrl\n this.orgIdToOrgMemberInfo = orgIdToOrgMemberInfo\n this.mfaEnabled = mfaEnabled\n this.canCreateOrgs = canCreateOrgs\n this.updatePasswordRequired = updatePasswordRequired\n this.createdAt = createdAt\n this.lastActiveAt = lastActiveAt\n this.legacyUserId = legacyUserId\n this.impersonatorUserId = impersonatorUserId\n }\n\n public getOrg(orgId: string): OrgMemberInfo | undefined {\n return this.orgIdToOrgMemberInfo?.[orgId]\n }\n\n public getOrgByName(orgName: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n const urlSafeOrgName = orgName.toLowerCase().replace(/ /g, \"-\")\n for (const orgId in this.orgIdToOrgMemberInfo) {\n const orgMemberInfo = this.orgIdToOrgMemberInfo[orgId]\n if (orgMemberInfo.urlSafeOrgName === urlSafeOrgName) {\n return orgMemberInfo\n }\n }\n\n return undefined\n }\n\n public getOrgs(): OrgMemberInfo[] {\n if (!this.orgIdToOrgMemberInfo) {\n return []\n }\n\n return Object.values(this.orgIdToOrgMemberInfo)\n }\n\n public isImpersonating(): boolean {\n return !!this.impersonatorUserId\n }\n}\n\nexport type UseUserLoading = {\n loading: true\n isLoggedIn: never\n user: never\n accessToken: never\n}\n\nexport type UseUserLoggedIn = {\n loading: false\n isLoggedIn: true\n user: User\n accessToken: string\n}\n\nexport type UseUserNotLoggedIn = {\n loading: false\n isLoggedIn: false\n user: undefined\n accessToken: undefined\n}\n\nexport type UseUser = UseUserLoading | UseUserLoggedIn | UseUserNotLoggedIn\n\nexport function useUser(): UseUser {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useUser must be used within an AuthProvider\")\n }\n\n const {loading, userAndAccessToken} = context\n if (loading) {\n return {\n loading: true,\n isLoggedIn: undefined as never,\n user: undefined as never,\n accessToken: undefined as never,\n }\n } else if (userAndAccessToken.user) {\n return {\n loading: false,\n isLoggedIn: true,\n user: userAndAccessToken.user,\n accessToken: userAndAccessToken.accessToken,\n }\n } else {\n return {\n loading: false,\n isLoggedIn: false,\n user: undefined,\n accessToken: undefined,\n }\n }\n}","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useHostedPageUrls() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useHostedPageUrls must be used within an AuthProvider\")\n }\n const {\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n } = context\n return {\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n }\n}\n","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useLogoutFunction() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useLogoutFunction must be used within an AuthProvider\")\n }\n const { logout } = context\n return logout\n}\n","import React, { useContext, useEffect } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useRedirectFunctions() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useRedirectFunctions must be used within an AuthProvider\")\n }\n const {\n redirectToAccountPage,\n redirectToSignupPage,\n redirectToLoginPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n } = context\n return {\n redirectToSignupPage,\n redirectToLoginPage,\n redirectToAccountPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n }\n}\n\nexport interface RedirectProps {\n children?: React.ReactNode\n}\n\nexport function RedirectToSignup({ children }: RedirectProps) {\n const { redirectToSignupPage } = useRedirectFunctions()\n\n useEffect(() => {\n redirectToSignupPage()\n }, [])\n\n return <>{children}</>\n}\n\nexport function RedirectToLogin({ children }: RedirectProps) {\n const { redirectToLoginPage } = useRedirectFunctions()\n useEffect(() => {\n redirectToLoginPage()\n }, [])\n return <>{children}</>\n}\n","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useRefreshAuth() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useRefreshAuth must be used within an AuthProvider\")\n }\n const { refreshAuthInfo } = context\n return refreshAuthInfo\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAN,MAAoB;AAAA,EAevB,YACI,QACA,OACA,sBACA,WACA,UACA,UACA,cACA,oBACF;AACE,SAAK,SAAS;AACd,SAAK,uBAAuB;AAE5B,SAAK,QAAQ;AACb,SAAK,YAAY;AACjB,SAAK,WAAW;AAChB,SAAK,WAAW;AAEhB,SAAK,eAAe;AACpB,SAAK,qBAAqB;AAAA,EAC9B;AAAA,EAEO,OAAO,OAA0C;AACpD,QAAI,CAAC,KAAK,sBAAsB;AAC5B,aAAO;AAAA,IACX;AAEA,WAAO,KAAK,qBAAqB,KAAK;AAAA,EAC1C;AAA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I,qBAAqB;AAEtD,+BAAU,MAAM;AACZ,yBAAqB;AAAA,EACzB,GAAG,CAAC,CAAC;AAEL,SAAO,8BAAAC,QAAA,4BAAAA,QAAA,gBAAG,QAAS;AACvB;AAEO,SAAS,gBAAgB,EAAE,SAAS,GAAkB;AACzD,QAAM,EAAE,oBAAoB,IAAI,qBAAqB;AACrD,+BAAU,MAAM;AACZ,wBAAoB;AAAA,EACxB,GAAG,CAAC,CAAC;AACL,SAAO,8BAAAA,QAAA,4BAAAA,QAAA,gBAAG,QAAS;AACvB;;;AC5CA,IAAAC,gBAA2B;AAGpB,SAAS,iBAAiB;AAC7B,QAAM,cAAU,0BAAW,WAAW;AACtC,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACxE;AACA,QAAM,EAAE,gBAAgB,IAAI;AAC5B,SAAO;AACX;","names":["import_react","React","refreshAuthInfo","import_react","import_react","import_react","React","import_react"]}
|
1
|
+
{"version":3,"sources":["../../src/client/index.ts","../../src/user.ts","../../src/client/AuthProvider.tsx","../../src/client/utils.ts","../../src/client/useUser.tsx","../../src/client/useHostedPageUrls.tsx","../../src/client/useLogoutFunction.ts","../../src/client/useRedirectFunctions.tsx","../../src/client/useRefreshAuth.ts"],"sourcesContent":["export type {OrgIdToOrgMemberInfo} from \"../user\"\nexport {UserFromToken, OrgMemberInfo} from \"../user\"\nexport {AuthProvider} from \"./AuthProvider\"\nexport type {AuthProviderProps} from \"./AuthProvider\"\nexport {useUser, User} from \"./useUser\"\nexport type {UseUser, UseUserLoading, UseUserLoggedIn, UseUserNotLoggedIn} from \"./useUser\"\nexport {useHostedPageUrls} from \"./useHostedPageUrls\"\nexport {useLogoutFunction} from \"./useLogoutFunction\"\nexport {useRedirectFunctions, RedirectToLogin, RedirectToSignup} from \"./useRedirectFunctions\"\nexport type {RedirectProps} from \"./useRedirectFunctions\"\nexport {useRefreshAuth} from \"./useRefreshAuth\"","export class UserFromToken {\n public userId: string\n public orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n\n // Metadata about the user\n public email: string\n public firstName?: string\n public lastName?: string\n public username?: string\n\n // If you used our migration APIs to migrate this user from a different system,\n // this is their original ID from that system.\n public legacyUserId?: string\n public impersonatorUserId?: string\n\n constructor(\n userId: string,\n email: string,\n orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo,\n firstName?: string,\n lastName?: string,\n username?: string,\n legacyUserId?: string,\n impersonatorUserId?: string\n ) {\n this.userId = userId\n this.orgIdToOrgMemberInfo = orgIdToOrgMemberInfo\n\n this.email = email\n this.firstName = firstName\n this.lastName = lastName\n this.username = username\n\n this.legacyUserId = legacyUserId\n this.impersonatorUserId = impersonatorUserId\n }\n\n public getOrg(orgId: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n return this.orgIdToOrgMemberInfo[orgId]\n }\n\n public getOrgByName(orgName: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n const urlSafeOrgName = orgName.toLowerCase().replace(/ /g, \"-\")\n for (const orgId in this.orgIdToOrgMemberInfo) {\n const orgMemberInfo = this.orgIdToOrgMemberInfo[orgId]\n if (orgMemberInfo.urlSafeOrgName === urlSafeOrgName) {\n return orgMemberInfo\n }\n }\n\n return undefined\n }\n\n public getOrgs(): OrgMemberInfo[] {\n if (!this.orgIdToOrgMemberInfo) {\n return []\n }\n\n return Object.values(this.orgIdToOrgMemberInfo)\n }\n\n public isImpersonating(): boolean {\n return !!this.impersonatorUserId\n }\n\n public static fromJSON(json: string): UserFromToken {\n const obj = JSON.parse(json)\n const orgIdToOrgMemberInfo: OrgIdToOrgMemberInfo = {}\n for (const orgId in obj.orgIdToOrgMemberInfo) {\n orgIdToOrgMemberInfo[orgId] = OrgMemberInfo.fromJSON(\n JSON.stringify(obj.orgIdToOrgMemberInfo[orgId])\n )\n }\n return new UserFromToken(\n obj.userId,\n obj.email,\n orgIdToOrgMemberInfo,\n obj.firstName,\n obj.lastName,\n obj.username,\n obj.legacyUserId,\n obj.impersonatorUserId\n )\n }\n}\n\nexport type OrgIdToOrgMemberInfo = {\n [orgId: string]: OrgMemberInfo\n}\n\nexport class OrgMemberInfo {\n public orgId: string\n public orgName: string\n public orgMetadata: { [key: string]: any }\n public urlSafeOrgName: string\n\n private userAssignedRole: string\n private userInheritedRolesPlusCurrentRole: string[]\n private userPermissions: string[]\n\n constructor(\n orgId: string,\n orgName: string,\n orgMetadata: { [key: string]: any },\n urlSafeOrgName: string,\n userAssignedRole: string,\n userInheritedRolesPlusCurrentRole: string[],\n userPermissions: string[]\n ) {\n this.orgId = orgId\n this.orgName = orgName\n this.orgMetadata = orgMetadata\n this.urlSafeOrgName = urlSafeOrgName\n\n this.userAssignedRole = userAssignedRole\n this.userInheritedRolesPlusCurrentRole = userInheritedRolesPlusCurrentRole\n this.userPermissions = userPermissions\n }\n\n // validation methods\n\n public isRole(role: string): boolean {\n return this.userAssignedRole === role\n }\n\n public isAtLeastRole(role: string): boolean {\n return this.userInheritedRolesPlusCurrentRole.includes(role)\n }\n\n public hasPermission(permission: string): boolean {\n return this.userPermissions.includes(permission)\n }\n\n public hasAllPermissions(permissions: string[]): boolean {\n return permissions.every((permission) => this.hasPermission(permission))\n }\n\n public static fromJSON(json: string): OrgMemberInfo {\n const obj = JSON.parse(json)\n return new OrgMemberInfo(\n obj.orgId,\n obj.orgName,\n obj.orgMetadata,\n obj.urlSafeOrgName,\n obj.userAssignedRole,\n obj.userInheritedRolesPlusCurrentRole,\n obj.userPermissions\n )\n }\n\n // getters for the private fields\n\n get assignedRole(): string {\n return this.userAssignedRole\n }\n\n get inheritedRolesPlusCurrentRole(): string[] {\n return this.userInheritedRolesPlusCurrentRole\n }\n\n get permissions(): string[] {\n return this.userPermissions\n }\n}\n\n// These Internal types exist since the server returns snake case, but typescript/javascript\n// convention is camelCase.\nexport type InternalOrgMemberInfo = {\n org_id: string\n org_name: string\n org_metadata: { [key: string]: any }\n url_safe_org_name: string\n user_role: string\n inherited_user_roles_plus_current_role: string[]\n user_permissions: string[]\n}\nexport type InternalUser = {\n user_id: string\n org_id_to_org_member_info?: { [org_id: string]: InternalOrgMemberInfo }\n\n email: string\n first_name?: string\n last_name?: string\n username?: string\n\n // If you used our migration APIs to migrate this user from a different system, this is their original ID from that system.\n legacy_user_id?: string\n impersonatorUserId?: string\n}\n\nexport function toUser(snake_case: InternalUser): UserFromToken {\n return new UserFromToken(\n snake_case.user_id,\n snake_case.email,\n toOrgIdToOrgMemberInfo(snake_case.org_id_to_org_member_info),\n snake_case.first_name,\n snake_case.last_name,\n snake_case.username,\n snake_case.legacy_user_id,\n snake_case.impersonatorUserId\n )\n}\n\nexport function toOrgIdToOrgMemberInfo(snake_case?: {\n [org_id: string]: InternalOrgMemberInfo\n}): OrgIdToOrgMemberInfo | undefined {\n if (snake_case === undefined) {\n return undefined\n }\n const camelCase: OrgIdToOrgMemberInfo = {}\n\n for (const key of Object.keys(snake_case)) {\n const snakeCaseValue = snake_case[key]\n if (snakeCaseValue) {\n camelCase[key] = new OrgMemberInfo(\n snakeCaseValue.org_id,\n snakeCaseValue.org_name,\n snakeCaseValue.org_metadata,\n snakeCaseValue.url_safe_org_name,\n snakeCaseValue.user_role,\n snakeCaseValue.inherited_user_roles_plus_current_role,\n snakeCaseValue.user_permissions\n )\n }\n }\n\n return camelCase\n}\n","'use client'\n\nimport React, {useCallback, useEffect, useReducer} from \"react\"\nimport {doesLocalStorageMatch, hasWindow, isEqual, saveUserToLocalStorage, USER_INFO_KEY} from \"./utils\";\nimport {useRouter} from \"next/navigation\";\nimport {User} from \"./useUser\";\nimport {toOrgIdToOrgMemberInfo} from \"../user\";\n\ninterface InternalAuthState {\n loading: boolean\n userAndAccessToken: UserAndAccessToken\n\n logout: () => Promise<void>\n\n redirectToLoginPage: () => void\n redirectToSignupPage: () => void\n redirectToAccountPage: () => void\n redirectToOrgPage: (orgId?: string) => void\n redirectToCreateOrgPage: () => void\n redirectToSetupSAMLPage: (orgId: string) => void\n\n getSignupPageUrl(): string\n\n getLoginPageUrl(): string\n\n getAccountPageUrl(): string\n\n getOrgPageUrl(orgId?: string): string\n\n getCreateOrgPageUrl(): string\n\n getSetupSAMLPageUrl(orgId: string): string\n\n refreshAuthInfo: () => Promise<User | undefined>\n}\n\nexport type AuthProviderProps = {\n authUrl: string\n children?: React.ReactNode\n}\n\nexport const AuthContext = React.createContext<InternalAuthState | undefined>(undefined)\n\ntype UserAndAccessToken = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\ntype AuthState = {\n loading: boolean\n userAndAccessToken: UserAndAccessToken\n\n // There's no good way to trigger server components to reload outside of router.refresh()\n // This is our workaround until the app router has something better\n authChangeDetected: boolean\n}\n\nconst initialAuthState = {\n loading: true,\n userAndAccessToken: {\n user: undefined,\n accessToken: undefined,\n },\n authChangeDetected: false,\n}\n\ntype AuthStateAction = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\nfunction authStateReducer(_state: AuthState, action: AuthStateAction): AuthState {\n const authChangeDetected = !_state.loading && !isEqual(action.user, _state.userAndAccessToken.user)\n console.log(\"dispatching auth state reducer\", {action, _state, authChangeDetected})\n\n if (!action.user) {\n return {\n loading: false,\n userAndAccessToken: {\n user: undefined,\n accessToken: undefined,\n },\n authChangeDetected,\n }\n } else if (_state.loading) {\n return {\n loading: false,\n userAndAccessToken: {\n user: action.user,\n accessToken: action.accessToken,\n },\n authChangeDetected,\n }\n } else {\n return {\n loading: false,\n userAndAccessToken: {\n user: action.user,\n accessToken: action.accessToken,\n },\n authChangeDetected\n }\n }\n}\n\nexport const AuthProvider = (props: AuthProviderProps) => {\n const [authState, dispatchInner] = useReducer(authStateReducer, initialAuthState)\n const router = useRouter()\n\n const dispatch = useCallback((action: AuthStateAction) => {\n dispatchInner(action)\n saveUserToLocalStorage(action.user)\n }, [dispatchInner])\n\n // This is because we don't have a good way to trigger server components to reload outside of router.refresh()\n // Once server actions isn't alpha, we can hopefully use that instead\n useEffect(() => {\n if (authState.authChangeDetected) {\n router.refresh()\n }\n }, [authState.authChangeDetected, router])\n\n // Trigger an initial refresh\n useEffect(() => {\n let didCancel = false\n\n async function refreshAuthInfo() {\n const action = await apiGetUserInfo()\n if (!didCancel) {\n dispatch(action)\n }\n }\n\n refreshAuthInfo()\n return () => {\n didCancel = true\n }\n }, [])\n\n\n // Periodically refresh the token\n useEffect(() => {\n let didCancel = false\n\n async function refreshToken() {\n const action = await apiGetUserInfo()\n if (!didCancel) {\n dispatch(action)\n }\n }\n\n async function onStorageEvent(event: StorageEvent) {\n if (event.key === USER_INFO_KEY && !doesLocalStorageMatch(event.newValue, authState.userAndAccessToken.user)) {\n await refreshToken()\n }\n }\n\n // TODO: Retry logic if the request fails\n const interval = setInterval(refreshToken, 5 * 60 * 1000)\n\n if (hasWindow()) {\n window.addEventListener(\"storage\", onStorageEvent)\n window.addEventListener(\"online\", refreshToken)\n window.addEventListener(\"focus\", refreshToken)\n }\n\n return () => {\n didCancel = true\n clearInterval(interval)\n if (hasWindow()) {\n window.removeEventListener(\"storage\", onStorageEvent)\n window.removeEventListener(\"online\", refreshToken)\n window.removeEventListener(\"focus\", refreshToken)\n }\n }\n }, [dispatch, authState.userAndAccessToken.user])\n\n\n const logout = useCallback(async () => {\n await fetch(\"/api/auth/logout\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n credentials: \"include\",\n })\n dispatch({user: undefined, accessToken: undefined})\n }, [dispatch])\n\n const getLoginPageUrl = () => \"/api/auth/login\"\n const getSignupPageUrl = () => \"/api/auth/signup\"\n const getAccountPageUrl = useCallback(() => {\n return `${props.authUrl}/account`\n }, [props.authUrl])\n const getOrgPageUrl = useCallback(\n (orgId?: string) => {\n if (orgId) {\n return `${props.authUrl}/org?id=${orgId}`\n } else {\n return `${props.authUrl}/org`\n }\n },\n [props.authUrl]\n )\n const getCreateOrgPageUrl = useCallback(() => {\n return `${props.authUrl}/create_org`\n }, [props.authUrl])\n\n const getSetupSAMLPageUrl = useCallback(\n (orgId: string) => {\n return `${props.authUrl}/saml?id=${orgId}`\n },\n [props.authUrl]\n )\n\n const redirectTo = (url: string) => {\n window.location.href = url\n }\n\n const redirectToLoginPage = () => redirectTo(getLoginPageUrl())\n const redirectToSignupPage = () => redirectTo(getSignupPageUrl())\n const redirectToAccountPage = () => redirectTo(getAccountPageUrl())\n const redirectToOrgPage = (orgId?: string) => redirectTo(getOrgPageUrl(orgId))\n const redirectToCreateOrgPage = () => redirectTo(getCreateOrgPageUrl())\n const redirectToSetupSAMLPage = (orgId: string) => redirectTo(getSetupSAMLPageUrl(orgId))\n\n const refreshAuthInfo = async () => {\n const action = await apiGetUserInfo()\n dispatch(action)\n return action.user\n }\n\n const value = {\n loading: authState.loading,\n userAndAccessToken: authState.userAndAccessToken,\n logout,\n redirectToLoginPage,\n redirectToSignupPage,\n redirectToAccountPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n redirectToSetupSAMLPage,\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n refreshAuthInfo,\n }\n return <AuthContext.Provider value={value}>{props.children}</AuthContext.Provider>\n}\n\ntype UserInfoResponse = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\nasync function apiGetUserInfo(): Promise<UserInfoResponse> {\n try {\n const userInfoResponse = await fetch(\"/api/auth/userinfo\", {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n credentials: \"include\",\n })\n\n if (userInfoResponse.ok) {\n const {userinfo, accessToken, impersonatorUserId} = await userInfoResponse.json()\n const user = new User({\n userId: userinfo.user_id,\n email: userinfo.email,\n emailConfirmed: userinfo.email_confirmed,\n hasPassword: userinfo.has_password,\n username: userinfo.username,\n firstName: userinfo.first_name,\n lastName: userinfo.last_name,\n pictureUrl: userinfo.picture_url,\n orgIdToOrgMemberInfo: toOrgIdToOrgMemberInfo(userinfo.org_id_to_org_info),\n mfaEnabled: userinfo.mfa_enabled,\n canCreateOrgs: userinfo.can_create_orgs,\n updatePasswordRequired: userinfo.update_password_required,\n createdAt: userinfo.created_at,\n lastActiveAt: userinfo.last_active_at,\n impersonatorUserId,\n })\n\n return {user, accessToken}\n } else if (userInfoResponse.status === 401) {\n return {user: undefined, accessToken: undefined}\n } else {\n console.log(\"Failed to refresh token\", userInfoResponse)\n }\n } catch (e) {\n console.log(\"Failed to refresh token\", e)\n }\n throw new Error(\"Failed to refresh token\")\n}\n","import {UserFromToken} from \"../user\";\nimport {User} from \"./useUser\";\n\nexport const USER_INFO_KEY = \"__PROPEL_AUTH_USER_INFO\"\n\nexport function hasWindow(): boolean {\n return typeof window !== \"undefined\"\n}\n\nexport function saveUserToLocalStorage(user: User | undefined) {\n if (user) {\n localStorage.setItem(USER_INFO_KEY, JSON.stringify(user))\n } else {\n localStorage.setItem(USER_INFO_KEY, \"{}\")\n }\n}\n\nexport function doesLocalStorageMatch(newValue: string | null, user: UserFromToken | undefined): boolean {\n if (!newValue) {\n return false\n } else if (!user) {\n return newValue === \"{}\"\n }\n\n const parsed = JSON.parse(newValue)\n if (!parsed) {\n return false\n }\n\n return isEqual(parsed, user)\n}\n\n\nexport function isEqual(a: any, b: any): boolean {\n if (typeof a !== typeof b) {\n return false\n }\n\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false\n }\n\n if (Array.isArray(a)) {\n const aArray = a as any[]\n const bArray = b as any[]\n if (aArray.length !== bArray.length) {\n return false\n }\n\n for (let i = 0; i < aArray.length; i++) {\n if (!isEqual(aArray[i], bArray[i])) {\n return false\n }\n }\n\n return true\n }\n\n if (typeof a === \"object\") {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length) {\n return false\n }\n\n for (const key of aKeys) {\n if (!isEqual(a[key], b[key])) {\n return false\n }\n }\n\n return true\n } else {\n return a === b\n }\n}","'use client'\n\nimport {useContext} from \"react\"\nimport {AuthContext} from \"./AuthProvider\"\nimport {OrgIdToOrgMemberInfo, OrgMemberInfo} from \"../user\";\n\nexport class User {\n public userId: string\n public email: string\n public emailConfirmed: boolean\n public hasPassword: boolean\n\n public username?: string\n public firstName?: string\n public lastName?: string\n public pictureUrl?: string\n\n public orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n\n public mfaEnabled: boolean\n public canCreateOrgs: boolean\n public updatePasswordRequired: boolean\n\n public createdAt: number\n public lastActiveAt: number\n\n public legacyUserId?: string\n public impersonatorUserId?: string\n\n constructor({\n userId,\n email,\n emailConfirmed,\n hasPassword,\n username,\n firstName,\n lastName,\n pictureUrl,\n orgIdToOrgMemberInfo,\n mfaEnabled,\n canCreateOrgs,\n updatePasswordRequired,\n createdAt,\n lastActiveAt,\n legacyUserId,\n impersonatorUserId,\n }: {\n userId: string\n email: string\n emailConfirmed: boolean\n hasPassword: boolean\n username?: string\n firstName?: string\n lastName?: string\n pictureUrl?: string\n orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n mfaEnabled: boolean\n canCreateOrgs: boolean\n updatePasswordRequired: boolean\n createdAt: number\n lastActiveAt: number\n legacyUserId?: string\n impersonatorUserId?: string\n }) {\n this.userId = userId\n this.email = email\n this.emailConfirmed = emailConfirmed\n this.hasPassword = hasPassword\n this.username = username\n this.firstName = firstName\n this.lastName = lastName\n this.pictureUrl = pictureUrl\n this.orgIdToOrgMemberInfo = orgIdToOrgMemberInfo\n this.mfaEnabled = mfaEnabled\n this.canCreateOrgs = canCreateOrgs\n this.updatePasswordRequired = updatePasswordRequired\n this.createdAt = createdAt\n this.lastActiveAt = lastActiveAt\n this.legacyUserId = legacyUserId\n this.impersonatorUserId = impersonatorUserId\n }\n\n public getOrg(orgId: string): OrgMemberInfo | undefined {\n return this.orgIdToOrgMemberInfo?.[orgId]\n }\n\n public getOrgByName(orgName: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n const urlSafeOrgName = orgName.toLowerCase().replace(/ /g, \"-\")\n for (const orgId in this.orgIdToOrgMemberInfo) {\n const orgMemberInfo = this.orgIdToOrgMemberInfo[orgId]\n if (orgMemberInfo.urlSafeOrgName === urlSafeOrgName) {\n return orgMemberInfo\n }\n }\n\n return undefined\n }\n\n public getOrgs(): OrgMemberInfo[] {\n if (!this.orgIdToOrgMemberInfo) {\n return []\n }\n\n return Object.values(this.orgIdToOrgMemberInfo)\n }\n\n public isImpersonating(): boolean {\n return !!this.impersonatorUserId\n }\n}\n\nexport type UseUserLoading = {\n loading: true\n isLoggedIn: never\n user: never\n accessToken: never\n}\n\nexport type UseUserLoggedIn = {\n loading: false\n isLoggedIn: true\n user: User\n accessToken: string\n}\n\nexport type UseUserNotLoggedIn = {\n loading: false\n isLoggedIn: false\n user: undefined\n accessToken: undefined\n}\n\nexport type UseUser = UseUserLoading | UseUserLoggedIn | UseUserNotLoggedIn\n\nexport function useUser(): UseUser {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useUser must be used within an AuthProvider\")\n }\n\n const {loading, userAndAccessToken} = context\n if (loading) {\n return {\n loading: true,\n isLoggedIn: undefined as never,\n user: undefined as never,\n accessToken: undefined as never,\n }\n } else if (userAndAccessToken.user) {\n return {\n loading: false,\n isLoggedIn: true,\n user: userAndAccessToken.user,\n accessToken: userAndAccessToken.accessToken,\n }\n } else {\n return {\n loading: false,\n isLoggedIn: false,\n user: undefined,\n accessToken: undefined,\n }\n }\n}","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useHostedPageUrls() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useHostedPageUrls must be used within an AuthProvider\")\n }\n const {\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n } = context\n return {\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n }\n}\n","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useLogoutFunction() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useLogoutFunction must be used within an AuthProvider\")\n }\n const { logout } = context\n return logout\n}\n","import React, { useContext, useEffect } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useRedirectFunctions() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useRedirectFunctions must be used within an AuthProvider\")\n }\n const {\n redirectToAccountPage,\n redirectToSignupPage,\n redirectToLoginPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n } = context\n return {\n redirectToSignupPage,\n redirectToLoginPage,\n redirectToAccountPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n }\n}\n\nexport interface RedirectProps {\n children?: React.ReactNode\n}\n\nexport function RedirectToSignup({ children }: RedirectProps) {\n const { redirectToSignupPage } = useRedirectFunctions()\n\n useEffect(() => {\n redirectToSignupPage()\n }, [])\n\n return <>{children}</>\n}\n\nexport function RedirectToLogin({ children }: RedirectProps) {\n const { redirectToLoginPage } = useRedirectFunctions()\n useEffect(() => {\n redirectToLoginPage()\n }, [])\n return <>{children}</>\n}\n","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useRefreshAuth() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useRefreshAuth must be used within an AuthProvider\")\n }\n const { refreshAuthInfo } = context\n return refreshAuthInfo\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gBAAN,MAAoB;AAAA,EAevB,YACI,QACA,OACA,sBACA,WACA,UACA,UACA,cACA,oBACF;AACE,SAAK,SAAS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;AACnC,QAAM,cAAU,0BAAW,WAAW;AACtC,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC9E;AACA,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AACJ,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;AAMO,SAAS,iBAAiB,EAAE,SAAS,GAAkB;AAC1D,QAAM,EAAE,qBAAqB,IAAI,qBAAqB;AAEtD,+BAAU,MAAM;AACZ,yBAAqB;AAAA,EACzB,GAAG,CAAC,CAAC;AAEL,SAAO,8BAAAC,QAAA,4BAAAA,QAAA,gBAAG,QAAS;AACvB;AAEO,SAAS,gBAAgB,EAAE,SAAS,GAAkB;AACzD,QAAM,EAAE,oBAAoB,IAAI,qBAAqB;AACrD,+BAAU,MAAM;AACZ,wBAAoB;AAAA,EACxB,GAAG,CAAC,CAAC;AACL,SAAO,8BAAAA,QAAA,4BAAAA,QAAA,gBAAG,QAAS;AACvB;;;AC5CA,IAAAC,gBAA2B;AAGpB,SAAS,iBAAiB;AAC7B,QAAM,cAAU,0BAAW,WAAW;AACtC,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACxE;AACA,QAAM,EAAE,gBAAgB,IAAI;AAC5B,SAAO;AACX;","names":["import_react","React","refreshAuthInfo","import_react","import_react","import_react","React","import_react"]}
|
package/dist/client/index.mjs
CHANGED
@@ -322,6 +322,7 @@ var initialAuthState = {
|
|
322
322
|
};
|
323
323
|
function authStateReducer(_state, action) {
|
324
324
|
const authChangeDetected = !_state.loading && !isEqual(action.user, _state.userAndAccessToken.user);
|
325
|
+
console.log("dispatching auth state reducer", { action, _state, authChangeDetected });
|
325
326
|
if (!action.user) {
|
326
327
|
return {
|
327
328
|
loading: false,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/user.ts","../../src/client/AuthProvider.tsx","../../src/client/utils.ts","../../src/client/useUser.tsx","../../src/client/useHostedPageUrls.tsx","../../src/client/useLogoutFunction.ts","../../src/client/useRedirectFunctions.tsx","../../src/client/useRefreshAuth.ts"],"sourcesContent":["export class UserFromToken {\n public userId: string\n public orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n\n // Metadata about the user\n public email: string\n public firstName?: string\n public lastName?: string\n public username?: string\n\n // If you used our migration APIs to migrate this user from a different system,\n // this is their original ID from that system.\n public legacyUserId?: string\n public impersonatorUserId?: string\n\n constructor(\n userId: string,\n email: string,\n orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo,\n firstName?: string,\n lastName?: string,\n username?: string,\n legacyUserId?: string,\n impersonatorUserId?: string\n ) {\n this.userId = userId\n this.orgIdToOrgMemberInfo = orgIdToOrgMemberInfo\n\n this.email = email\n this.firstName = firstName\n this.lastName = lastName\n this.username = username\n\n this.legacyUserId = legacyUserId\n this.impersonatorUserId = impersonatorUserId\n }\n\n public getOrg(orgId: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n return this.orgIdToOrgMemberInfo[orgId]\n }\n\n public getOrgByName(orgName: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n const urlSafeOrgName = orgName.toLowerCase().replace(/ /g, \"-\")\n for (const orgId in this.orgIdToOrgMemberInfo) {\n const orgMemberInfo = this.orgIdToOrgMemberInfo[orgId]\n if (orgMemberInfo.urlSafeOrgName === urlSafeOrgName) {\n return orgMemberInfo\n }\n }\n\n return undefined\n }\n\n public getOrgs(): OrgMemberInfo[] {\n if (!this.orgIdToOrgMemberInfo) {\n return []\n }\n\n return Object.values(this.orgIdToOrgMemberInfo)\n }\n\n public isImpersonating(): boolean {\n return !!this.impersonatorUserId\n }\n\n public static fromJSON(json: string): UserFromToken {\n const obj = JSON.parse(json)\n const orgIdToOrgMemberInfo: OrgIdToOrgMemberInfo = {}\n for (const orgId in obj.orgIdToOrgMemberInfo) {\n orgIdToOrgMemberInfo[orgId] = OrgMemberInfo.fromJSON(\n JSON.stringify(obj.orgIdToOrgMemberInfo[orgId])\n )\n }\n return new UserFromToken(\n obj.userId,\n obj.email,\n orgIdToOrgMemberInfo,\n obj.firstName,\n obj.lastName,\n obj.username,\n obj.legacyUserId,\n obj.impersonatorUserId\n )\n }\n}\n\nexport type OrgIdToOrgMemberInfo = {\n [orgId: string]: OrgMemberInfo\n}\n\nexport class OrgMemberInfo {\n public orgId: string\n public orgName: string\n public orgMetadata: { [key: string]: any }\n public urlSafeOrgName: string\n\n private userAssignedRole: string\n private userInheritedRolesPlusCurrentRole: string[]\n private userPermissions: string[]\n\n constructor(\n orgId: string,\n orgName: string,\n orgMetadata: { [key: string]: any },\n urlSafeOrgName: string,\n userAssignedRole: string,\n userInheritedRolesPlusCurrentRole: string[],\n userPermissions: string[]\n ) {\n this.orgId = orgId\n this.orgName = orgName\n this.orgMetadata = orgMetadata\n this.urlSafeOrgName = urlSafeOrgName\n\n this.userAssignedRole = userAssignedRole\n this.userInheritedRolesPlusCurrentRole = userInheritedRolesPlusCurrentRole\n this.userPermissions = userPermissions\n }\n\n // validation methods\n\n public isRole(role: string): boolean {\n return this.userAssignedRole === role\n }\n\n public isAtLeastRole(role: string): boolean {\n return this.userInheritedRolesPlusCurrentRole.includes(role)\n }\n\n public hasPermission(permission: string): boolean {\n return this.userPermissions.includes(permission)\n }\n\n public hasAllPermissions(permissions: string[]): boolean {\n return permissions.every((permission) => this.hasPermission(permission))\n }\n\n public static fromJSON(json: string): OrgMemberInfo {\n const obj = JSON.parse(json)\n return new OrgMemberInfo(\n obj.orgId,\n obj.orgName,\n obj.orgMetadata,\n obj.urlSafeOrgName,\n obj.userAssignedRole,\n obj.userInheritedRolesPlusCurrentRole,\n obj.userPermissions\n )\n }\n\n // getters for the private fields\n\n get assignedRole(): string {\n return this.userAssignedRole\n }\n\n get inheritedRolesPlusCurrentRole(): string[] {\n return this.userInheritedRolesPlusCurrentRole\n }\n\n get permissions(): string[] {\n return this.userPermissions\n }\n}\n\n// These Internal types exist since the server returns snake case, but typescript/javascript\n// convention is camelCase.\nexport type InternalOrgMemberInfo = {\n org_id: string\n org_name: string\n org_metadata: { [key: string]: any }\n url_safe_org_name: string\n user_role: string\n inherited_user_roles_plus_current_role: string[]\n user_permissions: string[]\n}\nexport type InternalUser = {\n user_id: string\n org_id_to_org_member_info?: { [org_id: string]: InternalOrgMemberInfo }\n\n email: string\n first_name?: string\n last_name?: string\n username?: string\n\n // If you used our migration APIs to migrate this user from a different system, this is their original ID from that system.\n legacy_user_id?: string\n impersonatorUserId?: string\n}\n\nexport function toUser(snake_case: InternalUser): UserFromToken {\n return new UserFromToken(\n snake_case.user_id,\n snake_case.email,\n toOrgIdToOrgMemberInfo(snake_case.org_id_to_org_member_info),\n snake_case.first_name,\n snake_case.last_name,\n snake_case.username,\n snake_case.legacy_user_id,\n snake_case.impersonatorUserId\n )\n}\n\nexport function toOrgIdToOrgMemberInfo(snake_case?: {\n [org_id: string]: InternalOrgMemberInfo\n}): OrgIdToOrgMemberInfo | undefined {\n if (snake_case === undefined) {\n return undefined\n }\n const camelCase: OrgIdToOrgMemberInfo = {}\n\n for (const key of Object.keys(snake_case)) {\n const snakeCaseValue = snake_case[key]\n if (snakeCaseValue) {\n camelCase[key] = new OrgMemberInfo(\n snakeCaseValue.org_id,\n snakeCaseValue.org_name,\n snakeCaseValue.org_metadata,\n snakeCaseValue.url_safe_org_name,\n snakeCaseValue.user_role,\n snakeCaseValue.inherited_user_roles_plus_current_role,\n snakeCaseValue.user_permissions\n )\n }\n }\n\n return camelCase\n}\n","'use client'\n\nimport React, {useCallback, useEffect, useReducer} from \"react\"\nimport {doesLocalStorageMatch, hasWindow, isEqual, saveUserToLocalStorage, USER_INFO_KEY} from \"./utils\";\nimport {useRouter} from \"next/navigation\";\nimport {User} from \"./useUser\";\nimport {toOrgIdToOrgMemberInfo} from \"../user\";\n\ninterface InternalAuthState {\n loading: boolean\n userAndAccessToken: UserAndAccessToken\n\n logout: () => Promise<void>\n\n redirectToLoginPage: () => void\n redirectToSignupPage: () => void\n redirectToAccountPage: () => void\n redirectToOrgPage: (orgId?: string) => void\n redirectToCreateOrgPage: () => void\n redirectToSetupSAMLPage: (orgId: string) => void\n\n getSignupPageUrl(): string\n\n getLoginPageUrl(): string\n\n getAccountPageUrl(): string\n\n getOrgPageUrl(orgId?: string): string\n\n getCreateOrgPageUrl(): string\n\n getSetupSAMLPageUrl(orgId: string): string\n\n refreshAuthInfo: () => Promise<User | undefined>\n}\n\nexport type AuthProviderProps = {\n authUrl: string\n children?: React.ReactNode\n}\n\nexport const AuthContext = React.createContext<InternalAuthState | undefined>(undefined)\n\ntype UserAndAccessToken = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\ntype AuthState = {\n loading: boolean\n userAndAccessToken: UserAndAccessToken\n\n // There's no good way to trigger server components to reload outside of router.refresh()\n // This is our workaround until the app router has something better\n authChangeDetected: boolean\n}\n\nconst initialAuthState = {\n loading: true,\n userAndAccessToken: {\n user: undefined,\n accessToken: undefined,\n },\n authChangeDetected: false,\n}\n\ntype AuthStateAction = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\nfunction authStateReducer(_state: AuthState, action: AuthStateAction): AuthState {\n const authChangeDetected = !_state.loading && !isEqual(action.user, _state.userAndAccessToken.user)\n\n if (!action.user) {\n return {\n loading: false,\n userAndAccessToken: {\n user: undefined,\n accessToken: undefined,\n },\n authChangeDetected,\n }\n } else if (_state.loading) {\n return {\n loading: false,\n userAndAccessToken: {\n user: action.user,\n accessToken: action.accessToken,\n },\n authChangeDetected,\n }\n } else {\n return {\n loading: false,\n userAndAccessToken: {\n user: action.user,\n accessToken: action.accessToken,\n },\n authChangeDetected\n }\n }\n}\n\nexport const AuthProvider = (props: AuthProviderProps) => {\n const [authState, dispatchInner] = useReducer(authStateReducer, initialAuthState)\n const router = useRouter()\n\n const dispatch = useCallback((action: AuthStateAction) => {\n dispatchInner(action)\n saveUserToLocalStorage(action.user)\n }, [dispatchInner])\n\n // This is because we don't have a good way to trigger server components to reload outside of router.refresh()\n // Once server actions isn't alpha, we can hopefully use that instead\n useEffect(() => {\n if (authState.authChangeDetected) {\n router.refresh()\n }\n }, [authState.authChangeDetected, router])\n\n // Trigger an initial refresh\n useEffect(() => {\n let didCancel = false\n\n async function refreshAuthInfo() {\n const action = await apiGetUserInfo()\n if (!didCancel) {\n dispatch(action)\n }\n }\n\n refreshAuthInfo()\n return () => {\n didCancel = true\n }\n }, [])\n\n\n // Periodically refresh the token\n useEffect(() => {\n let didCancel = false\n\n async function refreshToken() {\n const action = await apiGetUserInfo()\n if (!didCancel) {\n dispatch(action)\n }\n }\n\n async function onStorageEvent(event: StorageEvent) {\n if (event.key === USER_INFO_KEY && !doesLocalStorageMatch(event.newValue, authState.userAndAccessToken.user)) {\n await refreshToken()\n }\n }\n\n // TODO: Retry logic if the request fails\n const interval = setInterval(refreshToken, 5 * 60 * 1000)\n\n if (hasWindow()) {\n window.addEventListener(\"storage\", onStorageEvent)\n window.addEventListener(\"online\", refreshToken)\n window.addEventListener(\"focus\", refreshToken)\n }\n\n return () => {\n didCancel = true\n clearInterval(interval)\n if (hasWindow()) {\n window.removeEventListener(\"storage\", onStorageEvent)\n window.removeEventListener(\"online\", refreshToken)\n window.removeEventListener(\"focus\", refreshToken)\n }\n }\n }, [dispatch, authState.userAndAccessToken.user])\n\n\n const logout = useCallback(async () => {\n await fetch(\"/api/auth/logout\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n credentials: \"include\",\n })\n dispatch({user: undefined, accessToken: undefined})\n }, [dispatch])\n\n const getLoginPageUrl = () => \"/api/auth/login\"\n const getSignupPageUrl = () => \"/api/auth/signup\"\n const getAccountPageUrl = useCallback(() => {\n return `${props.authUrl}/account`\n }, [props.authUrl])\n const getOrgPageUrl = useCallback(\n (orgId?: string) => {\n if (orgId) {\n return `${props.authUrl}/org?id=${orgId}`\n } else {\n return `${props.authUrl}/org`\n }\n },\n [props.authUrl]\n )\n const getCreateOrgPageUrl = useCallback(() => {\n return `${props.authUrl}/create_org`\n }, [props.authUrl])\n\n const getSetupSAMLPageUrl = useCallback(\n (orgId: string) => {\n return `${props.authUrl}/saml?id=${orgId}`\n },\n [props.authUrl]\n )\n\n const redirectTo = (url: string) => {\n window.location.href = url\n }\n\n const redirectToLoginPage = () => redirectTo(getLoginPageUrl())\n const redirectToSignupPage = () => redirectTo(getSignupPageUrl())\n const redirectToAccountPage = () => redirectTo(getAccountPageUrl())\n const redirectToOrgPage = (orgId?: string) => redirectTo(getOrgPageUrl(orgId))\n const redirectToCreateOrgPage = () => redirectTo(getCreateOrgPageUrl())\n const redirectToSetupSAMLPage = (orgId: string) => redirectTo(getSetupSAMLPageUrl(orgId))\n\n const refreshAuthInfo = async () => {\n const action = await apiGetUserInfo()\n dispatch(action)\n return action.user\n }\n\n const value = {\n loading: authState.loading,\n userAndAccessToken: authState.userAndAccessToken,\n logout,\n redirectToLoginPage,\n redirectToSignupPage,\n redirectToAccountPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n redirectToSetupSAMLPage,\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n refreshAuthInfo,\n }\n return <AuthContext.Provider value={value}>{props.children}</AuthContext.Provider>\n}\n\ntype UserInfoResponse = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\nasync function apiGetUserInfo(): Promise<UserInfoResponse> {\n try {\n const userInfoResponse = await fetch(\"/api/auth/userinfo\", {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n credentials: \"include\",\n })\n\n if (userInfoResponse.ok) {\n const {userinfo, accessToken, impersonatorUserId} = await userInfoResponse.json()\n const user = new User({\n userId: userinfo.user_id,\n email: userinfo.email,\n emailConfirmed: userinfo.email_confirmed,\n hasPassword: userinfo.has_password,\n username: userinfo.username,\n firstName: userinfo.first_name,\n lastName: userinfo.last_name,\n pictureUrl: userinfo.picture_url,\n orgIdToOrgMemberInfo: toOrgIdToOrgMemberInfo(userinfo.org_id_to_org_info),\n mfaEnabled: userinfo.mfa_enabled,\n canCreateOrgs: userinfo.can_create_orgs,\n updatePasswordRequired: userinfo.update_password_required,\n createdAt: userinfo.created_at,\n lastActiveAt: userinfo.last_active_at,\n impersonatorUserId,\n })\n\n return {user, accessToken}\n } else if (userInfoResponse.status === 401) {\n return {user: undefined, accessToken: undefined}\n } else {\n console.log(\"Failed to refresh token\", userInfoResponse)\n }\n } catch (e) {\n console.log(\"Failed to refresh token\", e)\n }\n throw new Error(\"Failed to refresh token\")\n}\n","import {UserFromToken} from \"../user\";\nimport {User} from \"./useUser\";\n\nexport const USER_INFO_KEY = \"__PROPEL_AUTH_USER_INFO\"\n\nexport function hasWindow(): boolean {\n return typeof window !== \"undefined\"\n}\n\nexport function saveUserToLocalStorage(user: User | undefined) {\n if (user) {\n localStorage.setItem(USER_INFO_KEY, JSON.stringify(user))\n } else {\n localStorage.setItem(USER_INFO_KEY, \"{}\")\n }\n}\n\nexport function doesLocalStorageMatch(newValue: string | null, user: UserFromToken | undefined): boolean {\n if (!newValue) {\n return false\n } else if (!user) {\n return newValue === \"{}\"\n }\n\n const parsed = JSON.parse(newValue)\n if (!parsed) {\n return false\n }\n\n return isEqual(parsed, user)\n}\n\n\nexport function isEqual(a: any, b: any): boolean {\n if (typeof a !== typeof b) {\n return false\n }\n\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false\n }\n\n if (Array.isArray(a)) {\n const aArray = a as any[]\n const bArray = b as any[]\n if (aArray.length !== bArray.length) {\n return false\n }\n\n for (let i = 0; i < aArray.length; i++) {\n if (!isEqual(aArray[i], bArray[i])) {\n return false\n }\n }\n\n return true\n }\n\n if (typeof a === \"object\") {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length) {\n return false\n }\n\n for (const key of aKeys) {\n if (!isEqual(a[key], b[key])) {\n return false\n }\n }\n\n return true\n } else {\n return a === b\n }\n}","'use client'\n\nimport {useContext} from \"react\"\nimport {AuthContext} from \"./AuthProvider\"\nimport {OrgIdToOrgMemberInfo, OrgMemberInfo} from \"../user\";\n\nexport class User {\n public userId: string\n public email: string\n public emailConfirmed: boolean\n public hasPassword: boolean\n\n public username?: string\n public firstName?: string\n public lastName?: string\n public pictureUrl?: string\n\n public orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n\n public mfaEnabled: boolean\n public canCreateOrgs: boolean\n public updatePasswordRequired: boolean\n\n public createdAt: number\n public lastActiveAt: number\n\n public legacyUserId?: string\n public impersonatorUserId?: string\n\n constructor({\n userId,\n email,\n emailConfirmed,\n hasPassword,\n username,\n firstName,\n lastName,\n pictureUrl,\n orgIdToOrgMemberInfo,\n mfaEnabled,\n canCreateOrgs,\n updatePasswordRequired,\n createdAt,\n lastActiveAt,\n legacyUserId,\n impersonatorUserId,\n }: {\n userId: string\n email: string\n emailConfirmed: boolean\n hasPassword: boolean\n username?: string\n firstName?: string\n lastName?: string\n pictureUrl?: string\n orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n mfaEnabled: boolean\n canCreateOrgs: boolean\n updatePasswordRequired: boolean\n createdAt: number\n lastActiveAt: number\n legacyUserId?: string\n impersonatorUserId?: string\n }) {\n this.userId = userId\n this.email = email\n this.emailConfirmed = emailConfirmed\n this.hasPassword = hasPassword\n this.username = username\n this.firstName = firstName\n this.lastName = lastName\n this.pictureUrl = pictureUrl\n this.orgIdToOrgMemberInfo = orgIdToOrgMemberInfo\n this.mfaEnabled = mfaEnabled\n this.canCreateOrgs = canCreateOrgs\n this.updatePasswordRequired = updatePasswordRequired\n this.createdAt = createdAt\n this.lastActiveAt = lastActiveAt\n this.legacyUserId = legacyUserId\n this.impersonatorUserId = impersonatorUserId\n }\n\n public getOrg(orgId: string): OrgMemberInfo | undefined {\n return this.orgIdToOrgMemberInfo?.[orgId]\n }\n\n public getOrgByName(orgName: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n const urlSafeOrgName = orgName.toLowerCase().replace(/ /g, \"-\")\n for (const orgId in this.orgIdToOrgMemberInfo) {\n const orgMemberInfo = this.orgIdToOrgMemberInfo[orgId]\n if (orgMemberInfo.urlSafeOrgName === urlSafeOrgName) {\n return orgMemberInfo\n }\n }\n\n return undefined\n }\n\n public getOrgs(): OrgMemberInfo[] {\n if (!this.orgIdToOrgMemberInfo) {\n return []\n }\n\n return Object.values(this.orgIdToOrgMemberInfo)\n }\n\n public isImpersonating(): boolean {\n return !!this.impersonatorUserId\n }\n}\n\nexport type UseUserLoading = {\n loading: true\n isLoggedIn: never\n user: never\n accessToken: never\n}\n\nexport type UseUserLoggedIn = {\n loading: false\n isLoggedIn: true\n user: User\n accessToken: string\n}\n\nexport type UseUserNotLoggedIn = {\n loading: false\n isLoggedIn: false\n user: undefined\n accessToken: undefined\n}\n\nexport type UseUser = UseUserLoading | UseUserLoggedIn | UseUserNotLoggedIn\n\nexport function useUser(): UseUser {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useUser must be used within an AuthProvider\")\n }\n\n const {loading, userAndAccessToken} = context\n if (loading) {\n return {\n loading: true,\n isLoggedIn: undefined as never,\n user: undefined as never,\n accessToken: undefined as never,\n }\n } else if (userAndAccessToken.user) {\n return {\n loading: false,\n isLoggedIn: true,\n user: userAndAccessToken.user,\n accessToken: userAndAccessToken.accessToken,\n }\n } else {\n return {\n loading: false,\n isLoggedIn: false,\n user: undefined,\n accessToken: undefined,\n }\n }\n}","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useHostedPageUrls() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useHostedPageUrls must be used within an AuthProvider\")\n }\n const {\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n } = context\n return {\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n }\n}\n","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useLogoutFunction() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useLogoutFunction must be used within an AuthProvider\")\n }\n const { logout } = context\n return logout\n}\n","import React, { useContext, useEffect } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useRedirectFunctions() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useRedirectFunctions must be used within an AuthProvider\")\n }\n const {\n redirectToAccountPage,\n redirectToSignupPage,\n redirectToLoginPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n } = context\n return {\n redirectToSignupPage,\n redirectToLoginPage,\n redirectToAccountPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n }\n}\n\nexport interface RedirectProps {\n children?: React.ReactNode\n}\n\nexport function RedirectToSignup({ children }: RedirectProps) {\n const { redirectToSignupPage } = useRedirectFunctions()\n\n useEffect(() => {\n redirectToSignupPage()\n }, [])\n\n return <>{children}</>\n}\n\nexport function RedirectToLogin({ children }: RedirectProps) {\n const { redirectToLoginPage } = useRedirectFunctions()\n useEffect(() => {\n redirectToLoginPage()\n }, [])\n return <>{children}</>\n}\n","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useRefreshAuth() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useRefreshAuth must be used within an AuthProvider\")\n }\n const { refreshAuthInfo } = context\n return refreshAuthInfo\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,gBAAN,MAAoB;AAAA,EAevB,YACI,QACA,OACA,sBACA,WACA,UACA,UACA,cACA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AACnC,QAAM,UAAUC,YAAW,WAAW;AACtC,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC9E;AACA,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AACJ,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;AAMO,SAAS,iBAAiB,EAAE,SAAS,GAAkB;AAC1D,QAAM,EAAE,qBAAqB,IAAI,qBAAqB;AAEtD,EAAAC,WAAU,MAAM;AACZ,yBAAqB;AAAA,EACzB,GAAG,CAAC,CAAC;AAEL,SAAO,gBAAAC,OAAA,cAAAA,OAAA,gBAAG,QAAS;AACvB;AAEO,SAAS,gBAAgB,EAAE,SAAS,GAAkB;AACzD,QAAM,EAAE,oBAAoB,IAAI,qBAAqB;AACrD,EAAAD,WAAU,MAAM;AACZ,wBAAoB;AAAA,EACxB,GAAG,CAAC,CAAC;AACL,SAAO,gBAAAC,OAAA,cAAAA,OAAA,gBAAG,QAAS;AACvB;;;AC5CA,SAAS,cAAAC,mBAAkB;AAGpB,SAAS,iBAAiB;AAC7B,QAAM,UAAUC,YAAW,WAAW;AACtC,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACxE;AACA,QAAM,EAAE,gBAAgB,IAAI;AAC5B,SAAO;AACX;","names":["refreshAuthInfo","useContext","useContext","useContext","useContext","React","useContext","useEffect","useContext","useEffect","React","useContext","useContext"]}
|
1
|
+
{"version":3,"sources":["../../src/user.ts","../../src/client/AuthProvider.tsx","../../src/client/utils.ts","../../src/client/useUser.tsx","../../src/client/useHostedPageUrls.tsx","../../src/client/useLogoutFunction.ts","../../src/client/useRedirectFunctions.tsx","../../src/client/useRefreshAuth.ts"],"sourcesContent":["export class UserFromToken {\n public userId: string\n public orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n\n // Metadata about the user\n public email: string\n public firstName?: string\n public lastName?: string\n public username?: string\n\n // If you used our migration APIs to migrate this user from a different system,\n // this is their original ID from that system.\n public legacyUserId?: string\n public impersonatorUserId?: string\n\n constructor(\n userId: string,\n email: string,\n orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo,\n firstName?: string,\n lastName?: string,\n username?: string,\n legacyUserId?: string,\n impersonatorUserId?: string\n ) {\n this.userId = userId\n this.orgIdToOrgMemberInfo = orgIdToOrgMemberInfo\n\n this.email = email\n this.firstName = firstName\n this.lastName = lastName\n this.username = username\n\n this.legacyUserId = legacyUserId\n this.impersonatorUserId = impersonatorUserId\n }\n\n public getOrg(orgId: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n return this.orgIdToOrgMemberInfo[orgId]\n }\n\n public getOrgByName(orgName: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n const urlSafeOrgName = orgName.toLowerCase().replace(/ /g, \"-\")\n for (const orgId in this.orgIdToOrgMemberInfo) {\n const orgMemberInfo = this.orgIdToOrgMemberInfo[orgId]\n if (orgMemberInfo.urlSafeOrgName === urlSafeOrgName) {\n return orgMemberInfo\n }\n }\n\n return undefined\n }\n\n public getOrgs(): OrgMemberInfo[] {\n if (!this.orgIdToOrgMemberInfo) {\n return []\n }\n\n return Object.values(this.orgIdToOrgMemberInfo)\n }\n\n public isImpersonating(): boolean {\n return !!this.impersonatorUserId\n }\n\n public static fromJSON(json: string): UserFromToken {\n const obj = JSON.parse(json)\n const orgIdToOrgMemberInfo: OrgIdToOrgMemberInfo = {}\n for (const orgId in obj.orgIdToOrgMemberInfo) {\n orgIdToOrgMemberInfo[orgId] = OrgMemberInfo.fromJSON(\n JSON.stringify(obj.orgIdToOrgMemberInfo[orgId])\n )\n }\n return new UserFromToken(\n obj.userId,\n obj.email,\n orgIdToOrgMemberInfo,\n obj.firstName,\n obj.lastName,\n obj.username,\n obj.legacyUserId,\n obj.impersonatorUserId\n )\n }\n}\n\nexport type OrgIdToOrgMemberInfo = {\n [orgId: string]: OrgMemberInfo\n}\n\nexport class OrgMemberInfo {\n public orgId: string\n public orgName: string\n public orgMetadata: { [key: string]: any }\n public urlSafeOrgName: string\n\n private userAssignedRole: string\n private userInheritedRolesPlusCurrentRole: string[]\n private userPermissions: string[]\n\n constructor(\n orgId: string,\n orgName: string,\n orgMetadata: { [key: string]: any },\n urlSafeOrgName: string,\n userAssignedRole: string,\n userInheritedRolesPlusCurrentRole: string[],\n userPermissions: string[]\n ) {\n this.orgId = orgId\n this.orgName = orgName\n this.orgMetadata = orgMetadata\n this.urlSafeOrgName = urlSafeOrgName\n\n this.userAssignedRole = userAssignedRole\n this.userInheritedRolesPlusCurrentRole = userInheritedRolesPlusCurrentRole\n this.userPermissions = userPermissions\n }\n\n // validation methods\n\n public isRole(role: string): boolean {\n return this.userAssignedRole === role\n }\n\n public isAtLeastRole(role: string): boolean {\n return this.userInheritedRolesPlusCurrentRole.includes(role)\n }\n\n public hasPermission(permission: string): boolean {\n return this.userPermissions.includes(permission)\n }\n\n public hasAllPermissions(permissions: string[]): boolean {\n return permissions.every((permission) => this.hasPermission(permission))\n }\n\n public static fromJSON(json: string): OrgMemberInfo {\n const obj = JSON.parse(json)\n return new OrgMemberInfo(\n obj.orgId,\n obj.orgName,\n obj.orgMetadata,\n obj.urlSafeOrgName,\n obj.userAssignedRole,\n obj.userInheritedRolesPlusCurrentRole,\n obj.userPermissions\n )\n }\n\n // getters for the private fields\n\n get assignedRole(): string {\n return this.userAssignedRole\n }\n\n get inheritedRolesPlusCurrentRole(): string[] {\n return this.userInheritedRolesPlusCurrentRole\n }\n\n get permissions(): string[] {\n return this.userPermissions\n }\n}\n\n// These Internal types exist since the server returns snake case, but typescript/javascript\n// convention is camelCase.\nexport type InternalOrgMemberInfo = {\n org_id: string\n org_name: string\n org_metadata: { [key: string]: any }\n url_safe_org_name: string\n user_role: string\n inherited_user_roles_plus_current_role: string[]\n user_permissions: string[]\n}\nexport type InternalUser = {\n user_id: string\n org_id_to_org_member_info?: { [org_id: string]: InternalOrgMemberInfo }\n\n email: string\n first_name?: string\n last_name?: string\n username?: string\n\n // If you used our migration APIs to migrate this user from a different system, this is their original ID from that system.\n legacy_user_id?: string\n impersonatorUserId?: string\n}\n\nexport function toUser(snake_case: InternalUser): UserFromToken {\n return new UserFromToken(\n snake_case.user_id,\n snake_case.email,\n toOrgIdToOrgMemberInfo(snake_case.org_id_to_org_member_info),\n snake_case.first_name,\n snake_case.last_name,\n snake_case.username,\n snake_case.legacy_user_id,\n snake_case.impersonatorUserId\n )\n}\n\nexport function toOrgIdToOrgMemberInfo(snake_case?: {\n [org_id: string]: InternalOrgMemberInfo\n}): OrgIdToOrgMemberInfo | undefined {\n if (snake_case === undefined) {\n return undefined\n }\n const camelCase: OrgIdToOrgMemberInfo = {}\n\n for (const key of Object.keys(snake_case)) {\n const snakeCaseValue = snake_case[key]\n if (snakeCaseValue) {\n camelCase[key] = new OrgMemberInfo(\n snakeCaseValue.org_id,\n snakeCaseValue.org_name,\n snakeCaseValue.org_metadata,\n snakeCaseValue.url_safe_org_name,\n snakeCaseValue.user_role,\n snakeCaseValue.inherited_user_roles_plus_current_role,\n snakeCaseValue.user_permissions\n )\n }\n }\n\n return camelCase\n}\n","'use client'\n\nimport React, {useCallback, useEffect, useReducer} from \"react\"\nimport {doesLocalStorageMatch, hasWindow, isEqual, saveUserToLocalStorage, USER_INFO_KEY} from \"./utils\";\nimport {useRouter} from \"next/navigation\";\nimport {User} from \"./useUser\";\nimport {toOrgIdToOrgMemberInfo} from \"../user\";\n\ninterface InternalAuthState {\n loading: boolean\n userAndAccessToken: UserAndAccessToken\n\n logout: () => Promise<void>\n\n redirectToLoginPage: () => void\n redirectToSignupPage: () => void\n redirectToAccountPage: () => void\n redirectToOrgPage: (orgId?: string) => void\n redirectToCreateOrgPage: () => void\n redirectToSetupSAMLPage: (orgId: string) => void\n\n getSignupPageUrl(): string\n\n getLoginPageUrl(): string\n\n getAccountPageUrl(): string\n\n getOrgPageUrl(orgId?: string): string\n\n getCreateOrgPageUrl(): string\n\n getSetupSAMLPageUrl(orgId: string): string\n\n refreshAuthInfo: () => Promise<User | undefined>\n}\n\nexport type AuthProviderProps = {\n authUrl: string\n children?: React.ReactNode\n}\n\nexport const AuthContext = React.createContext<InternalAuthState | undefined>(undefined)\n\ntype UserAndAccessToken = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\ntype AuthState = {\n loading: boolean\n userAndAccessToken: UserAndAccessToken\n\n // There's no good way to trigger server components to reload outside of router.refresh()\n // This is our workaround until the app router has something better\n authChangeDetected: boolean\n}\n\nconst initialAuthState = {\n loading: true,\n userAndAccessToken: {\n user: undefined,\n accessToken: undefined,\n },\n authChangeDetected: false,\n}\n\ntype AuthStateAction = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\nfunction authStateReducer(_state: AuthState, action: AuthStateAction): AuthState {\n const authChangeDetected = !_state.loading && !isEqual(action.user, _state.userAndAccessToken.user)\n console.log(\"dispatching auth state reducer\", {action, _state, authChangeDetected})\n\n if (!action.user) {\n return {\n loading: false,\n userAndAccessToken: {\n user: undefined,\n accessToken: undefined,\n },\n authChangeDetected,\n }\n } else if (_state.loading) {\n return {\n loading: false,\n userAndAccessToken: {\n user: action.user,\n accessToken: action.accessToken,\n },\n authChangeDetected,\n }\n } else {\n return {\n loading: false,\n userAndAccessToken: {\n user: action.user,\n accessToken: action.accessToken,\n },\n authChangeDetected\n }\n }\n}\n\nexport const AuthProvider = (props: AuthProviderProps) => {\n const [authState, dispatchInner] = useReducer(authStateReducer, initialAuthState)\n const router = useRouter()\n\n const dispatch = useCallback((action: AuthStateAction) => {\n dispatchInner(action)\n saveUserToLocalStorage(action.user)\n }, [dispatchInner])\n\n // This is because we don't have a good way to trigger server components to reload outside of router.refresh()\n // Once server actions isn't alpha, we can hopefully use that instead\n useEffect(() => {\n if (authState.authChangeDetected) {\n router.refresh()\n }\n }, [authState.authChangeDetected, router])\n\n // Trigger an initial refresh\n useEffect(() => {\n let didCancel = false\n\n async function refreshAuthInfo() {\n const action = await apiGetUserInfo()\n if (!didCancel) {\n dispatch(action)\n }\n }\n\n refreshAuthInfo()\n return () => {\n didCancel = true\n }\n }, [])\n\n\n // Periodically refresh the token\n useEffect(() => {\n let didCancel = false\n\n async function refreshToken() {\n const action = await apiGetUserInfo()\n if (!didCancel) {\n dispatch(action)\n }\n }\n\n async function onStorageEvent(event: StorageEvent) {\n if (event.key === USER_INFO_KEY && !doesLocalStorageMatch(event.newValue, authState.userAndAccessToken.user)) {\n await refreshToken()\n }\n }\n\n // TODO: Retry logic if the request fails\n const interval = setInterval(refreshToken, 5 * 60 * 1000)\n\n if (hasWindow()) {\n window.addEventListener(\"storage\", onStorageEvent)\n window.addEventListener(\"online\", refreshToken)\n window.addEventListener(\"focus\", refreshToken)\n }\n\n return () => {\n didCancel = true\n clearInterval(interval)\n if (hasWindow()) {\n window.removeEventListener(\"storage\", onStorageEvent)\n window.removeEventListener(\"online\", refreshToken)\n window.removeEventListener(\"focus\", refreshToken)\n }\n }\n }, [dispatch, authState.userAndAccessToken.user])\n\n\n const logout = useCallback(async () => {\n await fetch(\"/api/auth/logout\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n credentials: \"include\",\n })\n dispatch({user: undefined, accessToken: undefined})\n }, [dispatch])\n\n const getLoginPageUrl = () => \"/api/auth/login\"\n const getSignupPageUrl = () => \"/api/auth/signup\"\n const getAccountPageUrl = useCallback(() => {\n return `${props.authUrl}/account`\n }, [props.authUrl])\n const getOrgPageUrl = useCallback(\n (orgId?: string) => {\n if (orgId) {\n return `${props.authUrl}/org?id=${orgId}`\n } else {\n return `${props.authUrl}/org`\n }\n },\n [props.authUrl]\n )\n const getCreateOrgPageUrl = useCallback(() => {\n return `${props.authUrl}/create_org`\n }, [props.authUrl])\n\n const getSetupSAMLPageUrl = useCallback(\n (orgId: string) => {\n return `${props.authUrl}/saml?id=${orgId}`\n },\n [props.authUrl]\n )\n\n const redirectTo = (url: string) => {\n window.location.href = url\n }\n\n const redirectToLoginPage = () => redirectTo(getLoginPageUrl())\n const redirectToSignupPage = () => redirectTo(getSignupPageUrl())\n const redirectToAccountPage = () => redirectTo(getAccountPageUrl())\n const redirectToOrgPage = (orgId?: string) => redirectTo(getOrgPageUrl(orgId))\n const redirectToCreateOrgPage = () => redirectTo(getCreateOrgPageUrl())\n const redirectToSetupSAMLPage = (orgId: string) => redirectTo(getSetupSAMLPageUrl(orgId))\n\n const refreshAuthInfo = async () => {\n const action = await apiGetUserInfo()\n dispatch(action)\n return action.user\n }\n\n const value = {\n loading: authState.loading,\n userAndAccessToken: authState.userAndAccessToken,\n logout,\n redirectToLoginPage,\n redirectToSignupPage,\n redirectToAccountPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n redirectToSetupSAMLPage,\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n refreshAuthInfo,\n }\n return <AuthContext.Provider value={value}>{props.children}</AuthContext.Provider>\n}\n\ntype UserInfoResponse = {\n user: User\n accessToken: string\n} | {\n user: undefined\n accessToken: undefined\n}\n\nasync function apiGetUserInfo(): Promise<UserInfoResponse> {\n try {\n const userInfoResponse = await fetch(\"/api/auth/userinfo\", {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n credentials: \"include\",\n })\n\n if (userInfoResponse.ok) {\n const {userinfo, accessToken, impersonatorUserId} = await userInfoResponse.json()\n const user = new User({\n userId: userinfo.user_id,\n email: userinfo.email,\n emailConfirmed: userinfo.email_confirmed,\n hasPassword: userinfo.has_password,\n username: userinfo.username,\n firstName: userinfo.first_name,\n lastName: userinfo.last_name,\n pictureUrl: userinfo.picture_url,\n orgIdToOrgMemberInfo: toOrgIdToOrgMemberInfo(userinfo.org_id_to_org_info),\n mfaEnabled: userinfo.mfa_enabled,\n canCreateOrgs: userinfo.can_create_orgs,\n updatePasswordRequired: userinfo.update_password_required,\n createdAt: userinfo.created_at,\n lastActiveAt: userinfo.last_active_at,\n impersonatorUserId,\n })\n\n return {user, accessToken}\n } else if (userInfoResponse.status === 401) {\n return {user: undefined, accessToken: undefined}\n } else {\n console.log(\"Failed to refresh token\", userInfoResponse)\n }\n } catch (e) {\n console.log(\"Failed to refresh token\", e)\n }\n throw new Error(\"Failed to refresh token\")\n}\n","import {UserFromToken} from \"../user\";\nimport {User} from \"./useUser\";\n\nexport const USER_INFO_KEY = \"__PROPEL_AUTH_USER_INFO\"\n\nexport function hasWindow(): boolean {\n return typeof window !== \"undefined\"\n}\n\nexport function saveUserToLocalStorage(user: User | undefined) {\n if (user) {\n localStorage.setItem(USER_INFO_KEY, JSON.stringify(user))\n } else {\n localStorage.setItem(USER_INFO_KEY, \"{}\")\n }\n}\n\nexport function doesLocalStorageMatch(newValue: string | null, user: UserFromToken | undefined): boolean {\n if (!newValue) {\n return false\n } else if (!user) {\n return newValue === \"{}\"\n }\n\n const parsed = JSON.parse(newValue)\n if (!parsed) {\n return false\n }\n\n return isEqual(parsed, user)\n}\n\n\nexport function isEqual(a: any, b: any): boolean {\n if (typeof a !== typeof b) {\n return false\n }\n\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false\n }\n\n if (Array.isArray(a)) {\n const aArray = a as any[]\n const bArray = b as any[]\n if (aArray.length !== bArray.length) {\n return false\n }\n\n for (let i = 0; i < aArray.length; i++) {\n if (!isEqual(aArray[i], bArray[i])) {\n return false\n }\n }\n\n return true\n }\n\n if (typeof a === \"object\") {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length) {\n return false\n }\n\n for (const key of aKeys) {\n if (!isEqual(a[key], b[key])) {\n return false\n }\n }\n\n return true\n } else {\n return a === b\n }\n}","'use client'\n\nimport {useContext} from \"react\"\nimport {AuthContext} from \"./AuthProvider\"\nimport {OrgIdToOrgMemberInfo, OrgMemberInfo} from \"../user\";\n\nexport class User {\n public userId: string\n public email: string\n public emailConfirmed: boolean\n public hasPassword: boolean\n\n public username?: string\n public firstName?: string\n public lastName?: string\n public pictureUrl?: string\n\n public orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n\n public mfaEnabled: boolean\n public canCreateOrgs: boolean\n public updatePasswordRequired: boolean\n\n public createdAt: number\n public lastActiveAt: number\n\n public legacyUserId?: string\n public impersonatorUserId?: string\n\n constructor({\n userId,\n email,\n emailConfirmed,\n hasPassword,\n username,\n firstName,\n lastName,\n pictureUrl,\n orgIdToOrgMemberInfo,\n mfaEnabled,\n canCreateOrgs,\n updatePasswordRequired,\n createdAt,\n lastActiveAt,\n legacyUserId,\n impersonatorUserId,\n }: {\n userId: string\n email: string\n emailConfirmed: boolean\n hasPassword: boolean\n username?: string\n firstName?: string\n lastName?: string\n pictureUrl?: string\n orgIdToOrgMemberInfo?: OrgIdToOrgMemberInfo\n mfaEnabled: boolean\n canCreateOrgs: boolean\n updatePasswordRequired: boolean\n createdAt: number\n lastActiveAt: number\n legacyUserId?: string\n impersonatorUserId?: string\n }) {\n this.userId = userId\n this.email = email\n this.emailConfirmed = emailConfirmed\n this.hasPassword = hasPassword\n this.username = username\n this.firstName = firstName\n this.lastName = lastName\n this.pictureUrl = pictureUrl\n this.orgIdToOrgMemberInfo = orgIdToOrgMemberInfo\n this.mfaEnabled = mfaEnabled\n this.canCreateOrgs = canCreateOrgs\n this.updatePasswordRequired = updatePasswordRequired\n this.createdAt = createdAt\n this.lastActiveAt = lastActiveAt\n this.legacyUserId = legacyUserId\n this.impersonatorUserId = impersonatorUserId\n }\n\n public getOrg(orgId: string): OrgMemberInfo | undefined {\n return this.orgIdToOrgMemberInfo?.[orgId]\n }\n\n public getOrgByName(orgName: string): OrgMemberInfo | undefined {\n if (!this.orgIdToOrgMemberInfo) {\n return undefined\n }\n\n const urlSafeOrgName = orgName.toLowerCase().replace(/ /g, \"-\")\n for (const orgId in this.orgIdToOrgMemberInfo) {\n const orgMemberInfo = this.orgIdToOrgMemberInfo[orgId]\n if (orgMemberInfo.urlSafeOrgName === urlSafeOrgName) {\n return orgMemberInfo\n }\n }\n\n return undefined\n }\n\n public getOrgs(): OrgMemberInfo[] {\n if (!this.orgIdToOrgMemberInfo) {\n return []\n }\n\n return Object.values(this.orgIdToOrgMemberInfo)\n }\n\n public isImpersonating(): boolean {\n return !!this.impersonatorUserId\n }\n}\n\nexport type UseUserLoading = {\n loading: true\n isLoggedIn: never\n user: never\n accessToken: never\n}\n\nexport type UseUserLoggedIn = {\n loading: false\n isLoggedIn: true\n user: User\n accessToken: string\n}\n\nexport type UseUserNotLoggedIn = {\n loading: false\n isLoggedIn: false\n user: undefined\n accessToken: undefined\n}\n\nexport type UseUser = UseUserLoading | UseUserLoggedIn | UseUserNotLoggedIn\n\nexport function useUser(): UseUser {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useUser must be used within an AuthProvider\")\n }\n\n const {loading, userAndAccessToken} = context\n if (loading) {\n return {\n loading: true,\n isLoggedIn: undefined as never,\n user: undefined as never,\n accessToken: undefined as never,\n }\n } else if (userAndAccessToken.user) {\n return {\n loading: false,\n isLoggedIn: true,\n user: userAndAccessToken.user,\n accessToken: userAndAccessToken.accessToken,\n }\n } else {\n return {\n loading: false,\n isLoggedIn: false,\n user: undefined,\n accessToken: undefined,\n }\n }\n}","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useHostedPageUrls() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useHostedPageUrls must be used within an AuthProvider\")\n }\n const {\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n } = context\n return {\n getLoginPageUrl,\n getSignupPageUrl,\n getAccountPageUrl,\n getOrgPageUrl,\n getCreateOrgPageUrl,\n getSetupSAMLPageUrl,\n }\n}\n","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useLogoutFunction() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useLogoutFunction must be used within an AuthProvider\")\n }\n const { logout } = context\n return logout\n}\n","import React, { useContext, useEffect } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useRedirectFunctions() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useRedirectFunctions must be used within an AuthProvider\")\n }\n const {\n redirectToAccountPage,\n redirectToSignupPage,\n redirectToLoginPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n } = context\n return {\n redirectToSignupPage,\n redirectToLoginPage,\n redirectToAccountPage,\n redirectToOrgPage,\n redirectToCreateOrgPage,\n }\n}\n\nexport interface RedirectProps {\n children?: React.ReactNode\n}\n\nexport function RedirectToSignup({ children }: RedirectProps) {\n const { redirectToSignupPage } = useRedirectFunctions()\n\n useEffect(() => {\n redirectToSignupPage()\n }, [])\n\n return <>{children}</>\n}\n\nexport function RedirectToLogin({ children }: RedirectProps) {\n const { redirectToLoginPage } = useRedirectFunctions()\n useEffect(() => {\n redirectToLoginPage()\n }, [])\n return <>{children}</>\n}\n","import { useContext } from \"react\"\nimport { AuthContext } from \"./AuthProvider\"\n\nexport function useRefreshAuth() {\n const context = useContext(AuthContext)\n if (context === undefined) {\n throw new Error(\"useRefreshAuth must be used within an AuthProvider\")\n }\n const { refreshAuthInfo } = context\n return refreshAuthInfo\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,gBAAN,MAAoB;AAAA,EAevB,YACI,QACA,OACA,sBACA,WACA,UACA,UACA,cACA,oBACF;AACE,SAAK,SAAS;AACd,SAAK,uBAAuB;AAE5B,SAAK,QAAQ;AACb,SAAK,YAAY;AACjB,SAAK,WAAW;AAChB,SAAK,WAAW;AAEhB,SAAK,eAAe;AACpB,SAAK,qBAAqB;AAAA,EAC9B;AAAA,EAEO,OAAO,OAA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IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ,IAAI;AACJ,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;AAMO,SAAS,iBAAiB,EAAE,SAAS,GAAkB;AAC1D,QAAM,EAAE,qBAAqB,IAAI,qBAAqB;AAEtD,EAAAC,WAAU,MAAM;AACZ,yBAAqB;AAAA,EACzB,GAAG,CAAC,CAAC;AAEL,SAAO,gBAAAC,OAAA,cAAAA,OAAA,gBAAG,QAAS;AACvB;AAEO,SAAS,gBAAgB,EAAE,SAAS,GAAkB;AACzD,QAAM,EAAE,oBAAoB,IAAI,qBAAqB;AACrD,EAAAD,WAAU,MAAM;AACZ,wBAAoB;AAAA,EACxB,GAAG,CAAC,CAAC;AACL,SAAO,gBAAAC,OAAA,cAAAA,OAAA,gBAAG,QAAS;AACvB;;;AC5CA,SAAS,cAAAC,mBAAkB;AAGpB,SAAS,iBAAiB;AAC7B,QAAM,UAAUC,YAAW,WAAW;AACtC,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACxE;AACA,QAAM,EAAE,gBAAgB,IAAI;AAC5B,SAAO;AACX;","names":["refreshAuthInfo","useContext","useContext","useContext","useContext","React","useContext","useEffect","useContext","useEffect","React","useContext","useContext"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@propelauth/nextjs",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.80",
|
4
4
|
"exports": {
|
5
5
|
"./server": {
|
6
6
|
"browser": "./dist/server/index.mjs",
|
@@ -59,7 +59,7 @@
|
|
59
59
|
"react": "^18.2.0"
|
60
60
|
},
|
61
61
|
"dependencies": {
|
62
|
-
"@propelauth/node-apis": "^2.1.
|
62
|
+
"@propelauth/node-apis": "^2.1.1",
|
63
63
|
"jose": "^4.14.4"
|
64
64
|
}
|
65
65
|
}
|