@forgezero/vault 0.1.7 → 0.1.9
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/config.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/providers.d.ts +17 -11
- package/dist/providers.js +16 -11
- package/dist/schema.js +1 -1
- package/package.json +6 -6
package/dist/config.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* A YAML parser is a third-party dependency, and this package claims to have
|
|
12
12
|
* none — it ends up inside a tenant's production application, where every edge
|
|
13
13
|
* in its dependency graph is one they did not choose. JSON is in the runtime.
|
|
14
|
-
* (`.fz/deploy.
|
|
14
|
+
* (`.fz/deploy.json` is a different file read by a different tool on our side of
|
|
15
15
|
* the wire, where the dependency is ours to carry.)
|
|
16
16
|
*
|
|
17
17
|
* ## What is deliberately NOT in here
|
package/dist/index.d.ts
CHANGED
|
@@ -282,4 +282,4 @@ export declare function systemdCredentials(options?: SystemdCredentialOptions):
|
|
|
282
282
|
readonly name: 'systemd';
|
|
283
283
|
get(reference: string, field: string): Promise<string>;
|
|
284
284
|
};
|
|
285
|
-
export declare const VERSION = "0.1.
|
|
285
|
+
export declare const VERSION = "0.1.9";
|
package/dist/index.js
CHANGED
package/dist/providers.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { ForgeZero } from './index';
|
|
2
|
-
/** Mirrors
|
|
3
|
-
export interface
|
|
2
|
+
/** Mirrors a provider identity in `@forgezero/providers`, matched structurally. */
|
|
3
|
+
export interface StoredProviderInstance {
|
|
4
|
+
instanceKey: string;
|
|
4
5
|
providerId: string;
|
|
5
|
-
/** Names one instance when a provider is configured more than once. */
|
|
6
|
-
instanceKey?: string;
|
|
7
|
-
/** 1 is tried first. */
|
|
8
|
-
priority: number;
|
|
9
6
|
enabled: boolean;
|
|
10
7
|
config: Record<string, unknown>;
|
|
11
|
-
/** Names the vault entry holding the secret. Never the secret. */
|
|
12
8
|
secretRef: string;
|
|
9
|
+
}
|
|
10
|
+
/** Mirrors one service-method attachment in `@forgezero/providers`. */
|
|
11
|
+
export interface StoredServiceMethodAttachment {
|
|
12
|
+
instanceKey: string;
|
|
13
|
+
providerMethod: string;
|
|
14
|
+
priority: number;
|
|
15
|
+
enabled: boolean;
|
|
13
16
|
health?: {
|
|
14
17
|
strikes: number;
|
|
15
18
|
status: 'ok' | 'degraded' | 'offline';
|
|
@@ -18,12 +21,14 @@ export interface StoredProvider {
|
|
|
18
21
|
}
|
|
19
22
|
export interface VaultConfigOptions {
|
|
20
23
|
/**
|
|
21
|
-
* Entry
|
|
24
|
+
* Entry containing provider identities, independent of services.
|
|
22
25
|
*
|
|
23
26
|
* Overridable because a tenant already using `providers.*` for something else
|
|
24
27
|
* should not have to rename it to adopt this.
|
|
25
28
|
*/
|
|
26
|
-
|
|
29
|
+
providersEntry?: string;
|
|
30
|
+
/** Entry containing one service method's ordered attachments. */
|
|
31
|
+
serviceEntryFor?: (serviceKey: string, methodKey: string) => string;
|
|
27
32
|
/**
|
|
28
33
|
* Persist health back to the vault.
|
|
29
34
|
*
|
|
@@ -50,8 +55,9 @@ export interface VaultConfigOptions {
|
|
|
50
55
|
*/
|
|
51
56
|
export declare function vaultConfig(vault: ForgeZero, options?: VaultConfigOptions): {
|
|
52
57
|
name: string;
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
provider(instanceKey: string): Promise<StoredProviderInstance | undefined>;
|
|
59
|
+
list(serviceKey: string, methodKey: string): Promise<readonly StoredServiceMethodAttachment[]>;
|
|
60
|
+
recordHealth(serviceKey: string, methodKey: string, instanceKey: string, providerMethod: string, health: NonNullable<StoredServiceMethodAttachment["health"]>): Promise<void>;
|
|
55
61
|
};
|
|
56
62
|
/**
|
|
57
63
|
* Credentials out of the vault, by the reference a provider config names.
|
package/dist/providers.js
CHANGED
|
@@ -382,14 +382,14 @@ function systemdCredentials(options = {}) {
|
|
|
382
382
|
}
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
var VERSION = "0.1.
|
|
385
|
+
var VERSION = "0.1.9";
|
|
386
386
|
|
|
387
387
|
// src/providers.ts
|
|
388
388
|
var MISSING = new Set(["ENTRY_NOT_FOUND", "VERSION_NOT_FOUND"]);
|
|
389
389
|
function vaultConfig(vault, options = {}) {
|
|
390
|
-
const
|
|
391
|
-
const
|
|
392
|
-
|
|
390
|
+
const providersEntry = options.providersEntry ?? "providers.instances";
|
|
391
|
+
const serviceEntryFor = options.serviceEntryFor ?? ((serviceKey, methodKey) => `services.${serviceKey}.${methodKey}`);
|
|
392
|
+
const readArray = async (name) => {
|
|
393
393
|
let raw;
|
|
394
394
|
try {
|
|
395
395
|
raw = await vault.get(name);
|
|
@@ -405,21 +405,26 @@ function vaultConfig(vault, options = {}) {
|
|
|
405
405
|
throw new VaultError("INVALID", `Vault entry "${name}" is not valid JSON.`);
|
|
406
406
|
}
|
|
407
407
|
if (!Array.isArray(parsed)) {
|
|
408
|
-
throw new VaultError("INVALID", `Vault entry "${name}" must be an array
|
|
408
|
+
throw new VaultError("INVALID", `Vault entry "${name}" must be an array.`);
|
|
409
409
|
}
|
|
410
410
|
return parsed;
|
|
411
411
|
};
|
|
412
412
|
return {
|
|
413
413
|
name: "vault",
|
|
414
|
-
async
|
|
415
|
-
|
|
414
|
+
async provider(instanceKey) {
|
|
415
|
+
const instances = await readArray(providersEntry);
|
|
416
|
+
return instances.find((instance) => instance.instanceKey === instanceKey);
|
|
416
417
|
},
|
|
417
|
-
async
|
|
418
|
+
async list(serviceKey, methodKey) {
|
|
419
|
+
return (await readArray(serviceEntryFor(serviceKey, methodKey))).slice().sort((a, b) => a.priority - b.priority);
|
|
420
|
+
},
|
|
421
|
+
async recordHealth(serviceKey, methodKey, instanceKey, providerMethod, health) {
|
|
418
422
|
if (!options.persistHealth)
|
|
419
423
|
return;
|
|
420
|
-
const
|
|
421
|
-
const
|
|
422
|
-
|
|
424
|
+
const entry = serviceEntryFor(serviceKey, methodKey);
|
|
425
|
+
const attachments = await readArray(entry);
|
|
426
|
+
const next = attachments.map((attachment) => attachment.instanceKey === instanceKey && attachment.providerMethod === providerMethod ? { ...attachment, health } : attachment);
|
|
427
|
+
await vault.set(entry, JSON.stringify(next));
|
|
423
428
|
}
|
|
424
429
|
};
|
|
425
430
|
}
|
package/dist/schema.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"//": "Publishing happens from an operator's machine, not CI \u2014 CLAUDE.md records that the absence of CI is deliberate. npm's `provenance` attests a tarball was built by a recognised CI provider from a named commit, so it cannot be produced here: it was set, and the first publish failed with `Automatic provenance generation not supported for provider: null`. A setting that can never be satisfied is worse than none, because it reads as a guarantee nobody is getting. Restore it the day this publishes from CI, and not before.",
|
|
3
2
|
"name": "@forgezero/vault",
|
|
4
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
5
4
|
"type": "module",
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public",
|
|
7
|
+
"provenance": true
|
|
8
8
|
},
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@types/bun": "latest"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
|
|
46
|
+
"@forgezero/runtime": "^0.1.6"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@noble/curves": "^2.2.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"repository": {
|
|
69
69
|
"type": "git",
|
|
70
70
|
"url": "git+https://github.com/forgezero-net/packages.git",
|
|
71
|
-
"directory": "
|
|
71
|
+
"directory": "vault"
|
|
72
72
|
},
|
|
73
73
|
"bugs": "https://github.com/forgezero-net/packages/issues",
|
|
74
74
|
"sideEffects": false,
|