diff --git a/.changeset/young-jeans-prove.md b/.changeset/young-jeans-prove.md new file mode 100644 index 00000000000..af88c1a39a1 --- /dev/null +++ b/.changeset/young-jeans-prove.md @@ -0,0 +1,5 @@ +--- +'@clerk/nextjs': patch +--- + +Vendor path-to-regexp diff --git a/package-lock.json b/package-lock.json index 00e184216df..d4270ead5cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28869,10 +28869,6 @@ "node": "14 || >=16.14" } }, - "node_modules/path-to-regexp": { - "version": "6.2.1", - "license": "MIT" - }, "node_modules/path-type": { "version": "4.0.0", "license": "MIT", @@ -36685,11 +36681,11 @@ }, "packages/backend": { "name": "@clerk/backend", - "version": "0.38.4", + "version": "0.38.13", "license": "MIT", "dependencies": { - "@clerk/shared": "1.4.0", - "@clerk/types": "3.63.0", + "@clerk/shared": "1.4.1", + "@clerk/types": "3.65.3", "@peculiar/webcrypto": "1.4.1", "@types/node": "16.18.6", "cookie": "0.5.0", @@ -36730,11 +36726,11 @@ }, "packages/chrome-extension": { "name": "@clerk/chrome-extension", - "version": "0.6.18", + "version": "0.7.6", "license": "MIT", "dependencies": { - "@clerk/clerk-js": "4.71.1", - "@clerk/clerk-react": "4.30.8" + "@clerk/clerk-js": "4.73.6", + "@clerk/clerk-react": "4.32.3" }, "devDependencies": { "@types/chrome": "*", @@ -36750,12 +36746,12 @@ }, "packages/clerk-js": { "name": "@clerk/clerk-js", - "version": "4.71.1", + "version": "4.73.6", "license": "MIT", "dependencies": { - "@clerk/localizations": "1.28.0", - "@clerk/shared": "1.4.0", - "@clerk/types": "3.63.0", + "@clerk/localizations": "1.28.8", + "@clerk/shared": "1.4.1", + "@clerk/types": "3.65.3", "@emotion/cache": "11.11.0", "@emotion/react": "11.11.1", "@floating-ui/react": "0.25.4", @@ -37090,17 +37086,17 @@ }, "packages/expo": { "name": "@clerk/clerk-expo", - "version": "0.20.13", + "version": "0.20.28", "license": "MIT", "dependencies": { - "@clerk/clerk-js": "4.71.1", - "@clerk/clerk-react": "4.30.8", - "@clerk/shared": "1.4.0", + "@clerk/clerk-js": "4.73.6", + "@clerk/clerk-react": "4.32.3", + "@clerk/shared": "1.4.1", "base-64": "1.0.0", "react-native-url-polyfill": "2.0.0" }, "devDependencies": { - "@clerk/types": "^3.63.0", + "@clerk/types": "^3.65.3", "@types/base-64": "^1.0.0", "@types/node": "^16.11.55", "@types/react": "*", @@ -37123,12 +37119,12 @@ }, "packages/fastify": { "name": "@clerk/fastify", - "version": "0.6.37", + "version": "0.6.46", "license": "MIT", "dependencies": { - "@clerk/backend": "0.38.4", - "@clerk/shared": "1.4.0", - "@clerk/types": "3.63.0", + "@clerk/backend": "0.38.13", + "@clerk/shared": "1.4.1", + "@clerk/types": "3.65.3", "cookies": "0.8.0" }, "devDependencies": { @@ -37144,13 +37140,13 @@ } }, "packages/gatsby-plugin-clerk": { - "version": "4.4.39", + "version": "4.4.49", "license": "MIT", "dependencies": { - "@clerk/backend": "0.38.4", - "@clerk/clerk-react": "4.30.8", - "@clerk/clerk-sdk-node": "4.13.12", - "@clerk/types": "3.63.0", + "@clerk/backend": "0.38.13", + "@clerk/clerk-react": "4.32.3", + "@clerk/clerk-sdk-node": "4.13.21", + "@clerk/types": "3.65.3", "cookie": "0.5.0", "tslib": "2.4.1" }, @@ -37173,10 +37169,10 @@ }, "packages/localizations": { "name": "@clerk/localizations", - "version": "1.28.0", + "version": "1.28.8", "license": "MIT", "dependencies": { - "@clerk/types": "3.63.0" + "@clerk/types": "3.65.3" }, "devDependencies": { "tsup": "*", @@ -37191,15 +37187,14 @@ }, "packages/nextjs": { "name": "@clerk/nextjs", - "version": "4.29.10", + "version": "4.31.4", "license": "MIT", "dependencies": { - "@clerk/backend": "0.38.4", - "@clerk/clerk-react": "4.30.8", - "@clerk/clerk-sdk-node": "4.13.12", - "@clerk/shared": "1.4.0", - "@clerk/types": "3.63.0", - "path-to-regexp": "6.2.1", + "@clerk/backend": "0.38.13", + "@clerk/clerk-react": "4.32.3", + "@clerk/clerk-sdk-node": "4.13.21", + "@clerk/shared": "1.4.1", + "@clerk/types": "3.65.3", "tslib": "2.4.1" }, "devDependencies": { @@ -37230,11 +37225,11 @@ }, "packages/react": { "name": "@clerk/clerk-react", - "version": "4.30.8", + "version": "4.32.3", "license": "MIT", "dependencies": { - "@clerk/shared": "1.4.0", - "@clerk/types": "3.63.0", + "@clerk/shared": "1.4.1", + "@clerk/types": "3.65.3", "tslib": "2.4.1" }, "devDependencies": { @@ -37256,13 +37251,13 @@ }, "packages/remix": { "name": "@clerk/remix", - "version": "3.2.1", + "version": "3.2.10", "license": "MIT", "dependencies": { - "@clerk/backend": "0.38.4", - "@clerk/clerk-react": "4.30.8", - "@clerk/shared": "1.4.0", - "@clerk/types": "3.63.0", + "@clerk/backend": "0.38.13", + "@clerk/clerk-react": "4.32.3", + "@clerk/shared": "1.4.1", + "@clerk/types": "3.65.3", "cookie": "0.5.0", "tslib": "2.4.1" }, @@ -37291,12 +37286,12 @@ }, "packages/sdk-node": { "name": "@clerk/clerk-sdk-node", - "version": "4.13.12", + "version": "4.13.21", "license": "MIT", "dependencies": { - "@clerk/backend": "0.38.4", - "@clerk/shared": "1.4.0", - "@clerk/types": "3.63.0", + "@clerk/backend": "0.38.13", + "@clerk/shared": "1.4.1", + "@clerk/types": "3.65.3", "@types/cookies": "0.7.7", "@types/express": "4.17.14", "@types/node-fetch": "2.6.2", @@ -37332,7 +37327,7 @@ }, "packages/shared": { "name": "@clerk/shared", - "version": "1.4.0", + "version": "1.4.1", "license": "MIT", "dependencies": { "glob-to-regexp": "0.4.1", @@ -37340,7 +37335,7 @@ "swr": "2.2.0" }, "devDependencies": { - "@clerk/types": "3.63.0", + "@clerk/types": "3.65.3", "@types/glob-to-regexp": "0.4.1", "@types/js-cookie": "3.0.2", "tsup": "*", @@ -37357,10 +37352,10 @@ }, "packages/themes": { "name": "@clerk/themes", - "version": "1.7.11", + "version": "1.7.18", "license": "MIT", "dependencies": { - "@clerk/types": "3.63.0", + "@clerk/types": "3.65.3", "tslib": "2.4.1" }, "devDependencies": { @@ -37380,7 +37375,7 @@ }, "packages/types": { "name": "@clerk/types", - "version": "3.63.0", + "version": "3.65.3", "license": "MIT", "dependencies": { "csstype": "3.1.1" diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 3db5c027ffc..ae25effc2b0 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -92,7 +92,6 @@ "@clerk/clerk-sdk-node": "4.13.21", "@clerk/shared": "1.4.1", "@clerk/types": "3.65.3", - "path-to-regexp": "6.2.1", "tslib": "2.4.1" }, "devDependencies": { diff --git a/packages/nextjs/src/utils/pathMatchers.ts b/packages/nextjs/src/utils/pathMatchers.ts index 7f16c6967df..adc3be2a6da 100644 --- a/packages/nextjs/src/utils/pathMatchers.ts +++ b/packages/nextjs/src/utils/pathMatchers.ts @@ -1,8 +1,9 @@ -import { pathToRegexp } from 'path-to-regexp'; +import { pathToRegexp } from './pathToRegexp'; export const paths = { toRegexp: (path: string) => { try { + // @ts-ignore precompiled package - no types available return pathToRegexp(path); } catch (e: any) { throw new Error( diff --git a/packages/nextjs/src/utils/pathToRegexp.ts b/packages/nextjs/src/utils/pathToRegexp.ts new file mode 100644 index 00000000000..62c1041651b --- /dev/null +++ b/packages/nextjs/src/utils/pathToRegexp.ts @@ -0,0 +1,265 @@ +/* eslint-disable */ +// @ts-nocheck + +/** + * Compiled path-to-regex + * + * The MIT License (MIT) + * + * Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +function _(r) { + for (var n = [], e = 0; e < r.length; ) { + const t = r[e]; + if (t === '*' || t === '+' || t === '?') { + n.push({ type: 'MODIFIER', index: e, value: r[e++] }); + continue; + } + if (t === '\\') { + n.push({ type: 'ESCAPED_CHAR', index: e++, value: r[e++] }); + continue; + } + if (t === '{') { + n.push({ type: 'OPEN', index: e, value: r[e++] }); + continue; + } + if (t === '}') { + n.push({ type: 'CLOSE', index: e, value: r[e++] }); + continue; + } + if (t === ':') { + for (var u = '', a = e + 1; a < r.length; ) { + const f = r.charCodeAt(a); + if ((f >= 48 && f <= 57) || (f >= 65 && f <= 90) || (f >= 97 && f <= 122) || f === 95) { + u += r[a++]; + continue; + } + break; + } + if (!u) { + throw new TypeError('Missing parameter name at '.concat(e)); + } + n.push({ type: 'NAME', index: e, value: u }), (e = a); + continue; + } + if (t === '(') { + var l = 1, + d = '', + a = e + 1; + if (r[a] === '?') { + throw new TypeError('Pattern cannot start with "?" at '.concat(a)); + } + for (; a < r.length; ) { + if (r[a] === '\\') { + d += r[a++] + r[a++]; + continue; + } + if (r[a] === ')') { + if ((l--, l === 0)) { + a++; + break; + } + } else if (r[a] === '(' && (l++, r[a + 1] !== '?')) { + throw new TypeError('Capturing groups are not allowed at '.concat(a)); + } + d += r[a++]; + } + if (l) { + throw new TypeError('Unbalanced pattern at '.concat(e)); + } + if (!d) { + throw new TypeError('Missing pattern at '.concat(e)); + } + n.push({ type: 'PATTERN', index: e, value: d }), (e = a); + continue; + } + n.push({ type: 'CHAR', index: e, value: r[e++] }); + } + return n.push({ type: 'END', index: e, value: '' }), n; +} +function D(r, n) { + n === void 0 && (n = {}); + for ( + var e = _(r), + t = n.prefixes, + u = t === void 0 ? './' : t, + a = '[^'.concat(y(n.delimiter || '/#?'), ']+?'), + f = [], + l = 0, + d = 0, + p = '', + c = function (v) { + if (d < e.length && e[d].type === v) { + return e[d++].value; + } + }, + w = function (v) { + const g = c(v); + if (g !== void 0) { + return g; + } + const h = e[d], + b = h.type, + N = h.index; + throw new TypeError('Unexpected '.concat(b, ' at ').concat(N, ', expected ').concat(v)); + }, + A = function () { + for (var v = '', g; (g = c('CHAR') || c('ESCAPED_CHAR')); ) { + v += g; + } + return v; + }; + d < e.length; + + ) { + const s = c('CHAR'), + C = c('NAME'), + E = c('PATTERN'); + if (C || E) { + var x = s || ''; + u.indexOf(x) === -1 && ((p += x), (x = '')), + p && (f.push(p), (p = '')), + f.push({ name: C || l++, prefix: x, suffix: '', pattern: E || a, modifier: c('MODIFIER') || '' }); + continue; + } + const o = s || c('ESCAPED_CHAR'); + if (o) { + p += o; + continue; + } + p && (f.push(p), (p = '')); + const R = c('OPEN'); + if (R) { + var x = A(), + T = c('NAME') || '', + i = c('PATTERN') || '', + m = A(); + w('CLOSE'), + f.push({ + name: T || (i ? l++ : ''), + pattern: T && !i ? a : i, + prefix: x, + suffix: m, + modifier: c('MODIFIER') || '', + }); + continue; + } + w('END'); + } + return f; +} +function y(r) { + return r.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1'); +} +function O(r) { + return r && r.sensitive ? '' : 'i'; +} +function M(r, n) { + if (!n) { + return r; + } + for (let e = /\((?:\?<(.*?)>)?(?!\?)/g, t = 0, u = e.exec(r.source); u; ) { + n.push({ name: u[1] || t++, prefix: '', suffix: '', modifier: '', pattern: '' }), (u = e.exec(r.source)); + } + return r; +} +function S(r, n, e) { + const t = r.map(function (u) { + return P(u, n, e).source; + }); + return new RegExp('(?:'.concat(t.join('|'), ')'), O(e)); +} +function F(r, n, e) { + return H(D(r, e), n, e); +} +function H(r, n, e) { + e === void 0 && (e = {}); + for ( + var t = e.strict, + u = t === void 0 ? !1 : t, + a = e.start, + f = a === void 0 ? !0 : a, + l = e.end, + d = l === void 0 ? !0 : l, + p = e.encode, + c = + p === void 0 + ? function (N) { + return N; + } + : p, + w = e.delimiter, + A = w === void 0 ? '/#?' : w, + s = e.endsWith, + C = s === void 0 ? '' : s, + E = '['.concat(y(C), ']|$'), + x = '['.concat(y(A), ']'), + o = f ? '^' : '', + R = 0, + T = r; + R < T.length; + R++ + ) { + const i = T[R]; + if (typeof i == 'string') { + o += y(c(i)); + } else { + const m = y(c(i.prefix)), + v = y(c(i.suffix)); + if (i.pattern) { + if ((n && n.push(i), m || v)) { + if (i.modifier === '+' || i.modifier === '*') { + const g = i.modifier === '*' ? '?' : ''; + o += '(?:' + .concat(m, '((?:') + .concat(i.pattern, ')(?:') + .concat(v) + .concat(m, '(?:') + .concat(i.pattern, '))*)') + .concat(v, ')') + .concat(g); + } else { + o += '(?:'.concat(m, '(').concat(i.pattern, ')').concat(v, ')').concat(i.modifier); + } + } else { + i.modifier === '+' || i.modifier === '*' + ? (o += '((?:'.concat(i.pattern, ')').concat(i.modifier, ')')) + : (o += '('.concat(i.pattern, ')').concat(i.modifier)); + } + } else { + o += '(?:'.concat(m).concat(v, ')').concat(i.modifier); + } + } + } + if (d) { + u || (o += ''.concat(x, '?')), (o += e.endsWith ? '(?='.concat(E, ')') : '$'); + } else { + const h = r[r.length - 1], + b = typeof h == 'string' ? x.indexOf(h[h.length - 1]) > -1 : h === void 0; + u || (o += '(?:'.concat(x, '(?=').concat(E, '))?')), b || (o += '(?='.concat(x, '|').concat(E, ')')); + } + return new RegExp(o, O(e)); +} +function P(r, n, e) { + return r instanceof RegExp ? M(r, n) : Array.isArray(r) ? S(r, n, e) : F(r, n, e); +} +export { P as pathToRegexp };