authscape 1.0.778 → 1.0.780

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.778",
3
+ "version": "1.0.780",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -41,6 +41,64 @@ import { createSitemapRoute } from 'authscape/src/lib/sitemap-route';
41
41
  export const GET = createSitemapRoute(process.env.apiUri);
42
42
  `;
43
43
 
44
+ // ---------------------------------------------------------------------------
45
+ // /signin-oidc page templates
46
+ // ---------------------------------------------------------------------------
47
+ // AuthScapeApp reads the PKCE `code` query param from `useSearchParams()`
48
+ // (next/navigation). If the consumer doesn't have a `/signin-oidc` page, the
49
+ // IDP's redirect back lands on Next.js's 404 page — and Webkit/Safari
50
+ // doesn't reliably hydrate `useSearchParams()` on the 404 page. The code is
51
+ // never read, the user is stuck.
52
+ //
53
+ // Making /signin-oidc a real Next.js page (200 status) fixes this in every
54
+ // browser. The page itself is a placeholder; AuthScapeApp's signInValidator
55
+ // does the actual token exchange.
56
+
57
+ const SIGNIN_OIDC_PAGES_ROUTER_TEMPLATE = `// Auto-generated by AuthScape - Do not edit manually.
58
+ // Exists so /signin-oidc returns HTTP 200 (not the Next.js 404 page).
59
+ // Required for Webkit/Safari: useSearchParams() doesn't hydrate on the 404
60
+ // page in Webkit, so the PKCE 'code' query param is never read and sign-in
61
+ // silently stalls. With this real page in place, AuthScapeApp's
62
+ // signInValidator picks up the code and completes the exchange normally.
63
+ export default function SignInOidc() {
64
+ return (
65
+ <div
66
+ style={{
67
+ display: "flex",
68
+ alignItems: "center",
69
+ justifyContent: "center",
70
+ minHeight: "60vh",
71
+ fontFamily: "system-ui, -apple-system, Segoe UI, sans-serif",
72
+ color: "#666",
73
+ }}
74
+ >
75
+ Signing you in…
76
+ </div>
77
+ );
78
+ }
79
+ `;
80
+
81
+ const SIGNIN_OIDC_APP_ROUTER_TEMPLATE = `// Auto-generated by AuthScape - Do not edit manually.
82
+ // Exists so /signin-oidc returns HTTP 200 (not the Next.js 404 page).
83
+ // Required for Webkit/Safari to pick up the PKCE 'code' query param.
84
+ export default function SignInOidc() {
85
+ return (
86
+ <div
87
+ style={{
88
+ display: "flex",
89
+ alignItems: "center",
90
+ justifyContent: "center",
91
+ minHeight: "60vh",
92
+ fontFamily: "system-ui, -apple-system, Segoe UI, sans-serif",
93
+ color: "#666",
94
+ }}
95
+ >
96
+ Signing you in…
97
+ </div>
98
+ );
99
+ }
100
+ `;
101
+
44
102
  function detectProjectStructure() {
45
103
  // Get the parent directory where the user ran npm install
46
104
  // This goes up from node_modules/authscape to the project root
@@ -118,9 +176,42 @@ function setupSitemap() {
118
176
  }
119
177
  }
120
178
 
179
+ function setupSigninOidc() {
180
+ const structure = detectProjectStructure();
181
+ if (!structure) return;
182
+
183
+ const targetFile =
184
+ structure.type === 'app'
185
+ ? path.join(structure.baseDir, 'signin-oidc', 'page.js')
186
+ : path.join(structure.baseDir, 'signin-oidc.js');
187
+
188
+ if (fs.existsSync(targetFile)) {
189
+ // File exists, don't overwrite — consumer may have their own handler
190
+ return;
191
+ }
192
+
193
+ try {
194
+ fs.mkdirSync(path.dirname(targetFile), { recursive: true });
195
+ fs.writeFileSync(
196
+ targetFile,
197
+ structure.type === 'app' ? SIGNIN_OIDC_APP_ROUTER_TEMPLATE : SIGNIN_OIDC_PAGES_ROUTER_TEMPLATE,
198
+ 'utf8'
199
+ );
200
+ console.log(
201
+ '✅ AuthScape signin-oidc page configured at /signin-oidc (' +
202
+ (structure.type === 'app' ? 'App Router' : 'Pages Router') +
203
+ ')'
204
+ );
205
+ } catch (error) {
206
+ console.log('⚠️ Could not auto-configure /signin-oidc:', error.message);
207
+ console.log(' Without this page, Safari users will fail to sign in.');
208
+ }
209
+ }
210
+
121
211
  // Run the setup
122
212
  try {
123
213
  setupSitemap();
214
+ setupSigninOidc();
124
215
  } catch (error) {
125
216
  // Completely silent failure to avoid breaking npm install
126
217
  // Only log if there's an unexpected error