naystack 1.8.6 → 1.8.8

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.
@@ -580,14 +580,16 @@ var import_server9 = require("next/server");
580
580
 
581
581
  // src/auth/instagram/utils.ts
582
582
  var import_server7 = require("next/server");
583
- function getAuthorizationHandoff(authorizationURL) {
583
+ var HANDOFF_DELAY_MS = 1500;
584
+ function getAuthorizationHandoff(authorizationURL, providerName) {
584
585
  const scriptSafeURL = JSON.stringify(authorizationURL).replace(
585
586
  /</g,
586
587
  "\\u003c"
587
588
  );
588
589
  const attributeSafeURL = authorizationURL.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
590
+ const safeProviderName = providerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
589
591
  return new import_server7.NextResponse(
590
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Connecting\u2026</title><script>location.replace(${scriptSafeURL})</script><noscript><meta http-equiv="refresh" content="0;url=${attributeSafeURL}"></noscript></head><body></body></html>`,
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>`,
591
593
  {
592
594
  headers: {
593
595
  "content-type": "text/html; charset=utf-8",
@@ -633,7 +635,7 @@ async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
633
635
  }
634
636
  }
635
637
  }
636
- var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize?client_id=${getEnv(
638
+ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize/?client_id=${getEnv(
637
639
  "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
638
640
  )}&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 */)}`;
639
641
 
@@ -676,7 +678,10 @@ var getInstagramRoute = ({
676
678
  if (error) return handleError2(error);
677
679
  if (!accessCode) {
678
680
  if (!stateToken) return handleError2("Invalid request");
679
- return getAuthorizationHandoff(getInstagramAuthorizationURL(stateToken));
681
+ return getAuthorizationHandoff(
682
+ getInstagramAuthorizationURL(stateToken),
683
+ "Instagram"
684
+ );
680
685
  }
681
686
  if (!stateToken) return handleError2("Invalid request");
682
687
  const instagramData = await getLongLivedToken(
@@ -537,14 +537,16 @@ import { NextResponse as NextResponse8 } from "next/server";
537
537
 
538
538
  // src/auth/instagram/utils.ts
539
539
  import { NextResponse as NextResponse6 } from "next/server";
540
- function getAuthorizationHandoff(authorizationURL) {
540
+ var HANDOFF_DELAY_MS = 1500;
541
+ function getAuthorizationHandoff(authorizationURL, providerName) {
541
542
  const scriptSafeURL = JSON.stringify(authorizationURL).replace(
542
543
  /</g,
543
544
  "\\u003c"
544
545
  );
545
546
  const attributeSafeURL = authorizationURL.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
547
+ const safeProviderName = providerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
546
548
  return new NextResponse6(
547
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Connecting\u2026</title><script>location.replace(${scriptSafeURL})</script><noscript><meta http-equiv="refresh" content="0;url=${attributeSafeURL}"></noscript></head><body></body></html>`,
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>`,
548
550
  {
549
551
  headers: {
550
552
  "content-type": "text/html; charset=utf-8",
@@ -590,7 +592,7 @@ async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
590
592
  }
591
593
  }
592
594
  }
593
- var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize?client_id=${getEnv(
595
+ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize/?client_id=${getEnv(
594
596
  "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
595
597
  )}&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 */)}`;
596
598
 
@@ -633,7 +635,10 @@ var getInstagramRoute = ({
633
635
  if (error) return handleError2(error);
634
636
  if (!accessCode) {
635
637
  if (!stateToken) return handleError2("Invalid request");
636
- return getAuthorizationHandoff(getInstagramAuthorizationURL(stateToken));
638
+ return getAuthorizationHandoff(
639
+ getInstagramAuthorizationURL(stateToken),
640
+ "Instagram"
641
+ );
637
642
  }
638
643
  if (!stateToken) return handleError2("Invalid request");
639
644
  const instagramData = await getLongLivedToken(
@@ -103,14 +103,16 @@ function getUserIdFromAccessToken(accessToken) {
103
103
 
104
104
  // src/auth/instagram/utils.ts
105
105
  var import_server2 = require("next/server");
106
- function getAuthorizationHandoff(authorizationURL) {
106
+ var HANDOFF_DELAY_MS = 1500;
107
+ function getAuthorizationHandoff(authorizationURL, providerName) {
107
108
  const scriptSafeURL = JSON.stringify(authorizationURL).replace(
108
109
  /</g,
109
110
  "\\u003c"
110
111
  );
111
112
  const attributeSafeURL = authorizationURL.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
113
+ const safeProviderName = providerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
112
114
  return new import_server2.NextResponse(
113
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Connecting\u2026</title><script>location.replace(${scriptSafeURL})</script><noscript><meta http-equiv="refresh" content="0;url=${attributeSafeURL}"></noscript></head><body></body></html>`,
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>`,
114
116
  {
115
117
  headers: {
116
118
  "content-type": "text/html; charset=utf-8",
@@ -156,7 +158,7 @@ async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
156
158
  }
157
159
  }
158
160
  }
159
- var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize?client_id=${getEnv(
161
+ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize/?client_id=${getEnv(
160
162
  "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
161
163
  )}&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 */)}`;
162
164
 
@@ -199,7 +201,10 @@ var getInstagramRoute = ({
199
201
  if (error) return handleError(error);
200
202
  if (!accessCode) {
201
203
  if (!stateToken) return handleError("Invalid request");
202
- return getAuthorizationHandoff(getInstagramAuthorizationURL(stateToken));
204
+ return getAuthorizationHandoff(
205
+ getInstagramAuthorizationURL(stateToken),
206
+ "Instagram"
207
+ );
203
208
  }
204
209
  if (!stateToken) return handleError("Invalid request");
205
210
  const instagramData = await getLongLivedToken(
@@ -22,9 +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 → an HTML page that jumps to Instagram's
26
- * authorize URL client-side, so mobile browsers don't universal-link the flow into
27
- * the Instagram app; see {@link getAuthorizationHandoff}).
25
+ * entry point (`?state` with no code → an interstitial page that waits, then jumps
26
+ * to Instagram's authorize URL; see {@link getAuthorizationHandoff}).
28
27
  *
29
28
  * Requires env vars: `INSTAGRAM_CLIENT_ID` (server-only), `INSTAGRAM_CLIENT_SECRET`, `NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT`.
30
29
  *
@@ -22,9 +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 → an HTML page that jumps to Instagram's
26
- * authorize URL client-side, so mobile browsers don't universal-link the flow into
27
- * the Instagram app; see {@link getAuthorizationHandoff}).
25
+ * entry point (`?state` with no code → an interstitial page that waits, then jumps
26
+ * to Instagram's authorize URL; see {@link getAuthorizationHandoff}).
28
27
  *
29
28
  * Requires env vars: `INSTAGRAM_CLIENT_ID` (server-only), `INSTAGRAM_CLIENT_SECRET`, `NEXT_PUBLIC_INSTAGRAM_AUTH_ENDPOINT`.
30
29
  *
@@ -74,14 +74,16 @@ function getUserIdFromAccessToken(accessToken) {
74
74
 
75
75
  // src/auth/instagram/utils.ts
76
76
  import { NextResponse as NextResponse2 } from "next/server";
77
- function getAuthorizationHandoff(authorizationURL) {
77
+ var HANDOFF_DELAY_MS = 1500;
78
+ function getAuthorizationHandoff(authorizationURL, providerName) {
78
79
  const scriptSafeURL = JSON.stringify(authorizationURL).replace(
79
80
  /</g,
80
81
  "\\u003c"
81
82
  );
82
83
  const attributeSafeURL = authorizationURL.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
84
+ const safeProviderName = providerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
83
85
  return new NextResponse2(
84
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Connecting\u2026</title><script>location.replace(${scriptSafeURL})</script><noscript><meta http-equiv="refresh" content="0;url=${attributeSafeURL}"></noscript></head><body></body></html>`,
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>`,
85
87
  {
86
88
  headers: {
87
89
  "content-type": "text/html; charset=utf-8",
@@ -127,7 +129,7 @@ async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
127
129
  }
128
130
  }
129
131
  }
130
- var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize?client_id=${getEnv(
132
+ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize/?client_id=${getEnv(
131
133
  "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
132
134
  )}&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 */)}`;
133
135
 
@@ -170,7 +172,10 @@ var getInstagramRoute = ({
170
172
  if (error) return handleError(error);
171
173
  if (!accessCode) {
172
174
  if (!stateToken) return handleError("Invalid request");
173
- return getAuthorizationHandoff(getInstagramAuthorizationURL(stateToken));
175
+ return getAuthorizationHandoff(
176
+ getInstagramAuthorizationURL(stateToken),
177
+ "Instagram"
178
+ );
174
179
  }
175
180
  if (!stateToken) return handleError("Invalid request");
176
181
  const instagramData = await getLongLivedToken(
@@ -98,14 +98,16 @@ function getUserIdFromAccessToken(accessToken) {
98
98
 
99
99
  // src/auth/instagram/utils.ts
100
100
  var import_server2 = require("next/server");
101
- function getAuthorizationHandoff(authorizationURL) {
101
+ var HANDOFF_DELAY_MS = 1500;
102
+ function getAuthorizationHandoff(authorizationURL, providerName) {
102
103
  const scriptSafeURL = JSON.stringify(authorizationURL).replace(
103
104
  /</g,
104
105
  "\\u003c"
105
106
  );
106
107
  const attributeSafeURL = authorizationURL.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
108
+ const safeProviderName = providerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
107
109
  return new import_server2.NextResponse(
108
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Connecting\u2026</title><script>location.replace(${scriptSafeURL})</script><noscript><meta http-equiv="refresh" content="0;url=${attributeSafeURL}"></noscript></head><body></body></html>`,
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>`,
109
111
  {
110
112
  headers: {
111
113
  "content-type": "text/html; charset=utf-8",
@@ -144,7 +146,7 @@ async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
144
146
  }
145
147
  }
146
148
  }
147
- var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize?client_id=${getEnv(
149
+ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize/?client_id=${getEnv(
148
150
  "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
149
151
  )}&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 */)}`;
150
152
 
@@ -187,7 +189,10 @@ var getInstagramRoute = ({
187
189
  if (error) return handleError(error);
188
190
  if (!accessCode) {
189
191
  if (!stateToken) return handleError("Invalid request");
190
- return getAuthorizationHandoff(getInstagramAuthorizationURL(stateToken));
192
+ return getAuthorizationHandoff(
193
+ getInstagramAuthorizationURL(stateToken),
194
+ "Instagram"
195
+ );
191
196
  }
192
197
  if (!stateToken) return handleError("Invalid request");
193
198
  const instagramData = await getLongLivedToken(
@@ -74,14 +74,16 @@ function getUserIdFromAccessToken(accessToken) {
74
74
 
75
75
  // src/auth/instagram/utils.ts
76
76
  import { NextResponse as NextResponse2 } from "next/server";
77
- function getAuthorizationHandoff(authorizationURL) {
77
+ var HANDOFF_DELAY_MS = 1500;
78
+ function getAuthorizationHandoff(authorizationURL, providerName) {
78
79
  const scriptSafeURL = JSON.stringify(authorizationURL).replace(
79
80
  /</g,
80
81
  "\\u003c"
81
82
  );
82
83
  const attributeSafeURL = authorizationURL.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
84
+ const safeProviderName = providerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
83
85
  return new NextResponse2(
84
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Connecting\u2026</title><script>location.replace(${scriptSafeURL})</script><noscript><meta http-equiv="refresh" content="0;url=${attributeSafeURL}"></noscript></head><body></body></html>`,
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>`,
85
87
  {
86
88
  headers: {
87
89
  "content-type": "text/html; charset=utf-8",
@@ -120,7 +122,7 @@ async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
120
122
  }
121
123
  }
122
124
  }
123
- var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize?client_id=${getEnv(
125
+ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize/?client_id=${getEnv(
124
126
  "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
125
127
  )}&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 */)}`;
126
128
 
@@ -163,7 +165,10 @@ var getInstagramRoute = ({
163
165
  if (error) return handleError(error);
164
166
  if (!accessCode) {
165
167
  if (!stateToken) return handleError("Invalid request");
166
- return getAuthorizationHandoff(getInstagramAuthorizationURL(stateToken));
168
+ return getAuthorizationHandoff(
169
+ getInstagramAuthorizationURL(stateToken),
170
+ "Instagram"
171
+ );
167
172
  }
168
173
  if (!stateToken) return handleError("Invalid request");
169
174
  const instagramData = await getLongLivedToken(
@@ -79,14 +79,16 @@ function getEnv(key, skipCheck) {
79
79
  }
80
80
 
81
81
  // src/auth/instagram/utils.ts
82
- function getAuthorizationHandoff(authorizationURL) {
82
+ var HANDOFF_DELAY_MS = 1500;
83
+ function getAuthorizationHandoff(authorizationURL, providerName) {
83
84
  const scriptSafeURL = JSON.stringify(authorizationURL).replace(
84
85
  /</g,
85
86
  "\\u003c"
86
87
  );
87
88
  const attributeSafeURL = authorizationURL.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
89
+ const safeProviderName = providerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
88
90
  return new import_server.NextResponse(
89
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Connecting\u2026</title><script>location.replace(${scriptSafeURL})</script><noscript><meta http-equiv="refresh" content="0;url=${attributeSafeURL}"></noscript></head><body></body></html>`,
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>`,
90
92
  {
91
93
  headers: {
92
94
  "content-type": "text/html; charset=utf-8",
@@ -132,7 +134,7 @@ async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
132
134
  }
133
135
  }
134
136
  }
135
- var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize?client_id=${getEnv(
137
+ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize/?client_id=${getEnv(
136
138
  "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
137
139
  )}&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 */)}`;
138
140
  // Annotate the CommonJS export names for ESM import in node:
@@ -2,26 +2,20 @@ import { NextResponse } from 'next/server';
2
2
 
3
3
  /**
4
4
  * Builds the interstitial document that carries the browser from our origin to a
5
- * provider's authorization page.
6
- *
7
- * Mobile browsers match universal links (iOS) and app links (Android) against the
8
- * final URL of a *user-initiated* navigation — following redirects — so both a
9
- * tapped `<a href="https://www.instagram.com/…">` and a server 302 to the same
10
- * place can be intercepted by the provider's native app, which has no idea what to
11
- * do with an OAuth flow. A navigation issued from a freshly loaded document has no
12
- * gesture token behind it and is never intercepted, so this page loads and
13
- * immediately replaces itself with `authorizationURL`.
5
+ * provider's authorization page: it renders, waits {@link HANDOFF_DELAY_MS}, then
6
+ * replaces itself with `authorizationURL`.
14
7
  *
15
8
  * `location.replace` keeps the interstitial out of session history, so Back from
16
9
  * the provider returns to the page that started the flow. The `noscript` meta
17
10
  * refresh is a fallback, not the primary path.
18
11
  *
19
12
  * @param authorizationURL - Provider authorization URL to hand the browser off to
20
- * @returns HTML response that redirects client-side
13
+ * @param providerName - Shown to the user while waiting, e.g. `"Instagram"`
14
+ * @returns HTML response that redirects client-side after a delay
21
15
  *
22
16
  * @category Auth
23
17
  */
24
- declare function getAuthorizationHandoff(authorizationURL: string): NextResponse<unknown>;
18
+ declare function getAuthorizationHandoff(authorizationURL: string, providerName: string): NextResponse<unknown>;
25
19
  /**
26
20
  * Exchanges a long-lived Instagram token for a refreshed token.
27
21
  * @param token - Current long-lived access token
@@ -57,12 +51,10 @@ declare function getLongLivedToken(code: string, redirectURL: string, clientId:
57
51
  *
58
52
  * @example
59
53
  * ```ts
60
- * // In a server route handler. Hand off with `getAuthorizationHandoff` rather
61
- * // than `NextResponse.redirect` a 302 onto instagram.com is still matched as a
62
- * // universal/app link and opens the Instagram app mid-flow.
63
- * import { getAuthorizationHandoff, getInstagramAuthorizationURL } from "naystack/auth";
54
+ * // In a server route handler:
55
+ * import { getInstagramAuthorizationURL } from "naystack/auth";
64
56
  *
65
- * return getAuthorizationHandoff(getInstagramAuthorizationURL(state));
57
+ * return NextResponse.redirect(getInstagramAuthorizationURL(state), 302);
66
58
  * ```
67
59
  *
68
60
  * @category Auth
@@ -2,26 +2,20 @@ import { NextResponse } from 'next/server';
2
2
 
3
3
  /**
4
4
  * Builds the interstitial document that carries the browser from our origin to a
5
- * provider's authorization page.
6
- *
7
- * Mobile browsers match universal links (iOS) and app links (Android) against the
8
- * final URL of a *user-initiated* navigation — following redirects — so both a
9
- * tapped `<a href="https://www.instagram.com/…">` and a server 302 to the same
10
- * place can be intercepted by the provider's native app, which has no idea what to
11
- * do with an OAuth flow. A navigation issued from a freshly loaded document has no
12
- * gesture token behind it and is never intercepted, so this page loads and
13
- * immediately replaces itself with `authorizationURL`.
5
+ * provider's authorization page: it renders, waits {@link HANDOFF_DELAY_MS}, then
6
+ * replaces itself with `authorizationURL`.
14
7
  *
15
8
  * `location.replace` keeps the interstitial out of session history, so Back from
16
9
  * the provider returns to the page that started the flow. The `noscript` meta
17
10
  * refresh is a fallback, not the primary path.
18
11
  *
19
12
  * @param authorizationURL - Provider authorization URL to hand the browser off to
20
- * @returns HTML response that redirects client-side
13
+ * @param providerName - Shown to the user while waiting, e.g. `"Instagram"`
14
+ * @returns HTML response that redirects client-side after a delay
21
15
  *
22
16
  * @category Auth
23
17
  */
24
- declare function getAuthorizationHandoff(authorizationURL: string): NextResponse<unknown>;
18
+ declare function getAuthorizationHandoff(authorizationURL: string, providerName: string): NextResponse<unknown>;
25
19
  /**
26
20
  * Exchanges a long-lived Instagram token for a refreshed token.
27
21
  * @param token - Current long-lived access token
@@ -57,12 +51,10 @@ declare function getLongLivedToken(code: string, redirectURL: string, clientId:
57
51
  *
58
52
  * @example
59
53
  * ```ts
60
- * // In a server route handler. Hand off with `getAuthorizationHandoff` rather
61
- * // than `NextResponse.redirect` a 302 onto instagram.com is still matched as a
62
- * // universal/app link and opens the Instagram app mid-flow.
63
- * import { getAuthorizationHandoff, getInstagramAuthorizationURL } from "naystack/auth";
54
+ * // In a server route handler:
55
+ * import { getInstagramAuthorizationURL } from "naystack/auth";
64
56
  *
65
- * return getAuthorizationHandoff(getInstagramAuthorizationURL(state));
57
+ * return NextResponse.redirect(getInstagramAuthorizationURL(state), 302);
66
58
  * ```
67
59
  *
68
60
  * @category Auth
@@ -52,14 +52,16 @@ function getEnv(key, skipCheck) {
52
52
  }
53
53
 
54
54
  // src/auth/instagram/utils.ts
55
- function getAuthorizationHandoff(authorizationURL) {
55
+ var HANDOFF_DELAY_MS = 1500;
56
+ function getAuthorizationHandoff(authorizationURL, providerName) {
56
57
  const scriptSafeURL = JSON.stringify(authorizationURL).replace(
57
58
  /</g,
58
59
  "\\u003c"
59
60
  );
60
61
  const attributeSafeURL = authorizationURL.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
62
+ const safeProviderName = providerName.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
61
63
  return new NextResponse(
62
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>Connecting\u2026</title><script>location.replace(${scriptSafeURL})</script><noscript><meta http-equiv="refresh" content="0;url=${attributeSafeURL}"></noscript></head><body></body></html>`,
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>`,
63
65
  {
64
66
  headers: {
65
67
  "content-type": "text/html; charset=utf-8",
@@ -105,7 +107,7 @@ async function getLongLivedToken(code, redirectURL, clientId, clientSecret) {
105
107
  }
106
108
  }
107
109
  }
108
- var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize?client_id=${getEnv(
110
+ var getInstagramAuthorizationURL = (token) => `https://www.instagram.com/oauth/authorize/?client_id=${getEnv(
109
111
  "INSTAGRAM_CLIENT_ID" /* INSTAGRAM_CLIENT_ID */
110
112
  )}&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 */)}`;
111
113
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "naystack",
3
- "version": "1.8.6",
3
+ "version": "1.8.8",
4
4
  "description": "A stack built with Next + GraphQL + S3 + Auth",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",