naystack 1.3.0 → 1.3.1
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 +4 -2
- package/dist/auth/email/client.d.ts +4 -2
- package/dist/auth/email/index.cjs.js +2 -2
- package/dist/auth/email/index.esm.js +2 -2
- package/dist/auth/email/routes/post.cjs.js +1 -1
- package/dist/auth/email/routes/post.esm.js +1 -1
- package/dist/auth/email/routes/put.cjs.js +1 -1
- package/dist/auth/email/routes/put.esm.js +1 -1
- package/dist/auth/email/types.d.mts +2 -2
- package/dist/auth/email/types.d.ts +2 -2
- package/dist/auth/index.cjs.js +2 -2
- package/dist/auth/index.esm.js +2 -2
- package/dist/auth/types.d.mts +0 -2
- package/dist/auth/types.d.ts +0 -2
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React__default, { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { UserInput } from '../types.mjs';
|
|
3
|
+
import 'next/server';
|
|
2
4
|
|
|
3
5
|
declare const TokenContext: React__default.Context<{
|
|
4
6
|
token: string | null;
|
|
@@ -10,8 +12,8 @@ declare const getAuthWrapper: (endpoint: string) => ({ children }: {
|
|
|
10
12
|
declare function useToken(): string | null;
|
|
11
13
|
declare function useSetToken(): React__default.Dispatch<React__default.SetStateAction<string | null>>;
|
|
12
14
|
declare function getEmailAuthUtils(endpoint: string): {
|
|
13
|
-
useSignUp: () => (data:
|
|
14
|
-
useLogin: () => (data:
|
|
15
|
+
useSignUp: () => (data: UserInput) => Promise<string | null>;
|
|
16
|
+
useLogin: () => (data: UserInput) => Promise<string | null>;
|
|
15
17
|
useLogout: () => (data?: object) => Promise<void>;
|
|
16
18
|
};
|
|
17
19
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React__default, { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { UserInput } from '../types.js';
|
|
3
|
+
import 'next/server';
|
|
2
4
|
|
|
3
5
|
declare const TokenContext: React__default.Context<{
|
|
4
6
|
token: string | null;
|
|
@@ -10,8 +12,8 @@ declare const getAuthWrapper: (endpoint: string) => ({ children }: {
|
|
|
10
12
|
declare function useToken(): string | null;
|
|
11
13
|
declare function useSetToken(): React__default.Dispatch<React__default.SetStateAction<string | null>>;
|
|
12
14
|
declare function getEmailAuthUtils(endpoint: string): {
|
|
13
|
-
useSignUp: () => (data:
|
|
14
|
-
useLogin: () => (data:
|
|
15
|
+
useSignUp: () => (data: UserInput) => Promise<string | null>;
|
|
16
|
+
useLogin: () => (data: UserInput) => Promise<string | null>;
|
|
15
17
|
useLogout: () => (data?: object) => Promise<void>;
|
|
16
18
|
};
|
|
17
19
|
|
|
@@ -179,7 +179,7 @@ var import_bcryptjs2 = require("bcryptjs");
|
|
|
179
179
|
var getPostRoute = (options) => async (req) => {
|
|
180
180
|
const { data, error } = await massageRequest(req, options);
|
|
181
181
|
if (error || !data) return error;
|
|
182
|
-
const existingUser = await options.getUser(data
|
|
182
|
+
const existingUser = await options.getUser(data);
|
|
183
183
|
if (existingUser) {
|
|
184
184
|
if (await verifyUser(existingUser, data.password)) {
|
|
185
185
|
return getTokenizedResponse(
|
|
@@ -210,7 +210,7 @@ var getPostRoute = (options) => async (req) => {
|
|
|
210
210
|
var getPutRoute = (options) => async (req) => {
|
|
211
211
|
const { data, error } = await massageRequest(req, options);
|
|
212
212
|
if (error || !data) return error;
|
|
213
|
-
const user = await options.getUser(data
|
|
213
|
+
const user = await options.getUser(data);
|
|
214
214
|
if (!user)
|
|
215
215
|
return handleError(400, "A user does not exist", options.onError);
|
|
216
216
|
if (await verifyUser(user, data.password)) {
|
|
@@ -153,7 +153,7 @@ import { hash } from "bcryptjs";
|
|
|
153
153
|
var getPostRoute = (options) => async (req) => {
|
|
154
154
|
const { data, error } = await massageRequest(req, options);
|
|
155
155
|
if (error || !data) return error;
|
|
156
|
-
const existingUser = await options.getUser(data
|
|
156
|
+
const existingUser = await options.getUser(data);
|
|
157
157
|
if (existingUser) {
|
|
158
158
|
if (await verifyUser(existingUser, data.password)) {
|
|
159
159
|
return getTokenizedResponse(
|
|
@@ -184,7 +184,7 @@ var getPostRoute = (options) => async (req) => {
|
|
|
184
184
|
var getPutRoute = (options) => async (req) => {
|
|
185
185
|
const { data, error } = await massageRequest(req, options);
|
|
186
186
|
if (error || !data) return error;
|
|
187
|
-
const user = await options.getUser(data
|
|
187
|
+
const user = await options.getUser(data);
|
|
188
188
|
if (!user)
|
|
189
189
|
return handleError(400, "A user does not exist", options.onError);
|
|
190
190
|
if (await verifyUser(user, data.password)) {
|
|
@@ -120,7 +120,7 @@ async function verifyCaptcha(token, secret) {
|
|
|
120
120
|
var getPostRoute = (options) => async (req) => {
|
|
121
121
|
const { data, error } = await massageRequest(req, options);
|
|
122
122
|
if (error || !data) return error;
|
|
123
|
-
const existingUser = await options.getUser(data
|
|
123
|
+
const existingUser = await options.getUser(data);
|
|
124
124
|
if (existingUser) {
|
|
125
125
|
if (await verifyUser(existingUser, data.password)) {
|
|
126
126
|
return getTokenizedResponse(
|
|
@@ -96,7 +96,7 @@ async function verifyCaptcha(token, secret) {
|
|
|
96
96
|
var getPostRoute = (options) => async (req) => {
|
|
97
97
|
const { data, error } = await massageRequest(req, options);
|
|
98
98
|
if (error || !data) return error;
|
|
99
|
-
const existingUser = await options.getUser(data
|
|
99
|
+
const existingUser = await options.getUser(data);
|
|
100
100
|
if (existingUser) {
|
|
101
101
|
if (await verifyUser(existingUser, data.password)) {
|
|
102
102
|
return getTokenizedResponse(
|
|
@@ -119,7 +119,7 @@ async function verifyCaptcha(token, secret) {
|
|
|
119
119
|
var getPutRoute = (options) => async (req) => {
|
|
120
120
|
const { data, error } = await massageRequest(req, options);
|
|
121
121
|
if (error || !data) return error;
|
|
122
|
-
const user = await options.getUser(data
|
|
122
|
+
const user = await options.getUser(data);
|
|
123
123
|
if (!user)
|
|
124
124
|
return handleError(400, "A user does not exist", options.onError);
|
|
125
125
|
if (await verifyUser(user, data.password)) {
|
|
@@ -93,7 +93,7 @@ async function verifyCaptcha(token, secret) {
|
|
|
93
93
|
var getPutRoute = (options) => async (req) => {
|
|
94
94
|
const { data, error } = await massageRequest(req, options);
|
|
95
95
|
if (error || !data) return error;
|
|
96
|
-
const user = await options.getUser(data
|
|
96
|
+
const user = await options.getUser(data);
|
|
97
97
|
if (!user)
|
|
98
98
|
return handleError(400, "A user does not exist", options.onError);
|
|
99
99
|
if (await verifyUser(user, data.password)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
|
-
import {
|
|
2
|
+
import { UserInput, UserOutput, ErrorHandler } from '../types.mjs';
|
|
3
3
|
|
|
4
4
|
type InitRoutesOptions = {
|
|
5
|
-
getUser: (
|
|
5
|
+
getUser: (data: UserInput) => Promise<UserOutput | undefined>;
|
|
6
6
|
createUser: (user: UserInput) => Promise<UserOutput | undefined>;
|
|
7
7
|
onError?: ErrorHandler;
|
|
8
8
|
keys: AuthKeys;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
|
-
import {
|
|
2
|
+
import { UserInput, UserOutput, ErrorHandler } from '../types.js';
|
|
3
3
|
|
|
4
4
|
type InitRoutesOptions = {
|
|
5
|
-
getUser: (
|
|
5
|
+
getUser: (data: UserInput) => Promise<UserOutput | undefined>;
|
|
6
6
|
createUser: (user: UserInput) => Promise<UserOutput | undefined>;
|
|
7
7
|
onError?: ErrorHandler;
|
|
8
8
|
keys: AuthKeys;
|
package/dist/auth/index.cjs.js
CHANGED
|
@@ -193,7 +193,7 @@ var import_bcryptjs2 = require("bcryptjs");
|
|
|
193
193
|
var getPostRoute = (options) => async (req) => {
|
|
194
194
|
const { data, error } = await massageRequest(req, options);
|
|
195
195
|
if (error || !data) return error;
|
|
196
|
-
const existingUser = await options.getUser(data
|
|
196
|
+
const existingUser = await options.getUser(data);
|
|
197
197
|
if (existingUser) {
|
|
198
198
|
if (await verifyUser(existingUser, data.password)) {
|
|
199
199
|
return getTokenizedResponse(
|
|
@@ -224,7 +224,7 @@ var getPostRoute = (options) => async (req) => {
|
|
|
224
224
|
var getPutRoute = (options) => async (req) => {
|
|
225
225
|
const { data, error } = await massageRequest(req, options);
|
|
226
226
|
if (error || !data) return error;
|
|
227
|
-
const user = await options.getUser(data
|
|
227
|
+
const user = await options.getUser(data);
|
|
228
228
|
if (!user)
|
|
229
229
|
return handleError(400, "A user does not exist", options.onError);
|
|
230
230
|
if (await verifyUser(user, data.password)) {
|
package/dist/auth/index.esm.js
CHANGED
|
@@ -165,7 +165,7 @@ import { hash } from "bcryptjs";
|
|
|
165
165
|
var getPostRoute = (options) => async (req) => {
|
|
166
166
|
const { data, error } = await massageRequest(req, options);
|
|
167
167
|
if (error || !data) return error;
|
|
168
|
-
const existingUser = await options.getUser(data
|
|
168
|
+
const existingUser = await options.getUser(data);
|
|
169
169
|
if (existingUser) {
|
|
170
170
|
if (await verifyUser(existingUser, data.password)) {
|
|
171
171
|
return getTokenizedResponse(
|
|
@@ -196,7 +196,7 @@ var getPostRoute = (options) => async (req) => {
|
|
|
196
196
|
var getPutRoute = (options) => async (req) => {
|
|
197
197
|
const { data, error } = await massageRequest(req, options);
|
|
198
198
|
if (error || !data) return error;
|
|
199
|
-
const user = await options.getUser(data
|
|
199
|
+
const user = await options.getUser(data);
|
|
200
200
|
if (!user)
|
|
201
201
|
return handleError(400, "A user does not exist", options.onError);
|
|
202
202
|
if (await verifyUser(user, data.password)) {
|
package/dist/auth/types.d.mts
CHANGED
|
@@ -5,14 +5,12 @@ type ErrorHandler = (error: {
|
|
|
5
5
|
message: string;
|
|
6
6
|
}) => NextResponse;
|
|
7
7
|
type UserInput = {
|
|
8
|
-
email: string;
|
|
9
8
|
password: string;
|
|
10
9
|
} & {
|
|
11
10
|
[key: string]: unknown;
|
|
12
11
|
};
|
|
13
12
|
type UserOutput = {
|
|
14
13
|
id: number;
|
|
15
|
-
email: string;
|
|
16
14
|
password: string | null;
|
|
17
15
|
} & {
|
|
18
16
|
[key: string]: unknown;
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -5,14 +5,12 @@ type ErrorHandler = (error: {
|
|
|
5
5
|
message: string;
|
|
6
6
|
}) => NextResponse;
|
|
7
7
|
type UserInput = {
|
|
8
|
-
email: string;
|
|
9
8
|
password: string;
|
|
10
9
|
} & {
|
|
11
10
|
[key: string]: unknown;
|
|
12
11
|
};
|
|
13
12
|
type UserOutput = {
|
|
14
13
|
id: number;
|
|
15
|
-
email: string;
|
|
16
14
|
password: string | null;
|
|
17
15
|
} & {
|
|
18
16
|
[key: string]: unknown;
|