@cotal-ai/auth 0.0.0 → 0.11.0

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.
Files changed (55) hide show
  1. package/LICENSE +202 -0
  2. package/dist/callout.d.ts +108 -0
  3. package/dist/callout.d.ts.map +1 -0
  4. package/dist/callout.js +219 -0
  5. package/dist/callout.js.map +1 -0
  6. package/dist/commands.d.ts +2 -0
  7. package/dist/commands.d.ts.map +1 -0
  8. package/dist/commands.js +359 -0
  9. package/dist/commands.js.map +1 -0
  10. package/dist/derive.d.ts +15 -0
  11. package/dist/derive.d.ts.map +1 -0
  12. package/dist/derive.js +72 -0
  13. package/dist/derive.js.map +1 -0
  14. package/dist/idp.d.ts +63 -0
  15. package/dist/idp.d.ts.map +1 -0
  16. package/dist/idp.js +125 -0
  17. package/dist/idp.js.map +1 -0
  18. package/dist/index.d.ts +13 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +13 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/issuer.d.ts +78 -0
  23. package/dist/issuer.d.ts.map +1 -0
  24. package/dist/issuer.js +137 -0
  25. package/dist/issuer.js.map +1 -0
  26. package/dist/ledger.d.ts +108 -0
  27. package/dist/ledger.d.ts.map +1 -0
  28. package/dist/ledger.js +399 -0
  29. package/dist/ledger.js.map +1 -0
  30. package/dist/login.d.ts +69 -0
  31. package/dist/login.d.ts.map +1 -0
  32. package/dist/login.js +338 -0
  33. package/dist/login.js.map +1 -0
  34. package/dist/permissions.d.ts +28 -0
  35. package/dist/permissions.d.ts.map +1 -0
  36. package/dist/permissions.js +50 -0
  37. package/dist/permissions.js.map +1 -0
  38. package/dist/provider.d.ts +18 -0
  39. package/dist/provider.d.ts.map +1 -0
  40. package/dist/provider.js +213 -0
  41. package/dist/provider.js.map +1 -0
  42. package/dist/service.d.ts +10 -0
  43. package/dist/service.d.ts.map +1 -0
  44. package/dist/service.js +288 -0
  45. package/dist/service.js.map +1 -0
  46. package/dist/store.d.ts +82 -0
  47. package/dist/store.d.ts.map +1 -0
  48. package/dist/store.js +208 -0
  49. package/dist/store.js.map +1 -0
  50. package/dist/token.d.ts +68 -0
  51. package/dist/token.d.ts.map +1 -0
  52. package/dist/token.js +128 -0
  53. package/dist/token.js.map +1 -0
  54. package/package.json +35 -5
  55. package/README.md +0 -4
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,108 @@
1
+ import type { JWTVerifyGetKey, CryptoKey } from "jose";
2
+ import { type ValidatedUserToken } from "./token.js";
3
+ /** The one subject the callout serves (ADR-26). */
4
+ export declare const AUTH_CALLOUT_SUBJECT = "$SYS.REQ.USER.AUTH";
5
+ /** The trust material of the dedicated auth-callout account. */
6
+ export interface CalloutAuth {
7
+ /** The auth account: operator-signed JWT carrying `authorization { auth_users, allowed_accounts, xkey }`. */
8
+ account: {
9
+ pub: string;
10
+ seed: string;
11
+ signingSeed: string;
12
+ signingPub: string;
13
+ jwt: string;
14
+ };
15
+ /** The callout service's own connection creds (the sole `auth_users` entry). */
16
+ calloutCreds: string;
17
+ /** Shared, deny-all sentinel creds agents present alongside their bearer. Powerless by design. */
18
+ sentinelCreds: string;
19
+ /** The callout curve keypair (xkey). The seed stays with the callout service only. */
20
+ xkey: {
21
+ seed: string;
22
+ pub: string;
23
+ };
24
+ }
25
+ /** EXACTLY what minting the callout account requires — a deliberate capability boundary (the
26
+ * auth-provider seam passes this, never the whole space bundle): the operator seed signs the new
27
+ * account into the trust chain; the data-account PUB is what `allowed_accounts` re-binds into. */
28
+ export interface CalloutProvisionInput {
29
+ space: string;
30
+ /** The space operator's signing seed — only the operator can sign a new account. */
31
+ operatorSeed: string;
32
+ /** The data account callout responses may bind users into (public key only). */
33
+ accountPub: string;
34
+ }
35
+ /** Generate the dedicated auth-callout account for a space: account + signing key, the callout
36
+ * service user, the deny-all sentinel, and the xkey — `authorization` wired so the server seals
37
+ * requests and lets responses bind users into the data account. */
38
+ export declare function createCalloutAuth(input: CalloutProvisionInput): Promise<CalloutAuth>;
39
+ /** The minimal connection surface the callout needs — structurally satisfied by a nats.js
40
+ * `NatsConnection` without this package depending on a transport. */
41
+ export interface CalloutConnection {
42
+ subscribe(subject: string, opts?: {
43
+ queue?: string;
44
+ }): AsyncIterable<CalloutMsg>;
45
+ }
46
+ export interface CalloutMsg {
47
+ data: Uint8Array;
48
+ headers?: {
49
+ get(key: string): string | undefined;
50
+ };
51
+ respond(data: Uint8Array): unknown;
52
+ }
53
+ export interface StartAuthCalloutOpts {
54
+ /** The callout xkey SEED — MANDATORY. No xkey, no service (fail startup, never plaintext). */
55
+ xkeySeed: string;
56
+ /** The auth account (response issuer): its pub + the signing seed the response is signed with. */
57
+ authAccount: {
58
+ pub: string;
59
+ signingSeed: string;
60
+ };
61
+ /** The data account users are bound into: its pub + the signing seed that mints user JWTs. */
62
+ dataAccount: {
63
+ pub: string;
64
+ signingSeed: string;
65
+ };
66
+ /** The space — enforced as the bearer's audience. */
67
+ space: string;
68
+ /** Pinned bearer verification: the key resolver (pinned JWKS/local key) + exact issuer. */
69
+ token: {
70
+ key: JWTVerifyGetKey | CryptoKey;
71
+ issuer: string;
72
+ };
73
+ /** The spawn-ledger hook: THROW to deny. Client-supplied actor claims are only as good as this
74
+ * server-side check — the flip wires the manager's authenticated spawn ledger in here. */
75
+ authorizeActor: (t: ValidatedUserToken) => void | Promise<void>;
76
+ /** Allow-list of trusted nats-server ids (`server_id.id`) — the tightest request-provenance pin:
77
+ * a request whose server id is not listed is dropped (no response). STRONGLY RECOMMENDED for any
78
+ * hardened / multi-server deploy. When omitted, the ONLY barrier left is NATS $SYS system-subject
79
+ * isolation (no in-account user can publish `$SYS.REQ.USER.AUTH`, and the callout user is even
80
+ * explicitly pub-denied it) — the app-layer `iss === server_id.id` + `N…`-prefix check is NOT
81
+ * independently sufficient, since an attacker who could reach the subject could present their own
82
+ * `createServer()` key and matching sealing xkey. That isolation holds single-broker, so omitting
83
+ * the list is safe today; startup logs a WARNING so the over-trust is never silent. */
84
+ expectedServerIds?: string[];
85
+ /** Permission builder for a validated principal (the flip feeds core's `permissionsFor` via a thin
86
+ * `@cotal-ai/auth` adapter). `connId` is the client-chosen inbox nonce (`req.connect_opts.name`), NOT
87
+ * the NATS-minted `req.user_nkey` — the builder scopes the private reply inbox `_INBOX_<connId>.>` on
88
+ * it. The client picks and passes this nonce because neither it nor this callout knows the per-connect
89
+ * nkey pre-connect; core's `assertInboxConnId` rejects a nonce with subject metacharacters, so it
90
+ * cannot widen the grant. An absent/invalid nonce makes the builder throw → a signed deny. */
91
+ permissionsFor: (t: ValidatedUserToken, connId: string) => Record<string, unknown>;
92
+ /** Diagnostics sink (default: console.error). Never carries bearer contents. */
93
+ log?: (line: string) => void;
94
+ /** Audit hook fired on each successful mint, BEFORE the response is sent — the minted user JWT
95
+ * plus its principal and bound expiry. For metering/audit and for asserting the revocation lever
96
+ * (the mint's `exp` is bound to the bearer's, so broker access dies with the bearer). */
97
+ onMint?: (info: {
98
+ jwt: string;
99
+ principal: string;
100
+ exp: number;
101
+ }) => void;
102
+ }
103
+ /** Serve the auth callout on an existing (auth-account) connection. Resolves setup synchronously —
104
+ * throws on missing/invalid xkey or signing material; returns the running service. */
105
+ export declare function startAuthCallout(nc: CalloutConnection, opts: StartAuthCalloutOpts): {
106
+ done: Promise<void>;
107
+ };
108
+ //# sourceMappingURL=callout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callout.d.ts","sourceRoot":"","sources":["../src/callout.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,EAAqB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAExE,mDAAmD;AACnD,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AAazD,gEAAgE;AAChE,MAAM,WAAW,WAAW;IAC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AAC;IAClD,8FAA8F;IAC9F,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,KAAK,EAAE;QAAE,GAAG,EAAE,eAAe,GAAG,SAAS,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D;+FAC2F;IAC3F,cAAc,EAAE,CAAC,CAAC,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE;;;;;;;4FAOwF;IACxF,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B;;;;;mGAK+F;IAC/F,cAAc,EAAE,CAAC,CAAC,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,gFAAgF;IAChF,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B;;8FAE0F;IAC1F,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC1E;AAED;uFACuF;AACvF,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,oBAAoB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAiI3G"}
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Plane-2 auth-callout bridge (ADR-26, operator mode) — the server-side service that turns a
3
+ * validated user bearer into a scoped, short-lived NATS user JWT at connect time.
4
+ *
5
+ * Operator-mode topology (the sentinel pattern):
6
+ * - a DEDICATED auth account quarantines callout traffic ({@link createCalloutAuth}): the callout
7
+ * service is its only privileged user, plus a shared deny-all "sentinel" user whose creds
8
+ * agents present alongside the real bearer in `auth_token`;
9
+ * - the auth account's JWT carries `authorization { auth_users, allowed_accounts, xkey }`, so the
10
+ * server routes connects landing there to `$SYS.REQ.USER.AUTH` and lets the response re-bind
11
+ * the client into the DATA account (`issuer_account` + a user JWT signed by the data account's
12
+ * signing key);
13
+ * - the **xkey is mandatory**: {@link startAuthCallout} refuses to start without one, and drops
14
+ * any request that arrives unsealed or whose signed `server_id.xkey` doesn't match the sealing
15
+ * header key — without this the bearer crosses the auth path in cleartext (TLS protects the
16
+ * transport, not this payload).
17
+ *
18
+ * Fail-closed at every step: protocol-shape violations (bad seal, bad signature, key mismatch)
19
+ * get NO response (the server denies on timeout — we cannot authenticate the peer, so we do not
20
+ * talk to it); authenticated-but-invalid bearers get a signed, sealed ERROR response; only a fully
21
+ * validated principal gets a mint. The minted user JWT's expiry is BOUND to the bearer's, so
22
+ * broker access dies with the token (the v1 revocation lever — nats-server disconnects clients at
23
+ * user-JWT expiry).
24
+ */
25
+ import { Algorithms, decode, encodeAccount, encodeAuthorizationResponse, encodeUser, fmtCreds, } from "@nats-io/jwt";
26
+ import { createAccount, createCurve, fromCurveSeed, fromPublic, fromSeed } from "@nats-io/nkeys";
27
+ import { assertInboxConnId, newIdentity, principalKey, principalTags, token } from "@cotal-ai/core";
28
+ import { validateUserToken } from "./token.js";
29
+ /** The one subject the callout serves (ADR-26). */
30
+ export const AUTH_CALLOUT_SUBJECT = "$SYS.REQ.USER.AUTH";
31
+ /** Header carrying the server's public curve key on sealed callout requests. */
32
+ const SERVER_XKEY_HEADER = "Nats-Server-Xkey";
33
+ // The auth account is a quarantine: no JetStream, unlimited conns (every callout-mode connect
34
+ // transits it). Mirrors core's account limits shape (which is module-private there on purpose —
35
+ // the auth account is this package's concern, not part of the wire standard).
36
+ const AUTH_ACCOUNT_LIMITS = {
37
+ subs: -1, conn: -1, leaf: -1, imports: -1, exports: -1,
38
+ data: -1, payload: -1, wildcards: true, mem_storage: 0, disk_storage: 0,
39
+ };
40
+ /** Generate the dedicated auth-callout account for a space: account + signing key, the callout
41
+ * service user, the deny-all sentinel, and the xkey — `authorization` wired so the server seals
42
+ * requests and lets responses bind users into the data account. */
43
+ export async function createCalloutAuth(input) {
44
+ if (!input.operatorSeed)
45
+ throw new Error("createCalloutAuth: the operator signing seed is required - a stripped space bundle cannot sign a new account");
46
+ if (!input.accountPub)
47
+ throw new Error("createCalloutAuth: the data account public key is required");
48
+ const okp = fromSeed(new TextEncoder().encode(input.operatorSeed));
49
+ const akp = createAccount();
50
+ const askp = createAccount();
51
+ const xkp = createCurve();
52
+ const callout = newIdentity();
53
+ const sentinel = newIdentity();
54
+ const accountJwt = await encodeAccount(`AUTH_${token(input.space)}`, akp, {
55
+ limits: { ...AUTH_ACCOUNT_LIMITS },
56
+ signing_keys: [askp.getPublicKey()],
57
+ authorization: {
58
+ auth_users: [callout.id],
59
+ allowed_accounts: [input.accountPub],
60
+ xkey: xkp.getPublicKey(),
61
+ },
62
+ }, { signer: okp });
63
+ const dec = (u) => new TextDecoder().decode(u);
64
+ const signer = askp;
65
+ // The callout user: subscribe ONLY the callout subject; publish everywhere it might need to send
66
+ // a reply (server-chosen inbox) EXCEPT the callout subject itself — denying pub on
67
+ // $SYS.REQ.USER.AUTH means even a leaked callout cred cannot inject a forged auth request into
68
+ // its own service (defense-in-depth behind the iss/server-id provenance check in the handler).
69
+ // The sentinel: deny-all both ways — it exists only so a connect can carry a bearer; any
70
+ // capability here would be pre-auth surface.
71
+ const calloutJwt = await encodeUser("callout", fromPublic(callout.id), fromPublic(akp.getPublicKey()), {
72
+ sub: { allow: [AUTH_CALLOUT_SUBJECT] },
73
+ pub: { allow: [">"], deny: [AUTH_CALLOUT_SUBJECT] },
74
+ }, { signer });
75
+ const sentinelJwt = await encodeUser("sentinel", fromPublic(sentinel.id), fromPublic(akp.getPublicKey()), {
76
+ sub: { deny: [">"] },
77
+ pub: { deny: [">"] },
78
+ }, { signer });
79
+ return {
80
+ account: { pub: akp.getPublicKey(), seed: dec(akp.getSeed()), signingSeed: dec(askp.getSeed()), signingPub: askp.getPublicKey(), jwt: accountJwt },
81
+ calloutCreds: dec(fmtCreds(calloutJwt, fromSeed(new TextEncoder().encode(callout.seed)))),
82
+ sentinelCreds: dec(fmtCreds(sentinelJwt, fromSeed(new TextEncoder().encode(sentinel.seed)))),
83
+ xkey: { seed: dec(xkp.getSeed()), pub: xkp.getPublicKey() },
84
+ };
85
+ }
86
+ /** Serve the auth callout on an existing (auth-account) connection. Resolves setup synchronously —
87
+ * throws on missing/invalid xkey or signing material; returns the running service. */
88
+ export function startAuthCallout(nc, opts) {
89
+ if (!opts.xkeySeed)
90
+ throw new Error("auth callout: xkey seed is required - refusing to start a callout that would receive bearer tokens unsealed");
91
+ const xkp = fromCurveSeed(new TextEncoder().encode(opts.xkeySeed)); // throws on non-curve seeds
92
+ const responseSigner = fromSeed(new TextEncoder().encode(opts.authAccount.signingSeed));
93
+ const userSigner = fromSeed(new TextEncoder().encode(opts.dataAccount.signingSeed));
94
+ if (!opts.space)
95
+ throw new Error("auth callout: space is required");
96
+ const log = opts.log ?? ((l) => console.error(l));
97
+ const enc = (s) => new TextEncoder().encode(s);
98
+ const dec = (u) => new TextDecoder().decode(u);
99
+ if (!opts.expectedServerIds?.length)
100
+ log("auth callout: WARNING - no expectedServerIds allow-list set; request provenance rests on $SYS system-subject isolation alone (safe single-broker, but set expectedServerIds for hardened/multi-server deploys)");
101
+ const sub = nc.subscribe(AUTH_CALLOUT_SUBJECT, { queue: "cotal-auth-callout" });
102
+ const done = (async () => {
103
+ for await (const msg of sub) {
104
+ // ---- authenticate the REQUEST itself; shape violations get NO response ----
105
+ const serverXkey = msg.headers?.get(SERVER_XKEY_HEADER);
106
+ if (!serverXkey) {
107
+ log("auth callout: dropped an UNSEALED request (no Nats-Server-Xkey header) - check the account xkey config");
108
+ continue;
109
+ }
110
+ let claims;
111
+ try {
112
+ const plain = xkp.open(msg.data, serverXkey);
113
+ if (plain === null)
114
+ throw new Error("xkey open failed");
115
+ claims = decode(dec(plain)); // ed25519 signature verified in decode()
116
+ }
117
+ catch (e) {
118
+ log(`auth callout: dropped an undecryptable/unverifiable request (${e instanceof Error ? e.message : String(e)})`);
119
+ continue;
120
+ }
121
+ const req = claims.nats;
122
+ if (!req?.user_nkey || !req.server_id?.id) {
123
+ log("auth callout: dropped a request without user_nkey/server_id");
124
+ continue;
125
+ }
126
+ // Request provenance — prove nats-server sent this, not an in-account publisher. `decode()`
127
+ // verified the signature against the embedded `iss`, but that alone accepts ANY self-signed
128
+ // JWT; without pinning, a holder of callout creds could publish a sealed forged request to a
129
+ // reply subject it controls and be minted a data-account JWT. So: the issuer must be the
130
+ // request's own server id AND a server-prefixed (`N…`) nkey, and — when configured — one of
131
+ // the trusted server ids.
132
+ const issuer = claims.iss;
133
+ if (issuer !== req.server_id.id || !req.server_id.id.startsWith("N")) {
134
+ log("auth callout: dropped a request whose issuer is not its own server identity (forgery guard)");
135
+ continue;
136
+ }
137
+ if (opts.expectedServerIds && !opts.expectedServerIds.includes(req.server_id.id)) {
138
+ log(`auth callout: dropped a request from an untrusted server id ${req.server_id.id}`);
139
+ continue;
140
+ }
141
+ if (req.server_id.xkey !== serverXkey) {
142
+ // The signed payload must vouch for the key that sealed it — otherwise a relay could
143
+ // re-seal someone else's request under its own key.
144
+ log("auth callout: dropped a request whose signed server_id.xkey != sealing header key");
145
+ continue;
146
+ }
147
+ const respond = async (data) => {
148
+ const resp = await encodeAuthorizationResponse(fromPublic(req.user_nkey), fromPublic(req.server_id.id), responseSigner, { ...data, issuer_account: opts.authAccount.pub }, { algorithm: Algorithms.v2 });
149
+ msg.respond(xkp.seal(enc(resp), serverXkey));
150
+ };
151
+ // ---- validate the bearer; failures are authenticated denials (signed error response) ----
152
+ try {
153
+ const bearer = req.connect_opts?.auth_token;
154
+ if (!bearer)
155
+ throw new Error("no user token presented (auth_token empty)");
156
+ const validated = await validateUserToken(bearer, {
157
+ key: opts.token.key,
158
+ issuer: opts.token.issuer,
159
+ audience: opts.space,
160
+ });
161
+ await opts.authorizeActor(validated);
162
+ // The private reply-inbox (`_INBOX_<connId>.>`) must scope on a token the CLIENT knows pre-connect
163
+ // — but under the callout the connection nkey (`req.user_nkey`) is minted per-connect by NATS, so
164
+ // the client cannot set its `inboxPrefix` to match it. So the client picks its own random inbox
165
+ // nonce and passes it as the connection `name`; we scope the grant on THAT (empirically: a scoped
166
+ // `_INBOX_<nonce>.>` round-trips through the rebind, and the nonce is a per-connection secret, the
167
+ // same security model as NATS's default random mux inbox). core's `assertInboxConnId` (via
168
+ // permissionsFor) rejects a nonce carrying subject metacharacters, so a client cannot widen the
169
+ // grant to `_INBOX_>.>`; a missing/garbled name throws → this becomes a signed deny (fail-closed).
170
+ // Validate the nonce HERE, at the boundary where untrusted client input enters — not inside the
171
+ // injected permissionsFor hook (which could be any implementation). assertInboxConnId throws on a
172
+ // missing/wildcard name → the catch below turns it into a signed deny (fail-closed).
173
+ const inboxNonce = assertInboxConnId(req.connect_opts?.name ?? "");
174
+ const perms = opts.permissionsFor(validated, inboxNonce);
175
+ // Stamp the principal into the minted JWT so the live identity is recoverable server-side: the
176
+ // connection's `user_nkey` is a per-connect ephemeral the SERVER generated, not the principal,
177
+ // so CONNZ-based attribution (the membership feed, live eviction) needs owner+actor carried
178
+ // here. What actually surfaces in CONNZ for a CALLOUT connection (proven live, nats-server
179
+ // 2.10/2.14) is the JWT `name` as `authorized_user` — the principal NAME-form — NOT the `tags`
180
+ // (those surface for static mints; see core's `principalFromConnz`). We set BOTH via core's
181
+ // single sources for shape-consistency with the static path, but attribution reads
182
+ // `authorized_user` here. The name is the principal name-form (JetStream-safe), a stable label.
183
+ const { key, name } = principalKey(validated.owner, validated.act.actor);
184
+ const userJwt = await encodeUser(name, fromPublic(req.user_nkey), fromPublic(opts.dataAccount.pub), { ...perms, tags: principalTags(validated.owner, validated.act.actor) }, { signer: userSigner, exp: validated.exp });
185
+ opts.onMint?.({ jwt: userJwt, principal: key, exp: validated.exp });
186
+ await respond({ jwt: userJwt });
187
+ }
188
+ catch (e) {
189
+ const reason = e instanceof Error ? e.message : String(e);
190
+ log(`auth callout: denied ${req.user_nkey}: ${reason}`);
191
+ try {
192
+ // The deny response MUST always encode: a denied connect that can't be answered TIMES OUT
193
+ // instead of getting a legible signed refusal, which breaks the fail-closed "refuse, never
194
+ // hang" contract. The auth-response JWT claim encoder is Latin1-limited (btoa-style — a
195
+ // non-ASCII char like the em-dash in many of our throw messages raises "Invalid character"),
196
+ // so coerce the reason to ASCII at this boundary. It is a human-readable hint, not a security
197
+ // token, so lossy folding (em-dash → "-", smart quotes → ASCII, else "?") is fine.
198
+ await respond({ error: asciiFold(reason) });
199
+ }
200
+ catch (re) {
201
+ log(`auth callout: failed to send deny response: ${re instanceof Error ? re.message : String(re)}`);
202
+ }
203
+ }
204
+ }
205
+ })();
206
+ return { done };
207
+ }
208
+ /** Fold a string to ASCII so the Latin1-limited auth-response encoder can always send it (a denied
209
+ * connect must get a legible signed refusal, never hang). Common Unicode punctuation maps to its ASCII
210
+ * stand-in; anything else outside 0x20–0x7E becomes "?". Used only for the human-readable deny reason. */
211
+ function asciiFold(s) {
212
+ return s
213
+ .replace(/[‐-―]/g, "-") // hyphens/dashes incl. em-dash
214
+ .replace(/[‘’‛]/g, "'") // single smart quotes
215
+ .replace(/[“”‟]/g, '"') // double smart quotes
216
+ .replace(/…/g, "...") // ellipsis
217
+ .replace(/[^\x20-\x7E]/g, "?"); // any remaining non-ASCII-printable
218
+ }
219
+ //# sourceMappingURL=callout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callout.js","sourceRoot":"","sources":["../src/callout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EACL,UAAU,EACV,MAAM,EACN,aAAa,EACb,2BAA2B,EAC3B,UAAU,EACV,QAAQ,GAET,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,W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