naystack 1.5.7 → 1.5.9

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.
@@ -22,7 +22,9 @@ var email_exports = {};
22
22
  __export(email_exports, {
23
23
  checkAuthStatus: () => checkAuthStatus,
24
24
  getContext: () => getContext,
25
- getEmailAuthRoutes: () => getEmailAuthRoutes
25
+ getCurrentRefreshToken: () => getCurrentRefreshToken,
26
+ getEmailAuthRoutes: () => getEmailAuthRoutes,
27
+ logout: () => logout
26
28
  });
27
29
  module.exports = __toCommonJS(email_exports);
28
30
 
@@ -141,6 +143,7 @@ async function checkAuthStatus(redirectUnauthorizedURL) {
141
143
 
142
144
  // src/auth/email/utils.ts
143
145
  var import_jsonwebtoken2 = require("jsonwebtoken");
146
+ var import_headers2 = require("next/headers");
144
147
 
145
148
  // src/auth/utils/errors.ts
146
149
  var import_server2 = require("next/server");
@@ -217,6 +220,19 @@ var getContext = (req) => {
217
220
  }
218
221
  return { userId: null };
219
222
  };
223
+ async function logout(data) {
224
+ const Cookie = await (0, import_headers2.cookies)();
225
+ Cookie.delete(REFRESH_COOKIE_NAME);
226
+ await fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
227
+ method: "DELETE",
228
+ credentials: "include",
229
+ body: JSON.stringify(data)
230
+ });
231
+ }
232
+ async function getCurrentRefreshToken() {
233
+ const Cookie = await (0, import_headers2.cookies)();
234
+ return Cookie.get(REFRESH_COOKIE_NAME)?.value;
235
+ }
220
236
 
221
237
  // src/auth/email/routes/delete.ts
222
238
  var getDeleteRoute = (options) => async (req) => {
@@ -311,5 +327,7 @@ function getEmailAuthRoutes(options) {
311
327
  0 && (module.exports = {
312
328
  checkAuthStatus,
313
329
  getContext,
314
- getEmailAuthRoutes
330
+ getCurrentRefreshToken,
331
+ getEmailAuthRoutes,
332
+ logout
315
333
  });
@@ -1,7 +1,7 @@
1
1
  import * as next_server from 'next/server';
2
2
  import { InitRoutesOptions } from './types.mjs';
3
3
  export { checkAuthStatus } from './token.mjs';
4
- export { getContext } from './utils.mjs';
4
+ export { getContext, getCurrentRefreshToken, logout } from './utils.mjs';
5
5
  import '../types.mjs';
6
6
  import '../../graphql/types.mjs';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import * as next_server from 'next/server';
2
2
  import { InitRoutesOptions } from './types.js';
3
3
  export { checkAuthStatus } from './token.js';
4
- export { getContext } from './utils.js';
4
+ export { getContext, getCurrentRefreshToken, logout } from './utils.js';
5
5
  import '../types.js';
6
6
  import '../../graphql/types.js';
7
7
 
@@ -113,6 +113,7 @@ async function checkAuthStatus(redirectUnauthorizedURL) {
113
113
 
114
114
  // src/auth/email/utils.ts
115
115
  import { verify as verify2 } from "jsonwebtoken";
116
+ import { cookies as cookies2 } from "next/headers";
116
117
 
117
118
  // src/auth/utils/errors.ts
118
119
  import { NextResponse as NextResponse2 } from "next/server";
@@ -189,6 +190,19 @@ var getContext = (req) => {
189
190
  }
190
191
  return { userId: null };
191
192
  };
193
+ async function logout(data) {
194
+ const Cookie = await cookies2();
195
+ Cookie.delete(REFRESH_COOKIE_NAME);
196
+ await fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
197
+ method: "DELETE",
198
+ credentials: "include",
199
+ body: JSON.stringify(data)
200
+ });
201
+ }
202
+ async function getCurrentRefreshToken() {
203
+ const Cookie = await cookies2();
204
+ return Cookie.get(REFRESH_COOKIE_NAME)?.value;
205
+ }
192
206
 
193
207
  // src/auth/email/routes/delete.ts
194
208
  var getDeleteRoute = (options) => async (req) => {
@@ -282,5 +296,7 @@ function getEmailAuthRoutes(options) {
282
296
  export {
283
297
  checkAuthStatus,
284
298
  getContext,
285
- getEmailAuthRoutes
299
+ getCurrentRefreshToken,
300
+ getEmailAuthRoutes,
301
+ logout
286
302
  };
@@ -120,6 +120,7 @@ function getUserIdFromRefreshToken(refreshToken) {
120
120
 
121
121
  // src/auth/email/utils.ts
122
122
  var import_jsonwebtoken2 = require("jsonwebtoken");
123
+ var import_headers2 = require("next/headers");
123
124
 
124
125
  // src/auth/utils/errors.ts
125
126
  var import_server2 = require("next/server");
@@ -94,6 +94,7 @@ function getUserIdFromRefreshToken(refreshToken) {
94
94
 
95
95
  // src/auth/email/utils.ts
96
96
  import { verify as verify2 } from "jsonwebtoken";
97
+ import { cookies as cookies2 } from "next/headers";
97
98
 
98
99
  // src/auth/utils/errors.ts
99
100
  import { NextResponse as NextResponse2 } from "next/server";
@@ -129,6 +129,7 @@ function verifyUser(user, password) {
129
129
 
130
130
  // src/auth/email/utils.ts
131
131
  var import_jsonwebtoken2 = require("jsonwebtoken");
132
+ var import_headers2 = require("next/headers");
132
133
  async function massageRequest(req, options) {
133
134
  const data = await req.json();
134
135
  if (!data.password)
@@ -105,6 +105,7 @@ function verifyUser(user, password) {
105
105
 
106
106
  // src/auth/email/utils.ts
107
107
  import { verify as verify2 } from "jsonwebtoken";
108
+ import { cookies as cookies2 } from "next/headers";
108
109
  async function massageRequest(req, options) {
109
110
  const data = await req.json();
110
111
  if (!data.password)
@@ -128,6 +128,7 @@ function verifyUser(user, password) {
128
128
 
129
129
  // src/auth/email/utils.ts
130
130
  var import_jsonwebtoken2 = require("jsonwebtoken");
131
+ var import_headers2 = require("next/headers");
131
132
  async function massageRequest(req, options) {
132
133
  const data = await req.json();
133
134
  if (!data.password)
@@ -102,6 +102,7 @@ function verifyUser(user, password) {
102
102
 
103
103
  // src/auth/email/utils.ts
104
104
  import { verify as verify2 } from "jsonwebtoken";
105
+ import { cookies as cookies2 } from "next/headers";
105
106
  async function massageRequest(req, options) {
106
107
  const data = await req.json();
107
108
  if (!data.password)
@@ -21,11 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var utils_exports = {};
22
22
  __export(utils_exports, {
23
23
  getContext: () => getContext,
24
+ getCurrentRefreshToken: () => getCurrentRefreshToken,
25
+ logout: () => logout,
24
26
  massageRequest: () => massageRequest,
25
27
  verifyCaptcha: () => verifyCaptcha
26
28
  });
27
29
  module.exports = __toCommonJS(utils_exports);
28
30
  var import_jsonwebtoken2 = require("jsonwebtoken");
31
+ var import_headers2 = require("next/headers");
29
32
 
30
33
  // src/auth/email/token.ts
31
34
  var import_bcryptjs = require("bcryptjs");
@@ -175,9 +178,24 @@ var getContext = (req) => {
175
178
  }
176
179
  return { userId: null };
177
180
  };
181
+ async function logout(data) {
182
+ const Cookie = await (0, import_headers2.cookies)();
183
+ Cookie.delete(REFRESH_COOKIE_NAME);
184
+ await fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
185
+ method: "DELETE",
186
+ credentials: "include",
187
+ body: JSON.stringify(data)
188
+ });
189
+ }
190
+ async function getCurrentRefreshToken() {
191
+ const Cookie = await (0, import_headers2.cookies)();
192
+ return Cookie.get(REFRESH_COOKIE_NAME)?.value;
193
+ }
178
194
  // Annotate the CommonJS export names for ESM import in node:
179
195
  0 && (module.exports = {
180
196
  getContext,
197
+ getCurrentRefreshToken,
198
+ logout,
181
199
  massageRequest,
182
200
  verifyCaptcha
183
201
  });
@@ -13,5 +13,7 @@ declare function massageRequest(req: NextRequest, options: InitRoutesOptions): P
13
13
  }>;
14
14
  declare function verifyCaptcha(token: string, secret?: string): Promise<boolean>;
15
15
  declare const getContext: (req: NextRequest) => Context;
16
+ declare function logout(data?: object): Promise<void>;
17
+ declare function getCurrentRefreshToken(): Promise<string | undefined>;
16
18
 
17
- export { getContext, massageRequest, verifyCaptcha };
19
+ export { getContext, getCurrentRefreshToken, logout, massageRequest, verifyCaptcha };
@@ -13,5 +13,7 @@ declare function massageRequest(req: NextRequest, options: InitRoutesOptions): P
13
13
  }>;
14
14
  declare function verifyCaptcha(token: string, secret?: string): Promise<boolean>;
15
15
  declare const getContext: (req: NextRequest) => Context;
16
+ declare function logout(data?: object): Promise<void>;
17
+ declare function getCurrentRefreshToken(): Promise<string | undefined>;
16
18
 
17
- export { getContext, massageRequest, verifyCaptcha };
19
+ export { getContext, getCurrentRefreshToken, logout, massageRequest, verifyCaptcha };
@@ -1,5 +1,6 @@
1
1
  // src/auth/email/utils.ts
2
2
  import { verify as verify2 } from "jsonwebtoken";
3
+ import { cookies as cookies2 } from "next/headers";
3
4
 
4
5
  // src/auth/email/token.ts
5
6
  import { compare } from "bcryptjs";
@@ -149,8 +150,23 @@ var getContext = (req) => {
149
150
  }
150
151
  return { userId: null };
151
152
  };
153
+ async function logout(data) {
154
+ const Cookie = await cookies2();
155
+ Cookie.delete(REFRESH_COOKIE_NAME);
156
+ await fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
157
+ method: "DELETE",
158
+ credentials: "include",
159
+ body: JSON.stringify(data)
160
+ });
161
+ }
162
+ async function getCurrentRefreshToken() {
163
+ const Cookie = await cookies2();
164
+ return Cookie.get(REFRESH_COOKIE_NAME)?.value;
165
+ }
152
166
  export {
153
167
  getContext,
168
+ getCurrentRefreshToken,
169
+ logout,
154
170
  massageRequest,
155
171
  verifyCaptcha
156
172
  };
@@ -22,10 +22,12 @@ var auth_exports = {};
22
22
  __export(auth_exports, {
23
23
  checkAuthStatus: () => checkAuthStatus,
24
24
  getContext: () => getContext,
25
+ getCurrentRefreshToken: () => getCurrentRefreshToken,
25
26
  getEmailAuthRoutes: () => getEmailAuthRoutes,
26
27
  getRefreshToken: () => getRefreshToken,
27
28
  initGoogleAuth: () => initGoogleAuth,
28
- initInstagramAuth: () => initInstagramAuth
29
+ initInstagramAuth: () => initInstagramAuth,
30
+ logout: () => logout
29
31
  });
30
32
  module.exports = __toCommonJS(auth_exports);
31
33
 
@@ -156,6 +158,7 @@ async function checkAuthStatus(redirectUnauthorizedURL) {
156
158
 
157
159
  // src/auth/email/utils.ts
158
160
  var import_jsonwebtoken2 = require("jsonwebtoken");
161
+ var import_headers2 = require("next/headers");
159
162
 
160
163
  // src/auth/utils/errors.ts
161
164
  var import_server2 = require("next/server");
@@ -232,6 +235,19 @@ var getContext = (req) => {
232
235
  }
233
236
  return { userId: null };
234
237
  };
238
+ async function logout(data) {
239
+ const Cookie = await (0, import_headers2.cookies)();
240
+ Cookie.delete(REFRESH_COOKIE_NAME);
241
+ await fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
242
+ method: "DELETE",
243
+ credentials: "include",
244
+ body: JSON.stringify(data)
245
+ });
246
+ }
247
+ async function getCurrentRefreshToken() {
248
+ const Cookie = await (0, import_headers2.cookies)();
249
+ return Cookie.get(REFRESH_COOKIE_NAME)?.value;
250
+ }
235
251
 
236
252
  // src/auth/email/routes/delete.ts
237
253
  var getDeleteRoute = (options) => async (req) => {
@@ -515,17 +531,19 @@ function initInstagramAuth(props) {
515
531
  }
516
532
 
517
533
  // src/auth/utils/token.ts
518
- var import_headers2 = require("next/headers");
534
+ var import_headers3 = require("next/headers");
519
535
  async function getRefreshToken() {
520
- const Cookie = await (0, import_headers2.cookies)();
536
+ const Cookie = await (0, import_headers3.cookies)();
521
537
  return Cookie.get(REFRESH_COOKIE_NAME)?.value || null;
522
538
  }
523
539
  // Annotate the CommonJS export names for ESM import in node:
524
540
  0 && (module.exports = {
525
541
  checkAuthStatus,
526
542
  getContext,
543
+ getCurrentRefreshToken,
527
544
  getEmailAuthRoutes,
528
545
  getRefreshToken,
529
546
  initGoogleAuth,
530
- initInstagramAuth
547
+ initInstagramAuth,
548
+ logout
531
549
  });
@@ -3,7 +3,7 @@ export { initGoogleAuth } from './google/index.mjs';
3
3
  export { initInstagramAuth } from './instagram/index.mjs';
4
4
  export { getRefreshToken } from './utils/token.mjs';
5
5
  export { checkAuthStatus } from './email/token.mjs';
6
- export { getContext } from './email/utils.mjs';
6
+ export { getContext, getCurrentRefreshToken, logout } from './email/utils.mjs';
7
7
  import 'next/server';
8
8
  import './email/types.mjs';
9
9
  import './types.mjs';
@@ -3,7 +3,7 @@ export { initGoogleAuth } from './google/index.js';
3
3
  export { initInstagramAuth } from './instagram/index.js';
4
4
  export { getRefreshToken } from './utils/token.js';
5
5
  export { checkAuthStatus } from './email/token.js';
6
- export { getContext } from './email/utils.js';
6
+ export { getContext, getCurrentRefreshToken, logout } from './email/utils.js';
7
7
  import 'next/server';
8
8
  import './email/types.js';
9
9
  import './types.js';
@@ -125,6 +125,7 @@ async function checkAuthStatus(redirectUnauthorizedURL) {
125
125
 
126
126
  // src/auth/email/utils.ts
127
127
  import { verify as verify2 } from "jsonwebtoken";
128
+ import { cookies as cookies2 } from "next/headers";
128
129
 
129
130
  // src/auth/utils/errors.ts
130
131
  import { NextResponse as NextResponse2 } from "next/server";
@@ -201,6 +202,19 @@ var getContext = (req) => {
201
202
  }
202
203
  return { userId: null };
203
204
  };
205
+ async function logout(data) {
206
+ const Cookie = await cookies2();
207
+ Cookie.delete(REFRESH_COOKIE_NAME);
208
+ await fetch(getEnv("NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT" /* NEXT_PUBLIC_EMAIL_AUTH_ENDPOINT */), {
209
+ method: "DELETE",
210
+ credentials: "include",
211
+ body: JSON.stringify(data)
212
+ });
213
+ }
214
+ async function getCurrentRefreshToken() {
215
+ const Cookie = await cookies2();
216
+ return Cookie.get(REFRESH_COOKIE_NAME)?.value;
217
+ }
204
218
 
205
219
  // src/auth/email/routes/delete.ts
206
220
  var getDeleteRoute = (options) => async (req) => {
@@ -484,16 +498,18 @@ function initInstagramAuth(props) {
484
498
  }
485
499
 
486
500
  // src/auth/utils/token.ts
487
- import { cookies as cookies2 } from "next/headers";
501
+ import { cookies as cookies3 } from "next/headers";
488
502
  async function getRefreshToken() {
489
- const Cookie = await cookies2();
503
+ const Cookie = await cookies3();
490
504
  return Cookie.get(REFRESH_COOKIE_NAME)?.value || null;
491
505
  }
492
506
  export {
493
507
  checkAuthStatus,
494
508
  getContext,
509
+ getCurrentRefreshToken,
495
510
  getEmailAuthRoutes,
496
511
  getRefreshToken,
497
512
  initGoogleAuth,
498
- initInstagramAuth
513
+ initInstagramAuth,
514
+ logout
499
515
  };
@@ -30,6 +30,7 @@ var import_uuid = require("uuid");
30
30
 
31
31
  // src/auth/email/utils.ts
32
32
  var import_jsonwebtoken2 = require("jsonwebtoken");
33
+ var import_headers2 = require("next/headers");
33
34
 
34
35
  // src/auth/email/token.ts
35
36
  var import_bcryptjs = require("bcryptjs");
@@ -4,6 +4,7 @@ import { v4 } from "uuid";
4
4
 
5
5
  // src/auth/email/utils.ts
6
6
  import { verify as verify2 } from "jsonwebtoken";
7
+ import { cookies as cookies2 } from "next/headers";
7
8
 
8
9
  // src/auth/email/token.ts
9
10
  import { compare } from "bcryptjs";
@@ -28,6 +28,7 @@ var import_uuid = require("uuid");
28
28
 
29
29
  // src/auth/email/utils.ts
30
30
  var import_jsonwebtoken2 = require("jsonwebtoken");
31
+ var import_headers2 = require("next/headers");
31
32
 
32
33
  // src/auth/email/token.ts
33
34
  var import_bcryptjs = require("bcryptjs");
@@ -4,6 +4,7 @@ import { v4 } from "uuid";
4
4
 
5
5
  // src/auth/email/utils.ts
6
6
  import { verify as verify2 } from "jsonwebtoken";
7
+ import { cookies as cookies2 } from "next/headers";
7
8
 
8
9
  // src/auth/email/token.ts
9
10
  import { compare } from "bcryptjs";
@@ -30,6 +30,7 @@ var import_uuid = require("uuid");
30
30
 
31
31
  // src/auth/email/utils.ts
32
32
  var import_jsonwebtoken2 = require("jsonwebtoken");
33
+ var import_headers2 = require("next/headers");
33
34
 
34
35
  // src/auth/email/token.ts
35
36
  var import_bcryptjs = require("bcryptjs");
@@ -4,6 +4,7 @@ import { v4 } from "uuid";
4
4
 
5
5
  // src/auth/email/utils.ts
6
6
  import { verify as verify2 } from "jsonwebtoken";
7
+ import { cookies as cookies2 } from "next/headers";
7
8
 
8
9
  // src/auth/email/token.ts
9
10
  import { compare } from "bcryptjs";
@@ -627,6 +627,7 @@ function getEnv(key, skipCheck) {
627
627
 
628
628
  // src/auth/email/utils.ts
629
629
  var import_jsonwebtoken2 = require("jsonwebtoken");
630
+ var import_headers2 = require("next/headers");
630
631
 
631
632
  // src/auth/email/token.ts
632
633
  var import_bcryptjs = require("bcryptjs");
@@ -716,7 +717,7 @@ async function initGraphQLServer({
716
717
  }
717
718
 
718
719
  // src/graphql/utils.ts
719
- var import_headers2 = require("next/headers");
720
+ var import_headers3 = require("next/headers");
720
721
  var import_react = require("react");
721
722
  var import_type_graphql2 = require("type-graphql");
722
723
  function query(fn, options) {
@@ -728,7 +729,7 @@ function query(fn, options) {
728
729
  };
729
730
  }
730
731
  var getUserId = async () => {
731
- const Cookie = await (0, import_headers2.cookies)();
732
+ const Cookie = await (0, import_headers3.cookies)();
732
733
  const refresh = Cookie.get(REFRESH_COOKIE_NAME)?.value;
733
734
  return refresh ? getUserIdFromRefreshToken(refresh) : null;
734
735
  };
@@ -614,6 +614,7 @@ function getEnv(key, skipCheck) {
614
614
 
615
615
  // src/auth/email/utils.ts
616
616
  import { verify as verify2 } from "jsonwebtoken";
617
+ import { cookies as cookies2 } from "next/headers";
617
618
 
618
619
  // src/auth/email/token.ts
619
620
  import { compare } from "bcryptjs";
@@ -703,7 +704,7 @@ async function initGraphQLServer({
703
704
  }
704
705
 
705
706
  // src/graphql/utils.ts
706
- import { cookies as cookies2 } from "next/headers";
707
+ import { cookies as cookies3 } from "next/headers";
707
708
  import { cache } from "react";
708
709
  import {
709
710
  Arg,
@@ -724,7 +725,7 @@ function query(fn, options) {
724
725
  };
725
726
  }
726
727
  var getUserId = async () => {
727
- const Cookie = await cookies2();
728
+ const Cookie = await cookies3();
728
729
  const refresh = Cookie.get(REFRESH_COOKIE_NAME)?.value;
729
730
  return refresh ? getUserIdFromRefreshToken(refresh) : null;
730
731
  };
@@ -80,6 +80,7 @@ function getEnv(key, skipCheck) {
80
80
 
81
81
  // src/auth/email/utils.ts
82
82
  var import_jsonwebtoken2 = require("jsonwebtoken");
83
+ var import_headers2 = require("next/headers");
83
84
 
84
85
  // src/auth/email/token.ts
85
86
  var import_bcryptjs = require("bcryptjs");
@@ -61,6 +61,7 @@ function getEnv(key, skipCheck) {
61
61
 
62
62
  // src/auth/email/utils.ts
63
63
  import { verify as verify2 } from "jsonwebtoken";
64
+ import { cookies as cookies2 } from "next/headers";
64
65
 
65
66
  // src/auth/email/token.ts
66
67
  import { compare } from "bcryptjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
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",