module.exports = [ "[project]/Documents/00 - projet/plumeia/node_modules/@panva/hkdf/dist/node/esm/runtime/fallback.js [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "default", ()=>__TURBOPACK__default__export__ ]); var __TURBOPACK__imported__module__$5b$externals$5d2f$crypto__$5b$external$5d$__$28$crypto$2c$__cjs$29$__ = __turbopack_context__.i("[externals]/crypto [external] (crypto, cjs)"); ; const __TURBOPACK__default__export__ = (digest, ikm, salt, info, keylen)=>{ const hashlen = parseInt(digest.substr(3), 10) >> 3 || 20; const prk = (0, __TURBOPACK__imported__module__$5b$externals$5d2f$crypto__$5b$external$5d$__$28$crypto$2c$__cjs$29$__["createHmac"])(digest, salt.byteLength ? salt : new Uint8Array(hashlen)).update(ikm).digest(); const N = Math.ceil(keylen / hashlen); const T = new Uint8Array(hashlen * N + info.byteLength + 1); let prev = 0; let start = 0; for(let c = 1; c <= N; c++){ T.set(info, start); T[start + info.byteLength] = c; T.set((0, __TURBOPACK__imported__module__$5b$externals$5d2f$crypto__$5b$external$5d$__$28$crypto$2c$__cjs$29$__["createHmac"])(digest, prk).update(T.subarray(prev, start + info.byteLength + 1)).digest(), start); prev = start; start += hashlen; } return T.slice(0, keylen); }; }), "[project]/Documents/00 - projet/plumeia/node_modules/@panva/hkdf/dist/node/esm/runtime/hkdf.js [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "default", ()=>__TURBOPACK__default__export__ ]); var __TURBOPACK__imported__module__$5b$externals$5d2f$crypto__$5b$external$5d$__$28$crypto$2c$__cjs$29$__ = __turbopack_context__.i("[externals]/crypto [external] (crypto, cjs)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$panva$2f$hkdf$2f$dist$2f$node$2f$esm$2f$runtime$2f$fallback$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@panva/hkdf/dist/node/esm/runtime/fallback.js [app-route] (ecmascript)"); ; ; let hkdf; if (typeof __TURBOPACK__imported__module__$5b$externals$5d2f$crypto__$5b$external$5d$__$28$crypto$2c$__cjs$29$__["hkdf"] === 'function' && !process.versions.electron) { hkdf = async (...args)=>new Promise((resolve, reject)=>{ __TURBOPACK__imported__module__$5b$externals$5d2f$crypto__$5b$external$5d$__$28$crypto$2c$__cjs$29$__["hkdf"](...args, (err, arrayBuffer)=>{ if (err) reject(err); else resolve(new Uint8Array(arrayBuffer)); }); }); } const __TURBOPACK__default__export__ = async (digest, ikm, salt, info, keylen)=>(hkdf || __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$panva$2f$hkdf$2f$dist$2f$node$2f$esm$2f$runtime$2f$fallback$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["default"])(digest, ikm, salt, info, keylen); }), "[project]/Documents/00 - projet/plumeia/node_modules/@panva/hkdf/dist/node/esm/index.js [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "default", ()=>hkdf, "hkdf", ()=>hkdf ]); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$panva$2f$hkdf$2f$dist$2f$node$2f$esm$2f$runtime$2f$hkdf$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@panva/hkdf/dist/node/esm/runtime/hkdf.js [app-route] (ecmascript)"); ; function normalizeDigest(digest) { switch(digest){ case 'sha256': case 'sha384': case 'sha512': case 'sha1': return digest; default: throw new TypeError('unsupported "digest" value'); } } function normalizeUint8Array(input, label) { if (typeof input === 'string') return new TextEncoder().encode(input); if (!(input instanceof Uint8Array)) throw new TypeError(`"${label}"" must be an instance of Uint8Array or a string`); return input; } function normalizeIkm(input) { const ikm = normalizeUint8Array(input, 'ikm'); if (!ikm.byteLength) throw new TypeError(`"ikm" must be at least one byte in length`); return ikm; } function normalizeInfo(input) { const info = normalizeUint8Array(input, 'info'); if (info.byteLength > 1024) { throw TypeError('"info" must not contain more than 1024 bytes'); } return info; } function normalizeKeylen(input, digest) { if (typeof input !== 'number' || !Number.isInteger(input) || input < 1) { throw new TypeError('"keylen" must be a positive integer'); } const hashlen = parseInt(digest.substr(3), 10) >> 3 || 20; if (input > 255 * hashlen) { throw new TypeError('"keylen" too large'); } return input; } async function hkdf(digest, ikm, salt, info, keylen) { return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$panva$2f$hkdf$2f$dist$2f$node$2f$esm$2f$runtime$2f$hkdf$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["default"])(normalizeDigest(digest), normalizeIkm(ikm), normalizeUint8Array(salt, 'salt'), normalizeInfo(info), normalizeKeylen(keylen, digest)); } ; }), "[project]/Documents/00 - projet/plumeia/node_modules/preact/dist/preact.mjs [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "Component", ()=>k, "Fragment", ()=>b, "cloneElement", ()=>E, "createContext", ()=>G, "createElement", ()=>_, "createRef", ()=>m, "h", ()=>_, "hydrate", ()=>D, "isValidElement", ()=>t, "options", ()=>l, "render", ()=>B, "toChildArray", ()=>H ]); var n, l, u, t, i, o, r, f, e, c, s, a, h = {}, v = [], p = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, y = Array.isArray; function d(n, l) { for(var u in l)n[u] = l[u]; return n; } function w(n) { n && n.parentNode && n.parentNode.removeChild(n); } function _(l, u, t) { var i, o, r, f = {}; for(r in u)"key" == r ? i = u[r] : "ref" == r ? o = u[r] : f[r] = u[r]; if (arguments.length > 2 && (f.children = arguments.length > 3 ? n.call(arguments, 2) : t), "function" == typeof l && null != l.defaultProps) for(r in l.defaultProps)void 0 === f[r] && (f[r] = l.defaultProps[r]); return g(l, f, i, o, null); } function g(n, t, i, o, r) { var f = { type: n, props: t, key: i, ref: o, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: null == r ? ++u : r, __i: -1, __u: 0 }; return null == r && null != l.vnode && l.vnode(f), f; } function m() { return { current: null }; } function b(n) { return n.children; } function k(n, l) { this.props = n, this.context = l; } function x(n, l) { if (null == l) return n.__ ? x(n.__, n.__i + 1) : null; for(var u; l < n.__k.length; l++)if (null != (u = n.__k[l]) && null != u.__e) return u.__e; return "function" == typeof n.type ? x(n) : null; } function C(n) { var l, u; if (null != (n = n.__) && null != n.__c) { for(n.__e = n.__c.base = null, l = 0; l < n.__k.length; l++)if (null != (u = n.__k[l]) && null != u.__e) { n.__e = n.__c.base = u.__e; break; } return C(n); } } function S(n) { (!n.__d && (n.__d = !0) && i.push(n) && !M.__r++ || o !== l.debounceRendering) && ((o = l.debounceRendering) || r)(M); } function M() { var n, u, t, o, r, e, c, s; for(i.sort(f); n = i.shift();)n.__d && (u = i.length, o = void 0, e = (r = (t = n).__v).__e, c = [], s = [], t.__P && ((o = d({}, r)).__v = r.__v + 1, l.vnode && l.vnode(o), O(t.__P, o, r, t.__n, t.__P.namespaceURI, 32 & r.__u ? [ e ] : null, c, null == e ? x(r) : e, !!(32 & r.__u), s), o.__v = r.__v, o.__.__k[o.__i] = o, j(c, o, s), o.__e != e && C(o)), i.length > u && i.sort(f)); M.__r = 0; } function P(n, l, u, t, i, o, r, f, e, c, s) { var a, p, y, d, w, _ = t && t.__k || v, g = l.length; for(u.__d = e, $(u, l, _), e = u.__d, a = 0; a < g; a++)null != (y = u.__k[a]) && (p = -1 === y.__i ? h : _[y.__i] || h, y.__i = a, O(n, y, p, i, o, r, f, e, c, s), d = y.__e, y.ref && p.ref != y.ref && (p.ref && N(p.ref, null, y), s.push(y.ref, y.__c || d, y)), null == w && null != d && (w = d), 65536 & y.__u || p.__k === y.__k ? e = I(y, e, n) : "function" == typeof y.type && void 0 !== y.__d ? e = y.__d : d && (e = d.nextSibling), y.__d = void 0, y.__u &= -196609); u.__d = e, u.__e = w; } function $(n, l, u) { var t, i, o, r, f, e = l.length, c = u.length, s = c, a = 0; for(n.__k = [], t = 0; t < e; t++)null != (i = l[t]) && "boolean" != typeof i && "function" != typeof i ? (r = t + a, (i = n.__k[t] = "string" == typeof i || "number" == typeof i || "bigint" == typeof i || i.constructor == String ? g(null, i, null, null, null) : y(i) ? g(b, { children: i }, null, null, null) : void 0 === i.constructor && i.__b > 0 ? g(i.type, i.props, i.key, i.ref ? i.ref : null, i.__v) : i).__ = n, i.__b = n.__b + 1, o = null, -1 !== (f = i.__i = L(i, u, r, s)) && (s--, (o = u[f]) && (o.__u |= 131072)), null == o || null === o.__v ? (-1 == f && a--, "function" != typeof i.type && (i.__u |= 65536)) : f !== r && (f == r - 1 ? a-- : f == r + 1 ? a++ : (f > r ? a-- : a++, i.__u |= 65536))) : i = n.__k[t] = null; if (s) for(t = 0; t < c; t++)null != (o = u[t]) && 0 == (131072 & o.__u) && (o.__e == n.__d && (n.__d = x(o)), V(o, o)); } function I(n, l, u) { var t, i; if ("function" == typeof n.type) { for(t = n.__k, i = 0; t && i < t.length; i++)t[i] && (t[i].__ = n, l = I(t[i], l, u)); return l; } n.__e != l && (l && n.type && !u.contains(l) && (l = x(n)), u.insertBefore(n.__e, l || null), l = n.__e); do { l = l && l.nextSibling; }while (null != l && 8 === l.nodeType) return l; } function H(n, l) { return l = l || [], null == n || "boolean" == typeof n || (y(n) ? n.some(function(n) { H(n, l); }) : l.push(n)), l; } function L(n, l, u, t) { var i = n.key, o = n.type, r = u - 1, f = u + 1, e = l[u]; if (null === e || e && i == e.key && o === e.type && 0 == (131072 & e.__u)) return u; if (t > (null != e && 0 == (131072 & e.__u) ? 1 : 0)) for(; r >= 0 || f < l.length;){ if (r >= 0) { if ((e = l[r]) && 0 == (131072 & e.__u) && i == e.key && o === e.type) return r; r--; } if (f < l.length) { if ((e = l[f]) && 0 == (131072 & e.__u) && i == e.key && o === e.type) return f; f++; } } return -1; } function T(n, l, u) { "-" === l[0] ? n.setProperty(l, null == u ? "" : u) : n[l] = null == u ? "" : "number" != typeof u || p.test(l) ? u : u + "px"; } function A(n, l, u, t, i) { var o; n: if ("style" === l) if ("string" == typeof u) n.style.cssText = u; else { if ("string" == typeof t && (n.style.cssText = t = ""), t) for(l in t)u && l in u || T(n.style, l, ""); if (u) for(l in u)t && u[l] === t[l] || T(n.style, l, u[l]); } else if ("o" === l[0] && "n" === l[1]) o = l !== (l = l.replace(/(PointerCapture)$|Capture$/i, "$1")), l = l.toLowerCase() in n || "onFocusOut" === l || "onFocusIn" === l ? l.toLowerCase().slice(2) : l.slice(2), n.l || (n.l = {}), n.l[l + o] = u, u ? t ? u.u = t.u : (u.u = e, n.addEventListener(l, o ? s : c, o)) : n.removeEventListener(l, o ? s : c, o); else { if ("http://www.w3.org/2000/svg" == i) l = l.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s"); else if ("width" != l && "height" != l && "href" != l && "list" != l && "form" != l && "tabIndex" != l && "download" != l && "rowSpan" != l && "colSpan" != l && "role" != l && "popover" != l && l in n) try { n[l] = null == u ? "" : u; break n; } catch (n) {} "function" == typeof u || (null == u || !1 === u && "-" !== l[4] ? n.removeAttribute(l) : n.setAttribute(l, "popover" == l && 1 == u ? "" : u)); } } function F(n) { return function(u) { if (this.l) { var t = this.l[u.type + n]; if (null == u.t) u.t = e++; else if (u.t < t.u) return; return t(l.event ? l.event(u) : u); } }; } function O(n, u, t, i, o, r, f, e, c, s) { var a, h, v, p, w, _, g, m, x, C, S, M, $, I, H, L, T = u.type; if (void 0 !== u.constructor) return null; 128 & t.__u && (c = !!(32 & t.__u), r = [ e = u.__e = t.__e ]), (a = l.__b) && a(u); n: if ("function" == typeof T) try { if (m = u.props, x = "prototype" in T && T.prototype.render, C = (a = T.contextType) && i[a.__c], S = a ? C ? C.props.value : a.__ : i, t.__c ? g = (h = u.__c = t.__c).__ = h.__E : (x ? u.__c = h = new T(m, S) : (u.__c = h = new k(m, S), h.constructor = T, h.render = q), C && C.sub(h), h.props = m, h.state || (h.state = {}), h.context = S, h.__n = i, v = h.__d = !0, h.__h = [], h._sb = []), x && null == h.__s && (h.__s = h.state), x && null != T.getDerivedStateFromProps && (h.__s == h.state && (h.__s = d({}, h.__s)), d(h.__s, T.getDerivedStateFromProps(m, h.__s))), p = h.props, w = h.state, h.__v = u, v) x && null == T.getDerivedStateFromProps && null != h.componentWillMount && h.componentWillMount(), x && null != h.componentDidMount && h.__h.push(h.componentDidMount); else { if (x && null == T.getDerivedStateFromProps && m !== p && null != h.componentWillReceiveProps && h.componentWillReceiveProps(m, S), !h.__e && (null != h.shouldComponentUpdate && !1 === h.shouldComponentUpdate(m, h.__s, S) || u.__v === t.__v)) { for(u.__v !== t.__v && (h.props = m, h.state = h.__s, h.__d = !1), u.__e = t.__e, u.__k = t.__k, u.__k.some(function(n) { n && (n.__ = u); }), M = 0; M < h._sb.length; M++)h.__h.push(h._sb[M]); h._sb = [], h.__h.length && f.push(h); break n; } null != h.componentWillUpdate && h.componentWillUpdate(m, h.__s, S), x && null != h.componentDidUpdate && h.__h.push(function() { h.componentDidUpdate(p, w, _); }); } if (h.context = S, h.props = m, h.__P = n, h.__e = !1, $ = l.__r, I = 0, x) { for(h.state = h.__s, h.__d = !1, $ && $(u), a = h.render(h.props, h.state, h.context), H = 0; H < h._sb.length; H++)h.__h.push(h._sb[H]); h._sb = []; } else do { h.__d = !1, $ && $(u), a = h.render(h.props, h.state, h.context), h.state = h.__s; }while (h.__d && ++I < 25) h.state = h.__s, null != h.getChildContext && (i = d(d({}, i), h.getChildContext())), x && !v && null != h.getSnapshotBeforeUpdate && (_ = h.getSnapshotBeforeUpdate(p, w)), P(n, y(L = null != a && a.type === b && null == a.key ? a.props.children : a) ? L : [ L ], u, t, i, o, r, f, e, c, s), h.base = u.__e, u.__u &= -161, h.__h.length && f.push(h), g && (h.__E = h.__ = null); } catch (n) { if (u.__v = null, c || null != r) { for(u.__u |= c ? 160 : 128; e && 8 === e.nodeType && e.nextSibling;)e = e.nextSibling; r[r.indexOf(e)] = null, u.__e = e; } else u.__e = t.__e, u.__k = t.__k; l.__e(n, u, t); } else null == r && u.__v === t.__v ? (u.__k = t.__k, u.__e = t.__e) : u.__e = z(t.__e, u, t, i, o, r, f, c, s); (a = l.diffed) && a(u); } function j(n, u, t) { u.__d = void 0; for(var i = 0; i < t.length; i++)N(t[i], t[++i], t[++i]); l.__c && l.__c(u, n), n.some(function(u) { try { n = u.__h, u.__h = [], n.some(function(n) { n.call(u); }); } catch (n) { l.__e(n, u.__v); } }); } function z(u, t, i, o, r, f, e, c, s) { var a, v, p, d, _, g, m, b = i.props, k = t.props, C = t.type; if ("svg" === C ? r = "http://www.w3.org/2000/svg" : "math" === C ? r = "http://www.w3.org/1998/Math/MathML" : r || (r = "http://www.w3.org/1999/xhtml"), null != f) { for(a = 0; a < f.length; a++)if ((_ = f[a]) && "setAttribute" in _ == !!C && (C ? _.localName === C : 3 === _.nodeType)) { u = _, f[a] = null; break; } } if (null == u) { if (null === C) return document.createTextNode(k); u = document.createElementNS(r, C, k.is && k), c && (l.__m && l.__m(t, f), c = !1), f = null; } if (null === C) b === k || c && u.data === k || (u.data = k); else { if (f = f && n.call(u.childNodes), b = i.props || h, !c && null != f) for(b = {}, a = 0; a < u.attributes.length; a++)b[(_ = u.attributes[a]).name] = _.value; for(a in b)if (_ = b[a], "children" == a) ; else if ("dangerouslySetInnerHTML" == a) p = _; else if (!(a in k)) { if ("value" == a && "defaultValue" in k || "checked" == a && "defaultChecked" in k) continue; A(u, a, null, _, r); } for(a in k)_ = k[a], "children" == a ? d = _ : "dangerouslySetInnerHTML" == a ? v = _ : "value" == a ? g = _ : "checked" == a ? m = _ : c && "function" != typeof _ || b[a] === _ || A(u, a, _, b[a], r); if (v) c || p && (v.__html === p.__html || v.__html === u.innerHTML) || (u.innerHTML = v.__html), t.__k = []; else if (p && (u.innerHTML = ""), P(u, y(d) ? d : [ d ], t, i, o, "foreignObject" === C ? "http://www.w3.org/1999/xhtml" : r, f, e, f ? f[0] : i.__k && x(i, 0), c, s), null != f) for(a = f.length; a--;)w(f[a]); c || (a = "value", "progress" === C && null == g ? u.removeAttribute("value") : void 0 !== g && (g !== u[a] || "progress" === C && !g || "option" === C && g !== b[a]) && A(u, a, g, b[a], r), a = "checked", void 0 !== m && m !== u[a] && A(u, a, m, b[a], r)); } return u; } function N(n, u, t) { try { if ("function" == typeof n) { var i = "function" == typeof n.__u; i && n.__u(), i && null == u || (n.__u = n(u)); } else n.current = u; } catch (n) { l.__e(n, t); } } function V(n, u, t) { var i, o; if (l.unmount && l.unmount(n), (i = n.ref) && (i.current && i.current !== n.__e || N(i, null, u)), null != (i = n.__c)) { if (i.componentWillUnmount) try { i.componentWillUnmount(); } catch (n) { l.__e(n, u); } i.base = i.__P = null; } if (i = n.__k) for(o = 0; o < i.length; o++)i[o] && V(i[o], u, t || "function" != typeof n.type); t || w(n.__e), n.__c = n.__ = n.__e = n.__d = void 0; } function q(n, l, u) { return this.constructor(n, u); } function B(u, t, i) { var o, r, f, e; l.__ && l.__(u, t), r = (o = "function" == typeof i) ? null : i && i.__k || t.__k, f = [], e = [], O(t, u = (!o && i || t).__k = _(b, null, [ u ]), r || h, h, t.namespaceURI, !o && i ? [ i ] : r ? null : t.firstChild ? n.call(t.childNodes) : null, f, !o && i ? i : r ? r.__e : t.firstChild, o, e), j(f, u, e); } function D(n, l) { B(n, l, D); } function E(l, u, t) { var i, o, r, f, e = d({}, l.props); for(r in l.type && l.type.defaultProps && (f = l.type.defaultProps), u)"key" == r ? i = u[r] : "ref" == r ? o = u[r] : e[r] = void 0 === u[r] && void 0 !== f ? f[r] : u[r]; return arguments.length > 2 && (e.children = arguments.length > 3 ? n.call(arguments, 2) : t), g(l.type, e, i || l.key, o || l.ref, null); } function G(n, l) { var u = { __c: l = "__cC" + a++, __: n, Consumer: function(n, l) { return n.children(l); }, Provider: function(n) { var u, t; return this.getChildContext || (u = new Set, (t = {})[l] = this, this.getChildContext = function() { return t; }, this.componentWillUnmount = function() { u = null; }, this.shouldComponentUpdate = function(n) { this.props.value !== n.value && u.forEach(function(n) { n.__e = !0, S(n); }); }, this.sub = function(n) { u.add(n); var l = n.componentWillUnmount; n.componentWillUnmount = function() { u && u.delete(n), l && l.call(n); }; }), n.children; } }; return u.Provider.__ = u.Consumer.contextType = u; } n = v.slice, l = { __e: function(n, l, u, t) { for(var i, o, r; l = l.__;)if ((i = l.__c) && !i.__) try { if ((o = i.constructor) && null != o.getDerivedStateFromError && (i.setState(o.getDerivedStateFromError(n)), r = i.__d), null != i.componentDidCatch && (i.componentDidCatch(n, t || {}), r = i.__d), r) return i.__E = i; } catch (l) { n = l; } throw n; } }, u = 0, t = function(n) { return null != n && null == n.constructor; }, k.prototype.setState = function(n, l) { var u; u = null != this.__s && this.__s !== this.state ? this.__s : this.__s = d({}, this.state), "function" == typeof n && (n = n(d({}, u), this.props)), n && d(u, n), null != n && this.__v && (l && this._sb.push(l), S(this)); }, k.prototype.forceUpdate = function(n) { this.__v && (this.__e = !0, n && this.__h.push(n), S(this)); }, k.prototype.render = b, i = [], r = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, f = function(n, l) { return n.__v.__b - l.__v.__b; }, M.__r = 0, e = 0, c = F(!1), s = F(!0), a = 0; ; //# sourceMappingURL=preact.module.js.map }), "[project]/Documents/00 - projet/plumeia/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs [app-route] (ecmascript) ", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "jsx", ()=>u, "jsxAttr", ()=>p, "jsxDEV", ()=>u, "jsxEscape", ()=>_, "jsxTemplate", ()=>a, "jsxs", ()=>u ]); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/preact/dist/preact.mjs [app-route] (ecmascript)"); ; ; var t = /["&<]/; function n(r) { if (0 === r.length || !1 === t.test(r)) return r; for(var e = 0, n = 0, o = "", f = ""; n < r.length; n++){ switch(r.charCodeAt(n)){ case 34: f = """; break; case 38: f = "&"; break; case 60: f = "<"; break; default: continue; } n !== e && (o += r.slice(e, n)), o += f, e = n + 1; } return n !== e && (o += r.slice(e, n)), o; } var o = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, f = 0, i = Array.isArray; function u(e, t, n, o, i, u) { t || (t = {}); var a, c, l = t; "ref" in t && (a = t.ref, delete t.ref); var p = { type: e, props: l, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --f, __i: -1, __u: 0, __source: i, __self: u }; if ("function" == typeof e && (a = e.defaultProps)) for(c in a)void 0 === l[c] && (l[c] = a[c]); return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].vnode && __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].vnode(p), p; } function a(r) { var t = u(__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Fragment"], { tpl: r, exprs: [].slice.call(arguments, 1) }); return t.key = t.__v, t; } var c = {}, l = /[A-Z]/g; function p(e, t) { if (__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].attr) { var f = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].attr(e, t); if ("string" == typeof f) return f; } if ("ref" === e || "key" === e) return ""; if ("style" === e && "object" == typeof t) { var i = ""; for(var u in t){ var a = t[u]; if (null != a && "" !== a) { var p = "-" == u[0] ? u : c[u] || (c[u] = u.replace(l, "-$&").toLowerCase()), _ = ";"; "number" != typeof a || p.startsWith("--") || o.test(p) || (_ = "px;"), i = i + p + ":" + a + _; } } return e + '="' + i + '"'; } return null == t || !1 === t || "function" == typeof t || "object" == typeof t ? "" : !0 === t ? e : e + '="' + n(t) + '"'; } function _(r) { if (null == r || "boolean" == typeof r || "function" == typeof r) return null; if ("object" == typeof r) { if (void 0 === r.constructor) return r; if (i(r)) { for(var e = 0; e < r.length; e++)r[e] = _(r[e]); return r; } } return n("" + r); } ; //# sourceMappingURL=jsxRuntime.module.js.map }), "[project]/Documents/00 - projet/plumeia/node_modules/preact-render-to-string/dist/index.mjs [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "default", ()=>__TURBOPACK__default__export__, "render", ()=>F, "renderToStaticMarkup", ()=>M, "renderToString", ()=>D, "renderToStringAsync", ()=>S ]); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/preact/dist/preact.mjs [app-route] (ecmascript)"); ; var r = /[\s\n\\/='"\0<>]/, o = /^(xlink|xmlns|xml)([A-Z])/, i = /^accessK|^auto[A-Z]|^cell|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|popoverT|readO|rowS|src[A-Z]|tabI|useM|item[A-Z]/, a = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/, c = new Set([ "draggable", "spellcheck" ]), s = /["&<]/; function l(e) { if (0 === e.length || !1 === s.test(e)) return e; for(var t = 0, n = 0, r = "", o = ""; n < e.length; n++){ switch(e.charCodeAt(n)){ case 34: o = """; break; case 38: o = "&"; break; case 60: o = "<"; break; default: continue; } n !== t && (r += e.slice(t, n)), r += o, t = n + 1; } return n !== t && (r += e.slice(t, n)), r; } var u = {}, f = new Set([ "animation-iteration-count", "border-image-outset", "border-image-slice", "border-image-width", "box-flex", "box-flex-group", "box-ordinal-group", "column-count", "fill-opacity", "flex", "flex-grow", "flex-negative", "flex-order", "flex-positive", "flex-shrink", "flood-opacity", "font-weight", "grid-column", "grid-row", "line-clamp", "line-height", "opacity", "order", "orphans", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-miterlimit", "stroke-opacity", "stroke-width", "tab-size", "widows", "z-index", "zoom" ]), p = /[A-Z]/g; function h(e) { var t = ""; for(var n in e){ var r = e[n]; if (null != r && "" !== r) { var o = "-" == n[0] ? n : u[n] || (u[n] = n.replace(p, "-$&").toLowerCase()), i = ";"; "number" != typeof r || o.startsWith("--") || f.has(o) || (i = "px;"), t = t + o + ":" + r + i; } } return t || void 0; } function d() { this.__d = !0; } function _(e, t) { return { __v: e, context: t, props: e.props, setState: d, forceUpdate: d, __d: !0, __h: new Array(0) }; } function v(e, t, n) { if (!e.s) { if (n instanceof m) { if (!n.s) return void (n.o = v.bind(null, e, t)); 1 & t && (t = n.s), n = n.v; } if (n && n.then) return void n.then(v.bind(null, e, t), v.bind(null, e, 2)); e.s = t, e.v = n; const r = e.o; r && r(e); } } var m = /*#__PURE__*/ function() { function e() {} return e.prototype.then = function(t, n) { var r = new e, o = this.s; if (o) { var i = 1 & o ? t : n; if (i) { try { v(r, 1, i(this.v)); } catch (e) { v(r, 2, e); } return r; } return this; } return this.o = function(e) { try { var o = e.v; 1 & e.s ? v(r, 1, t ? t(o) : o) : n ? v(r, 1, n(o)) : v(r, 2, o); } catch (e) { v(r, 2, e); } }, r; }, e; }(); function y(e) { return e instanceof m && 1 & e.s; } function g(e, t, n) { for(var r;;){ var o = e(); if (y(o) && (o = o.v), !o) return i; if (o.then) { r = 0; break; } var i = n(); if (i && i.then) { if (!y(i)) { r = 1; break; } i = i.s; } if (t) { var a = t(); if (a && a.then && !y(a)) { r = 2; break; } } } var c = new m, s = v.bind(null, c, 2); return (0 === r ? o.then(u) : 1 === r ? i.then(l) : a.then(f)).then(void 0, s), c; //TURBOPACK unreachable ; function l(r) { i = r; do { if (t && (a = t()) && a.then && !y(a)) return void a.then(f).then(void 0, s); if (!(o = e()) || y(o) && !o.v) return void v(c, 1, i); if (o.then) return void o.then(u).then(void 0, s); y(i = n()) && (i = i.v); }while (!i || !i.then) i.then(l).then(void 0, s); } function u(e) { e ? (i = n()) && i.then ? i.then(l).then(void 0, s) : l(i) : v(c, 1, i); } function f() { (o = e()) ? o.then ? o.then(u).then(void 0, s) : u(o) : v(c, 1, i); } } function b(e, t) { try { var n = e(); } catch (e) { return t(!0, e); } return n && n.then ? n.then(t.bind(null, !1), t.bind(null, !0)) : t(!1, n); } var k, w, x, C, S = function(r, o) { try { var i = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__s; __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__s = !0, k = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__b, w = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].diffed, x = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__r, C = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].unmount; var a = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["h"])(__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Fragment"], null); return a.__k = [ r ], Promise.resolve(b(function() { return Promise.resolve(U(r, o || A, !1, void 0, a, !0, void 0)).then(function(e) { var t, n = function() { if (E(e)) { var n = function() { var e = o.join(j); return t = 1, e; }, r = 0, o = e, i = g(function() { return !!o.some(function(e) { return e && "function" == typeof e.then; }) && r++ < 25; }, void 0, function() { return Promise.resolve(Promise.all(o)).then(function(e) { o = e.flat(); }); }); return i && i.then ? i.then(n) : n(); } }(); return n && n.then ? n.then(function(n) { return t ? n : e; }) : t ? n : e; }); }, function(t, n) { if (__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__c && __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__c(r, L), __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__s = i, L.length = 0, t) throw n; return n; })); } catch (e) { return Promise.reject(e); } }, A = {}, L = [], E = Array.isArray, T = Object.assign, j = ""; function D(r, o, i) { var a = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__s; __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__s = !0, k = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__b, w = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].diffed, x = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__r, C = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].unmount; var c = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["h"])(__TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Fragment"], null); c.__k = [ r ]; try { var s = U(r, o || A, !1, void 0, c, !1, i); return E(s) ? s.join(j) : s; } catch (e) { if (e.then) throw new Error('Use "renderToStringAsync" for suspenseful rendering.'); throw e; } finally{ __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__c && __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__c(r, L), __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__s = a, L.length = 0; } } function P(e, t) { var n, r = e.type, o = !0; return e.__c ? (o = !1, (n = e.__c).state = n.__s) : n = new r(e.props, t), e.__c = n, n.__v = e, n.props = e.props, n.context = t, n.__d = !0, null == n.state && (n.state = A), null == n.__s && (n.__s = n.state), r.getDerivedStateFromProps ? n.state = T({}, n.state, r.getDerivedStateFromProps(n.props, n.state)) : o && n.componentWillMount ? (n.componentWillMount(), n.state = n.__s !== n.state ? n.__s : n.state) : !o && n.componentWillUpdate && n.componentWillUpdate(), x && x(e), n.render(n.props, n.state, t); } function U(t, s, u, f, p, d, v) { if (null == t || !0 === t || !1 === t || t === j) return j; var m = typeof t; if ("object" != m) return "function" == m ? j : "string" == m ? l(t) : t + j; if (E(t)) { var y, g = j; p.__k = t; for(var b = 0; b < t.length; b++){ var S = t[b]; if (null != S && "boolean" != typeof S) { var L, D = U(S, s, u, f, p, d, v); "string" == typeof D ? g += D : (y || (y = []), g && y.push(g), g = j, E(D) ? (L = y).push.apply(L, D) : y.push(D)); } } return y ? (g && y.push(g), y) : g; } if (void 0 !== t.constructor) return j; t.__ = p, k && k(t); var F = t.type, M = t.props; if ("function" == typeof F) { var W, $, z, H = s; if (F === __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Fragment"]) { if ("tpl" in M) { for(var N = j, q = 0; q < M.tpl.length; q++)if (N += M.tpl[q], M.exprs && q < M.exprs.length) { var B = M.exprs[q]; if (null == B) continue; "object" != typeof B || void 0 !== B.constructor && !E(B) ? N += B : N += U(B, s, u, f, t, d, v); } return N; } if ("UNSTABLE_comment" in M) return "\x3c!--" + l(M.UNSTABLE_comment) + "--\x3e"; $ = M.children; } else { if (null != (W = F.contextType)) { var I = s[W.__c]; H = I ? I.props.value : W.__; } var O = F.prototype && "function" == typeof F.prototype.render; if (O) $ = P(t, H), z = t.__c; else { t.__c = z = _(t, H); for(var R = 0; z.__d && R++ < 25;)z.__d = !1, x && x(t), $ = F.call(z, M, H); z.__d = !0; } if (null != z.getChildContext && (s = T({}, s, z.getChildContext())), O && __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].errorBoundaries && (F.getDerivedStateFromError || z.componentDidCatch)) { $ = null != $ && $.type === __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Fragment"] && null == $.key && null == $.props.tpl ? $.props.children : $; try { return U($, s, u, f, t, d, v); } catch (e) { return F.getDerivedStateFromError && (z.__s = F.getDerivedStateFromError(e)), z.componentDidCatch && z.componentDidCatch(e, A), z.__d ? ($ = P(t, s), null != (z = t.__c).getChildContext && (s = T({}, s, z.getChildContext())), U($ = null != $ && $.type === __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Fragment"] && null == $.key && null == $.props.tpl ? $.props.children : $, s, u, f, t, d, v)) : j; } finally{ w && w(t), t.__ = null, C && C(t); } } } $ = null != $ && $.type === __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Fragment"] && null == $.key && null == $.props.tpl ? $.props.children : $; try { var V = U($, s, u, f, t, d, v); return w && w(t), t.__ = null, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].unmount && __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].unmount(t), V; } catch (n) { if (!d && v && v.onError) { var K = v.onError(n, t, function(e) { return U(e, s, u, f, t, d, v); }); if (void 0 !== K) return K; var G = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$preact$2f$dist$2f$preact$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["options"].__e; return G && G(n, t), j; } if (!d) throw n; if (!n || "function" != typeof n.then) throw n; return n.then(function e() { try { return U($, s, u, f, t, d, v); } catch (n) { if (!n || "function" != typeof n.then) throw n; return n.then(function() { return U($, s, u, f, t, d, v); }, e); } }); } } var J, Q = "<" + F, X = j; for(var Y in M){ var ee = M[Y]; if ("function" != typeof ee || "class" === Y || "className" === Y) { switch(Y){ case "children": J = ee; continue; case "key": case "ref": case "__self": case "__source": continue; case "htmlFor": if ("for" in M) continue; Y = "for"; break; case "className": if ("class" in M) continue; Y = "class"; break; case "defaultChecked": Y = "checked"; break; case "defaultSelected": Y = "selected"; break; case "defaultValue": case "value": switch(Y = "value", F){ case "textarea": J = ee; continue; case "select": f = ee; continue; case "option": f != ee || "selected" in M || (Q += " selected"); } break; case "dangerouslySetInnerHTML": X = ee && ee.__html; continue; case "style": "object" == typeof ee && (ee = h(ee)); break; case "acceptCharset": Y = "accept-charset"; break; case "httpEquiv": Y = "http-equiv"; break; default: if (o.test(Y)) Y = Y.replace(o, "$1:$2").toLowerCase(); else { if (r.test(Y)) continue; "-" !== Y[4] && !c.has(Y) || null == ee ? u ? a.test(Y) && (Y = "panose1" === Y ? "panose-1" : Y.replace(/([A-Z])/g, "-$1").toLowerCase()) : i.test(Y) && (Y = Y.toLowerCase()) : ee += j; } } null != ee && !1 !== ee && (Q = !0 === ee || ee === j ? Q + " " + Y : Q + " " + Y + '="' + ("string" == typeof ee ? l(ee) : ee + j) + '"'); } } if (r.test(F)) throw new Error(F + " is not a valid HTML tag name in " + Q + ">"); if (X || ("string" == typeof J ? X = l(J) : null != J && !1 !== J && !0 !== J && (X = U(J, s, "svg" === F || "foreignObject" !== F && u, f, t, d, v))), w && w(t), t.__ = null, C && C(t), !X && Z.has(F)) return Q + "/>"; var te = "", ne = Q + ">"; return E(X) ? [ ne ].concat(X, [ te ]) : "string" != typeof X ? [ ne, X, te ] : ne + X + te; } var Z = new Set([ "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr" ]), F = D, M = D; const __TURBOPACK__default__export__ = D; ; //# sourceMappingURL=index.module.js.map }), "[project]/Documents/00 - projet/plumeia/node_modules/oauth4webapi/build/index.js [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "AUTHORIZATION_RESPONSE_ERROR", ()=>AUTHORIZATION_RESPONSE_ERROR, "AuthorizationResponseError", ()=>AuthorizationResponseError, "ClientSecretBasic", ()=>ClientSecretBasic, "ClientSecretJwt", ()=>ClientSecretJwt, "ClientSecretPost", ()=>ClientSecretPost, "DPoP", ()=>DPoP, "HTTP_REQUEST_FORBIDDEN", ()=>HTTP_REQUEST_FORBIDDEN, "INVALID_REQUEST", ()=>INVALID_REQUEST, "INVALID_RESPONSE", ()=>INVALID_RESPONSE, "INVALID_SERVER_METADATA", ()=>INVALID_SERVER_METADATA, "JSON_ATTRIBUTE_COMPARISON", ()=>JSON_ATTRIBUTE_COMPARISON, "JWT_CLAIM_COMPARISON", ()=>JWT_CLAIM_COMPARISON, "JWT_TIMESTAMP_CHECK", ()=>JWT_TIMESTAMP_CHECK, "JWT_USERINFO_EXPECTED", ()=>JWT_USERINFO_EXPECTED, "KEY_SELECTION", ()=>KEY_SELECTION, "MISSING_SERVER_METADATA", ()=>MISSING_SERVER_METADATA, "None", ()=>None, "OperationProcessingError", ()=>OperationProcessingError, "PARSE_ERROR", ()=>PARSE_ERROR, "PrivateKeyJwt", ()=>PrivateKeyJwt, "REQUEST_PROTOCOL_FORBIDDEN", ()=>REQUEST_PROTOCOL_FORBIDDEN, "RESPONSE_BODY_ERROR", ()=>RESPONSE_BODY_ERROR, "RESPONSE_IS_NOT_CONFORM", ()=>RESPONSE_IS_NOT_CONFORM, "RESPONSE_IS_NOT_JSON", ()=>RESPONSE_IS_NOT_JSON, "ResponseBodyError", ()=>ResponseBodyError, "TlsClientAuth", ()=>TlsClientAuth, "UNSUPPORTED_OPERATION", ()=>UNSUPPORTED_OPERATION, "UnsupportedOperationError", ()=>UnsupportedOperationError, "WWWAuthenticateChallengeError", ()=>WWWAuthenticateChallengeError, "WWW_AUTHENTICATE_CHALLENGE", ()=>WWW_AUTHENTICATE_CHALLENGE, "_expectedIssuer", ()=>_expectedIssuer, "_nodiscoverycheck", ()=>_nodiscoverycheck, "_nopkce", ()=>_nopkce, "allowInsecureRequests", ()=>allowInsecureRequests, "authorizationCodeGrantRequest", ()=>authorizationCodeGrantRequest, "backchannelAuthenticationGrantRequest", ()=>backchannelAuthenticationGrantRequest, "backchannelAuthenticationRequest", ()=>backchannelAuthenticationRequest, "calculatePKCECodeChallenge", ()=>calculatePKCECodeChallenge, "checkProtocol", ()=>checkProtocol, "clientCredentialsGrantRequest", ()=>clientCredentialsGrantRequest, "clockSkew", ()=>clockSkew, "clockTolerance", ()=>clockTolerance, "customFetch", ()=>customFetch, "deviceAuthorizationRequest", ()=>deviceAuthorizationRequest, "deviceCodeGrantRequest", ()=>deviceCodeGrantRequest, "discoveryRequest", ()=>discoveryRequest, "dynamicClientRegistrationRequest", ()=>dynamicClientRegistrationRequest, "expectNoNonce", ()=>expectNoNonce, "expectNoState", ()=>expectNoState, "formPostResponse", ()=>formPostResponse, "generateKeyPair", ()=>generateKeyPair, "generateRandomCodeVerifier", ()=>generateRandomCodeVerifier, "generateRandomNonce", ()=>generateRandomNonce, "generateRandomState", ()=>generateRandomState, "genericTokenEndpointRequest", ()=>genericTokenEndpointRequest, "getContentType", ()=>getContentType, "getValidatedIdTokenClaims", ()=>getValidatedIdTokenClaims, "introspectionRequest", ()=>introspectionRequest, "isDPoPNonceError", ()=>isDPoPNonceError, "issueRequestObject", ()=>issueRequestObject, "jweDecrypt", ()=>jweDecrypt, "jwksCache", ()=>jwksCache, "modifyAssertion", ()=>modifyAssertion, "nopkce", ()=>nopkce, "processAuthorizationCodeResponse", ()=>processAuthorizationCodeResponse, "processBackchannelAuthenticationGrantResponse", ()=>processBackchannelAuthenticationGrantResponse, "processBackchannelAuthenticationResponse", ()=>processBackchannelAuthenticationResponse, "processClientCredentialsResponse", ()=>processClientCredentialsResponse, "processDeviceAuthorizationResponse", ()=>processDeviceAuthorizationResponse, "processDeviceCodeResponse", ()=>processDeviceCodeResponse, "processDiscoveryResponse", ()=>processDiscoveryResponse, "processDynamicClientRegistrationResponse", ()=>processDynamicClientRegistrationResponse, "processGenericTokenEndpointResponse", ()=>processGenericTokenEndpointResponse, "processIntrospectionResponse", ()=>processIntrospectionResponse, "processPushedAuthorizationResponse", ()=>processPushedAuthorizationResponse, "processRefreshTokenResponse", ()=>processRefreshTokenResponse, "processResourceDiscoveryResponse", ()=>processResourceDiscoveryResponse, "processRevocationResponse", ()=>processRevocationResponse, "processUserInfoResponse", ()=>processUserInfoResponse, "protectedResourceRequest", ()=>protectedResourceRequest, "pushedAuthorizationRequest", ()=>pushedAuthorizationRequest, "refreshTokenGrantRequest", ()=>refreshTokenGrantRequest, "resolveEndpoint", ()=>resolveEndpoint, "resourceDiscoveryRequest", ()=>resourceDiscoveryRequest, "revocationRequest", ()=>revocationRequest, "skipAuthTimeCheck", ()=>skipAuthTimeCheck, "skipStateCheck", ()=>skipStateCheck, "skipSubjectCheck", ()=>skipSubjectCheck, "userInfoRequest", ()=>userInfoRequest, "validateApplicationLevelSignature", ()=>validateApplicationLevelSignature, "validateAuthResponse", ()=>validateAuthResponse, "validateCodeIdTokenResponse", ()=>validateCodeIdTokenResponse, "validateDetachedSignatureResponse", ()=>validateDetachedSignatureResponse, "validateJwtAccessToken", ()=>validateJwtAccessToken, "validateJwtAuthResponse", ()=>validateJwtAuthResponse ]); let USER_AGENT; if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) { const NAME = 'oauth4webapi'; const VERSION = 'v3.8.5'; USER_AGENT = `${NAME}/${VERSION}`; } function looseInstanceOf(input, expected) { if (input == null) { return false; } try { return input instanceof expected || Object.getPrototypeOf(input)[Symbol.toStringTag] === expected.prototype[Symbol.toStringTag]; } catch { return false; } } const ERR_INVALID_ARG_VALUE = 'ERR_INVALID_ARG_VALUE'; const ERR_INVALID_ARG_TYPE = 'ERR_INVALID_ARG_TYPE'; function CodedTypeError(message, code, cause) { const err = new TypeError(message, { cause }); Object.assign(err, { code }); return err; } const allowInsecureRequests = Symbol(); const clockSkew = Symbol(); const clockTolerance = Symbol(); const customFetch = Symbol(); const modifyAssertion = Symbol(); const jweDecrypt = Symbol(); const jwksCache = Symbol(); const encoder = new TextEncoder(); const decoder = new TextDecoder(); function buf(input) { if (typeof input === 'string') { return encoder.encode(input); } return decoder.decode(input); } let encodeBase64Url; if (Uint8Array.prototype.toBase64) { encodeBase64Url = (input)=>{ if (input instanceof ArrayBuffer) { input = new Uint8Array(input); } return input.toBase64({ alphabet: 'base64url', omitPadding: true }); }; } else { const CHUNK_SIZE = 0x8000; encodeBase64Url = (input)=>{ if (input instanceof ArrayBuffer) { input = new Uint8Array(input); } const arr = []; for(let i = 0; i < input.byteLength; i += CHUNK_SIZE){ arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE))); } return btoa(arr.join('')).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_'); }; } let decodeBase64Url; if (Uint8Array.fromBase64) { decodeBase64Url = (input)=>{ try { return Uint8Array.fromBase64(input, { alphabet: 'base64url' }); } catch (cause) { throw CodedTypeError('The input to be decoded is not correctly encoded.', ERR_INVALID_ARG_VALUE, cause); } }; } else { decodeBase64Url = (input)=>{ try { const binary = atob(input.replace(/-/g, '+').replace(/_/g, '/').replace(/\s/g, '')); const bytes = new Uint8Array(binary.length); for(let i = 0; i < binary.length; i++){ bytes[i] = binary.charCodeAt(i); } return bytes; } catch (cause) { throw CodedTypeError('The input to be decoded is not correctly encoded.', ERR_INVALID_ARG_VALUE, cause); } }; } function b64u(input) { if (typeof input === 'string') { return decodeBase64Url(input); } return encodeBase64Url(input); } class UnsupportedOperationError extends Error { code; constructor(message, options){ super(message, options); this.name = this.constructor.name; this.code = UNSUPPORTED_OPERATION; Error.captureStackTrace?.(this, this.constructor); } } class OperationProcessingError extends Error { code; constructor(message, options){ super(message, options); this.name = this.constructor.name; if (options?.code) { this.code = options?.code; } Error.captureStackTrace?.(this, this.constructor); } } function OPE(message, code, cause) { return new OperationProcessingError(message, { code, cause }); } async function calculateJwkThumbprint(jwk) { let components; switch(jwk.kty){ case 'EC': components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y }; break; case 'OKP': components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x }; break; case 'AKP': components = { alg: jwk.alg, kty: jwk.kty, pub: jwk.pub }; break; case 'RSA': components = { e: jwk.e, kty: jwk.kty, n: jwk.n }; break; default: throw new UnsupportedOperationError('unsupported JWK key type', { cause: jwk }); } return b64u(await crypto.subtle.digest('SHA-256', buf(JSON.stringify(components)))); } function assertCryptoKey(key, it) { if (!(key instanceof CryptoKey)) { throw CodedTypeError(`${it} must be a CryptoKey`, ERR_INVALID_ARG_TYPE); } } function assertPrivateKey(key, it) { assertCryptoKey(key, it); if (key.type !== 'private') { throw CodedTypeError(`${it} must be a private CryptoKey`, ERR_INVALID_ARG_VALUE); } } function assertPublicKey(key, it) { assertCryptoKey(key, it); if (key.type !== 'public') { throw CodedTypeError(`${it} must be a public CryptoKey`, ERR_INVALID_ARG_VALUE); } } function normalizeTyp(value) { return value.toLowerCase().replace(/^application\//, ''); } function isJsonObject(input) { if (input === null || typeof input !== 'object' || Array.isArray(input)) { return false; } return true; } function prepareHeaders(input) { if (looseInstanceOf(input, Headers)) { input = Object.fromEntries(input.entries()); } const headers = new Headers(input ?? {}); if (USER_AGENT && !headers.has('user-agent')) { headers.set('user-agent', USER_AGENT); } if (headers.has('authorization')) { throw CodedTypeError('"options.headers" must not include the "authorization" header name', ERR_INVALID_ARG_VALUE); } return headers; } function signal(url, value) { if (value !== undefined) { if (typeof value === 'function') { value = value(url.href); } if (!(value instanceof AbortSignal)) { throw CodedTypeError('"options.signal" must return or be an instance of AbortSignal', ERR_INVALID_ARG_TYPE); } return value; } return undefined; } function replaceDoubleSlash(pathname) { if (pathname.includes('//')) { return pathname.replace('//', '/'); } return pathname; } function prependWellKnown(url, wellKnown, allowTerminatingSlash = false) { if (url.pathname === '/') { url.pathname = wellKnown; } else { url.pathname = replaceDoubleSlash(`${wellKnown}/${allowTerminatingSlash ? url.pathname : url.pathname.replace(/(\/)$/, '')}`); } return url; } function appendWellKnown(url, wellKnown) { url.pathname = replaceDoubleSlash(`${url.pathname}/${wellKnown}`); return url; } async function performDiscovery(input, urlName, transform, options) { if (!(input instanceof URL)) { throw CodedTypeError(`"${urlName}" must be an instance of URL`, ERR_INVALID_ARG_TYPE); } checkProtocol(input, options?.[allowInsecureRequests] !== true); const url = transform(new URL(input.href)); const headers = prepareHeaders(options?.headers); headers.set('accept', 'application/json'); return (options?.[customFetch] || fetch)(url.href, { body: undefined, headers: Object.fromEntries(headers.entries()), method: 'GET', redirect: 'manual', signal: signal(url, options?.signal) }); } async function discoveryRequest(issuerIdentifier, options) { return performDiscovery(issuerIdentifier, 'issuerIdentifier', (url)=>{ switch(options?.algorithm){ case undefined: case 'oidc': appendWellKnown(url, '.well-known/openid-configuration'); break; case 'oauth2': prependWellKnown(url, '.well-known/oauth-authorization-server'); break; default: throw CodedTypeError('"options.algorithm" must be "oidc" (default), or "oauth2"', ERR_INVALID_ARG_VALUE); } return url; }, options); } function assertNumber(input, allow0, it, code, cause) { try { if (typeof input !== 'number' || !Number.isFinite(input)) { throw CodedTypeError(`${it} must be a number`, ERR_INVALID_ARG_TYPE, cause); } if (input > 0) return; if (allow0) { if (input !== 0) { throw CodedTypeError(`${it} must be a non-negative number`, ERR_INVALID_ARG_VALUE, cause); } return; } throw CodedTypeError(`${it} must be a positive number`, ERR_INVALID_ARG_VALUE, cause); } catch (err) { if (code) { throw OPE(err.message, code, cause); } throw err; } } function assertString(input, it, code, cause) { try { if (typeof input !== 'string') { throw CodedTypeError(`${it} must be a string`, ERR_INVALID_ARG_TYPE, cause); } if (input.length === 0) { throw CodedTypeError(`${it} must not be empty`, ERR_INVALID_ARG_VALUE, cause); } } catch (err) { if (code) { throw OPE(err.message, code, cause); } throw err; } } async function processDiscoveryResponse(expectedIssuerIdentifier, response) { const expected = expectedIssuerIdentifier; if (!(expected instanceof URL) && expected !== _nodiscoverycheck) { throw CodedTypeError('"expectedIssuerIdentifier" must be an instance of URL', ERR_INVALID_ARG_TYPE); } if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } if (response.status !== 200) { throw OPE('"response" is not a conform Authorization Server Metadata response (unexpected HTTP status code)', RESPONSE_IS_NOT_CONFORM, response); } assertReadableResponse(response); const json = await getResponseJsonBody(response); assertString(json.issuer, '"response" body "issuer" property', INVALID_RESPONSE, { body: json }); if (expected !== _nodiscoverycheck && new URL(json.issuer).href !== expected.href) { throw OPE('"response" body "issuer" property does not match the expected value', JSON_ATTRIBUTE_COMPARISON, { expected: expected.href, body: json, attribute: 'issuer' }); } return json; } function assertApplicationJson(response) { assertContentType(response, 'application/json'); } function notJson(response, ...types) { let msg = '"response" content-type must be '; if (types.length > 2) { const last = types.pop(); msg += `${types.join(', ')}, or ${last}`; } else if (types.length === 2) { msg += `${types[0]} or ${types[1]}`; } else { msg += types[0]; } return OPE(msg, RESPONSE_IS_NOT_JSON, response); } function assertContentTypes(response, ...types) { if (!types.includes(getContentType(response))) { throw notJson(response, ...types); } } function assertContentType(response, contentType) { if (getContentType(response) !== contentType) { throw notJson(response, contentType); } } function randomBytes() { return b64u(crypto.getRandomValues(new Uint8Array(32))); } function generateRandomCodeVerifier() { return randomBytes(); } function generateRandomState() { return randomBytes(); } function generateRandomNonce() { return randomBytes(); } async function calculatePKCECodeChallenge(codeVerifier) { assertString(codeVerifier, 'codeVerifier'); return b64u(await crypto.subtle.digest('SHA-256', buf(codeVerifier))); } function getKeyAndKid(input) { if (input instanceof CryptoKey) { return { key: input }; } if (!(input?.key instanceof CryptoKey)) { return {}; } if (input.kid !== undefined) { assertString(input.kid, '"kid"'); } return { key: input.key, kid: input.kid }; } function psAlg(key) { switch(key.algorithm.hash.name){ case 'SHA-256': return 'PS256'; case 'SHA-384': return 'PS384'; case 'SHA-512': return 'PS512'; default: throw new UnsupportedOperationError('unsupported RsaHashedKeyAlgorithm hash name', { cause: key }); } } function rsAlg(key) { switch(key.algorithm.hash.name){ case 'SHA-256': return 'RS256'; case 'SHA-384': return 'RS384'; case 'SHA-512': return 'RS512'; default: throw new UnsupportedOperationError('unsupported RsaHashedKeyAlgorithm hash name', { cause: key }); } } function esAlg(key) { switch(key.algorithm.namedCurve){ case 'P-256': return 'ES256'; case 'P-384': return 'ES384'; case 'P-521': return 'ES512'; default: throw new UnsupportedOperationError('unsupported EcKeyAlgorithm namedCurve', { cause: key }); } } function keyToJws(key) { switch(key.algorithm.name){ case 'RSA-PSS': return psAlg(key); case 'RSASSA-PKCS1-v1_5': return rsAlg(key); case 'ECDSA': return esAlg(key); case 'Ed25519': case 'ML-DSA-44': case 'ML-DSA-65': case 'ML-DSA-87': return key.algorithm.name; case 'EdDSA': return 'Ed25519'; default: throw new UnsupportedOperationError('unsupported CryptoKey algorithm name', { cause: key }); } } function getClockSkew(client) { const skew = client?.[clockSkew]; return typeof skew === 'number' && Number.isFinite(skew) ? skew : 0; } function getClockTolerance(client) { const tolerance = client?.[clockTolerance]; return typeof tolerance === 'number' && Number.isFinite(tolerance) && Math.sign(tolerance) !== -1 ? tolerance : 30; } function epochTime() { return Math.floor(Date.now() / 1000); } function assertAs(as) { if (typeof as !== 'object' || as === null) { throw CodedTypeError('"as" must be an object', ERR_INVALID_ARG_TYPE); } assertString(as.issuer, '"as.issuer"'); } function assertClient(client) { if (typeof client !== 'object' || client === null) { throw CodedTypeError('"client" must be an object', ERR_INVALID_ARG_TYPE); } assertString(client.client_id, '"client.client_id"'); } function formUrlEncode(token) { return encodeURIComponent(token).replace(/(?:[-_.!~*'()]|%20)/g, (substring)=>{ switch(substring){ case '-': case '_': case '.': case '!': case '~': case '*': case "'": case '(': case ')': return `%${substring.charCodeAt(0).toString(16).toUpperCase()}`; case '%20': return '+'; default: throw new Error(); } }); } function ClientSecretPost(clientSecret) { assertString(clientSecret, '"clientSecret"'); return (_as, client, body, _headers)=>{ body.set('client_id', client.client_id); body.set('client_secret', clientSecret); }; } function ClientSecretBasic(clientSecret) { assertString(clientSecret, '"clientSecret"'); return (_as, client, _body, headers)=>{ const username = formUrlEncode(client.client_id); const password = formUrlEncode(clientSecret); const credentials = btoa(`${username}:${password}`); headers.set('authorization', `Basic ${credentials}`); }; } function clientAssertionPayload(as, client) { const now = epochTime() + getClockSkew(client); return { jti: randomBytes(), aud: as.issuer, exp: now + 60, iat: now, nbf: now, iss: client.client_id, sub: client.client_id }; } function PrivateKeyJwt(clientPrivateKey, options) { const { key, kid } = getKeyAndKid(clientPrivateKey); assertPrivateKey(key, '"clientPrivateKey.key"'); return async (as, client, body, _headers)=>{ const header = { alg: keyToJws(key), kid }; const payload = clientAssertionPayload(as, client); options?.[modifyAssertion]?.(header, payload); body.set('client_id', client.client_id); body.set('client_assertion_type', 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'); body.set('client_assertion', await signJwt(header, payload, key)); }; } function ClientSecretJwt(clientSecret, options) { assertString(clientSecret, '"clientSecret"'); const modify = options?.[modifyAssertion]; let key; return async (as, client, body, _headers)=>{ key ||= await crypto.subtle.importKey('raw', buf(clientSecret), { hash: 'SHA-256', name: 'HMAC' }, false, [ 'sign' ]); const header = { alg: 'HS256' }; const payload = clientAssertionPayload(as, client); modify?.(header, payload); const data = `${b64u(buf(JSON.stringify(header)))}.${b64u(buf(JSON.stringify(payload)))}`; const hmac = await crypto.subtle.sign(key.algorithm, key, buf(data)); body.set('client_id', client.client_id); body.set('client_assertion_type', 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'); body.set('client_assertion', `${data}.${b64u(new Uint8Array(hmac))}`); }; } function None() { return (_as, client, body, _headers)=>{ body.set('client_id', client.client_id); }; } function TlsClientAuth() { return None(); } async function signJwt(header, payload, key) { if (!key.usages.includes('sign')) { throw CodedTypeError('CryptoKey instances used for signing assertions must include "sign" in their "usages"', ERR_INVALID_ARG_VALUE); } const input = `${b64u(buf(JSON.stringify(header)))}.${b64u(buf(JSON.stringify(payload)))}`; const signature = b64u(await crypto.subtle.sign(keyToSubtle(key), key, buf(input))); return `${input}.${signature}`; } async function issueRequestObject(as, client, parameters, privateKey, options) { assertAs(as); assertClient(client); parameters = new URLSearchParams(parameters); const { key, kid } = getKeyAndKid(privateKey); assertPrivateKey(key, '"privateKey.key"'); parameters.set('client_id', client.client_id); const now = epochTime() + getClockSkew(client); const claims = { ...Object.fromEntries(parameters.entries()), jti: randomBytes(), aud: as.issuer, exp: now + 60, iat: now, nbf: now, iss: client.client_id }; let resource; if (parameters.has('resource') && (resource = parameters.getAll('resource')) && resource.length > 1) { claims.resource = resource; } { let value = parameters.get('max_age'); if (value !== null) { claims.max_age = parseInt(value, 10); assertNumber(claims.max_age, true, '"max_age" parameter'); } } { let value = parameters.get('claims'); if (value !== null) { try { claims.claims = JSON.parse(value); } catch (cause) { throw OPE('failed to parse the "claims" parameter as JSON', PARSE_ERROR, cause); } if (!isJsonObject(claims.claims)) { throw CodedTypeError('"claims" parameter must be a JSON with a top level object', ERR_INVALID_ARG_VALUE); } } } { let value = parameters.get('authorization_details'); if (value !== null) { try { claims.authorization_details = JSON.parse(value); } catch (cause) { throw OPE('failed to parse the "authorization_details" parameter as JSON', PARSE_ERROR, cause); } if (!Array.isArray(claims.authorization_details)) { throw CodedTypeError('"authorization_details" parameter must be a JSON with a top level array', ERR_INVALID_ARG_VALUE); } } } const header = { alg: keyToJws(key), typ: 'oauth-authz-req+jwt', kid }; options?.[modifyAssertion]?.(header, claims); return signJwt(header, claims, key); } let jwkCache; async function getSetPublicJwkCache(key, alg) { const { kty, e, n, x, y, crv, pub } = await crypto.subtle.exportKey('jwk', key); const jwk = { kty, e, n, x, y, crv, pub }; if (kty === 'AKP') jwk.alg = alg; jwkCache.set(key, jwk); return jwk; } async function publicJwk(key, alg) { jwkCache ||= new WeakMap(); return jwkCache.get(key) || getSetPublicJwkCache(key, alg); } const URLParse = URL.parse ? (url, base)=>URL.parse(url, base) : (url, base)=>{ try { return new URL(url, base); } catch { return null; } }; function checkProtocol(url, enforceHttps) { if (enforceHttps && url.protocol !== 'https:') { throw OPE('only requests to HTTPS are allowed', HTTP_REQUEST_FORBIDDEN, url); } if (url.protocol !== 'https:' && url.protocol !== 'http:') { throw OPE('only HTTP and HTTPS requests are allowed', REQUEST_PROTOCOL_FORBIDDEN, url); } } function validateEndpoint(value, endpoint, useMtlsAlias, enforceHttps) { let url; if (typeof value !== 'string' || !(url = URLParse(value))) { throw OPE(`authorization server metadata does not contain a valid ${useMtlsAlias ? `"as.mtls_endpoint_aliases.${endpoint}"` : `"as.${endpoint}"`}`, value === undefined ? MISSING_SERVER_METADATA : INVALID_SERVER_METADATA, { attribute: useMtlsAlias ? `mtls_endpoint_aliases.${endpoint}` : endpoint }); } checkProtocol(url, enforceHttps); return url; } function resolveEndpoint(as, endpoint, useMtlsAlias, enforceHttps) { if (useMtlsAlias && as.mtls_endpoint_aliases && endpoint in as.mtls_endpoint_aliases) { return validateEndpoint(as.mtls_endpoint_aliases[endpoint], endpoint, useMtlsAlias, enforceHttps); } return validateEndpoint(as[endpoint], endpoint, useMtlsAlias, enforceHttps); } async function pushedAuthorizationRequest(as, client, clientAuthentication, parameters, options) { assertAs(as); assertClient(client); const url = resolveEndpoint(as, 'pushed_authorization_request_endpoint', client.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true); const body = new URLSearchParams(parameters); body.set('client_id', client.client_id); const headers = prepareHeaders(options?.headers); headers.set('accept', 'application/json'); if (options?.DPoP !== undefined) { assertDPoP(options.DPoP); await options.DPoP.addProof(url, headers, 'POST'); } const response = await authenticatedRequest(as, client, clientAuthentication, url, body, headers, options); options?.DPoP?.cacheNonce(response, url); return response; } class DPoPHandler { #header; #privateKey; #publicKey; #clockSkew; #modifyAssertion; #map; #jkt; constructor(client, keyPair, options){ assertPrivateKey(keyPair?.privateKey, '"DPoP.privateKey"'); assertPublicKey(keyPair?.publicKey, '"DPoP.publicKey"'); if (!keyPair.publicKey.extractable) { throw CodedTypeError('"DPoP.publicKey.extractable" must be true', ERR_INVALID_ARG_VALUE); } this.#modifyAssertion = options?.[modifyAssertion]; this.#clockSkew = getClockSkew(client); this.#privateKey = keyPair.privateKey; this.#publicKey = keyPair.publicKey; branded.add(this); } #get(key) { this.#map ||= new Map(); let item = this.#map.get(key); if (item) { this.#map.delete(key); this.#map.set(key, item); } return item; } #set(key, val) { this.#map ||= new Map(); this.#map.delete(key); if (this.#map.size === 100) { this.#map.delete(this.#map.keys().next().value); } this.#map.set(key, val); } async calculateThumbprint() { if (!this.#jkt) { const jwk = await crypto.subtle.exportKey('jwk', this.#publicKey); this.#jkt ||= await calculateJwkThumbprint(jwk); } return this.#jkt; } async addProof(url, headers, htm, accessToken) { const alg = keyToJws(this.#privateKey); this.#header ||= { alg, typ: 'dpop+jwt', jwk: await publicJwk(this.#publicKey, alg) }; const nonce = this.#get(url.origin); const now = epochTime() + this.#clockSkew; const payload = { iat: now, jti: randomBytes(), htm, nonce, htu: `${url.origin}${url.pathname}`, ath: accessToken ? b64u(await crypto.subtle.digest('SHA-256', buf(accessToken))) : undefined }; this.#modifyAssertion?.(this.#header, payload); headers.set('dpop', await signJwt(this.#header, payload, this.#privateKey)); } cacheNonce(response, url) { try { const nonce = response.headers.get('dpop-nonce'); if (nonce) { this.#set(url.origin, nonce); } } catch {} } } function isDPoPNonceError(err) { if (err instanceof WWWAuthenticateChallengeError) { const { 0: challenge, length } = err.cause; return length === 1 && challenge.scheme === 'dpop' && challenge.parameters.error === 'use_dpop_nonce'; } if (err instanceof ResponseBodyError) { return err.error === 'use_dpop_nonce'; } return false; } function DPoP(client, keyPair, options) { return new DPoPHandler(client, keyPair, options); } class ResponseBodyError extends Error { cause; code; error; status; error_description; response; constructor(message, options){ super(message, options); this.name = this.constructor.name; this.code = RESPONSE_BODY_ERROR; this.cause = options.cause; this.error = options.cause.error; this.status = options.response.status; this.error_description = options.cause.error_description; Object.defineProperty(this, 'response', { enumerable: false, value: options.response }); Error.captureStackTrace?.(this, this.constructor); } } class AuthorizationResponseError extends Error { cause; code; error; error_description; constructor(message, options){ super(message, options); this.name = this.constructor.name; this.code = AUTHORIZATION_RESPONSE_ERROR; this.cause = options.cause; this.error = options.cause.get('error'); this.error_description = options.cause.get('error_description') ?? undefined; Error.captureStackTrace?.(this, this.constructor); } } class WWWAuthenticateChallengeError extends Error { cause; code; response; status; constructor(message, options){ super(message, options); this.name = this.constructor.name; this.code = WWW_AUTHENTICATE_CHALLENGE; this.cause = options.cause; this.status = options.response.status; this.response = options.response; Object.defineProperty(this, 'response', { enumerable: false }); Error.captureStackTrace?.(this, this.constructor); } } const tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+"; const token68Match = '[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}'; const quotedMatch = '"((?:[^"\\\\]|\\\\[\\s\\S])*)"'; const quotedParamMatcher = '(' + tokenMatch + ')\\s*=\\s*' + quotedMatch; const paramMatcher = '(' + tokenMatch + ')\\s*=\\s*(' + tokenMatch + ')'; const schemeRE = new RegExp('^[,\\s]*(' + tokenMatch + ')'); const quotedParamRE = new RegExp('^[,\\s]*' + quotedParamMatcher + '[,\\s]*(.*)'); const unquotedParamRE = new RegExp('^[,\\s]*' + paramMatcher + '[,\\s]*(.*)'); const token68ParamRE = new RegExp('^(' + token68Match + ')(?:$|[,\\s])(.*)'); function parseWwwAuthenticateChallenges(response) { if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } const header = response.headers.get('www-authenticate'); if (header === null) { return undefined; } const challenges = []; let rest = header; while(rest){ let match = rest.match(schemeRE); const scheme = match?.['1'].toLowerCase(); if (!scheme) { return undefined; } const afterScheme = rest.substring(match[0].length); if (afterScheme && !afterScheme.match(/^[\s,]/)) { return undefined; } const spaceMatch = afterScheme.match(/^\s+(.*)$/); const hasParameters = !!spaceMatch; rest = spaceMatch ? spaceMatch[1] : undefined; const parameters = {}; let token68; if (hasParameters) { while(rest){ let key; let value; if (match = rest.match(quotedParamRE)) { ; [, key, value, rest] = match; if (value.includes('\\')) { try { value = JSON.parse(`"${value}"`); } catch {} } parameters[key.toLowerCase()] = value; continue; } if (match = rest.match(unquotedParamRE)) { ; [, key, value, rest] = match; parameters[key.toLowerCase()] = value; continue; } if (match = rest.match(token68ParamRE)) { if (Object.keys(parameters).length) { break; } ; [, token68, rest] = match; break; } return undefined; } } else { rest = afterScheme || undefined; } const challenge = { scheme, parameters }; if (token68) { challenge.token68 = token68; } challenges.push(challenge); } if (!challenges.length) { return undefined; } return challenges; } async function processPushedAuthorizationResponse(as, client, response) { assertAs(as); assertClient(client); if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } await checkOAuthBodyError(response, 201, 'Pushed Authorization Request Endpoint'); assertReadableResponse(response); const json = await getResponseJsonBody(response); assertString(json.request_uri, '"response" body "request_uri" property', INVALID_RESPONSE, { body: json }); let expiresIn = typeof json.expires_in !== 'number' ? parseFloat(json.expires_in) : json.expires_in; assertNumber(expiresIn, true, '"response" body "expires_in" property', INVALID_RESPONSE, { body: json }); json.expires_in = expiresIn; return json; } async function parseOAuthResponseErrorBody(response) { if (response.status > 399 && response.status < 500) { assertReadableResponse(response); assertApplicationJson(response); try { const json = await response.clone().json(); if (isJsonObject(json) && typeof json.error === 'string' && json.error.length) { return json; } } catch {} } return undefined; } async function checkOAuthBodyError(response, expected, label) { if (response.status !== expected) { checkAuthenticationChallenges(response); let err; if (err = await parseOAuthResponseErrorBody(response)) { await response.body?.cancel(); throw new ResponseBodyError('server responded with an error in the response body', { cause: err, response }); } throw OPE(`"response" is not a conform ${label} response (unexpected HTTP status code)`, RESPONSE_IS_NOT_CONFORM, response); } } function assertDPoP(option) { if (!branded.has(option)) { throw CodedTypeError('"options.DPoP" is not a valid DPoPHandle', ERR_INVALID_ARG_VALUE); } } async function resourceRequest(accessToken, method, url, headers, body, options) { assertString(accessToken, '"accessToken"'); if (!(url instanceof URL)) { throw CodedTypeError('"url" must be an instance of URL', ERR_INVALID_ARG_TYPE); } checkProtocol(url, options?.[allowInsecureRequests] !== true); headers = prepareHeaders(headers); if (options?.DPoP) { assertDPoP(options.DPoP); await options.DPoP.addProof(url, headers, method.toUpperCase(), accessToken); } headers.set('authorization', `${headers.has('dpop') ? 'DPoP' : 'Bearer'} ${accessToken}`); const response = await (options?.[customFetch] || fetch)(url.href, { duplex: looseInstanceOf(body, ReadableStream) ? 'half' : undefined, body, headers: Object.fromEntries(headers.entries()), method, redirect: 'manual', signal: signal(url, options?.signal) }); options?.DPoP?.cacheNonce(response, url); return response; } async function protectedResourceRequest(accessToken, method, url, headers, body, options) { const response = await resourceRequest(accessToken, method, url, headers, body, options); checkAuthenticationChallenges(response); return response; } async function userInfoRequest(as, client, accessToken, options) { assertAs(as); assertClient(client); const url = resolveEndpoint(as, 'userinfo_endpoint', client.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true); const headers = prepareHeaders(options?.headers); if (client.userinfo_signed_response_alg) { headers.set('accept', 'application/jwt'); } else { headers.set('accept', 'application/json'); headers.append('accept', 'application/jwt'); } return resourceRequest(accessToken, 'GET', url, headers, null, { ...options, [clockSkew]: getClockSkew(client) }); } let jwksMap; function setJwksCache(as, jwks, uat, cache) { jwksMap ||= new WeakMap(); jwksMap.set(as, { jwks, uat, get age () { return epochTime() - this.uat; } }); if (cache) { Object.assign(cache, { jwks: structuredClone(jwks), uat }); } } function isFreshJwksCache(input) { if (typeof input !== 'object' || input === null) { return false; } if (!('uat' in input) || typeof input.uat !== 'number' || epochTime() - input.uat >= 300) { return false; } if (!('jwks' in input) || !isJsonObject(input.jwks) || !Array.isArray(input.jwks.keys) || !Array.prototype.every.call(input.jwks.keys, isJsonObject)) { return false; } return true; } function clearJwksCache(as, cache) { jwksMap?.delete(as); delete cache?.jwks; delete cache?.uat; } async function getPublicSigKeyFromIssuerJwksUri(as, options, header) { const { alg, kid } = header; checkSupportedJwsAlg(header); if (!jwksMap?.has(as) && isFreshJwksCache(options?.[jwksCache])) { setJwksCache(as, options?.[jwksCache].jwks, options?.[jwksCache].uat); } let jwks; let age; if (jwksMap?.has(as)) { ; ({ jwks, age } = jwksMap.get(as)); if (age >= 300) { clearJwksCache(as, options?.[jwksCache]); return getPublicSigKeyFromIssuerJwksUri(as, options, header); } } else { jwks = await jwksRequest(as, options).then(processJwksResponse); age = 0; setJwksCache(as, jwks, epochTime(), options?.[jwksCache]); } let kty; switch(alg.slice(0, 2)){ case 'RS': case 'PS': kty = 'RSA'; break; case 'ES': kty = 'EC'; break; case 'Ed': kty = 'OKP'; break; case 'ML': kty = 'AKP'; break; default: throw new UnsupportedOperationError('unsupported JWS algorithm', { cause: { alg } }); } const candidates = jwks.keys.filter((jwk)=>{ if (jwk.kty !== kty) { return false; } if (kid !== undefined && kid !== jwk.kid) { return false; } if (jwk.alg !== undefined && alg !== jwk.alg) { return false; } if (jwk.use !== undefined && jwk.use !== 'sig') { return false; } if (jwk.key_ops?.includes('verify') === false) { return false; } switch(true){ case alg === 'ES256' && jwk.crv !== 'P-256': case alg === 'ES384' && jwk.crv !== 'P-384': case alg === 'ES512' && jwk.crv !== 'P-521': case alg === 'Ed25519' && jwk.crv !== 'Ed25519': case alg === 'EdDSA' && jwk.crv !== 'Ed25519': return false; } return true; }); const { 0: jwk, length } = candidates; if (!length) { if (age >= 60) { clearJwksCache(as, options?.[jwksCache]); return getPublicSigKeyFromIssuerJwksUri(as, options, header); } throw OPE('error when selecting a JWT verification key, no applicable keys found', KEY_SELECTION, { header, candidates, jwks_uri: new URL(as.jwks_uri) }); } if (length !== 1) { throw OPE('error when selecting a JWT verification key, multiple applicable keys found, a "kid" JWT Header Parameter is required', KEY_SELECTION, { header, candidates, jwks_uri: new URL(as.jwks_uri) }); } return importJwk(alg, jwk); } const skipSubjectCheck = Symbol(); function getContentType(input) { return input.headers.get('content-type')?.split(';')[0]; } async function processUserInfoResponse(as, client, expectedSubject, response, options) { assertAs(as); assertClient(client); if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } checkAuthenticationChallenges(response); if (response.status !== 200) { throw OPE('"response" is not a conform UserInfo Endpoint response (unexpected HTTP status code)', RESPONSE_IS_NOT_CONFORM, response); } assertReadableResponse(response); let json; if (getContentType(response) === 'application/jwt') { const { claims, jwt } = await validateJwt(await response.text(), checkSigningAlgorithm.bind(undefined, client.userinfo_signed_response_alg, as.userinfo_signing_alg_values_supported, undefined), getClockSkew(client), getClockTolerance(client), options?.[jweDecrypt]).then(validateOptionalAudience.bind(undefined, client.client_id)).then(validateOptionalIssuer.bind(undefined, as)); jwtRefs.set(response, jwt); json = claims; } else { if (client.userinfo_signed_response_alg) { throw OPE('JWT UserInfo Response expected', JWT_USERINFO_EXPECTED, response); } json = await getResponseJsonBody(response); } assertString(json.sub, '"response" body "sub" property', INVALID_RESPONSE, { body: json }); switch(expectedSubject){ case skipSubjectCheck: break; default: assertString(expectedSubject, '"expectedSubject"'); if (json.sub !== expectedSubject) { throw OPE('unexpected "response" body "sub" property value', JSON_ATTRIBUTE_COMPARISON, { expected: expectedSubject, body: json, attribute: 'sub' }); } } return json; } async function authenticatedRequest(as, client, clientAuthentication, url, body, headers, options) { await clientAuthentication(as, client, body, headers); headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); return (options?.[customFetch] || fetch)(url.href, { body, headers: Object.fromEntries(headers.entries()), method: 'POST', redirect: 'manual', signal: signal(url, options?.signal) }); } async function tokenEndpointRequest(as, client, clientAuthentication, grantType, parameters, options) { const url = resolveEndpoint(as, 'token_endpoint', client.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true); parameters.set('grant_type', grantType); const headers = prepareHeaders(options?.headers); headers.set('accept', 'application/json'); if (options?.DPoP !== undefined) { assertDPoP(options.DPoP); await options.DPoP.addProof(url, headers, 'POST'); } const response = await authenticatedRequest(as, client, clientAuthentication, url, parameters, headers, options); options?.DPoP?.cacheNonce(response, url); return response; } async function refreshTokenGrantRequest(as, client, clientAuthentication, refreshToken, options) { assertAs(as); assertClient(client); assertString(refreshToken, '"refreshToken"'); const parameters = new URLSearchParams(options?.additionalParameters); parameters.set('refresh_token', refreshToken); return tokenEndpointRequest(as, client, clientAuthentication, 'refresh_token', parameters, options); } const idTokenClaims = new WeakMap(); const jwtRefs = new WeakMap(); function getValidatedIdTokenClaims(ref) { if (!ref.id_token) { return undefined; } const claims = idTokenClaims.get(ref); if (!claims) { throw CodedTypeError('"ref" was already garbage collected or did not resolve from the proper sources', ERR_INVALID_ARG_VALUE); } return claims; } async function validateApplicationLevelSignature(as, ref, options) { assertAs(as); if (!jwtRefs.has(ref)) { throw CodedTypeError('"ref" does not contain a processed JWT Response to verify the signature of', ERR_INVALID_ARG_VALUE); } const { 0: protectedHeader, 1: payload, 2: encodedSignature } = jwtRefs.get(ref).split('.'); const header = JSON.parse(buf(b64u(protectedHeader))); if (header.alg.startsWith('HS')) { throw new UnsupportedOperationError('unsupported JWS algorithm', { cause: { alg: header.alg } }); } let key; key = await getPublicSigKeyFromIssuerJwksUri(as, options, header); await validateJwsSignature(protectedHeader, payload, key, b64u(encodedSignature)); } async function processGenericAccessTokenResponse(as, client, response, additionalRequiredIdTokenClaims, decryptFn, recognizedTokenTypes) { assertAs(as); assertClient(client); if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } await checkOAuthBodyError(response, 200, 'Token Endpoint'); assertReadableResponse(response); const json = await getResponseJsonBody(response); assertString(json.access_token, '"response" body "access_token" property', INVALID_RESPONSE, { body: json }); assertString(json.token_type, '"response" body "token_type" property', INVALID_RESPONSE, { body: json }); json.token_type = json.token_type.toLowerCase(); if (json.expires_in !== undefined) { let expiresIn = typeof json.expires_in !== 'number' ? parseFloat(json.expires_in) : json.expires_in; assertNumber(expiresIn, true, '"response" body "expires_in" property', INVALID_RESPONSE, { body: json }); json.expires_in = expiresIn; } if (json.refresh_token !== undefined) { assertString(json.refresh_token, '"response" body "refresh_token" property', INVALID_RESPONSE, { body: json }); } if (json.scope !== undefined && typeof json.scope !== 'string') { throw OPE('"response" body "scope" property must be a string', INVALID_RESPONSE, { body: json }); } if (json.id_token !== undefined) { assertString(json.id_token, '"response" body "id_token" property', INVALID_RESPONSE, { body: json }); const requiredClaims = [ 'aud', 'exp', 'iat', 'iss', 'sub' ]; if (client.require_auth_time === true) { requiredClaims.push('auth_time'); } if (client.default_max_age !== undefined) { assertNumber(client.default_max_age, true, '"client.default_max_age"'); requiredClaims.push('auth_time'); } if (additionalRequiredIdTokenClaims?.length) { requiredClaims.push(...additionalRequiredIdTokenClaims); } const { claims, jwt } = await validateJwt(json.id_token, checkSigningAlgorithm.bind(undefined, client.id_token_signed_response_alg, as.id_token_signing_alg_values_supported, 'RS256'), getClockSkew(client), getClockTolerance(client), decryptFn).then(validatePresence.bind(undefined, requiredClaims)).then(validateIssuer.bind(undefined, as)).then(validateAudience.bind(undefined, client.client_id)); if (Array.isArray(claims.aud) && claims.aud.length !== 1) { if (claims.azp === undefined) { throw OPE('ID Token "aud" (audience) claim includes additional untrusted audiences', JWT_CLAIM_COMPARISON, { claims, claim: 'aud' }); } if (claims.azp !== client.client_id) { throw OPE('unexpected ID Token "azp" (authorized party) claim value', JWT_CLAIM_COMPARISON, { expected: client.client_id, claims, claim: 'azp' }); } } if (claims.auth_time !== undefined) { assertNumber(claims.auth_time, true, 'ID Token "auth_time" (authentication time)', INVALID_RESPONSE, { claims }); } jwtRefs.set(response, jwt); idTokenClaims.set(json, claims); } if (recognizedTokenTypes?.[json.token_type] !== undefined) { recognizedTokenTypes[json.token_type](response, json); } else if (json.token_type !== 'dpop' && json.token_type !== 'bearer') { throw new UnsupportedOperationError('unsupported `token_type` value', { cause: { body: json } }); } return json; } function checkAuthenticationChallenges(response) { let challenges; if (challenges = parseWwwAuthenticateChallenges(response)) { throw new WWWAuthenticateChallengeError('server responded with a challenge in the WWW-Authenticate HTTP Header', { cause: challenges, response }); } } async function processRefreshTokenResponse(as, client, response, options) { return processGenericAccessTokenResponse(as, client, response, undefined, options?.[jweDecrypt], options?.recognizedTokenTypes); } function validateOptionalAudience(expected, result) { if (result.claims.aud !== undefined) { return validateAudience(expected, result); } return result; } function validateAudience(expected, result) { if (Array.isArray(result.claims.aud)) { if (!result.claims.aud.includes(expected)) { throw OPE('unexpected JWT "aud" (audience) claim value', JWT_CLAIM_COMPARISON, { expected, claims: result.claims, claim: 'aud' }); } } else if (result.claims.aud !== expected) { throw OPE('unexpected JWT "aud" (audience) claim value', JWT_CLAIM_COMPARISON, { expected, claims: result.claims, claim: 'aud' }); } return result; } function validateOptionalIssuer(as, result) { if (result.claims.iss !== undefined) { return validateIssuer(as, result); } return result; } function validateIssuer(as, result) { const expected = as[_expectedIssuer]?.(result) ?? as.issuer; if (result.claims.iss !== expected) { throw OPE('unexpected JWT "iss" (issuer) claim value', JWT_CLAIM_COMPARISON, { expected, claims: result.claims, claim: 'iss' }); } return result; } const branded = new WeakSet(); function brand(searchParams) { branded.add(searchParams); return searchParams; } const nopkce = Symbol(); async function authorizationCodeGrantRequest(as, client, clientAuthentication, callbackParameters, redirectUri, codeVerifier, options) { assertAs(as); assertClient(client); if (!branded.has(callbackParameters)) { throw CodedTypeError('"callbackParameters" must be an instance of URLSearchParams obtained from "validateAuthResponse()", or "validateJwtAuthResponse()', ERR_INVALID_ARG_VALUE); } assertString(redirectUri, '"redirectUri"'); const code = getURLSearchParameter(callbackParameters, 'code'); if (!code) { throw OPE('no authorization code in "callbackParameters"', INVALID_RESPONSE); } const parameters = new URLSearchParams(options?.additionalParameters); parameters.set('redirect_uri', redirectUri); parameters.set('code', code); if (codeVerifier !== nopkce) { assertString(codeVerifier, '"codeVerifier"'); parameters.set('code_verifier', codeVerifier); } return tokenEndpointRequest(as, client, clientAuthentication, 'authorization_code', parameters, options); } const jwtClaimNames = { aud: 'audience', c_hash: 'code hash', client_id: 'client id', exp: 'expiration time', iat: 'issued at', iss: 'issuer', jti: 'jwt id', nonce: 'nonce', s_hash: 'state hash', sub: 'subject', ath: 'access token hash', htm: 'http method', htu: 'http uri', cnf: 'confirmation', auth_time: 'authentication time' }; function validatePresence(required, result) { for (const claim of required){ if (result.claims[claim] === undefined) { throw OPE(`JWT "${claim}" (${jwtClaimNames[claim]}) claim missing`, INVALID_RESPONSE, { claims: result.claims }); } } return result; } const expectNoNonce = Symbol(); const skipAuthTimeCheck = Symbol(); async function processAuthorizationCodeResponse(as, client, response, options) { if (typeof options?.expectedNonce === 'string' || typeof options?.maxAge === 'number' || options?.requireIdToken) { return processAuthorizationCodeOpenIDResponse(as, client, response, options.expectedNonce, options.maxAge, options[jweDecrypt], options.recognizedTokenTypes); } return processAuthorizationCodeOAuth2Response(as, client, response, options?.[jweDecrypt], options?.recognizedTokenTypes); } async function processAuthorizationCodeOpenIDResponse(as, client, response, expectedNonce, maxAge, decryptFn, recognizedTokenTypes) { const additionalRequiredClaims = []; switch(expectedNonce){ case undefined: expectedNonce = expectNoNonce; break; case expectNoNonce: break; default: assertString(expectedNonce, '"expectedNonce" argument'); additionalRequiredClaims.push('nonce'); } maxAge ??= client.default_max_age; switch(maxAge){ case undefined: maxAge = skipAuthTimeCheck; break; case skipAuthTimeCheck: break; default: assertNumber(maxAge, true, '"maxAge" argument'); additionalRequiredClaims.push('auth_time'); } const result = await processGenericAccessTokenResponse(as, client, response, additionalRequiredClaims, decryptFn, recognizedTokenTypes); assertString(result.id_token, '"response" body "id_token" property', INVALID_RESPONSE, { body: result }); const claims = getValidatedIdTokenClaims(result); if (maxAge !== skipAuthTimeCheck) { const now = epochTime() + getClockSkew(client); const tolerance = getClockTolerance(client); if (claims.auth_time + maxAge < now - tolerance) { throw OPE('too much time has elapsed since the last End-User authentication', JWT_TIMESTAMP_CHECK, { claims, now, tolerance, claim: 'auth_time' }); } } if (expectedNonce === expectNoNonce) { if (claims.nonce !== undefined) { throw OPE('unexpected ID Token "nonce" claim value', JWT_CLAIM_COMPARISON, { expected: undefined, claims, claim: 'nonce' }); } } else if (claims.nonce !== expectedNonce) { throw OPE('unexpected ID Token "nonce" claim value', JWT_CLAIM_COMPARISON, { expected: expectedNonce, claims, claim: 'nonce' }); } return result; } async function processAuthorizationCodeOAuth2Response(as, client, response, decryptFn, recognizedTokenTypes) { const result = await processGenericAccessTokenResponse(as, client, response, undefined, decryptFn, recognizedTokenTypes); const claims = getValidatedIdTokenClaims(result); if (claims) { if (client.default_max_age !== undefined) { assertNumber(client.default_max_age, true, '"client.default_max_age"'); const now = epochTime() + getClockSkew(client); const tolerance = getClockTolerance(client); if (claims.auth_time + client.default_max_age < now - tolerance) { throw OPE('too much time has elapsed since the last End-User authentication', JWT_TIMESTAMP_CHECK, { claims, now, tolerance, claim: 'auth_time' }); } } if (claims.nonce !== undefined) { throw OPE('unexpected ID Token "nonce" claim value', JWT_CLAIM_COMPARISON, { expected: undefined, claims, claim: 'nonce' }); } } return result; } const WWW_AUTHENTICATE_CHALLENGE = 'OAUTH_WWW_AUTHENTICATE_CHALLENGE'; const RESPONSE_BODY_ERROR = 'OAUTH_RESPONSE_BODY_ERROR'; const UNSUPPORTED_OPERATION = 'OAUTH_UNSUPPORTED_OPERATION'; const AUTHORIZATION_RESPONSE_ERROR = 'OAUTH_AUTHORIZATION_RESPONSE_ERROR'; const JWT_USERINFO_EXPECTED = 'OAUTH_JWT_USERINFO_EXPECTED'; const PARSE_ERROR = 'OAUTH_PARSE_ERROR'; const INVALID_RESPONSE = 'OAUTH_INVALID_RESPONSE'; const INVALID_REQUEST = 'OAUTH_INVALID_REQUEST'; const RESPONSE_IS_NOT_JSON = 'OAUTH_RESPONSE_IS_NOT_JSON'; const RESPONSE_IS_NOT_CONFORM = 'OAUTH_RESPONSE_IS_NOT_CONFORM'; const HTTP_REQUEST_FORBIDDEN = 'OAUTH_HTTP_REQUEST_FORBIDDEN'; const REQUEST_PROTOCOL_FORBIDDEN = 'OAUTH_REQUEST_PROTOCOL_FORBIDDEN'; const JWT_TIMESTAMP_CHECK = 'OAUTH_JWT_TIMESTAMP_CHECK_FAILED'; const JWT_CLAIM_COMPARISON = 'OAUTH_JWT_CLAIM_COMPARISON_FAILED'; const JSON_ATTRIBUTE_COMPARISON = 'OAUTH_JSON_ATTRIBUTE_COMPARISON_FAILED'; const KEY_SELECTION = 'OAUTH_KEY_SELECTION_FAILED'; const MISSING_SERVER_METADATA = 'OAUTH_MISSING_SERVER_METADATA'; const INVALID_SERVER_METADATA = 'OAUTH_INVALID_SERVER_METADATA'; function checkJwtType(expected, result) { if (typeof result.header.typ !== 'string' || normalizeTyp(result.header.typ) !== expected) { throw OPE('unexpected JWT "typ" header parameter value', INVALID_RESPONSE, { header: result.header }); } return result; } async function clientCredentialsGrantRequest(as, client, clientAuthentication, parameters, options) { assertAs(as); assertClient(client); return tokenEndpointRequest(as, client, clientAuthentication, 'client_credentials', new URLSearchParams(parameters), options); } async function genericTokenEndpointRequest(as, client, clientAuthentication, grantType, parameters, options) { assertAs(as); assertClient(client); assertString(grantType, '"grantType"'); return tokenEndpointRequest(as, client, clientAuthentication, grantType, new URLSearchParams(parameters), options); } async function processGenericTokenEndpointResponse(as, client, response, options) { return processGenericAccessTokenResponse(as, client, response, undefined, options?.[jweDecrypt], options?.recognizedTokenTypes); } async function processClientCredentialsResponse(as, client, response, options) { return processGenericAccessTokenResponse(as, client, response, undefined, options?.[jweDecrypt], options?.recognizedTokenTypes); } async function revocationRequest(as, client, clientAuthentication, token, options) { assertAs(as); assertClient(client); assertString(token, '"token"'); const url = resolveEndpoint(as, 'revocation_endpoint', client.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true); const body = new URLSearchParams(options?.additionalParameters); body.set('token', token); const headers = prepareHeaders(options?.headers); headers.delete('accept'); return authenticatedRequest(as, client, clientAuthentication, url, body, headers, options); } async function processRevocationResponse(response) { if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } await checkOAuthBodyError(response, 200, 'Revocation Endpoint'); return undefined; } function assertReadableResponse(response) { if (response.bodyUsed) { throw CodedTypeError('"response" body has been used already', ERR_INVALID_ARG_VALUE); } } async function introspectionRequest(as, client, clientAuthentication, token, options) { assertAs(as); assertClient(client); assertString(token, '"token"'); const url = resolveEndpoint(as, 'introspection_endpoint', client.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true); const body = new URLSearchParams(options?.additionalParameters); body.set('token', token); const headers = prepareHeaders(options?.headers); if (options?.requestJwtResponse ?? client.introspection_signed_response_alg) { headers.set('accept', 'application/token-introspection+jwt'); } else { headers.set('accept', 'application/json'); } return authenticatedRequest(as, client, clientAuthentication, url, body, headers, options); } async function processIntrospectionResponse(as, client, response, options) { assertAs(as); assertClient(client); if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } await checkOAuthBodyError(response, 200, 'Introspection Endpoint'); let json; if (getContentType(response) === 'application/token-introspection+jwt') { assertReadableResponse(response); const { claims, jwt } = await validateJwt(await response.text(), checkSigningAlgorithm.bind(undefined, client.introspection_signed_response_alg, as.introspection_signing_alg_values_supported, 'RS256'), getClockSkew(client), getClockTolerance(client), options?.[jweDecrypt]).then(checkJwtType.bind(undefined, 'token-introspection+jwt')).then(validatePresence.bind(undefined, [ 'aud', 'iat', 'iss' ])).then(validateIssuer.bind(undefined, as)).then(validateAudience.bind(undefined, client.client_id)); jwtRefs.set(response, jwt); if (!isJsonObject(claims.token_introspection)) { throw OPE('JWT "token_introspection" claim must be a JSON object', INVALID_RESPONSE, { claims }); } json = claims.token_introspection; } else { assertReadableResponse(response); json = await getResponseJsonBody(response); } if (typeof json.active !== 'boolean') { throw OPE('"response" body "active" property must be a boolean', INVALID_RESPONSE, { body: json }); } return json; } async function jwksRequest(as, options) { assertAs(as); const url = resolveEndpoint(as, 'jwks_uri', false, options?.[allowInsecureRequests] !== true); const headers = prepareHeaders(options?.headers); headers.set('accept', 'application/json'); headers.append('accept', 'application/jwk-set+json'); return (options?.[customFetch] || fetch)(url.href, { body: undefined, headers: Object.fromEntries(headers.entries()), method: 'GET', redirect: 'manual', signal: signal(url, options?.signal) }); } async function processJwksResponse(response) { if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } if (response.status !== 200) { throw OPE('"response" is not a conform JSON Web Key Set response (unexpected HTTP status code)', RESPONSE_IS_NOT_CONFORM, response); } assertReadableResponse(response); const json = await getResponseJsonBody(response, (response)=>assertContentTypes(response, 'application/json', 'application/jwk-set+json')); if (!Array.isArray(json.keys)) { throw OPE('"response" body "keys" property must be an array', INVALID_RESPONSE, { body: json }); } if (!Array.prototype.every.call(json.keys, isJsonObject)) { throw OPE('"response" body "keys" property members must be JWK formatted objects', INVALID_RESPONSE, { body: json }); } return json; } function supported(alg) { switch(alg){ case 'PS256': case 'ES256': case 'RS256': case 'PS384': case 'ES384': case 'RS384': case 'PS512': case 'ES512': case 'RS512': case 'Ed25519': case 'EdDSA': case 'ML-DSA-44': case 'ML-DSA-65': case 'ML-DSA-87': return true; default: return false; } } function checkSupportedJwsAlg(header) { if (!supported(header.alg)) { throw new UnsupportedOperationError('unsupported JWS "alg" identifier', { cause: { alg: header.alg } }); } } function checkRsaKeyAlgorithm(key) { const { algorithm } = key; if (typeof algorithm.modulusLength !== 'number' || algorithm.modulusLength < 2048) { throw new UnsupportedOperationError(`unsupported ${algorithm.name} modulusLength`, { cause: key }); } } function ecdsaHashName(key) { const { algorithm } = key; switch(algorithm.namedCurve){ case 'P-256': return 'SHA-256'; case 'P-384': return 'SHA-384'; case 'P-521': return 'SHA-512'; default: throw new UnsupportedOperationError('unsupported ECDSA namedCurve', { cause: key }); } } function keyToSubtle(key) { switch(key.algorithm.name){ case 'ECDSA': return { name: key.algorithm.name, hash: ecdsaHashName(key) }; case 'RSA-PSS': { checkRsaKeyAlgorithm(key); switch(key.algorithm.hash.name){ case 'SHA-256': case 'SHA-384': case 'SHA-512': return { name: key.algorithm.name, saltLength: parseInt(key.algorithm.hash.name.slice(-3), 10) >> 3 }; default: throw new UnsupportedOperationError('unsupported RSA-PSS hash name', { cause: key }); } } case 'RSASSA-PKCS1-v1_5': checkRsaKeyAlgorithm(key); return key.algorithm.name; case 'ML-DSA-44': case 'ML-DSA-65': case 'ML-DSA-87': case 'Ed25519': return key.algorithm.name; } throw new UnsupportedOperationError('unsupported CryptoKey algorithm name', { cause: key }); } async function validateJwsSignature(protectedHeader, payload, key, signature) { const data = buf(`${protectedHeader}.${payload}`); const algorithm = keyToSubtle(key); const verified = await crypto.subtle.verify(algorithm, key, signature, data); if (!verified) { throw OPE('JWT signature verification failed', INVALID_RESPONSE, { key, data, signature, algorithm }); } } async function validateJwt(jws, checkAlg, clockSkew, clockTolerance, decryptJwt) { let { 0: protectedHeader, 1: payload, length } = jws.split('.'); if (length === 5) { if (decryptJwt !== undefined) { jws = await decryptJwt(jws); ({ 0: protectedHeader, 1: payload, length } = jws.split('.')); } else { throw new UnsupportedOperationError('JWE decryption is not configured', { cause: jws }); } } if (length !== 3) { throw OPE('Invalid JWT', INVALID_RESPONSE, jws); } let header; try { header = JSON.parse(buf(b64u(protectedHeader))); } catch (cause) { throw OPE('failed to parse JWT Header body as base64url encoded JSON', PARSE_ERROR, cause); } if (!isJsonObject(header)) { throw OPE('JWT Header must be a top level object', INVALID_RESPONSE, jws); } checkAlg(header); if (header.crit !== undefined) { throw new UnsupportedOperationError('no JWT "crit" header parameter extensions are supported', { cause: { header } }); } let claims; try { claims = JSON.parse(buf(b64u(payload))); } catch (cause) { throw OPE('failed to parse JWT Payload body as base64url encoded JSON', PARSE_ERROR, cause); } if (!isJsonObject(claims)) { throw OPE('JWT Payload must be a top level object', INVALID_RESPONSE, jws); } const now = epochTime() + clockSkew; if (claims.exp !== undefined) { if (typeof claims.exp !== 'number') { throw OPE('unexpected JWT "exp" (expiration time) claim type', INVALID_RESPONSE, { claims }); } if (claims.exp <= now - clockTolerance) { throw OPE('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp', JWT_TIMESTAMP_CHECK, { claims, now, tolerance: clockTolerance, claim: 'exp' }); } } if (claims.iat !== undefined) { if (typeof claims.iat !== 'number') { throw OPE('unexpected JWT "iat" (issued at) claim type', INVALID_RESPONSE, { claims }); } } if (claims.iss !== undefined) { if (typeof claims.iss !== 'string') { throw OPE('unexpected JWT "iss" (issuer) claim type', INVALID_RESPONSE, { claims }); } } if (claims.nbf !== undefined) { if (typeof claims.nbf !== 'number') { throw OPE('unexpected JWT "nbf" (not before) claim type', INVALID_RESPONSE, { claims }); } if (claims.nbf > now + clockTolerance) { throw OPE('unexpected JWT "nbf" (not before) claim value', JWT_TIMESTAMP_CHECK, { claims, now, tolerance: clockTolerance, claim: 'nbf' }); } } if (claims.aud !== undefined) { if (typeof claims.aud !== 'string' && !Array.isArray(claims.aud)) { throw OPE('unexpected JWT "aud" (audience) claim type', INVALID_RESPONSE, { claims }); } } return { header, claims, jwt: jws }; } async function validateJwtAuthResponse(as, client, parameters, expectedState, options) { assertAs(as); assertClient(client); if (parameters instanceof URL) { parameters = parameters.searchParams; } if (!(parameters instanceof URLSearchParams)) { throw CodedTypeError('"parameters" must be an instance of URLSearchParams, or URL', ERR_INVALID_ARG_TYPE); } const response = getURLSearchParameter(parameters, 'response'); if (!response) { throw OPE('"parameters" does not contain a JARM response', INVALID_RESPONSE); } const { claims, header, jwt } = await validateJwt(response, checkSigningAlgorithm.bind(undefined, client.authorization_signed_response_alg, as.authorization_signing_alg_values_supported, 'RS256'), getClockSkew(client), getClockTolerance(client), options?.[jweDecrypt]).then(validatePresence.bind(undefined, [ 'aud', 'exp', 'iss' ])).then(validateIssuer.bind(undefined, as)).then(validateAudience.bind(undefined, client.client_id)); const { 0: protectedHeader, 1: payload, 2: encodedSignature } = jwt.split('.'); const signature = b64u(encodedSignature); const key = await getPublicSigKeyFromIssuerJwksUri(as, options, header); await validateJwsSignature(protectedHeader, payload, key, signature); const result = new URLSearchParams(); for (const [key, value] of Object.entries(claims)){ if (typeof value === 'string' && key !== 'aud') { result.set(key, value); } } return validateAuthResponse(as, client, result, expectedState); } async function idTokenHash(data, header, claimName) { let algorithm; switch(header.alg){ case 'RS256': case 'PS256': case 'ES256': algorithm = 'SHA-256'; break; case 'RS384': case 'PS384': case 'ES384': algorithm = 'SHA-384'; break; case 'RS512': case 'PS512': case 'ES512': case 'Ed25519': case 'EdDSA': algorithm = 'SHA-512'; break; case 'ML-DSA-44': case 'ML-DSA-65': case 'ML-DSA-87': algorithm = { name: 'cSHAKE256', length: 512, outputLength: 512 }; break; default: throw new UnsupportedOperationError(`unsupported JWS algorithm for ${claimName} calculation`, { cause: { alg: header.alg } }); } const digest = await crypto.subtle.digest(algorithm, buf(data)); return b64u(digest.slice(0, digest.byteLength / 2)); } async function idTokenHashMatches(data, actual, header, claimName) { const expected = await idTokenHash(data, header, claimName); return actual === expected; } async function validateDetachedSignatureResponse(as, client, parameters, expectedNonce, expectedState, maxAge, options) { return validateHybridResponse(as, client, parameters, expectedNonce, expectedState, maxAge, options, true); } async function validateCodeIdTokenResponse(as, client, parameters, expectedNonce, expectedState, maxAge, options) { return validateHybridResponse(as, client, parameters, expectedNonce, expectedState, maxAge, options, false); } async function consumeStream(request) { if (request.bodyUsed) { throw CodedTypeError('form_post Request instances must contain a readable body', ERR_INVALID_ARG_VALUE, { cause: request }); } return request.text(); } async function formPostResponse(request) { if (request.method !== 'POST') { throw CodedTypeError('form_post responses are expected to use the POST method', ERR_INVALID_ARG_VALUE, { cause: request }); } if (getContentType(request) !== 'application/x-www-form-urlencoded') { throw CodedTypeError('form_post responses are expected to use the application/x-www-form-urlencoded content-type', ERR_INVALID_ARG_VALUE, { cause: request }); } return consumeStream(request); } async function validateHybridResponse(as, client, parameters, expectedNonce, expectedState, maxAge, options, fapi) { assertAs(as); assertClient(client); if (parameters instanceof URL) { if (!parameters.hash.length) { throw CodedTypeError('"parameters" as an instance of URL must contain a hash (fragment) with the Authorization Response parameters', ERR_INVALID_ARG_VALUE); } parameters = new URLSearchParams(parameters.hash.slice(1)); } else if (looseInstanceOf(parameters, Request)) { parameters = new URLSearchParams(await formPostResponse(parameters)); } else if (parameters instanceof URLSearchParams) { parameters = new URLSearchParams(parameters); } else { throw CodedTypeError('"parameters" must be an instance of URLSearchParams, URL, or Response', ERR_INVALID_ARG_TYPE); } const id_token = getURLSearchParameter(parameters, 'id_token'); parameters.delete('id_token'); switch(expectedState){ case undefined: case expectNoState: break; default: assertString(expectedState, '"expectedState" argument'); } const result = validateAuthResponse({ ...as, authorization_response_iss_parameter_supported: false }, client, parameters, expectedState); if (!id_token) { throw OPE('"parameters" does not contain an ID Token', INVALID_RESPONSE); } const code = getURLSearchParameter(parameters, 'code'); if (!code) { throw OPE('"parameters" does not contain an Authorization Code', INVALID_RESPONSE); } const requiredClaims = [ 'aud', 'exp', 'iat', 'iss', 'sub', 'nonce', 'c_hash' ]; const state = parameters.get('state'); if (fapi && (typeof expectedState === 'string' || state !== null)) { requiredClaims.push('s_hash'); } if (maxAge !== undefined) { assertNumber(maxAge, true, '"maxAge" argument'); } else if (client.default_max_age !== undefined) { assertNumber(client.default_max_age, true, '"client.default_max_age"'); } maxAge ??= client.default_max_age ?? skipAuthTimeCheck; if (client.require_auth_time || maxAge !== skipAuthTimeCheck) { requiredClaims.push('auth_time'); } const { claims, header, jwt } = await validateJwt(id_token, checkSigningAlgorithm.bind(undefined, client.id_token_signed_response_alg, as.id_token_signing_alg_values_supported, 'RS256'), getClockSkew(client), getClockTolerance(client), options?.[jweDecrypt]).then(validatePresence.bind(undefined, requiredClaims)).then(validateIssuer.bind(undefined, as)).then(validateAudience.bind(undefined, client.client_id)); const clockSkew = getClockSkew(client); const now = epochTime() + clockSkew; if (claims.iat < now - 3600) { throw OPE('unexpected JWT "iat" (issued at) claim value, it is too far in the past', JWT_TIMESTAMP_CHECK, { now, claims, claim: 'iat' }); } assertString(claims.c_hash, 'ID Token "c_hash" (code hash) claim value', INVALID_RESPONSE, { claims }); if (claims.auth_time !== undefined) { assertNumber(claims.auth_time, true, 'ID Token "auth_time" (authentication time)', INVALID_RESPONSE, { claims }); } if (maxAge !== skipAuthTimeCheck) { const now = epochTime() + getClockSkew(client); const tolerance = getClockTolerance(client); if (claims.auth_time + maxAge < now - tolerance) { throw OPE('too much time has elapsed since the last End-User authentication', JWT_TIMESTAMP_CHECK, { claims, now, tolerance, claim: 'auth_time' }); } } assertString(expectedNonce, '"expectedNonce" argument'); if (claims.nonce !== expectedNonce) { throw OPE('unexpected ID Token "nonce" claim value', JWT_CLAIM_COMPARISON, { expected: expectedNonce, claims, claim: 'nonce' }); } if (Array.isArray(claims.aud) && claims.aud.length !== 1) { if (claims.azp === undefined) { throw OPE('ID Token "aud" (audience) claim includes additional untrusted audiences', JWT_CLAIM_COMPARISON, { claims, claim: 'aud' }); } if (claims.azp !== client.client_id) { throw OPE('unexpected ID Token "azp" (authorized party) claim value', JWT_CLAIM_COMPARISON, { expected: client.client_id, claims, claim: 'azp' }); } } const { 0: protectedHeader, 1: payload, 2: encodedSignature } = jwt.split('.'); const signature = b64u(encodedSignature); const key = await getPublicSigKeyFromIssuerJwksUri(as, options, header); await validateJwsSignature(protectedHeader, payload, key, signature); if (await idTokenHashMatches(code, claims.c_hash, header, 'c_hash') !== true) { throw OPE('invalid ID Token "c_hash" (code hash) claim value', JWT_CLAIM_COMPARISON, { code, alg: header.alg, claim: 'c_hash', claims }); } if (fapi && state !== null || claims.s_hash !== undefined) { assertString(claims.s_hash, 'ID Token "s_hash" (state hash) claim value', INVALID_RESPONSE, { claims }); assertString(state, '"state" response parameter', INVALID_RESPONSE, { parameters }); if (await idTokenHashMatches(state, claims.s_hash, header, 's_hash') !== true) { throw OPE('invalid ID Token "s_hash" (state hash) claim value', JWT_CLAIM_COMPARISON, { state, alg: header.alg, claim: 's_hash', claims }); } } return result; } function checkSigningAlgorithm(client, issuer, fallback, header) { if (client !== undefined) { if (typeof client === 'string' ? header.alg !== client : !client.includes(header.alg)) { throw OPE('unexpected JWT "alg" header parameter', INVALID_RESPONSE, { header, expected: client, reason: 'client configuration' }); } return; } if (Array.isArray(issuer)) { if (!issuer.includes(header.alg)) { throw OPE('unexpected JWT "alg" header parameter', INVALID_RESPONSE, { header, expected: issuer, reason: 'authorization server metadata' }); } return; } if (fallback !== undefined) { if (typeof fallback === 'string' ? header.alg !== fallback : typeof fallback === 'function' ? !fallback(header.alg) : !fallback.includes(header.alg)) { throw OPE('unexpected JWT "alg" header parameter', INVALID_RESPONSE, { header, expected: fallback, reason: 'default value' }); } return; } throw OPE('missing client or server configuration to verify used JWT "alg" header parameter', undefined, { client, issuer, fallback }); } function getURLSearchParameter(parameters, name) { const { 0: value, length } = parameters.getAll(name); if (length > 1) { throw OPE(`"${name}" parameter must be provided only once`, INVALID_RESPONSE); } return value; } const skipStateCheck = Symbol(); const expectNoState = Symbol(); function validateAuthResponse(as, client, parameters, expectedState) { assertAs(as); assertClient(client); if (parameters instanceof URL) { parameters = parameters.searchParams; } if (!(parameters instanceof URLSearchParams)) { throw CodedTypeError('"parameters" must be an instance of URLSearchParams, or URL', ERR_INVALID_ARG_TYPE); } if (getURLSearchParameter(parameters, 'response')) { throw OPE('"parameters" contains a JARM response, use validateJwtAuthResponse() instead of validateAuthResponse()', INVALID_RESPONSE, { parameters }); } const iss = getURLSearchParameter(parameters, 'iss'); const state = getURLSearchParameter(parameters, 'state'); if (!iss && as.authorization_response_iss_parameter_supported) { throw OPE('response parameter "iss" (issuer) missing', INVALID_RESPONSE, { parameters }); } if (iss && iss !== as.issuer) { throw OPE('unexpected "iss" (issuer) response parameter value', INVALID_RESPONSE, { expected: as.issuer, parameters }); } switch(expectedState){ case undefined: case expectNoState: if (state !== undefined) { throw OPE('unexpected "state" response parameter encountered', INVALID_RESPONSE, { expected: undefined, parameters }); } break; case skipStateCheck: break; default: assertString(expectedState, '"expectedState" argument'); if (state !== expectedState) { throw OPE(state === undefined ? 'response parameter "state" missing' : 'unexpected "state" response parameter value', INVALID_RESPONSE, { expected: expectedState, parameters }); } } const error = getURLSearchParameter(parameters, 'error'); if (error) { throw new AuthorizationResponseError('authorization response from the server is an error', { cause: parameters }); } const id_token = getURLSearchParameter(parameters, 'id_token'); const token = getURLSearchParameter(parameters, 'token'); if (id_token !== undefined || token !== undefined) { throw new UnsupportedOperationError('implicit and hybrid flows are not supported'); } return brand(new URLSearchParams(parameters)); } function algToSubtle(alg) { switch(alg){ case 'PS256': case 'PS384': case 'PS512': return { name: 'RSA-PSS', hash: `SHA-${alg.slice(-3)}` }; case 'RS256': case 'RS384': case 'RS512': return { name: 'RSASSA-PKCS1-v1_5', hash: `SHA-${alg.slice(-3)}` }; case 'ES256': case 'ES384': return { name: 'ECDSA', namedCurve: `P-${alg.slice(-3)}` }; case 'ES512': return { name: 'ECDSA', namedCurve: 'P-521' }; case 'EdDSA': return 'Ed25519'; case 'Ed25519': case 'ML-DSA-44': case 'ML-DSA-65': case 'ML-DSA-87': return alg; default: throw new UnsupportedOperationError('unsupported JWS algorithm', { cause: { alg } }); } } async function importJwk(alg, jwk) { const { ext, key_ops, use, ...key } = jwk; return crypto.subtle.importKey('jwk', key, algToSubtle(alg), true, [ 'verify' ]); } async function deviceAuthorizationRequest(as, client, clientAuthentication, parameters, options) { assertAs(as); assertClient(client); const url = resolveEndpoint(as, 'device_authorization_endpoint', client.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true); const body = new URLSearchParams(parameters); body.set('client_id', client.client_id); const headers = prepareHeaders(options?.headers); headers.set('accept', 'application/json'); return authenticatedRequest(as, client, clientAuthentication, url, body, headers, options); } async function processDeviceAuthorizationResponse(as, client, response) { assertAs(as); assertClient(client); if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } await checkOAuthBodyError(response, 200, 'Device Authorization Endpoint'); assertReadableResponse(response); const json = await getResponseJsonBody(response); assertString(json.device_code, '"response" body "device_code" property', INVALID_RESPONSE, { body: json }); assertString(json.user_code, '"response" body "user_code" property', INVALID_RESPONSE, { body: json }); assertString(json.verification_uri, '"response" body "verification_uri" property', INVALID_RESPONSE, { body: json }); let expiresIn = typeof json.expires_in !== 'number' ? parseFloat(json.expires_in) : json.expires_in; assertNumber(expiresIn, true, '"response" body "expires_in" property', INVALID_RESPONSE, { body: json }); json.expires_in = expiresIn; if (json.verification_uri_complete !== undefined) { assertString(json.verification_uri_complete, '"response" body "verification_uri_complete" property', INVALID_RESPONSE, { body: json }); } if (json.interval !== undefined) { assertNumber(json.interval, false, '"response" body "interval" property', INVALID_RESPONSE, { body: json }); } return json; } async function deviceCodeGrantRequest(as, client, clientAuthentication, deviceCode, options) { assertAs(as); assertClient(client); assertString(deviceCode, '"deviceCode"'); const parameters = new URLSearchParams(options?.additionalParameters); parameters.set('device_code', deviceCode); return tokenEndpointRequest(as, client, clientAuthentication, 'urn:ietf:params:oauth:grant-type:device_code', parameters, options); } async function processDeviceCodeResponse(as, client, response, options) { return processGenericAccessTokenResponse(as, client, response, undefined, options?.[jweDecrypt], options?.recognizedTokenTypes); } async function generateKeyPair(alg, options) { assertString(alg, '"alg"'); const algorithm = algToSubtle(alg); if (alg.startsWith('PS') || alg.startsWith('RS')) { Object.assign(algorithm, { modulusLength: options?.modulusLength ?? 2048, publicExponent: new Uint8Array([ 0x01, 0x00, 0x01 ]) }); } return crypto.subtle.generateKey(algorithm, options?.extractable ?? false, [ 'sign', 'verify' ]); } function normalizeHtu(htu) { const url = new URL(htu); url.search = ''; url.hash = ''; return url.href; } async function validateDPoP(request, accessToken, accessTokenClaims, options) { const headerValue = request.headers.get('dpop'); if (headerValue === null) { throw OPE('operation indicated DPoP use but the request has no DPoP HTTP Header', INVALID_REQUEST, { headers: request.headers }); } if (request.headers.get('authorization')?.toLowerCase().startsWith('dpop ') === false) { throw OPE(`operation indicated DPoP use but the request's Authorization HTTP Header scheme is not DPoP`, INVALID_REQUEST, { headers: request.headers }); } if (typeof accessTokenClaims.cnf?.jkt !== 'string') { throw OPE('operation indicated DPoP use but the JWT Access Token has no jkt confirmation claim', INVALID_REQUEST, { claims: accessTokenClaims }); } const clockSkew = getClockSkew(options); const proof = await validateJwt(headerValue, checkSigningAlgorithm.bind(undefined, options?.signingAlgorithms, undefined, supported), clockSkew, getClockTolerance(options), undefined).then(checkJwtType.bind(undefined, 'dpop+jwt')).then(validatePresence.bind(undefined, [ 'iat', 'jti', 'ath', 'htm', 'htu' ])); const now = epochTime() + clockSkew; const diff = Math.abs(now - proof.claims.iat); if (diff > 300) { throw OPE('DPoP Proof iat is not recent enough', JWT_TIMESTAMP_CHECK, { now, claims: proof.claims, claim: 'iat' }); } if (proof.claims.htm !== request.method) { throw OPE('DPoP Proof htm mismatch', JWT_CLAIM_COMPARISON, { expected: request.method, claims: proof.claims, claim: 'htm' }); } if (typeof proof.claims.htu !== 'string' || normalizeHtu(proof.claims.htu) !== normalizeHtu(request.url)) { throw OPE('DPoP Proof htu mismatch', JWT_CLAIM_COMPARISON, { expected: normalizeHtu(request.url), claims: proof.claims, claim: 'htu' }); } { const expected = b64u(await crypto.subtle.digest('SHA-256', buf(accessToken))); if (proof.claims.ath !== expected) { throw OPE('DPoP Proof ath mismatch', JWT_CLAIM_COMPARISON, { expected, claims: proof.claims, claim: 'ath' }); } } { const expected = await calculateJwkThumbprint(proof.header.jwk); if (accessTokenClaims.cnf.jkt !== expected) { throw OPE('JWT Access Token confirmation mismatch', JWT_CLAIM_COMPARISON, { expected, claims: accessTokenClaims, claim: 'cnf.jkt' }); } } const { 0: protectedHeader, 1: payload, 2: encodedSignature } = headerValue.split('.'); const signature = b64u(encodedSignature); const { jwk, alg } = proof.header; if (!jwk) { throw OPE('DPoP Proof is missing the jwk header parameter', INVALID_REQUEST, { header: proof.header }); } const key = await importJwk(alg, jwk); if (key.type !== 'public') { throw OPE('DPoP Proof jwk header parameter must contain a public key', INVALID_REQUEST, { header: proof.header }); } await validateJwsSignature(protectedHeader, payload, key, signature); } async function validateJwtAccessToken(as, request, expectedAudience, options) { assertAs(as); if (!looseInstanceOf(request, Request)) { throw CodedTypeError('"request" must be an instance of Request', ERR_INVALID_ARG_TYPE); } assertString(expectedAudience, '"expectedAudience"'); const authorization = request.headers.get('authorization'); if (authorization === null) { throw OPE('"request" is missing an Authorization HTTP Header', INVALID_REQUEST, { headers: request.headers }); } let { 0: scheme, 1: accessToken, length } = authorization.split(' '); scheme = scheme.toLowerCase(); switch(scheme){ case 'dpop': case 'bearer': break; default: throw new UnsupportedOperationError('unsupported Authorization HTTP Header scheme', { cause: { headers: request.headers } }); } if (length !== 2) { throw OPE('invalid Authorization HTTP Header format', INVALID_REQUEST, { headers: request.headers }); } const requiredClaims = [ 'iss', 'exp', 'aud', 'sub', 'iat', 'jti', 'client_id' ]; if (options?.requireDPoP || scheme === 'dpop' || request.headers.has('dpop')) { requiredClaims.push('cnf'); } const { claims, header } = await validateJwt(accessToken, checkSigningAlgorithm.bind(undefined, options?.signingAlgorithms, undefined, supported), getClockSkew(options), getClockTolerance(options), undefined).then(checkJwtType.bind(undefined, 'at+jwt')).then(validatePresence.bind(undefined, requiredClaims)).then(validateIssuer.bind(undefined, as)).then(validateAudience.bind(undefined, expectedAudience)).catch(reassignRSCode); for (const claim of [ 'client_id', 'jti', 'sub' ]){ if (typeof claims[claim] !== 'string') { throw OPE(`unexpected JWT "${claim}" claim type`, INVALID_REQUEST, { claims }); } } if ('cnf' in claims) { if (!isJsonObject(claims.cnf)) { throw OPE('unexpected JWT "cnf" (confirmation) claim value', INVALID_REQUEST, { claims }); } const { 0: cnf, length } = Object.keys(claims.cnf); if (length) { if (length !== 1) { throw new UnsupportedOperationError('multiple confirmation claims are not supported', { cause: { claims } }); } if (cnf !== 'jkt') { throw new UnsupportedOperationError('unsupported JWT Confirmation method', { cause: { claims } }); } } } const { 0: protectedHeader, 1: payload, 2: encodedSignature } = accessToken.split('.'); const signature = b64u(encodedSignature); const key = await getPublicSigKeyFromIssuerJwksUri(as, options, header); await validateJwsSignature(protectedHeader, payload, key, signature); if (options?.requireDPoP || scheme === 'dpop' || claims.cnf?.jkt !== undefined || request.headers.has('dpop')) { await validateDPoP(request, accessToken, claims, options).catch(reassignRSCode); } return claims; } function reassignRSCode(err) { if (err instanceof OperationProcessingError && err?.code === INVALID_REQUEST) { err.code = INVALID_RESPONSE; } throw err; } async function backchannelAuthenticationRequest(as, client, clientAuthentication, parameters, options) { assertAs(as); assertClient(client); const url = resolveEndpoint(as, 'backchannel_authentication_endpoint', client.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true); const body = new URLSearchParams(parameters); body.set('client_id', client.client_id); const headers = prepareHeaders(options?.headers); headers.set('accept', 'application/json'); return authenticatedRequest(as, client, clientAuthentication, url, body, headers, options); } async function processBackchannelAuthenticationResponse(as, client, response) { assertAs(as); assertClient(client); if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } await checkOAuthBodyError(response, 200, 'Backchannel Authentication Endpoint'); assertReadableResponse(response); const json = await getResponseJsonBody(response); assertString(json.auth_req_id, '"response" body "auth_req_id" property', INVALID_RESPONSE, { body: json }); let expiresIn = typeof json.expires_in !== 'number' ? parseFloat(json.expires_in) : json.expires_in; assertNumber(expiresIn, true, '"response" body "expires_in" property', INVALID_RESPONSE, { body: json }); json.expires_in = expiresIn; if (json.interval !== undefined) { assertNumber(json.interval, false, '"response" body "interval" property', INVALID_RESPONSE, { body: json }); } return json; } async function backchannelAuthenticationGrantRequest(as, client, clientAuthentication, authReqId, options) { assertAs(as); assertClient(client); assertString(authReqId, '"authReqId"'); const parameters = new URLSearchParams(options?.additionalParameters); parameters.set('auth_req_id', authReqId); return tokenEndpointRequest(as, client, clientAuthentication, 'urn:openid:params:grant-type:ciba', parameters, options); } async function processBackchannelAuthenticationGrantResponse(as, client, response, options) { return processGenericAccessTokenResponse(as, client, response, undefined, options?.[jweDecrypt], options?.recognizedTokenTypes); } async function dynamicClientRegistrationRequest(as, metadata, options) { assertAs(as); const url = resolveEndpoint(as, 'registration_endpoint', metadata.use_mtls_endpoint_aliases, options?.[allowInsecureRequests] !== true); const headers = prepareHeaders(options?.headers); headers.set('accept', 'application/json'); headers.set('content-type', 'application/json'); const method = 'POST'; if (options?.DPoP) { assertDPoP(options.DPoP); await options.DPoP.addProof(url, headers, method, options.initialAccessToken); } if (options?.initialAccessToken) { headers.set('authorization', `${headers.has('dpop') ? 'DPoP' : 'Bearer'} ${options.initialAccessToken}`); } const response = await (options?.[customFetch] || fetch)(url.href, { body: JSON.stringify(metadata), headers: Object.fromEntries(headers.entries()), method, redirect: 'manual', signal: signal(url, options?.signal) }); options?.DPoP?.cacheNonce(response, url); return response; } async function processDynamicClientRegistrationResponse(response) { if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } await checkOAuthBodyError(response, 201, 'Dynamic Client Registration Endpoint'); assertReadableResponse(response); const json = await getResponseJsonBody(response); assertString(json.client_id, '"response" body "client_id" property', INVALID_RESPONSE, { body: json }); if (json.client_secret !== undefined) { assertString(json.client_secret, '"response" body "client_secret" property', INVALID_RESPONSE, { body: json }); } if (json.client_secret) { assertNumber(json.client_secret_expires_at, true, '"response" body "client_secret_expires_at" property', INVALID_RESPONSE, { body: json }); } return json; } async function resourceDiscoveryRequest(resourceIdentifier, options) { return performDiscovery(resourceIdentifier, 'resourceIdentifier', (url)=>{ prependWellKnown(url, '.well-known/oauth-protected-resource', true); return url; }, options); } async function processResourceDiscoveryResponse(expectedResourceIdentifier, response) { const expected = expectedResourceIdentifier; if (!(expected instanceof URL) && expected !== _nodiscoverycheck) { throw CodedTypeError('"expectedResourceIdentifier" must be an instance of URL', ERR_INVALID_ARG_TYPE); } if (!looseInstanceOf(response, Response)) { throw CodedTypeError('"response" must be an instance of Response', ERR_INVALID_ARG_TYPE); } if (response.status !== 200) { throw OPE('"response" is not a conform Resource Server Metadata response (unexpected HTTP status code)', RESPONSE_IS_NOT_CONFORM, response); } assertReadableResponse(response); const json = await getResponseJsonBody(response); assertString(json.resource, '"response" body "resource" property', INVALID_RESPONSE, { body: json }); if (expected !== _nodiscoverycheck && new URL(json.resource).href !== expected.href) { throw OPE('"response" body "resource" property does not match the expected value', JSON_ATTRIBUTE_COMPARISON, { expected: expected.href, body: json, attribute: 'resource' }); } return json; } async function getResponseJsonBody(response, check = assertApplicationJson) { let json; try { json = await response.json(); } catch (cause) { check(response); throw OPE('failed to parse "response" body as JSON', PARSE_ERROR, cause); } if (!isJsonObject(json)) { throw OPE('"response" body must be a top level object', INVALID_RESPONSE, { body: json }); } return json; } const _nopkce = nopkce; const _nodiscoverycheck = Symbol(); const _expectedIssuer = Symbol(); //# sourceMappingURL=index.js.map }), "[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/env.js [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "reqWithEnvURL", ()=>reqWithEnvURL, "setEnvDefaults", ()=>setEnvDefaults ]); // @ts-expect-error Next.js does not yet correctly use the `package.json#exports` field var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/server.js [app-route] (ecmascript)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/index.js [app-route] (ecmascript) "); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$utils$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/lib/utils/env.js [app-route] (ecmascript)"); ; ; function reqWithEnvURL(req) { const url = process.env.AUTH_URL ?? process.env.NEXTAUTH_URL; if (!url) return req; const { origin: envOrigin } = new URL(url); const { href, origin } = req.nextUrl; return new __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["NextRequest"](href.replace(origin, envOrigin), req); } function setEnvDefaults(config) { try { config.secret ?? (config.secret = process.env.AUTH_SECRET ?? process.env.NEXTAUTH_SECRET); const url = process.env.AUTH_URL ?? process.env.NEXTAUTH_URL; if (!url) return; const { pathname } = new URL(url); if (pathname === "/") return; config.basePath || (config.basePath = pathname); } catch { // Catching and swallowing potential URL parsing errors, we'll fall // back to `/api/auth` below. } finally{ config.basePath || (config.basePath = "/api/auth"); (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$utils$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["setEnvDefaults"])(process.env, config, true); } } }), "[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/index.js [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "initAuth", ()=>initAuth ]); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/index.js [app-route] (ecmascript) "); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$utils$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/lib/utils/env.js [app-route] (ecmascript)"); // @ts-expect-error Next.js does not yet correctly use the `package.json#exports` field var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/headers.js [app-route] (ecmascript)"); // @ts-expect-error Next.js does not yet correctly use the `package.json#exports` field var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/server.js [app-route] (ecmascript)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/env.js [app-route] (ecmascript)"); ; ; ; ; async function getSession(headers, config) { const url = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$utils$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["createActionURL"])("session", // @ts-expect-error `x-forwarded-proto` is not nullable, next.js sets it by default headers.get("x-forwarded-proto"), headers, process.env, config); const request = new Request(url, { headers: { cookie: headers.get("cookie") ?? "" } }); return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["Auth"])(request, { ...config, callbacks: { ...config.callbacks, // Since we are server-side, we don't need to filter out the session data // See https://authjs.dev/getting-started/migrating-to-v5#authenticating-server-side // TODO: Taint the session data to prevent accidental leakage to the client // https://react.dev/reference/react/experimental_taintObjectReference async session (...args) { const session = // If the user defined a custom session callback, use that instead await config.callbacks?.session?.(...args) ?? { ...args[0].session, expires: args[0].session.expires?.toISOString?.() ?? args[0].session.expires }; const user = args[0].user ?? args[0].token; return { user, ...session }; } } }); } function isReqWrapper(arg) { return typeof arg === "function"; } function initAuth(config, onLazyLoad // To set the default env vars ) { if (typeof config === "function") { return async (...args)=>{ if (!args.length) { // React Server Components const _headers = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["headers"])(); const _config = await config(undefined); // Review: Should we pass headers() here instead? onLazyLoad?.(_config); return getSession(_headers, _config).then((r)=>r.json()); } if (args[0] instanceof Request) { // middleware.ts inline // export { auth as default } from "auth" const req = args[0]; const ev = args[1]; const _config = await config(req); onLazyLoad?.(_config); // args[0] is supposed to be NextRequest but the instanceof check is failing. return handleAuth([ req, ev ], _config); } if (isReqWrapper(args[0])) { // middleware.ts wrapper/route.ts // import { auth } from "auth" // export default auth((req) => { console.log(req.auth) }}) const userMiddlewareOrRoute = args[0]; return async (...args)=>{ const _config = await config(args[0]); onLazyLoad?.(_config); return handleAuth(args, _config, userMiddlewareOrRoute); }; } // API Routes, getServerSideProps const request = "req" in args[0] ? args[0].req : args[0]; const response = "res" in args[0] ? args[0].res : args[1]; const _config = await config(request); onLazyLoad?.(_config); // @ts-expect-error -- request is NextRequest return getSession(new Headers(request.headers), _config).then(async (authResponse)=>{ const auth = await authResponse.json(); for (const cookie of authResponse.headers.getSetCookie())if ("headers" in response) response.headers.append("set-cookie", cookie); else response.appendHeader("set-cookie", cookie); return auth; }); }; } return (...args)=>{ if (!args.length) { // React Server Components return Promise.resolve((0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["headers"])()).then((h)=>getSession(h, config).then((r)=>r.json())); } if (args[0] instanceof Request) { // middleware.ts inline // export { auth as default } from "auth" const req = args[0]; const ev = args[1]; return handleAuth([ req, ev ], config); } if (isReqWrapper(args[0])) { // middleware.ts wrapper/route.ts // import { auth } from "auth" // export default auth((req) => { console.log(req.auth) }}) const userMiddlewareOrRoute = args[0]; return async (...args)=>{ return handleAuth(args, config, userMiddlewareOrRoute).then((res)=>{ return res; }); }; } // API Routes, getServerSideProps const request = "req" in args[0] ? args[0].req : args[0]; const response = "res" in args[0] ? args[0].res : args[1]; return getSession(// @ts-expect-error new Headers(request.headers), config).then(async (authResponse)=>{ const auth = await authResponse.json(); for (const cookie of authResponse.headers.getSetCookie())if ("headers" in response) response.headers.append("set-cookie", cookie); else response.appendHeader("set-cookie", cookie); return auth; }); }; } async function handleAuth(args, config, userMiddlewareOrRoute) { const request = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["reqWithEnvURL"])(args[0]); const sessionResponse = await getSession(request.headers, config); const auth = await sessionResponse.json(); let authorized = true; if (config.callbacks?.authorized) { authorized = await config.callbacks.authorized({ request, auth }); } let response = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["NextResponse"].next?.(); if (authorized instanceof Response) { // User returned a custom response, like redirecting to a page or 401, respect it response = authorized; const redirect = authorized.headers.get("Location"); const { pathname } = request.nextUrl; // If the user is redirecting to the same NextAuth.js action path as the current request, // don't allow the redirect to prevent an infinite loop if (redirect && isSameAuthAction(pathname, new URL(redirect).pathname, config)) { authorized = true; } } else if (userMiddlewareOrRoute) { // Execute user's middleware/handler with the augmented request const augmentedReq = request; augmentedReq.auth = auth; response = await userMiddlewareOrRoute(augmentedReq, args[1]) ?? __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["NextResponse"].next(); } else if (!authorized) { const signInPage = config.pages?.signIn ?? `${config.basePath}/signin`; if (request.nextUrl.pathname !== signInPage) { // Redirect to signin page by default if not authorized const signInUrl = request.nextUrl.clone(); signInUrl.pathname = signInPage; signInUrl.searchParams.set("callbackUrl", request.nextUrl.href); response = __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["NextResponse"].redirect(signInUrl); } } const finalResponse = new Response(response?.body, response); // Preserve cookies from the session response for (const cookie of sessionResponse.headers.getSetCookie())finalResponse.headers.append("set-cookie", cookie); return finalResponse; } function isSameAuthAction(requestPath, redirectPath, config) { const action = redirectPath.replace(`${requestPath}/`, ""); const pages = Object.values(config.pages ?? {}); return (actions.has(action) || pages.includes(redirectPath)) && redirectPath === requestPath; } const actions = new Set([ "providers", "session", "csrf", "signin", "signout", "callback", "verify-request", "error" ]); }), "[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/actions.js [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "signIn", ()=>signIn, "signOut", ()=>signOut, "update", ()=>update ]); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/index.js [app-route] (ecmascript) "); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$symbols$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/lib/symbols.js [app-route] (ecmascript)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$utils$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/lib/utils/env.js [app-route] (ecmascript)"); // @ts-expect-error Next.js does not yet correctly use the `package.json#exports` field var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/headers.js [app-route] (ecmascript)"); // @ts-expect-error Next.js does not yet correctly use the `package.json#exports` field var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$api$2f$navigation$2e$react$2d$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/api/navigation.react-server.js [app-route] (ecmascript) "); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$client$2f$components$2f$navigation$2e$react$2d$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next/dist/client/components/navigation.react-server.js [app-route] (ecmascript)"); ; ; ; async function signIn(provider, options = {}, authorizationParams, config) { const headers = new Headers(await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["headers"])()); const { redirect: shouldRedirect = true, redirectTo, ...rest } = options instanceof FormData ? Object.fromEntries(options) : options; const callbackUrl = redirectTo?.toString() ?? headers.get("Referer") ?? "/"; const signInURL = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$utils$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["createActionURL"])("signin", // @ts-expect-error `x-forwarded-proto` is not nullable, next.js sets it by default headers.get("x-forwarded-proto"), headers, process.env, config); if (!provider) { signInURL.searchParams.append("callbackUrl", callbackUrl); if (shouldRedirect) (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$client$2f$components$2f$navigation$2e$react$2d$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["redirect"])(signInURL.toString()); return signInURL.toString(); } let url = `${signInURL}/${provider}?${new URLSearchParams(authorizationParams)}`; let foundProvider = {}; for (const providerConfig of config.providers){ const { options, ...defaults } = typeof providerConfig === "function" ? providerConfig() : providerConfig; const id = options?.id ?? defaults.id; if (id === provider) { foundProvider = { id, type: options?.type ?? defaults.type }; break; } } if (!foundProvider.id) { const url = `${signInURL}?${new URLSearchParams({ callbackUrl })}`; if (shouldRedirect) (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$client$2f$components$2f$navigation$2e$react$2d$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["redirect"])(url); return url; } if (foundProvider.type === "credentials") { url = url.replace("signin", "callback"); } headers.set("Content-Type", "application/x-www-form-urlencoded"); const body = new URLSearchParams({ ...rest, callbackUrl }); const req = new Request(url, { method: "POST", headers, body }); const res = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["Auth"])(req, { ...config, raw: __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$symbols$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["raw"], skipCSRFCheck: __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$symbols$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["skipCSRFCheck"] }); const cookieJar = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["cookies"])(); for (const c of res?.cookies ?? [])cookieJar.set(c.name, c.value, c.options); const responseUrl = res instanceof Response ? res.headers.get("Location") : res.redirect; // NOTE: if for some unexpected reason the responseUrl is not set, // we redirect to the original url const redirectUrl = responseUrl ?? url; if (shouldRedirect) return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$client$2f$components$2f$navigation$2e$react$2d$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["redirect"])(redirectUrl); return redirectUrl; } async function signOut(options, config) { const headers = new Headers(await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["headers"])()); headers.set("Content-Type", "application/x-www-form-urlencoded"); const url = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$utils$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["createActionURL"])("signout", // @ts-expect-error `x-forwarded-proto` is not nullable, next.js sets it by default headers.get("x-forwarded-proto"), headers, process.env, config); const callbackUrl = options?.redirectTo ?? headers.get("Referer") ?? "/"; const body = new URLSearchParams({ callbackUrl }); const req = new Request(url, { method: "POST", headers, body }); const res = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["Auth"])(req, { ...config, raw: __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$symbols$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["raw"], skipCSRFCheck: __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$symbols$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["skipCSRFCheck"] }); const cookieJar = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["cookies"])(); for (const c of res?.cookies ?? [])cookieJar.set(c.name, c.value, c.options); if (options?.redirect ?? true) return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$dist$2f$client$2f$components$2f$navigation$2e$react$2d$server$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["redirect"])(res.redirect); return res; } async function update(data, config) { const headers = new Headers(await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["headers"])()); headers.set("Content-Type", "application/json"); const url = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$utils$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["createActionURL"])("session", // @ts-expect-error `x-forwarded-proto` is not nullable, next.js sets it by default headers.get("x-forwarded-proto"), headers, process.env, config); const body = JSON.stringify({ data }); const req = new Request(url, { method: "POST", headers, body }); const res = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["Auth"])(req, { ...config, raw: __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$symbols$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["raw"], skipCSRFCheck: __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$symbols$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["skipCSRFCheck"] }); const cookieJar = await (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2f$headers$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["cookies"])(); for (const c of res?.cookies ?? [])cookieJar.set(c.name, c.value, c.options); return res.body; } }), "[project]/Documents/00 - projet/plumeia/node_modules/next-auth/index.js [app-route] (ecmascript) ", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "default", ()=>NextAuth ]); /** * _If you are looking to migrate from v4, visit the [Upgrade Guide (v5)](https://authjs.dev/getting-started/migrating-to-v5)._ * * ## Installation * * ```bash npm2yarn * npm install next-auth@beta * ``` * * ## Environment variable inference * * `NEXTAUTH_URL` and `NEXTAUTH_SECRET` have been inferred since v4. * * Since NextAuth.js v5 can also automatically infer environment variables that are prefixed with `AUTH_`. * * For example `AUTH_GITHUB_ID` and `AUTH_GITHUB_SECRET` will be used as the `clientId` and `clientSecret` options for the GitHub provider. * * :::tip * The environment variable name inferring has the following format for OAuth providers: `AUTH_{PROVIDER}_{ID|SECRET}`. * * `PROVIDER` is the uppercase snake case version of the provider's id, followed by either `ID` or `SECRET` respectively. * ::: * * `AUTH_SECRET` and `AUTH_URL` are also aliased for `NEXTAUTH_SECRET` and `NEXTAUTH_URL` for consistency. * * To add social login to your app, the configuration becomes: * * ```ts title="auth.ts" * import NextAuth from "next-auth" * import GitHub from "next-auth/providers/github" * export const { handlers, auth } = NextAuth({ providers: [ GitHub ] }) * ``` * * And the `.env.local` file: * * ```sh title=".env.local" * AUTH_GITHUB_ID=... * AUTH_GITHUB_SECRET=... * AUTH_SECRET=... * ``` * * :::tip * In production, `AUTH_SECRET` is a required environment variable - if not set, NextAuth.js will throw an error. See [MissingSecretError](https://authjs.dev/reference/core/errors#missingsecret) for more details. * ::: * * If you need to override the default values for a provider, you can still call it as a function `GitHub({...})` as before. * * ## Lazy initialization * You can also initialize NextAuth.js lazily (previously known as advanced intialization), which allows you to access the request context in the configuration in some cases, like Route Handlers, Middleware, API Routes or `getServerSideProps`. * The above example becomes: * * ```ts title="auth.ts" * import NextAuth from "next-auth" * import GitHub from "next-auth/providers/github" * export const { handlers, auth } = NextAuth(req => { * if (req) { * console.log(req) // do something with the request * } * return { providers: [ GitHub ] } * }) * ``` * * :::tip * This is useful if you want to customize the configuration based on the request, for example, to add a different provider in staging/dev environments. * ::: * * @module next-auth */ var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/index.js [app-route] (ecmascript) "); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$lib$2f$symbols$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/lib/symbols.js [app-route] (ecmascript)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/env.js [app-route] (ecmascript)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/index.js [app-route] (ecmascript)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$actions$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/next-auth/lib/actions.js [app-route] (ecmascript)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$errors$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/errors.js [app-route] (ecmascript)"); ; ; ; ; ; ; function NextAuth(config) { if (typeof config === "function") { const httpHandler = async (req)=>{ const _config = await config(req); (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["setEnvDefaults"])(_config); return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["Auth"])((0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["reqWithEnvURL"])(req), _config); }; return { handlers: { GET: httpHandler, POST: httpHandler }, // @ts-expect-error auth: (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["initAuth"])(config, (c)=>(0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["setEnvDefaults"])(c)), signIn: async (provider, options, authorizationParams)=>{ const _config = await config(undefined); (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["setEnvDefaults"])(_config); return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$actions$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["signIn"])(provider, options, authorizationParams, _config); }, signOut: async (options)=>{ const _config = await config(undefined); (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["setEnvDefaults"])(_config); return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$actions$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["signOut"])(options, _config); }, unstable_update: async (data)=>{ const _config = await config(undefined); (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["setEnvDefaults"])(_config); return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$actions$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["update"])(data, _config); } }; } (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["setEnvDefaults"])(config); const httpHandler = (req)=>(0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["Auth"])((0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$env$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["reqWithEnvURL"])(req), config); return { handlers: { GET: httpHandler, POST: httpHandler }, // @ts-expect-error auth: (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["initAuth"])(config), signIn: (provider, options, authorizationParams)=>{ return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$actions$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["signIn"])(provider, options, authorizationParams, config); }, signOut: (options)=>{ return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$actions$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["signOut"])(options, config); }, unstable_update: (data)=>{ return (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$next$2d$auth$2f$lib$2f$actions$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["update"])(data, config); } }; } }), "[project]/Documents/00 - projet/plumeia/node_modules/next-auth/providers/credentials.js [app-route] (ecmascript) ", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([]); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$auth$2f$core$2f$providers$2f$credentials$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@auth/core/providers/credentials.js [app-route] (ecmascript)"); ; ; }), "[externals]/bcryptjs [external] (bcryptjs, esm_import, [project]/Documents/00 - projet/plumeia/node_modules/bcryptjs)", ((__turbopack_context__) => { "use strict"; return __turbopack_context__.a(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try { const mod = await __turbopack_context__.y("bcryptjs-6c8cf8b3815327b5"); __turbopack_context__.n(mod); __turbopack_async_result__(); } catch(e) { __turbopack_async_result__(e); } }, true);}), "[externals]/@prisma/client [external] (@prisma/client, cjs, [project]/Documents/00 - projet/plumeia/node_modules/@prisma/client)", ((__turbopack_context__, module, exports) => { const mod = __turbopack_context__.x("@prisma/client-5d1deb26a67ff978", () => require("@prisma/client-5d1deb26a67ff978")); module.exports = mod; }), "[project]/Documents/00 - projet/plumeia/node_modules/@prisma/debug/dist/index.mjs [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "Debug", ()=>Debug, "clearLogs", ()=>clearLogs, "default", ()=>index_default, "getLogs", ()=>getLogs ]); var __defProp = Object.defineProperty; var __export = (target, all)=>{ for(var name in all)__defProp(target, name, { get: all[name], enumerable: true }); }; // ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs var colors_exports = {}; __export(colors_exports, { $: ()=>$, bgBlack: ()=>bgBlack, bgBlue: ()=>bgBlue, bgCyan: ()=>bgCyan, bgGreen: ()=>bgGreen, bgMagenta: ()=>bgMagenta, bgRed: ()=>bgRed, bgWhite: ()=>bgWhite, bgYellow: ()=>bgYellow, black: ()=>black, blue: ()=>blue, bold: ()=>bold, cyan: ()=>cyan, dim: ()=>dim, gray: ()=>gray, green: ()=>green, grey: ()=>grey, hidden: ()=>hidden, inverse: ()=>inverse, italic: ()=>italic, magenta: ()=>magenta, red: ()=>red, reset: ()=>reset, strikethrough: ()=>strikethrough, underline: ()=>underline, white: ()=>white, yellow: ()=>yellow }); var FORCE_COLOR; var NODE_DISABLE_COLORS; var NO_COLOR; var TERM; var isTTY = true; if (typeof process !== "undefined") { ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {}); isTTY = process.stdout && process.stdout.isTTY; } var $ = { enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY) }; function init(x, y) { let rgx = new RegExp(`\\x1b\\[${y}m`, "g"); let open = `\x1B[${x}m`, close = `\x1B[${y}m`; return function(txt) { if (!$.enabled || txt == null) return txt; return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close; }; } var reset = init(0, 0); var bold = init(1, 22); var dim = init(2, 22); var italic = init(3, 23); var underline = init(4, 24); var inverse = init(7, 27); var hidden = init(8, 28); var strikethrough = init(9, 29); var black = init(30, 39); var red = init(31, 39); var green = init(32, 39); var yellow = init(33, 39); var blue = init(34, 39); var magenta = init(35, 39); var cyan = init(36, 39); var white = init(37, 39); var gray = init(90, 39); var grey = init(90, 39); var bgBlack = init(40, 49); var bgRed = init(41, 49); var bgGreen = init(42, 49); var bgYellow = init(43, 49); var bgBlue = init(44, 49); var bgMagenta = init(45, 49); var bgCyan = init(46, 49); var bgWhite = init(47, 49); // src/index.ts var MAX_ARGS_HISTORY = 100; var COLORS = [ "green", "yellow", "blue", "magenta", "cyan", "red" ]; var argsHistory = []; var lastTimestamp = Date.now(); var lastColor = 0; var processEnv = typeof process !== "undefined" ? process.env : {}; globalThis.DEBUG ??= processEnv.DEBUG ?? ""; globalThis.DEBUG_COLORS ??= processEnv.DEBUG_COLORS ? processEnv.DEBUG_COLORS === "true" : true; var topProps = { enable (namespace) { if (typeof namespace === "string") { globalThis.DEBUG = namespace; } }, disable () { const prev = globalThis.DEBUG; globalThis.DEBUG = ""; return prev; }, // this is the core logic to check if logging should happen or not enabled (namespace) { const listenedNamespaces = globalThis.DEBUG.split(",").map((s)=>{ return s.replace(/[.+?^${}()|[\]\\]/g, "\\$&"); }); const isListened = listenedNamespaces.some((listenedNamespace)=>{ if (listenedNamespace === "" || listenedNamespace[0] === "-") return false; return namespace.match(RegExp(listenedNamespace.split("*").join(".*") + "$")); }); const isExcluded = listenedNamespaces.some((listenedNamespace)=>{ if (listenedNamespace === "" || listenedNamespace[0] !== "-") return false; return namespace.match(RegExp(listenedNamespace.slice(1).split("*").join(".*") + "$")); }); return isListened && !isExcluded; }, log: (...args)=>{ const [namespace, format, ...rest] = args; const logWithFormatting = console.warn ?? console.log; logWithFormatting(`${namespace} ${format}`, ...rest); }, formatters: {} }; function debugCreate(namespace) { const instanceProps = { color: COLORS[lastColor++ % COLORS.length], enabled: topProps.enabled(namespace), namespace, log: topProps.log, extend: ()=>{} }; const debugCall = (...args)=>{ const { enabled, namespace: namespace2, color, log } = instanceProps; if (args.length !== 0) { argsHistory.push([ namespace2, ...args ]); } if (argsHistory.length > MAX_ARGS_HISTORY) { argsHistory.shift(); } if (topProps.enabled(namespace2) || enabled) { const stringArgs = args.map((arg)=>{ if (typeof arg === "string") { return arg; } return safeStringify(arg); }); const ms = `+${Date.now() - lastTimestamp}ms`; lastTimestamp = Date.now(); if (globalThis.DEBUG_COLORS) { log(colors_exports[color](bold(namespace2)), ...stringArgs, colors_exports[color](ms)); } else { log(namespace2, ...stringArgs, ms); } } }; return new Proxy(debugCall, { get: (_, prop)=>instanceProps[prop], set: (_, prop, value)=>instanceProps[prop] = value }); } var Debug = new Proxy(debugCreate, { get: (_, prop)=>topProps[prop], set: (_, prop, value)=>topProps[prop] = value }); function safeStringify(value, indent = 2) { const cache = /* @__PURE__ */ new Set(); return JSON.stringify(value, (key, value2)=>{ if (typeof value2 === "object" && value2 !== null) { if (cache.has(value2)) { return `[Circular *]`; } cache.add(value2); } else if (typeof value2 === "bigint") { return value2.toString(); } return value2; }, indent); } function getLogs(numChars = 7500) { const logs = argsHistory.map(([namespace, ...args])=>{ return `${namespace} ${args.map((arg)=>{ if (typeof arg === "string") { return arg; } else { return JSON.stringify(arg); } }).join(" ")}`; }).join("\n"); if (logs.length < numChars) { return logs; } return logs.slice(-numChars); } function clearLogs() { argsHistory.length = 0; } var index_default = Debug; ; }), "[project]/Documents/00 - projet/plumeia/node_modules/@prisma/driver-adapter-utils/dist/index.mjs [app-route] (ecmascript) ", ((__turbopack_context__) => { "use strict"; __turbopack_context__.s([ "ColumnTypeEnum", ()=>ColumnTypeEnum, "DriverAdapterError", ()=>DriverAdapterError, "bindAdapter", ()=>bindAdapter, "bindMigrationAwareSqlAdapterFactory", ()=>bindMigrationAwareSqlAdapterFactory, "bindSqlAdapterFactory", ()=>bindSqlAdapterFactory, "err", ()=>err, "isDriverAdapterError", ()=>isDriverAdapterError, "mockAdapter", ()=>mockAdapter, "mockAdapterErrors", ()=>mockAdapterErrors, "mockAdapterFactory", ()=>mockAdapterFactory, "mockMigrationAwareAdapterFactory", ()=>mockMigrationAwareAdapterFactory, "ok", ()=>ok ]); // src/debug.ts var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$debug$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@prisma/debug/dist/index.mjs [app-route] (ecmascript)"); ; // src/error.ts var DriverAdapterError = class extends Error { name = "DriverAdapterError"; cause; constructor(payload){ super(typeof payload["message"] === "string" ? payload["message"] : payload.kind); this.cause = payload; } }; function isDriverAdapterError(error) { return error["name"] === "DriverAdapterError" && typeof error["cause"] === "object"; } // src/result.ts function ok(value) { return { ok: true, value, map (fn) { return ok(fn(value)); }, flatMap (fn) { return fn(value); } }; } function err(error) { return { ok: false, error, map () { return err(error); }, flatMap () { return err(error); } }; } // src/binder.ts var debug = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$debug$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Debug"])("driver-adapter-utils"); var ErrorRegistryInternal = class { registeredErrors = []; consumeError(id) { return this.registeredErrors[id]; } registerNewError(error) { let i = 0; while(this.registeredErrors[i] !== void 0){ i++; } this.registeredErrors[i] = { error }; return i; } }; function copySymbolsFromSource(source, target) { const symbols = Object.getOwnPropertySymbols(source); const symbolObject = Object.fromEntries(symbols.map((symbol)=>[ symbol, true ])); Object.assign(target, symbolObject); } var bindMigrationAwareSqlAdapterFactory = (adapterFactory)=>{ const errorRegistry = new ErrorRegistryInternal(); const boundFactory = { adapterName: adapterFactory.adapterName, provider: adapterFactory.provider, errorRegistry, connect: async (...args)=>{ const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args); return ctx.map((ctx2)=>bindAdapter(ctx2, errorRegistry)); }, connectToShadowDb: async (...args)=>{ const ctx = await wrapAsync(errorRegistry, adapterFactory.connectToShadowDb.bind(adapterFactory))(...args); return ctx.map((ctx2)=>bindAdapter(ctx2, errorRegistry)); } }; copySymbolsFromSource(adapterFactory, boundFactory); return boundFactory; }; var bindSqlAdapterFactory = (adapterFactory)=>{ const errorRegistry = new ErrorRegistryInternal(); const boundFactory = { adapterName: adapterFactory.adapterName, provider: adapterFactory.provider, errorRegistry, connect: async (...args)=>{ const ctx = await wrapAsync(errorRegistry, adapterFactory.connect.bind(adapterFactory))(...args); return ctx.map((ctx2)=>bindAdapter(ctx2, errorRegistry)); } }; copySymbolsFromSource(adapterFactory, boundFactory); return boundFactory; }; var bindAdapter = (adapter, errorRegistry = new ErrorRegistryInternal())=>{ const boundAdapter = { adapterName: adapter.adapterName, errorRegistry, queryRaw: wrapAsync(errorRegistry, adapter.queryRaw.bind(adapter)), executeRaw: wrapAsync(errorRegistry, adapter.executeRaw.bind(adapter)), executeScript: wrapAsync(errorRegistry, adapter.executeScript.bind(adapter)), dispose: wrapAsync(errorRegistry, adapter.dispose.bind(adapter)), provider: adapter.provider, startTransaction: async (...args)=>{ const ctx = await wrapAsync(errorRegistry, adapter.startTransaction.bind(adapter))(...args); return ctx.map((ctx2)=>bindTransaction(errorRegistry, ctx2)); } }; if (adapter.getConnectionInfo) { boundAdapter.getConnectionInfo = wrapSync(errorRegistry, adapter.getConnectionInfo.bind(adapter)); } return boundAdapter; }; var bindTransaction = (errorRegistry, transaction)=>{ return { adapterName: transaction.adapterName, provider: transaction.provider, options: transaction.options, queryRaw: wrapAsync(errorRegistry, transaction.queryRaw.bind(transaction)), executeRaw: wrapAsync(errorRegistry, transaction.executeRaw.bind(transaction)), commit: wrapAsync(errorRegistry, transaction.commit.bind(transaction)), rollback: wrapAsync(errorRegistry, transaction.rollback.bind(transaction)) }; }; function wrapAsync(registry, fn) { return async (...args)=>{ try { return ok(await fn(...args)); } catch (error) { debug("[error@wrapAsync]", error); if (isDriverAdapterError(error)) { return err(error.cause); } const id = registry.registerNewError(error); return err({ kind: "GenericJs", id }); } }; } function wrapSync(registry, fn) { return (...args)=>{ try { return ok(fn(...args)); } catch (error) { debug("[error@wrapSync]", error); if (isDriverAdapterError(error)) { return err(error.cause); } const id = registry.registerNewError(error); return err({ kind: "GenericJs", id }); } }; } // src/const.ts var ColumnTypeEnum = { // Scalars Int32: 0, Int64: 1, Float: 2, Double: 3, Numeric: 4, Boolean: 5, Character: 6, Text: 7, Date: 8, Time: 9, DateTime: 10, Json: 11, Enum: 12, Bytes: 13, Set: 14, Uuid: 15, // Arrays Int32Array: 64, Int64Array: 65, FloatArray: 66, DoubleArray: 67, NumericArray: 68, BooleanArray: 69, CharacterArray: 70, TextArray: 71, DateArray: 72, TimeArray: 73, DateTimeArray: 74, JsonArray: 75, EnumArray: 76, BytesArray: 77, UuidArray: 78, // Custom UnknownNumber: 128 }; // src/mock.ts var mockAdapterErrors = { queryRaw: new Error("Not implemented: queryRaw"), executeRaw: new Error("Not implemented: executeRaw"), startTransaction: new Error("Not implemented: startTransaction"), executeScript: new Error("Not implemented: executeScript"), dispose: new Error("Not implemented: dispose") }; function mockAdapter(provider) { return { provider, adapterName: "@prisma/adapter-mock", queryRaw: ()=>Promise.reject(mockAdapterErrors.queryRaw), executeRaw: ()=>Promise.reject(mockAdapterErrors.executeRaw), startTransaction: ()=>Promise.reject(mockAdapterErrors.startTransaction), executeScript: ()=>Promise.reject(mockAdapterErrors.executeScript), dispose: ()=>Promise.reject(mockAdapterErrors.dispose), [Symbol.for("adapter.mockAdapter")]: true }; } function mockAdapterFactory(provider) { return { provider, adapterName: "@prisma/adapter-mock", connect: ()=>Promise.resolve(mockAdapter(provider)), [Symbol.for("adapter.mockAdapterFactory")]: true }; } function mockMigrationAwareAdapterFactory(provider) { return { provider, adapterName: "@prisma/adapter-mock", connect: ()=>Promise.resolve(mockAdapter(provider)), connectToShadowDb: ()=>Promise.resolve(mockAdapter(provider)), [Symbol.for("adapter.mockMigrationAwareAdapterFactory")]: true }; } ; }), "[externals]/pg [external] (pg, esm_import, [project]/Documents/00 - projet/plumeia/node_modules/pg)", ((__turbopack_context__) => { "use strict"; return __turbopack_context__.a(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try { const mod = await __turbopack_context__.y("pg-909e2581735964d3"); __turbopack_context__.n(mod); __turbopack_async_result__(); } catch(e) { __turbopack_async_result__(e); } }, true);}), "[project]/Documents/00 - projet/plumeia/node_modules/postgres-array/index.js [app-route] (ecmascript)", ((__turbopack_context__, module, exports) => { "use strict"; const BACKSLASH = '\\'; const DQUOT = '"'; const LBRACE = '{'; const RBRACE = '}'; const LBRACKET = '['; const EQUALS = '='; const COMMA = ','; /** When the raw value is this, it means a literal `null` */ const NULL_STRING = 'NULL'; /** * Parses an array according to * https://www.postgresql.org/docs/17/arrays.html#ARRAYS-IO * * Trusts the data (mostly), so only hook up to trusted Postgres servers. */ function makeParseArrayWithTransform(transform) { const haveTransform = transform != null; return function parseArray(str) { const rbraceIndex = str.length - 1; if (rbraceIndex === 1) { return []; } if (str[rbraceIndex] !== RBRACE) { throw new Error('Invalid array text - must end with }'); } // If starts with `[`, it is specifying the index boundas. Skip past first `=`. let position = 0; if (str[position] === LBRACKET) { position = str.indexOf(EQUALS) + 1; } if (str[position++] !== LBRACE) { throw new Error('Invalid array text - must start with {'); } const output = []; let current = output; const stack = []; let currentStringStart = position; let currentString = ''; let expectValue = true; for(; position < rbraceIndex; ++position){ let char = str[position]; // > The array output routine will put double quotes around element values if // > they are empty strings, contain curly braces, delimiter characters, double // > quotes, backslashes, or white space, or match the word NULL. Double quotes // > and backslashes embedded in element values will be backslash-escaped. if (char === DQUOT) { // It's escaped currentStringStart = ++position; let dquot = str.indexOf(DQUOT, currentStringStart); let backSlash = str.indexOf(BACKSLASH, currentStringStart); while(backSlash !== -1 && backSlash < dquot){ position = backSlash; const part = str.slice(currentStringStart, position); currentString += part; currentStringStart = ++position; if (dquot === position++) { // This was an escaped doublequote; find the next one! dquot = str.indexOf(DQUOT, position); } // Either way, find the next backslash backSlash = str.indexOf(BACKSLASH, position); } position = dquot; const part = str.slice(currentStringStart, position); currentString += part; current.push(haveTransform ? transform(currentString) : currentString); currentString = ''; expectValue = false; } else if (char === LBRACE) { const newArray = []; current.push(newArray); stack.push(current); current = newArray; currentStringStart = position + 1; expectValue = true; } else if (char === COMMA) { expectValue = true; } else if (char === RBRACE) { expectValue = false; const arr = stack.pop(); if (arr === undefined) { throw new Error("Invalid array text - too many '}'"); } current = arr; } else if (expectValue) { currentStringStart = position; while((char = str[position]) !== COMMA && char !== RBRACE && position < rbraceIndex){ ++position; } const part = str.slice(currentStringStart, position--); current.push(part === NULL_STRING ? null : haveTransform ? transform(part) : part); expectValue = false; } else { throw new Error('Was expecting delimeter'); } } return output; }; } const parseArray = makeParseArrayWithTransform(); exports.parse = (source, transform)=>transform != null ? makeParseArrayWithTransform(transform)(source) : parseArray(source); }), "[project]/Documents/00 - projet/plumeia/node_modules/@prisma/adapter-pg/dist/index.mjs [app-route] (ecmascript)", ((__turbopack_context__) => { "use strict"; return __turbopack_context__.a(async (__turbopack_handle_async_dependencies__, __turbopack_async_result__) => { try { __turbopack_context__.s([ "PrismaPg", ()=>PrismaPgAdapterFactory ]); // src/pg.ts var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$debug$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@prisma/debug/dist/index.mjs [app-route] (ecmascript)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/@prisma/driver-adapter-utils/dist/index.mjs [app-route] (ecmascript) "); var __TURBOPACK__imported__module__$5b$externals$5d2f$pg__$5b$external$5d$__$28$pg$2c$__esm_import$2c$__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$pg$29$__ = __turbopack_context__.i("[externals]/pg [external] (pg, esm_import, [project]/Documents/00 - projet/plumeia/node_modules/pg)"); var __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$postgres$2d$array$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__ = __turbopack_context__.i("[project]/Documents/00 - projet/plumeia/node_modules/postgres-array/index.js [app-route] (ecmascript)"); var __turbopack_async_dependencies__ = __turbopack_handle_async_dependencies__([ __TURBOPACK__imported__module__$5b$externals$5d2f$pg__$5b$external$5d$__$28$pg$2c$__esm_import$2c$__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$pg$29$__ ]); [__TURBOPACK__imported__module__$5b$externals$5d2f$pg__$5b$external$5d$__$28$pg$2c$__esm_import$2c$__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$pg$29$__] = __turbopack_async_dependencies__.then ? (await __turbopack_async_dependencies__)() : __turbopack_async_dependencies__; ; ; // package.json var name = "@prisma/adapter-pg"; // src/constants.ts var FIRST_NORMAL_OBJECT_ID = 16384; ; ; ; var { types } = __TURBOPACK__imported__module__$5b$externals$5d2f$pg__$5b$external$5d$__$28$pg$2c$__esm_import$2c$__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$pg$29$__["default"]; var { builtins: ScalarColumnType, getTypeParser } = types; var AdditionalScalarColumnType = { NAME: 19 }; var ArrayColumnType = { BIT_ARRAY: 1561, BOOL_ARRAY: 1e3, BYTEA_ARRAY: 1001, BPCHAR_ARRAY: 1014, CHAR_ARRAY: 1002, CIDR_ARRAY: 651, DATE_ARRAY: 1182, FLOAT4_ARRAY: 1021, FLOAT8_ARRAY: 1022, INET_ARRAY: 1041, INT2_ARRAY: 1005, INT4_ARRAY: 1007, INT8_ARRAY: 1016, JSONB_ARRAY: 3807, JSON_ARRAY: 199, MONEY_ARRAY: 791, NUMERIC_ARRAY: 1231, OID_ARRAY: 1028, TEXT_ARRAY: 1009, TIMESTAMP_ARRAY: 1115, TIMESTAMPTZ_ARRAY: 1185, TIME_ARRAY: 1183, UUID_ARRAY: 2951, VARBIT_ARRAY: 1563, VARCHAR_ARRAY: 1015, XML_ARRAY: 143 }; var UnsupportedNativeDataType = class _UnsupportedNativeDataType extends Error { // map of type codes to type names static typeNames = { 16: "bool", 17: "bytea", 18: "char", 19: "name", 20: "int8", 21: "int2", 22: "int2vector", 23: "int4", 24: "regproc", 25: "text", 26: "oid", 27: "tid", 28: "xid", 29: "cid", 30: "oidvector", 32: "pg_ddl_command", 71: "pg_type", 75: "pg_attribute", 81: "pg_proc", 83: "pg_class", 114: "json", 142: "xml", 194: "pg_node_tree", 269: "table_am_handler", 325: "index_am_handler", 600: "point", 601: "lseg", 602: "path", 603: "box", 604: "polygon", 628: "line", 650: "cidr", 700: "float4", 701: "float8", 705: "unknown", 718: "circle", 774: "macaddr8", 790: "money", 829: "macaddr", 869: "inet", 1033: "aclitem", 1042: "bpchar", 1043: "varchar", 1082: "date", 1083: "time", 1114: "timestamp", 1184: "timestamptz", 1186: "interval", 1266: "timetz", 1560: "bit", 1562: "varbit", 1700: "numeric", 1790: "refcursor", 2202: "regprocedure", 2203: "regoper", 2204: "regoperator", 2205: "regclass", 2206: "regtype", 2249: "record", 2275: "cstring", 2276: "any", 2277: "anyarray", 2278: "void", 2279: "trigger", 2280: "language_handler", 2281: "internal", 2283: "anyelement", 2287: "_record", 2776: "anynonarray", 2950: "uuid", 2970: "txid_snapshot", 3115: "fdw_handler", 3220: "pg_lsn", 3310: "tsm_handler", 3361: "pg_ndistinct", 3402: "pg_dependencies", 3500: "anyenum", 3614: "tsvector", 3615: "tsquery", 3642: "gtsvector", 3734: "regconfig", 3769: "regdictionary", 3802: "jsonb", 3831: "anyrange", 3838: "event_trigger", 3904: "int4range", 3906: "numrange", 3908: "tsrange", 3910: "tstzrange", 3912: "daterange", 3926: "int8range", 4072: "jsonpath", 4089: "regnamespace", 4096: "regrole", 4191: "regcollation", 4451: "int4multirange", 4532: "nummultirange", 4533: "tsmultirange", 4534: "tstzmultirange", 4535: "datemultirange", 4536: "int8multirange", 4537: "anymultirange", 4538: "anycompatiblemultirange", 4600: "pg_brin_bloom_summary", 4601: "pg_brin_minmax_multi_summary", 5017: "pg_mcv_list", 5038: "pg_snapshot", 5069: "xid8", 5077: "anycompatible", 5078: "anycompatiblearray", 5079: "anycompatiblenonarray", 5080: "anycompatiblerange" }; type; constructor(code){ super(); this.type = _UnsupportedNativeDataType.typeNames[code] || "Unknown"; this.message = `Unsupported column type ${this.type}`; } }; function fieldToColumnType(fieldTypeId) { switch(fieldTypeId){ case ScalarColumnType.INT2: case ScalarColumnType.INT4: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Int32; case ScalarColumnType.INT8: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Int64; case ScalarColumnType.FLOAT4: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Float; case ScalarColumnType.FLOAT8: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Double; case ScalarColumnType.BOOL: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Boolean; case ScalarColumnType.DATE: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Date; case ScalarColumnType.TIME: case ScalarColumnType.TIMETZ: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Time; case ScalarColumnType.TIMESTAMP: case ScalarColumnType.TIMESTAMPTZ: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].DateTime; case ScalarColumnType.NUMERIC: case ScalarColumnType.MONEY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Numeric; case ScalarColumnType.JSON: case ScalarColumnType.JSONB: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Json; case ScalarColumnType.UUID: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Uuid; case ScalarColumnType.OID: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Int64; case ScalarColumnType.BPCHAR: case ScalarColumnType.TEXT: case ScalarColumnType.VARCHAR: case ScalarColumnType.BIT: case ScalarColumnType.VARBIT: case ScalarColumnType.INET: case ScalarColumnType.CIDR: case ScalarColumnType.XML: case AdditionalScalarColumnType.NAME: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Text; case ScalarColumnType.BYTEA: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Bytes; case ArrayColumnType.INT2_ARRAY: case ArrayColumnType.INT4_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Int32Array; case ArrayColumnType.FLOAT4_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].FloatArray; case ArrayColumnType.FLOAT8_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].DoubleArray; case ArrayColumnType.NUMERIC_ARRAY: case ArrayColumnType.MONEY_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].NumericArray; case ArrayColumnType.BOOL_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].BooleanArray; case ArrayColumnType.CHAR_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].CharacterArray; case ArrayColumnType.BPCHAR_ARRAY: case ArrayColumnType.TEXT_ARRAY: case ArrayColumnType.VARCHAR_ARRAY: case ArrayColumnType.VARBIT_ARRAY: case ArrayColumnType.BIT_ARRAY: case ArrayColumnType.INET_ARRAY: case ArrayColumnType.CIDR_ARRAY: case ArrayColumnType.XML_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].TextArray; case ArrayColumnType.DATE_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].DateArray; case ArrayColumnType.TIME_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].TimeArray; case ArrayColumnType.TIMESTAMP_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].DateTimeArray; case ArrayColumnType.TIMESTAMPTZ_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].DateTimeArray; case ArrayColumnType.JSON_ARRAY: case ArrayColumnType.JSONB_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].JsonArray; case ArrayColumnType.BYTEA_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].BytesArray; case ArrayColumnType.UUID_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].UuidArray; case ArrayColumnType.INT8_ARRAY: case ArrayColumnType.OID_ARRAY: return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Int64Array; default: if (fieldTypeId >= FIRST_NORMAL_OBJECT_ID) { return __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["ColumnTypeEnum"].Text; } throw new UnsupportedNativeDataType(fieldTypeId); } } function normalize_array(element_normalizer) { return (str)=>(0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$postgres$2d$array$2f$index$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["parse"])(str, element_normalizer); } function normalize_numeric(numeric) { return numeric; } function normalize_date(date) { return date; } function normalize_timestamp(time) { return `${time.replace(" ", "T")}+00:00`; } function normalize_timestamptz(time) { return time.replace(" ", "T").replace(/[+-]\d{2}(:\d{2})?$/, "+00:00"); } function normalize_time(time) { return time; } function normalize_timez(time) { return time.replace(/[+-]\d{2}(:\d{2})?$/, ""); } function normalize_money(money) { return money.slice(1); } function normalize_xml(xml) { return xml; } function toJson(json) { return json; } var parsePgBytes = getTypeParser(ScalarColumnType.BYTEA); var normalizeByteaArray = getTypeParser(ArrayColumnType.BYTEA_ARRAY); function convertBytes(serializedBytes) { return parsePgBytes(serializedBytes); } function normalizeBit(bit) { return bit; } var customParsers = { [ScalarColumnType.NUMERIC]: normalize_numeric, [ArrayColumnType.NUMERIC_ARRAY]: normalize_array(normalize_numeric), [ScalarColumnType.TIME]: normalize_time, [ArrayColumnType.TIME_ARRAY]: normalize_array(normalize_time), [ScalarColumnType.TIMETZ]: normalize_timez, [ScalarColumnType.DATE]: normalize_date, [ArrayColumnType.DATE_ARRAY]: normalize_array(normalize_date), [ScalarColumnType.TIMESTAMP]: normalize_timestamp, [ArrayColumnType.TIMESTAMP_ARRAY]: normalize_array(normalize_timestamp), [ScalarColumnType.TIMESTAMPTZ]: normalize_timestamptz, [ArrayColumnType.TIMESTAMPTZ_ARRAY]: normalize_array(normalize_timestamptz), [ScalarColumnType.MONEY]: normalize_money, [ArrayColumnType.MONEY_ARRAY]: normalize_array(normalize_money), [ScalarColumnType.JSON]: toJson, [ArrayColumnType.JSON_ARRAY]: normalize_array(toJson), [ScalarColumnType.JSONB]: toJson, [ArrayColumnType.JSONB_ARRAY]: normalize_array(toJson), [ScalarColumnType.BYTEA]: convertBytes, [ArrayColumnType.BYTEA_ARRAY]: normalizeByteaArray, [ArrayColumnType.BIT_ARRAY]: normalize_array(normalizeBit), [ArrayColumnType.VARBIT_ARRAY]: normalize_array(normalizeBit), [ArrayColumnType.XML_ARRAY]: normalize_array(normalize_xml) }; function mapArg(arg, argType) { if (arg === null) { return null; } if (Array.isArray(arg) && argType.arity === "list") { return arg.map((value)=>mapArg(value, argType)); } if (typeof arg === "string" && argType.scalarType === "datetime") { arg = new Date(arg); } if (arg instanceof Date) { switch(argType.dbType){ case "TIME": case "TIMETZ": return formatTime(arg); case "DATE": return formatDate(arg); default: return formatDateTime(arg); } } if (typeof arg === "string" && argType.scalarType === "bytes") { return Buffer.from(arg, "base64"); } if (ArrayBuffer.isView(arg)) { return new Uint8Array(arg.buffer, arg.byteOffset, arg.byteLength); } return arg; } function formatDateTime(date) { const pad = (n, z = 2)=>String(n).padStart(z, "0"); const ms = date.getUTCMilliseconds(); return pad(date.getUTCFullYear(), 4) + "-" + pad(date.getUTCMonth() + 1) + "-" + pad(date.getUTCDate()) + " " + pad(date.getUTCHours()) + ":" + pad(date.getUTCMinutes()) + ":" + pad(date.getUTCSeconds()) + (ms ? "." + String(ms).padStart(3, "0") : ""); } function formatDate(date) { const pad = (n, z = 2)=>String(n).padStart(z, "0"); return pad(date.getUTCFullYear(), 4) + "-" + pad(date.getUTCMonth() + 1) + "-" + pad(date.getUTCDate()); } function formatTime(date) { const pad = (n, z = 2)=>String(n).padStart(z, "0"); const ms = date.getUTCMilliseconds(); return pad(date.getUTCHours()) + ":" + pad(date.getUTCMinutes()) + ":" + pad(date.getUTCSeconds()) + (ms ? "." + String(ms).padStart(3, "0") : ""); } // src/errors.ts var TLS_ERRORS = /* @__PURE__ */ new Set([ "UNABLE_TO_GET_ISSUER_CERT", "UNABLE_TO_GET_CRL", "UNABLE_TO_DECRYPT_CERT_SIGNATURE", "UNABLE_TO_DECRYPT_CRL_SIGNATURE", "UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY", "CERT_SIGNATURE_FAILURE", "CRL_SIGNATURE_FAILURE", "CERT_NOT_YET_VALID", "CERT_HAS_EXPIRED", "CRL_NOT_YET_VALID", "CRL_HAS_EXPIRED", "ERROR_IN_CERT_NOT_BEFORE_FIELD", "ERROR_IN_CERT_NOT_AFTER_FIELD", "ERROR_IN_CRL_LAST_UPDATE_FIELD", "ERROR_IN_CRL_NEXT_UPDATE_FIELD", "DEPTH_ZERO_SELF_SIGNED_CERT", "SELF_SIGNED_CERT_IN_CHAIN", "UNABLE_TO_GET_ISSUER_CERT_LOCALLY", "UNABLE_TO_VERIFY_LEAF_SIGNATURE", "CERT_CHAIN_TOO_LONG", "CERT_REVOKED", "INVALID_CA", "INVALID_PURPOSE", "CERT_UNTRUSTED", "CERT_REJECTED", "HOSTNAME_MISMATCH", "ERR_TLS_CERT_ALTNAME_FORMAT", "ERR_TLS_CERT_ALTNAME_INVALID" ]); var SOCKET_ERRORS = /* @__PURE__ */ new Set([ "ENOTFOUND", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT" ]); function convertDriverError(error) { if (isSocketError(error)) { return mapSocketError(error); } if (isTlsError(error)) { return { kind: "TlsConnectionError", reason: error.message }; } if (isDriverError(error)) { return { originalCode: error.code, originalMessage: error.message, ...mapDriverError(error) }; } throw error; } function mapDriverError(error) { switch(error.code){ case "22001": return { kind: "LengthMismatch", column: error.column }; case "22003": return { kind: "ValueOutOfRange", cause: error.message }; case "22P02": return { kind: "InvalidInputValue", message: error.message }; case "23505": { const fields = error.detail?.match(/Key \(([^)]+)\)/)?.at(1)?.split(", "); return { kind: "UniqueConstraintViolation", constraint: fields !== void 0 ? { fields } : void 0 }; } case "23502": { const fields = error.detail?.match(/Key \(([^)]+)\)/)?.at(1)?.split(", "); return { kind: "NullConstraintViolation", constraint: fields !== void 0 ? { fields } : void 0 }; } case "23503": { let constraint; if (error.column) { constraint = { fields: [ error.column ] }; } else if (error.constraint) { constraint = { index: error.constraint }; } return { kind: "ForeignKeyConstraintViolation", constraint }; } case "3D000": return { kind: "DatabaseDoesNotExist", db: error.message.split(" ").at(1)?.split('"').at(1) }; case "28000": return { kind: "DatabaseAccessDenied", db: error.message.split(",").find((s)=>s.startsWith(" database"))?.split('"').at(1) }; case "28P01": return { kind: "AuthenticationFailed", user: error.message.split(" ").pop()?.split('"').at(1) }; case "40001": return { kind: "TransactionWriteConflict" }; case "42P01": return { kind: "TableDoesNotExist", table: error.message.split(" ").at(1)?.split('"').at(1) }; case "42703": return { kind: "ColumnNotFound", column: error.message.split(" ").at(1)?.split('"').at(1) }; case "42P04": return { kind: "DatabaseAlreadyExists", db: error.message.split(" ").at(1)?.split('"').at(1) }; case "53300": return { kind: "TooManyConnections", cause: error.message }; default: return { kind: "postgres", code: error.code ?? "N/A", severity: error.severity ?? "N/A", message: error.message, detail: error.detail, column: error.column, hint: error.hint }; } } function isDriverError(error) { return typeof error.code === "string" && typeof error.message === "string" && typeof error.severity === "string" && (typeof error.detail === "string" || error.detail === void 0) && (typeof error.column === "string" || error.column === void 0) && (typeof error.hint === "string" || error.hint === void 0); } function mapSocketError(error) { switch(error.code){ case "ENOTFOUND": case "ECONNREFUSED": return { kind: "DatabaseNotReachable", host: error.address ?? error.hostname, port: error.port }; case "ECONNRESET": return { kind: "ConnectionClosed" }; case "ETIMEDOUT": return { kind: "SocketTimeout" }; } } function isSocketError(error) { return typeof error.code === "string" && typeof error.syscall === "string" && typeof error.errno === "number" && SOCKET_ERRORS.has(error.code); } function isTlsError(error) { if (typeof error.code === "string") { return TLS_ERRORS.has(error.code); } switch(error.message){ case "The server does not support SSL connections": case "There was an error establishing an SSL connection": return true; } return false; } // src/pg.ts var types2 = __TURBOPACK__imported__module__$5b$externals$5d2f$pg__$5b$external$5d$__$28$pg$2c$__esm_import$2c$__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$pg$29$__["default"].types; var debug = (0, __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$debug$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__["Debug"])("prisma:driver-adapter:pg"); var PgQueryable = class { constructor(client, pgOptions){ this.client = client; this.pgOptions = pgOptions; } provider = "postgres"; adapterName = name; /** * Execute a query given as SQL, interpolating the given parameters. */ async queryRaw(query) { const tag = "[js::query_raw]"; debug(`${tag} %O`, query); const { fields, rows } = await this.performIO(query); const columnNames = fields.map((field)=>field.name); let columnTypes = []; try { columnTypes = fields.map((field)=>fieldToColumnType(field.dataTypeID)); } catch (e) { if (e instanceof UnsupportedNativeDataType) { throw new __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["DriverAdapterError"]({ kind: "UnsupportedNativeDataType", type: e.type }); } throw e; } const udtParser = this.pgOptions?.userDefinedTypeParser; if (udtParser) { for(let i = 0; i < fields.length; i++){ const field = fields[i]; if (field.dataTypeID >= FIRST_NORMAL_OBJECT_ID && !Object.hasOwn(customParsers, field.dataTypeID)) { for(let j = 0; j < rows.length; j++){ rows[j][i] = await udtParser(field.dataTypeID, rows[j][i], this); } } } } return { columnNames, columnTypes, rows }; } /** * Execute a query given as SQL, interpolating the given parameters and * returning the number of affected rows. * Note: Queryable expects a u64, but napi.rs only supports u32. */ async executeRaw(query) { const tag = "[js::execute_raw]"; debug(`${tag} %O`, query); return (await this.performIO(query)).rowCount ?? 0; } /** * Run a query against the database, returning the result set. * Should the query fail due to a connection error, the connection is * marked as unhealthy. */ async performIO(query) { const { sql, args } = query; const values = args.map((arg, i)=>mapArg(arg, query.argTypes[i])); try { const result = await this.client.query({ text: sql, values, rowMode: "array", types: { // This is the error expected: // No overload matches this call. // The last overload gave the following error. // Type '(oid: number, format?: any) => (json: string) => unknown' is not assignable to type '{ (oid: number): TypeParser; (oid: number, format: "text"): TypeParser; (oid: number, format: "binary"): TypeParser<...>; }'. // Type '(json: string) => unknown' is not assignable to type 'TypeParser'. // Types of parameters 'json' and 'value' are incompatible. // Type 'Buffer' is not assignable to type 'string'.ts(2769) // // Because pg-types types expect us to handle both binary and text protocol versions, // where as far we can see, pg will ever pass only text version. // // @ts-expect-error getTypeParser: (oid, format)=>{ if (format === "text" && customParsers[oid]) { return customParsers[oid]; } return types2.getTypeParser(oid, format); } } }, values); return result; } catch (e) { this.onError(e); } } onError(error) { debug("Error in performIO: %O", error); throw new __TURBOPACK__imported__module__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f40$prisma$2f$driver$2d$adapter$2d$utils$2f$dist$2f$index$2e$mjs__$5b$app$2d$route$5d$__$28$ecmascript$29$__$3c$locals$3e$__["DriverAdapterError"](convertDriverError(error)); } }; var PgTransaction = class extends PgQueryable { constructor(client, options, pgOptions, cleanup){ super(client, pgOptions); this.options = options; this.pgOptions = pgOptions; this.cleanup = cleanup; } async commit() { debug(`[js::commit]`); this.cleanup?.(); this.client.release(); } async rollback() { debug(`[js::rollback]`); this.cleanup?.(); this.client.release(); } }; var PrismaPgAdapter = class extends PgQueryable { constructor(client, pgOptions, release){ super(client); this.pgOptions = pgOptions; this.release = release; } async startTransaction(isolationLevel) { const options = { usePhantomQuery: false }; const tag = "[js::startTransaction]"; debug("%s options: %O", tag, options); const conn = await this.client.connect().catch((error)=>this.onError(error)); const onError = (err)=>{ debug(`Error from pool connection: ${err.message} %O`, err); this.pgOptions?.onConnectionError?.(err); }; conn.on("error", onError); const cleanup = ()=>{ conn.removeListener("error", onError); }; try { const tx = new PgTransaction(conn, options, this.pgOptions, cleanup); await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] }); if (isolationLevel) { await tx.executeRaw({ sql: `SET TRANSACTION ISOLATION LEVEL ${isolationLevel}`, args: [], argTypes: [] }); } return tx; } catch (error) { cleanup(); conn.release(error); this.onError(error); } } async executeScript(script) { const statements = script.split(";").map((stmt)=>stmt.trim()).filter((stmt)=>stmt.length > 0); for (const stmt of statements){ try { await this.client.query(stmt); } catch (error) { this.onError(error); } } } getConnectionInfo() { return { schemaName: this.pgOptions?.schema, supportsRelationJoins: true }; } async dispose() { return this.release?.(); } underlyingDriver() { return this.client; } }; var PrismaPgAdapterFactory = class { constructor(poolOrConfig, options){ this.options = options; if (poolOrConfig instanceof __TURBOPACK__imported__module__$5b$externals$5d2f$pg__$5b$external$5d$__$28$pg$2c$__esm_import$2c$__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$pg$29$__["default"].Pool) { this.externalPool = poolOrConfig; this.config = poolOrConfig.options; } else { this.externalPool = null; this.config = poolOrConfig; } } provider = "postgres"; adapterName = name; config; externalPool; async connect() { const client = this.externalPool ?? new __TURBOPACK__imported__module__$5b$externals$5d2f$pg__$5b$external$5d$__$28$pg$2c$__esm_import$2c$__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$pg$29$__["default"].Pool(this.config); const onIdleClientError = (err)=>{ debug(`Error from idle pool client: ${err.message} %O`, err); this.options?.onPoolError?.(err); }; client.on("error", onIdleClientError); return new PrismaPgAdapter(client, this.options, async ()=>{ if (this.externalPool) { if (this.options?.disposeExternalPool) { await this.externalPool.end(); this.externalPool = null; } else { this.externalPool.removeListener("error", onIdleClientError); } } else { await client.end(); } }); } async connectToShadowDb() { const conn = await this.connect(); const database = `prisma_migrate_shadow_db_${globalThis.crypto.randomUUID()}`; await conn.executeScript(`CREATE DATABASE "${database}"`); const client = new __TURBOPACK__imported__module__$5b$externals$5d2f$pg__$5b$external$5d$__$28$pg$2c$__esm_import$2c$__$5b$project$5d2f$Documents$2f$00__$2d$__projet$2f$plumeia$2f$node_modules$2f$pg$29$__["default"].Pool({ ...this.config, database }); return new PrismaPgAdapter(client, void 0, async ()=>{ await conn.executeScript(`DROP DATABASE "${database}"`); await client.end(); }); } }; ; __turbopack_async_result__(); } catch(e) { __turbopack_async_result__(e); } }, false);}), ]; //# sourceMappingURL=%5Broot-of-the-server%5D__49f1ce3b._.js.map