@cedarjs/auth 6.0.0-canary.2780 → 6.0.0-canary.2782

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.
Files changed (60) hide show
  1. package/package.json +16 -53
  2. package/dist/cjs/AuthContext.d.ts +0 -69
  3. package/dist/cjs/AuthContext.d.ts.map +0 -1
  4. package/dist/cjs/AuthContext.js +0 -41
  5. package/dist/cjs/AuthImplementation.d.ts +0 -49
  6. package/dist/cjs/AuthImplementation.d.ts.map +0 -1
  7. package/dist/cjs/AuthImplementation.js +0 -16
  8. package/dist/cjs/AuthProvider/AuthProvider.d.ts +0 -12
  9. package/dist/cjs/AuthProvider/AuthProvider.d.ts.map +0 -1
  10. package/dist/cjs/AuthProvider/AuthProvider.js +0 -117
  11. package/dist/cjs/AuthProvider/AuthProviderState.d.ts +0 -13
  12. package/dist/cjs/AuthProvider/AuthProviderState.d.ts.map +0 -1
  13. package/dist/cjs/AuthProvider/AuthProviderState.js +0 -43
  14. package/dist/cjs/AuthProvider/ServerAuthProvider.d.ts +0 -23
  15. package/dist/cjs/AuthProvider/ServerAuthProvider.d.ts.map +0 -1
  16. package/dist/cjs/AuthProvider/ServerAuthProvider.js +0 -78
  17. package/dist/cjs/AuthProvider/useCurrentUser.d.ts +0 -3
  18. package/dist/cjs/AuthProvider/useCurrentUser.d.ts.map +0 -1
  19. package/dist/cjs/AuthProvider/useCurrentUser.js +0 -55
  20. package/dist/cjs/AuthProvider/useForgotPassword.d.ts +0 -3
  21. package/dist/cjs/AuthProvider/useForgotPassword.d.ts.map +0 -1
  22. package/dist/cjs/AuthProvider/useForgotPassword.js +0 -42
  23. package/dist/cjs/AuthProvider/useHasRole.d.ts +0 -3
  24. package/dist/cjs/AuthProvider/useHasRole.d.ts.map +0 -1
  25. package/dist/cjs/AuthProvider/useHasRole.js +0 -58
  26. package/dist/cjs/AuthProvider/useLogIn.d.ts +0 -5
  27. package/dist/cjs/AuthProvider/useLogIn.d.ts.map +0 -1
  28. package/dist/cjs/AuthProvider/useLogIn.js +0 -46
  29. package/dist/cjs/AuthProvider/useLogOut.d.ts +0 -4
  30. package/dist/cjs/AuthProvider/useLogOut.d.ts.map +0 -1
  31. package/dist/cjs/AuthProvider/useLogOut.js +0 -45
  32. package/dist/cjs/AuthProvider/useReauthenticate.d.ts +0 -5
  33. package/dist/cjs/AuthProvider/useReauthenticate.d.ts.map +0 -1
  34. package/dist/cjs/AuthProvider/useReauthenticate.js +0 -81
  35. package/dist/cjs/AuthProvider/useResetPassword.d.ts +0 -3
  36. package/dist/cjs/AuthProvider/useResetPassword.d.ts.map +0 -1
  37. package/dist/cjs/AuthProvider/useResetPassword.js +0 -42
  38. package/dist/cjs/AuthProvider/useSignUp.d.ts +0 -5
  39. package/dist/cjs/AuthProvider/useSignUp.d.ts.map +0 -1
  40. package/dist/cjs/AuthProvider/useSignUp.js +0 -44
  41. package/dist/cjs/AuthProvider/useToken.d.ts +0 -3
  42. package/dist/cjs/AuthProvider/useToken.d.ts.map +0 -1
  43. package/dist/cjs/AuthProvider/useToken.js +0 -39
  44. package/dist/cjs/AuthProvider/useValidateResetToken.d.ts +0 -3
  45. package/dist/cjs/AuthProvider/useValidateResetToken.d.ts.map +0 -1
  46. package/dist/cjs/AuthProvider/useValidateResetToken.js +0 -42
  47. package/dist/cjs/authFactory.d.ts +0 -15
  48. package/dist/cjs/authFactory.d.ts.map +0 -1
  49. package/dist/cjs/authFactory.js +0 -40
  50. package/dist/cjs/getCurrentUserFromMiddleware.d.ts +0 -2
  51. package/dist/cjs/getCurrentUserFromMiddleware.d.ts.map +0 -1
  52. package/dist/cjs/getCurrentUserFromMiddleware.js +0 -47
  53. package/dist/cjs/index.d.ts +0 -11
  54. package/dist/cjs/index.d.ts.map +0 -1
  55. package/dist/cjs/index.js +0 -39
  56. package/dist/cjs/package.json +0 -1
  57. package/dist/cjs/useAuth.d.ts +0 -6
  58. package/dist/cjs/useAuth.d.ts.map +0 -1
  59. package/dist/cjs/useAuth.js +0 -78
  60. package/dist/package.json +0 -1
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useCurrentUser_exports = {};
20
- __export(useCurrentUser_exports, {
21
- useCurrentUser: () => useCurrentUser
22
- });
23
- module.exports = __toCommonJS(useCurrentUser_exports);
24
- var import_react = require("react");
25
- var import_useToken = require("./useToken.js");
26
- const useCurrentUser = (authImplementation) => {
27
- const getToken = (0, import_useToken.useToken)(authImplementation);
28
- return (0, import_react.useCallback)(async () => {
29
- const token = await getToken();
30
- const response = await globalThis.fetch(globalThis.RWJS_API_GRAPHQL_URL, {
31
- method: "POST",
32
- credentials: "include",
33
- headers: {
34
- "content-type": "application/json",
35
- "auth-provider": authImplementation.type,
36
- authorization: `Bearer ${token}`
37
- },
38
- body: JSON.stringify({
39
- query: "query __CEDAR__AUTH_GET_CURRENT_USER { cedar { currentUser } }"
40
- })
41
- });
42
- if (response.ok) {
43
- const { data } = await response.json();
44
- return data?.cedar?.currentUser;
45
- } else {
46
- throw new Error(
47
- `Could not fetch current user: ${response.statusText} (${response.status})`
48
- );
49
- }
50
- }, [authImplementation, getToken]);
51
- };
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- useCurrentUser
55
- });
@@ -1,3 +0,0 @@
1
- import type { AuthImplementation } from '../AuthImplementation.js';
2
- export declare const useForgotPassword: <TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>(authImplementation: AuthImplementation<TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>) => (username: string) => Promise<TForgotPassword>;
3
- //# sourceMappingURL=useForgotPassword.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useForgotPassword.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useForgotPassword.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,eAAO,MAAM,iBAAiB,GAC5B,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,EAEP,oBAAoB,kBAAkB,CACpC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,CACR,gBAGkB,MAAM,6BAW1B,CAAA"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useForgotPassword_exports = {};
20
- __export(useForgotPassword_exports, {
21
- useForgotPassword: () => useForgotPassword
22
- });
23
- module.exports = __toCommonJS(useForgotPassword_exports);
24
- var import_react = require("react");
25
- const useForgotPassword = (authImplementation) => {
26
- return (0, import_react.useCallback)(
27
- async (username) => {
28
- if (authImplementation.forgotPassword) {
29
- return await authImplementation.forgotPassword(username);
30
- } else {
31
- throw new Error(
32
- `Auth client ${authImplementation.type} does not implement this function`
33
- );
34
- }
35
- },
36
- [authImplementation]
37
- );
38
- };
39
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- useForgotPassword
42
- });
@@ -1,3 +0,0 @@
1
- import type { CurrentUser } from '../AuthContext.js';
2
- export declare const useHasRole: (currentUser: CurrentUser | null) => (rolesToCheck: string | string[]) => boolean;
3
- //# sourceMappingURL=useHasRole.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useHasRole.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useHasRole.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,eAAO,MAAM,UAAU,GAAI,aAAa,WAAW,GAAG,IAAI,oBAevC,MAAM,GAAG,MAAM,EAAE,KAAG,OAiCtC,CAAA"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useHasRole_exports = {};
20
- __export(useHasRole_exports, {
21
- useHasRole: () => useHasRole
22
- });
23
- module.exports = __toCommonJS(useHasRole_exports);
24
- var import_react = require("react");
25
- const useHasRole = (currentUser) => {
26
- return (0, import_react.useCallback)(
27
- (rolesToCheck) => {
28
- if (currentUser?.roles) {
29
- if (typeof rolesToCheck === "string") {
30
- if (typeof currentUser.roles === "string") {
31
- return currentUser.roles === rolesToCheck;
32
- } else if (Array.isArray(currentUser.roles)) {
33
- return currentUser.roles?.some(
34
- (allowedRole) => rolesToCheck === allowedRole
35
- );
36
- }
37
- }
38
- if (Array.isArray(rolesToCheck)) {
39
- if (Array.isArray(currentUser.roles)) {
40
- return currentUser.roles?.some(
41
- (allowedRole) => rolesToCheck.includes(allowedRole)
42
- );
43
- } else if (typeof currentUser.roles === "string") {
44
- return rolesToCheck.some(
45
- (allowedRole) => currentUser?.roles === allowedRole
46
- );
47
- }
48
- }
49
- }
50
- return false;
51
- },
52
- [currentUser]
53
- );
54
- };
55
- // Annotate the CommonJS export names for ESM import in node:
56
- 0 && (module.exports = {
57
- useHasRole
58
- });
@@ -1,5 +0,0 @@
1
- import type { AuthImplementation } from '../AuthImplementation.js';
2
- import type { AuthProviderState } from './AuthProviderState.js';
3
- import type { useCurrentUser } from './useCurrentUser.js';
4
- export declare const useLogIn: <TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>(authImplementation: AuthImplementation<TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>, setAuthProviderState: React.Dispatch<React.SetStateAction<AuthProviderState<TUser>>>, getCurrentUser: ReturnType<typeof useCurrentUser>) => (options?: TLogInOptions) => Promise<TLogIn>;
5
- //# sourceMappingURL=useLogIn.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLogIn.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useLogIn.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGzD,eAAO,MAAM,QAAQ,GACnB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,EAEP,oBAAoB,kBAAkB,CACpC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,CACR,EACD,sBAAsB,KAAK,CAAC,QAAQ,CAClC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAC/C,EACD,gBAAgB,UAAU,CAAC,OAAO,cAAc,CAAC,gBAS9B,aAAa,oBASjC,CAAA"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useLogIn_exports = {};
20
- __export(useLogIn_exports, {
21
- useLogIn: () => useLogIn
22
- });
23
- module.exports = __toCommonJS(useLogIn_exports);
24
- var import_react = require("react");
25
- var import_AuthProviderState = require("./AuthProviderState.js");
26
- var import_useReauthenticate = require("./useReauthenticate.js");
27
- const useLogIn = (authImplementation, setAuthProviderState, getCurrentUser) => {
28
- const reauthenticate = (0, import_useReauthenticate.useReauthenticate)(
29
- authImplementation,
30
- setAuthProviderState,
31
- getCurrentUser
32
- );
33
- return (0, import_react.useCallback)(
34
- async (options) => {
35
- setAuthProviderState(import_AuthProviderState.spaDefaultAuthProviderState);
36
- const loginResult = await authImplementation.login(options);
37
- await reauthenticate();
38
- return loginResult;
39
- },
40
- [authImplementation, reauthenticate, setAuthProviderState]
41
- );
42
- };
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- useLogIn
46
- });
@@ -1,4 +0,0 @@
1
- import type { AuthImplementation } from '../AuthImplementation.js';
2
- import type { AuthProviderState } from './AuthProviderState.js';
3
- export declare const useLogOut: <TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>(authImplementation: AuthImplementation<TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>, setAuthProviderState: React.Dispatch<React.SetStateAction<AuthProviderState<TUser>>>) => (options?: TLogOutOptions) => Promise<TLogOut>;
4
- //# sourceMappingURL=useLogOut.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLogOut.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useLogOut.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,eAAO,MAAM,SAAS,GACpB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,EAEP,oBAAoB,kBAAkB,CACpC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,CACR,EACD,sBAAsB,KAAK,CAAC,QAAQ,CAClC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAC/C,gBAGkB,cAAc,qBAgBlC,CAAA"}
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useLogOut_exports = {};
20
- __export(useLogOut_exports, {
21
- useLogOut: () => useLogOut
22
- });
23
- module.exports = __toCommonJS(useLogOut_exports);
24
- var import_react = require("react");
25
- const useLogOut = (authImplementation, setAuthProviderState) => {
26
- return (0, import_react.useCallback)(
27
- async (options) => {
28
- const logoutOutput = await authImplementation.logout(options);
29
- setAuthProviderState({
30
- userMetadata: null,
31
- currentUser: null,
32
- isAuthenticated: false,
33
- hasError: false,
34
- error: void 0,
35
- loading: false
36
- });
37
- return logoutOutput;
38
- },
39
- [authImplementation, setAuthProviderState]
40
- );
41
- };
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- useLogOut
45
- });
@@ -1,5 +0,0 @@
1
- import type { AuthImplementation } from '../AuthImplementation.js';
2
- import type { AuthProviderState } from './AuthProviderState.js';
3
- import type { useCurrentUser } from './useCurrentUser.js';
4
- export declare const useReauthenticate: <TUser>(authImplementation: AuthImplementation<TUser>, setAuthProviderState: React.Dispatch<React.SetStateAction<AuthProviderState<TUser>>>, getCurrentUser: ReturnType<typeof useCurrentUser>) => () => Promise<void>;
5
- //# sourceMappingURL=useReauthenticate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useReauthenticate.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useReauthenticate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAWzD,eAAO,MAAM,iBAAiB,GAAI,KAAK,EACrC,oBAAoB,kBAAkB,CAAC,KAAK,CAAC,EAC7C,sBAAsB,KAAK,CAAC,QAAQ,CAClC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAC/C,EACD,gBAAgB,UAAU,CAAC,OAAO,cAAc,CAAC,wBA0DlD,CAAA"}
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useReauthenticate_exports = {};
20
- __export(useReauthenticate_exports, {
21
- useReauthenticate: () => useReauthenticate
22
- });
23
- module.exports = __toCommonJS(useReauthenticate_exports);
24
- var import_react = require("react");
25
- var import_useToken = require("./useToken.js");
26
- const notAuthenticatedState = {
27
- isAuthenticated: false,
28
- currentUser: null,
29
- userMetadata: null,
30
- loading: false,
31
- hasError: false
32
- };
33
- const useReauthenticate = (authImplementation, setAuthProviderState, getCurrentUser) => {
34
- const getToken = (0, import_useToken.useToken)(authImplementation);
35
- return (0, import_react.useCallback)(async () => {
36
- if (authImplementation.loadWhileReauthenticating) {
37
- setAuthProviderState((oldState) => ({
38
- ...oldState,
39
- loading: true
40
- }));
41
- }
42
- try {
43
- const token = await getToken();
44
- let currentUser;
45
- if (token || authImplementation.middlewareAuthEnabled) {
46
- currentUser = await getCurrentUser();
47
- }
48
- if (!currentUser) {
49
- let loading = false;
50
- if (authImplementation.clientHasLoaded) {
51
- loading = !authImplementation.clientHasLoaded();
52
- }
53
- setAuthProviderState({
54
- ...notAuthenticatedState,
55
- loading,
56
- client: authImplementation.client
57
- });
58
- } else {
59
- const userMetadata = await authImplementation.getUserMetadata();
60
- setAuthProviderState((oldState) => ({
61
- ...oldState,
62
- userMetadata,
63
- currentUser,
64
- isAuthenticated: !!currentUser,
65
- loading: false,
66
- client: authImplementation.client
67
- }));
68
- }
69
- } catch (e) {
70
- setAuthProviderState({
71
- ...notAuthenticatedState,
72
- hasError: true,
73
- error: e
74
- });
75
- }
76
- }, [authImplementation, setAuthProviderState, getToken, getCurrentUser]);
77
- };
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- useReauthenticate
81
- });
@@ -1,3 +0,0 @@
1
- import type { AuthImplementation } from '../AuthImplementation.js';
2
- export declare const useResetPassword: <TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>(authImplementation: AuthImplementation<TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>) => (options?: TResetPasswordOptions) => Promise<TResetPassword>;
3
- //# sourceMappingURL=useResetPassword.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useResetPassword.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useResetPassword.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,eAAO,MAAM,gBAAgB,GAC3B,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,EAEP,oBAAoB,kBAAkB,CACpC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,CACR,gBAGkB,qBAAqB,4BAWzC,CAAA"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useResetPassword_exports = {};
20
- __export(useResetPassword_exports, {
21
- useResetPassword: () => useResetPassword
22
- });
23
- module.exports = __toCommonJS(useResetPassword_exports);
24
- var import_react = require("react");
25
- const useResetPassword = (authImplementation) => {
26
- return (0, import_react.useCallback)(
27
- async (options) => {
28
- if (authImplementation.resetPassword) {
29
- return await authImplementation.resetPassword(options);
30
- } else {
31
- throw new Error(
32
- `Auth client ${authImplementation.type} does not implement this function`
33
- );
34
- }
35
- },
36
- [authImplementation]
37
- );
38
- };
39
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- useResetPassword
42
- });
@@ -1,5 +0,0 @@
1
- import type { AuthImplementation } from '../AuthImplementation.js';
2
- import type { AuthProviderState } from './AuthProviderState.js';
3
- import type { useCurrentUser } from './useCurrentUser.js';
4
- export declare const useSignUp: <TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>(authImplementation: AuthImplementation<TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>, setAuthProviderState: React.Dispatch<React.SetStateAction<AuthProviderState<TUser>>>, getCurrentUser: ReturnType<typeof useCurrentUser>) => (options?: TSignUpOptions) => Promise<TSignUp>;
5
- //# sourceMappingURL=useSignUp.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSignUp.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useSignUp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGzD,eAAO,MAAM,SAAS,GACpB,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,EAEP,oBAAoB,kBAAkB,CACpC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,CACR,EACD,sBAAsB,KAAK,CAAC,QAAQ,CAClC,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAC/C,EACD,gBAAgB,UAAU,CAAC,OAAO,cAAc,CAAC,gBAS9B,cAAc,qBAOlC,CAAA"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useSignUp_exports = {};
20
- __export(useSignUp_exports, {
21
- useSignUp: () => useSignUp
22
- });
23
- module.exports = __toCommonJS(useSignUp_exports);
24
- var import_react = require("react");
25
- var import_useReauthenticate = require("./useReauthenticate.js");
26
- const useSignUp = (authImplementation, setAuthProviderState, getCurrentUser) => {
27
- const reauthenticate = (0, import_useReauthenticate.useReauthenticate)(
28
- authImplementation,
29
- setAuthProviderState,
30
- getCurrentUser
31
- );
32
- return (0, import_react.useCallback)(
33
- async (options) => {
34
- const signupOutput = await authImplementation.signup(options);
35
- await reauthenticate();
36
- return signupOutput;
37
- },
38
- [authImplementation, reauthenticate]
39
- );
40
- };
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- useSignUp
44
- });
@@ -1,3 +0,0 @@
1
- import type { AuthImplementation } from '../AuthImplementation.js';
2
- export declare const useToken: (authImplementation: AuthImplementation) => () => Promise<string | null>;
3
- //# sourceMappingURL=useToken.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useToken.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useToken.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,eAAO,MAAM,QAAQ,GAAI,oBAAoB,kBAAkB,iCAgB9D,CAAA"}
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useToken_exports = {};
20
- __export(useToken_exports, {
21
- useToken: () => useToken
22
- });
23
- module.exports = __toCommonJS(useToken_exports);
24
- var import_react = require("react");
25
- const useToken = (authImplementation) => {
26
- return (0, import_react.useCallback)(async () => {
27
- try {
28
- const token = await authImplementation.getToken();
29
- return token;
30
- } catch (e) {
31
- console.error("Caught internal:", e);
32
- return null;
33
- }
34
- }, [authImplementation]);
35
- };
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {
38
- useToken
39
- });
@@ -1,3 +0,0 @@
1
- import type { AuthImplementation } from '../AuthImplementation.js';
2
- export declare const useValidateResetToken: <TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>(authImplementation: AuthImplementation<TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>) => (resetToken: string | null) => Promise<TValidateResetToken>;
3
- //# sourceMappingURL=useValidateResetToken.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useValidateResetToken.d.ts","sourceRoot":"","sources":["../../../src/AuthProvider/useValidateResetToken.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE,eAAO,MAAM,qBAAqB,GAChC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,EAEP,oBAAoB,kBAAkB,CACpC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,CACR,kBAGoB,MAAM,GAAG,IAAI,iCAWnC,CAAA"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var useValidateResetToken_exports = {};
20
- __export(useValidateResetToken_exports, {
21
- useValidateResetToken: () => useValidateResetToken
22
- });
23
- module.exports = __toCommonJS(useValidateResetToken_exports);
24
- var import_react = require("react");
25
- const useValidateResetToken = (authImplementation) => {
26
- return (0, import_react.useCallback)(
27
- async (resetToken) => {
28
- if (authImplementation.validateResetToken) {
29
- return await authImplementation.validateResetToken(resetToken);
30
- } else {
31
- throw new Error(
32
- `Auth client ${authImplementation.type} does not implement this function`
33
- );
34
- }
35
- },
36
- [authImplementation]
37
- );
38
- };
39
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- useValidateResetToken
42
- });
@@ -1,15 +0,0 @@
1
- import type { CurrentUser } from './AuthContext.js';
2
- import type { AuthImplementation } from './AuthImplementation.js';
3
- export type CustomProviderHooks = {
4
- useCurrentUser?: () => Promise<CurrentUser>;
5
- useHasRole?: (currentUser: CurrentUser | null) => (rolesToCheck: string | string[]) => boolean;
6
- };
7
- export declare function createAuthentication<TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>(authImplementation: AuthImplementation<TUser, TRestoreAuth, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>, customProviderHooks?: {
8
- useCurrentUser?: () => Promise<CurrentUser>;
9
- useHasRole?: (currentUser: CurrentUser | null) => (rolesToCheck: string | string[]) => boolean;
10
- }): {
11
- AuthContext: import("react").Context<import("./AuthContext.js").AuthContextInterface<TUser, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient> | undefined>;
12
- AuthProvider: ({ children }: import("./AuthProvider/AuthProvider.js").AuthProviderProps) => import("react").JSX.Element;
13
- useAuth: () => import("./AuthContext.js").AuthContextInterface<TUser, TLogInOptions, TLogIn, TLogOutOptions, TLogOut, TSignUpOptions, TSignUp, TForgotPassword, TResetPasswordOptions, TResetPassword, TValidateResetToken, TClient>;
14
- };
15
- //# sourceMappingURL=authFactory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authFactory.d.ts","sourceRoot":"","sources":["../../src/authFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAIjE,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,UAAU,CAAC,EAAE,CACX,WAAW,EAAE,WAAW,GAAG,IAAI,KAC5B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAA;CAClD,CAAA;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,EAEP,kBAAkB,EAAE,kBAAkB,CACpC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,MAAM,EACN,cAAc,EACd,OAAO,EACP,cAAc,EACd,OAAO,EACP,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,CACR,EACD,mBAAmB,CAAC,EAAE;IACpB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,UAAU,CAAC,EAAE,CACX,WAAW,EAAE,WAAW,GAAG,IAAI,KAC5B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,OAAO,CAAA;CAClD;;;;EAwBF"}