@becklyn/deployment-protection 0.3.0 → 0.4.1

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.
@@ -0,0 +1,14 @@
1
+ import type { DeploymentProtectionOptions } from "./types";
2
+ /**
3
+ * Tell Vercel Edge Middleware to continue to the upstream / static asset.
4
+ * Same signal as `NextResponse.next()` without depending on the Next.js runtime.
5
+ */
6
+ export declare function middlewarePassThrough(): Response;
7
+ /**
8
+ * Framework-agnostic Vercel Edge Middleware factory (no Next.js runtime).
9
+ *
10
+ * Intended for static deployments such as Storybook `storybook-static` on Vercel.
11
+ * Reuses the same env vars and auth behaviour as {@link withDeploymentProtection}.
12
+ */
13
+ export declare function withEdgeDeploymentProtection(options?: DeploymentProtectionOptions): (request: Request) => Promise<Response>;
14
+ //# sourceMappingURL=edge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,QAAQ,CAOhD;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,GAAE,2BAAgC,IACzB,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAShG"}
@@ -0,0 +1,28 @@
1
+ import { handleDeploymentProtection } from "./handler";
2
+ /**
3
+ * Tell Vercel Edge Middleware to continue to the upstream / static asset.
4
+ * Same signal as `NextResponse.next()` without depending on the Next.js runtime.
5
+ */
6
+ export function middlewarePassThrough() {
7
+ return new Response(null, {
8
+ status: 200,
9
+ headers: {
10
+ "x-middleware-next": "1",
11
+ },
12
+ });
13
+ }
14
+ /**
15
+ * Framework-agnostic Vercel Edge Middleware factory (no Next.js runtime).
16
+ *
17
+ * Intended for static deployments such as Storybook `storybook-static` on Vercel.
18
+ * Reuses the same env vars and auth behaviour as {@link withDeploymentProtection}.
19
+ */
20
+ export function withEdgeDeploymentProtection(options = {}) {
21
+ return async function deploymentProtectionEdgeMiddleware(request) {
22
+ const protectionResponse = await handleDeploymentProtection(request, options);
23
+ if (protectionResponse) {
24
+ return protectionResponse;
25
+ }
26
+ return middlewarePassThrough();
27
+ };
28
+ }
@@ -2,6 +2,7 @@ export { INTERNAL_PATH_PREFIX, VERCEL_AUTHORIZE_PATH, VERCEL_CALLBACK_PATH } fro
2
2
  export { AUTH_PROXY_CALLBACK_PATH, AUTH_PROXY_START_PATH, handleAuthProxyCallback, handleAuthProxyStart, } from "./auth-proxy";
3
3
  export { handleDeploymentProtection } from "./handler";
4
4
  export { withDeploymentProtection } from "./middleware";
5
+ export { middlewarePassThrough, withEdgeDeploymentProtection } from "./edge";
5
6
  export { resolveConfig, hasPasswordAuth, hasVercelAuth, hasVercelDirectAuth, hasVercelProxyAuth, isProtectionActive, } from "./config";
6
7
  export type { AuthMethod, DeploymentProtectionConfig, DeploymentProtectionOptions, FormOptions, SessionPayload, } from "./types";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EACH,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EACH,aAAa,EACb,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,UAAU,CAAC;AAClB,YAAY,EACR,UAAU,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,WAAW,EACX,cAAc,GACjB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EACH,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,4BAA4B,EAAE,MAAM,QAAQ,CAAC;AAC7E,OAAO,EACH,aAAa,EACb,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,GACrB,MAAM,UAAU,CAAC;AAClB,YAAY,EACR,UAAU,EACV,0BAA0B,EAC1B,2BAA2B,EAC3B,WAAW,EACX,cAAc,GACjB,MAAM,SAAS,CAAC"}
package/dist/es/index.js CHANGED
@@ -2,4 +2,5 @@ export { INTERNAL_PATH_PREFIX, VERCEL_AUTHORIZE_PATH, VERCEL_CALLBACK_PATH } fro
2
2
  export { AUTH_PROXY_CALLBACK_PATH, AUTH_PROXY_START_PATH, handleAuthProxyCallback, handleAuthProxyStart, } from "./auth-proxy";
3
3
  export { handleDeploymentProtection } from "./handler";
4
4
  export { withDeploymentProtection } from "./middleware";
5
+ export { middlewarePassThrough, withEdgeDeploymentProtection } from "./edge";
5
6
  export { resolveConfig, hasPasswordAuth, hasVercelAuth, hasVercelDirectAuth, hasVercelProxyAuth, isProtectionActive, } from "./config";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Storybook deployment protection for Vercel.
3
+ *
4
+ * Built Storybooks are static sites, so protection runs as **Vercel Routing Middleware**
5
+ * (not Storybook config). Drop a `middleware.ts` next to the Vercel project root that
6
+ * serves `storybook-static` and set the same env vars as the Next.js integration.
7
+ *
8
+ * The published `./storybook` and `./edge` entry points resolve to self-contained ESM
9
+ * bundles so Vercel edge/nodejs middleware can load them without tracing multi-file
10
+ * package internals.
11
+ *
12
+ * @example middleware.ts
13
+ * ```ts
14
+ * import { withStorybookDeploymentProtection } from "@becklyn/deployment-protection/storybook";
15
+ *
16
+ * export default withStorybookDeploymentProtection();
17
+ *
18
+ * // Matcher must be a string literal in this file (Vercel/Next static analysis).
19
+ * export const config = {
20
+ * matcher: [
21
+ * "/((?!.*\\.(?:svg|png|jpg|jpeg|gif|webp|ico|css|js|map|txt|xml|woff2?|mjs)$).*)",
22
+ * ],
23
+ * };
24
+ * ```
25
+ *
26
+ * Optional `vercel.json` for a Storybook-only project (`framework` must be `null`):
27
+ * ```json
28
+ * {
29
+ * "buildCommand": "npm run build-storybook",
30
+ * "outputDirectory": "storybook-static",
31
+ * "framework": null
32
+ * }
33
+ * ```
34
+ */
35
+ export { middlewarePassThrough, withEdgeDeploymentProtection as withStorybookDeploymentProtection, } from "./edge";
36
+ export type { DeploymentProtectionOptions } from "./types";
37
+ //# sourceMappingURL=storybook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook.d.ts","sourceRoot":"","sources":["../../src/storybook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EACH,qBAAqB,EACrB,4BAA4B,IAAI,iCAAiC,GACpE,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Storybook deployment protection for Vercel.
3
+ *
4
+ * Built Storybooks are static sites, so protection runs as **Vercel Routing Middleware**
5
+ * (not Storybook config). Drop a `middleware.ts` next to the Vercel project root that
6
+ * serves `storybook-static` and set the same env vars as the Next.js integration.
7
+ *
8
+ * The published `./storybook` and `./edge` entry points resolve to self-contained ESM
9
+ * bundles so Vercel edge/nodejs middleware can load them without tracing multi-file
10
+ * package internals.
11
+ *
12
+ * @example middleware.ts
13
+ * ```ts
14
+ * import { withStorybookDeploymentProtection } from "@becklyn/deployment-protection/storybook";
15
+ *
16
+ * export default withStorybookDeploymentProtection();
17
+ *
18
+ * // Matcher must be a string literal in this file (Vercel/Next static analysis).
19
+ * export const config = {
20
+ * matcher: [
21
+ * "/((?!.*\\.(?:svg|png|jpg|jpeg|gif|webp|ico|css|js|map|txt|xml|woff2?|mjs)$).*)",
22
+ * ],
23
+ * };
24
+ * ```
25
+ *
26
+ * Optional `vercel.json` for a Storybook-only project (`framework` must be `null`):
27
+ * ```json
28
+ * {
29
+ * "buildCommand": "npm run build-storybook",
30
+ * "outputDirectory": "storybook-static",
31
+ * "framework": null
32
+ * }
33
+ * ```
34
+ */
35
+ export { middlewarePassThrough, withEdgeDeploymentProtection as withStorybookDeploymentProtection, } from "./edge";