naystack 1.4.0 → 1.4.2
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/client.d.mts +2 -4
- package/dist/auth/email/client.d.ts +2 -4
- package/dist/auth/email/index.cjs.js +5 -3
- package/dist/auth/email/index.esm.js +5 -3
- package/dist/auth/email/routes/post.cjs.js +5 -3
- package/dist/auth/email/routes/post.esm.js +5 -3
- package/dist/auth/email/routes/put.cjs.js +5 -3
- package/dist/auth/email/routes/put.esm.js +5 -3
- package/dist/auth/email/types.d.mts +3 -3
- package/dist/auth/email/types.d.ts +3 -3
- package/dist/auth/email/utils.cjs.js +5 -3
- package/dist/auth/email/utils.d.mts +0 -1
- package/dist/auth/email/utils.d.ts +0 -1
- package/dist/auth/email/utils.esm.js +5 -3
- package/dist/auth/index.cjs.js +5 -3
- package/dist/auth/index.esm.js +5 -3
- package/dist/auth/types.d.mts +1 -6
- package/dist/auth/types.d.ts +1 -6
- package/package.json +1 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React__default, { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { UserInput } from '../types.mjs';
|
|
3
|
-
import 'next/server';
|
|
4
2
|
|
|
5
3
|
declare const TokenContext: React__default.Context<{
|
|
6
4
|
token: string | null;
|
|
@@ -12,8 +10,8 @@ declare const getAuthWrapper: (endpoint: string) => ({ children }: {
|
|
|
12
10
|
declare function useToken(): string | null;
|
|
13
11
|
declare function useSetToken(): React__default.Dispatch<React__default.SetStateAction<string | null>>;
|
|
14
12
|
declare function getEmailAuthUtils(endpoint: string): {
|
|
15
|
-
useSignUp: () => (data:
|
|
16
|
-
useLogin: () => (data:
|
|
13
|
+
useSignUp: () => (data: object) => Promise<string | null>;
|
|
14
|
+
useLogin: () => (data: object) => Promise<string | null>;
|
|
17
15
|
useLogout: () => (data?: object) => Promise<void>;
|
|
18
16
|
};
|
|
19
17
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React__default, { Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { UserInput } from '../types.js';
|
|
3
|
-
import 'next/server';
|
|
4
2
|
|
|
5
3
|
declare const TokenContext: React__default.Context<{
|
|
6
4
|
token: string | null;
|
|
@@ -12,8 +10,8 @@ declare const getAuthWrapper: (endpoint: string) => ({ children }: {
|
|
|
12
10
|
declare function useToken(): string | null;
|
|
13
11
|
declare function useSetToken(): React__default.Dispatch<React__default.SetStateAction<string | null>>;
|
|
14
12
|
declare function getEmailAuthUtils(endpoint: string): {
|
|
15
|
-
useSignUp: () => (data:
|
|
16
|
-
useLogin: () => (data:
|
|
13
|
+
useSignUp: () => (data: object) => Promise<string | null>;
|
|
14
|
+
useLogin: () => (data: object) => Promise<string | null>;
|
|
17
15
|
useLogout: () => (data?: object) => Promise<void>;
|
|
18
16
|
};
|
|
19
17
|
|
|
@@ -88,13 +88,15 @@ function handleError(status, message, onError) {
|
|
|
88
88
|
// src/auth/email/utils.ts
|
|
89
89
|
async function massageRequest(req, options) {
|
|
90
90
|
const data = await req.json();
|
|
91
|
-
if (!data.
|
|
91
|
+
if (!data.password)
|
|
92
92
|
return {
|
|
93
|
-
error: handleError(400, "Missing
|
|
93
|
+
error: handleError(400, "Missing password", options.onError)
|
|
94
94
|
};
|
|
95
95
|
if (options.turnstileKey) {
|
|
96
96
|
if (!data.captchaToken)
|
|
97
|
-
return {
|
|
97
|
+
return {
|
|
98
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
99
|
+
};
|
|
98
100
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
99
101
|
return {
|
|
100
102
|
error: handleError(400, "Invalid captcha", options.onError)
|
|
@@ -62,13 +62,15 @@ function handleError(status, message, onError) {
|
|
|
62
62
|
// src/auth/email/utils.ts
|
|
63
63
|
async function massageRequest(req, options) {
|
|
64
64
|
const data = await req.json();
|
|
65
|
-
if (!data.
|
|
65
|
+
if (!data.password)
|
|
66
66
|
return {
|
|
67
|
-
error: handleError(400, "Missing
|
|
67
|
+
error: handleError(400, "Missing password", options.onError)
|
|
68
68
|
};
|
|
69
69
|
if (options.turnstileKey) {
|
|
70
70
|
if (!data.captchaToken)
|
|
71
|
-
return {
|
|
71
|
+
return {
|
|
72
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
73
|
+
};
|
|
72
74
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
73
75
|
return {
|
|
74
76
|
error: handleError(400, "Invalid captcha", options.onError)
|
|
@@ -75,13 +75,15 @@ function verifyUser(user, password) {
|
|
|
75
75
|
var import_jsonwebtoken2 = require("jsonwebtoken");
|
|
76
76
|
async function massageRequest(req, options) {
|
|
77
77
|
const data = await req.json();
|
|
78
|
-
if (!data.
|
|
78
|
+
if (!data.password)
|
|
79
79
|
return {
|
|
80
|
-
error: handleError(400, "Missing
|
|
80
|
+
error: handleError(400, "Missing password", options.onError)
|
|
81
81
|
};
|
|
82
82
|
if (options.turnstileKey) {
|
|
83
83
|
if (!data.captchaToken)
|
|
84
|
-
return {
|
|
84
|
+
return {
|
|
85
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
86
|
+
};
|
|
85
87
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
86
88
|
return {
|
|
87
89
|
error: handleError(400, "Invalid captcha", options.onError)
|
|
@@ -51,13 +51,15 @@ function verifyUser(user, password) {
|
|
|
51
51
|
import { verify as verify2 } from "jsonwebtoken";
|
|
52
52
|
async function massageRequest(req, options) {
|
|
53
53
|
const data = await req.json();
|
|
54
|
-
if (!data.
|
|
54
|
+
if (!data.password)
|
|
55
55
|
return {
|
|
56
|
-
error: handleError(400, "Missing
|
|
56
|
+
error: handleError(400, "Missing password", options.onError)
|
|
57
57
|
};
|
|
58
58
|
if (options.turnstileKey) {
|
|
59
59
|
if (!data.captchaToken)
|
|
60
|
-
return {
|
|
60
|
+
return {
|
|
61
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
62
|
+
};
|
|
61
63
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
62
64
|
return {
|
|
63
65
|
error: handleError(400, "Invalid captcha", options.onError)
|
|
@@ -74,13 +74,15 @@ function verifyUser(user, password) {
|
|
|
74
74
|
var import_jsonwebtoken2 = require("jsonwebtoken");
|
|
75
75
|
async function massageRequest(req, options) {
|
|
76
76
|
const data = await req.json();
|
|
77
|
-
if (!data.
|
|
77
|
+
if (!data.password)
|
|
78
78
|
return {
|
|
79
|
-
error: handleError(400, "Missing
|
|
79
|
+
error: handleError(400, "Missing password", options.onError)
|
|
80
80
|
};
|
|
81
81
|
if (options.turnstileKey) {
|
|
82
82
|
if (!data.captchaToken)
|
|
83
|
-
return {
|
|
83
|
+
return {
|
|
84
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
85
|
+
};
|
|
84
86
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
85
87
|
return {
|
|
86
88
|
error: handleError(400, "Invalid captcha", options.onError)
|
|
@@ -48,13 +48,15 @@ function verifyUser(user, password) {
|
|
|
48
48
|
import { verify as verify2 } from "jsonwebtoken";
|
|
49
49
|
async function massageRequest(req, options) {
|
|
50
50
|
const data = await req.json();
|
|
51
|
-
if (!data.
|
|
51
|
+
if (!data.password)
|
|
52
52
|
return {
|
|
53
|
-
error: handleError(400, "Missing
|
|
53
|
+
error: handleError(400, "Missing password", options.onError)
|
|
54
54
|
};
|
|
55
55
|
if (options.turnstileKey) {
|
|
56
56
|
if (!data.captchaToken)
|
|
57
|
-
return {
|
|
57
|
+
return {
|
|
58
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
59
|
+
};
|
|
58
60
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
59
61
|
return {
|
|
60
62
|
error: handleError(400, "Invalid captcha", options.onError)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
|
-
import {
|
|
2
|
+
import { UserOutput, ErrorHandler } from '../types.mjs';
|
|
3
3
|
|
|
4
4
|
type InitRoutesOptions = {
|
|
5
|
-
getUser: (data:
|
|
6
|
-
createUser: (user:
|
|
5
|
+
getUser: (data: any) => Promise<UserOutput | undefined>;
|
|
6
|
+
createUser: (user: any) => Promise<UserOutput | undefined>;
|
|
7
7
|
onError?: ErrorHandler;
|
|
8
8
|
keys: AuthKeys;
|
|
9
9
|
turnstileKey?: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
|
-
import {
|
|
2
|
+
import { UserOutput, ErrorHandler } from '../types.js';
|
|
3
3
|
|
|
4
4
|
type InitRoutesOptions = {
|
|
5
|
-
getUser: (data:
|
|
6
|
-
createUser: (user:
|
|
5
|
+
getUser: (data: any) => Promise<UserOutput | undefined>;
|
|
6
|
+
createUser: (user: any) => Promise<UserOutput | undefined>;
|
|
7
7
|
onError?: ErrorHandler;
|
|
8
8
|
keys: AuthKeys;
|
|
9
9
|
turnstileKey?: string;
|
|
@@ -55,13 +55,15 @@ function handleError(status, message, onError) {
|
|
|
55
55
|
// src/auth/email/utils.ts
|
|
56
56
|
async function massageRequest(req, options) {
|
|
57
57
|
const data = await req.json();
|
|
58
|
-
if (!data.
|
|
58
|
+
if (!data.password)
|
|
59
59
|
return {
|
|
60
|
-
error: handleError(400, "Missing
|
|
60
|
+
error: handleError(400, "Missing password", options.onError)
|
|
61
61
|
};
|
|
62
62
|
if (options.turnstileKey) {
|
|
63
63
|
if (!data.captchaToken)
|
|
64
|
-
return {
|
|
64
|
+
return {
|
|
65
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
66
|
+
};
|
|
65
67
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
66
68
|
return {
|
|
67
69
|
error: handleError(400, "Invalid captcha", options.onError)
|
|
@@ -29,13 +29,15 @@ function handleError(status, message, onError) {
|
|
|
29
29
|
// src/auth/email/utils.ts
|
|
30
30
|
async function massageRequest(req, options) {
|
|
31
31
|
const data = await req.json();
|
|
32
|
-
if (!data.
|
|
32
|
+
if (!data.password)
|
|
33
33
|
return {
|
|
34
|
-
error: handleError(400, "Missing
|
|
34
|
+
error: handleError(400, "Missing password", options.onError)
|
|
35
35
|
};
|
|
36
36
|
if (options.turnstileKey) {
|
|
37
37
|
if (!data.captchaToken)
|
|
38
|
-
return {
|
|
38
|
+
return {
|
|
39
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
40
|
+
};
|
|
39
41
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
40
42
|
return {
|
|
41
43
|
error: handleError(400, "Invalid captcha", options.onError)
|
package/dist/auth/index.cjs.js
CHANGED
|
@@ -102,13 +102,15 @@ function handleError(status, message, onError) {
|
|
|
102
102
|
// src/auth/email/utils.ts
|
|
103
103
|
async function massageRequest(req, options) {
|
|
104
104
|
const data = await req.json();
|
|
105
|
-
if (!data.
|
|
105
|
+
if (!data.password)
|
|
106
106
|
return {
|
|
107
|
-
error: handleError(400, "Missing
|
|
107
|
+
error: handleError(400, "Missing password", options.onError)
|
|
108
108
|
};
|
|
109
109
|
if (options.turnstileKey) {
|
|
110
110
|
if (!data.captchaToken)
|
|
111
|
-
return {
|
|
111
|
+
return {
|
|
112
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
113
|
+
};
|
|
112
114
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
113
115
|
return {
|
|
114
116
|
error: handleError(400, "Invalid captcha", options.onError)
|
package/dist/auth/index.esm.js
CHANGED
|
@@ -74,13 +74,15 @@ function handleError(status, message, onError) {
|
|
|
74
74
|
// src/auth/email/utils.ts
|
|
75
75
|
async function massageRequest(req, options) {
|
|
76
76
|
const data = await req.json();
|
|
77
|
-
if (!data.
|
|
77
|
+
if (!data.password)
|
|
78
78
|
return {
|
|
79
|
-
error: handleError(400, "Missing
|
|
79
|
+
error: handleError(400, "Missing password", options.onError)
|
|
80
80
|
};
|
|
81
81
|
if (options.turnstileKey) {
|
|
82
82
|
if (!data.captchaToken)
|
|
83
|
-
return {
|
|
83
|
+
return {
|
|
84
|
+
error: handleError(400, "Missing captchaToken", options.onError)
|
|
85
|
+
};
|
|
84
86
|
if (!await verifyCaptcha(data.captchaToken, options.turnstileKey))
|
|
85
87
|
return {
|
|
86
88
|
error: handleError(400, "Invalid captcha", options.onError)
|
package/dist/auth/types.d.mts
CHANGED
|
@@ -4,11 +4,6 @@ type ErrorHandler = (error: {
|
|
|
4
4
|
status: number;
|
|
5
5
|
message: string;
|
|
6
6
|
}) => NextResponse;
|
|
7
|
-
type UserInput = {
|
|
8
|
-
password: string;
|
|
9
|
-
} & {
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
};
|
|
12
7
|
type UserOutput = {
|
|
13
8
|
id: number;
|
|
14
9
|
password: string | null;
|
|
@@ -16,4 +11,4 @@ type UserOutput = {
|
|
|
16
11
|
[key: string]: unknown;
|
|
17
12
|
};
|
|
18
13
|
|
|
19
|
-
export type { ErrorHandler,
|
|
14
|
+
export type { ErrorHandler, UserOutput };
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -4,11 +4,6 @@ type ErrorHandler = (error: {
|
|
|
4
4
|
status: number;
|
|
5
5
|
message: string;
|
|
6
6
|
}) => NextResponse;
|
|
7
|
-
type UserInput = {
|
|
8
|
-
password: string;
|
|
9
|
-
} & {
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
};
|
|
12
7
|
type UserOutput = {
|
|
13
8
|
id: number;
|
|
14
9
|
password: string | null;
|
|
@@ -16,4 +11,4 @@ type UserOutput = {
|
|
|
16
11
|
[key: string]: unknown;
|
|
17
12
|
};
|
|
18
13
|
|
|
19
|
-
export type { ErrorHandler,
|
|
14
|
+
export type { ErrorHandler, UserOutput };
|