@lunora/cloudflare-access 1.0.0-alpha.7 → 1.0.0-alpha.70

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/LICENSE.md CHANGED
@@ -103,3 +103,343 @@ Unless required by applicable law or agreed to in writing, software distributed
103
103
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
104
  CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
105
  specific language governing permissions and limitations under the License.
106
+
107
+ <!-- DEPENDENCIES -->
108
+ <!-- /DEPENDENCIES -->
109
+
110
+ <!-- TYPE_DEPENDENCIES -->
111
+
112
+ # Licenses of bundled types
113
+ The published @lunora/cloudflare-access artifact additionally contains code with the following licenses:
114
+ FSL-1.1-Apache-2.0
115
+
116
+ # Bundled types:
117
+ ## @lunora/server
118
+ License: FSL-1.1-Apache-2.0
119
+ By: Daniel Bannert
120
+ Repository: git+https://github.com/anolilab/lunora.git
121
+
122
+ > # Functional Source License, Version 1.1, Apache 2.0 Future License
123
+ >
124
+ > ## Abbreviation
125
+ >
126
+ > FSL-1.1-Apache-2.0
127
+ >
128
+ > ## Notice
129
+ >
130
+ > Copyright 2026 anolilab and contributors
131
+ >
132
+ > ## Terms and Conditions
133
+ >
134
+ > ### Licensor ("We")
135
+ >
136
+ > The party offering the Software under these Terms and Conditions.
137
+ >
138
+ > ### The Software
139
+ >
140
+ > The "Software" is each version of the software that we make available under
141
+ > these Terms and Conditions, as indicated by our inclusion of these Terms and
142
+ > Conditions with the Software.
143
+ >
144
+ > ### License Grant
145
+ >
146
+ > Subject to your compliance with this License Grant and the Patents,
147
+ > Redistribution and Trademark clauses below, we hereby grant you the right to
148
+ > use, copy, modify, create derivative works, publicly perform, publicly display
149
+ > and redistribute the Software for any Permitted Purpose identified below.
150
+ >
151
+ > ### Permitted Purpose
152
+ >
153
+ > A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
154
+ > means making the Software available to others in a commercial product or service
155
+ > that:
156
+ >
157
+ > 1. substitutes for the Software;
158
+ >
159
+ > 2. substitutes for any other product or service we offer using the Software that
160
+ > exists as of the date we make the Software available; or
161
+ >
162
+ > 3. offers the same or substantially similar functionality as the Software.
163
+ >
164
+ > Permitted Purposes specifically include using the Software:
165
+ >
166
+ > 1. for your internal use and access;
167
+ >
168
+ > 2. for non-commercial education;
169
+ >
170
+ > 3. for non-commercial research; and
171
+ >
172
+ > 4. in connection with professional services that you provide to a licensee using
173
+ > the Software in accordance with these Terms and Conditions.
174
+ >
175
+ > ### Patents
176
+ >
177
+ > To the extent your use for a Permitted Purpose would necessarily infringe our
178
+ > patents, the license grant above includes a license under our patents. If you
179
+ > make a claim against any party that the Software infringes or contributes to the
180
+ > infringement of any patent, then your patent license to the Software ends
181
+ > immediately.
182
+ >
183
+ > ### Redistribution
184
+ >
185
+ > The Terms and Conditions apply to all copies, modifications and derivatives of
186
+ > the Software.
187
+ >
188
+ > If you redistribute any copies, modifications or derivatives of the Software,
189
+ > you must include a copy of or a link to these Terms and Conditions and not
190
+ > remove any copyright notices provided in or with the Software.
191
+ >
192
+ > ### Disclaimer
193
+ >
194
+ > THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
195
+ > IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
196
+ > PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
197
+ >
198
+ > IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
199
+ > SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN
200
+ > IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
201
+ >
202
+ > ### Trademarks
203
+ >
204
+ > Except for displaying the License Details and identifying us as the origin of
205
+ > the Software, you have no right under these Terms and Conditions to use our
206
+ > trademarks, trade names, service marks or product names.
207
+ >
208
+ > ## Grant of Future License
209
+ >
210
+ > We hereby irrevocably grant you an additional license to use the Software under
211
+ > the Apache License, Version 2.0 that is effective on the second anniversary of
212
+ > the date we make the Software available. On or after that date, you may use the
213
+ > Software under the Apache License, Version 2.0, in which case the following will
214
+ > apply:
215
+ >
216
+ > Licensed under the Apache License, Version 2.0 (the "License"); you may not use
217
+ > this file except in compliance with the License.
218
+ >
219
+ > You may obtain a copy of the License at
220
+ >
221
+ > http://www.apache.org/licenses/LICENSE-2.0
222
+ >
223
+ > Unless required by applicable law or agreed to in writing, software distributed
224
+ > under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
225
+ > CONDITIONS OF ANY KIND, either express or implied. See the License for the
226
+ > specific language governing permissions and limitations under the License.
227
+ >
228
+ > <!-- DEPENDENCIES -->
229
+ > <!-- /DEPENDENCIES -->
230
+ >
231
+ >
232
+ >
233
+ > # Licenses of bundled types
234
+ > The published @lunora/server artifact additionally contains code with the following licenses:
235
+ > Apache-2.0
236
+ >
237
+ > # Bundled types:
238
+ > ## @opentelemetry/api
239
+ > License: Apache-2.0
240
+ > By: OpenTelemetry Authors
241
+ > Repository: open-telemetry/opentelemetry-js
242
+ >
243
+ > > Apache License
244
+ > > Version 2.0, January 2004
245
+ > > http://www.apache.org/licenses/
246
+ > >
247
+ > > TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
248
+ > >
249
+ > > 1. Definitions.
250
+ > >
251
+ > > "License" shall mean the terms and conditions for use, reproduction,
252
+ > > and distribution as defined by Sections 1 through 9 of this document.
253
+ > >
254
+ > > "Licensor" shall mean the copyright owner or entity authorized by
255
+ > > the copyright owner that is granting the License.
256
+ > >
257
+ > > "Legal Entity" shall mean the union of the acting entity and all
258
+ > > other entities that control, are controlled by, or are under common
259
+ > > control with that entity. For the purposes of this definition,
260
+ > > "control" means (i) the power, direct or indirect, to cause the
261
+ > > direction or management of such entity, whether by contract or
262
+ > > otherwise, or (ii) ownership of fifty percent (50%) or more of the
263
+ > > outstanding shares, or (iii) beneficial ownership of such entity.
264
+ > >
265
+ > > "You" (or "Your") shall mean an individual or Legal Entity
266
+ > > exercising permissions granted by this License.
267
+ > >
268
+ > > "Source" form shall mean the preferred form for making modifications,
269
+ > > including but not limited to software source code, documentation
270
+ > > source, and configuration files.
271
+ > >
272
+ > > "Object" form shall mean any form resulting from mechanical
273
+ > > transformation or translation of a Source form, including but
274
+ > > not limited to compiled object code, generated documentation,
275
+ > > and conversions to other media types.
276
+ > >
277
+ > > "Work" shall mean the work of authorship, whether in Source or
278
+ > > Object form, made available under the License, as indicated by a
279
+ > > copyright notice that is included in or attached to the work
280
+ > > (an example is provided in the Appendix below).
281
+ > >
282
+ > > "Derivative Works" shall mean any work, whether in Source or Object
283
+ > > form, that is based on (or derived from) the Work and for which the
284
+ > > editorial revisions, annotations, elaborations, or other modifications
285
+ > > represent, as a whole, an original work of authorship. For the purposes
286
+ > > of this License, Derivative Works shall not include works that remain
287
+ > > separable from, or merely link (or bind by name) to the interfaces of,
288
+ > > the Work and Derivative Works thereof.
289
+ > >
290
+ > > "Contribution" shall mean any work of authorship, including
291
+ > > the original version of the Work and any modifications or additions
292
+ > > to that Work or Derivative Works thereof, that is intentionally
293
+ > > submitted to Licensor for inclusion in the Work by the copyright owner
294
+ > > or by an individual or Legal Entity authorized to submit on behalf of
295
+ > > the copyright owner. For the purposes of this definition, "submitted"
296
+ > > means any form of electronic, verbal, or written communication sent
297
+ > > to the Licensor or its representatives, including but not limited to
298
+ > > communication on electronic mailing lists, source code control systems,
299
+ > > and issue tracking systems that are managed by, or on behalf of, the
300
+ > > Licensor for the purpose of discussing and improving the Work, but
301
+ > > excluding communication that is conspicuously marked or otherwise
302
+ > > designated in writing by the copyright owner as "Not a Contribution."
303
+ > >
304
+ > > "Contributor" shall mean Licensor and any individual or Legal Entity
305
+ > > on behalf of whom a Contribution has been received by Licensor and
306
+ > > subsequently incorporated within the Work.
307
+ > >
308
+ > > 2. Grant of Copyright License. Subject to the terms and conditions of
309
+ > > this License, each Contributor hereby grants to You a perpetual,
310
+ > > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
311
+ > > copyright license to reproduce, prepare Derivative Works of,
312
+ > > publicly display, publicly perform, sublicense, and distribute the
313
+ > > Work and such Derivative Works in Source or Object form.
314
+ > >
315
+ > > 3. Grant of Patent License. Subject to the terms and conditions of
316
+ > > this License, each Contributor hereby grants to You a perpetual,
317
+ > > worldwide, non-exclusive, no-charge, royalty-free, irrevocable
318
+ > > (except as stated in this section) patent license to make, have made,
319
+ > > use, offer to sell, sell, import, and otherwise transfer the Work,
320
+ > > where such license applies only to those patent claims licensable
321
+ > > by such Contributor that are necessarily infringed by their
322
+ > > Contribution(s) alone or by combination of their Contribution(s)
323
+ > > with the Work to which such Contribution(s) was submitted. If You
324
+ > > institute patent litigation against any entity (including a
325
+ > > cross-claim or counterclaim in a lawsuit) alleging that the Work
326
+ > > or a Contribution incorporated within the Work constitutes direct
327
+ > > or contributory patent infringement, then any patent licenses
328
+ > > granted to You under this License for that Work shall terminate
329
+ > > as of the date such litigation is filed.
330
+ > >
331
+ > > 4. Redistribution. You may reproduce and distribute copies of the
332
+ > > Work or Derivative Works thereof in any medium, with or without
333
+ > > modifications, and in Source or Object form, provided that You
334
+ > > meet the following conditions:
335
+ > >
336
+ > > (a) You must give any other recipients of the Work or
337
+ > > Derivative Works a copy of this License; and
338
+ > >
339
+ > > (b) You must cause any modified files to carry prominent notices
340
+ > > stating that You changed the files; and
341
+ > >
342
+ > > (c) You must retain, in the Source form of any Derivative Works
343
+ > > that You distribute, all copyright, patent, trademark, and
344
+ > > attribution notices from the Source form of the Work,
345
+ > > excluding those notices that do not pertain to any part of
346
+ > > the Derivative Works; and
347
+ > >
348
+ > > (d) If the Work includes a "NOTICE" text file as part of its
349
+ > > distribution, then any Derivative Works that You distribute must
350
+ > > include a readable copy of the attribution notices contained
351
+ > > within such NOTICE file, excluding those notices that do not
352
+ > > pertain to any part of the Derivative Works, in at least one
353
+ > > of the following places: within a NOTICE text file distributed
354
+ > > as part of the Derivative Works; within the Source form or
355
+ > > documentation, if provided along with the Derivative Works; or,
356
+ > > within a display generated by the Derivative Works, if and
357
+ > > wherever such third-party notices normally appear. The contents
358
+ > > of the NOTICE file are for informational purposes only and
359
+ > > do not modify the License. You may add Your own attribution
360
+ > > notices within Derivative Works that You distribute, alongside
361
+ > > or as an addendum to the NOTICE text from the Work, provided
362
+ > > that such additional attribution notices cannot be construed
363
+ > > as modifying the License.
364
+ > >
365
+ > > You may add Your own copyright statement to Your modifications and
366
+ > > may provide additional or different license terms and conditions
367
+ > > for use, reproduction, or distribution of Your modifications, or
368
+ > > for any such Derivative Works as a whole, provided Your use,
369
+ > > reproduction, and distribution of the Work otherwise complies with
370
+ > > the conditions stated in this License.
371
+ > >
372
+ > > 5. Submission of Contributions. Unless You explicitly state otherwise,
373
+ > > any Contribution intentionally submitted for inclusion in the Work
374
+ > > by You to the Licensor shall be under the terms and conditions of
375
+ > > this License, without any additional terms or conditions.
376
+ > > Notwithstanding the above, nothing herein shall supersede or modify
377
+ > > the terms of any separate license agreement you may have executed
378
+ > > with Licensor regarding such Contributions.
379
+ > >
380
+ > > 6. Trademarks. This License does not grant permission to use the trade
381
+ > > names, trademarks, service marks, or product names of the Licensor,
382
+ > > except as required for reasonable and customary use in describing the
383
+ > > origin of the Work and reproducing the content of the NOTICE file.
384
+ > >
385
+ > > 7. Disclaimer of Warranty. Unless required by applicable law or
386
+ > > agreed to in writing, Licensor provides the Work (and each
387
+ > > Contributor provides its Contributions) on an "AS IS" BASIS,
388
+ > > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
389
+ > > implied, including, without limitation, any warranties or conditions
390
+ > > of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
391
+ > > PARTICULAR PURPOSE. You are solely responsible for determining the
392
+ > > appropriateness of using or redistributing the Work and assume any
393
+ > > risks associated with Your exercise of permissions under this License.
394
+ > >
395
+ > > 8. Limitation of Liability. In no event and under no legal theory,
396
+ > > whether in tort (including negligence), contract, or otherwise,
397
+ > > unless required by applicable law (such as deliberate and grossly
398
+ > > negligent acts) or agreed to in writing, shall any Contributor be
399
+ > > liable to You for damages, including any direct, indirect, special,
400
+ > > incidental, or consequential damages of any character arising as a
401
+ > > result of this License or out of the use or inability to use the
402
+ > > Work (including but not limited to damages for loss of goodwill,
403
+ > > work stoppage, computer failure or malfunction, or any and all
404
+ > > other commercial damages or losses), even if such Contributor
405
+ > > has been advised of the possibility of such damages.
406
+ > >
407
+ > > 9. Accepting Warranty or Additional Liability. While redistributing
408
+ > > the Work or Derivative Works thereof, You may choose to offer,
409
+ > > and charge a fee for, acceptance of support, warranty, indemnity,
410
+ > > or other liability obligations and/or rights consistent with this
411
+ > > License. However, in accepting such obligations, You may act only
412
+ > > on Your own behalf and on Your sole responsibility, not on behalf
413
+ > > of any other Contributor, and only if You agree to indemnify,
414
+ > > defend, and hold each Contributor harmless for any liability
415
+ > > incurred by, or claims asserted against, such Contributor by reason
416
+ > > of your accepting any such warranty or additional liability.
417
+ > >
418
+ > > END OF TERMS AND CONDITIONS
419
+ > >
420
+ > > APPENDIX: How to apply the Apache License to your work.
421
+ > >
422
+ > > To apply the Apache License to your work, attach the following
423
+ > > boilerplate notice, with the fields enclosed by brackets "[]"
424
+ > > replaced with your own identifying information. (Don't include
425
+ > > the brackets!) The text should be enclosed in the appropriate
426
+ > > comment syntax for the file format. We also recommend that a
427
+ > > file or class name and description of purpose be included on the
428
+ > > same "printed page" as the copyright notice for easier
429
+ > > identification within third-party archives.
430
+ > >
431
+ > > Copyright [yyyy] [name of copyright owner]
432
+ > >
433
+ > > Licensed under the Apache License, Version 2.0 (the "License");
434
+ > > you may not use this file except in compliance with the License.
435
+ > > You may obtain a copy of the License at
436
+ > >
437
+ > > http://www.apache.org/licenses/LICENSE-2.0
438
+ > >
439
+ > > Unless required by applicable law or agreed to in writing, software
440
+ > > distributed under the License is distributed on an "AS IS" BASIS,
441
+ > > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
442
+ > > See the License for the specific language governing permissions and
443
+ > > limitations under the License.
444
+
445
+ <!-- /TYPE_DEPENDENCIES -->
package/dist/admin.d.mts CHANGED
@@ -1,36 +1,36 @@
1
- import { A as AccessClaims, R as RequestVerifyOptions } from "./packem_shared/types.d-BO8d74KI.mjs";
1
+ import { A as AccessClaims, R as RequestVerifyOptions } from "./packem_shared/types.d-C8c7Qwx1.mjs";
2
2
  import 'jose';
3
3
  /** Options for {@link accessAdminGate}; extends {@link RequestVerifyOptions}. */
4
4
  interface AccessAdminGateOptions extends RequestVerifyOptions {
5
5
  /**
6
- * Decide whether the **verified** claims authorize the Studio/admin plane —
7
- * e.g. `(claims) => claims.groups?.includes("ops") ?? false` or an email-domain
8
- * check. Required: there is no implicit grant, so a verified-but-unprivileged
9
- * identity is denied. Runs only after signature/issuer/audience/expiry pass.
10
- */
6
+ * Decide whether the **verified** claims authorize the Studio/admin plane —
7
+ * e.g. `(claims) => claims.groups?.includes("ops") ?? false` or an email-domain
8
+ * check. Required: there is no implicit grant, so a verified-but-unprivileged
9
+ * identity is denied. Runs only after signature/issuer/audience/expiry pass.
10
+ */
11
11
  isAdmin: (claims: AccessClaims) => boolean | Promise<boolean>;
12
12
  }
13
13
  /**
14
- * Build an admin gate for `@lunora/runtime`'s `WorkerOptions.adminGate`: a
15
- * request-only predicate that verifies the request's `Cf-Access-Jwt-Assertion`
16
- * JWT and applies your `isAdmin(claims)` test. When it resolves `true` the
17
- * request authorizes the `/_lunora/admin/*` plane (the Studio's HTTP + WS
18
- * endpoints) in addition to — or instead of — the static admin bearer, so the
19
- * Studio can sit behind Cloudflare Access.
20
- *
21
- * It is **fail-closed**: a missing token, a token that fails verification, or an
22
- * `isAdmin` that returns `false` all resolve to `false` (the bearer remains the
23
- * only other path). Verification needs no `env` binding (static team-domain/aud
24
- * config + the remote JWKS over `fetch`), so the gate takes only the request and
25
- * the runtime can evaluate it without threading async through every admin route.
26
- *
27
- * ```ts
28
- * options.adminGate = accessAdminGate({
29
- * teamDomain: env.CF_ACCESS_TEAM_DOMAIN,
30
- * aud: env.CF_ACCESS_ADMIN_AUD,
31
- * isAdmin: (claims) => claims.groups?.includes("lunora-admins") ?? false,
32
- * });
33
- * ```
34
- */
14
+ * Build an admin gate for `@lunora/runtime`'s `WorkerOptions.adminGate`: a
15
+ * request-only predicate that verifies the request's `Cf-Access-Jwt-Assertion`
16
+ * JWT and applies your `isAdmin(claims)` test. When it resolves `true` the
17
+ * request authorizes the `/_lunora/admin/*` plane (the Studio's HTTP + WS
18
+ * endpoints) in addition to — or instead of — the static admin bearer, so the
19
+ * Studio can sit behind Cloudflare Access.
20
+ *
21
+ * It is **fail-closed**: a missing token, a token that fails verification, or an
22
+ * `isAdmin` that returns `false` all resolve to `false` (the bearer remains the
23
+ * only other path). Verification needs no `env` binding (static team-domain/aud
24
+ * config + the remote JWKS over `fetch`), so the gate takes only the request and
25
+ * the runtime can evaluate it without threading async through every admin route.
26
+ *
27
+ * ```ts
28
+ * options.adminGate = accessAdminGate({
29
+ * teamDomain: env.CF_ACCESS_TEAM_DOMAIN,
30
+ * aud: env.CF_ACCESS_ADMIN_AUD,
31
+ * isAdmin: (claims) => claims.groups?.includes("lunora-admins") ?? false,
32
+ * });
33
+ * ```
34
+ */
35
35
  declare const accessAdminGate: (options: AccessAdminGateOptions) => ((request: Request) => Promise<boolean>);
36
36
  export { type AccessAdminGateOptions, accessAdminGate };
package/dist/admin.d.ts CHANGED
@@ -1,36 +1,36 @@
1
- import { A as AccessClaims, R as RequestVerifyOptions } from "./packem_shared/types.d-BO8d74KI.js";
1
+ import { A as AccessClaims, R as RequestVerifyOptions } from "./packem_shared/types.d-C8c7Qwx1.js";
2
2
  import 'jose';
3
3
  /** Options for {@link accessAdminGate}; extends {@link RequestVerifyOptions}. */
4
4
  interface AccessAdminGateOptions extends RequestVerifyOptions {
5
5
  /**
6
- * Decide whether the **verified** claims authorize the Studio/admin plane —
7
- * e.g. `(claims) => claims.groups?.includes("ops") ?? false` or an email-domain
8
- * check. Required: there is no implicit grant, so a verified-but-unprivileged
9
- * identity is denied. Runs only after signature/issuer/audience/expiry pass.
10
- */
6
+ * Decide whether the **verified** claims authorize the Studio/admin plane —
7
+ * e.g. `(claims) => claims.groups?.includes("ops") ?? false` or an email-domain
8
+ * check. Required: there is no implicit grant, so a verified-but-unprivileged
9
+ * identity is denied. Runs only after signature/issuer/audience/expiry pass.
10
+ */
11
11
  isAdmin: (claims: AccessClaims) => boolean | Promise<boolean>;
12
12
  }
13
13
  /**
14
- * Build an admin gate for `@lunora/runtime`'s `WorkerOptions.adminGate`: a
15
- * request-only predicate that verifies the request's `Cf-Access-Jwt-Assertion`
16
- * JWT and applies your `isAdmin(claims)` test. When it resolves `true` the
17
- * request authorizes the `/_lunora/admin/*` plane (the Studio's HTTP + WS
18
- * endpoints) in addition to — or instead of — the static admin bearer, so the
19
- * Studio can sit behind Cloudflare Access.
20
- *
21
- * It is **fail-closed**: a missing token, a token that fails verification, or an
22
- * `isAdmin` that returns `false` all resolve to `false` (the bearer remains the
23
- * only other path). Verification needs no `env` binding (static team-domain/aud
24
- * config + the remote JWKS over `fetch`), so the gate takes only the request and
25
- * the runtime can evaluate it without threading async through every admin route.
26
- *
27
- * ```ts
28
- * options.adminGate = accessAdminGate({
29
- * teamDomain: env.CF_ACCESS_TEAM_DOMAIN,
30
- * aud: env.CF_ACCESS_ADMIN_AUD,
31
- * isAdmin: (claims) => claims.groups?.includes("lunora-admins") ?? false,
32
- * });
33
- * ```
34
- */
14
+ * Build an admin gate for `@lunora/runtime`'s `WorkerOptions.adminGate`: a
15
+ * request-only predicate that verifies the request's `Cf-Access-Jwt-Assertion`
16
+ * JWT and applies your `isAdmin(claims)` test. When it resolves `true` the
17
+ * request authorizes the `/_lunora/admin/*` plane (the Studio's HTTP + WS
18
+ * endpoints) in addition to — or instead of — the static admin bearer, so the
19
+ * Studio can sit behind Cloudflare Access.
20
+ *
21
+ * It is **fail-closed**: a missing token, a token that fails verification, or an
22
+ * `isAdmin` that returns `false` all resolve to `false` (the bearer remains the
23
+ * only other path). Verification needs no `env` binding (static team-domain/aud
24
+ * config + the remote JWKS over `fetch`), so the gate takes only the request and
25
+ * the runtime can evaluate it without threading async through every admin route.
26
+ *
27
+ * ```ts
28
+ * options.adminGate = accessAdminGate({
29
+ * teamDomain: env.CF_ACCESS_TEAM_DOMAIN,
30
+ * aud: env.CF_ACCESS_ADMIN_AUD,
31
+ * isAdmin: (claims) => claims.groups?.includes("lunora-admins") ?? false,
32
+ * });
33
+ * ```
34
+ */
35
35
  declare const accessAdminGate: (options: AccessAdminGateOptions) => ((request: Request) => Promise<boolean>);
36
36
  export { type AccessAdminGateOptions, accessAdminGate };
package/dist/admin.mjs CHANGED
@@ -1,8 +1 @@
1
- import { verifyRequest } from './packem_shared/accessIssuer-DhKaNoyU.mjs';
2
-
3
- const accessAdminGate = (options) => async (request) => {
4
- const claims = await verifyRequest(request, options);
5
- return claims === void 0 ? false : options.isAdmin(claims);
6
- };
7
-
8
- export { accessAdminGate };
1
+ import{assertVerifyOptions as t,verifyRequest as a}from"./packem_shared/accessIssuer-B6vVJPus.mjs";const c=e=>(t(e),async s=>{const r=await a(s,e);return r===void 0?!1:e.isAdmin(r)});export{c as accessAdminGate};
@@ -1,13 +1,13 @@
1
- import { M as Middleware } from "./packem_shared/index.d-C7lOF4ZA.mjs";
2
- import { A as AccessClaims } from "./packem_shared/types.d-BO8d74KI.mjs";
1
+ import { M as Middleware } from "./packem_shared/index.d-D7R8k7yf.mjs";
2
+ import { A as AccessClaims } from "./packem_shared/types.d-C8c7Qwx1.mjs";
3
3
  import 'jose';
4
4
  /**
5
- * The slice of context {@link accessContext} reads: the `auth` facade every
6
- * Lunora ctx carries. `getIdentity()` returns the verified identity envelope —
7
- * `createAccessResolver`'s {@link import("./types").ResolvedAccessIdentity}
8
- * output, which carries the full claim set under `access` plus the promoted
9
- * `email` / `groups` / `commonName` fields.
10
- */
5
+ * The slice of context {@link accessContext} reads: the `auth` facade every
6
+ * Lunora ctx carries. `getIdentity()` returns the verified identity envelope —
7
+ * `createAccessResolver`'s {@link import("./types").ResolvedAccessIdentity}
8
+ * output, which carries the full claim set under `access` plus the promoted
9
+ * `email` / `groups` / `commonName` fields.
10
+ */
11
11
  interface AccessContextInput {
12
12
  auth?: {
13
13
  getIdentity?: () => (Record<string, unknown> | null) | Promise<Record<string, unknown> | null>;
@@ -15,11 +15,11 @@ interface AccessContextInput {
15
15
  };
16
16
  }
17
17
  /**
18
- * The typed, per-request `ctx.access` facade {@link accessContext} attaches. A
19
- * synchronous, Access-shaped read over the already-resolved identity — so a
20
- * handler reads `ctx.access.email` / `ctx.access.hasGroup("ops")` without an
21
- * `await` or a cast off the generic `ctx.auth.getIdentity()` envelope.
22
- */
18
+ * The typed, per-request `ctx.access` facade {@link accessContext} attaches. A
19
+ * synchronous, Access-shaped read over the already-resolved identity — so a
20
+ * handler reads `ctx.access.email` / `ctx.access.hasGroup("ops")` without an
21
+ * `await` or a cast off the generic `ctx.auth.getIdentity()` envelope.
22
+ */
23
23
  interface AccessFacade {
24
24
  /** True when a verified Access identity is present on the request. */
25
25
  readonly authenticated: boolean;
@@ -41,39 +41,39 @@ interface AccessContextOutput extends AccessContextInput {
41
41
  access: AccessFacade;
42
42
  }
43
43
  /**
44
- * Build the `ctx.access` facade from a (possibly absent) resolved identity
45
- * envelope. Returns the anonymous facade when no identity is present, so callers
46
- * never null-check. Shared by {@link accessContext} and the codegen-wired global
47
- * `ctx.access` (which calls this synchronously from the resolved identity locals
48
- * at ctx-build time, so a global `ctx.access` adds only this object construction
49
- * per request — no extra I/O or re-verification).
50
- */
44
+ * Build the `ctx.access` facade from a (possibly absent) resolved identity
45
+ * envelope. Returns the anonymous facade when no identity is present, so callers
46
+ * never null-check. Shared by {@link accessContext} and the codegen-wired global
47
+ * `ctx.access` (which calls this synchronously from the resolved identity locals
48
+ * at ctx-build time, so a global `ctx.access` adds only this object construction
49
+ * per request — no extra I/O or re-verification).
50
+ */
51
51
  declare const accessFacade: (identity: Record<string, unknown> | null | undefined, userId: string | null | undefined) => AccessFacade;
52
52
  /**
53
- * Middleware that attaches a typed `ctx.access` facade derived from the verified
54
- * Cloudflare Access identity. It resolves `ctx.auth.getIdentity()` once and
55
- * exposes a **synchronous**, Access-shaped read — `ctx.access.email`,
56
- * `ctx.access.groups`, `ctx.access.hasGroup("ops")`, `ctx.access.claims` — so a
57
- * handler reads the verified identity ergonomically and with full typing instead
58
- * of casting off the generic `getIdentity()` envelope.
59
- *
60
- * When no identity is resolved (anonymous request) it attaches the anonymous
61
- * facade — `authenticated: false`, empty `groups`, `hasGroup` always `false` —
62
- * so reads stay safe without a null check, and authorization decisions still
63
- * fail closed.
64
- *
65
- * It does not gate the request; pair it with `rls(...)` (or
66
- * `accessRoles(...)` → `rls(...)`) when you need enforcement. It only surfaces
67
- * the identity for branching inside a handler.
68
- *
69
- * ```ts
70
- * export const whoAmI = query
71
- * .use(accessContext())
72
- * .query(async ({ ctx }) => ({
73
- * email: ctx.access.email,
74
- * isOps: ctx.access.hasGroup("ops"),
75
- * }));
76
- * ```
77
- */
53
+ * Middleware that attaches a typed `ctx.access` facade derived from the verified
54
+ * Cloudflare Access identity. It resolves `ctx.auth.getIdentity()` once and
55
+ * exposes a **synchronous**, Access-shaped read — `ctx.access.email`,
56
+ * `ctx.access.groups`, `ctx.access.hasGroup("ops")`, `ctx.access.claims` — so a
57
+ * handler reads the verified identity ergonomically and with full typing instead
58
+ * of casting off the generic `getIdentity()` envelope.
59
+ *
60
+ * When no identity is resolved (anonymous request) it attaches the anonymous
61
+ * facade — `authenticated: false`, empty `groups`, `hasGroup` always `false` —
62
+ * so reads stay safe without a null check, and authorization decisions still
63
+ * fail closed.
64
+ *
65
+ * It does not gate the request; pair it with `rls(...)` (or
66
+ * `accessRoles(...)` → `rls(...)`) when you need enforcement. It only surfaces
67
+ * the identity for branching inside a handler.
68
+ *
69
+ * ```ts
70
+ * export const whoAmI = query
71
+ * .use(accessContext())
72
+ * .query(async ({ ctx }) => ({
73
+ * email: ctx.access.email,
74
+ * isOps: ctx.access.hasGroup("ops"),
75
+ * }));
76
+ * ```
77
+ */
78
78
  declare const accessContext: <Context extends AccessContextInput>() => Middleware<Context, AccessContextOutput & Context>;
79
79
  export { type AccessContextInput, type AccessContextOutput, type AccessFacade, accessContext, accessFacade };