@civic/auth 0.0.1-beta.15 → 0.0.1-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3Q3CWGPG.mjs → chunk-5XL2ST72.mjs} +45 -14
- package/dist/chunk-5XL2ST72.mjs.map +1 -0
- package/dist/{chunk-EDLPS3AK.mjs → chunk-G3P5TIO2.mjs} +3 -1
- package/dist/chunk-G3P5TIO2.mjs.map +1 -0
- package/dist/{chunk-F2CKPLXX.js → chunk-RF23Q4V6.js} +4 -2
- package/dist/chunk-RF23Q4V6.js.map +1 -0
- package/dist/{chunk-F55XKBNM.js → chunk-SEKF2WZX.js} +50 -19
- package/dist/chunk-SEKF2WZX.js.map +1 -0
- package/dist/{index-Bq3T3FPG.d.ts → index-DTimUlkB.d.ts} +2 -1
- package/dist/{index-GtnyFGD2.d.mts → index-DvjkKpkk.d.mts} +2 -1
- package/dist/index.css +2 -6
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/nextjs.d.mts +3 -9
- package/dist/nextjs.d.ts +3 -9
- package/dist/nextjs.js +29 -24
- package/dist/nextjs.js.map +1 -1
- package/dist/nextjs.mjs +10 -5
- package/dist/nextjs.mjs.map +1 -1
- package/dist/react.d.mts +16 -10
- package/dist/react.d.ts +16 -10
- package/dist/react.js +156 -92
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +174 -110
- package/dist/react.mjs.map +1 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -2
- package/dist/server.mjs +1 -1
- package/dist/{types-Bfi0hVMZ.d.mts → types-HdCjGldB.d.mts} +2 -2
- package/dist/{types-Bfi0hVMZ.d.ts → types-HdCjGldB.d.ts} +2 -2
- package/dist/types-b4c1koXj.d.mts +19 -0
- package/dist/types-b4c1koXj.d.ts +19 -0
- package/package.json +3 -3
- package/dist/chunk-3Q3CWGPG.mjs.map +0 -1
- package/dist/chunk-EDLPS3AK.mjs.map +0 -1
- package/dist/chunk-F2CKPLXX.js.map +0 -1
- package/dist/chunk-F55XKBNM.js.map +0 -1
package/dist/index.css
CHANGED
|
@@ -166,8 +166,8 @@
|
|
|
166
166
|
.cac-h-8 {
|
|
167
167
|
height: 2rem;
|
|
168
168
|
}
|
|
169
|
-
.cac-h
|
|
170
|
-
height:
|
|
169
|
+
.cac-h-\[26rem\] {
|
|
170
|
+
height: 26rem;
|
|
171
171
|
}
|
|
172
172
|
.cac-h-full {
|
|
173
173
|
height: 100%;
|
|
@@ -238,10 +238,6 @@
|
|
|
238
238
|
--tw-border-opacity: 1;
|
|
239
239
|
border-color: rgb(115 115 115 / var(--tw-border-opacity));
|
|
240
240
|
}
|
|
241
|
-
.cac-bg-neutral-100 {
|
|
242
|
-
--tw-bg-opacity: 1;
|
|
243
|
-
background-color: rgb(245 245 245 / var(--tw-bg-opacity));
|
|
244
|
-
}
|
|
245
241
|
.cac-bg-neutral-950 {
|
|
246
242
|
--tw-bg-opacity: 1;
|
|
247
243
|
background-color: rgb(10 10 10 / var(--tw-bg-opacity));
|
package/dist/index.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/styles.css"],"sourcesContent":["*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: \n}\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: \n}\n.cac-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0\n}\n.cac-absolute {\n position: absolute\n}\n.cac-relative {\n position: relative\n}\n.cac-inset-0 {\n inset: 0px\n}\n.cac-left-0 {\n left: 0px\n}\n.cac-right-0 {\n right: 0px\n}\n.cac-right-4 {\n right: 1rem\n}\n.cac-top-0 {\n top: 0px\n}\n.cac-top-4 {\n top: 1rem\n}\n.cac-z-50 {\n z-index: 50\n}\n.cac-mt-2 {\n margin-top: 0.5rem\n}\n.cac-block {\n display: block\n}\n.cac-inline {\n display: inline\n}\n.cac-flex {\n display: flex\n}\n.cac-hidden {\n display: none\n}\n.cac-h-10 {\n height: 2.5rem\n}\n.cac-h-8 {\n height: 2rem\n}\n.cac-h-96 {\n height: 24rem\n}\n.cac-h-full {\n height: 100%\n}\n.cac-h-screen {\n height: 100vh\n}\n.cac-w-10 {\n width: 2.5rem\n}\n.cac-w-8 {\n width: 2rem\n}\n.cac-w-80 {\n width: 20rem\n}\n.cac-w-full {\n width: 100%\n}\n.cac-w-screen {\n width: 100vw\n}\n.cac-shrink-0 {\n flex-shrink: 0\n}\n@keyframes cac-spin {\n to {\n transform: rotate(360deg)\n }\n}\n.cac-animate-spin {\n animation: cac-spin 1s linear infinite\n}\n.cac-cursor-pointer {\n cursor: pointer\n}\n.cac-items-center {\n align-items: center\n}\n.cac-justify-center {\n justify-content: center\n}\n.cac-justify-between {\n justify-content: space-between\n}\n.cac-gap-2 {\n gap: 0.5rem\n}\n.cac-overflow-hidden {\n overflow: hidden\n}\n.cac-rounded-3xl {\n border-radius: 1.5rem\n}\n.cac-rounded-full {\n border-radius: 9999px\n}\n.cac-rounded-lg {\n border-radius: 0.5rem\n}\n.cac-border {\n border-width: 1px\n}\n.cac-border-none {\n border-style: none\n}\n.cac-border-neutral-500 {\n --tw-border-opacity: 1;\n border-color: rgb(115 115 115 / var(--tw-border-opacity))\n}\n.cac-bg-neutral-100 {\n --tw-bg-opacity: 1;\n background-color: rgb(245 245 245 / var(--tw-bg-opacity))\n}\n.cac-bg-neutral-950 {\n --tw-bg-opacity: 1;\n background-color: rgb(10 10 10 / var(--tw-bg-opacity))\n}\n.cac-bg-transparent {\n background-color: transparent\n}\n.cac-bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity))\n}\n.cac-bg-opacity-50 {\n --tw-bg-opacity: 0.5\n}\n.cac-fill-neutral-600 {\n fill: #525252\n}\n.cac-object-cover {\n -o-object-fit: cover;\n object-fit: cover\n}\n.cac-p-1 {\n padding: 0.25rem\n}\n.cac-p-6 {\n padding: 1.5rem\n}\n.cac-px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem\n}\n.cac-px-4 {\n padding-left: 1rem;\n padding-right: 1rem\n}\n.cac-py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem\n}\n.cac-text-neutral-200 {\n --tw-text-opacity: 1;\n color: rgb(229 229 229 / var(--tw-text-opacity))\n}\n.cac-text-neutral-400 {\n --tw-text-opacity: 1;\n color: rgb(163 163 163 / var(--tw-text-opacity))\n}\n.cac-text-neutral-500 {\n --tw-text-opacity: 1;\n color: rgb(115 115 115 / var(--tw-text-opacity))\n}\n.cac-shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)\n}\n.cac-shadow-xl {\n --tw-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)\n}\n.cac-transition-colors {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms\n}\n.hover\\:cac-bg-neutral-200:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(229 229 229 / var(--tw-bg-opacity))\n}\n.hover\\:cac-bg-opacity-50:hover {\n --tw-bg-opacity: 0.5\n}\n@media (prefers-color-scheme: dark) {\n .dark\\:cac-fill-neutral-300 {\n fill: #d4d4d4\n }\n .dark\\:cac-text-neutral-600 {\n --tw-text-opacity: 1;\n color: rgb(82 82 82 / var(--tw-text-opacity))\n }\n}\n"],"mappings":";AAAA;AAAG;AAAU;AACT,yBAAuB;AACvB,yBAAuB;AACvB,oBAAkB;AAClB,oBAAkB;AAClB,eAAa;AACb,eAAa;AACb,eAAa;AACb,gBAAc;AACd,gBAAc;AACd;AACA;AACA;AACA,+BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAAwB;AACxB,0BAAwB;AACxB,mBAAiB,IAAI,GAAG,IAAI,IAAI,EAAE;AAClC,2BAAyB,EAAE,EAAE;AAC7B,oBAAkB,EAAE,EAAE;AACtB,eAAa,EAAE,EAAE;AACjB,uBAAqB,EAAE,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACJ;AACA;AACI,yBAAuB;AACvB,yBAAuB;AACvB,oBAAkB;AAClB,oBAAkB;AAClB,eAAa;AACb,eAAa;AACb,eAAa;AACb,gBAAc;AACd,gBAAc;AACd;AACA;AACA;AACA,+BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAAwB;AACxB,0BAAwB;AACxB,mBAAiB,IAAI,GAAG,IAAI,IAAI,EAAE;AAClC,2BAAyB,EAAE,EAAE;AAC7B,oBAAkB,EAAE,EAAE;AACtB,eAAa,EAAE,EAAE;AACjB,uBAAqB,EAAE,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACJ;AACA,CAAC;AACG,YAAU;AACV,SAAO;AACP,UAAQ;AACR,WAAS;AACT,UAAQ;AACR,YAAU;AACV,QAAM,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;AACpB,eAAa;AACb,gBAAc;AAClB;AACA,CAAC;AACG,YAAU;AACd;AACA,CAAC;AACG,YAAU;AACd;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,QAAM;AACV;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,OAAK;AACT;AACA,CAAC;AACG,OAAK;AACT;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,cAAY;AAChB;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC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AC,oBAAoB,EAAE;AAC1B,GAAC;AACG,UAAM;AACV;AACA,GAAC;AACG,uBAAmB;AACnB,WAAO,IAAI,GAAG,GAAG,GAAG,EAAE,IAAI;AAC9B;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/styles.css"],"sourcesContent":["*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: \n}\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: \n}\n.cac-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0\n}\n.cac-absolute {\n position: absolute\n}\n.cac-relative {\n position: relative\n}\n.cac-inset-0 {\n inset: 0px\n}\n.cac-left-0 {\n left: 0px\n}\n.cac-right-0 {\n right: 0px\n}\n.cac-right-4 {\n right: 1rem\n}\n.cac-top-0 {\n top: 0px\n}\n.cac-top-4 {\n top: 1rem\n}\n.cac-z-50 {\n z-index: 50\n}\n.cac-mt-2 {\n margin-top: 0.5rem\n}\n.cac-block {\n display: block\n}\n.cac-inline {\n display: inline\n}\n.cac-flex {\n display: flex\n}\n.cac-hidden {\n display: none\n}\n.cac-h-10 {\n height: 2.5rem\n}\n.cac-h-8 {\n height: 2rem\n}\n.cac-h-\\[26rem\\] {\n height: 26rem\n}\n.cac-h-full {\n height: 100%\n}\n.cac-h-screen {\n height: 100vh\n}\n.cac-w-10 {\n width: 2.5rem\n}\n.cac-w-8 {\n width: 2rem\n}\n.cac-w-80 {\n width: 20rem\n}\n.cac-w-full {\n width: 100%\n}\n.cac-w-screen {\n width: 100vw\n}\n.cac-shrink-0 {\n flex-shrink: 0\n}\n@keyframes cac-spin {\n to {\n transform: rotate(360deg)\n }\n}\n.cac-animate-spin {\n animation: cac-spin 1s linear infinite\n}\n.cac-cursor-pointer {\n cursor: pointer\n}\n.cac-items-center {\n align-items: center\n}\n.cac-justify-center {\n justify-content: center\n}\n.cac-justify-between {\n justify-content: space-between\n}\n.cac-gap-2 {\n gap: 0.5rem\n}\n.cac-overflow-hidden {\n overflow: hidden\n}\n.cac-rounded-3xl {\n border-radius: 1.5rem\n}\n.cac-rounded-full {\n border-radius: 9999px\n}\n.cac-rounded-lg {\n border-radius: 0.5rem\n}\n.cac-border {\n border-width: 1px\n}\n.cac-border-none {\n border-style: none\n}\n.cac-border-neutral-500 {\n --tw-border-opacity: 1;\n border-color: rgb(115 115 115 / var(--tw-border-opacity))\n}\n.cac-bg-neutral-950 {\n --tw-bg-opacity: 1;\n background-color: rgb(10 10 10 / var(--tw-bg-opacity))\n}\n.cac-bg-transparent {\n background-color: transparent\n}\n.cac-bg-white {\n --tw-bg-opacity: 1;\n background-color: rgb(255 255 255 / var(--tw-bg-opacity))\n}\n.cac-bg-opacity-50 {\n --tw-bg-opacity: 0.5\n}\n.cac-fill-neutral-600 {\n fill: #525252\n}\n.cac-object-cover {\n -o-object-fit: cover;\n object-fit: cover\n}\n.cac-p-1 {\n padding: 0.25rem\n}\n.cac-p-6 {\n padding: 1.5rem\n}\n.cac-px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem\n}\n.cac-px-4 {\n padding-left: 1rem;\n padding-right: 1rem\n}\n.cac-py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem\n}\n.cac-text-neutral-200 {\n --tw-text-opacity: 1;\n color: rgb(229 229 229 / var(--tw-text-opacity))\n}\n.cac-text-neutral-400 {\n --tw-text-opacity: 1;\n color: rgb(163 163 163 / var(--tw-text-opacity))\n}\n.cac-text-neutral-500 {\n --tw-text-opacity: 1;\n color: rgb(115 115 115 / var(--tw-text-opacity))\n}\n.cac-shadow-lg {\n --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)\n}\n.cac-shadow-xl {\n --tw-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)\n}\n.cac-transition-colors {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms\n}\n.hover\\:cac-bg-neutral-200:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(229 229 229 / var(--tw-bg-opacity))\n}\n.hover\\:cac-bg-opacity-50:hover {\n --tw-bg-opacity: 0.5\n}\n@media (prefers-color-scheme: dark) {\n .dark\\:cac-fill-neutral-300 {\n fill: #d4d4d4\n }\n .dark\\:cac-text-neutral-600 {\n --tw-text-opacity: 1;\n color: rgb(82 82 82 / var(--tw-text-opacity))\n }\n}\n"],"mappings":";AAAA;AAAG;AAAU;AACT,yBAAuB;AACvB,yBAAuB;AACvB,oBAAkB;AAClB,oBAAkB;AAClB,eAAa;AACb,eAAa;AACb,eAAa;AACb,gBAAc;AACd,gBAAc;AACd;AACA;AACA;AACA,+BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAAwB;AACxB,0BAAwB;AACxB,mBAAiB,IAAI,GAAG,IAAI,IAAI,EAAE;AAClC,2BAAyB,EAAE,EAAE;AAC7B,oBAAkB,EAAE,EAAE;AACtB,eAAa,EAAE,EAAE;AACjB,uBAAqB,EAAE,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACJ;AACA;AACI,yBAAuB;AACvB,yBAAuB;AACvB,oBAAkB;AAClB,oBAAkB;AAClB,eAAa;AACb,eAAa;AACb,eAAa;AACb,gBAAc;AACd,gBAAc;AACd;AACA;AACA;AACA,+BAA6B;AAC7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0BAAwB;AACxB,0BAAwB;AACxB,mBAAiB,IAAI,GAAG,IAAI,IAAI,EAAE;AAClC,2BAAyB,EAAE,EAAE;AAC7B,oBAAkB,EAAE,EAAE;AACtB,eAAa,EAAE,EAAE;AACjB,uBAAqB,EAAE,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACJ;AACA,CAAC;AACG,YAAU;AACV,SAAO;AACP,UAAQ;AACR,WAAS;AACT,UAAQ;AACR,YAAU;AACV,QAAM,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE;AACpB,eAAa;AACb,gBAAc;AAClB;AACA,CAAC;AACG,YAAU;AACd;AACA,CAAC;AACG,YAAU;AACd;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,QAAM;AACV;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,OAAK;AACT;AACA,CAAC;AACG,OAAK;AACT;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,cAAY;AAChB;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,WAAS;AACb;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,SAAO;AACX;AACA,CAAC;AACG,eAAa;AACjB;AACA,WAAW;AACP;AACI,eAAW,OAAO;AACtB;AACJ;AACA,CAAC;AACG,aAAW,SAAS,GAAG,OAAO;AAClC;AACA,CAAC;AACG,UAAQ;AACZ;AACA,CAAC;AACG,eAAa;AACjB;AACA,CAAC;AACG,mBAAiB;AACrB;AACA,CAAC;AACG,mBAAiB;AACrB;AACA,CAAC;AACG,OAAK;AACT;AACA,CAAC;AACG,YAAU;AACd;AACA,CAAC;AACG,iBAAe;AACnB;AACA,CAAC;AACG,iBAAe;AACnB;AACA,CAAC;AACG,iBAAe;AACnB;AACA,CAAC;AACG,gBAAc;AAClB;AACA,CAAC;AACG,gBAAc;AAClB;AACA,CAAC;AACG,uBAAqB;AACrB,gBAAc,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI;AACxC;AACA,CAAC;AACG,mBAAiB;AACjB,oBAAkB,IAAI,GAAG,GAAG,GAAG,EAAE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ClF;AAAA,IAAY,IAAI,uBAAuB,EAAE,EAAE,EAAE,MAAM;AAAA,IAAE,IAAI,gBAAgB,EAAE,EAAE,EAAE,MAAM;AAAA,IAAE,IAAI;AAC/F;AACA,CAAC;AACG;AAAA,IAAqB,KAAK;AAAA,IAAE,gBAAgB;AAAA,IAAE,YAAY;AAAA,IAAE,qBAAqB;AAAA,IAAE,IAAI;AAAA,IAAE;AACzF,8BAA4B,aAAa,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE;AACtD,uBAAqB;AACzB;AACA,CAAC,yBAAyB;AACtB,mBAAiB;AACjB,oBAAkB,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI;AAC5C;AACA,CAAC,wBAAwB;AACrB,mBAAiB;AACrB;AACA,OAAO,CAAC,oBAAoB,EAAE;AAC1B,GAAC;AACG,UAAM;AACV;AACA,GAAC;AACG,uBAAmB;AACnB,WAAO,IAAI,GAAG,GAAG,GAAG,EAAE,IAAI;AAC9B;AACJ;","names":[]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { A as AuthStorage, C as Config, D as DisplayMode, E as Endpoints, F as ForwardedTokens, T as Tokens, U as User } from './types-
|
|
2
|
-
export { U as
|
|
1
|
+
export { A as AuthStorage, C as Config, D as DisplayMode, E as Endpoints, F as ForwardedTokens, T as Tokens, U as User } from './types-HdCjGldB.mjs';
|
|
2
|
+
export { C as CookieConfig, O as OAuthTokens, T as TokensCookieConfig, U as UserStorage } from './types-b4c1koXj.mjs';
|
|
3
|
+
export { U as UserContextType } from './index-DvjkKpkk.mjs';
|
|
3
4
|
import 'oslo/oauth2';
|
|
4
5
|
import 'oslo/jwt';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { A as AuthStorage, C as Config, D as DisplayMode, E as Endpoints, F as ForwardedTokens, T as Tokens, U as User } from './types-
|
|
2
|
-
export { U as
|
|
1
|
+
export { A as AuthStorage, C as Config, D as DisplayMode, E as Endpoints, F as ForwardedTokens, T as Tokens, U as User } from './types-HdCjGldB.js';
|
|
2
|
+
export { C as CookieConfig, O as OAuthTokens, T as TokensCookieConfig, U as UserStorage } from './types-b4c1koXj.js';
|
|
3
|
+
export { U as UserContextType } from './index-DTimUlkB.js';
|
|
3
4
|
import 'oslo/oauth2';
|
|
4
5
|
import 'oslo/jwt';
|
package/dist/nextjs.d.mts
CHANGED
|
@@ -2,17 +2,11 @@ import * as next_dist_shared_lib_image_config from 'next/dist/shared/lib/image-c
|
|
|
2
2
|
import * as next_dist_lib_load_custom_routes from 'next/dist/lib/load-custom-routes';
|
|
3
3
|
import * as next_dist_server_config_shared from 'next/dist/server/config-shared';
|
|
4
4
|
import { NextConfig } from 'next';
|
|
5
|
-
import {
|
|
5
|
+
import { T as TokensCookieConfig, C as CookieConfig } from './types-b4c1koXj.mjs';
|
|
6
|
+
import { U as User } from './types-HdCjGldB.mjs';
|
|
6
7
|
import { NextRequest, NextResponse } from 'next/server.js';
|
|
7
8
|
import 'oslo/oauth2';
|
|
8
9
|
|
|
9
|
-
interface CookieConfig {
|
|
10
|
-
secure?: boolean;
|
|
11
|
-
sameSite?: "strict" | "lax" | "none";
|
|
12
|
-
domain?: string;
|
|
13
|
-
path?: string;
|
|
14
|
-
maxAge?: number;
|
|
15
|
-
}
|
|
16
10
|
type AuthConfigWithDefaults = {
|
|
17
11
|
clientId: string;
|
|
18
12
|
oauthServer: string;
|
|
@@ -24,7 +18,7 @@ type AuthConfigWithDefaults = {
|
|
|
24
18
|
include: string[];
|
|
25
19
|
exclude: string[];
|
|
26
20
|
cookies: {
|
|
27
|
-
tokens:
|
|
21
|
+
tokens: TokensCookieConfig;
|
|
28
22
|
user: CookieConfig;
|
|
29
23
|
};
|
|
30
24
|
};
|
package/dist/nextjs.d.ts
CHANGED
|
@@ -2,17 +2,11 @@ import * as next_dist_shared_lib_image_config from 'next/dist/shared/lib/image-c
|
|
|
2
2
|
import * as next_dist_lib_load_custom_routes from 'next/dist/lib/load-custom-routes';
|
|
3
3
|
import * as next_dist_server_config_shared from 'next/dist/server/config-shared';
|
|
4
4
|
import { NextConfig } from 'next';
|
|
5
|
-
import {
|
|
5
|
+
import { T as TokensCookieConfig, C as CookieConfig } from './types-b4c1koXj.js';
|
|
6
|
+
import { U as User } from './types-HdCjGldB.js';
|
|
6
7
|
import { NextRequest, NextResponse } from 'next/server.js';
|
|
7
8
|
import 'oslo/oauth2';
|
|
8
9
|
|
|
9
|
-
interface CookieConfig {
|
|
10
|
-
secure?: boolean;
|
|
11
|
-
sameSite?: "strict" | "lax" | "none";
|
|
12
|
-
domain?: string;
|
|
13
|
-
path?: string;
|
|
14
|
-
maxAge?: number;
|
|
15
|
-
}
|
|
16
10
|
type AuthConfigWithDefaults = {
|
|
17
11
|
clientId: string;
|
|
18
12
|
oauthServer: string;
|
|
@@ -24,7 +18,7 @@ type AuthConfigWithDefaults = {
|
|
|
24
18
|
include: string[];
|
|
25
19
|
exclude: string[];
|
|
26
20
|
cookies: {
|
|
27
|
-
tokens:
|
|
21
|
+
tokens: TokensCookieConfig;
|
|
28
22
|
user: CookieConfig;
|
|
29
23
|
};
|
|
30
24
|
};
|
package/dist/nextjs.js
CHANGED
|
@@ -7,14 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _chunkSEKF2WZXjs = require('./chunk-SEKF2WZX.js');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
var _chunkRF23Q4V6js = require('./chunk-RF23Q4V6.js');
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
|
|
@@ -24,9 +25,9 @@ var _chunkCRTRMMJ7js = require('./chunk-CRTRMMJ7.js');
|
|
|
24
25
|
// src/nextjs/GetUser.ts
|
|
25
26
|
var getUser2 = () => {
|
|
26
27
|
var _a;
|
|
27
|
-
const clientStorage = new (0,
|
|
28
|
-
const userSession = new (0,
|
|
29
|
-
const tokens =
|
|
28
|
+
const clientStorage = new (0, _chunkSEKF2WZXjs.NextjsClientStorage)();
|
|
29
|
+
const userSession = new (0, _chunkRF23Q4V6js.GenericUserSession)(clientStorage);
|
|
30
|
+
const tokens = _chunkRF23Q4V6js.retrieveTokens.call(void 0, clientStorage);
|
|
30
31
|
const user = userSession.get();
|
|
31
32
|
if (!user || !tokens) return null;
|
|
32
33
|
return _chunkCRTRMMJ7js.__spreadProps.call(void 0, _chunkCRTRMMJ7js.__spreadValues.call(void 0, {}, user), {
|
|
@@ -53,7 +54,7 @@ var matchesGlobs = (pathname, patterns) => patterns.some((pattern) => {
|
|
|
53
54
|
return matchGlob(pathname, pattern);
|
|
54
55
|
});
|
|
55
56
|
var applyAuth = (authConfig, request) => _chunkCRTRMMJ7js.__async.call(void 0, void 0, null, function* () {
|
|
56
|
-
const authConfigWithDefaults =
|
|
57
|
+
const authConfigWithDefaults = _chunkSEKF2WZXjs.resolveAuthConfig.call(void 0, authConfig);
|
|
57
58
|
const isAuthenticated = !!request.cookies.get("id_token");
|
|
58
59
|
if (request.nextUrl.pathname === authConfigWithDefaults.loginUrl) {
|
|
59
60
|
console.log("\u2192 Skipping auth check - this is the login URL");
|
|
@@ -75,7 +76,7 @@ var applyAuth = (authConfig, request) => _chunkCRTRMMJ7js.__async.call(void 0, v
|
|
|
75
76
|
console.log("\u2192 Auth check passed");
|
|
76
77
|
return void 0;
|
|
77
78
|
});
|
|
78
|
-
var authMiddleware = (authConfig =
|
|
79
|
+
var authMiddleware = (authConfig = _chunkSEKF2WZXjs.defaultAuthConfig) => (request) => _chunkCRTRMMJ7js.__async.call(void 0, void 0, null, function* () {
|
|
79
80
|
const response = yield applyAuth(authConfig, request);
|
|
80
81
|
if (response) return response;
|
|
81
82
|
return _serverjs.NextResponse.next();
|
|
@@ -100,7 +101,7 @@ function auth(authConfig = {}) {
|
|
|
100
101
|
// src/nextjs/routeHandler.ts
|
|
101
102
|
|
|
102
103
|
var _cachejs = require('next/cache.js');
|
|
103
|
-
var logger =
|
|
104
|
+
var logger = _chunkSEKF2WZXjs.loggers.nextjs.handlers.auth;
|
|
104
105
|
var AuthError = class extends Error {
|
|
105
106
|
constructor(message, status = 401) {
|
|
106
107
|
super(message);
|
|
@@ -110,8 +111,8 @@ var AuthError = class extends Error {
|
|
|
110
111
|
};
|
|
111
112
|
function handleChallenge() {
|
|
112
113
|
return _chunkCRTRMMJ7js.__async.call(void 0, this, null, function* () {
|
|
113
|
-
const cookieStorage = new (0,
|
|
114
|
-
const pkceProducer = new (0,
|
|
114
|
+
const cookieStorage = new (0, _chunkSEKF2WZXjs.NextjsCookieStorage)();
|
|
115
|
+
const pkceProducer = new (0, _chunkRF23Q4V6js.GenericPublicClientPKCEProducer)(cookieStorage);
|
|
115
116
|
const challenge = yield pkceProducer.getCodeChallenge();
|
|
116
117
|
return _serverjs.NextResponse.json({ status: "success", challenge });
|
|
117
118
|
});
|
|
@@ -119,31 +120,35 @@ function handleChallenge() {
|
|
|
119
120
|
function handleCallback(request, config) {
|
|
120
121
|
return _chunkCRTRMMJ7js.__async.call(void 0, this, null, function* () {
|
|
121
122
|
if (!request.cookies.get("code_verifier")) {
|
|
122
|
-
const response2 = new (0, _serverjs.NextResponse)(
|
|
123
|
+
const response2 = new (0, _serverjs.NextResponse)(
|
|
124
|
+
`<html><body><span style="display:none">${_chunkRF23Q4V6js.TOKEN_EXCHANGE_TRIGGER_TEXT}</span></body></html>`
|
|
125
|
+
);
|
|
123
126
|
response2.headers.set("Content-Type", "text/html; charset=utf-8");
|
|
124
|
-
console.log(
|
|
127
|
+
console.log(
|
|
128
|
+
`handleCallback no code_verifier found, returning ${_chunkRF23Q4V6js.TOKEN_EXCHANGE_TRIGGER_TEXT}`
|
|
129
|
+
);
|
|
125
130
|
return response2;
|
|
126
131
|
}
|
|
127
132
|
const code = request.nextUrl.searchParams.get("code");
|
|
128
133
|
const state = request.nextUrl.searchParams.get("state");
|
|
129
134
|
if (!code || !state) throw new AuthError("Bad parameters", 400);
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const callbackUrl =
|
|
135
|
+
const resolvedConfigs = _chunkSEKF2WZXjs.resolveAuthConfig.call(void 0, config);
|
|
136
|
+
const cookieStorage = new (0, _chunkSEKF2WZXjs.NextjsCookieStorage)(resolvedConfigs.cookies.tokens);
|
|
137
|
+
const callbackUrl = _chunkSEKF2WZXjs.resolveCallbackUrl.call(void 0, resolvedConfigs, request.url);
|
|
133
138
|
try {
|
|
134
|
-
yield
|
|
139
|
+
yield _chunkRF23Q4V6js.resolveOAuthAccessCode.call(void 0, code, state, cookieStorage, _chunkCRTRMMJ7js.__spreadProps.call(void 0, _chunkCRTRMMJ7js.__spreadValues.call(void 0, {}, resolvedConfigs), {
|
|
135
140
|
redirectUrl: callbackUrl
|
|
136
141
|
}));
|
|
137
142
|
} catch (error) {
|
|
138
143
|
logger.error("Token exchange failed:", error);
|
|
139
144
|
throw new AuthError("Failed to authenticate user", 401);
|
|
140
145
|
}
|
|
141
|
-
const user = yield
|
|
146
|
+
const user = yield _chunkRF23Q4V6js.getUser.call(void 0, cookieStorage);
|
|
142
147
|
if (!user) {
|
|
143
148
|
throw new AuthError("Failed to get user info", 401);
|
|
144
149
|
}
|
|
145
|
-
const clientStorage = new (0,
|
|
146
|
-
const userSession = new (0,
|
|
150
|
+
const clientStorage = new (0, _chunkSEKF2WZXjs.NextjsClientStorage)();
|
|
151
|
+
const userSession = new (0, _chunkRF23Q4V6js.GenericUserSession)(clientStorage);
|
|
147
152
|
userSession.set(user);
|
|
148
153
|
const response = new (0, _serverjs.NextResponse)(`<html></html>`);
|
|
149
154
|
response.headers.set("Content-Type", "text/html; charset=utf-8");
|
|
@@ -159,7 +164,7 @@ var getAbsoluteRedirectPath = (redirectPath, currentBasePath) => {
|
|
|
159
164
|
function handleLogout(request, config) {
|
|
160
165
|
return _chunkCRTRMMJ7js.__async.call(void 0, this, null, function* () {
|
|
161
166
|
var _a;
|
|
162
|
-
const resolvedConfigs =
|
|
167
|
+
const resolvedConfigs = _chunkSEKF2WZXjs.resolveAuthConfig.call(void 0, config);
|
|
163
168
|
const defaultRedirectPath = (_a = resolvedConfigs.loginUrl) != null ? _a : "/";
|
|
164
169
|
const redirectTarget = new URL(request.url).searchParams.get("redirect") || defaultRedirectPath;
|
|
165
170
|
const isAbsoluteRedirect = /^(https?:\/\/|www\.).+/i.test(redirectTarget);
|
|
@@ -168,7 +173,7 @@ function handleLogout(request, config) {
|
|
|
168
173
|
new URL(request.url).origin
|
|
169
174
|
);
|
|
170
175
|
const response = _serverjs.NextResponse.redirect(finalRedirectUrl);
|
|
171
|
-
|
|
176
|
+
_chunkSEKF2WZXjs.clearAuthCookies.call(void 0, );
|
|
172
177
|
try {
|
|
173
178
|
_cachejs.revalidatePath.call(void 0, isAbsoluteRedirect ? finalRedirectUrl : redirectTarget);
|
|
174
179
|
} catch (error) {
|
|
@@ -178,7 +183,7 @@ function handleLogout(request, config) {
|
|
|
178
183
|
});
|
|
179
184
|
}
|
|
180
185
|
var handler = (authConfig = {}) => (request) => _chunkCRTRMMJ7js.__async.call(void 0, void 0, null, function* () {
|
|
181
|
-
const config =
|
|
186
|
+
const config = _chunkSEKF2WZXjs.resolveAuthConfig.call(void 0, authConfig);
|
|
182
187
|
try {
|
|
183
188
|
const pathname = request.nextUrl.pathname;
|
|
184
189
|
const pathSegments = pathname.split("/");
|
|
@@ -198,7 +203,7 @@ var handler = (authConfig = {}) => (request) => _chunkCRTRMMJ7js.__async.call(vo
|
|
|
198
203
|
const status = error instanceof AuthError ? error.status : 500;
|
|
199
204
|
const message = error instanceof Error ? error.message : "Authentication failed";
|
|
200
205
|
const response = _serverjs.NextResponse.json({ error: message }, { status });
|
|
201
|
-
|
|
206
|
+
_chunkSEKF2WZXjs.clearAuthCookies.call(void 0, );
|
|
202
207
|
return response;
|
|
203
208
|
}
|
|
204
209
|
});
|
|
@@ -209,5 +214,5 @@ var handler = (authConfig = {}) => (request) => _chunkCRTRMMJ7js.__async.call(vo
|
|
|
209
214
|
|
|
210
215
|
|
|
211
216
|
|
|
212
|
-
exports.auth = auth; exports.authMiddleware = authMiddleware; exports.createCivicAuthPlugin =
|
|
217
|
+
exports.auth = auth; exports.authMiddleware = authMiddleware; exports.createCivicAuthPlugin = _chunkSEKF2WZXjs.createCivicAuthPlugin; exports.getUser = getUser2; exports.handler = handler; exports.withAuth = withAuth;
|
|
213
218
|
//# sourceMappingURL=nextjs.js.map
|
package/dist/nextjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevincolgan/code/civic-auth/packages/civic-auth-client/dist/nextjs.js","../src/nextjs/GetUser.ts","../src/nextjs/middleware.ts","../src/nextjs/routeHandler.ts"],"names":["getUser","NextResponse","response"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACA;ACfO,IAAMA,SAAAA,EAAU,CAAA,EAAA,GAAmB;AAR1C,EAAA,IAAA,EAAA;AASE,EAAA,MAAM,cAAA,EAAgB,IAAI,yCAAA,CAAoB,CAAA;AAC9C,EAAA,MAAM,YAAA,EAAc,IAAI,wCAAA,CAAmB,aAAa,CAAA;AACxD,EAAA,MAAM,OAAA,EAAS,6CAAA,aAA4B,CAAA;AAC3C,EAAA,MAAM,KAAA,EAAO,WAAA,CAAY,GAAA,CAAI,CAAA;AAC7B,EAAA,GAAA,CAAI,CAAC,KAAA,GAAQ,CAAC,MAAA,EAAQ,OAAO,IAAA;AAE7B,EAAA,OAAO,4CAAA,6CAAA,CAAA,CAAA,EACF,IAAA,CAAA,EADE;AAAA,IAEL,OAAA,EAAS,MAAA,CAAO,QAAA;AAAA,IAChB,WAAA,EAAa,MAAA,CAAO,YAAA;AAAA,IACpB,YAAA,EAAA,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AA,OAAO,MAAM,eAAA,CAAgB,CAAA;AAAA,MAC/B,KAAK,UAAA;AACH,QAAA,OAAO,MAAM,cAAA,CAAe,OAAA,EAAS,MAAM,CAAA;AAAA,MAC7C,KAAK,QAAA;AACH,QAAA,OAAO,MAAM,YAAA,CAAa,OAAA,EAAS,MAAM,CAAA;AAAA,MAC3C,OAAA;AACE,QAAA,MAAM,IAAI,SAAA,CAAU,CAAA,oBAAA,EAAuB,QAAQ,CAAA,CAAA;AACvD,IAAA;AACc,EAAA;AAC2B,IAAA;AAES,IAAA;AAEjB,IAAA;AAEsB,IAAA;AAEtC,IAAA;AACV,IAAA;AACT,EAAA;AACF;AHwB0D;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/kevincolgan/code/civic-auth/packages/civic-auth-client/dist/nextjs.js","sourcesContent":[null,"/**\n * Used on the server-side to get the user object from the cookie\n */\nimport { User } from \"@/types\";\nimport { GenericUserSession } from \"@/shared/UserSession\";\nimport { NextjsClientStorage } from \"@/nextjs/cookies\";\nimport { retrieveTokens } from \"@/shared/util\";\n\nexport const getUser = (): User | null => {\n const clientStorage = new NextjsClientStorage();\n const userSession = new GenericUserSession(clientStorage);\n const tokens = retrieveTokens(clientStorage);\n const user = userSession.get();\n if (!user || !tokens) return null;\n\n return {\n ...user!,\n idToken: tokens.id_token,\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token ?? \"\",\n } as User;\n};\n","/**\n * Authenticates the user on all requests by checking the token cookie\n *\n * Usage:\n * Option 1: use if no other middleware (e.g. no next-intl etc)\n * export default authMiddleware();\n *\n * Option 2: use if other middleware is needed - default auth config\n * export default withAuth((request) => {\n * console.log('in custom middleware', request.nextUrl.pathname);\n * return NextResponse.next();\n * })\n *\n * Option 3: use if other middleware is needed - specifying auth config\n * const withCivicAuth = auth({ loginUrl: '/login', include: ['/[.*]/user'] })\n * export default withCivicAuth((request) => {\n * console.log('in custom middleware', request.url);\n * return NextResponse.next();\n * })\n *\n */\nimport { NextRequest, NextResponse } from \"next/server.js\";\nimport picomatch from \"picomatch\";\nimport {\n AuthConfig,\n defaultAuthConfig,\n resolveAuthConfig,\n} from \"@/nextjs/config.js\";\n\ntype Middleware = (\n request: NextRequest,\n) => Promise<NextResponse> | NextResponse;\n\n// Matches globs:\n// Examples:\n// /user\n// /user/*\n// /user/**/info\nconst matchGlob = (pathname: string, globPattern: string) => {\n const matches = picomatch(globPattern);\n return matches(pathname);\n};\n\n// Matches globs:\n// Examples:\n// /user\n// /user/*\n// /user/**/info\nconst matchesGlobs = (pathname: string, patterns: string[]) =>\n patterns.some((pattern) => {\n if (!pattern) return false;\n console.log(\"matching\", {\n pattern,\n pathname,\n match: matchGlob(pathname, pattern),\n });\n return matchGlob(pathname, pattern);\n });\n\n// internal - used by all exported functions\nconst applyAuth = async (\n authConfig: AuthConfig,\n request: NextRequest,\n): Promise<NextResponse | undefined> => {\n const authConfigWithDefaults = resolveAuthConfig(authConfig);\n\n // Check for any valid auth token\n const isAuthenticated = !!request.cookies.get(\"id_token\");\n\n // skip auth check for login url\n if (request.nextUrl.pathname === authConfigWithDefaults.loginUrl) {\n console.log(\"→ Skipping auth check - this is the login URL\");\n return undefined;\n }\n\n if (!matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.include)) {\n console.log(\"→ Skipping auth check - path not in include patterns\");\n return undefined;\n }\n\n if (matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.exclude)) {\n console.log(\"→ Skipping auth check - path in exclude patterns\");\n return undefined;\n }\n\n // Check for either token type\n if (!isAuthenticated) {\n console.log(\"→ No valid token found - redirecting to login\");\n const loginUrl = new URL(authConfigWithDefaults.loginUrl, request.url);\n return NextResponse.redirect(loginUrl);\n }\n\n console.log(\"→ Auth check passed\");\n return undefined;\n};\n\n/**\n *\n * Use this when auth is the only middleware you need.\n * Usage:\n *\n * export default authMiddleware({ loginUrl = '/login' }); // or just authMiddleware();\n *\n */\nexport const authMiddleware =\n (authConfig = defaultAuthConfig) =>\n async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth(authConfig, request);\n if (response) return response;\n\n // NextJS doesn't do middleware chaining yet, so this does not mean\n // \"call the next middleware\" - it means \"continue to the route handler\"\n return NextResponse.next();\n };\n\n/**\n * Usage:\n *\n * export default withAuth(async (request) => {\n * console.log('my middleware');\n * return NextResponse.next();\n * })\n */\n// use this when you have your own middleware to chain\nexport function withAuth(\n middleware: Middleware,\n): (request: NextRequest) => Promise<NextResponse> {\n return async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth({}, request);\n if (response) return response;\n return middleware(request);\n };\n}\n\n/**\n * Use this when you want to configure the middleware here (an alternative is to do it in the next.config file)\n *\n * Usage:\n *\n * const withAuth = auth({ loginUrl = '/login' }); // or just auth();\n *\n * export default withAuth(async (request) => {\n * console.log('my middleware');\n * return NextResponse.next();\n * })\n *\n */\nexport function auth(authConfig: AuthConfig = {}) {\n return (\n middleware: Middleware,\n ): ((request: NextRequest) => Promise<NextResponse>) => {\n return async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth(authConfig, request);\n if (response) return response;\n return middleware(request);\n };\n };\n}\n","import { NextRequest, NextResponse } from \"next/server.js\";\nimport { revalidatePath } from \"next/cache.js\";\nimport { AuthConfig, resolveAuthConfig } from \"@/nextjs/config.js\";\nimport { loggers } from \"@/lib/logger.js\";\nimport {\n clearAuthCookies,\n NextjsClientStorage,\n NextjsCookieStorage,\n} from \"@/nextjs/cookies.js\";\nimport { GenericPublicClientPKCEProducer } from \"@/services/PKCE.js\";\nimport { resolveOAuthAccessCode } from \"@/server/login.js\";\nimport { getUser } from \"@/shared/session.js\";\nimport { resolveCallbackUrl } from \"@/nextjs/utils.js\";\nimport { GenericUserSession } from \"@/shared/UserSession.js\";\n\nconst logger = loggers.nextjs.handlers.auth;\n\nclass AuthError extends Error {\n constructor(\n message: string,\n public readonly status: number = 401,\n ) {\n super(message);\n this.name = \"AuthError\";\n }\n}\n\n/**\n * create a code verifier and challenge for PKCE\n * saving the verifier in a cookie for later use\n * @returns {Promise<NextResponse>}\n */\nasync function handleChallenge(): Promise<NextResponse> {\n const cookieStorage = new NextjsCookieStorage();\n const pkceProducer = new GenericPublicClientPKCEProducer(cookieStorage);\n\n const challenge = await pkceProducer.getCodeChallenge();\n\n return NextResponse.json({ status: \"success\", challenge });\n}\n\nasync function handleCallback(\n request: NextRequest,\n config: AuthConfig,\n): Promise<NextResponse> {\n\n // If we have a code_verifier cookie, we can do a token exchange.\n // Otherwise, just render an empty page.\n // The initial redirect back from the auth server does not send cookies, because the redirect is from a 3rd-party domain.\n // The client will make an additional call to this route with cookies included, at which point we do the token exchange.\n if (!request.cookies.get(\"code_verifier\")) {\n const response = new NextResponse(`<html><body><span style=\"display:none\">sameDomainCodeExchangeRequired</span></body></html>`);\n response.headers.set(\"Content-Type\", \"text/html; charset=utf-8\");\n console.log('handleCallback no code_verifier found, returning sameDomainCodeExchangeRequired: true');\n return response;\n }\n const code = request.nextUrl.searchParams.get(\"code\");\n const state = request.nextUrl.searchParams.get(\"state\");\n if (!code || !state) throw new AuthError(\"Bad parameters\", 400);\n\n const cookieStorage = new NextjsCookieStorage();\n\n const resolvedConfigs = resolveAuthConfig(config);\n\n const callbackUrl = resolveCallbackUrl(resolvedConfigs, request.url);\n try {\n await resolveOAuthAccessCode(code, state, cookieStorage, {\n ...resolvedConfigs,\n redirectUrl: callbackUrl,\n });\n } catch (error) {\n logger.error(\"Token exchange failed:\", error);\n throw new AuthError(\"Failed to authenticate user\", 401);\n }\n\n const user = await getUser(cookieStorage);\n if (!user) {\n throw new AuthError(\"Failed to get user info\", 401);\n }\n\n const clientStorage = new NextjsClientStorage();\n const userSession = new GenericUserSession(clientStorage);\n userSession.set(user);\n\n // return an empty HTML response so the iframe doesn't show any response\n // in the short moment between the redirect and the parent window\n // acknowledging the redirect and closing the iframe\n const response = new NextResponse(`<html></html>`);\n response.headers.set(\"Content-Type\", \"text/html; charset=utf-8\");\n return response;\n}\n\n/**\n * If redirectPath is an absolute path, return it as-is.\n * Otherwise for relative paths, append it to the current domain.\n * @param redirectPath\n * @returns\n */\nconst getAbsoluteRedirectPath = (\n redirectPath: string,\n currentBasePath: string,\n) => {\n // Check if the redirectPath is an absolute URL\n if (/^(https?:\\/\\/|www\\.).+/i.test(redirectPath)) {\n return redirectPath; // Return as-is if it's an absolute URL\n }\n return new URL(redirectPath, currentBasePath).href;\n};\n\nasync function handleLogout(\n request: NextRequest,\n config: AuthConfig,\n): Promise<NextResponse> {\n const resolvedConfigs = resolveAuthConfig(config);\n const defaultRedirectPath = resolvedConfigs.loginUrl ?? \"/\";\n const redirectTarget =\n new URL(request.url).searchParams.get(\"redirect\") || defaultRedirectPath;\n const isAbsoluteRedirect = /^(https?:\\/\\/|www\\.).+/i.test(redirectTarget);\n const finalRedirectUrl = getAbsoluteRedirectPath(\n redirectTarget,\n new URL(request.url).origin,\n );\n\n const response = NextResponse.redirect(finalRedirectUrl);\n\n clearAuthCookies();\n\n try {\n revalidatePath(isAbsoluteRedirect ? finalRedirectUrl : redirectTarget);\n } catch (error) {\n logger.warn(\"Failed to revalidate path after logout:\", error);\n }\n\n return response;\n}\n\n/**\n * Creates an authentication handler for Next.js API routes\n *\n * Usage:\n * ```ts\n * // app/api/auth/[...civicauth]/route.ts\n * import { handler } from '@civic/auth/nextjs'\n * export const GET = handler({\n * // optional config overrides\n * })\n * ```\n */\nexport const handler =\n (authConfig = {}) =>\n async (request: NextRequest): Promise<NextResponse> => {\n const config = resolveAuthConfig(authConfig);\n\n try {\n const pathname = request.nextUrl.pathname;\n const pathSegments = pathname.split(\"/\");\n const lastSegment = pathSegments[pathSegments.length - 1];\n\n switch (lastSegment) {\n case \"challenge\":\n return await handleChallenge();\n case \"callback\":\n return await handleCallback(request, config);\n case \"logout\":\n return await handleLogout(request, config);\n default:\n throw new AuthError(`Invalid auth route: ${pathname}`, 404);\n }\n } catch (error) {\n logger.error(\"Auth handler error:\", error);\n\n const status = error instanceof AuthError ? error.status : 500;\n const message =\n error instanceof Error ? error.message : \"Authentication failed\";\n\n const response = NextResponse.json({ error: message }, { status });\n\n clearAuthCookies();\n return response;\n }\n };\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/kevincolgan/code/civic-auth/packages/civic-auth-client/dist/nextjs.js","../src/nextjs/GetUser.ts","../src/nextjs/middleware.ts","../src/nextjs/routeHandler.ts"],"names":["getUser","NextResponse","response"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACA;AACA;AACA;AACF,sDAA4B;AAC5B;AACE;AACA;AACA;AACF,sDAA4B;AAC5B;AACA;AChBO,IAAMA,SAAAA,EAAU,CAAA,EAAA,GAAmB;AAR1C,EAAA,IAAA,EAAA;AASE,EAAA,MAAM,cAAA,EAAgB,IAAI,yCAAA,CAAoB,CAAA;AAC9C,EAAA,MAAM,YAAA,EAAc,IAAI,wCAAA,CAAmB,aAAa,CAAA;AACxD,EAAA,MAAM,OAAA,EAAS,6CAAA,aAA4B,CAAA;AAC3C,EAAA,MAAM,KAAA,EAAO,WAAA,CAAY,GAAA,CAAI,CAAA;AAC7B,EAAA,GAAA,CAAI,CAAC,KAAA,GAAQ,CAAC,MAAA,EAAQ,OAAO,IAAA;AAE7B,EAAA,OAAO,4CAAA,6CAAA,CAAA,CAAA,EACF,IAAA,CAAA,EADE;AAAA,IAEL,OAAA,EAAS,MAAA,CAAO,QAAA;AAAA,IAChB,WAAA,EAAa,MAAA,CAAO,YAAA;AAAA,IACpB,YAAA,EAAA,CAAc,GAAA,EAAA,MAAA,CAAO,aAAA,EAAA,GAAP,KAAA,EAAA,GAAA,EAAwB;AAAA,EACxC,CAAA,CAAA;AACF,CAAA;ADiBA;AACA;AElBA,0CAA0C;AAC1C,4FAAsB;AAgBtB,IAAM,UAAA,EAAY,CAAC,QAAA,EAAkB,WAAA,EAAA,GAAwB;AAC3D,EAAA,MAAM,QAAA,EAAU,iCAAA,WAAqB,CAAA;AACrC,E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EX;AH0BF;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/kevincolgan/code/civic-auth/packages/civic-auth-client/dist/nextjs.js","sourcesContent":[null,"/**\n * Used on the server-side to get the user object from the cookie\n */\nimport { User } from \"@/types\";\nimport { GenericUserSession } from \"@/shared/UserSession\";\nimport { NextjsClientStorage } from \"@/nextjs/cookies\";\nimport { retrieveTokens } from \"@/shared/util\";\n\nexport const getUser = (): User | null => {\n const clientStorage = new NextjsClientStorage();\n const userSession = new GenericUserSession(clientStorage);\n const tokens = retrieveTokens(clientStorage);\n const user = userSession.get();\n if (!user || !tokens) return null;\n\n return {\n ...user!,\n idToken: tokens.id_token,\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token ?? \"\",\n } as User;\n};\n","/**\n * Authenticates the user on all requests by checking the token cookie\n *\n * Usage:\n * Option 1: use if no other middleware (e.g. no next-intl etc)\n * export default authMiddleware();\n *\n * Option 2: use if other middleware is needed - default auth config\n * export default withAuth((request) => {\n * console.log('in custom middleware', request.nextUrl.pathname);\n * return NextResponse.next();\n * })\n *\n * Option 3: use if other middleware is needed - specifying auth config\n * const withCivicAuth = auth({ loginUrl: '/login', include: ['/[.*]/user'] })\n * export default withCivicAuth((request) => {\n * console.log('in custom middleware', request.url);\n * return NextResponse.next();\n * })\n *\n */\nimport { NextRequest, NextResponse } from \"next/server.js\";\nimport picomatch from \"picomatch\";\nimport {\n AuthConfig,\n defaultAuthConfig,\n resolveAuthConfig,\n} from \"@/nextjs/config.js\";\n\ntype Middleware = (\n request: NextRequest,\n) => Promise<NextResponse> | NextResponse;\n\n// Matches globs:\n// Examples:\n// /user\n// /user/*\n// /user/**/info\nconst matchGlob = (pathname: string, globPattern: string) => {\n const matches = picomatch(globPattern);\n return matches(pathname);\n};\n\n// Matches globs:\n// Examples:\n// /user\n// /user/*\n// /user/**/info\nconst matchesGlobs = (pathname: string, patterns: string[]) =>\n patterns.some((pattern) => {\n if (!pattern) return false;\n console.log(\"matching\", {\n pattern,\n pathname,\n match: matchGlob(pathname, pattern),\n });\n return matchGlob(pathname, pattern);\n });\n\n// internal - used by all exported functions\nconst applyAuth = async (\n authConfig: AuthConfig,\n request: NextRequest,\n): Promise<NextResponse | undefined> => {\n const authConfigWithDefaults = resolveAuthConfig(authConfig);\n\n // Check for any valid auth token\n const isAuthenticated = !!request.cookies.get(\"id_token\");\n\n // skip auth check for login url\n if (request.nextUrl.pathname === authConfigWithDefaults.loginUrl) {\n console.log(\"→ Skipping auth check - this is the login URL\");\n return undefined;\n }\n\n if (!matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.include)) {\n console.log(\"→ Skipping auth check - path not in include patterns\");\n return undefined;\n }\n\n if (matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.exclude)) {\n console.log(\"→ Skipping auth check - path in exclude patterns\");\n return undefined;\n }\n\n // Check for either token type\n if (!isAuthenticated) {\n console.log(\"→ No valid token found - redirecting to login\");\n const loginUrl = new URL(authConfigWithDefaults.loginUrl, request.url);\n return NextResponse.redirect(loginUrl);\n }\n\n console.log(\"→ Auth check passed\");\n return undefined;\n};\n\n/**\n *\n * Use this when auth is the only middleware you need.\n * Usage:\n *\n * export default authMiddleware({ loginUrl = '/login' }); // or just authMiddleware();\n *\n */\nexport const authMiddleware =\n (authConfig = defaultAuthConfig) =>\n async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth(authConfig, request);\n if (response) return response;\n\n // NextJS doesn't do middleware chaining yet, so this does not mean\n // \"call the next middleware\" - it means \"continue to the route handler\"\n return NextResponse.next();\n };\n\n/**\n * Usage:\n *\n * export default withAuth(async (request) => {\n * console.log('my middleware');\n * return NextResponse.next();\n * })\n */\n// use this when you have your own middleware to chain\nexport function withAuth(\n middleware: Middleware,\n): (request: NextRequest) => Promise<NextResponse> {\n return async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth({}, request);\n if (response) return response;\n return middleware(request);\n };\n}\n\n/**\n * Use this when you want to configure the middleware here (an alternative is to do it in the next.config file)\n *\n * Usage:\n *\n * const withAuth = auth({ loginUrl = '/login' }); // or just auth();\n *\n * export default withAuth(async (request) => {\n * console.log('my middleware');\n * return NextResponse.next();\n * })\n *\n */\nexport function auth(authConfig: AuthConfig = {}) {\n return (\n middleware: Middleware,\n ): ((request: NextRequest) => Promise<NextResponse>) => {\n return async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth(authConfig, request);\n if (response) return response;\n return middleware(request);\n };\n };\n}\n","import { NextRequest, NextResponse } from \"next/server.js\";\nimport { revalidatePath } from \"next/cache.js\";\nimport { AuthConfig, resolveAuthConfig } from \"@/nextjs/config.js\";\nimport { loggers } from \"@/lib/logger.js\";\nimport {\n clearAuthCookies,\n NextjsClientStorage,\n NextjsCookieStorage,\n} from \"@/nextjs/cookies.js\";\nimport { GenericPublicClientPKCEProducer } from \"@/services/PKCE.js\";\nimport { resolveOAuthAccessCode } from \"@/server/login.js\";\nimport { getUser } from \"@/shared/session.js\";\nimport { resolveCallbackUrl } from \"@/nextjs/utils.js\";\nimport { GenericUserSession } from \"@/shared/UserSession.js\";\nimport { TOKEN_EXCHANGE_TRIGGER_TEXT } from \"@/constants\";\n\nconst logger = loggers.nextjs.handlers.auth;\n\nclass AuthError extends Error {\n constructor(\n message: string,\n public readonly status: number = 401,\n ) {\n super(message);\n this.name = \"AuthError\";\n }\n}\n\n/**\n * create a code verifier and challenge for PKCE\n * saving the verifier in a cookie for later use\n * @returns {Promise<NextResponse>}\n */\nasync function handleChallenge(): Promise<NextResponse> {\n const cookieStorage = new NextjsCookieStorage();\n const pkceProducer = new GenericPublicClientPKCEProducer(cookieStorage);\n\n const challenge = await pkceProducer.getCodeChallenge();\n\n return NextResponse.json({ status: \"success\", challenge });\n}\n\nasync function handleCallback(\n request: NextRequest,\n config: AuthConfig,\n): Promise<NextResponse> {\n // If we have a code_verifier cookie, we can do a token exchange.\n // Otherwise, just render an empty page.\n // The initial redirect back from the auth server does not send cookies, because the redirect is from a 3rd-party domain.\n // The client will make an additional call to this route with cookies included, at which point we do the token exchange.\n if (!request.cookies.get(\"code_verifier\")) {\n const response = new NextResponse(\n `<html><body><span style=\"display:none\">${TOKEN_EXCHANGE_TRIGGER_TEXT}</span></body></html>`,\n );\n response.headers.set(\"Content-Type\", \"text/html; charset=utf-8\");\n console.log(\n `handleCallback no code_verifier found, returning ${TOKEN_EXCHANGE_TRIGGER_TEXT}`,\n );\n return response;\n }\n const code = request.nextUrl.searchParams.get(\"code\");\n const state = request.nextUrl.searchParams.get(\"state\");\n if (!code || !state) throw new AuthError(\"Bad parameters\", 400);\n\n const resolvedConfigs = resolveAuthConfig(config);\n const cookieStorage = new NextjsCookieStorage(resolvedConfigs.cookies.tokens);\n\n const callbackUrl = resolveCallbackUrl(resolvedConfigs, request.url);\n try {\n await resolveOAuthAccessCode(code, state, cookieStorage, {\n ...resolvedConfigs,\n redirectUrl: callbackUrl,\n });\n } catch (error) {\n logger.error(\"Token exchange failed:\", error);\n throw new AuthError(\"Failed to authenticate user\", 401);\n }\n\n const user = await getUser(cookieStorage);\n if (!user) {\n throw new AuthError(\"Failed to get user info\", 401);\n }\n\n const clientStorage = new NextjsClientStorage();\n const userSession = new GenericUserSession(clientStorage);\n userSession.set(user);\n\n // return an empty HTML response so the iframe doesn't show any response\n // in the short moment between the redirect and the parent window\n // acknowledging the redirect and closing the iframe\n const response = new NextResponse(`<html></html>`);\n response.headers.set(\"Content-Type\", \"text/html; charset=utf-8\");\n return response;\n}\n\n/**\n * If redirectPath is an absolute path, return it as-is.\n * Otherwise for relative paths, append it to the current domain.\n * @param redirectPath\n * @returns\n */\nconst getAbsoluteRedirectPath = (\n redirectPath: string,\n currentBasePath: string,\n) => {\n // Check if the redirectPath is an absolute URL\n if (/^(https?:\\/\\/|www\\.).+/i.test(redirectPath)) {\n return redirectPath; // Return as-is if it's an absolute URL\n }\n return new URL(redirectPath, currentBasePath).href;\n};\n\nasync function handleLogout(\n request: NextRequest,\n config: AuthConfig,\n): Promise<NextResponse> {\n const resolvedConfigs = resolveAuthConfig(config);\n const defaultRedirectPath = resolvedConfigs.loginUrl ?? \"/\";\n const redirectTarget =\n new URL(request.url).searchParams.get(\"redirect\") || defaultRedirectPath;\n const isAbsoluteRedirect = /^(https?:\\/\\/|www\\.).+/i.test(redirectTarget);\n const finalRedirectUrl = getAbsoluteRedirectPath(\n redirectTarget,\n new URL(request.url).origin,\n );\n\n const response = NextResponse.redirect(finalRedirectUrl);\n\n clearAuthCookies();\n\n try {\n revalidatePath(isAbsoluteRedirect ? finalRedirectUrl : redirectTarget);\n } catch (error) {\n logger.warn(\"Failed to revalidate path after logout:\", error);\n }\n\n return response;\n}\n\n/**\n * Creates an authentication handler for Next.js API routes\n *\n * Usage:\n * ```ts\n * // app/api/auth/[...civicauth]/route.ts\n * import { handler } from '@civic/auth/nextjs'\n * export const GET = handler({\n * // optional config overrides\n * })\n * ```\n */\nexport const handler =\n (authConfig = {}) =>\n async (request: NextRequest): Promise<NextResponse> => {\n const config = resolveAuthConfig(authConfig);\n\n try {\n const pathname = request.nextUrl.pathname;\n const pathSegments = pathname.split(\"/\");\n const lastSegment = pathSegments[pathSegments.length - 1];\n\n switch (lastSegment) {\n case \"challenge\":\n return await handleChallenge();\n case \"callback\":\n return await handleCallback(request, config);\n case \"logout\":\n return await handleLogout(request, config);\n default:\n throw new AuthError(`Invalid auth route: ${pathname}`, 404);\n }\n } catch (error) {\n logger.error(\"Auth handler error:\", error);\n\n const status = error instanceof AuthError ? error.status : 500;\n const message =\n error instanceof Error ? error.message : \"Authentication failed\";\n\n const response = NextResponse.json({ error: message }, { status });\n\n clearAuthCookies();\n return response;\n }\n };\n"]}
|
package/dist/nextjs.mjs
CHANGED
|
@@ -7,14 +7,15 @@ import {
|
|
|
7
7
|
loggers,
|
|
8
8
|
resolveAuthConfig,
|
|
9
9
|
resolveCallbackUrl
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-5XL2ST72.mjs";
|
|
11
11
|
import {
|
|
12
12
|
GenericPublicClientPKCEProducer,
|
|
13
13
|
GenericUserSession,
|
|
14
|
+
TOKEN_EXCHANGE_TRIGGER_TEXT,
|
|
14
15
|
getUser,
|
|
15
16
|
resolveOAuthAccessCode,
|
|
16
17
|
retrieveTokens
|
|
17
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-G3P5TIO2.mjs";
|
|
18
19
|
import {
|
|
19
20
|
__async,
|
|
20
21
|
__spreadProps,
|
|
@@ -119,16 +120,20 @@ function handleChallenge() {
|
|
|
119
120
|
function handleCallback(request, config) {
|
|
120
121
|
return __async(this, null, function* () {
|
|
121
122
|
if (!request.cookies.get("code_verifier")) {
|
|
122
|
-
const response2 = new NextResponse2(
|
|
123
|
+
const response2 = new NextResponse2(
|
|
124
|
+
`<html><body><span style="display:none">${TOKEN_EXCHANGE_TRIGGER_TEXT}</span></body></html>`
|
|
125
|
+
);
|
|
123
126
|
response2.headers.set("Content-Type", "text/html; charset=utf-8");
|
|
124
|
-
console.log(
|
|
127
|
+
console.log(
|
|
128
|
+
`handleCallback no code_verifier found, returning ${TOKEN_EXCHANGE_TRIGGER_TEXT}`
|
|
129
|
+
);
|
|
125
130
|
return response2;
|
|
126
131
|
}
|
|
127
132
|
const code = request.nextUrl.searchParams.get("code");
|
|
128
133
|
const state = request.nextUrl.searchParams.get("state");
|
|
129
134
|
if (!code || !state) throw new AuthError("Bad parameters", 400);
|
|
130
|
-
const cookieStorage = new NextjsCookieStorage();
|
|
131
135
|
const resolvedConfigs = resolveAuthConfig(config);
|
|
136
|
+
const cookieStorage = new NextjsCookieStorage(resolvedConfigs.cookies.tokens);
|
|
132
137
|
const callbackUrl = resolveCallbackUrl(resolvedConfigs, request.url);
|
|
133
138
|
try {
|
|
134
139
|
yield resolveOAuthAccessCode(code, state, cookieStorage, __spreadProps(__spreadValues({}, resolvedConfigs), {
|
package/dist/nextjs.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/nextjs/GetUser.ts","../src/nextjs/middleware.ts","../src/nextjs/routeHandler.ts"],"sourcesContent":["/**\n * Used on the server-side to get the user object from the cookie\n */\nimport { User } from \"@/types\";\nimport { GenericUserSession } from \"@/shared/UserSession\";\nimport { NextjsClientStorage } from \"@/nextjs/cookies\";\nimport { retrieveTokens } from \"@/shared/util\";\n\nexport const getUser = (): User | null => {\n const clientStorage = new NextjsClientStorage();\n const userSession = new GenericUserSession(clientStorage);\n const tokens = retrieveTokens(clientStorage);\n const user = userSession.get();\n if (!user || !tokens) return null;\n\n return {\n ...user!,\n idToken: tokens.id_token,\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token ?? \"\",\n } as User;\n};\n","/**\n * Authenticates the user on all requests by checking the token cookie\n *\n * Usage:\n * Option 1: use if no other middleware (e.g. no next-intl etc)\n * export default authMiddleware();\n *\n * Option 2: use if other middleware is needed - default auth config\n * export default withAuth((request) => {\n * console.log('in custom middleware', request.nextUrl.pathname);\n * return NextResponse.next();\n * })\n *\n * Option 3: use if other middleware is needed - specifying auth config\n * const withCivicAuth = auth({ loginUrl: '/login', include: ['/[.*]/user'] })\n * export default withCivicAuth((request) => {\n * console.log('in custom middleware', request.url);\n * return NextResponse.next();\n * })\n *\n */\nimport { NextRequest, NextResponse } from \"next/server.js\";\nimport picomatch from \"picomatch\";\nimport {\n AuthConfig,\n defaultAuthConfig,\n resolveAuthConfig,\n} from \"@/nextjs/config.js\";\n\ntype Middleware = (\n request: NextRequest,\n) => Promise<NextResponse> | NextResponse;\n\n// Matches globs:\n// Examples:\n// /user\n// /user/*\n// /user/**/info\nconst matchGlob = (pathname: string, globPattern: string) => {\n const matches = picomatch(globPattern);\n return matches(pathname);\n};\n\n// Matches globs:\n// Examples:\n// /user\n// /user/*\n// /user/**/info\nconst matchesGlobs = (pathname: string, patterns: string[]) =>\n patterns.some((pattern) => {\n if (!pattern) return false;\n console.log(\"matching\", {\n pattern,\n pathname,\n match: matchGlob(pathname, pattern),\n });\n return matchGlob(pathname, pattern);\n });\n\n// internal - used by all exported functions\nconst applyAuth = async (\n authConfig: AuthConfig,\n request: NextRequest,\n): Promise<NextResponse | undefined> => {\n const authConfigWithDefaults = resolveAuthConfig(authConfig);\n\n // Check for any valid auth token\n const isAuthenticated = !!request.cookies.get(\"id_token\");\n\n // skip auth check for login url\n if (request.nextUrl.pathname === authConfigWithDefaults.loginUrl) {\n console.log(\"→ Skipping auth check - this is the login URL\");\n return undefined;\n }\n\n if (!matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.include)) {\n console.log(\"→ Skipping auth check - path not in include patterns\");\n return undefined;\n }\n\n if (matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.exclude)) {\n console.log(\"→ Skipping auth check - path in exclude patterns\");\n return undefined;\n }\n\n // Check for either token type\n if (!isAuthenticated) {\n console.log(\"→ No valid token found - redirecting to login\");\n const loginUrl = new URL(authConfigWithDefaults.loginUrl, request.url);\n return NextResponse.redirect(loginUrl);\n }\n\n console.log(\"→ Auth check passed\");\n return undefined;\n};\n\n/**\n *\n * Use this when auth is the only middleware you need.\n * Usage:\n *\n * export default authMiddleware({ loginUrl = '/login' }); // or just authMiddleware();\n *\n */\nexport const authMiddleware =\n (authConfig = defaultAuthConfig) =>\n async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth(authConfig, request);\n if (response) return response;\n\n // NextJS doesn't do middleware chaining yet, so this does not mean\n // \"call the next middleware\" - it means \"continue to the route handler\"\n return NextResponse.next();\n };\n\n/**\n * Usage:\n *\n * export default withAuth(async (request) => {\n * console.log('my middleware');\n * return NextResponse.next();\n * })\n */\n// use this when you have your own middleware to chain\nexport function withAuth(\n middleware: Middleware,\n): (request: NextRequest) => Promise<NextResponse> {\n return async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth({}, request);\n if (response) return response;\n return middleware(request);\n };\n}\n\n/**\n * Use this when you want to configure the middleware here (an alternative is to do it in the next.config file)\n *\n * Usage:\n *\n * const withAuth = auth({ loginUrl = '/login' }); // or just auth();\n *\n * export default withAuth(async (request) => {\n * console.log('my middleware');\n * return NextResponse.next();\n * })\n *\n */\nexport function auth(authConfig: AuthConfig = {}) {\n return (\n middleware: Middleware,\n ): ((request: NextRequest) => Promise<NextResponse>) => {\n return async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth(authConfig, request);\n if (response) return response;\n return middleware(request);\n };\n };\n}\n","import { NextRequest, NextResponse } from \"next/server.js\";\nimport { revalidatePath } from \"next/cache.js\";\nimport { AuthConfig, resolveAuthConfig } from \"@/nextjs/config.js\";\nimport { loggers } from \"@/lib/logger.js\";\nimport {\n clearAuthCookies,\n NextjsClientStorage,\n NextjsCookieStorage,\n} from \"@/nextjs/cookies.js\";\nimport { GenericPublicClientPKCEProducer } from \"@/services/PKCE.js\";\nimport { resolveOAuthAccessCode } from \"@/server/login.js\";\nimport { getUser } from \"@/shared/session.js\";\nimport { resolveCallbackUrl } from \"@/nextjs/utils.js\";\nimport { GenericUserSession } from \"@/shared/UserSession.js\";\n\nconst logger = loggers.nextjs.handlers.auth;\n\nclass AuthError extends Error {\n constructor(\n message: string,\n public readonly status: number = 401,\n ) {\n super(message);\n this.name = \"AuthError\";\n }\n}\n\n/**\n * create a code verifier and challenge for PKCE\n * saving the verifier in a cookie for later use\n * @returns {Promise<NextResponse>}\n */\nasync function handleChallenge(): Promise<NextResponse> {\n const cookieStorage = new NextjsCookieStorage();\n const pkceProducer = new GenericPublicClientPKCEProducer(cookieStorage);\n\n const challenge = await pkceProducer.getCodeChallenge();\n\n return NextResponse.json({ status: \"success\", challenge });\n}\n\nasync function handleCallback(\n request: NextRequest,\n config: AuthConfig,\n): Promise<NextResponse> {\n\n // If we have a code_verifier cookie, we can do a token exchange.\n // Otherwise, just render an empty page.\n // The initial redirect back from the auth server does not send cookies, because the redirect is from a 3rd-party domain.\n // The client will make an additional call to this route with cookies included, at which point we do the token exchange.\n if (!request.cookies.get(\"code_verifier\")) {\n const response = new NextResponse(`<html><body><span style=\"display:none\">sameDomainCodeExchangeRequired</span></body></html>`);\n response.headers.set(\"Content-Type\", \"text/html; charset=utf-8\");\n console.log('handleCallback no code_verifier found, returning sameDomainCodeExchangeRequired: true');\n return response;\n }\n const code = request.nextUrl.searchParams.get(\"code\");\n const state = request.nextUrl.searchParams.get(\"state\");\n if (!code || !state) throw new AuthError(\"Bad parameters\", 400);\n\n const cookieStorage = new NextjsCookieStorage();\n\n const resolvedConfigs = resolveAuthConfig(config);\n\n const callbackUrl = resolveCallbackUrl(resolvedConfigs, request.url);\n try {\n await resolveOAuthAccessCode(code, state, cookieStorage, {\n ...resolvedConfigs,\n redirectUrl: callbackUrl,\n });\n } catch (error) {\n logger.error(\"Token exchange failed:\", error);\n throw new AuthError(\"Failed to authenticate user\", 401);\n }\n\n const user = await getUser(cookieStorage);\n if (!user) {\n throw new AuthError(\"Failed to get user info\", 401);\n }\n\n const clientStorage = new NextjsClientStorage();\n const userSession = new GenericUserSession(clientStorage);\n userSession.set(user);\n\n // return an empty HTML response so the iframe doesn't show any response\n // in the short moment between the redirect and the parent window\n // acknowledging the redirect and closing the iframe\n const response = new NextResponse(`<html></html>`);\n response.headers.set(\"Content-Type\", \"text/html; charset=utf-8\");\n return response;\n}\n\n/**\n * If redirectPath is an absolute path, return it as-is.\n * Otherwise for relative paths, append it to the current domain.\n * @param redirectPath\n * @returns\n */\nconst getAbsoluteRedirectPath = (\n redirectPath: string,\n currentBasePath: string,\n) => {\n // Check if the redirectPath is an absolute URL\n if (/^(https?:\\/\\/|www\\.).+/i.test(redirectPath)) {\n return redirectPath; // Return as-is if it's an absolute URL\n }\n return new URL(redirectPath, currentBasePath).href;\n};\n\nasync function handleLogout(\n request: NextRequest,\n config: AuthConfig,\n): Promise<NextResponse> {\n const resolvedConfigs = resolveAuthConfig(config);\n const defaultRedirectPath = resolvedConfigs.loginUrl ?? \"/\";\n const redirectTarget =\n new URL(request.url).searchParams.get(\"redirect\") || defaultRedirectPath;\n const isAbsoluteRedirect = /^(https?:\\/\\/|www\\.).+/i.test(redirectTarget);\n const finalRedirectUrl = getAbsoluteRedirectPath(\n redirectTarget,\n new URL(request.url).origin,\n );\n\n const response = NextResponse.redirect(finalRedirectUrl);\n\n clearAuthCookies();\n\n try {\n revalidatePath(isAbsoluteRedirect ? finalRedirectUrl : redirectTarget);\n } catch (error) {\n logger.warn(\"Failed to revalidate path after logout:\", error);\n }\n\n return response;\n}\n\n/**\n * Creates an authentication handler for Next.js API routes\n *\n * Usage:\n * ```ts\n * // app/api/auth/[...civicauth]/route.ts\n * import { handler } from '@civic/auth/nextjs'\n * export const GET = handler({\n * // optional config overrides\n * })\n * ```\n */\nexport const handler =\n (authConfig = {}) =>\n async (request: NextRequest): Promise<NextResponse> => {\n const config = resolveAuthConfig(authConfig);\n\n try {\n const pathname = request.nextUrl.pathname;\n const pathSegments = pathname.split(\"/\");\n const lastSegment = pathSegments[pathSegments.length - 1];\n\n switch (lastSegment) {\n case \"challenge\":\n return await handleChallenge();\n case \"callback\":\n return await handleCallback(request, config);\n case \"logout\":\n return await handleLogout(request, config);\n default:\n throw new AuthError(`Invalid auth route: ${pathname}`, 404);\n }\n } catch (error) {\n logger.error(\"Auth handler error:\", error);\n\n const status = error instanceof AuthError ? error.status : 500;\n const message =\n error instanceof Error ? error.message : \"Authentication failed\";\n\n const response = NextResponse.json({ error: message }, { status });\n\n clearAuthCookies();\n return response;\n }\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAQO,IAAMA,WAAU,MAAmB;AAR1C;AASE,QAAM,gBAAgB,IAAI,oBAAoB;AAC9C,QAAM,cAAc,IAAI,mBAAmB,aAAa;AACxD,QAAM,SAAS,eAAe,aAAa;AAC3C,QAAM,OAAO,YAAY,IAAI;AAC7B,MAAI,CAAC,QAAQ,CAAC,OAAQ,QAAO;AAE7B,SAAO,iCACF,OADE;AAAA,IAEL,SAAS,OAAO;AAAA,IAChB,aAAa,OAAO;AAAA,IACpB,eAAc,YAAO,kBAAP,YAAwB;AAAA,EACxC;AACF;;;ACAA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AA,EACT;AAAA;AAcO,IAAM,UACX,CAAC,aAAa,CAAC,MACf,CAAO,YAAgD;AACrD,QAAM,SAAS,kBAAkB,UAAU;AAE3C,MAAI;AACF,UAAM,WAAW,QAAQ,QAAQ;AACjC,UAAM,eAAe,SAAS,MAAM,GAAG;AACvC,UAAM,cAAc,aAAa,aAAa,SAAS,CAAC;AAExD,YAAQ,aAAa;AAAA,MACnB,KAAK;AACH,eAAO,MAAM,gBAAgB;AAAA,MAC/B,KAAK;AACH,eAAO,MAAM,eAAe,SAAS,MAAM;AAAA,MAC7C,KAAK;AACH,eAAO,MAAM,aAAa,SAAS,MAAM;AAAA,MAC3C;AACE,cAAM,IAAI,UAAU,uBAAuB,QAAQ,IAAI,GAAG;AAAA,IAC9D;AAAA,EACF,SAAS,OAAO;AACd,WAAO,MAAM,uBAAuB,KAAK;AAEzC,UAAM,SAAS,iBAAiB,YAAY,MAAM,SAAS;AAC3D,UAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU;AAE3C,UAAM,WAAWA,cAAa,KAAK,EAAE,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC;AAEjE,qBAAiB;AACjB,WAAO;AAAA,EACT;AACF;","names":["getUser","NextResponse","NextResponse","response"]}
|
|
1
|
+
{"version":3,"sources":["../src/nextjs/GetUser.ts","../src/nextjs/middleware.ts","../src/nextjs/routeHandler.ts"],"sourcesContent":["/**\n * Used on the server-side to get the user object from the cookie\n */\nimport { User } from \"@/types\";\nimport { GenericUserSession } from \"@/shared/UserSession\";\nimport { NextjsClientStorage } from \"@/nextjs/cookies\";\nimport { retrieveTokens } from \"@/shared/util\";\n\nexport const getUser = (): User | null => {\n const clientStorage = new NextjsClientStorage();\n const userSession = new GenericUserSession(clientStorage);\n const tokens = retrieveTokens(clientStorage);\n const user = userSession.get();\n if (!user || !tokens) return null;\n\n return {\n ...user!,\n idToken: tokens.id_token,\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token ?? \"\",\n } as User;\n};\n","/**\n * Authenticates the user on all requests by checking the token cookie\n *\n * Usage:\n * Option 1: use if no other middleware (e.g. no next-intl etc)\n * export default authMiddleware();\n *\n * Option 2: use if other middleware is needed - default auth config\n * export default withAuth((request) => {\n * console.log('in custom middleware', request.nextUrl.pathname);\n * return NextResponse.next();\n * })\n *\n * Option 3: use if other middleware is needed - specifying auth config\n * const withCivicAuth = auth({ loginUrl: '/login', include: ['/[.*]/user'] })\n * export default withCivicAuth((request) => {\n * console.log('in custom middleware', request.url);\n * return NextResponse.next();\n * })\n *\n */\nimport { NextRequest, NextResponse } from \"next/server.js\";\nimport picomatch from \"picomatch\";\nimport {\n AuthConfig,\n defaultAuthConfig,\n resolveAuthConfig,\n} from \"@/nextjs/config.js\";\n\ntype Middleware = (\n request: NextRequest,\n) => Promise<NextResponse> | NextResponse;\n\n// Matches globs:\n// Examples:\n// /user\n// /user/*\n// /user/**/info\nconst matchGlob = (pathname: string, globPattern: string) => {\n const matches = picomatch(globPattern);\n return matches(pathname);\n};\n\n// Matches globs:\n// Examples:\n// /user\n// /user/*\n// /user/**/info\nconst matchesGlobs = (pathname: string, patterns: string[]) =>\n patterns.some((pattern) => {\n if (!pattern) return false;\n console.log(\"matching\", {\n pattern,\n pathname,\n match: matchGlob(pathname, pattern),\n });\n return matchGlob(pathname, pattern);\n });\n\n// internal - used by all exported functions\nconst applyAuth = async (\n authConfig: AuthConfig,\n request: NextRequest,\n): Promise<NextResponse | undefined> => {\n const authConfigWithDefaults = resolveAuthConfig(authConfig);\n\n // Check for any valid auth token\n const isAuthenticated = !!request.cookies.get(\"id_token\");\n\n // skip auth check for login url\n if (request.nextUrl.pathname === authConfigWithDefaults.loginUrl) {\n console.log(\"→ Skipping auth check - this is the login URL\");\n return undefined;\n }\n\n if (!matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.include)) {\n console.log(\"→ Skipping auth check - path not in include patterns\");\n return undefined;\n }\n\n if (matchesGlobs(request.nextUrl.pathname, authConfigWithDefaults.exclude)) {\n console.log(\"→ Skipping auth check - path in exclude patterns\");\n return undefined;\n }\n\n // Check for either token type\n if (!isAuthenticated) {\n console.log(\"→ No valid token found - redirecting to login\");\n const loginUrl = new URL(authConfigWithDefaults.loginUrl, request.url);\n return NextResponse.redirect(loginUrl);\n }\n\n console.log(\"→ Auth check passed\");\n return undefined;\n};\n\n/**\n *\n * Use this when auth is the only middleware you need.\n * Usage:\n *\n * export default authMiddleware({ loginUrl = '/login' }); // or just authMiddleware();\n *\n */\nexport const authMiddleware =\n (authConfig = defaultAuthConfig) =>\n async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth(authConfig, request);\n if (response) return response;\n\n // NextJS doesn't do middleware chaining yet, so this does not mean\n // \"call the next middleware\" - it means \"continue to the route handler\"\n return NextResponse.next();\n };\n\n/**\n * Usage:\n *\n * export default withAuth(async (request) => {\n * console.log('my middleware');\n * return NextResponse.next();\n * })\n */\n// use this when you have your own middleware to chain\nexport function withAuth(\n middleware: Middleware,\n): (request: NextRequest) => Promise<NextResponse> {\n return async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth({}, request);\n if (response) return response;\n return middleware(request);\n };\n}\n\n/**\n * Use this when you want to configure the middleware here (an alternative is to do it in the next.config file)\n *\n * Usage:\n *\n * const withAuth = auth({ loginUrl = '/login' }); // or just auth();\n *\n * export default withAuth(async (request) => {\n * console.log('my middleware');\n * return NextResponse.next();\n * })\n *\n */\nexport function auth(authConfig: AuthConfig = {}) {\n return (\n middleware: Middleware,\n ): ((request: NextRequest) => Promise<NextResponse>) => {\n return async (request: NextRequest): Promise<NextResponse> => {\n const response = await applyAuth(authConfig, request);\n if (response) return response;\n return middleware(request);\n };\n };\n}\n","import { NextRequest, NextResponse } from \"next/server.js\";\nimport { revalidatePath } from \"next/cache.js\";\nimport { AuthConfig, resolveAuthConfig } from \"@/nextjs/config.js\";\nimport { loggers } from \"@/lib/logger.js\";\nimport {\n clearAuthCookies,\n NextjsClientStorage,\n NextjsCookieStorage,\n} from \"@/nextjs/cookies.js\";\nimport { GenericPublicClientPKCEProducer } from \"@/services/PKCE.js\";\nimport { resolveOAuthAccessCode } from \"@/server/login.js\";\nimport { getUser } from \"@/shared/session.js\";\nimport { resolveCallbackUrl } from \"@/nextjs/utils.js\";\nimport { GenericUserSession } from \"@/shared/UserSession.js\";\nimport { TOKEN_EXCHANGE_TRIGGER_TEXT } from \"@/constants\";\n\nconst logger = loggers.nextjs.handlers.auth;\n\nclass AuthError extends Error {\n constructor(\n message: string,\n public readonly status: number = 401,\n ) {\n super(message);\n this.name = \"AuthError\";\n }\n}\n\n/**\n * create a code verifier and challenge for PKCE\n * saving the verifier in a cookie for later use\n * @returns {Promise<NextResponse>}\n */\nasync function handleChallenge(): Promise<NextResponse> {\n const cookieStorage = new NextjsCookieStorage();\n const pkceProducer = new GenericPublicClientPKCEProducer(cookieStorage);\n\n const challenge = await pkceProducer.getCodeChallenge();\n\n return NextResponse.json({ status: \"success\", challenge });\n}\n\nasync function handleCallback(\n request: NextRequest,\n config: AuthConfig,\n): Promise<NextResponse> {\n // If we have a code_verifier cookie, we can do a token exchange.\n // Otherwise, just render an empty page.\n // The initial redirect back from the auth server does not send cookies, because the redirect is from a 3rd-party domain.\n // The client will make an additional call to this route with cookies included, at which point we do the token exchange.\n if (!request.cookies.get(\"code_verifier\")) {\n const response = new NextResponse(\n `<html><body><span style=\"display:none\">${TOKEN_EXCHANGE_TRIGGER_TEXT}</span></body></html>`,\n );\n response.headers.set(\"Content-Type\", \"text/html; charset=utf-8\");\n console.log(\n `handleCallback no code_verifier found, returning ${TOKEN_EXCHANGE_TRIGGER_TEXT}`,\n );\n return response;\n }\n const code = request.nextUrl.searchParams.get(\"code\");\n const state = request.nextUrl.searchParams.get(\"state\");\n if (!code || !state) throw new AuthError(\"Bad parameters\", 400);\n\n const resolvedConfigs = resolveAuthConfig(config);\n const cookieStorage = new NextjsCookieStorage(resolvedConfigs.cookies.tokens);\n\n const callbackUrl = resolveCallbackUrl(resolvedConfigs, request.url);\n try {\n await resolveOAuthAccessCode(code, state, cookieStorage, {\n ...resolvedConfigs,\n redirectUrl: callbackUrl,\n });\n } catch (error) {\n logger.error(\"Token exchange failed:\", error);\n throw new AuthError(\"Failed to authenticate user\", 401);\n }\n\n const user = await getUser(cookieStorage);\n if (!user) {\n throw new AuthError(\"Failed to get user info\", 401);\n }\n\n const clientStorage = new NextjsClientStorage();\n const userSession = new GenericUserSession(clientStorage);\n userSession.set(user);\n\n // return an empty HTML response so the iframe doesn't show any response\n // in the short moment between the redirect and the parent window\n // acknowledging the redirect and closing the iframe\n const response = new NextResponse(`<html></html>`);\n response.headers.set(\"Content-Type\", \"text/html; charset=utf-8\");\n return response;\n}\n\n/**\n * If redirectPath is an absolute path, return it as-is.\n * Otherwise for relative paths, append it to the current domain.\n * @param redirectPath\n * @returns\n */\nconst getAbsoluteRedirectPath = (\n redirectPath: string,\n currentBasePath: string,\n) => {\n // Check if the redirectPath is an absolute URL\n if (/^(https?:\\/\\/|www\\.).+/i.test(redirectPath)) {\n return redirectPath; // Return as-is if it's an absolute URL\n }\n return new URL(redirectPath, currentBasePath).href;\n};\n\nasync function handleLogout(\n request: NextRequest,\n config: AuthConfig,\n): Promise<NextResponse> {\n const resolvedConfigs = resolveAuthConfig(config);\n const defaultRedirectPath = resolvedConfigs.loginUrl ?? \"/\";\n const redirectTarget =\n new URL(request.url).searchParams.get(\"redirect\") || defaultRedirectPath;\n const isAbsoluteRedirect = /^(https?:\\/\\/|www\\.).+/i.test(redirectTarget);\n const finalRedirectUrl = getAbsoluteRedirectPath(\n redirectTarget,\n new URL(request.url).origin,\n );\n\n const response = NextResponse.redirect(finalRedirectUrl);\n\n clearAuthCookies();\n\n try {\n revalidatePath(isAbsoluteRedirect ? finalRedirectUrl : redirectTarget);\n } catch (error) {\n logger.warn(\"Failed to revalidate path after logout:\", error);\n }\n\n return response;\n}\n\n/**\n * Creates an authentication handler for Next.js API routes\n *\n * Usage:\n * ```ts\n * // app/api/auth/[...civicauth]/route.ts\n * import { handler } from '@civic/auth/nextjs'\n * export const GET = handler({\n * // optional config overrides\n * })\n * ```\n */\nexport const handler =\n (authConfig = {}) =>\n async (request: NextRequest): Promise<NextResponse> => {\n const config = resolveAuthConfig(authConfig);\n\n try {\n const pathname = request.nextUrl.pathname;\n const pathSegments = pathname.split(\"/\");\n const lastSegment = pathSegments[pathSegments.length - 1];\n\n switch (lastSegment) {\n case \"challenge\":\n return await handleChallenge();\n case \"callback\":\n return await handleCallback(request, config);\n case \"logout\":\n return await handleLogout(request, config);\n default:\n throw new AuthError(`Invalid auth route: ${pathname}`, 404);\n }\n } catch (error) {\n logger.error(\"Auth handler error:\", error);\n\n const status = error instanceof AuthError ? error.status : 500;\n const message =\n error instanceof Error ? error.message : \"Authentication failed\";\n\n const response = NextResponse.json({ error: message }, { status });\n\n clearAuthCookies();\n return response;\n }\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAQO,IAAMA,WAAU,MAAmB;AAR1C;AASE,QAAM,gBAAgB,IAAI,oBAAoB;AAC9C,QAAM,cAAc,IAAI,mBAAmB,aAAa;AACxD,QAAM,SAAS,eAAe,aAAa;AAC3C,QAAM,OAAO,YAAY,IAAI;AAC7B,MAAI,CAAC,QAAQ,CAAC,OAAQ,QAAO;AAE7B,SAAO,iCACF,OADE;AAAA,IAEL,SAAS,OAAO;AAAA,IAChB,aAAa,OAAO;AAAA,IACpB,eAAc,YAAO,kBAAP,YAAwB;AAAA,EACxC;AACF;;;ACAA,SAAsB,oBAAoB;AAC1C,OAAO,eAAe;AAgBtB,IAAM,YAAY,CAAC,UAAkB,gBAAwB;AAC3D,QAAM,UAAU,UAAU,WAAW;AACrC,SAAO,QAAQ,QAAQ;AACzB;AAOA,IAAM,eAAe,CAAC,UAAkB,aACtC,SAAS,KAAK,CAAC,YAAY;AACzB,MAAI,CAAC,QAAS,QAAO;AACrB,UAAQ,IAAI,YAAY;AAAA,IACtB;AAAA,IACA;AAAA,IACA,OAAO,UAAU,UAAU,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AAAA,MACnB,KAAK;AACH,eAAO,MAAM,gBAAgB;AAAA,MAC/B,KAAK;AACH,eAAO,MAAM,eAAe,SAAS,MAAM;AAAA,MAC7C,KAAK;AACH,eAAO,MAAM,aAAa,SAAS,MAAM;AAAA,MAC3C;AACE,cAAM,IAAI,UAAU,uBAAuB,QAAQ,IAAI,GAAG;AAAA,IAC9D;AAAA,EACF,SAAS,OAAO;AACd,WAAO,MAAM,uBAAuB,KAAK;AAEzC,UAAM,SAAS,iBAAiB,YAAY,MAAM,SAAS;AAC3D,UAAM,UACJ,iBAAiB,QAAQ,MAAM,UAAU;AAE3C,UAAM,WAAWA,cAAa,KAAK,EAAE,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC;AAEjE,qBAAiB;AACjB,WAAO;AAAA,EACT;AACF;","names":["getUser","NextResponse","NextResponse","response"]}
|
package/dist/react.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { U as UserContextType, A as AuthContextType } from './index-
|
|
2
|
-
import { F as ForwardedTokens, C as Config, S as SessionData, D as DisplayMode } from './types-
|
|
1
|
+
import { U as UserContextType, A as AuthContextType } from './index-DvjkKpkk.mjs';
|
|
2
|
+
import { F as ForwardedTokens, C as Config, S as SessionData, b as EmptyObject, U as User, D as DisplayMode } from './types-HdCjGldB.mjs';
|
|
3
|
+
import { O as OAuthTokens } from './types-b4c1koXj.mjs';
|
|
3
4
|
import { ReactNode, RefObject, Dispatch, SetStateAction } from 'react';
|
|
4
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
import 'oslo/jwt';
|
|
@@ -28,11 +29,7 @@ type AuthProviderProps = {
|
|
|
28
29
|
onSignOut?: () => void;
|
|
29
30
|
pkceConsumer?: PKCEConsumer;
|
|
30
31
|
modalIframe?: boolean;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type SessionProviderOutput = SessionData & {
|
|
34
|
-
iframeRef: RefObject<HTMLIFrameElement> | null;
|
|
35
|
-
setAuthResponseUrl: Dispatch<SetStateAction<string | null>>;
|
|
32
|
+
sessionData?: SessionData;
|
|
36
33
|
};
|
|
37
34
|
|
|
38
35
|
type CivicAuthProviderProps = Omit<AuthProviderProps, "pkceConsumer">;
|
|
@@ -43,13 +40,13 @@ declare const CivicNextAuthProvider: ({ children, ...props }: NextCivicAuthProvi
|
|
|
43
40
|
|
|
44
41
|
declare const useUser: <T extends Record<string, unknown> = Record<string, never>>() => UserContextType<T>;
|
|
45
42
|
|
|
46
|
-
declare const useUserCookie: () =>
|
|
43
|
+
declare const useUserCookie: <T extends EmptyObject>() => User<T> | null;
|
|
47
44
|
|
|
48
45
|
declare const useToken: () => TokenContextType;
|
|
49
46
|
|
|
50
47
|
declare const useAuth: () => AuthContextType;
|
|
51
48
|
|
|
52
|
-
declare const useSession: () =>
|
|
49
|
+
declare const useSession: () => SessionData;
|
|
53
50
|
|
|
54
51
|
type ConfigProviderOutput = {
|
|
55
52
|
config: Config;
|
|
@@ -60,6 +57,15 @@ type ConfigProviderOutput = {
|
|
|
60
57
|
|
|
61
58
|
declare const useConfig: () => ConfigProviderOutput;
|
|
62
59
|
|
|
60
|
+
declare const useTokenCookie: (tokenName: OAuthTokens) => string | null;
|
|
61
|
+
|
|
62
|
+
type IframeProviderOutput = {
|
|
63
|
+
iframeRef: RefObject<HTMLIFrameElement> | null;
|
|
64
|
+
setAuthResponseUrl: Dispatch<SetStateAction<string | null>>;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
declare const useIframe: () => IframeProviderOutput;
|
|
68
|
+
|
|
63
69
|
type CivicAuthIframeContainerProps = {
|
|
64
70
|
onClose?: () => void;
|
|
65
71
|
closeOnRedirect?: boolean;
|
|
@@ -84,4 +90,4 @@ declare const NextLogOut: ({ children }: {
|
|
|
84
90
|
children: ReactNode;
|
|
85
91
|
}) => react_jsx_runtime.JSX.Element;
|
|
86
92
|
|
|
87
|
-
export { AuthContextType, CivicAuthIframeContainer, CivicAuthProvider, type CivicAuthProviderProps, CivicNextAuthProvider, type NextCivicAuthProviderProps, NextLogOut, SignInButton, SignOutButton, type TokenContextType, UserButton, UserContextType, useAuth, useConfig, useSession, useToken, useUser, useUserCookie };
|
|
93
|
+
export { AuthContextType, CivicAuthIframeContainer, CivicAuthProvider, type CivicAuthProviderProps, CivicNextAuthProvider, type NextCivicAuthProviderProps, NextLogOut, SignInButton, SignOutButton, type TokenContextType, UserButton, UserContextType, useAuth, useConfig, useIframe, useSession, useToken, useTokenCookie, useUser, useUserCookie };
|