naystack 1.5.27 → 1.5.29

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.
@@ -116,11 +116,13 @@ var AuthWrapper = ({
116
116
  function useAuthFetch(getRefreshToken) {
117
117
  const setToken = useSetToken();
118
118
  const fetchToken = async () => {
119
- fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
120
- credentials: "include",
121
- body: getRefreshToken ? JSON.stringify({
122
- [REFRESH_COOKIE_NAME]: await getRefreshToken()
123
- }) : void 0
119
+ const url = new URL(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */));
120
+ if (getRefreshToken) {
121
+ const token = await getRefreshToken();
122
+ if (token) url.searchParams.set(REFRESH_COOKIE_NAME, token);
123
+ }
124
+ fetch(url, {
125
+ credentials: "include"
124
126
  }).then((res) => res.json()).then((data) => setToken(data.accessToken));
125
127
  };
126
128
  (0, import_react.useEffect)(() => {
@@ -43,7 +43,7 @@ declare const AuthWrapper: ({ children, onTokenUpdate, }: {
43
43
  children: React__default.ReactNode;
44
44
  onTokenUpdate?: (token: string | null) => void;
45
45
  }) => React__default.JSX.Element;
46
- declare function useAuthFetch(getRefreshToken?: () => Promise<string>): void;
46
+ declare function useAuthFetch(getRefreshToken?: () => Promise<string | null>): void;
47
47
  declare function AuthApply({ data }: {
48
48
  data?: string | null;
49
49
  }): null;
@@ -43,7 +43,7 @@ declare const AuthWrapper: ({ children, onTokenUpdate, }: {
43
43
  children: React__default.ReactNode;
44
44
  onTokenUpdate?: (token: string | null) => void;
45
45
  }) => React__default.JSX.Element;
46
- declare function useAuthFetch(getRefreshToken?: () => Promise<string>): void;
46
+ declare function useAuthFetch(getRefreshToken?: () => Promise<string | null>): void;
47
47
  declare function AuthApply({ data }: {
48
48
  data?: string | null;
49
49
  }): null;
@@ -81,11 +81,13 @@ var AuthWrapper = ({
81
81
  function useAuthFetch(getRefreshToken) {
82
82
  const setToken = useSetToken();
83
83
  const fetchToken = async () => {
84
- fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
85
- credentials: "include",
86
- body: getRefreshToken ? JSON.stringify({
87
- [REFRESH_COOKIE_NAME]: await getRefreshToken()
88
- }) : void 0
84
+ const url = new URL(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */));
85
+ if (getRefreshToken) {
86
+ const token = await getRefreshToken();
87
+ if (token) url.searchParams.set(REFRESH_COOKIE_NAME, token);
88
+ }
89
+ fetch(url, {
90
+ credentials: "include"
89
91
  }).then((res) => res.json()).then((data) => setToken(data.accessToken));
90
92
  };
91
93
  useEffect(() => {
@@ -242,10 +242,8 @@ var getDeleteRoute = (options) => async (req) => {
242
242
 
243
243
  // src/auth/email/routes/get.ts
244
244
  var getGetRoute = (options) => async (req) => {
245
- const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value;
246
- const requestBody = refresh ? null : await req.json();
247
- const bodyRefresh = requestBody?.[REFRESH_COOKIE_NAME];
248
- const userID = getUserIdFromRefreshToken(refresh || bodyRefresh);
245
+ const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value || req.nextUrl.searchParams.get(REFRESH_COOKIE_NAME) || void 0;
246
+ const userID = getUserIdFromRefreshToken(refresh);
249
247
  if (userID) {
250
248
  if (options.onRefresh) {
251
249
  const body = await req.json();
@@ -205,10 +205,8 @@ var getDeleteRoute = (options) => async (req) => {
205
205
 
206
206
  // src/auth/email/routes/get.ts
207
207
  var getGetRoute = (options) => async (req) => {
208
- const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value;
209
- const requestBody = refresh ? null : await req.json();
210
- const bodyRefresh = requestBody?.[REFRESH_COOKIE_NAME];
211
- const userID = getUserIdFromRefreshToken(refresh || bodyRefresh);
208
+ const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value || req.nextUrl.searchParams.get(REFRESH_COOKIE_NAME) || void 0;
209
+ const userID = getUserIdFromRefreshToken(refresh);
212
210
  if (userID) {
213
211
  if (options.onRefresh) {
214
212
  const body = await req.json();
@@ -123,10 +123,8 @@ function getUserIdFromRefreshToken(refreshToken) {
123
123
 
124
124
  // src/auth/email/routes/get.ts
125
125
  var getGetRoute = (options) => async (req) => {
126
- const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value;
127
- const requestBody = refresh ? null : await req.json();
128
- const bodyRefresh = requestBody?.[REFRESH_COOKIE_NAME];
129
- const userID = getUserIdFromRefreshToken(refresh || bodyRefresh);
126
+ const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value || req.nextUrl.searchParams.get(REFRESH_COOKIE_NAME) || void 0;
127
+ const userID = getUserIdFromRefreshToken(refresh);
130
128
  if (userID) {
131
129
  if (options.onRefresh) {
132
130
  const body = await req.json();
@@ -97,10 +97,8 @@ function getUserIdFromRefreshToken(refreshToken) {
97
97
 
98
98
  // src/auth/email/routes/get.ts
99
99
  var getGetRoute = (options) => async (req) => {
100
- const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value;
101
- const requestBody = refresh ? null : await req.json();
102
- const bodyRefresh = requestBody?.[REFRESH_COOKIE_NAME];
103
- const userID = getUserIdFromRefreshToken(refresh || bodyRefresh);
100
+ const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value || req.nextUrl.searchParams.get(REFRESH_COOKIE_NAME) || void 0;
101
+ const userID = getUserIdFromRefreshToken(refresh);
104
102
  if (userID) {
105
103
  if (options.onRefresh) {
106
104
  const body = await req.json();
@@ -260,10 +260,8 @@ var getDeleteRoute = (options) => async (req) => {
260
260
 
261
261
  // src/auth/email/routes/get.ts
262
262
  var getGetRoute = (options) => async (req) => {
263
- const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value;
264
- const requestBody = refresh ? null : await req.json();
265
- const bodyRefresh = requestBody?.[REFRESH_COOKIE_NAME];
266
- const userID = getUserIdFromRefreshToken(refresh || bodyRefresh);
263
+ const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value || req.nextUrl.searchParams.get(REFRESH_COOKIE_NAME) || void 0;
264
+ const userID = getUserIdFromRefreshToken(refresh);
267
265
  if (userID) {
268
266
  if (options.onRefresh) {
269
267
  const body = await req.json();
@@ -217,10 +217,8 @@ var getDeleteRoute = (options) => async (req) => {
217
217
 
218
218
  // src/auth/email/routes/get.ts
219
219
  var getGetRoute = (options) => async (req) => {
220
- const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value;
221
- const requestBody = refresh ? null : await req.json();
222
- const bodyRefresh = requestBody?.[REFRESH_COOKIE_NAME];
223
- const userID = getUserIdFromRefreshToken(refresh || bodyRefresh);
220
+ const refresh = req.cookies.get(REFRESH_COOKIE_NAME)?.value || req.nextUrl.searchParams.get(REFRESH_COOKIE_NAME) || void 0;
221
+ const userID = getUserIdFromRefreshToken(refresh);
224
222
  if (userID) {
225
223
  if (options.onRefresh) {
226
224
  const body = await req.json();
@@ -32,14 +32,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
32
32
  var client_exports = {};
33
33
  __export(client_exports, {
34
34
  ApolloWrapper: () => ApolloWrapper,
35
- ApolloWrapperNext: () => ApolloWrapperNext,
36
35
  tokenContext: () => tokenContext,
37
36
  useAuthMutation: () => useAuthMutation,
38
37
  useAuthQuery: () => useAuthQuery
39
38
  });
40
39
  module.exports = __toCommonJS(client_exports);
41
40
  var import_client = require("@apollo/client");
42
- var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
43
41
  var import_client2 = require("naystack/auth/email/client");
44
42
  var import_react = __toESM(require("react"));
45
43
 
@@ -94,20 +92,6 @@ function getEnv(key, skipCheck) {
94
92
 
95
93
  // src/graphql/client.tsx
96
94
  function makeClient(cacheConfig) {
97
- return new import_client_integration_nextjs.ApolloClient({
98
- cache: new import_client_integration_nextjs.InMemoryCache(cacheConfig),
99
- link: new import_client.HttpLink({
100
- uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
101
- })
102
- });
103
- }
104
- var ApolloWrapperNext = ({
105
- children,
106
- cacheConfig
107
- }) => {
108
- return /* @__PURE__ */ import_react.default.createElement(import_client_integration_nextjs.ApolloNextAppProvider, { makeClient: () => makeClient(cacheConfig) }, children);
109
- };
110
- function makeClientBasic(cacheConfig) {
111
95
  return new import_client.ApolloClient({
112
96
  cache: new import_client.InMemoryCache(cacheConfig),
113
97
  link: new import_client.HttpLink({
@@ -119,7 +103,7 @@ var ApolloWrapper = ({
119
103
  children,
120
104
  cacheConfig
121
105
  }) => {
122
- return /* @__PURE__ */ import_react.default.createElement(import_client.ApolloProvider, { client: makeClientBasic(cacheConfig) }, children);
106
+ return /* @__PURE__ */ import_react.default.createElement(import_client.ApolloProvider, { client: makeClient(cacheConfig) }, children);
123
107
  };
124
108
  var tokenContext = (token) => {
125
109
  if (!token) return void 0;
@@ -172,7 +156,6 @@ function useAuthMutation(mutation, options) {
172
156
  // Annotate the CommonJS export names for ESM import in node:
173
157
  0 && (module.exports = {
174
158
  ApolloWrapper,
175
- ApolloWrapperNext,
176
159
  tokenContext,
177
160
  useAuthMutation,
178
161
  useAuthQuery
@@ -3,9 +3,6 @@ import { InMemoryCacheConfig, OperationVariables, MutationHookOptions } from '@a
3
3
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
4
4
  import React__default, { PropsWithChildren } from 'react';
5
5
 
6
- declare const ApolloWrapperNext: ({ children, cacheConfig, }: PropsWithChildren<{
7
- cacheConfig?: InMemoryCacheConfig;
8
- }>) => React__default.JSX.Element;
9
6
  declare const ApolloWrapper: ({ children, cacheConfig, }: PropsWithChildren<{
10
7
  cacheConfig?: InMemoryCacheConfig;
11
8
  }>) => React__default.JSX.Element;
@@ -99,4 +96,4 @@ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocum
99
96
  */
100
97
  declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input?: V["input"]) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
101
98
 
102
- export { ApolloWrapper, ApolloWrapperNext, tokenContext, useAuthMutation, useAuthQuery };
99
+ export { ApolloWrapper, tokenContext, useAuthMutation, useAuthQuery };
@@ -3,9 +3,6 @@ import { InMemoryCacheConfig, OperationVariables, MutationHookOptions } from '@a
3
3
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
4
4
  import React__default, { PropsWithChildren } from 'react';
5
5
 
6
- declare const ApolloWrapperNext: ({ children, cacheConfig, }: PropsWithChildren<{
7
- cacheConfig?: InMemoryCacheConfig;
8
- }>) => React__default.JSX.Element;
9
6
  declare const ApolloWrapper: ({ children, cacheConfig, }: PropsWithChildren<{
10
7
  cacheConfig?: InMemoryCacheConfig;
11
8
  }>) => React__default.JSX.Element;
@@ -99,4 +96,4 @@ declare function useAuthQuery<T, V extends OperationVariables>(query: TypedDocum
99
96
  */
100
97
  declare function useAuthMutation<T, V extends OperationVariables>(mutation: TypedDocumentNode<T, V>, options?: MutationHookOptions<T, V>): readonly [(input?: V["input"]) => Promise<_apollo_client.FetchResult<T>>, _apollo_client.MutationResult<T>];
101
98
 
102
- export { ApolloWrapper, ApolloWrapperNext, tokenContext, useAuthMutation, useAuthQuery };
99
+ export { ApolloWrapper, tokenContext, useAuthMutation, useAuthQuery };
@@ -2,18 +2,13 @@
2
2
 
3
3
  // src/graphql/client.tsx
4
4
  import {
5
- ApolloClient as ApolloClientBasic,
5
+ ApolloClient,
6
6
  ApolloProvider,
7
7
  HttpLink,
8
- InMemoryCache as InMemoryCacheBasic,
8
+ InMemoryCache,
9
9
  useLazyQuery,
10
10
  useMutation
11
11
  } from "@apollo/client";
12
- import {
13
- ApolloClient,
14
- ApolloNextAppProvider,
15
- InMemoryCache
16
- } from "@apollo/client-integration-nextjs";
17
12
  import { useToken } from "naystack/auth/email/client";
18
13
  import React, {
19
14
  useCallback,
@@ -79,25 +74,11 @@ function makeClient(cacheConfig) {
79
74
  })
80
75
  });
81
76
  }
82
- var ApolloWrapperNext = ({
83
- children,
84
- cacheConfig
85
- }) => {
86
- return /* @__PURE__ */ React.createElement(ApolloNextAppProvider, { makeClient: () => makeClient(cacheConfig) }, children);
87
- };
88
- function makeClientBasic(cacheConfig) {
89
- return new ApolloClientBasic({
90
- cache: new InMemoryCacheBasic(cacheConfig),
91
- link: new HttpLink({
92
- uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
93
- })
94
- });
95
- }
96
77
  var ApolloWrapper = ({
97
78
  children,
98
79
  cacheConfig
99
80
  }) => {
100
- return /* @__PURE__ */ React.createElement(ApolloProvider, { client: makeClientBasic(cacheConfig) }, children);
81
+ return /* @__PURE__ */ React.createElement(ApolloProvider, { client: makeClient(cacheConfig) }, children);
101
82
  };
102
83
  var tokenContext = (token) => {
103
84
  if (!token) return void 0;
@@ -149,7 +130,6 @@ function useAuthMutation(mutation, options) {
149
130
  }
150
131
  export {
151
132
  ApolloWrapper,
152
- ApolloWrapperNext,
153
133
  tokenContext,
154
134
  useAuthMutation,
155
135
  useAuthQuery
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/graphql/next.tsx
32
+ var next_exports = {};
33
+ __export(next_exports, {
34
+ ApolloWrapper: () => ApolloWrapper
35
+ });
36
+ module.exports = __toCommonJS(next_exports);
37
+ var import_client = require("@apollo/client");
38
+ var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
39
+ var import_react = __toESM(require("react"));
40
+
41
+ // src/env.ts
42
+ var getEnvValue = (key) => {
43
+ switch (key) {
44
+ case "NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */:
45
+ return process.env.NEXT_PUBLIC_GRAPHQL_ENDPOINT || process.env.EXPO_PUBLIC_GRAPHQL_ENDPOINT;
46
+ case "NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */:
47
+ return process.env.NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT || process.env.EXPO_PUBLIC_EMAIL_AUTH_ENDPOINT;
48
+ case "NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT" /* NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT */:
49
+ return process.env.NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT || process.env.EXPO_PUBLIC_GOOGLE_AUTH_ENDPOINT;
50
+ case "NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT" /* NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT */:
51
+ return process.env.NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT || process.env.EXPO_PUBLIC_INSTAGRAM_AUTH_ENDPOINT;
52
+ case "NEXT_PUBLIC_FILE_ENDPOINT" /* NEXT_PUBLIC_FILE_ENDPOINT */:
53
+ return process.env.NEXT_PUBLIC_FILE_ENDPOINT || process.env.EXPO_PUBLIC_FILE_ENDPOINT;
54
+ case "NEXT_PUBLIC_BASE_URL" /* NEXT_PUBLIC_BASE_URL */:
55
+ return process.env.NEXT_PUBLIC_BASE_URL || process.env.EXPO_PUBLIC_BASE_URL;
56
+ case "REFRESH_KEY" /* REFRESH_KEY */:
57
+ return process.env.REFRESH_KEY;
58
+ case "SIGNING_KEY" /* SIGNING_KEY */:
59
+ return process.env.SIGNING_KEY;
60
+ case "INSTAGRAM_CLIENT_SECRET" /* INSTAGRAM_CLIENT_SECRET */:
61
+ return process.env.INSTAGRAM_CLIENT_SECRET;
62
+ case "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */:
63
+ return process.env.INSTAGRAM_CLIENT_ID;
64
+ case "GOOGLE_CLIENT_SECRET" /* GOOGLE_CLIENT_SECRET */:
65
+ return process.env.GOOGLE_CLIENT_SECRET;
66
+ case "GOOGLE_CLIENT_ID" /* GOOGLE_CLIENT_ID */:
67
+ return process.env.GOOGLE_CLIENT_ID;
68
+ case "TURNSTILE_KEY" /* TURNSTILE_KEY */:
69
+ return process.env.TURNSTILE_KEY;
70
+ case "AWS_ACCESS_KEY_ID" /* AWS_ACCESS_KEY_ID */:
71
+ return process.env.AWS_ACCESS_KEY_ID;
72
+ case "AWS_ACCESS_KEY_SECRET" /* AWS_ACCESS_KEY_SECRET */:
73
+ return process.env.AWS_ACCESS_KEY_SECRET;
74
+ case "AWS_REGION" /* AWS_REGION */:
75
+ return process.env.AWS_REGION;
76
+ case "AWS_BUCKET" /* AWS_BUCKET */:
77
+ return process.env.AWS_BUCKET;
78
+ case "NODE_ENV" /* NODE_ENV */:
79
+ return process.env.NODE_ENV;
80
+ default:
81
+ return process.env[key];
82
+ }
83
+ };
84
+ function getEnv(key, skipCheck) {
85
+ const value = getEnvValue(key);
86
+ if (!skipCheck && !value) throw new Error(`${key} is not defined`);
87
+ return value;
88
+ }
89
+
90
+ // src/graphql/next.tsx
91
+ function makeClient(cacheConfig) {
92
+ return new import_client_integration_nextjs.ApolloClient({
93
+ cache: new import_client_integration_nextjs.InMemoryCache(cacheConfig),
94
+ link: new import_client.HttpLink({
95
+ uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
96
+ })
97
+ });
98
+ }
99
+ var ApolloWrapper = ({
100
+ children,
101
+ cacheConfig
102
+ }) => {
103
+ return /* @__PURE__ */ import_react.default.createElement(import_client_integration_nextjs.ApolloNextAppProvider, { makeClient: () => makeClient(cacheConfig) }, children);
104
+ };
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ ApolloWrapper
108
+ });
@@ -0,0 +1,8 @@
1
+ import { InMemoryCacheConfig } from '@apollo/client';
2
+ import React__default, { PropsWithChildren } from 'react';
3
+
4
+ declare const ApolloWrapper: ({ children, cacheConfig, }: PropsWithChildren<{
5
+ cacheConfig?: InMemoryCacheConfig;
6
+ }>) => React__default.JSX.Element;
7
+
8
+ export { ApolloWrapper };
@@ -0,0 +1,8 @@
1
+ import { InMemoryCacheConfig } from '@apollo/client';
2
+ import React__default, { PropsWithChildren } from 'react';
3
+
4
+ declare const ApolloWrapper: ({ children, cacheConfig, }: PropsWithChildren<{
5
+ cacheConfig?: InMemoryCacheConfig;
6
+ }>) => React__default.JSX.Element;
7
+
8
+ export { ApolloWrapper };
@@ -0,0 +1,78 @@
1
+ "use client";
2
+
3
+ // src/graphql/next.tsx
4
+ import { HttpLink } from "@apollo/client";
5
+ import {
6
+ ApolloClient,
7
+ ApolloNextAppProvider,
8
+ InMemoryCache
9
+ } from "@apollo/client-integration-nextjs";
10
+ import React from "react";
11
+
12
+ // src/env.ts
13
+ var getEnvValue = (key) => {
14
+ switch (key) {
15
+ case "NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */:
16
+ return process.env.NEXT_PUBLIC_GRAPHQL_ENDPOINT || process.env.EXPO_PUBLIC_GRAPHQL_ENDPOINT;
17
+ case "NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */:
18
+ return process.env.NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT || process.env.EXPO_PUBLIC_EMAIL_AUTH_ENDPOINT;
19
+ case "NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT" /* NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT */:
20
+ return process.env.NEXT_PUBLIC_GOOGLE_AUTH_ENDPOINT || process.env.EXPO_PUBLIC_GOOGLE_AUTH_ENDPOINT;
21
+ case "NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT" /* NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT */:
22
+ return process.env.NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT || process.env.EXPO_PUBLIC_INSTAGRAM_AUTH_ENDPOINT;
23
+ case "NEXT_PUBLIC_FILE_ENDPOINT" /* NEXT_PUBLIC_FILE_ENDPOINT */:
24
+ return process.env.NEXT_PUBLIC_FILE_ENDPOINT || process.env.EXPO_PUBLIC_FILE_ENDPOINT;
25
+ case "NEXT_PUBLIC_BASE_URL" /* NEXT_PUBLIC_BASE_URL */:
26
+ return process.env.NEXT_PUBLIC_BASE_URL || process.env.EXPO_PUBLIC_BASE_URL;
27
+ case "REFRESH_KEY" /* REFRESH_KEY */:
28
+ return process.env.REFRESH_KEY;
29
+ case "SIGNING_KEY" /* SIGNING_KEY */:
30
+ return process.env.SIGNING_KEY;
31
+ case "INSTAGRAM_CLIENT_SECRET" /* INSTAGRAM_CLIENT_SECRET */:
32
+ return process.env.INSTAGRAM_CLIENT_SECRET;
33
+ case "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */:
34
+ return process.env.INSTAGRAM_CLIENT_ID;
35
+ case "GOOGLE_CLIENT_SECRET" /* GOOGLE_CLIENT_SECRET */:
36
+ return process.env.GOOGLE_CLIENT_SECRET;
37
+ case "GOOGLE_CLIENT_ID" /* GOOGLE_CLIENT_ID */:
38
+ return process.env.GOOGLE_CLIENT_ID;
39
+ case "TURNSTILE_KEY" /* TURNSTILE_KEY */:
40
+ return process.env.TURNSTILE_KEY;
41
+ case "AWS_ACCESS_KEY_ID" /* AWS_ACCESS_KEY_ID */:
42
+ return process.env.AWS_ACCESS_KEY_ID;
43
+ case "AWS_ACCESS_KEY_SECRET" /* AWS_ACCESS_KEY_SECRET */:
44
+ return process.env.AWS_ACCESS_KEY_SECRET;
45
+ case "AWS_REGION" /* AWS_REGION */:
46
+ return process.env.AWS_REGION;
47
+ case "AWS_BUCKET" /* AWS_BUCKET */:
48
+ return process.env.AWS_BUCKET;
49
+ case "NODE_ENV" /* NODE_ENV */:
50
+ return process.env.NODE_ENV;
51
+ default:
52
+ return process.env[key];
53
+ }
54
+ };
55
+ function getEnv(key, skipCheck) {
56
+ const value = getEnvValue(key);
57
+ if (!skipCheck && !value) throw new Error(`${key} is not defined`);
58
+ return value;
59
+ }
60
+
61
+ // src/graphql/next.tsx
62
+ function makeClient(cacheConfig) {
63
+ return new ApolloClient({
64
+ cache: new InMemoryCache(cacheConfig),
65
+ link: new HttpLink({
66
+ uri: getEnv("NEXT_PUBLIC_GRAPHQL_ENDPOINT" /* NEXT_PUBLIC_GRAPHQL_ENDPOINT */)
67
+ })
68
+ });
69
+ }
70
+ var ApolloWrapper = ({
71
+ children,
72
+ cacheConfig
73
+ }) => {
74
+ return /* @__PURE__ */ React.createElement(ApolloNextAppProvider, { makeClient: () => makeClient(cacheConfig) }, children);
75
+ };
76
+ export {
77
+ ApolloWrapper
78
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.5.27",
3
+ "version": "1.5.29",
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",
@@ -33,6 +33,11 @@
33
33
  "import": "./dist/graphql/client.esm.js",
34
34
  "require": "./dist/graphql/client.cjs.js"
35
35
  },
36
+ "./graphql/next": {
37
+ "types": "./dist/graphql/next.d.ts",
38
+ "import": "./dist/graphql/next.esm.js",
39
+ "require": "./dist/graphql/next.cjs.js"
40
+ },
36
41
  "./auth/email/client": {
37
42
  "types": "./dist/auth/email/client.d.ts",
38
43
  "import": "./dist/auth/email/client.esm.js",