@contember/react-identity 1.3.0-alpha.26 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/components/IdentityEnvironmentProvider.cjs +16 -0
- package/dist/development/components/IdentityEnvironmentProvider.cjs.map +1 -0
- package/dist/development/components/IdentityEnvironmentProvider.js +16 -0
- package/dist/development/components/IdentityEnvironmentProvider.js.map +1 -0
- package/dist/development/environment/IdentityEnvironmentExtension.cjs.map +1 -1
- package/dist/development/environment/IdentityEnvironmentExtension.js.map +1 -1
- package/dist/development/hooks/useProjectUserRoles.cjs +2 -2
- package/dist/development/hooks/useProjectUserRoles.cjs.map +1 -1
- package/dist/development/hooks/useProjectUserRoles.js +1 -1
- package/dist/development/hooks/useProjectUserRoles.js.map +1 -1
- package/dist/development/index.cjs +10 -14
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +3 -14
- package/dist/development/index.js.map +1 -1
- package/dist/production/components/IdentityEnvironmentProvider.cjs +12 -0
- package/dist/production/components/IdentityEnvironmentProvider.cjs.map +1 -0
- package/dist/production/components/IdentityEnvironmentProvider.js +12 -0
- package/dist/production/components/IdentityEnvironmentProvider.js.map +1 -0
- package/dist/production/environment/IdentityEnvironmentExtension.cjs.map +1 -1
- package/dist/production/environment/IdentityEnvironmentExtension.js.map +1 -1
- package/dist/production/hooks/useProjectUserRoles.cjs +2 -2
- package/dist/production/hooks/useProjectUserRoles.cjs.map +1 -1
- package/dist/production/hooks/useProjectUserRoles.js +1 -1
- package/dist/production/hooks/useProjectUserRoles.js.map +1 -1
- package/dist/production/index.cjs +10 -14
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +3 -14
- package/dist/production/index.js.map +1 -1
- package/dist/types/components/IdentityEnvironmentProvider.d.ts +6 -0
- package/dist/types/components/IdentityEnvironmentProvider.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +1 -3
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/environment/IdentityEnvironmentExtension.d.ts +1 -1
- package/dist/types/environment/IdentityEnvironmentExtension.d.ts.map +1 -1
- package/dist/types/hooks/index.d.ts +0 -3
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -7
- package/src/components/IdentityEnvironmentProvider.tsx +19 -0
- package/src/components/index.ts +1 -3
- package/src/environment/IdentityEnvironmentExtension.ts +1 -1
- package/src/hooks/index.ts +1 -7
- package/src/hooks/useProjectUserRoles.tsx +1 -1
- package/src/index.ts +1 -1
- package/src/tsconfig.json +0 -1
- package/dist/development/components/IdentityProvider.cjs +0 -44
- package/dist/development/components/IdentityProvider.cjs.map +0 -1
- package/dist/development/components/IdentityProvider.js +0 -44
- package/dist/development/components/IdentityProvider.js.map +0 -1
- package/dist/development/components/IdentityState.cjs +0 -14
- package/dist/development/components/IdentityState.cjs.map +0 -1
- package/dist/development/components/IdentityState.js +0 -14
- package/dist/development/components/IdentityState.js.map +0 -1
- package/dist/development/components/LogoutTrigger.cjs +0 -16
- package/dist/development/components/LogoutTrigger.cjs.map +0 -1
- package/dist/development/components/LogoutTrigger.js +0 -16
- package/dist/development/components/LogoutTrigger.js.map +0 -1
- package/dist/development/hooks/useFetchIdentity.cjs +0 -52
- package/dist/development/hooks/useFetchIdentity.cjs.map +0 -1
- package/dist/development/hooks/useFetchIdentity.js +0 -52
- package/dist/development/hooks/useFetchIdentity.js.map +0 -1
- package/dist/development/hooks/useLogout.cjs +0 -10
- package/dist/development/hooks/useLogout.cjs.map +0 -1
- package/dist/development/hooks/useLogout.js +0 -10
- package/dist/development/hooks/useLogout.js.map +0 -1
- package/dist/development/internal/contexts.cjs +0 -13
- package/dist/development/internal/contexts.cjs.map +0 -1
- package/dist/development/internal/contexts.js +0 -13
- package/dist/development/internal/contexts.js.map +0 -1
- package/dist/development/internal/hooks/useFetchMe.cjs +0 -33
- package/dist/development/internal/hooks/useFetchMe.cjs.map +0 -1
- package/dist/development/internal/hooks/useFetchMe.js +0 -16
- package/dist/development/internal/hooks/useFetchMe.js.map +0 -1
- package/dist/development/internal/hooks/useLogoutInternal.cjs +0 -35
- package/dist/development/internal/hooks/useLogoutInternal.cjs.map +0 -1
- package/dist/development/internal/hooks/useLogoutInternal.js +0 -35
- package/dist/development/internal/hooks/useLogoutInternal.js.map +0 -1
- package/dist/development/internal/hooks/useSignOut.cjs +0 -31
- package/dist/development/internal/hooks/useSignOut.cjs.map +0 -1
- package/dist/development/internal/hooks/useSignOut.js +0 -14
- package/dist/development/internal/hooks/useSignOut.js.map +0 -1
- package/dist/production/components/IdentityProvider.cjs +0 -28
- package/dist/production/components/IdentityProvider.cjs.map +0 -1
- package/dist/production/components/IdentityProvider.js +0 -28
- package/dist/production/components/IdentityProvider.js.map +0 -1
- package/dist/production/components/IdentityState.cjs +0 -10
- package/dist/production/components/IdentityState.cjs.map +0 -1
- package/dist/production/components/IdentityState.js +0 -10
- package/dist/production/components/IdentityState.js.map +0 -1
- package/dist/production/components/LogoutTrigger.cjs +0 -12
- package/dist/production/components/LogoutTrigger.cjs.map +0 -1
- package/dist/production/components/LogoutTrigger.js +0 -12
- package/dist/production/components/LogoutTrigger.js.map +0 -1
- package/dist/production/hooks/useFetchIdentity.cjs +0 -52
- package/dist/production/hooks/useFetchIdentity.cjs.map +0 -1
- package/dist/production/hooks/useFetchIdentity.js +0 -52
- package/dist/production/hooks/useFetchIdentity.js.map +0 -1
- package/dist/production/hooks/useLogout.cjs +0 -10
- package/dist/production/hooks/useLogout.cjs.map +0 -1
- package/dist/production/hooks/useLogout.js +0 -10
- package/dist/production/hooks/useLogout.js.map +0 -1
- package/dist/production/internal/contexts.cjs +0 -13
- package/dist/production/internal/contexts.cjs.map +0 -1
- package/dist/production/internal/contexts.js +0 -13
- package/dist/production/internal/contexts.js.map +0 -1
- package/dist/production/internal/hooks/useFetchMe.cjs +0 -33
- package/dist/production/internal/hooks/useFetchMe.cjs.map +0 -1
- package/dist/production/internal/hooks/useFetchMe.js +0 -16
- package/dist/production/internal/hooks/useFetchMe.js.map +0 -1
- package/dist/production/internal/hooks/useLogoutInternal.cjs +0 -35
- package/dist/production/internal/hooks/useLogoutInternal.cjs.map +0 -1
- package/dist/production/internal/hooks/useLogoutInternal.js +0 -35
- package/dist/production/internal/hooks/useLogoutInternal.js.map +0 -1
- package/dist/production/internal/hooks/useSignOut.cjs +0 -31
- package/dist/production/internal/hooks/useSignOut.cjs.map +0 -1
- package/dist/production/internal/hooks/useSignOut.js +0 -14
- package/dist/production/internal/hooks/useSignOut.js.map +0 -1
- package/dist/types/components/IdentityProvider.d.ts +0 -6
- package/dist/types/components/IdentityProvider.d.ts.map +0 -1
- package/dist/types/components/IdentityState.d.ts +0 -8
- package/dist/types/components/IdentityState.d.ts.map +0 -1
- package/dist/types/components/LogoutTrigger.d.ts +0 -5
- package/dist/types/components/LogoutTrigger.d.ts.map +0 -1
- package/dist/types/hooks/useFetchIdentity.d.ts +0 -6
- package/dist/types/hooks/useFetchIdentity.d.ts.map +0 -1
- package/dist/types/hooks/useLogout.d.ts +0 -4
- package/dist/types/hooks/useLogout.d.ts.map +0 -1
- package/dist/types/internal/contexts.d.ts +0 -7
- package/dist/types/internal/contexts.d.ts.map +0 -1
- package/dist/types/internal/hooks/useFetchMe.d.ts +0 -95
- package/dist/types/internal/hooks/useFetchMe.d.ts.map +0 -1
- package/dist/types/internal/hooks/useLogoutInternal.d.ts +0 -4
- package/dist/types/internal/hooks/useLogoutInternal.d.ts.map +0 -1
- package/dist/types/internal/hooks/useSignOut.d.ts +0 -27
- package/dist/types/internal/hooks/useSignOut.d.ts.map +0 -1
- package/dist/types/types/Identity.d.ts +0 -19
- package/dist/types/types/Identity.d.ts.map +0 -1
- package/dist/types/types/IdentityMethods.d.ts +0 -5
- package/dist/types/types/IdentityMethods.d.ts.map +0 -1
- package/dist/types/types/IdentityStateValue.d.ts +0 -2
- package/dist/types/types/IdentityStateValue.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -4
- package/dist/types/types/index.d.ts.map +0 -1
- package/src/components/IdentityProvider.tsx +0 -43
- package/src/components/IdentityState.tsx +0 -14
- package/src/components/LogoutTrigger.tsx +0 -10
- package/src/hooks/useFetchIdentity.ts +0 -55
- package/src/hooks/useLogout.ts +0 -7
- package/src/internal/contexts.ts +0 -8
- package/src/internal/hooks/useFetchMe.ts +0 -22
- package/src/internal/hooks/useLogoutInternal.ts +0 -35
- package/src/internal/hooks/useSignOut.ts +0 -14
- package/src/types/Identity.ts +0 -20
- package/src/types/IdentityMethods.ts +0 -4
- package/src/types/IdentityStateValue.ts +0 -6
- package/src/types/index.ts +0 -3
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSignOut.cjs","sources":["../../../../src/internal/hooks/useSignOut.ts"],"sourcesContent":["import * as TenantApi from '@contember/graphql-client-tenant'\nimport { ModelType, useTenantApi } from '@contember/react-client-tenant'\nimport { useCallback } from 'react'\n\nconst signOutFragment = TenantApi.signOutResponse$$.error(TenantApi.signOutError$$)\n\nexport type SignOutResult = ModelType<typeof signOutFragment>\n\nexport const useSignOut = () => {\n\tconst api = useTenantApi()\n\treturn useCallback(async () => {\n\t\treturn (await api(TenantApi.mutation$.signOut(signOutFragment))).signOut\n\t}, [api])\n}\n"],"names":["TenantApi","useTenantApi","useCallback"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,kBAAkBA,qBAAU,kBAAkB,MAAMA,qBAAU,cAAc;AAI3E,MAAM,aAAa,MAAM;AAC/B,QAAM,MAAMC,kBAAAA;AACZ,SAAOC,kBAAY,YAAY;AAC9B,YAAQ,MAAM,IAAIF,qBAAU,UAAU,QAAQ,eAAe,CAAC,GAAG;AAAA,EAAA,GAC/D,CAAC,GAAG,CAAC;AACT;;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as TenantApi from "@contember/graphql-client-tenant";
|
|
2
|
-
import { useTenantApi } from "@contember/react-client-tenant";
|
|
3
|
-
import { useCallback } from "react";
|
|
4
|
-
const signOutFragment = TenantApi.signOutResponse$$.error(TenantApi.signOutError$$);
|
|
5
|
-
const useSignOut = () => {
|
|
6
|
-
const api = useTenantApi();
|
|
7
|
-
return useCallback(async () => {
|
|
8
|
-
return (await api(TenantApi.mutation$.signOut(signOutFragment))).signOut;
|
|
9
|
-
}, [api]);
|
|
10
|
-
};
|
|
11
|
-
export {
|
|
12
|
-
useSignOut
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=useSignOut.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSignOut.js","sources":["../../../../src/internal/hooks/useSignOut.ts"],"sourcesContent":["import * as TenantApi from '@contember/graphql-client-tenant'\nimport { ModelType, useTenantApi } from '@contember/react-client-tenant'\nimport { useCallback } from 'react'\n\nconst signOutFragment = TenantApi.signOutResponse$$.error(TenantApi.signOutError$$)\n\nexport type SignOutResult = ModelType<typeof signOutFragment>\n\nexport const useSignOut = () => {\n\tconst api = useTenantApi()\n\treturn useCallback(async () => {\n\t\treturn (await api(TenantApi.mutation$.signOut(signOutFragment))).signOut\n\t}, [api])\n}\n"],"names":[],"mappings":";;;AAIA,MAAM,kBAAkB,UAAU,kBAAkB,MAAM,UAAU,cAAc;AAI3E,MAAM,aAAa,MAAM;AAC/B,QAAM,MAAM;AACZ,SAAO,YAAY,YAAY;AAC9B,YAAQ,MAAM,IAAI,UAAU,UAAU,QAAQ,eAAe,CAAC,GAAG;AAAA,EAAA,GAC/D,CAAC,GAAG,CAAC;AACT;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.d.ts","sourceRoot":"","sources":["../../../src/components/IdentityProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;AAO5C,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,SAAS,CAAA;CACnB;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA8B5D,CAAA"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { IdentityStateValue } from '../types';
|
|
3
|
-
export interface IdentityStateProps {
|
|
4
|
-
state: IdentityStateValue | IdentityStateValue[];
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const IdentityState: ({ state, children }: IdentityStateProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
-
//# sourceMappingURL=IdentityState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityState.d.ts","sourceRoot":"","sources":["../../../src/components/IdentityState.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAG7C,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,kBAAkB,GAAG,kBAAkB,EAAE,CAAA;IAChD,QAAQ,EAAE,SAAS,CAAA;CACnB;AAED,eAAO,MAAM,aAAa,wBAAyB,kBAAkB,mDAIpE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LogoutTrigger.d.ts","sourceRoot":"","sources":["../../../src/components/LogoutTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAA;AAI9C,eAAO,MAAM,aAAa,iBAAkB;IAC3C,QAAQ,EAAE,SAAS,CAAA;CACnB,4CAGA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchIdentity.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFetchIdentity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAKxE,eAAO,MAAM,gBAAgB,QAAO,CAAC;IAAE,KAAK,EAAE,kBAAkB,CAAC;IAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,EAAE,eAAe,CAgDlH,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLogout.d.ts","sourceRoot":"","sources":["../../../src/hooks/useLogout.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS;;mBAGrB,CAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { IdentityMethods } from '../types/IdentityMethods';
|
|
2
|
-
import { Identity } from '../types/Identity';
|
|
3
|
-
import { IdentityStateValue } from '../types/IdentityStateValue';
|
|
4
|
-
export declare const IdentityContext: import("react").Context<Identity | undefined>, useIdentity: () => Identity | undefined;
|
|
5
|
-
export declare const IdentityMethodsContext: import("react").Context<IdentityMethods>, useIdentityMethods: () => IdentityMethods;
|
|
6
|
-
export declare const IdentityStateContext: import("react").Context<IdentityStateValue>, useIdentityState: () => IdentityStateValue;
|
|
7
|
-
//# sourceMappingURL=contexts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../src/internal/contexts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAEhE,eAAO,MAAO,eAAe,iDAAE,WAAW,4BAAqE,CAAA;AAC/G,eAAO,MAAO,sBAAsB,4CAAE,kBAAkB,uBAAoE,CAAA;AAC5H,eAAO,MAAO,oBAAoB,+CAAE,gBAAgB,0BAAqE,CAAA"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import * as TenantApi from '@contember/graphql-client-tenant';
|
|
2
|
-
import { ModelType } from '@contember/react-client-tenant';
|
|
3
|
-
declare const identityFragment: TenantApi.IdentityFetcher<{
|
|
4
|
-
readonly id: string;
|
|
5
|
-
} & {
|
|
6
|
-
readonly description?: string | undefined;
|
|
7
|
-
} & {
|
|
8
|
-
readonly roles?: readonly string[] | undefined;
|
|
9
|
-
} & {
|
|
10
|
-
readonly person?: ({
|
|
11
|
-
readonly id: string;
|
|
12
|
-
} & {
|
|
13
|
-
readonly email?: string | undefined;
|
|
14
|
-
} & {
|
|
15
|
-
readonly name?: string | undefined;
|
|
16
|
-
} & {
|
|
17
|
-
readonly otpEnabled: boolean;
|
|
18
|
-
}) | undefined;
|
|
19
|
-
} & {
|
|
20
|
-
readonly projects: readonly ({
|
|
21
|
-
readonly project: {
|
|
22
|
-
readonly id: string;
|
|
23
|
-
} & {
|
|
24
|
-
readonly name: string;
|
|
25
|
-
} & {
|
|
26
|
-
readonly slug: string;
|
|
27
|
-
} & {
|
|
28
|
-
readonly config: unknown;
|
|
29
|
-
};
|
|
30
|
-
} & {
|
|
31
|
-
readonly memberships: readonly ({
|
|
32
|
-
readonly role: string;
|
|
33
|
-
} & {
|
|
34
|
-
readonly variables: readonly ({
|
|
35
|
-
readonly name: string;
|
|
36
|
-
} & {
|
|
37
|
-
readonly values: readonly string[];
|
|
38
|
-
})[];
|
|
39
|
-
})[];
|
|
40
|
-
})[];
|
|
41
|
-
} & {
|
|
42
|
-
readonly permissions?: ({
|
|
43
|
-
readonly canCreateProject: boolean;
|
|
44
|
-
} & {
|
|
45
|
-
readonly canDeployEntrypoint: boolean;
|
|
46
|
-
}) | undefined;
|
|
47
|
-
}, {}>;
|
|
48
|
-
export type FetchedIdentity = ModelType<typeof identityFragment>;
|
|
49
|
-
export declare const useFetchMe: () => () => Promise<{
|
|
50
|
-
readonly id: string;
|
|
51
|
-
} & {
|
|
52
|
-
readonly description?: string | undefined;
|
|
53
|
-
} & {
|
|
54
|
-
readonly roles?: readonly string[] | undefined;
|
|
55
|
-
} & {
|
|
56
|
-
readonly person?: ({
|
|
57
|
-
readonly id: string;
|
|
58
|
-
} & {
|
|
59
|
-
readonly email?: string | undefined;
|
|
60
|
-
} & {
|
|
61
|
-
readonly name?: string | undefined;
|
|
62
|
-
} & {
|
|
63
|
-
readonly otpEnabled: boolean;
|
|
64
|
-
}) | undefined;
|
|
65
|
-
} & {
|
|
66
|
-
readonly projects: readonly ({
|
|
67
|
-
readonly project: {
|
|
68
|
-
readonly id: string;
|
|
69
|
-
} & {
|
|
70
|
-
readonly name: string;
|
|
71
|
-
} & {
|
|
72
|
-
readonly slug: string;
|
|
73
|
-
} & {
|
|
74
|
-
readonly config: unknown;
|
|
75
|
-
};
|
|
76
|
-
} & {
|
|
77
|
-
readonly memberships: readonly ({
|
|
78
|
-
readonly role: string;
|
|
79
|
-
} & {
|
|
80
|
-
readonly variables: readonly ({
|
|
81
|
-
readonly name: string;
|
|
82
|
-
} & {
|
|
83
|
-
readonly values: readonly string[];
|
|
84
|
-
})[];
|
|
85
|
-
})[];
|
|
86
|
-
})[];
|
|
87
|
-
} & {
|
|
88
|
-
readonly permissions?: ({
|
|
89
|
-
readonly canCreateProject: boolean;
|
|
90
|
-
} & {
|
|
91
|
-
readonly canDeployEntrypoint: boolean;
|
|
92
|
-
}) | undefined;
|
|
93
|
-
}>;
|
|
94
|
-
export {};
|
|
95
|
-
//# sourceMappingURL=useFetchMe.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchMe.d.ts","sourceRoot":"","sources":["../../../../src/internal/hooks/useFetchMe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAgB,MAAM,gCAAgC,CAAA;AAGxE,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAQ8B,CAAA;AAEpD,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEhE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKtB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLogoutInternal.d.ts","sourceRoot":"","sources":["../../../../src/internal/hooks/useLogoutInternal.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,mBAAoB,MAAM,IAAI,uBAK3B;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,kBAyBxD,CAAA"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as TenantApi from '@contember/graphql-client-tenant';
|
|
2
|
-
import { ModelType } from '@contember/react-client-tenant';
|
|
3
|
-
declare const signOutFragment: TenantApi.SignOutResponseFetcher<{
|
|
4
|
-
readonly ok: boolean;
|
|
5
|
-
} & {
|
|
6
|
-
readonly error?: ({
|
|
7
|
-
readonly code: TenantApi.SignOutErrorCode;
|
|
8
|
-
} & {
|
|
9
|
-
readonly developerMessage: string;
|
|
10
|
-
} & {
|
|
11
|
-
readonly endUserMessage?: string | undefined;
|
|
12
|
-
}) | undefined;
|
|
13
|
-
}, {}>;
|
|
14
|
-
export type SignOutResult = ModelType<typeof signOutFragment>;
|
|
15
|
-
export declare const useSignOut: () => () => Promise<({
|
|
16
|
-
readonly ok: boolean;
|
|
17
|
-
} & {
|
|
18
|
-
readonly error?: ({
|
|
19
|
-
readonly code: TenantApi.SignOutErrorCode;
|
|
20
|
-
} & {
|
|
21
|
-
readonly developerMessage: string;
|
|
22
|
-
} & {
|
|
23
|
-
readonly endUserMessage?: string | undefined;
|
|
24
|
-
}) | undefined;
|
|
25
|
-
}) | undefined>;
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=useSignOut.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSignOut.d.ts","sourceRoot":"","sources":["../../../../src/internal/hooks/useSignOut.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,kCAAkC,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAgB,MAAM,gCAAgC,CAAA;AAGxE,QAAA,MAAM,eAAe;;;;;;;;;;MAA8D,CAAA;AAEnF,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,eAAe,CAAC,CAAA;AAE7D,eAAO,MAAM,UAAU;;;;;;;;;;eAKtB,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface Identity {
|
|
2
|
-
readonly id: string;
|
|
3
|
-
readonly person?: Person;
|
|
4
|
-
readonly projects: IdentityProject[];
|
|
5
|
-
readonly permissions: {
|
|
6
|
-
readonly canCreateProject: boolean;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
export interface Person {
|
|
10
|
-
readonly id: string;
|
|
11
|
-
readonly email?: string;
|
|
12
|
-
readonly otpEnabled: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface IdentityProject {
|
|
15
|
-
readonly slug: string;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly roles: readonly string[];
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=Identity.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Identity.d.ts","sourceRoot":"","sources":["../../../src/types/Identity.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,CAAA;IACpC,QAAQ,CAAC,WAAW,EAAE;QACrB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;KAClC,CAAA;CACD;AAED,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAC5B;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CACjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityMethods.d.ts","sourceRoot":"","sources":["../../../src/types/IdentityMethods.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC/B,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityStateValue.d.ts","sourceRoot":"","sources":["../../../src/types/IdentityStateValue.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAC3B,MAAM,GACN,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,YAAY,CAAA"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { useSessionToken } from '@contember/react-client'
|
|
2
|
-
import { ReactNode, useEffect } from 'react'
|
|
3
|
-
import { EnvironmentExtensionProvider } from '@contember/react-binding'
|
|
4
|
-
import { useFetchIdentity } from '../hooks'
|
|
5
|
-
import { IdentityContext, IdentityMethodsContext, IdentityStateContext } from '../internal/contexts'
|
|
6
|
-
import { identityEnvironmentExtension } from '../environment'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export interface IdentityProviderProps {
|
|
10
|
-
children: ReactNode
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const IdentityProvider: React.FC<IdentityProviderProps> = ({ children }) => {
|
|
14
|
-
const sessionToken = useSessionToken()
|
|
15
|
-
const [{ identity, state }, methods] = useFetchIdentity()
|
|
16
|
-
|
|
17
|
-
const { refreshIdentity, clearIdentity } = methods
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (sessionToken !== undefined) {
|
|
20
|
-
refreshIdentity()
|
|
21
|
-
}
|
|
22
|
-
}, [sessionToken, refreshIdentity])
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const hasIdentity = identity !== undefined
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (sessionToken === undefined && hasIdentity) {
|
|
28
|
-
clearIdentity()
|
|
29
|
-
}
|
|
30
|
-
}, [sessionToken, clearIdentity, hasIdentity])
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<IdentityStateContext.Provider value={state}>
|
|
34
|
-
<IdentityContext.Provider value={identity}>
|
|
35
|
-
<IdentityMethodsContext.Provider value={methods}>
|
|
36
|
-
<EnvironmentExtensionProvider extension={identityEnvironmentExtension} state={identity ?? null}>
|
|
37
|
-
{children}
|
|
38
|
-
</EnvironmentExtensionProvider>
|
|
39
|
-
</IdentityMethodsContext.Provider>
|
|
40
|
-
</IdentityContext.Provider>
|
|
41
|
-
</IdentityStateContext.Provider>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react'
|
|
2
|
-
import { IdentityStateValue } from '../types'
|
|
3
|
-
import { useIdentityState } from '../internal/contexts'
|
|
4
|
-
|
|
5
|
-
export interface IdentityStateProps {
|
|
6
|
-
state: IdentityStateValue | IdentityStateValue[]
|
|
7
|
-
children: ReactNode
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const IdentityState = ({ state, children }: IdentityStateProps) => {
|
|
11
|
-
const currentState = useIdentityState()
|
|
12
|
-
|
|
13
|
-
return state === currentState || (Array.isArray(state) && state.includes(currentState)) ? <>{children}</> : null
|
|
14
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ReactNode, useCallback } from 'react'
|
|
2
|
-
import { Slot } from '@radix-ui/react-slot'
|
|
3
|
-
import { useLogout } from '../hooks'
|
|
4
|
-
|
|
5
|
-
export const LogoutTrigger = ({ children }: {
|
|
6
|
-
children: ReactNode
|
|
7
|
-
}) => {
|
|
8
|
-
const logout = useLogout()
|
|
9
|
-
return <Slot onClick={useCallback(() => logout(), [logout])}>{children}</Slot>
|
|
10
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from 'react'
|
|
2
|
-
import { Identity, IdentityMethods, IdentityStateValue } from '../types'
|
|
3
|
-
import { useSessionToken } from '@contember/react-client'
|
|
4
|
-
import { useFetchMe } from '../internal/hooks/useFetchMe'
|
|
5
|
-
import { useLogoutInternal } from '../internal/hooks/useLogoutInternal'
|
|
6
|
-
|
|
7
|
-
export const useFetchIdentity = (): [{ state: IdentityStateValue, identity: Identity | undefined }, IdentityMethods] => {
|
|
8
|
-
const sessionToken = useSessionToken()
|
|
9
|
-
const fetchMe = useFetchMe()
|
|
10
|
-
|
|
11
|
-
const [identityState, setIdentityState] = useState<ReturnType<typeof useFetchIdentity>[0]>({ state: sessionToken ? 'loading' : 'none', identity: undefined })
|
|
12
|
-
|
|
13
|
-
const clearIdentity = useCallback(() => setIdentityState({ state: 'cleared', identity: undefined }), [])
|
|
14
|
-
const logout = useLogoutInternal(clearIdentity)
|
|
15
|
-
|
|
16
|
-
const fetch = useCallback(async () => {
|
|
17
|
-
setIdentityState({ state: 'loading', identity: undefined })
|
|
18
|
-
try {
|
|
19
|
-
const response = await fetchMe()
|
|
20
|
-
const person = response.person
|
|
21
|
-
const projects = response.projects
|
|
22
|
-
const permissions = response.permissions ?? { canCreateProject: false }
|
|
23
|
-
|
|
24
|
-
setIdentityState({
|
|
25
|
-
state: 'success',
|
|
26
|
-
identity: {
|
|
27
|
-
id: response.id,
|
|
28
|
-
person: person ?? undefined,
|
|
29
|
-
projects: projects.map(it => ({
|
|
30
|
-
name: it.project.name,
|
|
31
|
-
slug: it.project.slug,
|
|
32
|
-
roles: it.memberships.map(it => it.role),
|
|
33
|
-
})),
|
|
34
|
-
permissions,
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
} catch (e) {
|
|
38
|
-
console.error(e)
|
|
39
|
-
if (typeof e === 'object' && e !== null && 'status' in e && (e as { status?: unknown }).status === 401) {
|
|
40
|
-
logout({ noRedirect: true })
|
|
41
|
-
setIdentityState({ state: 'cleared', identity: undefined })
|
|
42
|
-
} else {
|
|
43
|
-
setIdentityState({ state: 'failed', identity: undefined })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}, [fetchMe, logout])
|
|
47
|
-
|
|
48
|
-
return [
|
|
49
|
-
identityState,
|
|
50
|
-
useMemo((): IdentityMethods => ({
|
|
51
|
-
clearIdentity,
|
|
52
|
-
refreshIdentity: fetch,
|
|
53
|
-
}), [clearIdentity, fetch]),
|
|
54
|
-
]
|
|
55
|
-
}
|
package/src/hooks/useLogout.ts
DELETED
package/src/internal/contexts.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createContext, createRequiredContext } from '@contember/react-utils'
|
|
2
|
-
import { IdentityMethods } from '../types/IdentityMethods'
|
|
3
|
-
import { Identity } from '../types/Identity'
|
|
4
|
-
import { IdentityStateValue } from '../types/IdentityStateValue'
|
|
5
|
-
|
|
6
|
-
export const [IdentityContext, useIdentity] = createContext<Identity | undefined>('IdentityContext', undefined)
|
|
7
|
-
export const [IdentityMethodsContext, useIdentityMethods] = createRequiredContext<IdentityMethods>('IdentityMethodsContext')
|
|
8
|
-
export const [IdentityStateContext, useIdentityState] = createRequiredContext<IdentityStateValue>('IdentityStateContext')
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as TenantApi from '@contember/graphql-client-tenant'
|
|
2
|
-
import { ModelType, useTenantApi } from '@contember/react-client-tenant'
|
|
3
|
-
import { useCallback } from 'react'
|
|
4
|
-
|
|
5
|
-
const identityFragment = TenantApi
|
|
6
|
-
.identity$$
|
|
7
|
-
.person(TenantApi.person$$)
|
|
8
|
-
.projects(TenantApi
|
|
9
|
-
.identityProjectRelation$
|
|
10
|
-
.project(TenantApi.project$$)
|
|
11
|
-
.memberships(TenantApi.membership$$.variables(TenantApi.variableEntry$$)),
|
|
12
|
-
)
|
|
13
|
-
.permissions(TenantApi.identityGlobalPermissions$$)
|
|
14
|
-
|
|
15
|
-
export type FetchedIdentity = ModelType<typeof identityFragment>
|
|
16
|
-
|
|
17
|
-
export const useFetchMe = () => {
|
|
18
|
-
const executor = useTenantApi()
|
|
19
|
-
return useCallback(async () => {
|
|
20
|
-
return (await executor(TenantApi.query$.me(identityFragment))).me
|
|
21
|
-
}, [executor])
|
|
22
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { useSetSessionToken } from '@contember/react-client'
|
|
2
|
-
import { useCallback } from 'react'
|
|
3
|
-
import { useSignOut } from './useSignOut'
|
|
4
|
-
|
|
5
|
-
export const useLogoutInternal = (clearIdentity?: () => void) => {
|
|
6
|
-
const tenantLogout = useSignOut()
|
|
7
|
-
const setSessionToken = useSetSessionToken()
|
|
8
|
-
|
|
9
|
-
return useCallback(
|
|
10
|
-
async ({ noRedirect = false }: { noRedirect?: boolean } = {}) => {
|
|
11
|
-
if (navigator.credentials && navigator.credentials.preventSilentAccess) {
|
|
12
|
-
try {
|
|
13
|
-
await navigator.credentials.preventSilentAccess()
|
|
14
|
-
} catch {
|
|
15
|
-
// actually, not implemented in safari:
|
|
16
|
-
// https://github.com/WebKit/WebKit/blob/414f4e45b0e82bbfcee783d08a9642be1afa8f72/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp#L132
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
clearIdentity?.()
|
|
20
|
-
setSessionToken(undefined)
|
|
21
|
-
try {
|
|
22
|
-
const response = await tenantLogout()
|
|
23
|
-
if (!response?.ok) {
|
|
24
|
-
console.warn(response?.error)
|
|
25
|
-
}
|
|
26
|
-
} catch (e) {
|
|
27
|
-
console.warn(e)
|
|
28
|
-
}
|
|
29
|
-
if (!noRedirect) {
|
|
30
|
-
window.location.href = '/' // todo better redirect?
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
[clearIdentity, setSessionToken, tenantLogout],
|
|
34
|
-
)
|
|
35
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as TenantApi from '@contember/graphql-client-tenant'
|
|
2
|
-
import { ModelType, useTenantApi } from '@contember/react-client-tenant'
|
|
3
|
-
import { useCallback } from 'react'
|
|
4
|
-
|
|
5
|
-
const signOutFragment = TenantApi.signOutResponse$$.error(TenantApi.signOutError$$)
|
|
6
|
-
|
|
7
|
-
export type SignOutResult = ModelType<typeof signOutFragment>
|
|
8
|
-
|
|
9
|
-
export const useSignOut = () => {
|
|
10
|
-
const api = useTenantApi()
|
|
11
|
-
return useCallback(async () => {
|
|
12
|
-
return (await api(TenantApi.mutation$.signOut(signOutFragment))).signOut
|
|
13
|
-
}, [api])
|
|
14
|
-
}
|
package/src/types/Identity.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface Identity {
|
|
2
|
-
readonly id: string
|
|
3
|
-
readonly person?: Person
|
|
4
|
-
readonly projects: IdentityProject[]
|
|
5
|
-
readonly permissions: {
|
|
6
|
-
readonly canCreateProject: boolean
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface Person {
|
|
11
|
-
readonly id: string
|
|
12
|
-
readonly email?: string
|
|
13
|
-
readonly otpEnabled: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface IdentityProject {
|
|
17
|
-
readonly slug: string
|
|
18
|
-
readonly name: string
|
|
19
|
-
readonly roles: readonly string[]
|
|
20
|
-
}
|
package/src/types/index.ts
DELETED