@pontive/server 1.23.0 → 1.24.0
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/README.md +42 -0
- package/dist/authorization.cjs +1 -1
- package/dist/authorization.js +2 -2
- package/dist/client-BiVX0Gh-.cjs +2 -0
- package/dist/client-BiVX0Gh-.cjs.map +1 -0
- package/dist/client-_s4seciG.js +6693 -0
- package/dist/client-_s4seciG.js.map +1 -0
- package/dist/env.d.cts +2 -0
- package/dist/env.d.ts +2 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +219 -248
- package/dist/index.js.map +1 -1
- package/dist/management/client.d.cts +68 -0
- package/dist/management/client.d.ts +68 -0
- package/dist/management/core.d.cts +112 -0
- package/dist/management/core.d.ts +112 -0
- package/dist/management/errors.d.cts +78 -0
- package/dist/management/errors.d.ts +78 -0
- package/dist/management/generated/namespaces.d.cts +5404 -0
- package/dist/management/generated/namespaces.d.ts +5404 -0
- package/dist/management/generated/types.d.cts +7756 -0
- package/dist/management/generated/types.d.ts +7756 -0
- package/dist/management/index.d.cts +10 -0
- package/dist/management/index.d.ts +10 -0
- package/dist/management-credential--CmS8XaV.cjs +2 -0
- package/dist/management-credential--CmS8XaV.cjs.map +1 -0
- package/dist/management-credential-CynS93TR.js +166 -0
- package/dist/management-credential-CynS93TR.js.map +1 -0
- package/dist/management.cjs +2 -0
- package/dist/management.cjs.map +1 -0
- package/dist/management.js +20 -0
- package/dist/management.js.map +1 -0
- package/dist/resource-server.cjs +1 -1
- package/dist/resource-server.cjs.map +1 -1
- package/dist/resource-server.js +3 -4
- package/dist/resource-server.js.map +1 -1
- package/package.json +12 -2
- package/dist/management-credential-BNyhHagG.cjs +0 -2
- package/dist/management-credential-BNyhHagG.cjs.map +0 -1
- package/dist/management-credential-VhmMzGDl.js +0 -39
- package/dist/management-credential-VhmMzGDl.js.map +0 -1
- package/dist/oidc--We55Nrh.cjs +0 -2
- package/dist/oidc--We55Nrh.cjs.map +0 -1
- package/dist/oidc-CB0FqjFz.js +0 -131
- package/dist/oidc-CB0FqjFz.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { p as fe, w as we, k as me, i as ve } from "./client-_s4seciG.js";
|
|
2
|
+
import { h as yt, d as gt, e as Et, f as _t } from "./client-_s4seciG.js";
|
|
3
|
+
import { readKeylessRecord as Se, KeylessUnavailableError as te, claimLinkFor as ke, PontiveApiError as D, goneMessage as ne, ensureKeylessInstance as ye, loopbackCallbacks as ge, keylessMessage as Ee, KEYLESS_FILE as _e, ENV_FILE as Pe, KeylessInstanceGoneError as be } from "./keyless.js";
|
|
4
|
+
import { v as Ie, s as re, u as Te, r as F, T as j, e as $, f as Re, p as Ue, g as Ce, h as Ae, i as Ne } from "./management-credential-CynS93TR.js";
|
|
5
|
+
import { decodeJwt as $e, jwtDecrypt as Oe, EncryptJWT as Le } from "jose";
|
|
4
6
|
const xe = 10080 * 60;
|
|
5
|
-
function
|
|
7
|
+
function se(e) {
|
|
6
8
|
const t = e.clientSecret ? "server" : "browser", n = ["issuer", "clientId"];
|
|
7
9
|
t === "server" && n.push("sessionSecret");
|
|
8
10
|
for (const s of n)
|
|
@@ -42,42 +44,8 @@ function ae(e) {
|
|
|
42
44
|
logger: e.logger ?? console
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
clientId: "PONTIVE_CLIENT_ID",
|
|
48
|
-
clientSecret: "PONTIVE_CLIENT_SECRET",
|
|
49
|
-
sessionSecret: "PONTIVE_SESSION_SECRET",
|
|
50
|
-
secretKey: "PONTIVE_SECRET_KEY",
|
|
51
|
-
instanceId: "PONTIVE_INSTANCE_ID",
|
|
52
|
-
apiUrl: "PONTIVE_API_URL",
|
|
53
|
-
region: "PONTIVE_REGION",
|
|
54
|
-
keyless: "PONTIVE_KEYLESS"
|
|
55
|
-
};
|
|
56
|
-
function V() {
|
|
57
|
-
try {
|
|
58
|
-
return globalThis.process?.env ?? {};
|
|
59
|
-
} catch {
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const L = (e) => e && e.trim() ? e.trim() : void 0;
|
|
64
|
-
function Ve(e, t = V()) {
|
|
65
|
-
return {
|
|
66
|
-
...e,
|
|
67
|
-
issuer: e.issuer || L(t[U.issuer]),
|
|
68
|
-
clientId: e.clientId || L(t[U.clientId]),
|
|
69
|
-
clientSecret: e.clientSecret || L(t[U.clientSecret]),
|
|
70
|
-
sessionSecret: e.sessionSecret || L(t[U.sessionSecret])
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function ce(e = V()) {
|
|
74
|
-
return e.NODE_ENV === "development";
|
|
75
|
-
}
|
|
76
|
-
function Me(e, t = V()) {
|
|
77
|
-
return ce(t) && !e.issuer && t[U.keyless]?.trim() !== "0";
|
|
78
|
-
}
|
|
79
|
-
const D = 3500, z = 16;
|
|
80
|
-
function b(e) {
|
|
47
|
+
const x = 3500, V = 16;
|
|
48
|
+
function T(e) {
|
|
81
49
|
const t = /* @__PURE__ */ new Map();
|
|
82
50
|
if (!e) return t;
|
|
83
51
|
for (const n of e.split(";")) {
|
|
@@ -88,74 +56,74 @@ function b(e) {
|
|
|
88
56
|
}
|
|
89
57
|
return t;
|
|
90
58
|
}
|
|
91
|
-
function
|
|
59
|
+
function W(e) {
|
|
92
60
|
return [...e].map(([t, n]) => `${t}=${n}`).join("; ");
|
|
93
61
|
}
|
|
94
|
-
function
|
|
62
|
+
function C(e, t, n) {
|
|
95
63
|
const s = n.sameSite ?? "Lax", c = [`${e}=${t}`, "Path=/", "HttpOnly", `SameSite=${s}`, `Max-Age=${n.maxAge}`];
|
|
96
64
|
return (n.secure || s === "None") && c.push("Secure"), c.join("; ");
|
|
97
65
|
}
|
|
98
|
-
function
|
|
66
|
+
function U(e, t) {
|
|
99
67
|
return t === 0 ? e : `${e}.${t}`;
|
|
100
68
|
}
|
|
101
|
-
function
|
|
69
|
+
function Me(e, t) {
|
|
102
70
|
const n = e.get(t);
|
|
103
71
|
if (n === void 0) return null;
|
|
104
72
|
let s = n;
|
|
105
|
-
for (let c = 1; c <
|
|
106
|
-
const a = e.get(
|
|
73
|
+
for (let c = 1; c < V; c++) {
|
|
74
|
+
const a = e.get(U(t, c));
|
|
107
75
|
if (a === void 0) break;
|
|
108
76
|
s += a;
|
|
109
77
|
}
|
|
110
78
|
return s;
|
|
111
79
|
}
|
|
112
|
-
function
|
|
113
|
-
const c = [], a = Math.max(1, Math.ceil(n.length /
|
|
80
|
+
function Ve(e, t, n, s) {
|
|
81
|
+
const c = [], a = Math.max(1, Math.ceil(n.length / x));
|
|
114
82
|
for (let i = 0; i < a; i++) {
|
|
115
|
-
const l = n.slice(i *
|
|
116
|
-
e.set(
|
|
83
|
+
const l = n.slice(i * x, (i + 1) * x);
|
|
84
|
+
e.set(U(t, i), l), c.push(C(U(t, i), l, s));
|
|
117
85
|
}
|
|
118
|
-
for (let i = a; i <
|
|
119
|
-
const l =
|
|
86
|
+
for (let i = a; i < V; i++) {
|
|
87
|
+
const l = U(t, i);
|
|
120
88
|
if (!e.has(l)) break;
|
|
121
|
-
e.delete(l), c.push(
|
|
89
|
+
e.delete(l), c.push(C(l, "", { ...s, maxAge: 0 }));
|
|
122
90
|
}
|
|
123
91
|
return c;
|
|
124
92
|
}
|
|
125
|
-
function
|
|
93
|
+
function G(e, t, n) {
|
|
126
94
|
const s = [];
|
|
127
|
-
for (let c = 0; c <
|
|
128
|
-
const a =
|
|
95
|
+
for (let c = 0; c < V; c++) {
|
|
96
|
+
const a = U(t, c);
|
|
129
97
|
if (!e.has(a)) {
|
|
130
98
|
if (c > 0) break;
|
|
131
99
|
continue;
|
|
132
100
|
}
|
|
133
|
-
e.delete(a), s.push(
|
|
101
|
+
e.delete(a), s.push(C(a, "", { ...n, maxAge: 0 }));
|
|
134
102
|
}
|
|
135
103
|
return s;
|
|
136
104
|
}
|
|
137
|
-
const
|
|
138
|
-
function
|
|
105
|
+
const H = "switch-organization", He = "organization_error", K = (e) => Array.isArray(e) ? e.filter((t) => typeof t == "string") : [];
|
|
106
|
+
function oe(e) {
|
|
139
107
|
const t = e.org_id;
|
|
140
108
|
return typeof t != "string" || t === "" ? null : {
|
|
141
109
|
id: t,
|
|
142
|
-
roles:
|
|
143
|
-
permissions:
|
|
110
|
+
roles: K(e.roles),
|
|
111
|
+
permissions: K(e.permissions)
|
|
144
112
|
};
|
|
145
113
|
}
|
|
146
|
-
function
|
|
114
|
+
function ze(e) {
|
|
147
115
|
try {
|
|
148
|
-
return
|
|
116
|
+
return $e(e);
|
|
149
117
|
} catch {
|
|
150
118
|
return {};
|
|
151
119
|
}
|
|
152
120
|
}
|
|
153
|
-
function
|
|
121
|
+
function mt(e, t, n = "/") {
|
|
154
122
|
const s = new URLSearchParams({ organization_id: t, returnTo: n });
|
|
155
|
-
return `${e}/${
|
|
123
|
+
return `${e}/${H}?${s.toString()}`;
|
|
156
124
|
}
|
|
157
|
-
const
|
|
158
|
-
function
|
|
125
|
+
const De = "__Host-pontive_access", Fe = "__Secure-pontive_session_state";
|
|
126
|
+
function je(e) {
|
|
159
127
|
const t = (n) => typeof e[n] == "string" ? e[n] : void 0;
|
|
160
128
|
return {
|
|
161
129
|
id: t("sub") ?? "",
|
|
@@ -166,7 +134,7 @@ function Ke(e) {
|
|
|
166
134
|
emailVerified: e.email_verified === !0
|
|
167
135
|
};
|
|
168
136
|
}
|
|
169
|
-
function
|
|
137
|
+
function We(e) {
|
|
170
138
|
const t = { issuer: e.issuer, clientId: e.clientId }, n = /* @__PURE__ */ new Map();
|
|
171
139
|
function s(i) {
|
|
172
140
|
for (const [l, d] of n)
|
|
@@ -175,17 +143,17 @@ function Ge(e) {
|
|
|
175
143
|
async function c(i, l) {
|
|
176
144
|
const d = Date.now();
|
|
177
145
|
s(d);
|
|
178
|
-
const u = await
|
|
146
|
+
const u = await re(i), p = n.get(u);
|
|
179
147
|
if (p) return p.profile;
|
|
180
|
-
const m =
|
|
148
|
+
const m = Te(t, e.fetch, i).catch((S) => (n.delete(u), e.logger.warn("[pontive] could not read the user's profile:", S instanceof Error ? S.message : String(S)), null));
|
|
181
149
|
return n.set(u, { expiresAt: l, profile: m }), m;
|
|
182
150
|
}
|
|
183
151
|
async function a(i) {
|
|
184
|
-
const l =
|
|
152
|
+
const l = T(i).get(De);
|
|
185
153
|
if (!l) return null;
|
|
186
154
|
let d;
|
|
187
155
|
try {
|
|
188
|
-
d = await
|
|
156
|
+
d = await Ie(t, e.fetch, l);
|
|
189
157
|
} catch (m) {
|
|
190
158
|
return m.code !== "ERR_JWT_EXPIRED" && e.logger.warn("[pontive] access token cookie refused:", m instanceof Error ? m.message : String(m)), null;
|
|
191
159
|
}
|
|
@@ -193,11 +161,11 @@ function Ge(e) {
|
|
|
193
161
|
return {
|
|
194
162
|
// The token's own claims win for sub: the profile describes the user the
|
|
195
163
|
// token names, never another one.
|
|
196
|
-
user:
|
|
164
|
+
user: je({ ...p, ...d, sub: d.sub }),
|
|
197
165
|
accessToken: l,
|
|
198
166
|
expiresAt: u,
|
|
199
167
|
sessionId: typeof d.sid == "string" ? d.sid : void 0,
|
|
200
|
-
organization:
|
|
168
|
+
organization: oe(d),
|
|
201
169
|
claims: d
|
|
202
170
|
};
|
|
203
171
|
}
|
|
@@ -209,28 +177,28 @@ function Ge(e) {
|
|
|
209
177
|
// refresh token. A refused switch comes back with organization_error.
|
|
210
178
|
async handle(i) {
|
|
211
179
|
const l = new URL(i.url);
|
|
212
|
-
if (l.pathname !== `${e.basePath}/${
|
|
213
|
-
const d = l.searchParams.get("organization_id"), u =
|
|
214
|
-
if (!d) return
|
|
180
|
+
if (l.pathname !== `${e.basePath}/${H}`) return null;
|
|
181
|
+
const d = l.searchParams.get("organization_id"), u = Ge(l.searchParams.get("returnTo"));
|
|
182
|
+
if (!d) return B(u);
|
|
215
183
|
const p = new URL(`${e.authPath}/oauth2/session`, l.origin);
|
|
216
|
-
return p.searchParams.set("client_id", e.clientId), p.searchParams.set("return_to", u), p.searchParams.set("organization_id", d),
|
|
184
|
+
return p.searchParams.set("client_id", e.clientId), p.searchParams.set("return_to", u), p.searchParams.set("organization_id", d), B(p.pathname + p.search);
|
|
217
185
|
},
|
|
218
186
|
getSession: a,
|
|
219
187
|
async refresh(i) {
|
|
220
188
|
const l = i.headers.get("cookie"), d = await a(l), u = { session: d, setCookies: [], cookieHeader: l ?? "" };
|
|
221
|
-
if (d || !
|
|
189
|
+
if (d || !T(l).has(Fe)) return u;
|
|
222
190
|
const p = new URL(i.url), m = new URL(`${e.authPath}/oauth2/session`, p.origin);
|
|
223
191
|
return m.searchParams.set("client_id", e.clientId), m.searchParams.set("return_to", p.pathname + p.search), { ...u, handshake: m.pathname + m.search };
|
|
224
192
|
}
|
|
225
193
|
};
|
|
226
194
|
}
|
|
227
|
-
function
|
|
195
|
+
function Ge(e) {
|
|
228
196
|
return e && e.startsWith("/") && !e.startsWith("//") && !e.startsWith("/\\") ? e : "/";
|
|
229
197
|
}
|
|
230
|
-
function
|
|
198
|
+
function B(e) {
|
|
231
199
|
return new Response(null, { status: 302, headers: { location: e, "cache-control": "no-store" } });
|
|
232
200
|
}
|
|
233
|
-
const
|
|
201
|
+
const Ke = [
|
|
234
202
|
"lovable.app",
|
|
235
203
|
"lovableproject.com",
|
|
236
204
|
"lovable.dev",
|
|
@@ -245,11 +213,11 @@ const Je = [
|
|
|
245
213
|
"bolt.host",
|
|
246
214
|
"csb.app"
|
|
247
215
|
];
|
|
248
|
-
function
|
|
216
|
+
function Be(e) {
|
|
249
217
|
const t = e.toLowerCase().replace(/\.$/, "");
|
|
250
|
-
return
|
|
218
|
+
return Ke.some((n) => t === n || t.endsWith(`.${n}`));
|
|
251
219
|
}
|
|
252
|
-
const
|
|
220
|
+
const Je = {
|
|
253
221
|
lovable: ["*.lovableproject.com", "*.lovable.app", "*.lovable.dev"],
|
|
254
222
|
v0: ["*.vusercontent.net", "*.lite.vusercontent.net", "*.v0.app", "*.v0.dev"],
|
|
255
223
|
vercel: ["*.vercel.app"],
|
|
@@ -261,8 +229,8 @@ const Xe = {
|
|
|
261
229
|
"*.local-corp.webcontainer-api.io"
|
|
262
230
|
],
|
|
263
231
|
codesandbox: ["*.csb.app"]
|
|
264
|
-
},
|
|
265
|
-
function
|
|
232
|
+
}, Xe = "/oauth2/preview-callback", Ye = "pontive:authorization-response", Ze = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
233
|
+
function Qe(e) {
|
|
266
234
|
let t;
|
|
267
235
|
try {
|
|
268
236
|
t = new URL(e);
|
|
@@ -271,27 +239,27 @@ function et(e) {
|
|
|
271
239
|
}
|
|
272
240
|
if (t.protocol !== "https:" || t.port !== "" || t.origin !== e) return null;
|
|
273
241
|
const n = t.hostname.split(".");
|
|
274
|
-
for (const [s, c] of Object.entries(
|
|
242
|
+
for (const [s, c] of Object.entries(Je))
|
|
275
243
|
for (const a of c) {
|
|
276
244
|
const i = a.split(".");
|
|
277
|
-
if (i.length === n.length && i.every((l, d) => l === "*" ?
|
|
245
|
+
if (i.length === n.length && i.every((l, d) => l === "*" ? Ze.test(n[d]) : l === n[d]))
|
|
278
246
|
return s;
|
|
279
247
|
}
|
|
280
248
|
return null;
|
|
281
249
|
}
|
|
282
|
-
function
|
|
283
|
-
return `${e.replace(/\/$/, "")}${
|
|
250
|
+
function qe(e, t) {
|
|
251
|
+
return `${e.replace(/\/$/, "")}${Xe}?origin=${encodeURIComponent(t)}`;
|
|
284
252
|
}
|
|
285
|
-
const
|
|
286
|
-
class
|
|
287
|
-
constructor(t =
|
|
253
|
+
const et = 3e4;
|
|
254
|
+
class tt {
|
|
255
|
+
constructor(t = et) {
|
|
288
256
|
this.recentMs = t;
|
|
289
257
|
}
|
|
290
258
|
recentMs;
|
|
291
259
|
inFlight = /* @__PURE__ */ new Map();
|
|
292
260
|
recent = /* @__PURE__ */ new Map();
|
|
293
261
|
async run(t, n) {
|
|
294
|
-
const s = await
|
|
262
|
+
const s = await re(t);
|
|
295
263
|
this.sweep();
|
|
296
264
|
const c = this.recent.get(s);
|
|
297
265
|
if (c) return c.result;
|
|
@@ -304,34 +272,34 @@ class rt {
|
|
|
304
272
|
s.at < t && this.recent.delete(n);
|
|
305
273
|
}
|
|
306
274
|
}
|
|
307
|
-
const
|
|
308
|
-
function
|
|
309
|
-
let t =
|
|
310
|
-
return t || (t = crypto.subtle.digest("SHA-256", new TextEncoder().encode(e)).then((n) => new Uint8Array(n)),
|
|
275
|
+
const J = /* @__PURE__ */ new Map();
|
|
276
|
+
function ie(e) {
|
|
277
|
+
let t = J.get(e);
|
|
278
|
+
return t || (t = crypto.subtle.digest("SHA-256", new TextEncoder().encode(e)).then((n) => new Uint8Array(n)), J.set(e, t)), t;
|
|
311
279
|
}
|
|
312
|
-
async function
|
|
313
|
-
return new
|
|
280
|
+
async function X(e, t, n) {
|
|
281
|
+
return new Le(e).setProtectedHeader({ alg: "dir", enc: "A256GCM" }).setIssuedAt().setExpirationTime(`${n}s`).encrypt(await ie(t));
|
|
314
282
|
}
|
|
315
|
-
async function
|
|
283
|
+
async function Y(e, t) {
|
|
316
284
|
try {
|
|
317
|
-
const { payload: n } = await
|
|
285
|
+
const { payload: n } = await Oe(e, await ie(t));
|
|
318
286
|
return n;
|
|
319
287
|
} catch {
|
|
320
288
|
return null;
|
|
321
289
|
}
|
|
322
290
|
}
|
|
323
|
-
const
|
|
324
|
-
function
|
|
291
|
+
const nt = 900, Z = 600;
|
|
292
|
+
function Q(e, t) {
|
|
325
293
|
return e && e.startsWith("/") && !e.startsWith("//") && !e.startsWith("/\\") ? e : t;
|
|
326
294
|
}
|
|
327
|
-
function
|
|
295
|
+
function b(e, t = []) {
|
|
328
296
|
const n = new Headers({ location: e, "cache-control": "no-store" });
|
|
329
297
|
for (const s of t) n.append("set-cookie", s);
|
|
330
298
|
return new Response(null, { status: 302, headers: n });
|
|
331
299
|
}
|
|
332
|
-
const
|
|
333
|
-
function
|
|
334
|
-
const c = `<!doctype html><meta charset="utf-8"><title>Signing in</title><script type="application/json" id="pontive-popup">${JSON.stringify({ message: { type:
|
|
300
|
+
const rt = "pontive:popup-complete";
|
|
301
|
+
function st(e, t, n) {
|
|
302
|
+
const c = `<!doctype html><meta charset="utf-8"><title>Signing in</title><script type="application/json" id="pontive-popup">${JSON.stringify({ message: { type: rt, url: e }, origin: t }).replace(/</g, "\\u003c")}<\/script><script>(function(){var d=JSON.parse(document.getElementById("pontive-popup").textContent);var go=function(){window.location.replace(d.message.url)};if(window.opener&&window.opener!==window){try{window.opener.postMessage(d.message,d.origin)}catch(e){}window.close();setTimeout(go,1000)}else{go()}})()<\/script>`, a = new Headers({
|
|
335
303
|
"content-type": "text/html; charset=utf-8",
|
|
336
304
|
"cache-control": "no-store",
|
|
337
305
|
"content-security-policy": "default-src 'none'; script-src 'unsafe-inline'",
|
|
@@ -340,8 +308,8 @@ function it(e, t, n) {
|
|
|
340
308
|
for (const i of n) a.append("set-cookie", i);
|
|
341
309
|
return new Response(c, { status: 200, headers: a });
|
|
342
310
|
}
|
|
343
|
-
function
|
|
344
|
-
const t = $(), s = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Sign in</title><style>body{font-family:system-ui,sans-serif;margin:4rem auto;max-width:28rem;padding:0 1rem}</style><p>This preview signs in in a new window.</p><p><button id="go" type="button">Sign in</button></p><p id="status"></p><script type="application/json" id="pontive-preview-signin">${JSON.stringify({ ...e, type:
|
|
311
|
+
function ot(e) {
|
|
312
|
+
const t = $(), s = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Sign in</title><style>body{font-family:system-ui,sans-serif;margin:4rem auto;max-width:28rem;padding:0 1rem}</style><p>This preview signs in in a new window.</p><p><button id="go" type="button">Sign in</button></p><p id="status"></p><script type="application/json" id="pontive-preview-signin">${JSON.stringify({ ...e, type: Ye }).replace(/</g, "\\u003c")}<\/script><script nonce="${t}">(function(){var d=JSON.parse(document.getElementById("pontive-preview-signin").textContent);var s=document.getElementById("status");var w=null;window.addEventListener("message",function(e){if(!w||e.source!==w||e.origin!==d.authOrigin)return;var m=e.data;if(!m||m.type!==d.type||!m.response||typeof m.response!=="object")return;var u=new URL(d.callbackUrl);["code","state","iss","error","error_description","error_uri"].forEach(function(k){var v=m.response[k];if(typeof v==="string")u.searchParams.set(k,v)});try{w.close()}catch(x){}if(u.origin===location.origin)location.replace(u.toString())});document.getElementById("go").addEventListener("click",function(){w=window.open(d.popupUrl,"pontive_signin_popup","popup=yes,width=500,height=680");s.textContent=w?"Finish signing in in the new window.":"The sign-in window was blocked. Allow popups for this site and try again."})})()<\/script>`;
|
|
345
313
|
return new Response(s, {
|
|
346
314
|
status: 200,
|
|
347
315
|
headers: {
|
|
@@ -353,7 +321,7 @@ function at(e) {
|
|
|
353
321
|
}
|
|
354
322
|
});
|
|
355
323
|
}
|
|
356
|
-
function
|
|
324
|
+
function _(e, t) {
|
|
357
325
|
if (e.baseUrl) return e.baseUrl;
|
|
358
326
|
const n = t.headers.get("x-forwarded-host")?.split(",")[0]?.trim() || t.headers.get("host")?.trim();
|
|
359
327
|
if (n) {
|
|
@@ -365,7 +333,7 @@ function g(e, t) {
|
|
|
365
333
|
}
|
|
366
334
|
return new URL(t.url).origin;
|
|
367
335
|
}
|
|
368
|
-
function
|
|
336
|
+
function it(e) {
|
|
369
337
|
const t = (s) => typeof e[s] == "string" ? e[s] : void 0, n = t("name") ?? ([t("given_name"), t("family_name")].filter(Boolean).join(" ") || void 0) ?? t("email");
|
|
370
338
|
return {
|
|
371
339
|
id: e.sub ?? "",
|
|
@@ -376,55 +344,55 @@ function ct(e) {
|
|
|
376
344
|
emailVerified: e.email_verified === !0
|
|
377
345
|
};
|
|
378
346
|
}
|
|
379
|
-
function
|
|
380
|
-
return Date.now() + (e.expires_in ??
|
|
347
|
+
function q(e) {
|
|
348
|
+
return Date.now() + (e.expires_in ?? nt) * 1e3;
|
|
381
349
|
}
|
|
382
|
-
function
|
|
383
|
-
return e.mode === "browser" ?
|
|
350
|
+
function ae(e) {
|
|
351
|
+
return e.mode === "browser" ? We(e) : at(e);
|
|
384
352
|
}
|
|
385
|
-
function
|
|
386
|
-
const t = { issuer: e.issuer, clientId: e.clientId, clientSecret: e.clientSecret }, n = `${e.cookieName}_tx`, s = new
|
|
387
|
-
const h = new URL(e.signInPath,
|
|
353
|
+
function at(e) {
|
|
354
|
+
const t = { issuer: e.issuer, clientId: e.clientId, clientSecret: e.clientSecret }, n = `${e.cookieName}_tx`, s = new tt(), c = (r) => e.secureCookies ?? _(e, r).startsWith("https:"), a = (r) => e.iframeSafe === !0 || e.iframeSafe === "auto" && Be(new URL(_(e, r)).hostname), i = (r, o) => a(r) ? { maxAge: o, secure: !0, sameSite: "None" } : { maxAge: o, secure: c(r) }, l = (r) => e.previewCallback === "always" || e.previewCallback === "auto" && Qe(_(e, r)) !== null, d = (r) => `${_(e, r)}${e.basePath}/callback`, u = (r) => l(r) ? qe(e.issuer, _(e, r)) : e.redirectUri ?? d(r), p = (r, o) => {
|
|
355
|
+
const h = new URL(e.signInPath, _(e, r));
|
|
388
356
|
return o && h.searchParams.set("error", o), h.toString();
|
|
389
357
|
};
|
|
390
358
|
async function m(r) {
|
|
391
|
-
const o =
|
|
359
|
+
const o = Me(r, e.cookieName);
|
|
392
360
|
if (o === null) return null;
|
|
393
|
-
const h = await
|
|
361
|
+
const h = await Y(o, e.sessionSecret);
|
|
394
362
|
return h || e.logger.warn("[pontive] session cookie could not be read (sealed with another secret, or truncated)"), h;
|
|
395
363
|
}
|
|
396
|
-
async function
|
|
397
|
-
const f = await
|
|
398
|
-
return
|
|
364
|
+
async function S(r, o, h) {
|
|
365
|
+
const f = await X({ ...o }, e.sessionSecret, e.sessionMaxAgeSeconds);
|
|
366
|
+
return Ve(r, e.cookieName, f, i(h, e.sessionMaxAgeSeconds));
|
|
399
367
|
}
|
|
400
|
-
function
|
|
401
|
-
const { refreshToken: o, ...h } = r, f =
|
|
402
|
-
return { ...h, organization:
|
|
368
|
+
function P(r) {
|
|
369
|
+
const { refreshToken: o, ...h } = r, f = ze(r.accessToken);
|
|
370
|
+
return { ...h, organization: oe(f), claims: f };
|
|
403
371
|
}
|
|
404
372
|
async function R(r) {
|
|
405
373
|
const o = new URL(r.url), h = l(r), f = o.searchParams.get("popup") === "1";
|
|
406
374
|
if (h && !f) {
|
|
407
|
-
const
|
|
408
|
-
return o.searchParams.forEach((y,
|
|
409
|
-
popupUrl:
|
|
375
|
+
const v = new URL(`${e.basePath}/login`, _(e, r));
|
|
376
|
+
return o.searchParams.forEach((y, I) => v.searchParams.set(I, y)), v.searchParams.set("popup", "1"), ot({
|
|
377
|
+
popupUrl: v.toString(),
|
|
410
378
|
authOrigin: new URL(e.issuer).origin,
|
|
411
379
|
callbackUrl: d(r)
|
|
412
380
|
});
|
|
413
381
|
}
|
|
414
|
-
const
|
|
382
|
+
const k = {
|
|
415
383
|
state: $(),
|
|
416
384
|
verifier: $(),
|
|
417
385
|
nonce: $(),
|
|
418
|
-
returnTo:
|
|
386
|
+
returnTo: Q(o.searchParams.get("returnTo") ?? o.searchParams.get("next"), e.afterSignInPath),
|
|
419
387
|
popup: f,
|
|
420
388
|
redirectUri: u(r),
|
|
421
389
|
previewCallback: h
|
|
422
390
|
}, w = await Re(t, e.fetch, {
|
|
423
|
-
redirectUri:
|
|
391
|
+
redirectUri: k.redirectUri,
|
|
424
392
|
scopes: e.scopes,
|
|
425
|
-
state:
|
|
426
|
-
nonce:
|
|
427
|
-
codeChallenge: await Ue(
|
|
393
|
+
state: k.state,
|
|
394
|
+
nonce: k.nonce,
|
|
395
|
+
codeChallenge: await Ue(k.verifier),
|
|
428
396
|
prompt: e.prompt,
|
|
429
397
|
// The organization the app wants this sign-in to start in; the user is
|
|
430
398
|
// never asked to pick one.
|
|
@@ -432,81 +400,81 @@ function lt(e) {
|
|
|
432
400
|
// Pre-fills the sign-in page with the address the user is expected to
|
|
433
401
|
// sign in with — an accepted invitation sends its invitee here with it.
|
|
434
402
|
loginHint: o.searchParams.get("login_hint") ?? void 0
|
|
435
|
-
}),
|
|
436
|
-
return
|
|
403
|
+
}), E = await X({ ...k }, e.sessionSecret, Z);
|
|
404
|
+
return b(w, [C(n, E, i(r, Z))]);
|
|
437
405
|
}
|
|
438
|
-
async function
|
|
439
|
-
const o = new URL(r.url), h =
|
|
440
|
-
if (y) return
|
|
441
|
-
if (!w || !
|
|
442
|
-
return
|
|
443
|
-
const
|
|
444
|
-
if (w.previewCallback &&
|
|
445
|
-
return
|
|
406
|
+
async function A(r) {
|
|
407
|
+
const o = new URL(r.url), h = T(r.headers.get("cookie")), f = [C(n, "", i(r, 0))], k = h.get(n), w = k ? await Y(k, e.sessionSecret) : null, E = o.searchParams.get("code"), v = (g) => w?.popup && !w.previewCallback ? st(g, _(e, r), f) : b(g, f), y = o.searchParams.get("error");
|
|
408
|
+
if (y) return v(p(r, y));
|
|
409
|
+
if (!w || !E || o.searchParams.get("state") !== w.state)
|
|
410
|
+
return v(p(r, "invalid_state"));
|
|
411
|
+
const I = o.searchParams.get("iss");
|
|
412
|
+
if (w.previewCallback && I !== null && I !== e.issuer)
|
|
413
|
+
return v(p(r, "invalid_issuer"));
|
|
446
414
|
try {
|
|
447
|
-
const
|
|
448
|
-
code:
|
|
415
|
+
const g = await Ce(t, e.fetch, {
|
|
416
|
+
code: E,
|
|
449
417
|
codeVerifier: w.verifier,
|
|
450
418
|
// Exactly as the authorization request named it.
|
|
451
419
|
redirectUri: w.redirectUri ?? u(r)
|
|
452
420
|
});
|
|
453
|
-
if (!
|
|
454
|
-
const
|
|
455
|
-
user:
|
|
456
|
-
accessToken:
|
|
457
|
-
refreshToken:
|
|
458
|
-
expiresAt:
|
|
459
|
-
sessionId: typeof
|
|
421
|
+
if (!g.id_token) throw new Error("the token response carried no id_token; is the openid scope requested?");
|
|
422
|
+
const L = await Ae(t, e.fetch, g.id_token, w.nonce), de = {
|
|
423
|
+
user: it(L),
|
|
424
|
+
accessToken: g.access_token,
|
|
425
|
+
refreshToken: g.refresh_token,
|
|
426
|
+
expiresAt: q(g),
|
|
427
|
+
sessionId: typeof L.sid == "string" ? L.sid : void 0
|
|
460
428
|
};
|
|
461
|
-
f.push(...await
|
|
462
|
-
} catch (
|
|
463
|
-
return e.logger.warn("[pontive] sign-in failed:",
|
|
429
|
+
f.push(...await S(h, de, r));
|
|
430
|
+
} catch (g) {
|
|
431
|
+
return e.logger.warn("[pontive] sign-in failed:", g instanceof Error ? g.message : String(g)), v(p(r, "exchange_failed"));
|
|
464
432
|
}
|
|
465
|
-
return
|
|
433
|
+
return v(new URL(w.returnTo, _(e, r)).toString());
|
|
466
434
|
}
|
|
467
|
-
async function
|
|
468
|
-
const o =
|
|
469
|
-
let
|
|
435
|
+
async function N(r) {
|
|
436
|
+
const o = T(r.headers.get("cookie")), h = await m(o), f = G(o, e.cookieName, i(r, 0));
|
|
437
|
+
let k = p(r);
|
|
470
438
|
try {
|
|
471
|
-
|
|
439
|
+
k = await Ne(t, e.fetch, {
|
|
472
440
|
postLogoutRedirectUri: p(r),
|
|
473
441
|
sessionId: h?.sessionId
|
|
474
|
-
}) ??
|
|
442
|
+
}) ?? k;
|
|
475
443
|
} catch (w) {
|
|
476
444
|
e.logger.warn("[pontive] could not reach the issuer to end its session:", w instanceof Error ? w.message : String(w));
|
|
477
445
|
}
|
|
478
|
-
return
|
|
446
|
+
return b(k, f);
|
|
479
447
|
}
|
|
480
|
-
function
|
|
448
|
+
function z(r, o) {
|
|
481
449
|
return {
|
|
482
450
|
...r,
|
|
483
451
|
accessToken: o.access_token,
|
|
484
452
|
// A response without one means rotation is off: the token in hand is still current.
|
|
485
453
|
refreshToken: o.refresh_token ?? r.refreshToken,
|
|
486
|
-
expiresAt:
|
|
454
|
+
expiresAt: q(o)
|
|
487
455
|
};
|
|
488
456
|
}
|
|
489
|
-
async function
|
|
490
|
-
const o = new URL(r.url), h =
|
|
491
|
-
const
|
|
492
|
-
return y &&
|
|
493
|
-
},
|
|
494
|
-
if (!
|
|
495
|
-
if (!
|
|
496
|
-
let
|
|
457
|
+
async function pe(r) {
|
|
458
|
+
const o = new URL(r.url), h = T(r.headers.get("cookie")), f = Q(o.searchParams.get("returnTo"), e.afterSignInPath), k = o.searchParams.get("organization_id"), w = (y) => {
|
|
459
|
+
const I = new URL(f, _(e, r));
|
|
460
|
+
return y && I.searchParams.set(He, y), I.toString();
|
|
461
|
+
}, E = await m(h);
|
|
462
|
+
if (!E?.refreshToken) return b(p(r));
|
|
463
|
+
if (!k) return b(w("invalid_request"));
|
|
464
|
+
let v;
|
|
497
465
|
try {
|
|
498
|
-
|
|
466
|
+
v = await F(t, e.fetch, E.refreshToken, k);
|
|
499
467
|
} catch (y) {
|
|
500
|
-
return y instanceof
|
|
468
|
+
return y instanceof j && y.code === "invalid_request" ? b(w("not_a_member")) : (e.logger.warn("[pontive] organization switch failed:", y instanceof Error ? y.message : String(y)), b(w("switch_failed")));
|
|
501
469
|
}
|
|
502
|
-
return
|
|
470
|
+
return b(w(), await S(h, z(E, v), r));
|
|
503
471
|
}
|
|
504
|
-
async function
|
|
472
|
+
async function he(r) {
|
|
505
473
|
try {
|
|
506
|
-
const o = await
|
|
507
|
-
return
|
|
474
|
+
const o = await F(t, e.fetch, r.refreshToken);
|
|
475
|
+
return z(r, o);
|
|
508
476
|
} catch (o) {
|
|
509
|
-
if (o instanceof
|
|
477
|
+
if (o instanceof j && o.status >= 400 && o.status < 500)
|
|
510
478
|
return e.logger.warn("[pontive] refresh refused; signing out:", o.message), null;
|
|
511
479
|
throw o;
|
|
512
480
|
}
|
|
@@ -516,71 +484,71 @@ function lt(e) {
|
|
|
516
484
|
const { pathname: o } = new URL(r.url);
|
|
517
485
|
if (!o.startsWith(`${e.basePath}/`)) return null;
|
|
518
486
|
const h = o.slice(e.basePath.length + 1);
|
|
519
|
-
return h === "login" && r.method === "GET" ? R(r) : h === "callback" && r.method === "GET" ?
|
|
487
|
+
return h === "login" && r.method === "GET" ? R(r) : h === "callback" && r.method === "GET" ? A(r) : h === "logout" && (r.method === "GET" || r.method === "POST") ? N(r) : h === H && (r.method === "GET" || r.method === "POST") ? pe(r) : null;
|
|
520
488
|
},
|
|
521
489
|
async getSession(r) {
|
|
522
|
-
const o = await m(
|
|
490
|
+
const o = await m(T(r));
|
|
523
491
|
return o ? Date.now() >= o.expiresAt ? (e.logger.warn(
|
|
524
492
|
"[pontive] the session's access token has expired and getSession cannot refresh it. Run the SDK's middleware on this path so it refreshes before the request is handled."
|
|
525
|
-
), null) :
|
|
493
|
+
), null) : P(o) : null;
|
|
526
494
|
},
|
|
527
495
|
async refresh(r) {
|
|
528
|
-
const o =
|
|
529
|
-
session:
|
|
496
|
+
const o = T(r.headers.get("cookie")), h = (v) => ({
|
|
497
|
+
session: v,
|
|
530
498
|
setCookies: [],
|
|
531
499
|
cookieHeader: r.headers.get("cookie") ?? ""
|
|
532
500
|
}), f = await m(o);
|
|
533
501
|
if (!f) return h(null);
|
|
534
502
|
if (new URL(r.url).pathname.startsWith(`${e.basePath}/`))
|
|
535
|
-
return h(Date.now() < f.expiresAt ?
|
|
536
|
-
if (Date.now() < f.expiresAt - e.refreshSkewSeconds * 1e3) return h(
|
|
537
|
-
const
|
|
538
|
-
if (!f.refreshToken) return
|
|
503
|
+
return h(Date.now() < f.expiresAt ? P(f) : null);
|
|
504
|
+
if (Date.now() < f.expiresAt - e.refreshSkewSeconds * 1e3) return h(P(f));
|
|
505
|
+
const k = () => ({ session: null, setCookies: G(o, e.cookieName, i(r, 0)), cookieHeader: W(o) });
|
|
506
|
+
if (!f.refreshToken) return k();
|
|
539
507
|
let w;
|
|
540
508
|
try {
|
|
541
|
-
w = await s.run(f.refreshToken, () =>
|
|
542
|
-
} catch (
|
|
543
|
-
return e.logger.warn("[pontive] refresh failed, will retry:",
|
|
509
|
+
w = await s.run(f.refreshToken, () => he(f));
|
|
510
|
+
} catch (v) {
|
|
511
|
+
return e.logger.warn("[pontive] refresh failed, will retry:", v instanceof Error ? v.message : String(v)), h(Date.now() < f.expiresAt ? P(f) : null);
|
|
544
512
|
}
|
|
545
|
-
if (!w) return
|
|
546
|
-
const
|
|
547
|
-
return { session:
|
|
513
|
+
if (!w) return k();
|
|
514
|
+
const E = await S(o, w, r);
|
|
515
|
+
return { session: P(w), setCookies: E, cookieHeader: W(o) };
|
|
548
516
|
}
|
|
549
517
|
};
|
|
550
518
|
}
|
|
551
|
-
const
|
|
519
|
+
const ct = "1.24.0", lt = "claim";
|
|
552
520
|
function vt(e = {}, t = {}) {
|
|
553
|
-
const n =
|
|
554
|
-
if (
|
|
555
|
-
const c =
|
|
556
|
-
return
|
|
521
|
+
const n = fe(), s = we(e, n);
|
|
522
|
+
if (me(s, n)) return ut(s, t);
|
|
523
|
+
const c = se(s), a = ve(n) ? () => le(ce(t), c.issuer) : async () => null;
|
|
524
|
+
return ue(c, ae(c), a);
|
|
557
525
|
}
|
|
558
|
-
function
|
|
526
|
+
function ce(e) {
|
|
559
527
|
if (e.projectDir) return e.projectDir;
|
|
560
528
|
const t = globalThis.process;
|
|
561
|
-
if (typeof t?.cwd != "function") throw new
|
|
529
|
+
if (typeof t?.cwd != "function") throw new te("keyless mode needs a project directory (process.cwd)");
|
|
562
530
|
return t.cwd();
|
|
563
531
|
}
|
|
564
|
-
async function
|
|
532
|
+
async function le(e, t) {
|
|
565
533
|
try {
|
|
566
|
-
const n = await
|
|
534
|
+
const n = await Se(e);
|
|
567
535
|
return n?.claim_token && n.issuer.replace(/\/+$/, "") === t ? n : null;
|
|
568
536
|
} catch {
|
|
569
537
|
return null;
|
|
570
538
|
}
|
|
571
539
|
}
|
|
572
|
-
function
|
|
540
|
+
function O(e, t) {
|
|
573
541
|
return new Response(`${t}
|
|
574
542
|
`, { status: e, headers: { "content-type": "text/plain; charset=utf-8", "cache-control": "no-store" } });
|
|
575
543
|
}
|
|
576
|
-
function
|
|
577
|
-
const s = `${e.basePath}/${
|
|
544
|
+
function ue(e, t, n) {
|
|
545
|
+
const s = `${e.basePath}/${lt}`;
|
|
578
546
|
async function c(a) {
|
|
579
547
|
try {
|
|
580
|
-
const i = await
|
|
548
|
+
const i = await ke(a, { fetch: e.fetch });
|
|
581
549
|
return new Response(null, { status: 302, headers: { location: i.url, "cache-control": "no-store", "referrer-policy": "no-referrer" } });
|
|
582
550
|
} catch (i) {
|
|
583
|
-
return i instanceof
|
|
551
|
+
return i instanceof D && i.status === 409 ? O(409, "This Pontive instance has already been claimed. Nothing in your app changes; manage it in the Pontive dashboard.") : i instanceof D && i.status === 404 ? O(410, ne(a, "expired")) : (e.logger.warn("[pontive] could not create a claim link:", i instanceof Error ? i.message : String(i)), O(502, "Pontive could not create a claim link just now. Try again, or run `npx pontive claim`."));
|
|
584
552
|
}
|
|
585
553
|
}
|
|
586
554
|
return {
|
|
@@ -603,48 +571,48 @@ function fe(e, t, n) {
|
|
|
603
571
|
}
|
|
604
572
|
};
|
|
605
573
|
}
|
|
606
|
-
const
|
|
607
|
-
function
|
|
574
|
+
const M = /* @__PURE__ */ new Map(), ee = /* @__PURE__ */ new Set();
|
|
575
|
+
function ut(e, t) {
|
|
608
576
|
const n = e.logger ?? console;
|
|
609
577
|
let s, c, a = !1;
|
|
610
578
|
async function i() {
|
|
611
|
-
const u =
|
|
612
|
-
let m =
|
|
579
|
+
const u = ce(t), p = (e.basePath ?? "/api/auth").replace(/\/+$/, "");
|
|
580
|
+
let m = M.get(u);
|
|
613
581
|
m || (m = ye({
|
|
614
582
|
dir: u,
|
|
615
|
-
redirectUris: e.redirectUri ? [e.redirectUri] :
|
|
616
|
-
client: { name: t.clientName ?? "@pontive/server", version:
|
|
583
|
+
redirectUris: e.redirectUri ? [e.redirectUri] : ge(p),
|
|
584
|
+
client: { name: t.clientName ?? "@pontive/server", version: ct },
|
|
617
585
|
fetch: e.fetch
|
|
618
|
-
}),
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
${
|
|
586
|
+
}), M.set(u, m), m.catch(() => M.delete(u)));
|
|
587
|
+
const S = await m;
|
|
588
|
+
ee.has(u) || (ee.add(u), n.warn(`
|
|
589
|
+
${Ee(S.record, { created: S.created })}
|
|
622
590
|
`));
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
625
|
-
for (const [
|
|
626
|
-
|
|
627
|
-
if (!e.clientSecret && !
|
|
591
|
+
const P = globalThis.process;
|
|
592
|
+
if (P?.env)
|
|
593
|
+
for (const [A, N] of Object.entries(S.env))
|
|
594
|
+
N !== void 0 && !P.env[A] && (P.env[A] = N);
|
|
595
|
+
if (!e.clientSecret && !S.env.PONTIVE_CLIENT_SECRET)
|
|
628
596
|
throw new Error(
|
|
629
|
-
`@pontive/server: ${
|
|
597
|
+
`@pontive/server: ${_e} names ${S.record.instance_id}, but PONTIVE_CLIENT_SECRET is neither in ${Pe} nor in the environment. Put it back, or run \`npx pontive init --reset\`.`
|
|
630
598
|
);
|
|
631
|
-
const R =
|
|
599
|
+
const R = se({
|
|
632
600
|
...e,
|
|
633
|
-
issuer: e.issuer ||
|
|
634
|
-
clientId: e.clientId ||
|
|
635
|
-
clientSecret: e.clientSecret ||
|
|
636
|
-
sessionSecret: e.sessionSecret ||
|
|
637
|
-
fetch:
|
|
601
|
+
issuer: e.issuer || S.env.PONTIVE_ISSUER,
|
|
602
|
+
clientId: e.clientId || S.env.PONTIVE_CLIENT_ID,
|
|
603
|
+
clientSecret: e.clientSecret || S.env.PONTIVE_CLIENT_SECRET,
|
|
604
|
+
sessionSecret: e.sessionSecret || S.env.PONTIVE_SESSION_SECRET,
|
|
605
|
+
fetch: pt(e.fetch, S.record, n)
|
|
638
606
|
});
|
|
639
|
-
return
|
|
607
|
+
return ue(R, ae(R), () => le(u, R.issuer));
|
|
640
608
|
}
|
|
641
609
|
function l() {
|
|
642
610
|
return c ? Promise.reject(c) : (s ??= i().catch((u) => {
|
|
643
|
-
throw s = void 0, u instanceof
|
|
611
|
+
throw s = void 0, u instanceof be && (c = u), u;
|
|
644
612
|
}), s);
|
|
645
613
|
}
|
|
646
614
|
function d(u) {
|
|
647
|
-
return u instanceof
|
|
615
|
+
return u instanceof te ? (a || (a = !0, n.warn(
|
|
648
616
|
`[pontive] ${u.message}. Requests here proceed without a session until the dev server restarts with the PONTIVE_* variables keyless mode wrote to .env.local.`
|
|
649
617
|
)), !0) : !1;
|
|
650
618
|
}
|
|
@@ -653,7 +621,7 @@ ${_e(v.record, { created: v.created })}
|
|
|
653
621
|
try {
|
|
654
622
|
return await (await l()).handle(u);
|
|
655
623
|
} catch (p) {
|
|
656
|
-
if (d(p)) return
|
|
624
|
+
if (d(p)) return O(503, "Pontive keyless mode can't run in this runtime; restart the dev server.");
|
|
657
625
|
throw p;
|
|
658
626
|
}
|
|
659
627
|
},
|
|
@@ -678,23 +646,26 @@ ${_e(v.record, { created: v.created })}
|
|
|
678
646
|
}
|
|
679
647
|
};
|
|
680
648
|
}
|
|
681
|
-
function
|
|
649
|
+
function pt(e, t, n) {
|
|
682
650
|
const s = e ?? ((...a) => fetch(...a));
|
|
683
651
|
let c = !1;
|
|
684
652
|
return async (a, i) => {
|
|
685
653
|
const l = await s(a, i);
|
|
686
|
-
return l.status === 401 && !c && (typeof a == "string" ? a : a instanceof URL ? a.toString() : a.url).startsWith(t.issuer) && (c = !0, n.warn(`[pontive] ${
|
|
654
|
+
return l.status === 401 && !c && (typeof a == "string" ? a : a instanceof URL ? a.toString() : a.url).startsWith(t.issuer) && (c = !0, n.warn(`[pontive] ${ne(t, "refused")}`)), l;
|
|
687
655
|
};
|
|
688
656
|
}
|
|
689
657
|
export {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
658
|
+
De as ACCESS_COOKIE,
|
|
659
|
+
lt as CLAIM_ROUTE,
|
|
660
|
+
He as ORGANIZATION_ERROR_PARAM,
|
|
661
|
+
yt as PONTIVE_ENV,
|
|
662
|
+
ct as PONTIVE_SERVER_VERSION,
|
|
663
|
+
gt as Pontive,
|
|
664
|
+
Et as PontiveAPIError,
|
|
665
|
+
_t as PontiveConnectionError,
|
|
666
|
+
Fe as SESSION_HINT_COOKIE,
|
|
667
|
+
H as SWITCH_ORGANIZATION_ROUTE,
|
|
697
668
|
vt as createServerAuth,
|
|
698
|
-
|
|
669
|
+
mt as switchOrganizationPath
|
|
699
670
|
};
|
|
700
671
|
//# sourceMappingURL=index.js.map
|