naystack 1.5.20 → 1.5.22
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 +2 -1
- package/dist/auth/email/index.esm.js +5 -4
- package/dist/auth/email/server.cjs.js +2 -1
- package/dist/auth/email/server.d.mts +2 -2
- package/dist/auth/email/server.d.ts +2 -2
- package/dist/auth/email/server.esm.js +5 -4
- package/dist/auth/google/get.cjs.js +5 -2
- package/dist/auth/google/get.esm.js +5 -2
- package/dist/auth/google/index.cjs.js +5 -2
- package/dist/auth/google/index.d.mts +1 -1
- package/dist/auth/google/index.d.ts +1 -1
- package/dist/auth/google/index.esm.js +5 -2
- package/dist/auth/index.cjs.js +7 -3
- package/dist/auth/index.esm.js +10 -6
- package/package.json +1 -1
|
@@ -312,6 +312,7 @@ var getPutRoute = (options) => async (req) => {
|
|
|
312
312
|
// src/auth/email/server.tsx
|
|
313
313
|
var import_client2 = require("naystack/auth/email/client");
|
|
314
314
|
var import_headers3 = require("next/headers");
|
|
315
|
+
var import_react3 = __toESM(require("react"));
|
|
315
316
|
|
|
316
317
|
// src/graphql/server.tsx
|
|
317
318
|
var import_client = require("@apollo/client");
|
|
@@ -345,7 +346,7 @@ var { query: gqlQuery } = (0, import_client_integration_nextjs.registerApolloCli
|
|
|
345
346
|
|
|
346
347
|
// src/auth/email/server.tsx
|
|
347
348
|
function AuthFetch() {
|
|
348
|
-
return /* @__PURE__ */
|
|
349
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
349
350
|
Injector,
|
|
350
351
|
{
|
|
351
352
|
fetch: async () => {
|
|
@@ -273,6 +273,7 @@ var getPutRoute = (options) => async (req) => {
|
|
|
273
273
|
// src/auth/email/server.tsx
|
|
274
274
|
import { AuthApply } from "naystack/auth/email/client";
|
|
275
275
|
import { cookies as cookies3 } from "next/headers";
|
|
276
|
+
import React2 from "react";
|
|
276
277
|
|
|
277
278
|
// src/graphql/server.tsx
|
|
278
279
|
import {
|
|
@@ -282,14 +283,14 @@ import {
|
|
|
282
283
|
} from "@apollo/client";
|
|
283
284
|
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
284
285
|
import { cookies as cookies2 } from "next/headers";
|
|
285
|
-
import
|
|
286
|
+
import React from "react";
|
|
286
287
|
import { Suspense } from "react";
|
|
287
288
|
function Injector({
|
|
288
289
|
fetch: fetch2,
|
|
289
290
|
Component,
|
|
290
291
|
props
|
|
291
292
|
}) {
|
|
292
|
-
return /* @__PURE__ */
|
|
293
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch: fetch2, props }));
|
|
293
294
|
}
|
|
294
295
|
async function InjectorSuspensed({
|
|
295
296
|
fetch: fetch2,
|
|
@@ -297,7 +298,7 @@ async function InjectorSuspensed({
|
|
|
297
298
|
props
|
|
298
299
|
}) {
|
|
299
300
|
const data = await fetch2();
|
|
300
|
-
return /* @__PURE__ */
|
|
301
|
+
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
301
302
|
}
|
|
302
303
|
var { query: gqlQuery } = registerApolloClient(() => {
|
|
303
304
|
return new ApolloClient({
|
|
@@ -310,7 +311,7 @@ var { query: gqlQuery } = registerApolloClient(() => {
|
|
|
310
311
|
|
|
311
312
|
// src/auth/email/server.tsx
|
|
312
313
|
function AuthFetch() {
|
|
313
|
-
return /* @__PURE__ */
|
|
314
|
+
return /* @__PURE__ */ React2.createElement(
|
|
314
315
|
Injector,
|
|
315
316
|
{
|
|
316
317
|
fetch: async () => {
|
|
@@ -35,6 +35,7 @@ __export(server_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(server_exports);
|
|
36
36
|
var import_client2 = require("naystack/auth/email/client");
|
|
37
37
|
var import_headers2 = require("next/headers");
|
|
38
|
+
var import_react3 = __toESM(require("react"));
|
|
38
39
|
|
|
39
40
|
// src/graphql/server.tsx
|
|
40
41
|
var import_client = require("@apollo/client");
|
|
@@ -119,7 +120,7 @@ var { query: gqlQuery } = (0, import_client_integration_nextjs.registerApolloCli
|
|
|
119
120
|
|
|
120
121
|
// src/auth/email/server.tsx
|
|
121
122
|
function AuthFetch() {
|
|
122
|
-
return /* @__PURE__ */
|
|
123
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
123
124
|
Injector,
|
|
124
125
|
{
|
|
125
126
|
fetch: async () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/auth/email/server.tsx
|
|
2
2
|
import { AuthApply } from "naystack/auth/email/client";
|
|
3
3
|
import { cookies as cookies2 } from "next/headers";
|
|
4
|
+
import React2 from "react";
|
|
4
5
|
|
|
5
6
|
// src/graphql/server.tsx
|
|
6
7
|
import {
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
} from "@apollo/client";
|
|
11
12
|
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
12
13
|
import { cookies } from "next/headers";
|
|
13
|
-
import
|
|
14
|
+
import React from "react";
|
|
14
15
|
import { Suspense } from "react";
|
|
15
16
|
|
|
16
17
|
// src/env.ts
|
|
@@ -68,7 +69,7 @@ function Injector({
|
|
|
68
69
|
Component,
|
|
69
70
|
props
|
|
70
71
|
}) {
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch: fetch2, props }));
|
|
72
73
|
}
|
|
73
74
|
async function InjectorSuspensed({
|
|
74
75
|
fetch: fetch2,
|
|
@@ -76,7 +77,7 @@ async function InjectorSuspensed({
|
|
|
76
77
|
props
|
|
77
78
|
}) {
|
|
78
79
|
const data = await fetch2();
|
|
79
|
-
return /* @__PURE__ */
|
|
80
|
+
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
80
81
|
}
|
|
81
82
|
var { query: gqlQuery } = registerApolloClient(() => {
|
|
82
83
|
return new ApolloClient({
|
|
@@ -89,7 +90,7 @@ var { query: gqlQuery } = registerApolloClient(() => {
|
|
|
89
90
|
|
|
90
91
|
// src/auth/email/server.tsx
|
|
91
92
|
function AuthFetch() {
|
|
92
|
-
return /* @__PURE__ */
|
|
93
|
+
return /* @__PURE__ */ React2.createElement(
|
|
93
94
|
Injector,
|
|
94
95
|
{
|
|
95
96
|
fetch: async () => {
|
|
@@ -107,7 +107,9 @@ var getGoogleGetRoute = ({
|
|
|
107
107
|
const code = req.nextUrl.searchParams.get("code");
|
|
108
108
|
const error = req.nextUrl.searchParams.get("error");
|
|
109
109
|
if (!code && !error) {
|
|
110
|
-
const
|
|
110
|
+
const data = req.nextUrl.searchParams.get("data");
|
|
111
|
+
const stateData = { data, id: (0, import_uuid.v4)() };
|
|
112
|
+
const state2 = JSON.stringify(stateData);
|
|
111
113
|
const authorizationUrl = oauth2Client.generateAuthUrl({
|
|
112
114
|
scope: [
|
|
113
115
|
"https://www.googleapis.com/auth/userinfo.profile",
|
|
@@ -141,7 +143,8 @@ var getGoogleGetRoute = ({
|
|
|
141
143
|
}).userinfo.get();
|
|
142
144
|
const user = userInfoRequest.data;
|
|
143
145
|
if (user.email) {
|
|
144
|
-
const
|
|
146
|
+
const { data } = JSON.parse(localState);
|
|
147
|
+
const id = await getUserIdFromEmail(user, data);
|
|
145
148
|
const res = import_server2.NextResponse.redirect(redirectURL);
|
|
146
149
|
if (id) {
|
|
147
150
|
res.cookies.set(
|
|
@@ -83,7 +83,9 @@ var getGoogleGetRoute = ({
|
|
|
83
83
|
const code = req.nextUrl.searchParams.get("code");
|
|
84
84
|
const error = req.nextUrl.searchParams.get("error");
|
|
85
85
|
if (!code && !error) {
|
|
86
|
-
const
|
|
86
|
+
const data = req.nextUrl.searchParams.get("data");
|
|
87
|
+
const stateData = { data, id: v4() };
|
|
88
|
+
const state2 = JSON.stringify(stateData);
|
|
87
89
|
const authorizationUrl = oauth2Client.generateAuthUrl({
|
|
88
90
|
scope: [
|
|
89
91
|
"https://www.googleapis.com/auth/userinfo.profile",
|
|
@@ -117,7 +119,8 @@ var getGoogleGetRoute = ({
|
|
|
117
119
|
}).userinfo.get();
|
|
118
120
|
const user = userInfoRequest.data;
|
|
119
121
|
if (user.email) {
|
|
120
|
-
const
|
|
122
|
+
const { data } = JSON.parse(localState);
|
|
123
|
+
const id = await getUserIdFromEmail(user, data);
|
|
121
124
|
const res = NextResponse2.redirect(redirectURL);
|
|
122
125
|
if (id) {
|
|
123
126
|
res.cookies.set(
|
|
@@ -109,7 +109,9 @@ var getGoogleGetRoute = ({
|
|
|
109
109
|
const code = req.nextUrl.searchParams.get("code");
|
|
110
110
|
const error = req.nextUrl.searchParams.get("error");
|
|
111
111
|
if (!code && !error) {
|
|
112
|
-
const
|
|
112
|
+
const data = req.nextUrl.searchParams.get("data");
|
|
113
|
+
const stateData = { data, id: (0, import_uuid.v4)() };
|
|
114
|
+
const state2 = JSON.stringify(stateData);
|
|
113
115
|
const authorizationUrl = oauth2Client.generateAuthUrl({
|
|
114
116
|
scope: [
|
|
115
117
|
"https://www.googleapis.com/auth/userinfo.profile",
|
|
@@ -143,7 +145,8 @@ var getGoogleGetRoute = ({
|
|
|
143
145
|
}).userinfo.get();
|
|
144
146
|
const user = userInfoRequest.data;
|
|
145
147
|
if (user.email) {
|
|
146
|
-
const
|
|
148
|
+
const { data } = JSON.parse(localState);
|
|
149
|
+
const id = await getUserIdFromEmail(user, data);
|
|
147
150
|
const res = import_server2.NextResponse.redirect(redirectURL);
|
|
148
151
|
if (id) {
|
|
149
152
|
res.cookies.set(
|
|
@@ -13,7 +13,7 @@ type Schema$Userinfo = oauth2_v2.Schema$Userinfo;
|
|
|
13
13
|
* @category Auth
|
|
14
14
|
*/
|
|
15
15
|
interface InitGoogleAuthOptions {
|
|
16
|
-
getUserIdFromEmail: (email: Schema$Userinfo) => Promise<number | null>;
|
|
16
|
+
getUserIdFromEmail: (email: Schema$Userinfo, data?: object) => Promise<number | null>;
|
|
17
17
|
redirectURL: string;
|
|
18
18
|
errorRedirectURL?: string;
|
|
19
19
|
}
|
|
@@ -13,7 +13,7 @@ type Schema$Userinfo = oauth2_v2.Schema$Userinfo;
|
|
|
13
13
|
* @category Auth
|
|
14
14
|
*/
|
|
15
15
|
interface InitGoogleAuthOptions {
|
|
16
|
-
getUserIdFromEmail: (email: Schema$Userinfo) => Promise<number | null>;
|
|
16
|
+
getUserIdFromEmail: (email: Schema$Userinfo, data?: object) => Promise<number | null>;
|
|
17
17
|
redirectURL: string;
|
|
18
18
|
errorRedirectURL?: string;
|
|
19
19
|
}
|
|
@@ -83,7 +83,9 @@ var getGoogleGetRoute = ({
|
|
|
83
83
|
const code = req.nextUrl.searchParams.get("code");
|
|
84
84
|
const error = req.nextUrl.searchParams.get("error");
|
|
85
85
|
if (!code && !error) {
|
|
86
|
-
const
|
|
86
|
+
const data = req.nextUrl.searchParams.get("data");
|
|
87
|
+
const stateData = { data, id: v4() };
|
|
88
|
+
const state2 = JSON.stringify(stateData);
|
|
87
89
|
const authorizationUrl = oauth2Client.generateAuthUrl({
|
|
88
90
|
scope: [
|
|
89
91
|
"https://www.googleapis.com/auth/userinfo.profile",
|
|
@@ -117,7 +119,8 @@ var getGoogleGetRoute = ({
|
|
|
117
119
|
}).userinfo.get();
|
|
118
120
|
const user = userInfoRequest.data;
|
|
119
121
|
if (user.email) {
|
|
120
|
-
const
|
|
122
|
+
const { data } = JSON.parse(localState);
|
|
123
|
+
const id = await getUserIdFromEmail(user, data);
|
|
121
124
|
const res = NextResponse2.redirect(redirectURL);
|
|
122
125
|
if (id) {
|
|
123
126
|
res.cookies.set(
|
package/dist/auth/index.cjs.js
CHANGED
|
@@ -328,6 +328,7 @@ var getPutRoute = (options) => async (req) => {
|
|
|
328
328
|
// src/auth/email/server.tsx
|
|
329
329
|
var import_client2 = require("naystack/auth/email/client");
|
|
330
330
|
var import_headers3 = require("next/headers");
|
|
331
|
+
var import_react3 = __toESM(require("react"));
|
|
331
332
|
|
|
332
333
|
// src/graphql/server.tsx
|
|
333
334
|
var import_client = require("@apollo/client");
|
|
@@ -361,7 +362,7 @@ var { query: gqlQuery } = (0, import_client_integration_nextjs.registerApolloCli
|
|
|
361
362
|
|
|
362
363
|
// src/auth/email/server.tsx
|
|
363
364
|
function AuthFetch() {
|
|
364
|
-
return /* @__PURE__ */
|
|
365
|
+
return /* @__PURE__ */ import_react3.default.createElement(
|
|
365
366
|
Injector,
|
|
366
367
|
{
|
|
367
368
|
fetch: async () => {
|
|
@@ -409,7 +410,9 @@ var getGoogleGetRoute = ({
|
|
|
409
410
|
const code = req.nextUrl.searchParams.get("code");
|
|
410
411
|
const error = req.nextUrl.searchParams.get("error");
|
|
411
412
|
if (!code && !error) {
|
|
412
|
-
const
|
|
413
|
+
const data = req.nextUrl.searchParams.get("data");
|
|
414
|
+
const stateData = { data, id: (0, import_uuid.v4)() };
|
|
415
|
+
const state2 = JSON.stringify(stateData);
|
|
413
416
|
const authorizationUrl = oauth2Client.generateAuthUrl({
|
|
414
417
|
scope: [
|
|
415
418
|
"https://www.googleapis.com/auth/userinfo.profile",
|
|
@@ -443,7 +446,8 @@ var getGoogleGetRoute = ({
|
|
|
443
446
|
}).userinfo.get();
|
|
444
447
|
const user = userInfoRequest.data;
|
|
445
448
|
if (user.email) {
|
|
446
|
-
const
|
|
449
|
+
const { data } = JSON.parse(localState);
|
|
450
|
+
const id = await getUserIdFromEmail(user, data);
|
|
447
451
|
const res = import_server5.NextResponse.redirect(redirectURL);
|
|
448
452
|
if (id) {
|
|
449
453
|
res.cookies.set(
|
package/dist/auth/index.esm.js
CHANGED
|
@@ -285,6 +285,7 @@ var getPutRoute = (options) => async (req) => {
|
|
|
285
285
|
// src/auth/email/server.tsx
|
|
286
286
|
import { AuthApply } from "naystack/auth/email/client";
|
|
287
287
|
import { cookies as cookies3 } from "next/headers";
|
|
288
|
+
import React2 from "react";
|
|
288
289
|
|
|
289
290
|
// src/graphql/server.tsx
|
|
290
291
|
import {
|
|
@@ -294,14 +295,14 @@ import {
|
|
|
294
295
|
} from "@apollo/client";
|
|
295
296
|
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
296
297
|
import { cookies as cookies2 } from "next/headers";
|
|
297
|
-
import
|
|
298
|
+
import React from "react";
|
|
298
299
|
import { Suspense } from "react";
|
|
299
300
|
function Injector({
|
|
300
301
|
fetch: fetch2,
|
|
301
302
|
Component,
|
|
302
303
|
props
|
|
303
304
|
}) {
|
|
304
|
-
return /* @__PURE__ */
|
|
305
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Component, { ...props || {}, loading: true }) }, /* @__PURE__ */ React.createElement(InjectorSuspensed, { Component, fetch: fetch2, props }));
|
|
305
306
|
}
|
|
306
307
|
async function InjectorSuspensed({
|
|
307
308
|
fetch: fetch2,
|
|
@@ -309,7 +310,7 @@ async function InjectorSuspensed({
|
|
|
309
310
|
props
|
|
310
311
|
}) {
|
|
311
312
|
const data = await fetch2();
|
|
312
|
-
return /* @__PURE__ */
|
|
313
|
+
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
313
314
|
}
|
|
314
315
|
var { query: gqlQuery } = registerApolloClient(() => {
|
|
315
316
|
return new ApolloClient({
|
|
@@ -322,7 +323,7 @@ var { query: gqlQuery } = registerApolloClient(() => {
|
|
|
322
323
|
|
|
323
324
|
// src/auth/email/server.tsx
|
|
324
325
|
function AuthFetch() {
|
|
325
|
-
return /* @__PURE__ */
|
|
326
|
+
return /* @__PURE__ */ React2.createElement(
|
|
326
327
|
Injector,
|
|
327
328
|
{
|
|
328
329
|
fetch: async () => {
|
|
@@ -370,7 +371,9 @@ var getGoogleGetRoute = ({
|
|
|
370
371
|
const code = req.nextUrl.searchParams.get("code");
|
|
371
372
|
const error = req.nextUrl.searchParams.get("error");
|
|
372
373
|
if (!code && !error) {
|
|
373
|
-
const
|
|
374
|
+
const data = req.nextUrl.searchParams.get("data");
|
|
375
|
+
const stateData = { data, id: v4() };
|
|
376
|
+
const state2 = JSON.stringify(stateData);
|
|
374
377
|
const authorizationUrl = oauth2Client.generateAuthUrl({
|
|
375
378
|
scope: [
|
|
376
379
|
"https://www.googleapis.com/auth/userinfo.profile",
|
|
@@ -404,7 +407,8 @@ var getGoogleGetRoute = ({
|
|
|
404
407
|
}).userinfo.get();
|
|
405
408
|
const user = userInfoRequest.data;
|
|
406
409
|
if (user.email) {
|
|
407
|
-
const
|
|
410
|
+
const { data } = JSON.parse(localState);
|
|
411
|
+
const id = await getUserIdFromEmail(user, data);
|
|
408
412
|
const res = NextResponse3.redirect(redirectURL);
|
|
409
413
|
if (id) {
|
|
410
414
|
res.cookies.set(
|