@byline/auth 0.9.3

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 ADDED
@@ -0,0 +1,373 @@
1
+ Mozilla Public License Version 2.0
2
+ ==================================
3
+
4
+ 1. Definitions
5
+ --------------
6
+
7
+ 1.1. "Contributor"
8
+ means each individual or legal entity that creates, contributes to
9
+ the creation of, or owns Covered Software.
10
+
11
+ 1.2. "Contributor Version"
12
+ means the combination of the Contributions of others (if any) used
13
+ by a Contributor and that particular Contributor's Contribution.
14
+
15
+ 1.3. "Contribution"
16
+ means Covered Software of a particular Contributor.
17
+
18
+ 1.4. "Covered Software"
19
+ means Source Code Form to which the initial Contributor has attached
20
+ the notice in Exhibit A, the Executable Form of such Source Code
21
+ Form, and Modifications of such Source Code Form, in each case
22
+ including portions thereof.
23
+
24
+ 1.5. "Incompatible With Secondary Licenses"
25
+ means
26
+
27
+ (a) that the initial Contributor has attached the notice described
28
+ in Exhibit B to the Covered Software; or
29
+
30
+ (b) that the Covered Software was made available under the terms of
31
+ version 1.1 or earlier of the License, but not also under the
32
+ terms of a Secondary License.
33
+
34
+ 1.6. "Executable Form"
35
+ means any form of the work other than Source Code Form.
36
+
37
+ 1.7. "Larger Work"
38
+ means a work that combines Covered Software with other material, in
39
+ a separate file or files, that is not Covered Software.
40
+
41
+ 1.8. "License"
42
+ means this document.
43
+
44
+ 1.9. "Licensable"
45
+ means having the right to grant, to the maximum extent possible,
46
+ whether at the time of the initial grant or subsequently, any and
47
+ all of the rights conveyed by this License.
48
+
49
+ 1.10. "Modifications"
50
+ means any of the following:
51
+
52
+ (a) any file in Source Code Form that results from an addition to,
53
+ deletion from, or modification of the contents of Covered
54
+ Software; or
55
+
56
+ (b) any new file in Source Code Form that contains any Covered
57
+ Software.
58
+
59
+ 1.11. "Patent Claims" of a Contributor
60
+ means any patent claim(s), including without limitation, method,
61
+ process, and apparatus claims, in any patent Licensable by such
62
+ Contributor that would be infringed, but for the grant of the
63
+ License, by the making, using, selling, offering for sale, having
64
+ made, import, or transfer of either its Contributions or its
65
+ Contributor Version.
66
+
67
+ 1.12. "Secondary License"
68
+ means either the GNU General Public License, Version 2.0, the GNU
69
+ Lesser General Public License, Version 2.1, the GNU Affero General
70
+ Public License, Version 3.0, or any later versions of those
71
+ licenses.
72
+
73
+ 1.13. "Source Code Form"
74
+ means the form of the work preferred for making modifications.
75
+
76
+ 1.14. "You" (or "Your")
77
+ means an individual or a legal entity exercising rights under this
78
+ License. For legal entities, "You" includes any entity that
79
+ controls, is controlled by, or is under common control with You. For
80
+ purposes of this definition, "control" means (a) the power, direct
81
+ or indirect, to cause the direction or management of such entity,
82
+ whether by contract or otherwise, or (b) ownership of more than
83
+ fifty percent (50%) of the outstanding shares or beneficial
84
+ ownership of such entity.
85
+
86
+ 2. License Grants and Conditions
87
+ --------------------------------
88
+
89
+ 2.1. Grants
90
+
91
+ Each Contributor hereby grants You a world-wide, royalty-free,
92
+ non-exclusive license:
93
+
94
+ (a) under intellectual property rights (other than patent or trademark)
95
+ Licensable by such Contributor to use, reproduce, make available,
96
+ modify, display, perform, distribute, and otherwise exploit its
97
+ Contributions, either on an unmodified basis, with Modifications, or
98
+ as part of a Larger Work; and
99
+
100
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
101
+ for sale, have made, import, and otherwise transfer either its
102
+ Contributions or its Contributor Version.
103
+
104
+ 2.2. Effective Date
105
+
106
+ The licenses granted in Section 2.1 with respect to any Contribution
107
+ become effective for each Contribution on the date the Contributor first
108
+ distributes such Contribution.
109
+
110
+ 2.3. Limitations on Grant Scope
111
+
112
+ The licenses granted in this Section 2 are the only rights granted under
113
+ this License. No additional rights or licenses will be implied from the
114
+ distribution or licensing of Covered Software under this License.
115
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
116
+ Contributor:
117
+
118
+ (a) for any code that a Contributor has removed from Covered Software;
119
+ or
120
+
121
+ (b) for infringements caused by: (i) Your and any other third party's
122
+ modifications of Covered Software, or (ii) the combination of its
123
+ Contributions with other software (except as part of its Contributor
124
+ Version); or
125
+
126
+ (c) under Patent Claims infringed by Covered Software in the absence of
127
+ its Contributions.
128
+
129
+ This License does not grant any rights in the trademarks, service marks,
130
+ or logos of any Contributor (except as may be necessary to comply with
131
+ the notice requirements in Section 3.4).
132
+
133
+ 2.4. Subsequent Licenses
134
+
135
+ No Contributor makes additional grants as a result of Your choice to
136
+ distribute the Covered Software under a subsequent version of this
137
+ License (see Section 10.2) or under the terms of a Secondary License (if
138
+ permitted under the terms of Section 3.3).
139
+
140
+ 2.5. Representation
141
+
142
+ Each Contributor represents that the Contributor believes its
143
+ Contributions are its original creation(s) or it has sufficient rights
144
+ to grant the rights to its Contributions conveyed by this License.
145
+
146
+ 2.6. Fair Use
147
+
148
+ This License is not intended to limit any rights You have under
149
+ applicable copyright doctrines of fair use, fair dealing, or other
150
+ equivalents.
151
+
152
+ 2.7. Conditions
153
+
154
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
+ in Section 2.1.
156
+
157
+ 3. Responsibilities
158
+ -------------------
159
+
160
+ 3.1. Distribution of Source Form
161
+
162
+ All distribution of Covered Software in Source Code Form, including any
163
+ Modifications that You create or to which You contribute, must be under
164
+ the terms of this License. You must inform recipients that the Source
165
+ Code Form of the Covered Software is governed by the terms of this
166
+ License, and how they can obtain a copy of this License. You may not
167
+ attempt to alter or restrict the recipients' rights in the Source Code
168
+ Form.
169
+
170
+ 3.2. Distribution of Executable Form
171
+
172
+ If You distribute Covered Software in Executable Form then:
173
+
174
+ (a) such Covered Software must also be made available in Source Code
175
+ Form, as described in Section 3.1, and You must inform recipients of
176
+ the Executable Form how they can obtain a copy of such Source Code
177
+ Form by reasonable means in a timely manner, at a charge no more
178
+ than the cost of distribution to the recipient; and
179
+
180
+ (b) You may distribute such Executable Form under the terms of this
181
+ License, or sublicense it under different terms, provided that the
182
+ license for the Executable Form does not attempt to limit or alter
183
+ the recipients' rights in the Source Code Form under this License.
184
+
185
+ 3.3. Distribution of a Larger Work
186
+
187
+ You may create and distribute a Larger Work under terms of Your choice,
188
+ provided that You also comply with the requirements of this License for
189
+ the Covered Software. If the Larger Work is a combination of Covered
190
+ Software with a work governed by one or more Secondary Licenses, and the
191
+ Covered Software is not Incompatible With Secondary Licenses, this
192
+ License permits You to additionally distribute such Covered Software
193
+ under the terms of such Secondary License(s), so that the recipient of
194
+ the Larger Work may, at their option, further distribute the Covered
195
+ Software under the terms of either this License or such Secondary
196
+ License(s).
197
+
198
+ 3.4. Notices
199
+
200
+ You may not remove or alter the substance of any license notices
201
+ (including copyright notices, patent notices, disclaimers of warranty,
202
+ or limitations of liability) contained within the Source Code Form of
203
+ the Covered Software, except that You may alter any license notices to
204
+ the extent required to remedy known factual inaccuracies.
205
+
206
+ 3.5. Application of Additional Terms
207
+
208
+ You may choose to offer, and to charge a fee for, warranty, support,
209
+ indemnity or liability obligations to one or more recipients of Covered
210
+ Software. However, You may do so only on Your own behalf, and not on
211
+ behalf of any Contributor. You must make it absolutely clear that any
212
+ such warranty, support, indemnity, or liability obligation is offered by
213
+ You alone, and You hereby agree to indemnify every Contributor for any
214
+ liability incurred by such Contributor as a result of warranty, support,
215
+ indemnity or liability terms You offer. You may include additional
216
+ disclaimers of warranty and limitations of liability specific to any
217
+ jurisdiction.
218
+
219
+ 4. Inability to Comply Due to Statute or Regulation
220
+ ---------------------------------------------------
221
+
222
+ If it is impossible for You to comply with any of the terms of this
223
+ License with respect to some or all of the Covered Software due to
224
+ statute, judicial order, or regulation then You must: (a) comply with
225
+ the terms of this License to the maximum extent possible; and (b)
226
+ describe the limitations and the code they affect. Such description must
227
+ be placed in a text file included with all distributions of the Covered
228
+ Software under this License. Except to the extent prohibited by statute
229
+ or regulation, such description must be sufficiently detailed for a
230
+ recipient of ordinary skill to be able to understand it.
231
+
232
+ 5. Termination
233
+ --------------
234
+
235
+ 5.1. The rights granted under this License will terminate automatically
236
+ if You fail to comply with any of its terms. However, if You become
237
+ compliant, then the rights granted under this License from a particular
238
+ Contributor are reinstated (a) provisionally, unless and until such
239
+ Contributor explicitly and finally terminates Your grants, and (b) on an
240
+ ongoing basis, if such Contributor fails to notify You of the
241
+ non-compliance by some reasonable means prior to 60 days after You have
242
+ come back into compliance. Moreover, Your grants from a particular
243
+ Contributor are reinstated on an ongoing basis if such Contributor
244
+ notifies You of the non-compliance by some reasonable means, this is the
245
+ first time You have received notice of non-compliance with this License
246
+ from such Contributor, and You become compliant prior to 30 days after
247
+ Your receipt of the notice.
248
+
249
+ 5.2. If You initiate litigation against any entity by asserting a patent
250
+ infringement claim (excluding declaratory judgment actions,
251
+ counter-claims, and cross-claims) alleging that a Contributor Version
252
+ directly or indirectly infringes any patent, then the rights granted to
253
+ You by any and all Contributors for the Covered Software under Section
254
+ 2.1 of this License shall terminate.
255
+
256
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257
+ end user license agreements (excluding distributors and resellers) which
258
+ have been validly granted by You or Your distributors under this License
259
+ prior to termination shall survive termination.
260
+
261
+ ************************************************************************
262
+ * *
263
+ * 6. Disclaimer of Warranty *
264
+ * ------------------------- *
265
+ * *
266
+ * Covered Software is provided under this License on an "as is" *
267
+ * basis, without warranty of any kind, either expressed, implied, or *
268
+ * statutory, including, without limitation, warranties that the *
269
+ * Covered Software is free of defects, merchantable, fit for a *
270
+ * particular purpose or non-infringing. The entire risk as to the *
271
+ * quality and performance of the Covered Software is with You. *
272
+ * Should any Covered Software prove defective in any respect, You *
273
+ * (not any Contributor) assume the cost of any necessary servicing, *
274
+ * repair, or correction. This disclaimer of warranty constitutes an *
275
+ * essential part of this License. No use of any Covered Software is *
276
+ * authorized under this License except under this disclaimer. *
277
+ * *
278
+ ************************************************************************
279
+
280
+ ************************************************************************
281
+ * *
282
+ * 7. Limitation of Liability *
283
+ * -------------------------- *
284
+ * *
285
+ * Under no circumstances and under no legal theory, whether tort *
286
+ * (including negligence), contract, or otherwise, shall any *
287
+ * Contributor, or anyone who distributes Covered Software as *
288
+ * permitted above, be liable to You for any direct, indirect, *
289
+ * special, incidental, or consequential damages of any character *
290
+ * including, without limitation, damages for lost profits, loss of *
291
+ * goodwill, work stoppage, computer failure or malfunction, or any *
292
+ * and all other commercial damages or losses, even if such party *
293
+ * shall have been informed of the possibility of such damages. This *
294
+ * limitation of liability shall not apply to liability for death or *
295
+ * personal injury resulting from such party's negligence to the *
296
+ * extent applicable law prohibits such limitation. Some *
297
+ * jurisdictions do not allow the exclusion or limitation of *
298
+ * incidental or consequential damages, so this exclusion and *
299
+ * limitation may not apply to You. *
300
+ * *
301
+ ************************************************************************
302
+
303
+ 8. Litigation
304
+ -------------
305
+
306
+ Any litigation relating to this License may be brought only in the
307
+ courts of a jurisdiction where the defendant maintains its principal
308
+ place of business and such litigation shall be governed by laws of that
309
+ jurisdiction, without reference to its conflict-of-law provisions.
310
+ Nothing in this Section shall prevent a party's ability to bring
311
+ cross-claims or counter-claims.
312
+
313
+ 9. Miscellaneous
314
+ ----------------
315
+
316
+ This License represents the complete agreement concerning the subject
317
+ matter hereof. If any provision of this License is held to be
318
+ unenforceable, such provision shall be reformed only to the extent
319
+ necessary to make it enforceable. Any law or regulation which provides
320
+ that the language of a contract shall be construed against the drafter
321
+ shall not be used to construe this License against a Contributor.
322
+
323
+ 10. Versions of the License
324
+ ---------------------------
325
+
326
+ 10.1. New Versions
327
+
328
+ Mozilla Foundation is the license steward. Except as provided in Section
329
+ 10.3, no one other than the license steward has the right to modify or
330
+ publish new versions of this License. Each version will be given a
331
+ distinguishing version number.
332
+
333
+ 10.2. Effect of New Versions
334
+
335
+ You may distribute the Covered Software under the terms of the version
336
+ of the License under which You originally received the Covered Software,
337
+ or under the terms of any subsequent version published by the license
338
+ steward.
339
+
340
+ 10.3. Modified Versions
341
+
342
+ If you create software not governed by this License, and you want to
343
+ create a new license for such software, you may create and use a
344
+ modified version of this License if you rename the license and remove
345
+ any references to the name of the license steward (except to note that
346
+ such modified license differs from this License).
347
+
348
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
349
+ Licenses
350
+
351
+ If You choose to distribute Source Code Form that is Incompatible With
352
+ Secondary Licenses under the terms of this version of the License, the
353
+ notice described in Exhibit B of this License must be attached.
354
+
355
+ Exhibit A - Source Code Form License Notice
356
+ -------------------------------------------
357
+
358
+ This Source Code is subject to the terms of the Mozilla Public
359
+ License, v. 2.0. If a copy of the MPL was not distributed with this
360
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
361
+
362
+ If it is not possible or desirable to put the notice in a particular
363
+ file, then You may include the notice in a location (such as a LICENSE
364
+ file in a relevant directory) where a recipient would be likely to look
365
+ for such a notice.
366
+
367
+ You may add additional accurate notices of copyright ownership.
368
+
369
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
370
+ ---------------------------------------------------------
371
+
372
+ This Source Code is "Incompatible With Secondary Licenses", as
373
+ defined by the Mozilla Public License, v. 2.0.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @byline/auth
2
+
3
+ Auth primitives for Byline CMS — actor classes (`AdminAuth`, `UserAuth`,
4
+ `Actor`), the `RequestContext` shape, the `AbilityRegistry`, the
5
+ `SessionProvider` interface, and the `AuthError` factories. A leaf package
6
+ with no DB or transport dependencies.
7
+
8
+ This package is part of [Byline CMS](https://github.com/Byline-CMS/bylinecms.dev)
9
+ — a developer-friendly, open-source headless CMS with versioning, editorial
10
+ workflow, and content translation as first-class concerns.
11
+
12
+ For documentation, the full architecture overview, and getting started
13
+ instructions, see the main repository:
14
+ <https://github.com/Byline-CMS/bylinecms.dev>.
15
+
16
+ ## License
17
+
18
+ MPL-2.0
@@ -0,0 +1,78 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Ability registry.
10
+ *
11
+ * The load-bearing abstraction of Byline's authorization system.
12
+ *
13
+ * Every subsystem that wants to gate behaviour behind a permission
14
+ * registers its abilities here at `initBylineCore()` time. The registry
15
+ * feeds two consumers:
16
+ *
17
+ * - **Runtime** — `AdminAuth.assertAbility('collections.pages.publish')`
18
+ * checks the flat ability set on the actor; the registry is intended
19
+ * to be consulted in dev mode to warn on unregistered keys once
20
+ * service-layer enforcement is wired in.
21
+ * - **Admin UI** — the role editor enumerates `list()` / `byGroup()`
22
+ * and renders a grouped checkbox tree. No per-plugin wiring.
23
+ *
24
+ * Collections auto-register their CRUD + workflow abilities via the
25
+ * collection registrar in `@byline/core`. Future plugins (media,
26
+ * uploads, settings) contribute their own groups.
27
+ *
28
+ * See docs/analysis/AUTHN-AUTHZ-ANALYSIS.md §3.
29
+ */
30
+ /**
31
+ * A single registered ability.
32
+ *
33
+ * `key` is the flat dotted string thrown against `AdminAuth.assertAbility`
34
+ * and stored one-per-row in `admin_permissions`. Keep keys stable — they
35
+ * are data-plane identifiers.
36
+ *
37
+ * `label` and `description` are UI-facing. `group` controls how the role
38
+ * editor buckets the checkbox tree — collections typically use
39
+ * `collections.<path>` so every ability for a collection lands in one
40
+ * group.
41
+ *
42
+ * `source` tags the ability's origin for the inspector view (the
43
+ * registered-collections / who-has-what panels still to ship).
44
+ */
45
+ export interface AbilityDescriptor {
46
+ /** Flat dotted string, e.g. `'collections.pages.publish'`. */
47
+ key: string;
48
+ /** Short human-readable label for UI display. */
49
+ label: string;
50
+ /** Group key for UI bucketing, e.g. `'collections.pages'` or `'media'`. */
51
+ group: string;
52
+ /** Optional longer description, shown as tooltip / help text. */
53
+ description?: string;
54
+ /** Where this ability was registered from. */
55
+ source?: 'collection' | 'plugin' | 'core' | 'admin';
56
+ }
57
+ export declare class AbilityRegistry {
58
+ #private;
59
+ /**
60
+ * Register an ability. Silent no-op when the same key is re-registered
61
+ * (dupe-tolerant so tests, hot-reload, and bootstrap re-runs don't need
62
+ * to guard).
63
+ */
64
+ register(descriptor: AbilityDescriptor): void;
65
+ /** Whether a key has been registered. */
66
+ has(key: string): boolean;
67
+ /** Look up a descriptor by key. */
68
+ get(key: string): AbilityDescriptor | undefined;
69
+ /** All registered abilities, in registration order. */
70
+ list(): AbilityDescriptor[];
71
+ /** All registered abilities grouped by their `group` key. */
72
+ byGroup(): Map<string, AbilityDescriptor[]>;
73
+ /** Number of registered abilities. */
74
+ get size(): number;
75
+ /** Drop every registered ability. Primarily for tests. */
76
+ clear(): void;
77
+ }
78
+ //# sourceMappingURL=abilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abilities.d.ts","sourceRoot":"","sources":["../src/abilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,GAAG,EAAE,MAAM,CAAA;IACX,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAA;IACb,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAA;IACb,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;CACpD;AAED,qBAAa,eAAe;;IAG1B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAK7C,yCAAyC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,mCAAmC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAK/C,uDAAuD;IACvD,IAAI,IAAI,iBAAiB,EAAE;IAI3B,6DAA6D;IAC7D,OAAO,IAAI,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAW3C,sCAAsC;IACtC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,0DAA0D;IAC1D,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ export class AbilityRegistry {
9
+ #abilities = new Map();
10
+ /**
11
+ * Register an ability. Silent no-op when the same key is re-registered
12
+ * (dupe-tolerant so tests, hot-reload, and bootstrap re-runs don't need
13
+ * to guard).
14
+ */
15
+ register(descriptor) {
16
+ if (this.#abilities.has(descriptor.key))
17
+ return;
18
+ this.#abilities.set(descriptor.key, { ...descriptor });
19
+ }
20
+ /** Whether a key has been registered. */
21
+ has(key) {
22
+ return this.#abilities.has(key);
23
+ }
24
+ /** Look up a descriptor by key. */
25
+ get(key) {
26
+ const found = this.#abilities.get(key);
27
+ return found ? { ...found } : undefined;
28
+ }
29
+ /** All registered abilities, in registration order. */
30
+ list() {
31
+ return Array.from(this.#abilities.values(), (d) => ({ ...d }));
32
+ }
33
+ /** All registered abilities grouped by their `group` key. */
34
+ byGroup() {
35
+ const buckets = new Map();
36
+ for (const descriptor of this.#abilities.values()) {
37
+ const bucket = buckets.get(descriptor.group);
38
+ const entry = { ...descriptor };
39
+ if (bucket)
40
+ bucket.push(entry);
41
+ else
42
+ buckets.set(descriptor.group, [entry]);
43
+ }
44
+ return buckets;
45
+ }
46
+ /** Number of registered abilities. */
47
+ get size() {
48
+ return this.#abilities.size;
49
+ }
50
+ /** Drop every registered ability. Primarily for tests. */
51
+ clear() {
52
+ this.#abilities.clear();
53
+ }
54
+ }
55
+ //# sourceMappingURL=abilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abilities.js","sourceRoot":"","sources":["../src/abilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAqDH,MAAM,OAAO,eAAe;IACjB,UAAU,GAAmC,IAAI,GAAG,EAAE,CAAA;IAE/D;;;;OAIG;IACH,QAAQ,CAAC,UAA6B;QACpC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAM;QAC/C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,CAAA;IACxD,CAAC;IAED,yCAAyC;IACzC,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACjC,CAAC;IAED,mCAAmC;IACnC,GAAG,CAAC,GAAW;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACtC,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IACzC,CAAC;IAED,uDAAuD;IACvD,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,6DAA6D;IAC7D,OAAO;QACL,MAAM,OAAO,GAAG,IAAI,GAAG,EAA+B,CAAA;QACtD,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YAClD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YAC5C,MAAM,KAAK,GAAG,EAAE,GAAG,UAAU,EAAE,CAAA;YAC/B,IAAI,MAAM;gBAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;;gBACzB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;QAC7C,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,sCAAsC;IACtC,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAA;IAC7B,CAAC;IAED,0DAA0D;IAC1D,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;IACzB,CAAC;CACF"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Admin-realm identity. Constructed by the session provider's
10
+ * `resolveActor()` method, which joins roles → permissions into the
11
+ * flat ability set.
12
+ *
13
+ * `isSuperAdmin` short-circuits every ability check. It mirrors the
14
+ * `is_super_admin` flag on the `admin_users` row (see Phase 2 schema).
15
+ */
16
+ export declare class AdminAuth {
17
+ readonly id: string;
18
+ readonly abilities: ReadonlySet<string>;
19
+ readonly isSuperAdmin: boolean;
20
+ constructor(params: {
21
+ id: string;
22
+ abilities: Iterable<string>;
23
+ isSuperAdmin?: boolean;
24
+ });
25
+ /** Non-throwing check. Super-admins always return `true`. */
26
+ hasAbility(ability: string): boolean;
27
+ /**
28
+ * Throwing check. Throws `ERR_FORBIDDEN` when the actor lacks the
29
+ * ability. Super-admins bypass. Primary enforcement call site once
30
+ * service-layer enforcement (`document-lifecycle` / `IDocumentQueries`)
31
+ * is wired in.
32
+ */
33
+ assertAbility(ability: string, message?: string): void;
34
+ /**
35
+ * Throwing check for a set of abilities (AND semantics — every listed
36
+ * ability must be held). Super-admins bypass.
37
+ */
38
+ assertAbilities(abilities: readonly string[], messageFor?: (ability: string) => string): void;
39
+ }
40
+ /**
41
+ * End-user / app-side identity. Stubbed in Phase 0 — the class exists so
42
+ * `Actor` can discriminate between realms without later breaking
43
+ * signatures, but the ability surface is deliberately minimal.
44
+ *
45
+ * Fleshed out when an end-user sign-in surface is actually needed. Until
46
+ * then, assume no call path constructs a `UserAuth` instance in practice.
47
+ */
48
+ export declare class UserAuth {
49
+ readonly id: string;
50
+ readonly abilities: ReadonlySet<string>;
51
+ constructor(params: {
52
+ id: string;
53
+ abilities?: Iterable<string>;
54
+ });
55
+ hasAbility(ability: string): boolean;
56
+ assertAbility(ability: string, message?: string): void;
57
+ }
58
+ /**
59
+ * Canonical actor shape carried on `RequestContext`. `null` represents an
60
+ * unauthenticated request — permitted only on public read paths once
61
+ * service-layer enforcement is in place.
62
+ */
63
+ export type Actor = AdminAuth | UserAuth | null;
64
+ /** Narrow an `Actor` to the admin realm. */
65
+ export declare function isAdminAuth(actor: Actor): actor is AdminAuth;
66
+ /** Narrow an `Actor` to the end-user realm. */
67
+ export declare function isUserAuth(actor: Actor): actor is UserAuth;
68
+ //# sourceMappingURL=actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.d.ts","sourceRoot":"","sources":["../src/actor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA8BH;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB,SAAgB,EAAE,EAAE,MAAM,CAAA;IAC1B,SAAgB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC9C,SAAgB,YAAY,EAAE,OAAO,CAAA;gBAEzB,MAAM,EAAE;QAClB,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC3B,YAAY,CAAC,EAAE,OAAO,CAAA;KACvB;IAMD,6DAA6D;IAC7D,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAKpC;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAStD;;;OAGG;IACH,eAAe,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI;CAU9F;AAED;;;;;;;GAOG;AACH,qBAAa,QAAQ;IACnB,SAAgB,EAAE,EAAE,MAAM,CAAA;IAC1B,SAAgB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;gBAElC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;KAAE;IAKhE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIpC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;CAOvD;AAED;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAA;AAE/C,4CAA4C;AAC5C,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,SAAS,CAE5D;AAED,+CAA+C;AAC/C,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,QAAQ,CAE1D"}
package/dist/actor.js ADDED
@@ -0,0 +1,122 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Actor primitives.
10
+ *
11
+ * Two realms are modelled from day one, even though only `AdminAuth` is
12
+ * fleshed out in Phase 0:
13
+ *
14
+ * - `AdminAuth` — the identity of a signed-in Byline admin (CMS staff,
15
+ * editors, super-admins). Carries a flat set of ability strings
16
+ * resolved from the role graph.
17
+ * - `UserAuth` — reserved for end-user / app-side identity (public
18
+ * readers with entitlements, member-only access, per-user drafts).
19
+ * Stubbed out in Phase 0 so every signature that must accommodate
20
+ * "either realm or neither" can reference it already; filled in when
21
+ * a concrete end-user feature arrives.
22
+ *
23
+ * The `Actor` union (`AdminAuth | UserAuth | null`) is the canonical shape
24
+ * carried on `RequestContext`. A `null` actor represents an
25
+ * unauthenticated request — only permitted on public read paths
26
+ * (`readMode === 'published'`) once service-layer enforcement lands
27
+ * (the outstanding item in AUTHN-AUTHZ-ANALYSIS.md).
28
+ *
29
+ * Ability keys are flat dotted strings (e.g. `collections.pages.publish`,
30
+ * `media.manage`). See AUTHN-AUTHZ-ANALYSIS.md §4 for the rationale and
31
+ * §1 (Phase 1) for the registry that mints them.
32
+ */
33
+ import { ERR_FORBIDDEN } from './errors.js';
34
+ /**
35
+ * Admin-realm identity. Constructed by the session provider's
36
+ * `resolveActor()` method, which joins roles → permissions into the
37
+ * flat ability set.
38
+ *
39
+ * `isSuperAdmin` short-circuits every ability check. It mirrors the
40
+ * `is_super_admin` flag on the `admin_users` row (see Phase 2 schema).
41
+ */
42
+ export class AdminAuth {
43
+ id;
44
+ abilities;
45
+ isSuperAdmin;
46
+ constructor(params) {
47
+ this.id = params.id;
48
+ this.abilities = new Set(params.abilities);
49
+ this.isSuperAdmin = params.isSuperAdmin ?? false;
50
+ }
51
+ /** Non-throwing check. Super-admins always return `true`. */
52
+ hasAbility(ability) {
53
+ if (this.isSuperAdmin)
54
+ return true;
55
+ return this.abilities.has(ability);
56
+ }
57
+ /**
58
+ * Throwing check. Throws `ERR_FORBIDDEN` when the actor lacks the
59
+ * ability. Super-admins bypass. Primary enforcement call site once
60
+ * service-layer enforcement (`document-lifecycle` / `IDocumentQueries`)
61
+ * is wired in.
62
+ */
63
+ assertAbility(ability, message) {
64
+ if (this.isSuperAdmin)
65
+ return;
66
+ if (!this.abilities.has(ability)) {
67
+ throw ERR_FORBIDDEN({
68
+ message: message ?? `missing required ability: ${ability}`,
69
+ });
70
+ }
71
+ }
72
+ /**
73
+ * Throwing check for a set of abilities (AND semantics — every listed
74
+ * ability must be held). Super-admins bypass.
75
+ */
76
+ assertAbilities(abilities, messageFor) {
77
+ if (this.isSuperAdmin)
78
+ return;
79
+ for (const ability of abilities) {
80
+ if (!this.abilities.has(ability)) {
81
+ throw ERR_FORBIDDEN({
82
+ message: messageFor?.(ability) ?? `missing required ability: ${ability}`,
83
+ });
84
+ }
85
+ }
86
+ }
87
+ }
88
+ /**
89
+ * End-user / app-side identity. Stubbed in Phase 0 — the class exists so
90
+ * `Actor` can discriminate between realms without later breaking
91
+ * signatures, but the ability surface is deliberately minimal.
92
+ *
93
+ * Fleshed out when an end-user sign-in surface is actually needed. Until
94
+ * then, assume no call path constructs a `UserAuth` instance in practice.
95
+ */
96
+ export class UserAuth {
97
+ id;
98
+ abilities;
99
+ constructor(params) {
100
+ this.id = params.id;
101
+ this.abilities = new Set(params.abilities ?? []);
102
+ }
103
+ hasAbility(ability) {
104
+ return this.abilities.has(ability);
105
+ }
106
+ assertAbility(ability, message) {
107
+ if (!this.abilities.has(ability)) {
108
+ throw ERR_FORBIDDEN({
109
+ message: message ?? `missing required ability: ${ability}`,
110
+ });
111
+ }
112
+ }
113
+ }
114
+ /** Narrow an `Actor` to the admin realm. */
115
+ export function isAdminAuth(actor) {
116
+ return actor instanceof AdminAuth;
117
+ }
118
+ /** Narrow an `Actor` to the end-user realm. */
119
+ export function isUserAuth(actor) {
120
+ return actor instanceof UserAuth;
121
+ }
122
+ //# sourceMappingURL=actor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actor.js","sourceRoot":"","sources":["../src/actor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C;;;;;;;GAOG;AACH,MAAM,OAAO,SAAS;IACJ,EAAE,CAAQ;IACV,SAAS,CAAqB;IAC9B,YAAY,CAAS;IAErC,YAAY,MAIX;QACC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAC1C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,KAAK,CAAA;IAClD,CAAC;IAED,6DAA6D;IAC7D,UAAU,CAAC,OAAe;QACxB,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO,IAAI,CAAA;QAClC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,OAAe,EAAE,OAAgB;QAC7C,IAAI,IAAI,CAAC,YAAY;YAAE,OAAM;QAC7B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,MAAM,aAAa,CAAC;gBAClB,OAAO,EAAE,OAAO,IAAI,6BAA6B,OAAO,EAAE;aAC3D,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,SAA4B,EAAE,UAAwC;QACpF,IAAI,IAAI,CAAC,YAAY;YAAE,OAAM;QAC7B,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACjC,MAAM,aAAa,CAAC;oBAClB,OAAO,EAAE,UAAU,EAAE,CAAC,OAAO,CAAC,IAAI,6BAA6B,OAAO,EAAE;iBACzE,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,QAAQ;IACH,EAAE,CAAQ;IACV,SAAS,CAAqB;IAE9C,YAAY,MAAoD;QAC9D,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAA;QACnB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,UAAU,CAAC,OAAe;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC;IAED,aAAa,CAAC,OAAe,EAAE,OAAgB;QAC7C,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,MAAM,aAAa,CAAC;gBAClB,OAAO,EAAE,OAAO,IAAI,6BAA6B,OAAO,EAAE;aAC3D,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AASD,4CAA4C;AAC5C,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,OAAO,KAAK,YAAY,SAAS,CAAA;AACnC,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,UAAU,CAAC,KAAY;IACrC,OAAO,KAAK,YAAY,QAAQ,CAAA;AAClC,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { type Actor } from './actor.js';
9
+ /**
10
+ * Request-scoped context threaded through every admin server fn,
11
+ * `document-lifecycle` service, `IDocumentQueries` method, `@byline/client`
12
+ * entry point, and collection hook.
13
+ *
14
+ * The auth subsystem populates `actor`; downstream code reads it. Today
15
+ * the threading is plumbing only — `actor.assertAbility(...)` is not yet
16
+ * called at the `document-lifecycle` / `IDocumentQueries` boundary. See
17
+ * the Phase status table in AUTHN-AUTHZ-ANALYSIS.md.
18
+ *
19
+ * `RequestContext` is intentionally independent of the existing
20
+ * `ReadContext` (populate / `afterRead` recursion guard) for now. Merging
21
+ * them is a potential follow-up if it earns its keep; keeping them
22
+ * separate in Phase 0 avoids churning every populate call site.
23
+ *
24
+ * Fields:
25
+ * - `actor` — the authenticated identity (or `null` for public
26
+ * read paths). Service-layer enforcement (when wired)
27
+ * will permit `null` only when
28
+ * `readMode === 'published'`.
29
+ * - `requestId` — monotonic-ish UUIDv7 per logical request. Surfaces
30
+ * in log lines and error cause chains.
31
+ * - `locale` — optional content locale for this request. When
32
+ * omitted, callers fall back to the default locale
33
+ * from `ServerConfig.i18n.content.defaultLocale`.
34
+ * - `readMode` — `'any'` (admin default) or `'published'` (public
35
+ * default). Mirrors the existing `ReadMode` on
36
+ * `IDocumentQueries` call options; threaded here so
37
+ * the auth layer can reason about the public-read
38
+ * case uniformly.
39
+ */
40
+ export interface RequestContext {
41
+ actor: Actor;
42
+ requestId: string;
43
+ locale?: string;
44
+ readMode?: 'any' | 'published';
45
+ }
46
+ /** Build a fresh `RequestContext`. All fields optional for ergonomic test/script construction. */
47
+ export declare function createRequestContext(overrides?: Partial<RequestContext>): RequestContext;
48
+ /**
49
+ * Construct an explicit super-admin `RequestContext` for scripts, seeds,
50
+ * and tests.
51
+ *
52
+ * The super-admin bypass on `AdminAuth.isSuperAdmin` short-circuits every
53
+ * ability check downstream — which is exactly what migration scripts and
54
+ * seeders need, but it is also why this helper is **explicit**: callers
55
+ * must state "I am acting as super-admin" in code so the fact is
56
+ * auditable. No ambient bypass, no environment-variable escape hatch.
57
+ */
58
+ export declare function createSuperAdminContext(params?: {
59
+ id?: string;
60
+ requestId?: string;
61
+ locale?: string;
62
+ }): RequestContext;
63
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAa,MAAM,YAAY,CAAA;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,KAAK,GAAG,WAAW,CAAA;CAC/B;AAED,kGAAkG;AAClG,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAOxF;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE;IAC/C,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GAAG,cAAc,CAWjB"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { v7 as uuidv7 } from 'uuid';
9
+ import { AdminAuth } from './actor.js';
10
+ /** Build a fresh `RequestContext`. All fields optional for ergonomic test/script construction. */
11
+ export function createRequestContext(overrides) {
12
+ return {
13
+ actor: overrides?.actor ?? null,
14
+ requestId: overrides?.requestId ?? uuidv7(),
15
+ locale: overrides?.locale,
16
+ readMode: overrides?.readMode,
17
+ };
18
+ }
19
+ /**
20
+ * Construct an explicit super-admin `RequestContext` for scripts, seeds,
21
+ * and tests.
22
+ *
23
+ * The super-admin bypass on `AdminAuth.isSuperAdmin` short-circuits every
24
+ * ability check downstream — which is exactly what migration scripts and
25
+ * seeders need, but it is also why this helper is **explicit**: callers
26
+ * must state "I am acting as super-admin" in code so the fact is
27
+ * auditable. No ambient bypass, no environment-variable escape hatch.
28
+ */
29
+ export function createSuperAdminContext(params) {
30
+ const actor = new AdminAuth({
31
+ id: params?.id ?? 'super-admin',
32
+ abilities: [],
33
+ isSuperAdmin: true,
34
+ });
35
+ return {
36
+ actor,
37
+ requestId: params?.requestId ?? uuidv7(),
38
+ locale: params?.locale,
39
+ };
40
+ }
41
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAc,SAAS,EAAE,MAAM,YAAY,CAAA;AAwClD,kGAAkG;AAClG,MAAM,UAAU,oBAAoB,CAAC,SAAmC;IACtE,OAAO;QACL,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,IAAI;QAC/B,SAAS,EAAE,SAAS,EAAE,SAAS,IAAI,MAAM,EAAE;QAC3C,MAAM,EAAE,SAAS,EAAE,MAAM;QACzB,QAAQ,EAAE,SAAS,EAAE,QAAQ;KAC9B,CAAA;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAIvC;IACC,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC;QAC1B,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,aAAa;QAC/B,SAAS,EAAE,EAAE;QACb,YAAY,EAAE,IAAI;KACnB,CAAC,CAAA;IACF,OAAO;QACL,KAAK;QACL,SAAS,EAAE,MAAM,EAAE,SAAS,IAAI,MAAM,EAAE;QACxC,MAAM,EAAE,MAAM,EAAE,MAAM;KACvB,CAAA;AACH,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Auth-realm error factories.
10
+ *
11
+ * Shaped to match `@byline/core`'s `BylineError` / `createErrorType` conventions
12
+ * (a `code` property and a factory that returns a thrown-ready error) without
13
+ * depending on core — `@byline/auth` stays a leaf package so that core can
14
+ * import types from it without circular risk.
15
+ *
16
+ * Consumers can:
17
+ * - `instanceof AuthError` to narrow,
18
+ * - `err.code === 'ERR_FORBIDDEN'` to branch on category,
19
+ * - catch and re-throw as a `BylineError` at the service boundary if the
20
+ * logger integration is wanted (Phase 4 call sites will do this).
21
+ */
22
+ export declare const AuthErrorCodes: {
23
+ readonly UNAUTHENTICATED: "ERR_UNAUTHENTICATED";
24
+ readonly FORBIDDEN: "ERR_FORBIDDEN";
25
+ readonly INVALID_CREDENTIALS: "ERR_INVALID_CREDENTIALS";
26
+ readonly INVALID_TOKEN: "ERR_INVALID_TOKEN";
27
+ readonly REVOKED_TOKEN: "ERR_REVOKED_TOKEN";
28
+ readonly ACCOUNT_DISABLED: "ERR_ACCOUNT_DISABLED";
29
+ };
30
+ export type AuthErrorCode = (typeof AuthErrorCodes)[keyof typeof AuthErrorCodes];
31
+ export interface AuthErrorOptions {
32
+ message: string;
33
+ cause?: unknown;
34
+ }
35
+ export declare class AuthError extends Error {
36
+ readonly code: AuthErrorCode;
37
+ constructor(code: AuthErrorCode, options: AuthErrorOptions);
38
+ }
39
+ /** Throw when a request has no actor and the path requires one. */
40
+ export declare const ERR_UNAUTHENTICATED: (options: AuthErrorOptions) => AuthError;
41
+ /** Throw when the actor is known but lacks the required ability. */
42
+ export declare const ERR_FORBIDDEN: (options: AuthErrorOptions) => AuthError;
43
+ /**
44
+ * Throw on sign-in when the email/password combination does not match a
45
+ * known account. Message is intentionally generic — callers should not
46
+ * distinguish "unknown email" from "wrong password" at this layer.
47
+ */
48
+ export declare const ERR_INVALID_CREDENTIALS: (options: AuthErrorOptions) => AuthError;
49
+ /**
50
+ * Throw when an access or refresh token is malformed, has a bad signature,
51
+ * has expired, or otherwise cannot be verified.
52
+ */
53
+ export declare const ERR_INVALID_TOKEN: (options: AuthErrorOptions) => AuthError;
54
+ /**
55
+ * Throw when a refresh token has been revoked — either explicitly, or
56
+ * because it was rotated and the caller is presenting a stale copy
57
+ * (replay). Presenting a rotated token additionally revokes the entire
58
+ * chain descended from it.
59
+ */
60
+ export declare const ERR_REVOKED_TOKEN: (options: AuthErrorOptions) => AuthError;
61
+ /**
62
+ * Throw when credentials / token are valid but the account has been
63
+ * disabled (`is_enabled = false`).
64
+ */
65
+ export declare const ERR_ACCOUNT_DISABLED: (options: AuthErrorOptions) => AuthError;
66
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,cAAc;;;;;;;CAOjB,CAAA;AAEV,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAA;AAEhF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,IAAI,EAAE,aAAa,CAAA;gBAEvB,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB;CAK3D;AAMD,mEAAmE;AACnE,eAAO,MAAM,mBAAmB,YAJb,gBAAgB,cAImD,CAAA;AAEtF,oEAAoE;AACpE,eAAO,MAAM,aAAa,YAPP,gBAAgB,cAOuC,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,YAdjB,gBAAgB,cAc2D,CAAA;AAE9F;;;GAGG;AACH,eAAO,MAAM,iBAAiB,YApBX,gBAAgB,cAoB+C,CAAA;AAElF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,YA5BX,gBAAgB,cA4B+C,CAAA;AAElF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,YAlCd,gBAAgB,cAkCqD,CAAA"}
package/dist/errors.js ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Auth-realm error factories.
10
+ *
11
+ * Shaped to match `@byline/core`'s `BylineError` / `createErrorType` conventions
12
+ * (a `code` property and a factory that returns a thrown-ready error) without
13
+ * depending on core — `@byline/auth` stays a leaf package so that core can
14
+ * import types from it without circular risk.
15
+ *
16
+ * Consumers can:
17
+ * - `instanceof AuthError` to narrow,
18
+ * - `err.code === 'ERR_FORBIDDEN'` to branch on category,
19
+ * - catch and re-throw as a `BylineError` at the service boundary if the
20
+ * logger integration is wanted (Phase 4 call sites will do this).
21
+ */
22
+ export const AuthErrorCodes = {
23
+ UNAUTHENTICATED: 'ERR_UNAUTHENTICATED',
24
+ FORBIDDEN: 'ERR_FORBIDDEN',
25
+ INVALID_CREDENTIALS: 'ERR_INVALID_CREDENTIALS',
26
+ INVALID_TOKEN: 'ERR_INVALID_TOKEN',
27
+ REVOKED_TOKEN: 'ERR_REVOKED_TOKEN',
28
+ ACCOUNT_DISABLED: 'ERR_ACCOUNT_DISABLED',
29
+ };
30
+ export class AuthError extends Error {
31
+ code;
32
+ constructor(code, options) {
33
+ super(options.message, options.cause != null ? { cause: options.cause } : undefined);
34
+ this.name = 'AuthError';
35
+ this.code = code;
36
+ }
37
+ }
38
+ const createAuthErrorType = (code) => {
39
+ return (options) => new AuthError(code, options);
40
+ };
41
+ /** Throw when a request has no actor and the path requires one. */
42
+ export const ERR_UNAUTHENTICATED = createAuthErrorType(AuthErrorCodes.UNAUTHENTICATED);
43
+ /** Throw when the actor is known but lacks the required ability. */
44
+ export const ERR_FORBIDDEN = createAuthErrorType(AuthErrorCodes.FORBIDDEN);
45
+ /**
46
+ * Throw on sign-in when the email/password combination does not match a
47
+ * known account. Message is intentionally generic — callers should not
48
+ * distinguish "unknown email" from "wrong password" at this layer.
49
+ */
50
+ export const ERR_INVALID_CREDENTIALS = createAuthErrorType(AuthErrorCodes.INVALID_CREDENTIALS);
51
+ /**
52
+ * Throw when an access or refresh token is malformed, has a bad signature,
53
+ * has expired, or otherwise cannot be verified.
54
+ */
55
+ export const ERR_INVALID_TOKEN = createAuthErrorType(AuthErrorCodes.INVALID_TOKEN);
56
+ /**
57
+ * Throw when a refresh token has been revoked — either explicitly, or
58
+ * because it was rotated and the caller is presenting a stale copy
59
+ * (replay). Presenting a rotated token additionally revokes the entire
60
+ * chain descended from it.
61
+ */
62
+ export const ERR_REVOKED_TOKEN = createAuthErrorType(AuthErrorCodes.REVOKED_TOKEN);
63
+ /**
64
+ * Throw when credentials / token are valid but the account has been
65
+ * disabled (`is_enabled = false`).
66
+ */
67
+ export const ERR_ACCOUNT_DISABLED = createAuthErrorType(AuthErrorCodes.ACCOUNT_DISABLED);
68
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,eAAe,EAAE,qBAAqB;IACtC,SAAS,EAAE,eAAe;IAC1B,mBAAmB,EAAE,yBAAyB;IAC9C,aAAa,EAAE,mBAAmB;IAClC,aAAa,EAAE,mBAAmB;IAClC,gBAAgB,EAAE,sBAAsB;CAChC,CAAA;AASV,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClB,IAAI,CAAe;IAEnC,YAAY,IAAmB,EAAE,OAAyB;QACxD,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QACpF,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED,MAAM,mBAAmB,GAAG,CAAC,IAAmB,EAAE,EAAE;IAClD,OAAO,CAAC,OAAyB,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACpE,CAAC,CAAA;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,cAAc,CAAC,eAAe,CAAC,CAAA;AAEtF,oEAAoE;AACpE,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAA;AAE1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAA;AAE9F;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,cAAc,CAAC,aAAa,CAAC,CAAA;AAElF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,cAAc,CAAC,aAAa,CAAC,CAAA;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ export { type AbilityDescriptor, AbilityRegistry, } from './abilities.js';
9
+ export { type Actor, AdminAuth, isAdminAuth, isUserAuth, UserAuth, } from './actor.js';
10
+ export { createRequestContext, createSuperAdminContext, type RequestContext, } from './context.js';
11
+ export { AuthError, type AuthErrorCode, AuthErrorCodes, type AuthErrorOptions, ERR_ACCOUNT_DISABLED, ERR_FORBIDDEN, ERR_INVALID_CREDENTIALS, ERR_INVALID_TOKEN, ERR_REVOKED_TOKEN, ERR_UNAUTHENTICATED, } from './errors.js';
12
+ export type { AccessTokenPayload, RefreshSessionArgs, SessionProvider, SessionProviderCapabilities, SessionTokens, SignInResult, SignInWithPasswordArgs, } from './session-provider.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,KAAK,iBAAiB,EACtB,eAAe,GAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,KAAK,KAAK,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,SAAS,EACT,KAAK,aAAa,EAClB,cAAc,EACd,KAAK,gBAAgB,EACrB,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,2BAA2B,EAC3B,aAAa,EACb,YAAY,EACZ,sBAAsB,GACvB,MAAM,uBAAuB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ export { AbilityRegistry, } from './abilities.js';
9
+ export { AdminAuth, isAdminAuth, isUserAuth, UserAuth, } from './actor.js';
10
+ export { createRequestContext, createSuperAdminContext, } from './context.js';
11
+ export { AuthError, AuthErrorCodes, ERR_ACCOUNT_DISABLED, ERR_FORBIDDEN, ERR_INVALID_CREDENTIALS, ERR_INVALID_TOKEN, ERR_REVOKED_TOKEN, ERR_UNAUTHENTICATED, } from './errors.js';
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,eAAe,GAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAEL,SAAS,EACT,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GAExB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,SAAS,EAET,cAAc,EAEd,oBAAoB,EACpB,aAAa,EACb,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAA"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Session provider — the transport-agnostic contract for authenticating
10
+ * admin users and managing session tokens.
11
+ *
12
+ * The built-in `JwtSessionProvider` (in `@byline/db-postgres/admin`) mints
13
+ * short-lived JWT access tokens and long-lived opaque refresh tokens,
14
+ * storing refresh-token hashes in `byline_admin_refresh_tokens` for
15
+ * revocation and replay detection.
16
+ *
17
+ * Alternative providers can adapt Lucia, better-auth, WorkOS, Clerk, or an
18
+ * institutional SSO/IdP by implementing this surface. `capabilities` lets
19
+ * the admin UI render affordances appropriate to whatever provider is
20
+ * wired up.
21
+ *
22
+ * See docs/analysis/AUTHN-AUTHZ-ANALYSIS.md §7.
23
+ */
24
+ import type { AdminAuth } from './actor.js';
25
+ /**
26
+ * Decoded access-token payload. `JwtSessionProvider` issues this shape;
27
+ * alternative providers may attach additional claims but must at minimum
28
+ * carry the `sub` (admin user id) so `verifyAccessToken` can resolve the
29
+ * actor.
30
+ */
31
+ export interface AccessTokenPayload {
32
+ /** Admin user id (UUIDv7). */
33
+ sub: string;
34
+ /** Issued-at (seconds since epoch). */
35
+ iat: number;
36
+ /** Expires-at (seconds since epoch). */
37
+ exp: number;
38
+ /** Issuer identifier — `'byline'` for the built-in provider. */
39
+ iss: string;
40
+ /** JWT id. Unique per issuance so same-second re-issuance produces distinct tokens. */
41
+ jti: string;
42
+ /** Token type discriminator — `'access'` for access tokens. */
43
+ typ: 'access';
44
+ }
45
+ /** Returned by `signInWithPassword` and `refreshSession`. */
46
+ export interface SessionTokens {
47
+ /** Short-lived (typically 15 min). Sent on every authenticated request. */
48
+ accessToken: string;
49
+ /**
50
+ * Long-lived (typically 30 days). Opaque random string in the built-in
51
+ * provider; alternative providers may use their own format. Client
52
+ * stores this in an http-only cookie or secure storage.
53
+ */
54
+ refreshToken: string;
55
+ /** Seconds-from-now at which `accessToken` expires. */
56
+ accessTokenExpiresAt: Date;
57
+ /** Seconds-from-now at which `refreshToken` expires. */
58
+ refreshTokenExpiresAt: Date;
59
+ }
60
+ export interface SignInResult extends SessionTokens {
61
+ actor: AdminAuth;
62
+ }
63
+ export interface SignInWithPasswordArgs {
64
+ email: string;
65
+ password: string;
66
+ /** Client IP — recorded on the refresh-token row for observability. */
67
+ ip?: string;
68
+ /** Client User-Agent — recorded on the refresh-token row for observability. */
69
+ userAgent?: string;
70
+ }
71
+ export interface RefreshSessionArgs {
72
+ refreshToken: string;
73
+ ip?: string;
74
+ userAgent?: string;
75
+ }
76
+ /**
77
+ * Capability flags. The admin UI consults these when rendering sign-in
78
+ * affordances — e.g. hide the "change password" button when the provider
79
+ * delegates credential management to an external IdP, show a "Sign in
80
+ * with SSO" button when appropriate.
81
+ */
82
+ export interface SessionProviderCapabilities {
83
+ /** Can callers change their password through this provider? */
84
+ passwordChange: boolean;
85
+ /** Does the provider support magic-link sign-in? */
86
+ magicLink: boolean;
87
+ /** Does the provider delegate to an SSO/IdP (SAML, OIDC, etc.)? */
88
+ sso: boolean;
89
+ }
90
+ export interface SessionProvider {
91
+ /** Verify email + password, return fresh tokens and the resolved actor. */
92
+ signInWithPassword(args: SignInWithPasswordArgs): Promise<SignInResult>;
93
+ /**
94
+ * Verify an access token. Returns the actor resolved from the token's
95
+ * subject. Throws `ERR_INVALID_TOKEN` on bad signature, expiry, or
96
+ * tampering; throws `ERR_ACCOUNT_DISABLED` if the subject has been
97
+ * disabled since the token was issued.
98
+ */
99
+ verifyAccessToken(token: string): Promise<{
100
+ actor: AdminAuth;
101
+ }>;
102
+ /**
103
+ * Rotate the refresh token. Returns fresh tokens; the presented token
104
+ * is revoked. Presenting an already-rotated token triggers
105
+ * `ERR_REVOKED_TOKEN` and revokes the entire chain descended from the
106
+ * replayed token (theft recovery).
107
+ */
108
+ refreshSession(args: RefreshSessionArgs): Promise<SessionTokens>;
109
+ /** Revoke a refresh token. Idempotent on an already-revoked token. */
110
+ revokeSession(refreshToken: string): Promise<void>;
111
+ /**
112
+ * Resolve an actor from an admin user id without any token. Used by
113
+ * tests, seeds, and admin tooling that authenticates outside the
114
+ * sign-in flow. Returns `null` when the user does not exist or is
115
+ * disabled.
116
+ */
117
+ resolveActor(adminUserId: string): Promise<AdminAuth | null>;
118
+ /** Declarative capability flags. See `SessionProviderCapabilities`. */
119
+ readonly capabilities: SessionProviderCapabilities;
120
+ }
121
+ //# sourceMappingURL=session-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-provider.d.ts","sourceRoot":"","sources":["../src/session-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAA;IACX,gEAAgE;IAChE,GAAG,EAAE,MAAM,CAAA;IACX,uFAAuF;IACvF,GAAG,EAAE,MAAM,CAAA;IACX,+DAA+D;IAC/D,GAAG,EAAE,QAAQ,CAAA;CACd;AAED,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAA;IACnB;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB,uDAAuD;IACvD,oBAAoB,EAAE,IAAI,CAAA;IAC1B,wDAAwD;IACxD,qBAAqB,EAAE,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,KAAK,EAAE,SAAS,CAAA;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,uEAAuE;IACvE,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAA;IACpB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C,+DAA+D;IAC/D,cAAc,EAAE,OAAO,CAAA;IACvB,oDAAoD;IACpD,SAAS,EAAE,OAAO,CAAA;IAClB,mEAAmE;IACnE,GAAG,EAAE,OAAO,CAAA;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAEvE;;;;;OAKG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC,CAAA;IAE/D;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IAEhE,sEAAsE;IACtE,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAElD;;;;;OAKG;IACH,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAA;IAE5D,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=session-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-provider.js","sourceRoot":"","sources":["../src/session-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@byline/auth",
3
+ "private": false,
4
+ "license": "MPL-2.0",
5
+ "version": "0.9.3",
6
+ "engines": {
7
+ "node": ">=20.9.0"
8
+ },
9
+ "description": "Byline CMS auth primitives — actors, abilities, request context, session provider interface",
10
+ "keywords": [
11
+ "cms",
12
+ "headless cms",
13
+ "content management",
14
+ "authentication",
15
+ "authorization"
16
+ ],
17
+ "homepage": "https://github.com/Byline-CMS/bylinecms.dev",
18
+ "bugs": {
19
+ "url": "https://github.com/Byline-CMS/bylinecms.dev/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/Byline-CMS/bylinecms.dev.git",
24
+ "directory": "packages/auth"
25
+ },
26
+ "type": "module",
27
+ "main": "dist/index.js",
28
+ "index": "dist/index.js",
29
+ "types": "dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.js"
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "dependencies": {
42
+ "npm-run-all": "^4.1.5",
43
+ "uuid": "^14.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "@biomejs/biome": "2.4.14",
47
+ "@types/node": "^25.6.0",
48
+ "chokidar": "^5.0.0",
49
+ "chokidar-cli": "^3.0.0",
50
+ "tsc-alias": "^1.8.17",
51
+ "tsx": "^4.21.0",
52
+ "typescript": "6.0.3",
53
+ "vitest": "^4.1.5"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public",
57
+ "index": "dist/index.js",
58
+ "registry": "https://registry.npmjs.org/"
59
+ },
60
+ "scripts": {
61
+ "dev": "chokidar 'src/**/*' -c 'npm-run-all build'",
62
+ "build": "tsc -p tsconfig.json && tsc-alias",
63
+ "clean": "rimraf node_modules dist build .turbo",
64
+ "lint": "biome check --write --unsafe --diagnostic-level=error",
65
+ "test": "vitest run --mode=node",
66
+ "test:watch": "vitest --mode=node",
67
+ "typecheck": "tsc --noEmit"
68
+ }
69
+ }