naystack 1.2.9 → 1.2.13
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.
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,44 +15,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/auth/email/client.ts
|
|
31
21
|
var client_exports = {};
|
|
32
22
|
__export(client_exports, {
|
|
33
|
-
getEmailAuthUtils: () => getEmailAuthUtils
|
|
34
|
-
useLoginWithEmail: () => useLoginWithEmail,
|
|
35
|
-
useLogout: () => useLogout,
|
|
36
|
-
useSignUpWithEmail: () => useSignUpWithEmail
|
|
23
|
+
getEmailAuthUtils: () => getEmailAuthUtils
|
|
37
24
|
});
|
|
38
25
|
module.exports = __toCommonJS(client_exports);
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
// src/graphql/client.tsx
|
|
42
|
-
var import_client = require("@apollo/client");
|
|
43
|
-
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
44
|
-
var import_react = __toESM(require("react"));
|
|
45
|
-
var TokenContext = (0, import_react.createContext)({
|
|
46
|
-
token: null,
|
|
47
|
-
setToken: () => null
|
|
48
|
-
});
|
|
49
|
-
function useSetToken() {
|
|
50
|
-
const { setToken } = (0, import_react.useContext)(TokenContext);
|
|
51
|
-
return setToken;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// src/auth/email/client.ts
|
|
26
|
+
var import_client = require("naystack/graphql/client");
|
|
27
|
+
var import_react = require("react");
|
|
55
28
|
function useSignUpWithEmail(endpoint) {
|
|
56
|
-
const setToken = useSetToken();
|
|
57
|
-
return (0,
|
|
29
|
+
const setToken = (0, import_client.useSetToken)();
|
|
30
|
+
return (0, import_react.useCallback)(
|
|
58
31
|
async (data) => {
|
|
59
32
|
const res = await fetch(endpoint, {
|
|
60
33
|
method: "POST",
|
|
@@ -72,9 +45,8 @@ function useSignUpWithEmail(endpoint) {
|
|
|
72
45
|
);
|
|
73
46
|
}
|
|
74
47
|
function useLoginWithEmail(endpoint) {
|
|
75
|
-
const setToken = useSetToken();
|
|
76
|
-
|
|
77
|
-
return (0, import_react2.useCallback)(
|
|
48
|
+
const setToken = (0, import_client.useSetToken)();
|
|
49
|
+
return (0, import_react.useCallback)(
|
|
78
50
|
async (data) => {
|
|
79
51
|
const res = await fetch(endpoint, {
|
|
80
52
|
method: "PUT",
|
|
@@ -92,9 +64,8 @@ function useLoginWithEmail(endpoint) {
|
|
|
92
64
|
);
|
|
93
65
|
}
|
|
94
66
|
function useLogout(endpoint) {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
return (0, import_react2.useCallback)(
|
|
67
|
+
const setToken = (0, import_client.useSetToken)();
|
|
68
|
+
return (0, import_react.useCallback)(
|
|
98
69
|
async (data) => {
|
|
99
70
|
setToken(null);
|
|
100
71
|
await fetch(endpoint, {
|
|
@@ -115,8 +86,5 @@ function getEmailAuthUtils(endpoint) {
|
|
|
115
86
|
}
|
|
116
87
|
// Annotate the CommonJS export names for ESM import in node:
|
|
117
88
|
0 && (module.exports = {
|
|
118
|
-
getEmailAuthUtils
|
|
119
|
-
useLoginWithEmail,
|
|
120
|
-
useLogout,
|
|
121
|
-
useSignUpWithEmail
|
|
89
|
+
getEmailAuthUtils
|
|
122
90
|
});
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
declare function useSignUpWithEmail(endpoint: string): (data: object) => Promise<string | null>;
|
|
2
|
-
declare function useLoginWithEmail(endpoint: string): (data: object) => Promise<string | null>;
|
|
3
|
-
declare function useLogout(endpoint: string): (data?: object) => Promise<void>;
|
|
4
1
|
declare function getEmailAuthUtils(endpoint: string): {
|
|
5
2
|
useSignUp: () => (data: object) => Promise<string | null>;
|
|
6
3
|
useLogin: () => (data: object) => Promise<string | null>;
|
|
7
4
|
useLogout: () => (data?: object) => Promise<void>;
|
|
8
5
|
};
|
|
9
6
|
|
|
10
|
-
export { getEmailAuthUtils
|
|
7
|
+
export { getEmailAuthUtils };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
declare function useSignUpWithEmail(endpoint: string): (data: object) => Promise<string | null>;
|
|
2
|
-
declare function useLoginWithEmail(endpoint: string): (data: object) => Promise<string | null>;
|
|
3
|
-
declare function useLogout(endpoint: string): (data?: object) => Promise<void>;
|
|
4
1
|
declare function getEmailAuthUtils(endpoint: string): {
|
|
5
2
|
useSignUp: () => (data: object) => Promise<string | null>;
|
|
6
3
|
useLogin: () => (data: object) => Promise<string | null>;
|
|
7
4
|
useLogout: () => (data?: object) => Promise<void>;
|
|
8
5
|
};
|
|
9
6
|
|
|
10
|
-
export { getEmailAuthUtils
|
|
7
|
+
export { getEmailAuthUtils };
|
|
@@ -1,37 +1,9 @@
|
|
|
1
1
|
// src/auth/email/client.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
// src/graphql/client.tsx
|
|
5
|
-
import {
|
|
6
|
-
HttpLink,
|
|
7
|
-
useLazyQuery,
|
|
8
|
-
useMutation
|
|
9
|
-
} from "@apollo/client";
|
|
10
|
-
import {
|
|
11
|
-
ApolloClient,
|
|
12
|
-
ApolloNextAppProvider,
|
|
13
|
-
InMemoryCache
|
|
14
|
-
} from "@apollo/client-integration-nextjs";
|
|
15
|
-
import React, {
|
|
16
|
-
createContext,
|
|
17
|
-
useCallback,
|
|
18
|
-
useContext,
|
|
19
|
-
useEffect,
|
|
20
|
-
useState
|
|
21
|
-
} from "react";
|
|
22
|
-
var TokenContext = createContext({
|
|
23
|
-
token: null,
|
|
24
|
-
setToken: () => null
|
|
25
|
-
});
|
|
26
|
-
function useSetToken() {
|
|
27
|
-
const { setToken } = useContext(TokenContext);
|
|
28
|
-
return setToken;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// src/auth/email/client.ts
|
|
2
|
+
import { useSetToken } from "naystack/graphql/client";
|
|
3
|
+
import { useCallback } from "react";
|
|
32
4
|
function useSignUpWithEmail(endpoint) {
|
|
33
5
|
const setToken = useSetToken();
|
|
34
|
-
return
|
|
6
|
+
return useCallback(
|
|
35
7
|
async (data) => {
|
|
36
8
|
const res = await fetch(endpoint, {
|
|
37
9
|
method: "POST",
|
|
@@ -50,8 +22,7 @@ function useSignUpWithEmail(endpoint) {
|
|
|
50
22
|
}
|
|
51
23
|
function useLoginWithEmail(endpoint) {
|
|
52
24
|
const setToken = useSetToken();
|
|
53
|
-
|
|
54
|
-
return useCallback2(
|
|
25
|
+
return useCallback(
|
|
55
26
|
async (data) => {
|
|
56
27
|
const res = await fetch(endpoint, {
|
|
57
28
|
method: "PUT",
|
|
@@ -69,9 +40,8 @@ function useLoginWithEmail(endpoint) {
|
|
|
69
40
|
);
|
|
70
41
|
}
|
|
71
42
|
function useLogout(endpoint) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
return useCallback2(
|
|
43
|
+
const setToken = useSetToken();
|
|
44
|
+
return useCallback(
|
|
75
45
|
async (data) => {
|
|
76
46
|
setToken(null);
|
|
77
47
|
await fetch(endpoint, {
|
|
@@ -91,8 +61,5 @@ function getEmailAuthUtils(endpoint) {
|
|
|
91
61
|
};
|
|
92
62
|
}
|
|
93
63
|
export {
|
|
94
|
-
getEmailAuthUtils
|
|
95
|
-
useLoginWithEmail,
|
|
96
|
-
useLogout,
|
|
97
|
-
useSignUpWithEmail
|
|
64
|
+
getEmailAuthUtils
|
|
98
65
|
};
|