naystack 1.4.4 → 1.4.5
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.
- package/dist/auth/email/index.cjs.js +9 -0
- package/dist/auth/email/index.d.mts +1 -0
- package/dist/auth/email/index.d.ts +1 -0
- package/dist/auth/email/index.esm.js +8 -0
- package/dist/auth/index.cjs.js +9 -0
- package/dist/auth/index.d.mts +1 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.esm.js +8 -0
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/auth/email/index.ts
|
|
21
21
|
var email_exports = {};
|
|
22
22
|
__export(email_exports, {
|
|
23
|
+
checkAuthStatus: () => checkAuthStatus,
|
|
23
24
|
getEmailAuthRoutes: () => getEmailAuthRoutes
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(email_exports);
|
|
@@ -83,6 +84,13 @@ function verifyUser(user, password) {
|
|
|
83
84
|
if (!user.password) return false;
|
|
84
85
|
return (0, import_bcryptjs.compare)(password, user.password);
|
|
85
86
|
}
|
|
87
|
+
async function checkAuthStatus(redirectUnauthorizedURL) {
|
|
88
|
+
const Cookie = await (0, import_headers.cookies)();
|
|
89
|
+
const isAuthorized = !!Cookie.get(REFRESH_COOKIE_NAME)?.value;
|
|
90
|
+
if (!isAuthorized && redirectUnauthorizedURL)
|
|
91
|
+
return (0, import_navigation.redirect)(redirectUnauthorizedURL);
|
|
92
|
+
return isAuthorized;
|
|
93
|
+
}
|
|
86
94
|
|
|
87
95
|
// src/auth/utils/errors.ts
|
|
88
96
|
var import_server2 = require("next/server");
|
|
@@ -246,5 +254,6 @@ function getEmailAuthRoutes(options) {
|
|
|
246
254
|
}
|
|
247
255
|
// Annotate the CommonJS export names for ESM import in node:
|
|
248
256
|
0 && (module.exports = {
|
|
257
|
+
checkAuthStatus,
|
|
249
258
|
getEmailAuthRoutes
|
|
250
259
|
});
|
|
@@ -2,6 +2,7 @@ import * as next_server from 'next/server';
|
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
3
|
import { Context } from '../../graphql/types.mjs';
|
|
4
4
|
import { InitRoutesOptions } from './types.mjs';
|
|
5
|
+
export { checkAuthStatus } from './token.mjs';
|
|
5
6
|
import '../types.mjs';
|
|
6
7
|
|
|
7
8
|
declare function getEmailAuthRoutes(options: InitRoutesOptions): {
|
|
@@ -2,6 +2,7 @@ import * as next_server from 'next/server';
|
|
|
2
2
|
import { NextRequest } from 'next/server';
|
|
3
3
|
import { Context } from '../../graphql/types.js';
|
|
4
4
|
import { InitRoutesOptions } from './types.js';
|
|
5
|
+
export { checkAuthStatus } from './token.js';
|
|
5
6
|
import '../types.js';
|
|
6
7
|
|
|
7
8
|
declare function getEmailAuthRoutes(options: InitRoutesOptions): {
|
|
@@ -57,6 +57,13 @@ function verifyUser(user, password) {
|
|
|
57
57
|
if (!user.password) return false;
|
|
58
58
|
return compare(password, user.password);
|
|
59
59
|
}
|
|
60
|
+
async function checkAuthStatus(redirectUnauthorizedURL) {
|
|
61
|
+
const Cookie = await cookies();
|
|
62
|
+
const isAuthorized = !!Cookie.get(REFRESH_COOKIE_NAME)?.value;
|
|
63
|
+
if (!isAuthorized && redirectUnauthorizedURL)
|
|
64
|
+
return redirect(redirectUnauthorizedURL);
|
|
65
|
+
return isAuthorized;
|
|
66
|
+
}
|
|
60
67
|
|
|
61
68
|
// src/auth/utils/errors.ts
|
|
62
69
|
import { NextResponse as NextResponse2 } from "next/server";
|
|
@@ -219,5 +226,6 @@ function getEmailAuthRoutes(options) {
|
|
|
219
226
|
};
|
|
220
227
|
}
|
|
221
228
|
export {
|
|
229
|
+
checkAuthStatus,
|
|
222
230
|
getEmailAuthRoutes
|
|
223
231
|
};
|
package/dist/auth/index.cjs.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/auth/index.ts
|
|
21
21
|
var auth_exports = {};
|
|
22
22
|
__export(auth_exports, {
|
|
23
|
+
checkAuthStatus: () => checkAuthStatus,
|
|
23
24
|
getEmailAuthRoutes: () => getEmailAuthRoutes,
|
|
24
25
|
initGoogleAuth: () => initGoogleAuth,
|
|
25
26
|
initInstagramAuth: () => initInstagramAuth
|
|
@@ -97,6 +98,13 @@ function verifyUser(user, password) {
|
|
|
97
98
|
if (!user.password) return false;
|
|
98
99
|
return (0, import_bcryptjs.compare)(password, user.password);
|
|
99
100
|
}
|
|
101
|
+
async function checkAuthStatus(redirectUnauthorizedURL) {
|
|
102
|
+
const Cookie = await (0, import_headers.cookies)();
|
|
103
|
+
const isAuthorized = !!Cookie.get(REFRESH_COOKIE_NAME)?.value;
|
|
104
|
+
if (!isAuthorized && redirectUnauthorizedURL)
|
|
105
|
+
return (0, import_navigation.redirect)(redirectUnauthorizedURL);
|
|
106
|
+
return isAuthorized;
|
|
107
|
+
}
|
|
100
108
|
|
|
101
109
|
// src/auth/utils/errors.ts
|
|
102
110
|
var import_server2 = require("next/server");
|
|
@@ -453,6 +461,7 @@ function initInstagramAuth(props) {
|
|
|
453
461
|
}
|
|
454
462
|
// Annotate the CommonJS export names for ESM import in node:
|
|
455
463
|
0 && (module.exports = {
|
|
464
|
+
checkAuthStatus,
|
|
456
465
|
getEmailAuthRoutes,
|
|
457
466
|
initGoogleAuth,
|
|
458
467
|
initInstagramAuth
|
package/dist/auth/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { getEmailAuthRoutes } from './email/index.mjs';
|
|
2
2
|
export { initGoogleAuth } from './google/index.mjs';
|
|
3
3
|
export { initInstagramAuth } from './instagram/index.mjs';
|
|
4
|
+
export { checkAuthStatus } from './email/token.mjs';
|
|
4
5
|
import 'next/server';
|
|
5
6
|
import '../graphql/types.mjs';
|
|
6
7
|
import './email/types.mjs';
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { getEmailAuthRoutes } from './email/index.js';
|
|
2
2
|
export { initGoogleAuth } from './google/index.js';
|
|
3
3
|
export { initInstagramAuth } from './instagram/index.js';
|
|
4
|
+
export { checkAuthStatus } from './email/token.js';
|
|
4
5
|
import 'next/server';
|
|
5
6
|
import '../graphql/types.js';
|
|
6
7
|
import './email/types.js';
|
package/dist/auth/index.esm.js
CHANGED
|
@@ -69,6 +69,13 @@ function verifyUser(user, password) {
|
|
|
69
69
|
if (!user.password) return false;
|
|
70
70
|
return compare(password, user.password);
|
|
71
71
|
}
|
|
72
|
+
async function checkAuthStatus(redirectUnauthorizedURL) {
|
|
73
|
+
const Cookie = await cookies();
|
|
74
|
+
const isAuthorized = !!Cookie.get(REFRESH_COOKIE_NAME)?.value;
|
|
75
|
+
if (!isAuthorized && redirectUnauthorizedURL)
|
|
76
|
+
return redirect(redirectUnauthorizedURL);
|
|
77
|
+
return isAuthorized;
|
|
78
|
+
}
|
|
72
79
|
|
|
73
80
|
// src/auth/utils/errors.ts
|
|
74
81
|
import { NextResponse as NextResponse2 } from "next/server";
|
|
@@ -424,6 +431,7 @@ function initInstagramAuth(props) {
|
|
|
424
431
|
};
|
|
425
432
|
}
|
|
426
433
|
export {
|
|
434
|
+
checkAuthStatus,
|
|
427
435
|
getEmailAuthRoutes,
|
|
428
436
|
initGoogleAuth,
|
|
429
437
|
initInstagramAuth
|