@astram/core 1.2.0 → 1.3.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.
- package/dist/authentication/index.d.ts +1 -0
- package/dist/authentication/index.d.ts.map +1 -1
- package/dist/authentication/index.js +2 -0
- package/dist/authentication/index.js.map +1 -1
- package/dist/authentication/service-account-authenticator.d.ts +82 -0
- package/dist/authentication/service-account-authenticator.d.ts.map +1 -0
- package/dist/authentication/service-account-authenticator.js +74 -0
- package/dist/authentication/service-account-authenticator.js.map +1 -0
- package/dist/encryption/encryption-service.d.ts +63 -0
- package/dist/encryption/encryption-service.d.ts.map +1 -0
- package/dist/encryption/encryption-service.js +184 -0
- package/dist/encryption/encryption-service.js.map +1 -0
- package/dist/encryption/index.d.ts +17 -0
- package/dist/encryption/index.d.ts.map +1 -0
- package/dist/encryption/index.js +15 -0
- package/dist/encryption/index.js.map +1 -0
- package/dist/encryption/ports.d.ts +84 -0
- package/dist/encryption/ports.d.ts.map +1 -0
- package/dist/encryption/ports.js +18 -0
- package/dist/encryption/ports.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/secrets/index.d.ts +15 -0
- package/dist/secrets/index.d.ts.map +1 -0
- package/dist/secrets/index.js +14 -0
- package/dist/secrets/index.js.map +1 -0
- package/dist/secrets/ports.d.ts +45 -0
- package/dist/secrets/ports.d.ts.map +1 -0
- package/dist/secrets/ports.js +26 -0
- package/dist/secrets/ports.js.map +1 -0
- package/dist/secrets/resolve.d.ts +29 -0
- package/dist/secrets/resolve.d.ts.map +1 -0
- package/dist/secrets/resolve.js +49 -0
- package/dist/secrets/resolve.js.map +1 -0
- package/dist-cjs/authentication/index.js +2 -0
- package/dist-cjs/authentication/service-account-authenticator.js +78 -0
- package/dist-cjs/encryption/encryption-service.js +189 -0
- package/dist-cjs/encryption/index.js +20 -0
- package/dist-cjs/encryption/ports.js +18 -0
- package/dist-cjs/index.js +2 -0
- package/dist-cjs/secrets/index.js +21 -0
- package/dist-cjs/secrets/ports.js +29 -0
- package/dist-cjs/secrets/resolve.js +54 -0
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SECRET_REF_PREFIX = void 0;
|
|
4
|
+
exports.isSecretRef = isSecretRef;
|
|
5
|
+
exports.secretRefPath = secretRefPath;
|
|
6
|
+
exports.resolveSecretRefs = resolveSecretRefs;
|
|
7
|
+
/** The prefix that marks an env value as a secret REFERENCE (a pointer, safe to log/commit). */
|
|
8
|
+
exports.SECRET_REF_PREFIX = 'secret-ref:';
|
|
9
|
+
/** True if `value` is a secret reference (not a literal). */
|
|
10
|
+
function isSecretRef(value) {
|
|
11
|
+
return typeof value === 'string' && value.startsWith(exports.SECRET_REF_PREFIX);
|
|
12
|
+
}
|
|
13
|
+
/** Extract the secret path from a reference (`secret-ref:db/prod/pw` → `db/prod/pw`). */
|
|
14
|
+
function secretRefPath(ref) {
|
|
15
|
+
return ref.slice(exports.SECRET_REF_PREFIX.length);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve every `secret-ref:` value in `env` via `provider`, returning a NEW bag where references
|
|
19
|
+
* are replaced by their real values and literals are copied unchanged. Async (a fetch is I/O).
|
|
20
|
+
*
|
|
21
|
+
* Fail-closed: a reference with an EMPTY path, or one the provider cannot resolve, THROWS — the
|
|
22
|
+
* error names the ENV KEY + PATH (safe pointers), never the value. Non-string values are copied
|
|
23
|
+
* as-is. The input bag is not mutated.
|
|
24
|
+
*/
|
|
25
|
+
async function resolveSecretRefs(env, provider) {
|
|
26
|
+
const out = {};
|
|
27
|
+
// Resolve sequentially-collected refs; a single failure aborts the whole resolution (fail-closed).
|
|
28
|
+
const refs = [];
|
|
29
|
+
for (const [key, value] of Object.entries(env)) {
|
|
30
|
+
if (isSecretRef(value)) {
|
|
31
|
+
const path = secretRefPath(value);
|
|
32
|
+
if (path.trim() === '') {
|
|
33
|
+
throw new Error(`invalid secret reference for env '${key}': empty path`);
|
|
34
|
+
}
|
|
35
|
+
refs.push({ key, path });
|
|
36
|
+
out[key] = undefined; // placeholder; filled below
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
out[key] = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const { key, path } of refs) {
|
|
43
|
+
let resolved;
|
|
44
|
+
try {
|
|
45
|
+
resolved = await provider.resolve(path);
|
|
46
|
+
}
|
|
47
|
+
catch (cause) {
|
|
48
|
+
// Include the key + path (safe pointers), NEVER a value.
|
|
49
|
+
throw new Error(`could not resolve secret for env '${key}' (path '${path}')`, { cause });
|
|
50
|
+
}
|
|
51
|
+
out[key] = resolved;
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Astram framework — sealed security core (Identity, Authentication, Session, Risk, Authorization, Audit). ZERO framework deps — the portable decision brain (ADR-0003). The frozen public contract consumers build against; installed, not edited (ADR-0023).",
|
|
6
6
|
"type": "module",
|