naystack 1.8.9 → 1.8.10
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/index.cjs.js +5 -31
- package/dist/auth/index.d.mts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.esm.js +5 -30
- package/dist/auth/instagram/index.cjs.js +5 -31
- package/dist/auth/instagram/index.d.mts +3 -3
- package/dist/auth/instagram/index.d.ts +3 -3
- package/dist/auth/instagram/index.esm.js +5 -30
- package/dist/auth/instagram/route.cjs.js +5 -29
- package/dist/auth/instagram/route.esm.js +5 -29
- package/dist/auth/instagram/utils.cjs.js +0 -23
- package/dist/auth/instagram/utils.d.mts +1 -19
- package/dist/auth/instagram/utils.d.ts +1 -19
- package/dist/auth/instagram/utils.esm.js +0 -24
- package/package.json +1 -1
package/dist/auth/index.cjs.js
CHANGED
|
@@ -33,7 +33,6 @@ __export(auth_exports, {
|
|
|
33
33
|
AuthFetch: () => AuthFetch,
|
|
34
34
|
AuthWrapper: () => AuthWrapper,
|
|
35
35
|
checkAuthStatus: () => checkAuthStatus,
|
|
36
|
-
getAuthorizationHandoff: () => getAuthorizationHandoff,
|
|
37
36
|
getContext: () => getContext,
|
|
38
37
|
getInstagramAuthorizationURL: () => getInstagramAuthorizationURL,
|
|
39
38
|
getRefreshToken: () => getRefreshToken,
|
|
@@ -576,30 +575,9 @@ function setupGoogleAuth(props) {
|
|
|
576
575
|
}
|
|
577
576
|
|
|
578
577
|
// src/auth/instagram/route.ts
|
|
579
|
-
var
|
|
578
|
+
var import_server8 = require("next/server");
|
|
580
579
|
|
|
581
580
|
// src/auth/instagram/utils.ts
|
|
582
|
-
var import_server7 = require("next/server");
|
|
583
|
-
var HANDOFF_DELAY_MS = 1500;
|
|
584
|
-
function getAuthorizationHandoff(authorizationURL, providerName) {
|
|
585
|
-
const scriptSafeURL = JSON.stringify(authorizationURL).replace(
|
|
586
|
-
/</g,
|
|
587
|
-
"\\u003c"
|
|
588
|
-
);
|
|
589
|
-
const attributeSafeURL = authorizationURL.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
590
|
-
const safeProviderName = providerName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
591
|
-
return new import_server7.NextResponse(
|
|
592
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Redirecting to ${safeProviderName}\u2026</title><style>body{margin:0;min-height:100dvh;display:flex;align-items:center;justify-content:center;font:500 15px/1.5 system-ui,-apple-system,sans-serif;color:#111}</style><script>setTimeout(function(){location.replace(${scriptSafeURL})},${HANDOFF_DELAY_MS})</script><noscript><meta http-equiv="refresh" content="2;url=${attributeSafeURL}"></noscript></head><body><p>Redirecting to ${safeProviderName}\u2026</p></body></html>`,
|
|
593
|
-
{
|
|
594
|
-
headers: {
|
|
595
|
-
"content-type": "text/html; charset=utf-8",
|
|
596
|
-
"cache-control": "no-store",
|
|
597
|
-
// The token is in the URL; keep it off the provider's referer log.
|
|
598
|
-
"referrer-policy": "no-referrer"
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
581
|
async function getRefreshedInstagramAccessToken(token) {
|
|
604
582
|
const request = await fetch(
|
|
605
583
|
`https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=${token}`
|
|
@@ -662,7 +640,7 @@ var getInstagramUser = (token, id, fields) => {
|
|
|
662
640
|
};
|
|
663
641
|
|
|
664
642
|
// src/socials/meta-webhook.ts
|
|
665
|
-
var
|
|
643
|
+
var import_server7 = require("next/server");
|
|
666
644
|
|
|
667
645
|
// src/auth/instagram/route.ts
|
|
668
646
|
var getInstagramRoute = ({
|
|
@@ -670,7 +648,7 @@ var getInstagramRoute = ({
|
|
|
670
648
|
errorRedirectURL,
|
|
671
649
|
onUser
|
|
672
650
|
}) => {
|
|
673
|
-
const handleError2 = (message) =>
|
|
651
|
+
const handleError2 = (message) => import_server8.NextResponse.redirect(`${errorRedirectURL}?error=${message}`);
|
|
674
652
|
return async (req) => {
|
|
675
653
|
const accessCode = req.nextUrl.searchParams.get("code");
|
|
676
654
|
const error = req.nextUrl.searchParams.get("error");
|
|
@@ -678,10 +656,7 @@ var getInstagramRoute = ({
|
|
|
678
656
|
if (error) return handleError2(error);
|
|
679
657
|
if (!accessCode) {
|
|
680
658
|
if (!stateToken) return handleError2("Invalid request");
|
|
681
|
-
return
|
|
682
|
-
getInstagramAuthorizationURL(stateToken),
|
|
683
|
-
"Instagram"
|
|
684
|
-
);
|
|
659
|
+
return import_server8.NextResponse.redirect(getInstagramAuthorizationURL(stateToken), 302);
|
|
685
660
|
}
|
|
686
661
|
if (!stateToken) return handleError2("Invalid request");
|
|
687
662
|
const instagramData = await getLongLivedToken(
|
|
@@ -701,7 +676,7 @@ var getInstagramRoute = ({
|
|
|
701
676
|
instagramData.accessToken
|
|
702
677
|
);
|
|
703
678
|
if (errorMessage) return handleError2(errorMessage);
|
|
704
|
-
return
|
|
679
|
+
return import_server8.NextResponse.redirect(redirectURL);
|
|
705
680
|
};
|
|
706
681
|
};
|
|
707
682
|
|
|
@@ -723,7 +698,6 @@ async function getRefreshToken() {
|
|
|
723
698
|
AuthFetch,
|
|
724
699
|
AuthWrapper,
|
|
725
700
|
checkAuthStatus,
|
|
726
|
-
getAuthorizationHandoff,
|
|
727
701
|
getContext,
|
|
728
702
|
getInstagramAuthorizationURL,
|
|
729
703
|
getRefreshToken,
|
package/dist/auth/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ export { getRefreshToken } from './utils/token.mjs';
|
|
|
5
5
|
export { AuthFetch, AuthWrapper } from './email/next.mjs';
|
|
6
6
|
export { checkAuthStatus, getTokenizedResponse } from './email/token.mjs';
|
|
7
7
|
export { getContext } from './email/utils.mjs';
|
|
8
|
-
export {
|
|
8
|
+
export { getInstagramAuthorizationURL, getRefreshedInstagramAccessToken } from './instagram/utils.mjs';
|
|
9
9
|
import 'next/server';
|
|
10
10
|
import './email/types.mjs';
|
|
11
11
|
import './types.mjs';
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { getRefreshToken } from './utils/token.js';
|
|
|
5
5
|
export { AuthFetch, AuthWrapper } from './email/next.js';
|
|
6
6
|
export { checkAuthStatus, getTokenizedResponse } from './email/token.js';
|
|
7
7
|
export { getContext } from './email/utils.js';
|
|
8
|
-
export {
|
|
8
|
+
export { getInstagramAuthorizationURL, getRefreshedInstagramAccessToken } from './instagram/utils.js';
|
|
9
9
|
import 'next/server';
|
|
10
10
|
import './email/types.js';
|
|
11
11
|
import './types.js';
|
package/dist/auth/index.esm.js
CHANGED
|
@@ -533,30 +533,9 @@ function setupGoogleAuth(props) {
|
|
|
533
533
|
}
|
|
534
534
|
|
|
535
535
|
// src/auth/instagram/route.ts
|
|
536
|
-
import { NextResponse as
|
|
536
|
+
import { NextResponse as NextResponse7 } from "next/server";
|
|
537
537
|
|
|
538
538
|
// src/auth/instagram/utils.ts
|
|
539
|
-
import { NextResponse as NextResponse6 } from "next/server";
|
|
540
|
-
var HANDOFF_DELAY_MS = 1500;
|
|
541
|
-
function getAuthorizationHandoff(authorizationURL, providerName) {
|
|
542
|
-
const scriptSafeURL = JSON.stringify(authorizationURL).replace(
|
|
543
|
-
/</g,
|
|
544
|
-
"\\u003c"
|
|
545
|
-
);
|
|
546
|
-
const attributeSafeURL = authorizationURL.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
547
|
-
const safeProviderName = providerName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
548
|
-
return new NextResponse6(
|
|
549
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Redirecting to ${safeProviderName}\u2026</title><style>body{margin:0;min-height:100dvh;display:flex;align-items:center;justify-content:center;font:500 15px/1.5 system-ui,-apple-system,sans-serif;color:#111}</style><script>setTimeout(function(){location.replace(${scriptSafeURL})},${HANDOFF_DELAY_MS})</script><noscript><meta http-equiv="refresh" content="2;url=${attributeSafeURL}"></noscript></head><body><p>Redirecting to ${safeProviderName}\u2026</p></body></html>`,
|
|
550
|
-
{
|
|
551
|
-
headers: {
|
|
552
|
-
"content-type": "text/html; charset=utf-8",
|
|
553
|
-
"cache-control": "no-store",
|
|
554
|
-
// The token is in the URL; keep it off the provider's referer log.
|
|
555
|
-
"referrer-policy": "no-referrer"
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
);
|
|
559
|
-
}
|
|
560
539
|
async function getRefreshedInstagramAccessToken(token) {
|
|
561
540
|
const request = await fetch(
|
|
562
541
|
`https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=${token}`
|
|
@@ -619,7 +598,7 @@ var getInstagramUser = (token, id, fields) => {
|
|
|
619
598
|
};
|
|
620
599
|
|
|
621
600
|
// src/socials/meta-webhook.ts
|
|
622
|
-
import { NextResponse as
|
|
601
|
+
import { NextResponse as NextResponse6 } from "next/server";
|
|
623
602
|
|
|
624
603
|
// src/auth/instagram/route.ts
|
|
625
604
|
var getInstagramRoute = ({
|
|
@@ -627,7 +606,7 @@ var getInstagramRoute = ({
|
|
|
627
606
|
errorRedirectURL,
|
|
628
607
|
onUser
|
|
629
608
|
}) => {
|
|
630
|
-
const handleError2 = (message) =>
|
|
609
|
+
const handleError2 = (message) => NextResponse7.redirect(`${errorRedirectURL}?error=${message}`);
|
|
631
610
|
return async (req) => {
|
|
632
611
|
const accessCode = req.nextUrl.searchParams.get("code");
|
|
633
612
|
const error = req.nextUrl.searchParams.get("error");
|
|
@@ -635,10 +614,7 @@ var getInstagramRoute = ({
|
|
|
635
614
|
if (error) return handleError2(error);
|
|
636
615
|
if (!accessCode) {
|
|
637
616
|
if (!stateToken) return handleError2("Invalid request");
|
|
638
|
-
return
|
|
639
|
-
getInstagramAuthorizationURL(stateToken),
|
|
640
|
-
"Instagram"
|
|
641
|
-
);
|
|
617
|
+
return NextResponse7.redirect(getInstagramAuthorizationURL(stateToken), 302);
|
|
642
618
|
}
|
|
643
619
|
if (!stateToken) return handleError2("Invalid request");
|
|
644
620
|
const instagramData = await getLongLivedToken(
|
|
@@ -658,7 +634,7 @@ var getInstagramRoute = ({
|
|
|
658
634
|
instagramData.accessToken
|
|
659
635
|
);
|
|
660
636
|
if (errorMessage) return handleError2(errorMessage);
|
|
661
|
-
return
|
|
637
|
+
return NextResponse7.redirect(redirectURL);
|
|
662
638
|
};
|
|
663
639
|
};
|
|
664
640
|
|
|
@@ -679,7 +655,6 @@ export {
|
|
|
679
655
|
AuthFetch,
|
|
680
656
|
AuthWrapper,
|
|
681
657
|
checkAuthStatus,
|
|
682
|
-
getAuthorizationHandoff,
|
|
683
658
|
getContext,
|
|
684
659
|
getInstagramAuthorizationURL,
|
|
685
660
|
getRefreshToken,
|
|
@@ -20,7 +20,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/auth/instagram/index.ts
|
|
21
21
|
var instagram_exports = {};
|
|
22
22
|
__export(instagram_exports, {
|
|
23
|
-
getAuthorizationHandoff: () => getAuthorizationHandoff,
|
|
24
23
|
getInstagramAuthorizationURL: () => getInstagramAuthorizationURL,
|
|
25
24
|
getRefreshedInstagramAccessToken: () => getRefreshedInstagramAccessToken,
|
|
26
25
|
setupInstagramAuth: () => setupInstagramAuth
|
|
@@ -28,7 +27,7 @@ __export(instagram_exports, {
|
|
|
28
27
|
module.exports = __toCommonJS(instagram_exports);
|
|
29
28
|
|
|
30
29
|
// src/auth/instagram/route.ts
|
|
31
|
-
var
|
|
30
|
+
var import_server3 = require("next/server");
|
|
32
31
|
|
|
33
32
|
// src/auth/email/token.ts
|
|
34
33
|
var import_bcryptjs = require("bcryptjs");
|
|
@@ -102,27 +101,6 @@ function getUserIdFromAccessToken(accessToken) {
|
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
// src/auth/instagram/utils.ts
|
|
105
|
-
var import_server2 = require("next/server");
|
|
106
|
-
var HANDOFF_DELAY_MS = 1500;
|
|
107
|
-
function getAuthorizationHandoff(authorizationURL, providerName) {
|
|
108
|
-
const scriptSafeURL = JSON.stringify(authorizationURL).replace(
|
|
109
|
-
/</g,
|
|
110
|
-
"\\u003c"
|
|
111
|
-
);
|
|
112
|
-
const attributeSafeURL = authorizationURL.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
113
|
-
const safeProviderName = providerName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
114
|
-
return new import_server2.NextResponse(
|
|
115
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Redirecting to ${safeProviderName}\u2026</title><style>body{margin:0;min-height:100dvh;display:flex;align-items:center;justify-content:center;font:500 15px/1.5 system-ui,-apple-system,sans-serif;color:#111}</style><script>setTimeout(function(){location.replace(${scriptSafeURL})},${HANDOFF_DELAY_MS})</script><noscript><meta http-equiv="refresh" content="2;url=${attributeSafeURL}"></noscript></head><body><p>Redirecting to ${safeProviderName}\u2026</p></body></html>`,
|
|
116
|
-
{
|
|
117
|
-
headers: {
|
|
118
|
-
"content-type": "text/html; charset=utf-8",
|
|
119
|
-
"cache-control": "no-store",
|
|
120
|
-
// The token is in the URL; keep it off the provider's referer log.
|
|
121
|
-
"referrer-policy": "no-referrer"
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
104
|
async function getRefreshedInstagramAccessToken(token) {
|
|
127
105
|
const request = await fetch(
|
|
128
106
|
`https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=${token}`
|
|
@@ -185,7 +163,7 @@ var getInstagramUser = (token, id, fields) => {
|
|
|
185
163
|
};
|
|
186
164
|
|
|
187
165
|
// src/socials/meta-webhook.ts
|
|
188
|
-
var
|
|
166
|
+
var import_server2 = require("next/server");
|
|
189
167
|
|
|
190
168
|
// src/auth/instagram/route.ts
|
|
191
169
|
var getInstagramRoute = ({
|
|
@@ -193,7 +171,7 @@ var getInstagramRoute = ({
|
|
|
193
171
|
errorRedirectURL,
|
|
194
172
|
onUser
|
|
195
173
|
}) => {
|
|
196
|
-
const handleError = (message) =>
|
|
174
|
+
const handleError = (message) => import_server3.NextResponse.redirect(`${errorRedirectURL}?error=${message}`);
|
|
197
175
|
return async (req) => {
|
|
198
176
|
const accessCode = req.nextUrl.searchParams.get("code");
|
|
199
177
|
const error = req.nextUrl.searchParams.get("error");
|
|
@@ -201,10 +179,7 @@ var getInstagramRoute = ({
|
|
|
201
179
|
if (error) return handleError(error);
|
|
202
180
|
if (!accessCode) {
|
|
203
181
|
if (!stateToken) return handleError("Invalid request");
|
|
204
|
-
return
|
|
205
|
-
getInstagramAuthorizationURL(stateToken),
|
|
206
|
-
"Instagram"
|
|
207
|
-
);
|
|
182
|
+
return import_server3.NextResponse.redirect(getInstagramAuthorizationURL(stateToken), 302);
|
|
208
183
|
}
|
|
209
184
|
if (!stateToken) return handleError("Invalid request");
|
|
210
185
|
const instagramData = await getLongLivedToken(
|
|
@@ -224,7 +199,7 @@ var getInstagramRoute = ({
|
|
|
224
199
|
instagramData.accessToken
|
|
225
200
|
);
|
|
226
201
|
if (errorMessage) return handleError(errorMessage);
|
|
227
|
-
return
|
|
202
|
+
return import_server3.NextResponse.redirect(redirectURL);
|
|
228
203
|
};
|
|
229
204
|
};
|
|
230
205
|
|
|
@@ -236,7 +211,6 @@ function setupInstagramAuth(props) {
|
|
|
236
211
|
}
|
|
237
212
|
// Annotate the CommonJS export names for ESM import in node:
|
|
238
213
|
0 && (module.exports = {
|
|
239
|
-
getAuthorizationHandoff,
|
|
240
214
|
getInstagramAuthorizationURL,
|
|
241
215
|
getRefreshedInstagramAccessToken,
|
|
242
216
|
setupInstagramAuth
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as next_server from 'next/server';
|
|
2
|
-
export {
|
|
2
|
+
export { getInstagramAuthorizationURL, getRefreshedInstagramAccessToken } from './utils.mjs';
|
|
3
3
|
import { InstagramUser } from '../../socials/instagram/types.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -22,8 +22,8 @@ interface SetupInstagramAuthOptions {
|
|
|
22
22
|
* Mount the GET handler on your Instagram auth route (e.g. `app/api/(auth)/instagram/route.ts`).
|
|
23
23
|
*
|
|
24
24
|
* The single GET handler serves both the OAuth callback (`?code`) and the connect
|
|
25
|
-
* entry point (`?state` with no code →
|
|
26
|
-
*
|
|
25
|
+
* entry point (`?state` with no code → 302 to Instagram's authorize URL; see
|
|
26
|
+
* {@link getInstagramAuthorizationURL} for why that URL is spelled the way it is).
|
|
27
27
|
*
|
|
28
28
|
* Requires env vars: `INSTAGRAM_CLIENT_ID` (server-only), `INSTAGRAM_CLIENT_SECRET`, `NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT`.
|
|
29
29
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as next_server from 'next/server';
|
|
2
|
-
export {
|
|
2
|
+
export { getInstagramAuthorizationURL, getRefreshedInstagramAccessToken } from './utils.js';
|
|
3
3
|
import { InstagramUser } from '../../socials/instagram/types.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -22,8 +22,8 @@ interface SetupInstagramAuthOptions {
|
|
|
22
22
|
* Mount the GET handler on your Instagram auth route (e.g. `app/api/(auth)/instagram/route.ts`).
|
|
23
23
|
*
|
|
24
24
|
* The single GET handler serves both the OAuth callback (`?code`) and the connect
|
|
25
|
-
* entry point (`?state` with no code →
|
|
26
|
-
*
|
|
25
|
+
* entry point (`?state` with no code → 302 to Instagram's authorize URL; see
|
|
26
|
+
* {@link getInstagramAuthorizationURL} for why that URL is spelled the way it is).
|
|
27
27
|
*
|
|
28
28
|
* Requires env vars: `INSTAGRAM_CLIENT_ID` (server-only), `INSTAGRAM_CLIENT_SECRET`, `NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT`.
|
|
29
29
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/auth/instagram/route.ts
|
|
2
|
-
import { NextResponse as
|
|
2
|
+
import { NextResponse as NextResponse3 } from "next/server";
|
|
3
3
|
|
|
4
4
|
// src/auth/email/token.ts
|
|
5
5
|
import { compare } from "bcryptjs";
|
|
@@ -73,27 +73,6 @@ function getUserIdFromAccessToken(accessToken) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// src/auth/instagram/utils.ts
|
|
76
|
-
import { NextResponse as NextResponse2 } from "next/server";
|
|
77
|
-
var HANDOFF_DELAY_MS = 1500;
|
|
78
|
-
function getAuthorizationHandoff(authorizationURL, providerName) {
|
|
79
|
-
const scriptSafeURL = JSON.stringify(authorizationURL).replace(
|
|
80
|
-
/</g,
|
|
81
|
-
"\\u003c"
|
|
82
|
-
);
|
|
83
|
-
const attributeSafeURL = authorizationURL.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
84
|
-
const safeProviderName = providerName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
85
|
-
return new NextResponse2(
|
|
86
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Redirecting to ${safeProviderName}\u2026</title><style>body{margin:0;min-height:100dvh;display:flex;align-items:center;justify-content:center;font:500 15px/1.5 system-ui,-apple-system,sans-serif;color:#111}</style><script>setTimeout(function(){location.replace(${scriptSafeURL})},${HANDOFF_DELAY_MS})</script><noscript><meta http-equiv="refresh" content="2;url=${attributeSafeURL}"></noscript></head><body><p>Redirecting to ${safeProviderName}\u2026</p></body></html>`,
|
|
87
|
-
{
|
|
88
|
-
headers: {
|
|
89
|
-
"content-type": "text/html; charset=utf-8",
|
|
90
|
-
"cache-control": "no-store",
|
|
91
|
-
// The token is in the URL; keep it off the provider's referer log.
|
|
92
|
-
"referrer-policy": "no-referrer"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
76
|
async function getRefreshedInstagramAccessToken(token) {
|
|
98
77
|
const request = await fetch(
|
|
99
78
|
`https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=${token}`
|
|
@@ -156,7 +135,7 @@ var getInstagramUser = (token, id, fields) => {
|
|
|
156
135
|
};
|
|
157
136
|
|
|
158
137
|
// src/socials/meta-webhook.ts
|
|
159
|
-
import { NextResponse as
|
|
138
|
+
import { NextResponse as NextResponse2 } from "next/server";
|
|
160
139
|
|
|
161
140
|
// src/auth/instagram/route.ts
|
|
162
141
|
var getInstagramRoute = ({
|
|
@@ -164,7 +143,7 @@ var getInstagramRoute = ({
|
|
|
164
143
|
errorRedirectURL,
|
|
165
144
|
onUser
|
|
166
145
|
}) => {
|
|
167
|
-
const handleError = (message) =>
|
|
146
|
+
const handleError = (message) => NextResponse3.redirect(`${errorRedirectURL}?error=${message}`);
|
|
168
147
|
return async (req) => {
|
|
169
148
|
const accessCode = req.nextUrl.searchParams.get("code");
|
|
170
149
|
const error = req.nextUrl.searchParams.get("error");
|
|
@@ -172,10 +151,7 @@ var getInstagramRoute = ({
|
|
|
172
151
|
if (error) return handleError(error);
|
|
173
152
|
if (!accessCode) {
|
|
174
153
|
if (!stateToken) return handleError("Invalid request");
|
|
175
|
-
return
|
|
176
|
-
getInstagramAuthorizationURL(stateToken),
|
|
177
|
-
"Instagram"
|
|
178
|
-
);
|
|
154
|
+
return NextResponse3.redirect(getInstagramAuthorizationURL(stateToken), 302);
|
|
179
155
|
}
|
|
180
156
|
if (!stateToken) return handleError("Invalid request");
|
|
181
157
|
const instagramData = await getLongLivedToken(
|
|
@@ -195,7 +171,7 @@ var getInstagramRoute = ({
|
|
|
195
171
|
instagramData.accessToken
|
|
196
172
|
);
|
|
197
173
|
if (errorMessage) return handleError(errorMessage);
|
|
198
|
-
return
|
|
174
|
+
return NextResponse3.redirect(redirectURL);
|
|
199
175
|
};
|
|
200
176
|
};
|
|
201
177
|
|
|
@@ -206,7 +182,6 @@ function setupInstagramAuth(props) {
|
|
|
206
182
|
};
|
|
207
183
|
}
|
|
208
184
|
export {
|
|
209
|
-
getAuthorizationHandoff,
|
|
210
185
|
getInstagramAuthorizationURL,
|
|
211
186
|
getRefreshedInstagramAccessToken,
|
|
212
187
|
setupInstagramAuth
|
|
@@ -23,7 +23,7 @@ __export(route_exports, {
|
|
|
23
23
|
getInstagramRoute: () => getInstagramRoute
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(route_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_server3 = require("next/server");
|
|
27
27
|
|
|
28
28
|
// src/auth/email/token.ts
|
|
29
29
|
var import_bcryptjs = require("bcryptjs");
|
|
@@ -97,27 +97,6 @@ function getUserIdFromAccessToken(accessToken) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// src/auth/instagram/utils.ts
|
|
100
|
-
var import_server2 = require("next/server");
|
|
101
|
-
var HANDOFF_DELAY_MS = 1500;
|
|
102
|
-
function getAuthorizationHandoff(authorizationURL, providerName) {
|
|
103
|
-
const scriptSafeURL = JSON.stringify(authorizationURL).replace(
|
|
104
|
-
/</g,
|
|
105
|
-
"\\u003c"
|
|
106
|
-
);
|
|
107
|
-
const attributeSafeURL = authorizationURL.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
108
|
-
const safeProviderName = providerName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
109
|
-
return new import_server2.NextResponse(
|
|
110
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Redirecting to ${safeProviderName}\u2026</title><style>body{margin:0;min-height:100dvh;display:flex;align-items:center;justify-content:center;font:500 15px/1.5 system-ui,-apple-system,sans-serif;color:#111}</style><script>setTimeout(function(){location.replace(${scriptSafeURL})},${HANDOFF_DELAY_MS})</script><noscript><meta http-equiv="refresh" content="2;url=${attributeSafeURL}"></noscript></head><body><p>Redirecting to ${safeProviderName}\u2026</p></body></html>`,
|
|
111
|
-
{
|
|
112
|
-
headers: {
|
|
113
|
-
"content-type": "text/html; charset=utf-8",
|
|
114
|
-
"cache-control": "no-store",
|
|
115
|
-
// The token is in the URL; keep it off the provider's referer log.
|
|
116
|
-
"referrer-policy": "no-referrer"
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
100
|
async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
|
|
122
101
|
const formData = new FormData();
|
|
123
102
|
formData.set("client_id", clientId);
|
|
@@ -173,7 +152,7 @@ var getInstagramUser = (token, id, fields) => {
|
|
|
173
152
|
};
|
|
174
153
|
|
|
175
154
|
// src/socials/meta-webhook.ts
|
|
176
|
-
var
|
|
155
|
+
var import_server2 = require("next/server");
|
|
177
156
|
|
|
178
157
|
// src/auth/instagram/route.ts
|
|
179
158
|
var getInstagramRoute = ({
|
|
@@ -181,7 +160,7 @@ var getInstagramRoute = ({
|
|
|
181
160
|
errorRedirectURL,
|
|
182
161
|
onUser
|
|
183
162
|
}) => {
|
|
184
|
-
const handleError = (message) =>
|
|
163
|
+
const handleError = (message) => import_server3.NextResponse.redirect(`${errorRedirectURL}?error=${message}`);
|
|
185
164
|
return async (req) => {
|
|
186
165
|
const accessCode = req.nextUrl.searchParams.get("code");
|
|
187
166
|
const error = req.nextUrl.searchParams.get("error");
|
|
@@ -189,10 +168,7 @@ var getInstagramRoute = ({
|
|
|
189
168
|
if (error) return handleError(error);
|
|
190
169
|
if (!accessCode) {
|
|
191
170
|
if (!stateToken) return handleError("Invalid request");
|
|
192
|
-
return
|
|
193
|
-
getInstagramAuthorizationURL(stateToken),
|
|
194
|
-
"Instagram"
|
|
195
|
-
);
|
|
171
|
+
return import_server3.NextResponse.redirect(getInstagramAuthorizationURL(stateToken), 302);
|
|
196
172
|
}
|
|
197
173
|
if (!stateToken) return handleError("Invalid request");
|
|
198
174
|
const instagramData = await getLongLivedToken(
|
|
@@ -212,7 +188,7 @@ var getInstagramRoute = ({
|
|
|
212
188
|
instagramData.accessToken
|
|
213
189
|
);
|
|
214
190
|
if (errorMessage) return handleError(errorMessage);
|
|
215
|
-
return
|
|
191
|
+
return import_server3.NextResponse.redirect(redirectURL);
|
|
216
192
|
};
|
|
217
193
|
};
|
|
218
194
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/auth/instagram/route.ts
|
|
2
|
-
import { NextResponse as
|
|
2
|
+
import { NextResponse as NextResponse3 } from "next/server";
|
|
3
3
|
|
|
4
4
|
// src/auth/email/token.ts
|
|
5
5
|
import { compare } from "bcryptjs";
|
|
@@ -73,27 +73,6 @@ function getUserIdFromAccessToken(accessToken) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// src/auth/instagram/utils.ts
|
|
76
|
-
import { NextResponse as NextResponse2 } from "next/server";
|
|
77
|
-
var HANDOFF_DELAY_MS = 1500;
|
|
78
|
-
function getAuthorizationHandoff(authorizationURL, providerName) {
|
|
79
|
-
const scriptSafeURL = JSON.stringify(authorizationURL).replace(
|
|
80
|
-
/</g,
|
|
81
|
-
"\\u003c"
|
|
82
|
-
);
|
|
83
|
-
const attributeSafeURL = authorizationURL.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
84
|
-
const safeProviderName = providerName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
85
|
-
return new NextResponse2(
|
|
86
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Redirecting to ${safeProviderName}\u2026</title><style>body{margin:0;min-height:100dvh;display:flex;align-items:center;justify-content:center;font:500 15px/1.5 system-ui,-apple-system,sans-serif;color:#111}</style><script>setTimeout(function(){location.replace(${scriptSafeURL})},${HANDOFF_DELAY_MS})</script><noscript><meta http-equiv="refresh" content="2;url=${attributeSafeURL}"></noscript></head><body><p>Redirecting to ${safeProviderName}\u2026</p></body></html>`,
|
|
87
|
-
{
|
|
88
|
-
headers: {
|
|
89
|
-
"content-type": "text/html; charset=utf-8",
|
|
90
|
-
"cache-control": "no-store",
|
|
91
|
-
// The token is in the URL; keep it off the provider's referer log.
|
|
92
|
-
"referrer-policy": "no-referrer"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
76
|
async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
|
|
98
77
|
const formData = new FormData();
|
|
99
78
|
formData.set("client_id", clientId);
|
|
@@ -149,7 +128,7 @@ var getInstagramUser = (token, id, fields) => {
|
|
|
149
128
|
};
|
|
150
129
|
|
|
151
130
|
// src/socials/meta-webhook.ts
|
|
152
|
-
import { NextResponse as
|
|
131
|
+
import { NextResponse as NextResponse2 } from "next/server";
|
|
153
132
|
|
|
154
133
|
// src/auth/instagram/route.ts
|
|
155
134
|
var getInstagramRoute = ({
|
|
@@ -157,7 +136,7 @@ var getInstagramRoute = ({
|
|
|
157
136
|
errorRedirectURL,
|
|
158
137
|
onUser
|
|
159
138
|
}) => {
|
|
160
|
-
const handleError = (message) =>
|
|
139
|
+
const handleError = (message) => NextResponse3.redirect(`${errorRedirectURL}?error=${message}`);
|
|
161
140
|
return async (req) => {
|
|
162
141
|
const accessCode = req.nextUrl.searchParams.get("code");
|
|
163
142
|
const error = req.nextUrl.searchParams.get("error");
|
|
@@ -165,10 +144,7 @@ var getInstagramRoute = ({
|
|
|
165
144
|
if (error) return handleError(error);
|
|
166
145
|
if (!accessCode) {
|
|
167
146
|
if (!stateToken) return handleError("Invalid request");
|
|
168
|
-
return
|
|
169
|
-
getInstagramAuthorizationURL(stateToken),
|
|
170
|
-
"Instagram"
|
|
171
|
-
);
|
|
147
|
+
return NextResponse3.redirect(getInstagramAuthorizationURL(stateToken), 302);
|
|
172
148
|
}
|
|
173
149
|
if (!stateToken) return handleError("Invalid request");
|
|
174
150
|
const instagramData = await getLongLivedToken(
|
|
@@ -188,7 +164,7 @@ var getInstagramRoute = ({
|
|
|
188
164
|
instagramData.accessToken
|
|
189
165
|
);
|
|
190
166
|
if (errorMessage) return handleError(errorMessage);
|
|
191
|
-
return
|
|
167
|
+
return NextResponse3.redirect(redirectURL);
|
|
192
168
|
};
|
|
193
169
|
};
|
|
194
170
|
export {
|
|
@@ -20,13 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/auth/instagram/utils.ts
|
|
21
21
|
var utils_exports = {};
|
|
22
22
|
__export(utils_exports, {
|
|
23
|
-
getAuthorizationHandoff: () => getAuthorizationHandoff,
|
|
24
23
|
getInstagramAuthorizationURL: () => getInstagramAuthorizationURL,
|
|
25
24
|
getLongLivedToken: () => getLongLivedToken,
|
|
26
25
|
getRefreshedInstagramAccessToken: () => getRefreshedInstagramAccessToken
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(utils_exports);
|
|
29
|
-
var import_server = require("next/server");
|
|
30
28
|
|
|
31
29
|
// src/env.ts
|
|
32
30
|
var EXTRA_ENV = globalThis.__NAYSTACK_ENV__ || (globalThis.__NAYSTACK_ENV__ = {});
|
|
@@ -79,26 +77,6 @@ function getEnv(key, skipCheck) {
|
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
// src/auth/instagram/utils.ts
|
|
82
|
-
var HANDOFF_DELAY_MS = 1500;
|
|
83
|
-
function getAuthorizationHandoff(authorizationURL, providerName) {
|
|
84
|
-
const scriptSafeURL = JSON.stringify(authorizationURL).replace(
|
|
85
|
-
/</g,
|
|
86
|
-
"\\u003c"
|
|
87
|
-
);
|
|
88
|
-
const attributeSafeURL = authorizationURL.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
89
|
-
const safeProviderName = providerName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
90
|
-
return new import_server.NextResponse(
|
|
91
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Redirecting to ${safeProviderName}\u2026</title><style>body{margin:0;min-height:100dvh;display:flex;align-items:center;justify-content:center;font:500 15px/1.5 system-ui,-apple-system,sans-serif;color:#111}</style><script>setTimeout(function(){location.replace(${scriptSafeURL})},${HANDOFF_DELAY_MS})</script><noscript><meta http-equiv="refresh" content="2;url=${attributeSafeURL}"></noscript></head><body><p>Redirecting to ${safeProviderName}\u2026</p></body></html>`,
|
|
92
|
-
{
|
|
93
|
-
headers: {
|
|
94
|
-
"content-type": "text/html; charset=utf-8",
|
|
95
|
-
"cache-control": "no-store",
|
|
96
|
-
// The token is in the URL; keep it off the provider's referer log.
|
|
97
|
-
"referrer-policy": "no-referrer"
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
80
|
async function getRefreshedInstagramAccessToken(token) {
|
|
103
81
|
const request = await fetch(
|
|
104
82
|
`https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=${token}`
|
|
@@ -139,7 +117,6 @@ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/a
|
|
|
139
117
|
)}&response_type=code&enable_fb_login=0&force_authentication=1&scope=instagram_business_basic&state=${token}&redirect_uri=${getEnv("NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT" /* NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT */)}#weblink`;
|
|
140
118
|
// Annotate the CommonJS export names for ESM import in node:
|
|
141
119
|
0 && (module.exports = {
|
|
142
|
-
getAuthorizationHandoff,
|
|
143
120
|
getInstagramAuthorizationURL,
|
|
144
121
|
getLongLivedToken,
|
|
145
122
|
getRefreshedInstagramAccessToken
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import { NextResponse } from 'next/server';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Builds the interstitial document that carries the browser from our origin to a
|
|
5
|
-
* provider's authorization page: it renders, waits {@link HANDOFF_DELAY_MS}, then
|
|
6
|
-
* replaces itself with `authorizationURL`.
|
|
7
|
-
*
|
|
8
|
-
* `location.replace` keeps the interstitial out of session history, so Back from
|
|
9
|
-
* the provider returns to the page that started the flow. The `noscript` meta
|
|
10
|
-
* refresh is a fallback, not the primary path.
|
|
11
|
-
*
|
|
12
|
-
* @param authorizationURL - Provider authorization URL to hand the browser off to
|
|
13
|
-
* @param providerName - Shown to the user while waiting, e.g. `"Instagram"`
|
|
14
|
-
* @returns HTML response that redirects client-side after a delay
|
|
15
|
-
*
|
|
16
|
-
* @category Auth
|
|
17
|
-
*/
|
|
18
|
-
declare function getAuthorizationHandoff(authorizationURL: string, providerName: string): NextResponse<unknown>;
|
|
19
1
|
/**
|
|
20
2
|
* Exchanges a long-lived Instagram token for a refreshed token.
|
|
21
3
|
* @param token - Current long-lived access token
|
|
@@ -61,4 +43,4 @@ declare function getLongLivedToken(code: string, redirectURL: string, clientId:
|
|
|
61
43
|
*/
|
|
62
44
|
declare const getInstagramAuthorizationURL: (token: string) => string;
|
|
63
45
|
|
|
64
|
-
export {
|
|
46
|
+
export { getInstagramAuthorizationURL, getLongLivedToken, getRefreshedInstagramAccessToken };
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import { NextResponse } from 'next/server';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Builds the interstitial document that carries the browser from our origin to a
|
|
5
|
-
* provider's authorization page: it renders, waits {@link HANDOFF_DELAY_MS}, then
|
|
6
|
-
* replaces itself with `authorizationURL`.
|
|
7
|
-
*
|
|
8
|
-
* `location.replace` keeps the interstitial out of session history, so Back from
|
|
9
|
-
* the provider returns to the page that started the flow. The `noscript` meta
|
|
10
|
-
* refresh is a fallback, not the primary path.
|
|
11
|
-
*
|
|
12
|
-
* @param authorizationURL - Provider authorization URL to hand the browser off to
|
|
13
|
-
* @param providerName - Shown to the user while waiting, e.g. `"Instagram"`
|
|
14
|
-
* @returns HTML response that redirects client-side after a delay
|
|
15
|
-
*
|
|
16
|
-
* @category Auth
|
|
17
|
-
*/
|
|
18
|
-
declare function getAuthorizationHandoff(authorizationURL: string, providerName: string): NextResponse<unknown>;
|
|
19
1
|
/**
|
|
20
2
|
* Exchanges a long-lived Instagram token for a refreshed token.
|
|
21
3
|
* @param token - Current long-lived access token
|
|
@@ -61,4 +43,4 @@ declare function getLongLivedToken(code: string, redirectURL: string, clientId:
|
|
|
61
43
|
*/
|
|
62
44
|
declare const getInstagramAuthorizationURL: (token: string) => string;
|
|
63
45
|
|
|
64
|
-
export {
|
|
46
|
+
export { getInstagramAuthorizationURL, getLongLivedToken, getRefreshedInstagramAccessToken };
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/auth/instagram/utils.ts
|
|
2
|
-
import { NextResponse } from "next/server";
|
|
3
|
-
|
|
4
1
|
// src/env.ts
|
|
5
2
|
var EXTRA_ENV = globalThis.__NAYSTACK_ENV__ || (globalThis.__NAYSTACK_ENV__ = {});
|
|
6
3
|
var getEnvValue = (key) => {
|
|
@@ -52,26 +49,6 @@ function getEnv(key, skipCheck) {
|
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
// src/auth/instagram/utils.ts
|
|
55
|
-
var HANDOFF_DELAY_MS = 1500;
|
|
56
|
-
function getAuthorizationHandoff(authorizationURL, providerName) {
|
|
57
|
-
const scriptSafeURL = JSON.stringify(authorizationURL).replace(
|
|
58
|
-
/</g,
|
|
59
|
-
"\\u003c"
|
|
60
|
-
);
|
|
61
|
-
const attributeSafeURL = authorizationURL.replace(/&/g, "&").replace(/</g, "<").replace(/"/g, """);
|
|
62
|
-
const safeProviderName = providerName.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
63
|
-
return new NextResponse(
|
|
64
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Redirecting to ${safeProviderName}\u2026</title><style>body{margin:0;min-height:100dvh;display:flex;align-items:center;justify-content:center;font:500 15px/1.5 system-ui,-apple-system,sans-serif;color:#111}</style><script>setTimeout(function(){location.replace(${scriptSafeURL})},${HANDOFF_DELAY_MS})</script><noscript><meta http-equiv="refresh" content="2;url=${attributeSafeURL}"></noscript></head><body><p>Redirecting to ${safeProviderName}\u2026</p></body></html>`,
|
|
65
|
-
{
|
|
66
|
-
headers: {
|
|
67
|
-
"content-type": "text/html; charset=utf-8",
|
|
68
|
-
"cache-control": "no-store",
|
|
69
|
-
// The token is in the URL; keep it off the provider's referer log.
|
|
70
|
-
"referrer-policy": "no-referrer"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
52
|
async function getRefreshedInstagramAccessToken(token) {
|
|
76
53
|
const request = await fetch(
|
|
77
54
|
`https://graph.instagram.com/refresh_access_token?grant_type=ig_refresh_token&access_token=${token}`
|
|
@@ -111,7 +88,6 @@ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/a
|
|
|
111
88
|
"INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
|
|
112
89
|
)}&response_type=code&enable_fb_login=0&force_authentication=1&scope=instagram_business_basic&state=${token}&redirect_uri=${getEnv("NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT" /* NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT */)}#weblink`;
|
|
113
90
|
export {
|
|
114
|
-
getAuthorizationHandoff,
|
|
115
91
|
getInstagramAuthorizationURL,
|
|
116
92
|
getLongLivedToken,
|
|
117
93
|
getRefreshedInstagramAccessToken
|