naystack 1.2.7 → 1.2.8

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.
@@ -49,7 +49,8 @@ var TokenContext = (0, import_react.createContext)({
49
49
 
50
50
  // src/auth/email/client.ts
51
51
  function useSignUpWithEmail(endpoint) {
52
- const { setToken } = (0, import_react2.useContext)(TokenContext);
52
+ const { setToken, token } = (0, import_react2.useContext)(TokenContext);
53
+ console.warn(token, setToken, "1");
53
54
  return (0, import_react2.useCallback)(
54
55
  async (data) => {
55
56
  const res = await fetch(endpoint, {
@@ -87,7 +88,8 @@ function useLoginWithEmail(endpoint) {
87
88
  );
88
89
  }
89
90
  function useLogout(endpoint) {
90
- const { setToken } = (0, import_react2.useContext)(TokenContext);
91
+ const { setToken, token } = (0, import_react2.useContext)(TokenContext);
92
+ console.warn(token, setToken, "1");
91
93
  return (0, import_react2.useCallback)(
92
94
  async (data) => {
93
95
  setToken(null);
@@ -26,7 +26,8 @@ var TokenContext = createContext({
26
26
 
27
27
  // src/auth/email/client.ts
28
28
  function useSignUpWithEmail(endpoint) {
29
- const { setToken } = useContext2(TokenContext);
29
+ const { setToken, token } = useContext2(TokenContext);
30
+ console.warn(token, setToken, "1");
30
31
  return useCallback2(
31
32
  async (data) => {
32
33
  const res = await fetch(endpoint, {
@@ -64,7 +65,8 @@ function useLoginWithEmail(endpoint) {
64
65
  );
65
66
  }
66
67
  function useLogout(endpoint) {
67
- const { setToken } = useContext2(TokenContext);
68
+ const { setToken, token } = useContext2(TokenContext);
69
+ console.warn(token, setToken, "1");
68
70
  return useCallback2(
69
71
  async (data) => {
70
72
  setToken(null);
@@ -36,6 +36,7 @@ __export(client_exports, {
36
36
  tokenContext: () => tokenContext,
37
37
  useAuthMutation: () => useAuthMutation,
38
38
  useAuthQuery: () => useAuthQuery,
39
+ useSetToken: () => useSetToken,
39
40
  useToken: () => useToken
40
41
  });
41
42
  module.exports = __toCommonJS(client_exports);
@@ -73,6 +74,10 @@ function useToken() {
73
74
  const { token } = (0, import_react.useContext)(TokenContext);
74
75
  return token;
75
76
  }
77
+ function useSetToken() {
78
+ const { setToken } = (0, import_react.useContext)(TokenContext);
79
+ return setToken;
80
+ }
76
81
  var tokenContext = (token) => {
77
82
  if (!token) return void 0;
78
83
  return {
@@ -125,5 +130,6 @@ function useAuthMutation(mutation, options) {
125
130
  tokenContext,
126
131
  useAuthMutation,
127
132
  useAuthQuery,
133
+ useSetToken,
128
134
  useToken
129
135
  });
@@ -14,6 +14,7 @@ declare const getApolloWrapper: ({ graphqlUri, cacheConfig, authEndpoint, }: {
14
14
  cacheConfig?: InMemoryCacheConfig;
15
15
  }) => ({ children }: PropsWithChildren) => React__default.JSX.Element;
16
16
  declare function useToken(): string | null;
17
+ declare function useSetToken(): React__default.Dispatch<React__default.SetStateAction<string | null>>;
17
18
  declare const tokenContext: (token?: string | null) => {
18
19
  headers: {
19
20
  authorization: string;
@@ -23,4 +24,4 @@ declare const tokenContext: (token?: string | null) => {
23
24
  declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V): readonly [(v?: V) => Promise<_apollo_client.QueryResult<T, V>>, _apollo_client.QueryResult<T, V>];
24
25
  declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(variables?: V) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
25
26
 
26
- export { TokenContext, getApolloWrapper, tokenContext, useAuthMutation, useAuthQuery, useToken };
27
+ export { TokenContext, getApolloWrapper, tokenContext, useAuthMutation, useAuthQuery, useSetToken, useToken };
@@ -14,6 +14,7 @@ declare const getApolloWrapper: ({ graphqlUri, cacheConfig, authEndpoint, }: {
14
14
  cacheConfig?: InMemoryCacheConfig;
15
15
  }) => ({ children }: PropsWithChildren) => React__default.JSX.Element;
16
16
  declare function useToken(): string | null;
17
+ declare function useSetToken(): React__default.Dispatch<React__default.SetStateAction<string | null>>;
17
18
  declare const tokenContext: (token?: string | null) => {
18
19
  headers: {
19
20
  authorization: string;
@@ -23,4 +24,4 @@ declare const tokenContext: (token?: string | null) => {
23
24
  declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocumentNode<T, V>, variables?: V): readonly [(v?: V) => Promise<_apollo_client.QueryResult<T, V>>, _apollo_client.QueryResult<T, V>];
24
25
  declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(variables?: V) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
25
26
 
26
- export { TokenContext, getApolloWrapper, tokenContext, useAuthMutation, useAuthQuery, useToken };
27
+ export { TokenContext, getApolloWrapper, tokenContext, useAuthMutation, useAuthQuery, useSetToken, useToken };
@@ -49,6 +49,10 @@ function useToken() {
49
49
  const { token } = useContext(TokenContext);
50
50
  return token;
51
51
  }
52
+ function useSetToken() {
53
+ const { setToken } = useContext(TokenContext);
54
+ return setToken;
55
+ }
52
56
  var tokenContext = (token) => {
53
57
  if (!token) return void 0;
54
58
  return {
@@ -100,5 +104,6 @@ export {
100
104
  tokenContext,
101
105
  useAuthMutation,
102
106
  useAuthQuery,
107
+ useSetToken,
103
108
  useToken
104
109
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "A stack built with Next + GraphQL + S3 + Auth",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",