naystack 1.2.8 → 1.2.12
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,14 +15,6 @@ 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
|
|
@@ -36,22 +26,11 @@ __export(client_exports, {
|
|
|
36
26
|
useSignUpWithEmail: () => useSignUpWithEmail
|
|
37
27
|
});
|
|
38
28
|
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
|
-
|
|
50
|
-
// src/auth/email/client.ts
|
|
29
|
+
var import_client = require("naystack/graphql/client");
|
|
30
|
+
var import_react = require("react");
|
|
51
31
|
function useSignUpWithEmail(endpoint) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
return (0, import_react2.useCallback)(
|
|
32
|
+
const setToken = (0, import_client.useSetToken)();
|
|
33
|
+
return (0, import_react.useCallback)(
|
|
55
34
|
async (data) => {
|
|
56
35
|
const res = await fetch(endpoint, {
|
|
57
36
|
method: "POST",
|
|
@@ -69,8 +48,9 @@ function useSignUpWithEmail(endpoint) {
|
|
|
69
48
|
);
|
|
70
49
|
}
|
|
71
50
|
function useLoginWithEmail(endpoint) {
|
|
72
|
-
const
|
|
73
|
-
|
|
51
|
+
const setToken = (0, import_client.useSetToken)();
|
|
52
|
+
console.warn(setToken, "2");
|
|
53
|
+
return (0, import_react.useCallback)(
|
|
74
54
|
async (data) => {
|
|
75
55
|
const res = await fetch(endpoint, {
|
|
76
56
|
method: "PUT",
|
|
@@ -88,9 +68,9 @@ function useLoginWithEmail(endpoint) {
|
|
|
88
68
|
);
|
|
89
69
|
}
|
|
90
70
|
function useLogout(endpoint) {
|
|
91
|
-
const { setToken, token } = (0,
|
|
71
|
+
const { setToken, token } = (0, import_react.useContext)(import_client.TokenContext);
|
|
92
72
|
console.warn(token, setToken, "1");
|
|
93
|
-
return (0,
|
|
73
|
+
return (0, import_react.useCallback)(
|
|
94
74
|
async (data) => {
|
|
95
75
|
setToken(null);
|
|
96
76
|
await fetch(endpoint, {
|
|
@@ -1,34 +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
|
-
|
|
27
|
-
// src/auth/email/client.ts
|
|
2
|
+
import { TokenContext, useSetToken } from "naystack/graphql/client";
|
|
3
|
+
import { useCallback, useContext } from "react";
|
|
28
4
|
function useSignUpWithEmail(endpoint) {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
return useCallback2(
|
|
5
|
+
const setToken = useSetToken();
|
|
6
|
+
return useCallback(
|
|
32
7
|
async (data) => {
|
|
33
8
|
const res = await fetch(endpoint, {
|
|
34
9
|
method: "POST",
|
|
@@ -46,8 +21,9 @@ function useSignUpWithEmail(endpoint) {
|
|
|
46
21
|
);
|
|
47
22
|
}
|
|
48
23
|
function useLoginWithEmail(endpoint) {
|
|
49
|
-
const
|
|
50
|
-
|
|
24
|
+
const setToken = useSetToken();
|
|
25
|
+
console.warn(setToken, "2");
|
|
26
|
+
return useCallback(
|
|
51
27
|
async (data) => {
|
|
52
28
|
const res = await fetch(endpoint, {
|
|
53
29
|
method: "PUT",
|
|
@@ -65,9 +41,9 @@ function useLoginWithEmail(endpoint) {
|
|
|
65
41
|
);
|
|
66
42
|
}
|
|
67
43
|
function useLogout(endpoint) {
|
|
68
|
-
const { setToken, token } =
|
|
44
|
+
const { setToken, token } = useContext(TokenContext);
|
|
69
45
|
console.warn(token, setToken, "1");
|
|
70
|
-
return
|
|
46
|
+
return useCallback(
|
|
71
47
|
async (data) => {
|
|
72
48
|
setToken(null);
|
|
73
49
|
await fetch(endpoint, {
|