@amalgm/core 0.5.1-main.44980093747 → 0.5.1-main.46255610608
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +28 -0
- package/dist/adapters/index.d.ts +0 -10
- package/dist/adapters/index.js +0 -11
- package/dist/identity/auth-records.d.ts +0 -66
- package/dist/identity/auth-records.js +1 -216
- package/dist/identity/authorization/broker.d.ts +0 -2
- package/dist/identity/authorization/broker.js +2 -117
- package/dist/identity/authorization/claims.d.ts +0 -2
- package/dist/identity/authorization/claims.js +1 -14
- package/dist/identity/authorization/dpop.d.ts +0 -7
- package/dist/identity/authorization/dpop.js +1 -39
- package/dist/identity/authorization/index.d.ts +0 -1
- package/dist/identity/authorization/index.js +1 -7
- package/dist/identity/authorization/key-transition.d.ts +0 -2
- package/dist/identity/authorization/key-transition.js +1 -44
- package/dist/identity/authorization/policy.d.ts +0 -2
- package/dist/identity/authorization/policy.js +1 -66
- package/dist/identity/authorization/resource.d.ts +0 -5
- package/dist/identity/authorization/resource.js +1 -132
- package/dist/identity/credentials/api.d.ts +0 -1
- package/dist/identity/credentials/api.js +1 -61
- package/dist/identity/credentials/index.d.ts +0 -1
- package/dist/identity/credentials/index.js +1 -3
- package/dist/identity/credentials/types.d.ts +0 -2
- package/dist/identity/credentials/types.js +0 -2
- package/dist/identity/credentials/vault.d.ts +0 -2
- package/dist/identity/credentials/vault.js +1 -238
- package/dist/identity/display-profile.d.ts +0 -28
- package/dist/identity/display-profile.js +1 -53
- package/dist/identity/ids.d.ts +0 -46
- package/dist/identity/ids.js +1 -80
- package/dist/identity/index.d.ts +0 -8
- package/dist/identity/index.js +1 -19
- package/dist/identity/labels.d.ts +0 -96
- package/dist/identity/labels.js +1 -155
- package/dist/identity/layout.d.ts +1 -54
- package/dist/identity/layout.js +1 -224
- package/dist/identity/local/api.d.ts +0 -1
- package/dist/identity/local/api.js +1 -21
- package/dist/identity/local/discovery.d.ts +0 -2
- package/dist/identity/local/discovery.js +1 -74
- package/dist/identity/local/index.d.ts +0 -1
- package/dist/identity/local/index.js +1 -3
- package/dist/identity/local/types.d.ts +0 -1
- package/dist/identity/local/types.js +0 -2
- package/dist/identity/machine-setup.d.ts +0 -22
- package/dist/identity/machine-setup.js +1 -415
- package/dist/identity/ports.d.ts +0 -16
- package/dist/identity/ports.js +0 -9
- package/dist/identity/runtime-binding.d.ts +0 -17
- package/dist/identity/runtime-binding.js +1 -161
- package/dist/identity/runtime-endpoints.d.ts +0 -14
- package/dist/identity/runtime-endpoints.js +1 -102
- package/dist/index.d.ts +0 -16
- package/dist/index.js +1 -19
- package/dist/supervision/activity.d.ts +0 -32
- package/dist/supervision/activity.js +1 -56
- package/dist/supervision/app-health.d.ts +2 -87
- package/dist/supervision/app-health.js +1 -165
- package/dist/supervision/app-restart.d.ts +3 -58
- package/dist/supervision/app-restart.js +1 -97
- package/dist/supervision/health.d.ts +7 -131
- package/dist/supervision/health.js +1 -227
- package/dist/supervision/index.d.ts +0 -13
- package/dist/supervision/index.js +1 -22
- package/dist/supervision/installation-plan.d.ts +0 -14
- package/dist/supervision/installation-plan.js +1 -119
- package/dist/supervision/managed-release.d.ts +1 -14
- package/dist/supervision/managed-release.js +1 -168
- package/dist/supervision/managed-update.d.ts +0 -16
- package/dist/supervision/managed-update.js +1 -226
- package/dist/supervision/service-registration.d.ts +3 -142
- package/dist/supervision/service-registration.js +1 -347
- package/dist/supervision/update.d.ts +0 -74
- package/dist/supervision/update.js +1 -184
- package/dist/transport/admission.d.ts +0 -152
- package/dist/transport/admission.js +1 -313
- package/dist/transport/auth.d.ts +0 -144
- package/dist/transport/auth.js +1 -266
- package/dist/transport/diagnostics.d.ts +0 -2
- package/dist/transport/diagnostics.js +2 -106
- package/dist/transport/index.d.ts +0 -16
- package/dist/transport/index.js +1 -23
- package/dist/transport/pty/api.d.ts +0 -2
- package/dist/transport/pty/api.js +1 -45
- package/dist/transport/pty/index.d.ts +0 -1
- package/dist/transport/pty/index.js +1 -4
- package/dist/transport/pty/session-manager.d.ts +0 -9
- package/dist/transport/pty/session-manager.js +1 -153
- package/dist/transport/pty/types.d.ts +0 -4
- package/dist/transport/pty/types.js +0 -2
- package/dist/transport/routing.d.ts +0 -155
- package/dist/transport/routing.js +1 -287
- package/dist/transport/shipped-routes.d.ts +0 -31
- package/dist/transport/shipped-routes.js +1 -62
- package/dist/transport/state/api.d.ts +0 -1
- package/dist/transport/state/api.js +16 -106
- package/dist/transport/state/index.d.ts +0 -1
- package/dist/transport/state/index.js +1 -5
- package/dist/transport/state/memory-store.d.ts +0 -2
- package/dist/transport/state/memory-store.js +1 -30
- package/dist/transport/state/rail.d.ts +0 -1
- package/dist/transport/state/rail.js +1 -79
- package/dist/transport/state/registry.d.ts +0 -1
- package/dist/transport/state/registry.js +1 -46
- package/dist/transport/state/types.d.ts +0 -2
- package/dist/transport/state/types.js +0 -2
- package/package.json +11 -10
- package/PURPOSE.md +0 -279
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js.map +0 -1
- package/dist/identity/auth-records.d.ts.map +0 -1
- package/dist/identity/auth-records.js.map +0 -1
- package/dist/identity/authorization/broker.d.ts.map +0 -1
- package/dist/identity/authorization/broker.js.map +0 -1
- package/dist/identity/authorization/claims.d.ts.map +0 -1
- package/dist/identity/authorization/claims.js.map +0 -1
- package/dist/identity/authorization/dpop.d.ts.map +0 -1
- package/dist/identity/authorization/dpop.js.map +0 -1
- package/dist/identity/authorization/index.d.ts.map +0 -1
- package/dist/identity/authorization/index.js.map +0 -1
- package/dist/identity/authorization/key-transition.d.ts.map +0 -1
- package/dist/identity/authorization/key-transition.js.map +0 -1
- package/dist/identity/authorization/policy.d.ts.map +0 -1
- package/dist/identity/authorization/policy.js.map +0 -1
- package/dist/identity/authorization/resource.d.ts.map +0 -1
- package/dist/identity/authorization/resource.js.map +0 -1
- package/dist/identity/credentials/api.d.ts.map +0 -1
- package/dist/identity/credentials/api.js.map +0 -1
- package/dist/identity/credentials/index.d.ts.map +0 -1
- package/dist/identity/credentials/index.js.map +0 -1
- package/dist/identity/credentials/types.d.ts.map +0 -1
- package/dist/identity/credentials/types.js.map +0 -1
- package/dist/identity/credentials/vault.d.ts.map +0 -1
- package/dist/identity/credentials/vault.js.map +0 -1
- package/dist/identity/display-profile.d.ts.map +0 -1
- package/dist/identity/display-profile.js.map +0 -1
- package/dist/identity/ids.d.ts.map +0 -1
- package/dist/identity/ids.js.map +0 -1
- package/dist/identity/index.d.ts.map +0 -1
- package/dist/identity/index.js.map +0 -1
- package/dist/identity/labels.d.ts.map +0 -1
- package/dist/identity/labels.js.map +0 -1
- package/dist/identity/layout.d.ts.map +0 -1
- package/dist/identity/layout.js.map +0 -1
- package/dist/identity/local/api.d.ts.map +0 -1
- package/dist/identity/local/api.js.map +0 -1
- package/dist/identity/local/discovery.d.ts.map +0 -1
- package/dist/identity/local/discovery.js.map +0 -1
- package/dist/identity/local/index.d.ts.map +0 -1
- package/dist/identity/local/index.js.map +0 -1
- package/dist/identity/local/types.d.ts.map +0 -1
- package/dist/identity/local/types.js.map +0 -1
- package/dist/identity/machine-setup.d.ts.map +0 -1
- package/dist/identity/machine-setup.js.map +0 -1
- package/dist/identity/ports.d.ts.map +0 -1
- package/dist/identity/ports.js.map +0 -1
- package/dist/identity/runtime-binding.d.ts.map +0 -1
- package/dist/identity/runtime-binding.js.map +0 -1
- package/dist/identity/runtime-endpoints.d.ts.map +0 -1
- package/dist/identity/runtime-endpoints.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/supervision/activity.d.ts.map +0 -1
- package/dist/supervision/activity.js.map +0 -1
- package/dist/supervision/app-health.d.ts.map +0 -1
- package/dist/supervision/app-health.js.map +0 -1
- package/dist/supervision/app-restart.d.ts.map +0 -1
- package/dist/supervision/app-restart.js.map +0 -1
- package/dist/supervision/health.d.ts.map +0 -1
- package/dist/supervision/health.js.map +0 -1
- package/dist/supervision/index.d.ts.map +0 -1
- package/dist/supervision/index.js.map +0 -1
- package/dist/supervision/installation-plan.d.ts.map +0 -1
- package/dist/supervision/installation-plan.js.map +0 -1
- package/dist/supervision/managed-release.d.ts.map +0 -1
- package/dist/supervision/managed-release.js.map +0 -1
- package/dist/supervision/managed-update.d.ts.map +0 -1
- package/dist/supervision/managed-update.js.map +0 -1
- package/dist/supervision/service-registration.d.ts.map +0 -1
- package/dist/supervision/service-registration.js.map +0 -1
- package/dist/supervision/update.d.ts.map +0 -1
- package/dist/supervision/update.js.map +0 -1
- package/dist/transport/admission.d.ts.map +0 -1
- package/dist/transport/admission.js.map +0 -1
- package/dist/transport/auth.d.ts.map +0 -1
- package/dist/transport/auth.js.map +0 -1
- package/dist/transport/diagnostics.d.ts.map +0 -1
- package/dist/transport/diagnostics.js.map +0 -1
- package/dist/transport/index.d.ts.map +0 -1
- package/dist/transport/index.js.map +0 -1
- package/dist/transport/pty/api.d.ts.map +0 -1
- package/dist/transport/pty/api.js.map +0 -1
- package/dist/transport/pty/index.d.ts.map +0 -1
- package/dist/transport/pty/index.js.map +0 -1
- package/dist/transport/pty/session-manager.d.ts.map +0 -1
- package/dist/transport/pty/session-manager.js.map +0 -1
- package/dist/transport/pty/types.d.ts.map +0 -1
- package/dist/transport/pty/types.js.map +0 -1
- package/dist/transport/routing.d.ts.map +0 -1
- package/dist/transport/routing.js.map +0 -1
- package/dist/transport/shipped-routes.d.ts.map +0 -1
- package/dist/transport/shipped-routes.js.map +0 -1
- package/dist/transport/state/api.d.ts.map +0 -1
- package/dist/transport/state/api.js.map +0 -1
- package/dist/transport/state/index.d.ts.map +0 -1
- package/dist/transport/state/index.js.map +0 -1
- package/dist/transport/state/memory-store.d.ts.map +0 -1
- package/dist/transport/state/memory-store.js.map +0 -1
- package/dist/transport/state/rail.d.ts.map +0 -1
- package/dist/transport/state/rail.js.map +0 -1
- package/dist/transport/state/registry.d.ts.map +0 -1
- package/dist/transport/state/registry.js.map +0 -1
- package/dist/transport/state/types.d.ts.map +0 -1
- package/dist/transport/state/types.js.map +0 -1
- package/docs/authorization.md +0 -57
- package/docs/managed-updates.md +0 -126
package/LICENSE.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Amalgm proprietary licence
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 Amalgm. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This package and every file in it ("the Software") belong to Amalgm. It is
|
|
6
|
+
not open source.
|
|
7
|
+
|
|
8
|
+
You may install and run the Software only as part of using Amalgm, and only as
|
|
9
|
+
the Amalgm Terms of Service allow. Those terms govern your use of the
|
|
10
|
+
Software; if you do not accept them, do not install or run it.
|
|
11
|
+
|
|
12
|
+
Unless Amalgm agrees otherwise in writing, you may not:
|
|
13
|
+
|
|
14
|
+
- copy, modify, translate or make works based on the Software;
|
|
15
|
+
- reverse engineer, decompile or disassemble it, or try to recover its source
|
|
16
|
+
code, except where the law allows this despite this restriction;
|
|
17
|
+
- sell, rent, lend, publish, redistribute or sublicense it, or bundle it into
|
|
18
|
+
another product or service;
|
|
19
|
+
- use it, or any part of it, to build a product or service that competes with
|
|
20
|
+
Amalgm;
|
|
21
|
+
- remove or change this notice or any other proprietary notice.
|
|
22
|
+
|
|
23
|
+
Open-source components the Software uses keep their own licences, which this
|
|
24
|
+
notice does not change. Their notices ship with them.
|
|
25
|
+
|
|
26
|
+
The Software is provided "as is", without any warranty, express or implied, to
|
|
27
|
+
the extent the law allows. Amalgm is not liable for any damage arising from it,
|
|
28
|
+
except where the law does not allow that liability to be excluded.
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The adapter ports — every real-world effect the kernel SDK needs,
|
|
3
|
-
* gathered in one place so a host can see the full contract it must
|
|
4
|
-
* satisfy (PURPOSE.md axiom 6: a host supplies its own effects).
|
|
5
|
-
*
|
|
6
|
-
* Nothing in `src/` reaches for `node:*` or `process.env`; these types are
|
|
7
|
-
* the entire boundary. A Node host wires them from `node:crypto`,
|
|
8
|
-
* `node:path`, and `Date`; a test wires them from fixtures.
|
|
9
|
-
*/
|
|
10
1
|
export type { ClockIsoPort, ClockMsPort, RandomHexPort, Sha256HexPort, ResolvePathPort, } from '../identity/ports.js';
|
|
11
2
|
export type { TimingSafeEqualPort } from '../transport/auth.js';
|
|
12
3
|
export type { CredentialCipherPort, CredentialStorePort } from '../identity/credentials/index.js';
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/adapters/index.js
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The adapter ports — every real-world effect the kernel SDK needs,
|
|
3
|
-
* gathered in one place so a host can see the full contract it must
|
|
4
|
-
* satisfy (PURPOSE.md axiom 6: a host supplies its own effects).
|
|
5
|
-
*
|
|
6
|
-
* Nothing in `src/` reaches for `node:*` or `process.env`; these types are
|
|
7
|
-
* the entire boundary. A Node host wires them from `node:crypto`,
|
|
8
|
-
* `node:path`, and `Date`; a test wires them from fixtures.
|
|
9
|
-
*/
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,82 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential-record shaping laws (engine packages/amalgm/lib/auth-store.js
|
|
3
|
-
* and runtime/scripts/proxy-token-store.js) — how a computer record splits
|
|
4
|
-
* into its PUBLIC face (`computer.json`) and its SECRET envelope
|
|
5
|
-
* (`auth.json`), and how the two merge back. Pure record computations only:
|
|
6
|
-
* reading, writing, and env access stay host-side; the clock arrives as a
|
|
7
|
-
* port.
|
|
8
|
-
*
|
|
9
|
-
* Records are loose JSON from disk, so inputs are typed as they truly are:
|
|
10
|
-
* dictionaries of unknowns, validated key by key.
|
|
11
|
-
*/
|
|
12
1
|
import type { ClockIsoPort } from './ports.js';
|
|
13
2
|
type Dict = Record<string, unknown>;
|
|
14
|
-
/** Emails compare lowercased; a record's email is stored lowercased. */
|
|
15
3
|
export declare function normalizeUserEmail(value: unknown): string;
|
|
16
|
-
/** A record's email under any of its historical spellings (auth-store.js:74-76). */
|
|
17
4
|
export declare function userEmailFromRecord(record: unknown): string;
|
|
18
|
-
/**
|
|
19
|
-
* Every key that must NEVER appear in the public `computer.json`
|
|
20
|
-
* (auth-store.js:24-35). Secrets live only in `auth.json`; the exact list —
|
|
21
|
-
* including the legacy camelCase and hmac spellings — is the contract.
|
|
22
|
-
*/
|
|
23
5
|
export declare const SECRET_COMPUTER_KEYS: ReadonlySet<string>;
|
|
24
|
-
/** Does a secret envelope still carry the retired durable proxy credential? */
|
|
25
6
|
export declare function hasRetiredProxyAuth(auth: unknown): boolean;
|
|
26
|
-
/** Does this record carry any secret worth an auth envelope?
|
|
27
|
-
* (auth-store.js:78-81). Whitespace-only values do not count. */
|
|
28
7
|
export declare function hasComputerSecrets(record: unknown): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* The public face of a computer record (auth-store.js:83-92): the record
|
|
31
|
-
* with every secret key removed, its email normalized, and an `auth_file`
|
|
32
|
-
* pointer naming the sibling envelope by BASENAME — the record must stay
|
|
33
|
-
* true when the directory moves. DELIBERATE DEVIATION: the engine's
|
|
34
|
-
* parameter is a full path passed through `node:path.basename`; the same
|
|
35
|
-
* basename law is implemented here inline to stay dependency-free.
|
|
36
|
-
*/
|
|
37
8
|
export declare function publicComputerRecord(record: unknown, authFile?: string): Dict;
|
|
38
|
-
/**
|
|
39
|
-
* The full secret envelope distilled from a computer record
|
|
40
|
-
* (auth-store.js:94-156):
|
|
41
|
-
*
|
|
42
|
-
* { schema_version: 1, computer_id, device_id, user_id, user_email,
|
|
43
|
-
* app_url, tunnel: { token, url }, machine: { token } }
|
|
44
|
-
*
|
|
45
|
-
* Merging over `existing` is additive: identity keys are copied only when
|
|
46
|
-
* the record actually carries them, each token section is (re)stamped only
|
|
47
|
-
* when its token arrives, and a record carrying only tunnel URLs updates
|
|
48
|
-
* the URLs while PRESERVING the existing tunnel token. Retired proxy-token
|
|
49
|
-
* fields are dropped from both new records and existing envelopes: provider
|
|
50
|
-
* access is short-lived broker state, never durable machine state.
|
|
51
|
-
*/
|
|
52
9
|
export declare function authFromRecord(record: unknown, existing: unknown, ports: ClockIsoPort): Dict;
|
|
53
|
-
/**
|
|
54
|
-
* Rejoin a public record with its secret envelope (auth-store.js:158-189).
|
|
55
|
-
* THE REFUSAL: when both sides name a computer_id and they disagree, the
|
|
56
|
-
* envelope is IGNORED wholesale — credentials from one machine identity
|
|
57
|
-
* must never dress up a record claiming another. On agreement the envelope
|
|
58
|
-
* only fills gaps; a value the record already carries always wins. Absent
|
|
59
|
-
* envelope values fill gaps as `''` — exactly the engine's bytes on disk.
|
|
60
|
-
*/
|
|
61
10
|
export declare function mergeRecordAuth(record: unknown, auth: unknown): Dict | null;
|
|
62
|
-
/**
|
|
63
|
-
* May this stored record serve the runtime labeled `currentLabel`?
|
|
64
|
-
* (auth-store.js:191-199). The record's claim is read with key precedence
|
|
65
|
-
* runtime_label > label > branch through the NON-coercing normalizer, so a
|
|
66
|
-
* record with no recognizable label — one that predates labels — belongs
|
|
67
|
-
* to `main` and only main may claim it. Pure over the injected current
|
|
68
|
-
* label instead of module state.
|
|
69
|
-
*/
|
|
70
11
|
export declare function recordMatchesCurrentRuntime(record: unknown, currentLabel: string): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* The scope guard (auth-store.js:201-209): credentials for user A must
|
|
73
|
-
* never be saved into user B's scope. Enforced only when both sides are
|
|
74
|
-
* known and the scope is a real user — the `local` scope predates
|
|
75
|
-
* enrollment and accepts anyone. The refusal string is the ratified text.
|
|
76
|
-
*/
|
|
77
12
|
export declare function assertRecordMatchesUserScope(record: unknown, context: {
|
|
78
13
|
readonly runtimeLabel: string;
|
|
79
14
|
readonly userScope: string;
|
|
80
15
|
}): void;
|
|
81
16
|
export {};
|
|
82
|
-
//# sourceMappingURL=auth-records.d.ts.map
|
|
@@ -1,216 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Credential-record shaping laws (engine packages/amalgm/lib/auth-store.js
|
|
3
|
-
* and runtime/scripts/proxy-token-store.js) — how a computer record splits
|
|
4
|
-
* into its PUBLIC face (`computer.json`) and its SECRET envelope
|
|
5
|
-
* (`auth.json`), and how the two merge back. Pure record computations only:
|
|
6
|
-
* reading, writing, and env access stay host-side; the clock arrives as a
|
|
7
|
-
* port.
|
|
8
|
-
*
|
|
9
|
-
* Records are loose JSON from disk, so inputs are typed as they truly are:
|
|
10
|
-
* dictionaries of unknowns, validated key by key.
|
|
11
|
-
*/
|
|
12
|
-
import { normalizeRuntimeLabel } from './labels.js';
|
|
13
|
-
const asDict = (value) => (value && typeof value === 'object' ? value : null);
|
|
14
|
-
function cleanString(value) {
|
|
15
|
-
return typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
16
|
-
}
|
|
17
|
-
/** Emails compare lowercased; a record's email is stored lowercased. */
|
|
18
|
-
export function normalizeUserEmail(value) {
|
|
19
|
-
return cleanString(value).toLowerCase();
|
|
20
|
-
}
|
|
21
|
-
/** A record's email under any of its historical spellings (auth-store.js:74-76). */
|
|
22
|
-
export function userEmailFromRecord(record) {
|
|
23
|
-
const r = asDict(record);
|
|
24
|
-
return normalizeUserEmail(r?.['user_email'] || r?.['userEmail'] || r?.['email']);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Every key that must NEVER appear in the public `computer.json`
|
|
28
|
-
* (auth-store.js:24-35). Secrets live only in `auth.json`; the exact list —
|
|
29
|
-
* including the legacy camelCase and hmac spellings — is the contract.
|
|
30
|
-
*/
|
|
31
|
-
export const SECRET_COMPUTER_KEYS = new Set([
|
|
32
|
-
'tunnel_token',
|
|
33
|
-
'computer_auth_token',
|
|
34
|
-
'proxy_token',
|
|
35
|
-
'proxy_token_expires_in',
|
|
36
|
-
'proxy_token_expires_at',
|
|
37
|
-
'proxy_token_refreshed_at',
|
|
38
|
-
'proxyToken',
|
|
39
|
-
'proxyTokenExpiresAt',
|
|
40
|
-
'hmac_token',
|
|
41
|
-
'hmacToken',
|
|
42
|
-
]);
|
|
43
|
-
const RETIRED_PROXY_AUTH_KEYS = [
|
|
44
|
-
'proxy',
|
|
45
|
-
'proxy_token',
|
|
46
|
-
'proxy_token_expires_in',
|
|
47
|
-
'proxy_token_expires_at',
|
|
48
|
-
'proxy_token_refreshed_at',
|
|
49
|
-
'proxyToken',
|
|
50
|
-
'proxyTokenExpiresAt',
|
|
51
|
-
'hmac_token',
|
|
52
|
-
'hmacToken',
|
|
53
|
-
];
|
|
54
|
-
/** Does a secret envelope still carry the retired durable proxy credential? */
|
|
55
|
-
export function hasRetiredProxyAuth(auth) {
|
|
56
|
-
const record = asDict(auth);
|
|
57
|
-
return !!record && RETIRED_PROXY_AUTH_KEYS.some((key) => key in record);
|
|
58
|
-
}
|
|
59
|
-
/** Does this record carry any secret worth an auth envelope?
|
|
60
|
-
* (auth-store.js:78-81). Whitespace-only values do not count. */
|
|
61
|
-
export function hasComputerSecrets(record) {
|
|
62
|
-
const r = asDict(record);
|
|
63
|
-
if (!r)
|
|
64
|
-
return false;
|
|
65
|
-
return Array.from(SECRET_COMPUTER_KEYS).some((key) => cleanString(r[key]));
|
|
66
|
-
}
|
|
67
|
-
/** The engine's `path.basename` over both separators, with trailing
|
|
68
|
-
* separators stripped — only the file's own name is published. */
|
|
69
|
-
const baseName = (file) => {
|
|
70
|
-
const trimmed = file.replace(/[\\/]+$/, '');
|
|
71
|
-
const cut = Math.max(trimmed.lastIndexOf('/'), trimmed.lastIndexOf('\\'));
|
|
72
|
-
return cut === -1 ? trimmed : trimmed.slice(cut + 1);
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* The public face of a computer record (auth-store.js:83-92): the record
|
|
76
|
-
* with every secret key removed, its email normalized, and an `auth_file`
|
|
77
|
-
* pointer naming the sibling envelope by BASENAME — the record must stay
|
|
78
|
-
* true when the directory moves. DELIBERATE DEVIATION: the engine's
|
|
79
|
-
* parameter is a full path passed through `node:path.basename`; the same
|
|
80
|
-
* basename law is implemented here inline to stay dependency-free.
|
|
81
|
-
*/
|
|
82
|
-
export function publicComputerRecord(record, authFile = 'auth.json') {
|
|
83
|
-
const out = {
|
|
84
|
-
...(asDict(record) || {}),
|
|
85
|
-
auth_file: baseName(authFile),
|
|
86
|
-
};
|
|
87
|
-
const email = userEmailFromRecord(out);
|
|
88
|
-
if (email)
|
|
89
|
-
out['user_email'] = email;
|
|
90
|
-
for (const key of SECRET_COMPUTER_KEYS)
|
|
91
|
-
delete out[key];
|
|
92
|
-
return out;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* The full secret envelope distilled from a computer record
|
|
96
|
-
* (auth-store.js:94-156):
|
|
97
|
-
*
|
|
98
|
-
* { schema_version: 1, computer_id, device_id, user_id, user_email,
|
|
99
|
-
* app_url, tunnel: { token, url }, machine: { token } }
|
|
100
|
-
*
|
|
101
|
-
* Merging over `existing` is additive: identity keys are copied only when
|
|
102
|
-
* the record actually carries them, each token section is (re)stamped only
|
|
103
|
-
* when its token arrives, and a record carrying only tunnel URLs updates
|
|
104
|
-
* the URLs while PRESERVING the existing tunnel token. Retired proxy-token
|
|
105
|
-
* fields are dropped from both new records and existing envelopes: provider
|
|
106
|
-
* access is short-lived broker state, never durable machine state.
|
|
107
|
-
*/
|
|
108
|
-
export function authFromRecord(record, existing, ports) {
|
|
109
|
-
const now = ports.nowIso();
|
|
110
|
-
const r = asDict(record);
|
|
111
|
-
const auth = {
|
|
112
|
-
schema_version: 1,
|
|
113
|
-
...(asDict(existing) || {}),
|
|
114
|
-
updated_at: now,
|
|
115
|
-
};
|
|
116
|
-
for (const key of RETIRED_PROXY_AUTH_KEYS)
|
|
117
|
-
delete auth[key];
|
|
118
|
-
for (const key of ['computer_id', 'device_id', 'user_id', 'user_email', 'app_url']) {
|
|
119
|
-
const value = key === 'user_email' ? userEmailFromRecord(r) : cleanString(r?.[key]);
|
|
120
|
-
if (value)
|
|
121
|
-
auth[key] = value;
|
|
122
|
-
}
|
|
123
|
-
const priorTunnel = asDict(auth['tunnel']);
|
|
124
|
-
const tunnelToken = cleanString(r?.['tunnel_token']);
|
|
125
|
-
if (tunnelToken) {
|
|
126
|
-
auth['tunnel'] = {
|
|
127
|
-
...(priorTunnel || {}),
|
|
128
|
-
token: tunnelToken,
|
|
129
|
-
url: cleanString(r?.['tunnel_url']) || cleanString(priorTunnel?.['url']),
|
|
130
|
-
updated_at: now,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
else if (r?.['tunnel_url']) {
|
|
134
|
-
auth['tunnel'] = {
|
|
135
|
-
...(priorTunnel || {}),
|
|
136
|
-
url: cleanString(r?.['tunnel_url']) || cleanString(priorTunnel?.['url']),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
const computerAuthToken = cleanString(r?.['computer_auth_token']);
|
|
140
|
-
if (computerAuthToken) {
|
|
141
|
-
auth['machine'] = {
|
|
142
|
-
...(asDict(auth['machine']) || {}),
|
|
143
|
-
token: computerAuthToken,
|
|
144
|
-
updated_at: now,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
return auth;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Rejoin a public record with its secret envelope (auth-store.js:158-189).
|
|
151
|
-
* THE REFUSAL: when both sides name a computer_id and they disagree, the
|
|
152
|
-
* envelope is IGNORED wholesale — credentials from one machine identity
|
|
153
|
-
* must never dress up a record claiming another. On agreement the envelope
|
|
154
|
-
* only fills gaps; a value the record already carries always wins. Absent
|
|
155
|
-
* envelope values fill gaps as `''` — exactly the engine's bytes on disk.
|
|
156
|
-
*/
|
|
157
|
-
export function mergeRecordAuth(record, auth) {
|
|
158
|
-
const r = asDict(record);
|
|
159
|
-
if (!r)
|
|
160
|
-
return null;
|
|
161
|
-
const merged = { ...r };
|
|
162
|
-
const a = asDict(auth);
|
|
163
|
-
if (!a)
|
|
164
|
-
return merged;
|
|
165
|
-
const authComputerId = cleanString(a['computer_id']);
|
|
166
|
-
const recordComputerId = cleanString(r['computer_id']);
|
|
167
|
-
if (authComputerId && recordComputerId && authComputerId !== recordComputerId)
|
|
168
|
-
return merged;
|
|
169
|
-
const tunnel = asDict(a['tunnel']);
|
|
170
|
-
const machine = asDict(a['machine']);
|
|
171
|
-
if (!merged['tunnel_token'])
|
|
172
|
-
merged['tunnel_token'] = cleanString(tunnel?.['token']) || cleanString(a['tunnel_token']);
|
|
173
|
-
if (!merged['tunnel_url'])
|
|
174
|
-
merged['tunnel_url'] = cleanString(tunnel?.['url']);
|
|
175
|
-
if (!merged['computer_auth_token']) {
|
|
176
|
-
merged['computer_auth_token'] = cleanString(machine?.['token']) || cleanString(a['computer_auth_token']);
|
|
177
|
-
}
|
|
178
|
-
if (!merged['user_id'])
|
|
179
|
-
merged['user_id'] = cleanString(a['user_id']);
|
|
180
|
-
if (!merged['user_email'])
|
|
181
|
-
merged['user_email'] = normalizeUserEmail(a['user_email']);
|
|
182
|
-
if (!merged['app_url'])
|
|
183
|
-
merged['app_url'] = cleanString(a['app_url']);
|
|
184
|
-
return merged;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* May this stored record serve the runtime labeled `currentLabel`?
|
|
188
|
-
* (auth-store.js:191-199). The record's claim is read with key precedence
|
|
189
|
-
* runtime_label > label > branch through the NON-coercing normalizer, so a
|
|
190
|
-
* record with no recognizable label — one that predates labels — belongs
|
|
191
|
-
* to `main` and only main may claim it. Pure over the injected current
|
|
192
|
-
* label instead of module state.
|
|
193
|
-
*/
|
|
194
|
-
export function recordMatchesCurrentRuntime(record, currentLabel) {
|
|
195
|
-
const r = asDict(record);
|
|
196
|
-
const label = normalizeRuntimeLabel(r?.['runtime_label'] || r?.['label'] || r?.['branch']);
|
|
197
|
-
if (!label)
|
|
198
|
-
return currentLabel === 'main';
|
|
199
|
-
return label === currentLabel;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* The scope guard (auth-store.js:201-209): credentials for user A must
|
|
203
|
-
* never be saved into user B's scope. Enforced only when both sides are
|
|
204
|
-
* known and the scope is a real user — the `local` scope predates
|
|
205
|
-
* enrollment and accepts anyone. The refusal string is the ratified text.
|
|
206
|
-
*/
|
|
207
|
-
export function assertRecordMatchesUserScope(record, context) {
|
|
208
|
-
const userId = cleanString(asDict(record)?.['user_id']);
|
|
209
|
-
const expectedScope = cleanString(context.userScope);
|
|
210
|
-
if (!userId || !expectedScope || expectedScope === 'local')
|
|
211
|
-
return;
|
|
212
|
-
if (userId === expectedScope)
|
|
213
|
-
return;
|
|
214
|
-
throw new Error(`Refusing to save ${context.runtimeLabel} computer credentials for user ${userId} in scope ${expectedScope}.`);
|
|
215
|
-
}
|
|
216
|
-
//# sourceMappingURL=auth-records.js.map
|
|
1
|
+
var h=Object.defineProperty;var i=(t,r)=>h(t,"name",{value:r,configurable:!0});import{normalizeRuntimeLabel as y}from"./labels.js";const c=i(t=>t&&typeof t=="object"?t:null,"asDict");function o(t){return typeof t=="string"&&t.trim()?t.trim():""}i(o,"cleanString");function f(t){return o(t).toLowerCase()}i(f,"normalizeUserEmail");function d(t){const r=c(t);return f(r?.user_email||r?.userEmail||r?.email)}i(d,"userEmailFromRecord");const k=new Set(["tunnel_token","computer_auth_token","proxy_token","proxy_token_expires_in","proxy_token_expires_at","proxy_token_refreshed_at","proxyToken","proxyTokenExpiresAt","hmac_token","hmacToken"]),x=["proxy","proxy_token","proxy_token_expires_in","proxy_token_expires_at","proxy_token_refreshed_at","proxyToken","proxyTokenExpiresAt","hmac_token","hmacToken"];function S(t){const r=c(t);return!!r&&x.some(n=>n in r)}i(S,"hasRetiredProxyAuth");function b(t){const r=c(t);return r?Array.from(k).some(n=>o(r[n])):!1}i(b,"hasComputerSecrets");const R=i(t=>{const r=t.replace(/[\\/]+$/,""),n=Math.max(r.lastIndexOf("/"),r.lastIndexOf("\\"));return n===-1?r:r.slice(n+1)},"baseName");function C(t,r="auth.json"){const n={...c(t)||{},auth_file:R(r)},e=d(n);e&&(n.user_email=e);for(const u of k)delete n[u];return n}i(C,"publicComputerRecord");function A(t,r,n){const e=n.nowIso(),u=c(t),s={schema_version:1,...c(r)||{},updated_at:e};for(const l of x)delete s[l];for(const l of["computer_id","device_id","user_id","user_email","app_url"]){const m=l==="user_email"?d(u):o(u?.[l]);m&&(s[l]=m)}const _=c(s.tunnel),a=o(u?.tunnel_token);a?s.tunnel={..._||{},token:a,url:o(u?.tunnel_url)||o(_?.url),updated_at:e}:u?.tunnel_url&&(s.tunnel={..._||{},url:o(u?.tunnel_url)||o(_?.url)});const p=o(u?.computer_auth_token);return p&&(s.machine={...c(s.machine)||{},token:p,updated_at:e}),s}i(A,"authFromRecord");function I(t,r){const n=c(t);if(!n)return null;const e={...n},u=c(r);if(!u)return e;const s=o(u.computer_id),_=o(n.computer_id);if(s&&_&&s!==_)return e;const a=c(u.tunnel),p=c(u.machine);return e.tunnel_token||(e.tunnel_token=o(a?.token)||o(u.tunnel_token)),e.tunnel_url||(e.tunnel_url=o(a?.url)),e.computer_auth_token||(e.computer_auth_token=o(p?.token)||o(u.computer_auth_token)),e.user_id||(e.user_id=o(u.user_id)),e.user_email||(e.user_email=f(u.user_email)),e.app_url||(e.app_url=o(u.app_url)),e}i(I,"mergeRecordAuth");function w(t,r){const n=c(t),e=y(n?.runtime_label||n?.label||n?.branch);return e?e===r:r==="main"}i(w,"recordMatchesCurrentRuntime");function g(t,r){const n=o(c(t)?.user_id),e=o(r.userScope);if(!(!n||!e||e==="local")&&n!==e)throw new Error(`Refusing to save ${r.runtimeLabel} computer credentials for user ${n} in scope ${e}.`)}i(g,"assertRecordMatchesUserScope");export{k as SECRET_COMPUTER_KEYS,g as assertRecordMatchesUserScope,A as authFromRecord,b as hasComputerSecrets,S as hasRetiredProxyAuth,I as mergeRecordAuth,f as normalizeUserEmail,C as publicComputerRecord,w as recordMatchesCurrentRuntime,d as userEmailFromRecord};
|
|
@@ -25,7 +25,6 @@ export interface CredentialBrokerPorts {
|
|
|
25
25
|
nowMs(): number;
|
|
26
26
|
random(): number;
|
|
27
27
|
}
|
|
28
|
-
/** One in-memory authority for token reuse, renewal, and per-request proofs. */
|
|
29
28
|
export declare class CredentialBroker {
|
|
30
29
|
private readonly ports;
|
|
31
30
|
private readonly cache;
|
|
@@ -44,4 +43,3 @@ export declare class CredentialBrokerError extends Error {
|
|
|
44
43
|
readonly code: string;
|
|
45
44
|
constructor(code: string);
|
|
46
45
|
}
|
|
47
|
-
//# sourceMappingURL=broker.d.ts.map
|
|
@@ -1,117 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { canonicalScopes, } from './policy.js';
|
|
4
|
-
/** One in-memory authority for token reuse, renewal, and per-request proofs. */
|
|
5
|
-
export class CredentialBroker {
|
|
6
|
-
ports;
|
|
7
|
-
cache = new Map();
|
|
8
|
-
inFlight = new Map();
|
|
9
|
-
constructor(ports) {
|
|
10
|
-
this.ports = ports;
|
|
11
|
-
}
|
|
12
|
-
async get(request) {
|
|
13
|
-
const normalized = normalizeRequest(request);
|
|
14
|
-
const key = requestKey(normalized);
|
|
15
|
-
const cached = this.cache.get(key);
|
|
16
|
-
const minimum = Math.max(0, normalized.minValidityMs ?? 0);
|
|
17
|
-
const now = this.ports.nowMs();
|
|
18
|
-
if (cached && cached.credential.expiresAtMs - now > minimum && cached.refreshAtMs > now) {
|
|
19
|
-
return cached.credential;
|
|
20
|
-
}
|
|
21
|
-
const pending = this.inFlight.get(key);
|
|
22
|
-
if (pending)
|
|
23
|
-
return pending;
|
|
24
|
-
const issued = this.issue(key, normalized);
|
|
25
|
-
this.inFlight.set(key, issued);
|
|
26
|
-
try {
|
|
27
|
-
return await issued;
|
|
28
|
-
}
|
|
29
|
-
finally {
|
|
30
|
-
if (this.inFlight.get(key) === issued)
|
|
31
|
-
this.inFlight.delete(key);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async authorize(request) {
|
|
35
|
-
const credential = await this.get(request);
|
|
36
|
-
const method = normalizeDpopMethod(request.method);
|
|
37
|
-
const url = normalizeDpopHtu(request.url);
|
|
38
|
-
const dpop = await this.ports.signer.signProof({
|
|
39
|
-
method,
|
|
40
|
-
url,
|
|
41
|
-
accessToken: credential.accessToken,
|
|
42
|
-
});
|
|
43
|
-
return Object.freeze({
|
|
44
|
-
...credential,
|
|
45
|
-
method,
|
|
46
|
-
url,
|
|
47
|
-
authorization: `DPoP ${credential.accessToken}`,
|
|
48
|
-
dpop,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
invalidate(credential) {
|
|
52
|
-
for (const [key, cached] of this.cache) {
|
|
53
|
-
if (cached.credential.accessToken === credential.accessToken)
|
|
54
|
-
this.cache.delete(key);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
clear() {
|
|
58
|
-
this.cache.clear();
|
|
59
|
-
}
|
|
60
|
-
async issue(key, request) {
|
|
61
|
-
const credential = await this.ports.issuer.issue({
|
|
62
|
-
audience: request.audience,
|
|
63
|
-
scopes: request.scopes,
|
|
64
|
-
keyThumbprint: this.ports.signer.keyThumbprint,
|
|
65
|
-
});
|
|
66
|
-
assertIssuedCredential(request, this.ports.signer.keyThumbprint, credential, this.ports.nowMs());
|
|
67
|
-
const sample = this.ports.random();
|
|
68
|
-
const random = Number.isFinite(sample) ? Math.min(1, Math.max(0, sample)) : 0;
|
|
69
|
-
const refreshAtMs = credential.expiresAtMs
|
|
70
|
-
- ACCESS_TOKEN_REFRESH_EARLY_MS
|
|
71
|
-
- Math.round(random * ACCESS_TOKEN_REFRESH_JITTER_MS);
|
|
72
|
-
this.cache.set(key, { credential, refreshAtMs });
|
|
73
|
-
return credential;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function normalizeRequest(request) {
|
|
77
|
-
if (request.minValidityMs !== undefined
|
|
78
|
-
&& (!Number.isFinite(request.minValidityMs) || request.minValidityMs < 0))
|
|
79
|
-
throw new TypeError('minValidityMs must be a finite non-negative number');
|
|
80
|
-
return Object.freeze({
|
|
81
|
-
audience: request.audience,
|
|
82
|
-
scopes: canonicalScopes(request.audience, request.scopes),
|
|
83
|
-
...(request.minValidityMs === undefined ? {} : { minValidityMs: request.minValidityMs }),
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function requestKey(request) {
|
|
87
|
-
return `${request.audience}\n${request.scopes.join(' ')}`;
|
|
88
|
-
}
|
|
89
|
-
function assertIssuedCredential(request, keyThumbprint, credential, nowMs) {
|
|
90
|
-
if (credential.tokenType !== 'DPoP' || !credential.accessToken) {
|
|
91
|
-
throw new CredentialBrokerError('invalid_credential');
|
|
92
|
-
}
|
|
93
|
-
if (credential.audience !== request.audience) {
|
|
94
|
-
throw new CredentialBrokerError('audience_mismatch');
|
|
95
|
-
}
|
|
96
|
-
if (credential.keyThumbprint !== keyThumbprint) {
|
|
97
|
-
throw new CredentialBrokerError('key_mismatch');
|
|
98
|
-
}
|
|
99
|
-
const expected = request.scopes.join(' ');
|
|
100
|
-
const received = canonicalScopes(credential.audience, credential.scopes).join(' ');
|
|
101
|
-
if (received !== expected)
|
|
102
|
-
throw new CredentialBrokerError('scope_mismatch');
|
|
103
|
-
const minimum = request.minValidityMs ?? 0;
|
|
104
|
-
if (!Number.isFinite(credential.expiresAtMs)
|
|
105
|
-
|| credential.expiresAtMs <= nowMs + minimum) {
|
|
106
|
-
throw new CredentialBrokerError('invalid_expiry');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export class CredentialBrokerError extends Error {
|
|
110
|
-
code;
|
|
111
|
-
constructor(code) {
|
|
112
|
-
super(`Credential broker rejected an issued credential: ${code}`);
|
|
113
|
-
this.name = 'CredentialBrokerError';
|
|
114
|
-
this.code = code;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=broker.js.map
|
|
1
|
+
var p=Object.defineProperty;var c=(i,t)=>p(i,"name",{value:t,configurable:!0});import{ACCESS_TOKEN_REFRESH_EARLY_MS as l,ACCESS_TOKEN_REFRESH_JITTER_MS as u}from"./claims.js";import{normalizeDpopHtu as f,normalizeDpopMethod as M}from"./dpop.js";import{canonicalScopes as m}from"./policy.js";class b{static{c(this,"CredentialBroker")}ports;cache=new Map;inFlight=new Map;constructor(t){this.ports=t}async get(t){const e=y(t),n=w(e),s=this.cache.get(n),o=Math.max(0,e.minValidityMs??0),r=this.ports.nowMs();if(s&&s.credential.expiresAtMs-r>o&&s.refreshAtMs>r)return s.credential;const d=this.inFlight.get(n);if(d)return d;const h=this.issue(n,e);this.inFlight.set(n,h);try{return await h}finally{this.inFlight.get(n)===h&&this.inFlight.delete(n)}}async authorize(t){const e=await this.get(t),n=M(t.method),s=f(t.url),o=await this.ports.signer.signProof({method:n,url:s,accessToken:e.accessToken});return Object.freeze({...e,method:n,url:s,authorization:`DPoP ${e.accessToken}`,dpop:o})}invalidate(t){for(const[e,n]of this.cache)n.credential.accessToken===t.accessToken&&this.cache.delete(e)}clear(){this.cache.clear()}async issue(t,e){const n=await this.ports.issuer.issue({audience:e.audience,scopes:e.scopes,keyThumbprint:this.ports.signer.keyThumbprint});k(e,this.ports.signer.keyThumbprint,n,this.ports.nowMs());const s=this.ports.random(),o=Number.isFinite(s)?Math.min(1,Math.max(0,s)):0,r=n.expiresAtMs-l-Math.round(o*u);return this.cache.set(t,{credential:n,refreshAtMs:r}),n}}function y(i){if(i.minValidityMs!==void 0&&(!Number.isFinite(i.minValidityMs)||i.minValidityMs<0))throw new TypeError("minValidityMs must be a finite non-negative number");return Object.freeze({audience:i.audience,scopes:m(i.audience,i.scopes),...i.minValidityMs===void 0?{}:{minValidityMs:i.minValidityMs}})}c(y,"normalizeRequest");function w(i){return`${i.audience}
|
|
2
|
+
${i.scopes.join(" ")}`}c(w,"requestKey");function k(i,t,e,n){if(e.tokenType!=="DPoP"||!e.accessToken)throw new a("invalid_credential");if(e.audience!==i.audience)throw new a("audience_mismatch");if(e.keyThumbprint!==t)throw new a("key_mismatch");const s=i.scopes.join(" ");if(m(e.audience,e.scopes).join(" ")!==s)throw new a("scope_mismatch");const r=i.minValidityMs??0;if(!Number.isFinite(e.expiresAtMs)||e.expiresAtMs<=n+r)throw new a("invalid_expiry")}c(k,"assertIssuedCredential");class a extends Error{static{c(this,"CredentialBrokerError")}code;constructor(t){super(`Credential broker rejected an issued credential: ${t}`),this.name="CredentialBrokerError",this.code=t}}export{b as CredentialBroker,a as CredentialBrokerError};
|
|
@@ -7,7 +7,6 @@ export declare const DPOP_PROOF_MAX_AGE_SECONDS = 60;
|
|
|
7
7
|
export interface AccessTokenConfirmation {
|
|
8
8
|
readonly jkt: string;
|
|
9
9
|
}
|
|
10
|
-
/** Exact claims carried by a machine-bound Amalgm access token. */
|
|
11
10
|
export interface AccessTokenClaims {
|
|
12
11
|
readonly iss: string;
|
|
13
12
|
readonly aud: AuthorizationAudience;
|
|
@@ -30,4 +29,3 @@ export interface IssuedAccessCredential {
|
|
|
30
29
|
}
|
|
31
30
|
export declare function scopeClaim(scopes: readonly AuthorizationScope[]): string;
|
|
32
31
|
export declare function scopesFromClaim(value: unknown): readonly string[];
|
|
33
|
-
//# sourceMappingURL=claims.d.ts.map
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const ACCESS_TOKEN_CLOCK_SKEW_SECONDS = 30;
|
|
3
|
-
export const ACCESS_TOKEN_REFRESH_EARLY_MS = 2 * 60 * 1000;
|
|
4
|
-
export const ACCESS_TOKEN_REFRESH_JITTER_MS = 30 * 1000;
|
|
5
|
-
export const DPOP_PROOF_MAX_AGE_SECONDS = 60;
|
|
6
|
-
export function scopeClaim(scopes) {
|
|
7
|
-
return [...scopes].sort().join(' ');
|
|
8
|
-
}
|
|
9
|
-
export function scopesFromClaim(value) {
|
|
10
|
-
if (typeof value !== 'string')
|
|
11
|
-
return [];
|
|
12
|
-
return Object.freeze([...new Set(value.split(/\s+/).filter(Boolean))].sort());
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=claims.js.map
|
|
1
|
+
var S=Object.defineProperty;var o=(t,e)=>S(t,"name",{value:e,configurable:!0});const E=900,_=30,n=12e4,C=3e4,s=60;function O(t){return[...t].sort().join(" ")}o(O,"scopeClaim");function p(t){return typeof t!="string"?[]:Object.freeze([...new Set(t.split(/\s+/).filter(Boolean))].sort())}o(p,"scopesFromClaim");export{_ as ACCESS_TOKEN_CLOCK_SKEW_SECONDS,n as ACCESS_TOKEN_REFRESH_EARLY_MS,C as ACCESS_TOKEN_REFRESH_JITTER_MS,E as ACCESS_TOKEN_TTL_SECONDS,s as DPOP_PROOF_MAX_AGE_SECONDS,O as scopeClaim,p as scopesFromClaim};
|
|
@@ -14,13 +14,6 @@ export interface DpopSignerPort {
|
|
|
14
14
|
readonly keyThumbprint: string;
|
|
15
15
|
signProof(input: DpopProofInput): Promise<string>;
|
|
16
16
|
}
|
|
17
|
-
/** RFC 9449 htu excludes query and fragment and uses an absolute URI. */
|
|
18
17
|
export declare function normalizeDpopHtu(value: string): string;
|
|
19
18
|
export declare function normalizeDpopMethod(value: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* Reconstruct the public resource URL behind a reverse proxy without trusting
|
|
22
|
-
* caller-controlled forwarding headers. Deployment config owns the origin;
|
|
23
|
-
* the HTTP request contributes only its origin-form path and query.
|
|
24
|
-
*/
|
|
25
19
|
export declare function publicResourceRequestUrl(publicOrigin: string, requestTarget: string): string;
|
|
26
|
-
//# sourceMappingURL=dpop.d.ts.map
|
|
@@ -1,39 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export function normalizeDpopHtu(value) {
|
|
3
|
-
const url = new URL(value);
|
|
4
|
-
if (!['http:', 'https:'].includes(url.protocol)) {
|
|
5
|
-
throw new TypeError('DPoP target must be an HTTP URL');
|
|
6
|
-
}
|
|
7
|
-
url.username = '';
|
|
8
|
-
url.password = '';
|
|
9
|
-
url.search = '';
|
|
10
|
-
url.hash = '';
|
|
11
|
-
return url.toString();
|
|
12
|
-
}
|
|
13
|
-
export function normalizeDpopMethod(value) {
|
|
14
|
-
const method = value.trim().toUpperCase();
|
|
15
|
-
if (!/^[A-Z]+$/.test(method))
|
|
16
|
-
throw new TypeError('DPoP method is invalid');
|
|
17
|
-
return method;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Reconstruct the public resource URL behind a reverse proxy without trusting
|
|
21
|
-
* caller-controlled forwarding headers. Deployment config owns the origin;
|
|
22
|
-
* the HTTP request contributes only its origin-form path and query.
|
|
23
|
-
*/
|
|
24
|
-
export function publicResourceRequestUrl(publicOrigin, requestTarget) {
|
|
25
|
-
const origin = new URL(publicOrigin);
|
|
26
|
-
const loopback = origin.hostname === 'localhost' || origin.hostname === '127.0.0.1';
|
|
27
|
-
if ((origin.protocol !== 'https:' && !(loopback && origin.protocol === 'http:'))
|
|
28
|
-
|| origin.username
|
|
29
|
-
|| origin.password
|
|
30
|
-
|| origin.pathname !== '/'
|
|
31
|
-
|| origin.search
|
|
32
|
-
|| origin.hash)
|
|
33
|
-
throw new TypeError('Public resource origin must be an HTTPS origin');
|
|
34
|
-
if (!requestTarget.startsWith('/') || requestTarget.startsWith('//')) {
|
|
35
|
-
throw new TypeError('Resource request target must use origin form');
|
|
36
|
-
}
|
|
37
|
-
return new URL(requestTarget, origin).toString();
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=dpop.js.map
|
|
1
|
+
var s=Object.defineProperty;var e=(r,o)=>s(r,"name",{value:o,configurable:!0});function p(r){const o=new URL(r);if(!["http:","https:"].includes(o.protocol))throw new TypeError("DPoP target must be an HTTP URL");return o.username="",o.password="",o.search="",o.hash="",o.toString()}e(p,"normalizeDpopHtu");function h(r){const o=r.trim().toUpperCase();if(!/^[A-Z]+$/.test(o))throw new TypeError("DPoP method is invalid");return o}e(h,"normalizeDpopMethod");function a(r,o){const t=new URL(r),n=t.hostname==="localhost"||t.hostname==="127.0.0.1";if(t.protocol!=="https:"&&!(n&&t.protocol==="http:")||t.username||t.password||t.pathname!=="/"||t.search||t.hash)throw new TypeError("Public resource origin must be an HTTPS origin");if(!o.startsWith("/")||o.startsWith("//"))throw new TypeError("Resource request target must use origin form");return new URL(o,t).toString()}e(a,"publicResourceRequestUrl");export{p as normalizeDpopHtu,h as normalizeDpopMethod,a as publicResourceRequestUrl};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './claims.js';
|
|
3
|
-
export * from './dpop.js';
|
|
4
|
-
export * from './broker.js';
|
|
5
|
-
export * from './resource.js';
|
|
6
|
-
export * from './key-transition.js';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export*from"./policy.js";export*from"./claims.js";export*from"./dpop.js";export*from"./broker.js";export*from"./resource.js";export*from"./key-transition.js";
|
|
@@ -8,7 +8,6 @@ export interface AuthorizationKeyTransitionInput {
|
|
|
8
8
|
readonly expectedKeyThumbprint: string;
|
|
9
9
|
}>;
|
|
10
10
|
}
|
|
11
|
-
/** One closed rule for initial pinning, ordinary reuse, and explicit recovery. */
|
|
12
11
|
export declare function authorizationKeyTransition(input: AuthorizationKeyTransitionInput): AuthorizationKeyTransition;
|
|
13
12
|
export declare function isAuthorizationKeyThumbprint(value: unknown): value is string;
|
|
14
13
|
export type AuthorizationKeyTransitionErrorCode = 'invalid_key_thumbprint' | 'invalid_recovery_purpose' | 'recovery_key_unchanged' | 'recovery_basis_mismatch' | 'key_mismatch';
|
|
@@ -16,4 +15,3 @@ export declare class AuthorizationKeyTransitionError extends Error {
|
|
|
16
15
|
readonly code: AuthorizationKeyTransitionErrorCode;
|
|
17
16
|
constructor(code: AuthorizationKeyTransitionErrorCode);
|
|
18
17
|
}
|
|
19
|
-
//# sourceMappingURL=key-transition.d.ts.map
|