diff --git a/src/config/index.js b/src/config/index.ts similarity index 90% rename from src/config/index.js rename to src/config/index.ts index cec9bb2f..8bd9d4cf 100644 --- a/src/config/index.js +++ b/src/config/index.ts @@ -1,10 +1,8 @@ import {version} from '../utils/version'; import {removeTrailingSlash} from '../utils/removeTrailingSlash'; +import {KindeState} from '../../types'; -/** - * @type {import('../../types').KindeState} - */ -const initialState = { +const initialState: KindeState = { accessToken: null, idToken: null, isAuthenticated: false, @@ -12,7 +10,7 @@ const initialState = { organization: null, permissions: [], user: null, - userOrganizations: [], + userOrganizations: null, getAccessToken: () => null, getBooleanFlag: () => null, getClaim: () => null, @@ -26,7 +24,13 @@ const initialState = { getToken: () => null, getUser: () => null, getUserOrganizations: () => null, - refreshData: () => null + refreshData: () => null, + accessTokenEncoded: null, + accessTokenRaw: null, + idTokenRaw: null, + idTokenEncoded: null, + getAccessTokenRaw: () => null, + getIdTokenRaw: () => null }; const SESSION_PREFIX = 'pkce-verifier'; diff --git a/types.d.ts b/types.d.ts index 004ac4b2..60bb6a3b 100644 --- a/types.d.ts +++ b/types.d.ts @@ -303,7 +303,7 @@ export type KindeState = { isAuthenticated: boolean | null; isLoading: boolean | null; organization: KindeOrganization; - permissions: KindePermissions; + permissions: KindePermissions | {permissions: []; orgCode: null}; user: { id: string; email: string | null; @@ -337,7 +337,7 @@ export type KindeState = { getPermission: ( key: string ) => {isGranted: boolean; orgCode: string | null} | null; - getPermissions: () => KindePermissions; + getPermissions: () => KindePermissions | {permissions: []; orgCode: null}; getStringFlag: ( code: string, defaultValue: string