@forgezero/vault 0.1.6 → 0.1.7
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/index.d.ts +9 -1
- package/dist/index.js +19 -3
- package/dist/providers.js +18 -3
- package/dist/schema.js +18 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,14 @@ export type AgentResponse = {
|
|
|
110
110
|
};
|
|
111
111
|
};
|
|
112
112
|
export type AgentTransport = (socketPath: string, request: AgentRequest) => Promise<AgentResponse>;
|
|
113
|
+
/**
|
|
114
|
+
* Systemd retains the listening socket during a supervised Agent replacement.
|
|
115
|
+
* A connection already accepted by the old process can still reset at the exact
|
|
116
|
+
* handover boundary, so bounded retry makes idempotent local reads continuous
|
|
117
|
+
* without hiding a genuinely unavailable Agent for more than a fraction of a
|
|
118
|
+
* second.
|
|
119
|
+
*/
|
|
120
|
+
export declare const managedAgentTransport: AgentTransport;
|
|
113
121
|
export interface VaultOptions {
|
|
114
122
|
/** Stable public API origin. Node topology is never exposed to the client. */
|
|
115
123
|
apiUrl?: string;
|
|
@@ -274,4 +282,4 @@ export declare function systemdCredentials(options?: SystemdCredentialOptions):
|
|
|
274
282
|
readonly name: 'systemd';
|
|
275
283
|
get(reference: string, field: string): Promise<string>;
|
|
276
284
|
};
|
|
277
|
-
export declare const VERSION = "0.1.
|
|
285
|
+
export declare const VERSION = "0.1.7";
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ function signerFromApiKey(secret) {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
var
|
|
74
|
+
var requestAgentOnce = (socketPath, request) => new Promise((resolveRequest, reject) => {
|
|
75
75
|
if (typeof process === "undefined" || typeof process.getBuiltinModule !== "function") {
|
|
76
76
|
reject(new VaultError("MANAGED_RUNTIME_UNAVAILABLE", "The managed agent socket needs a Node or Bun server runtime."));
|
|
77
77
|
return;
|
|
@@ -102,8 +102,23 @@ var requestAgent = (socketPath, request) => new Promise((resolveRequest, reject)
|
|
|
102
102
|
reject(new VaultError("AGENT_RESPONSE_MALFORMED", "The local ForgeZero agent response was malformed."));
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
+
socket.on("end", () => reject(new VaultError("AGENT_UNAVAILABLE", "The local ForgeZero agent closed during a supervised handover.")));
|
|
105
106
|
socket.on("error", (cause) => reject(new VaultError("AGENT_UNAVAILABLE", cause.message)));
|
|
106
107
|
});
|
|
108
|
+
var managedAgentTransport = async (socketPath, request) => {
|
|
109
|
+
let last;
|
|
110
|
+
for (let attempt = 0;attempt < 5; attempt += 1) {
|
|
111
|
+
try {
|
|
112
|
+
return await requestAgentOnce(socketPath, request);
|
|
113
|
+
} catch (cause) {
|
|
114
|
+
last = cause;
|
|
115
|
+
if (cause?.code !== "AGENT_UNAVAILABLE" || attempt === 4)
|
|
116
|
+
throw cause;
|
|
117
|
+
await new Promise((resolve) => setTimeout(resolve, 25 * 2 ** attempt));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
throw last;
|
|
121
|
+
};
|
|
107
122
|
var DEFAULT_API_URL = "https://api.forgezero.net";
|
|
108
123
|
var DEFAULT_REQUEST_TIMEOUT_MS = 15000;
|
|
109
124
|
function apiOrigin(value) {
|
|
@@ -134,7 +149,7 @@ class ForgeZero {
|
|
|
134
149
|
this.apiUrl = apiOrigin(options.apiUrl ?? DEFAULT_API_URL);
|
|
135
150
|
this.doFetch = options.fetch ?? globalThis.fetch;
|
|
136
151
|
this.signer = options.signer ?? (this.credential.mode === "external" ? signerFromApiKey(this.credential.apiKey) : undefined);
|
|
137
|
-
this.agentTransport = options.agentTransport ??
|
|
152
|
+
this.agentTransport = options.agentTransport ?? managedAgentTransport;
|
|
138
153
|
this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
139
154
|
if (!Number.isFinite(this.requestTimeoutMs) || this.requestTimeoutMs < 100 || this.requestTimeoutMs > 120000) {
|
|
140
155
|
throw new VaultError("INVALID_TIMEOUT", "requestTimeoutMs must be between 100 and 120000 milliseconds.");
|
|
@@ -367,11 +382,12 @@ function systemdCredentials(options = {}) {
|
|
|
367
382
|
}
|
|
368
383
|
};
|
|
369
384
|
}
|
|
370
|
-
var VERSION = "0.1.
|
|
385
|
+
var VERSION = "0.1.7";
|
|
371
386
|
export {
|
|
372
387
|
vaultCredentials,
|
|
373
388
|
systemdCredentials,
|
|
374
389
|
signerFromApiKey,
|
|
390
|
+
managedAgentTransport,
|
|
375
391
|
discover,
|
|
376
392
|
directCredentials,
|
|
377
393
|
createVault,
|
package/dist/providers.js
CHANGED
|
@@ -71,7 +71,7 @@ function signerFromApiKey(secret) {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
var
|
|
74
|
+
var requestAgentOnce = (socketPath, request) => new Promise((resolveRequest, reject) => {
|
|
75
75
|
if (typeof process === "undefined" || typeof process.getBuiltinModule !== "function") {
|
|
76
76
|
reject(new VaultError("MANAGED_RUNTIME_UNAVAILABLE", "The managed agent socket needs a Node or Bun server runtime."));
|
|
77
77
|
return;
|
|
@@ -102,8 +102,23 @@ var requestAgent = (socketPath, request) => new Promise((resolveRequest, reject)
|
|
|
102
102
|
reject(new VaultError("AGENT_RESPONSE_MALFORMED", "The local ForgeZero agent response was malformed."));
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
+
socket.on("end", () => reject(new VaultError("AGENT_UNAVAILABLE", "The local ForgeZero agent closed during a supervised handover.")));
|
|
105
106
|
socket.on("error", (cause) => reject(new VaultError("AGENT_UNAVAILABLE", cause.message)));
|
|
106
107
|
});
|
|
108
|
+
var managedAgentTransport = async (socketPath, request) => {
|
|
109
|
+
let last;
|
|
110
|
+
for (let attempt = 0;attempt < 5; attempt += 1) {
|
|
111
|
+
try {
|
|
112
|
+
return await requestAgentOnce(socketPath, request);
|
|
113
|
+
} catch (cause) {
|
|
114
|
+
last = cause;
|
|
115
|
+
if (cause?.code !== "AGENT_UNAVAILABLE" || attempt === 4)
|
|
116
|
+
throw cause;
|
|
117
|
+
await new Promise((resolve) => setTimeout(resolve, 25 * 2 ** attempt));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
throw last;
|
|
121
|
+
};
|
|
107
122
|
var DEFAULT_API_URL = "https://api.forgezero.net";
|
|
108
123
|
var DEFAULT_REQUEST_TIMEOUT_MS = 15000;
|
|
109
124
|
function apiOrigin(value) {
|
|
@@ -134,7 +149,7 @@ class ForgeZero {
|
|
|
134
149
|
this.apiUrl = apiOrigin(options.apiUrl ?? DEFAULT_API_URL);
|
|
135
150
|
this.doFetch = options.fetch ?? globalThis.fetch;
|
|
136
151
|
this.signer = options.signer ?? (this.credential.mode === "external" ? signerFromApiKey(this.credential.apiKey) : undefined);
|
|
137
|
-
this.agentTransport = options.agentTransport ??
|
|
152
|
+
this.agentTransport = options.agentTransport ?? managedAgentTransport;
|
|
138
153
|
this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
139
154
|
if (!Number.isFinite(this.requestTimeoutMs) || this.requestTimeoutMs < 100 || this.requestTimeoutMs > 120000) {
|
|
140
155
|
throw new VaultError("INVALID_TIMEOUT", "requestTimeoutMs must be between 100 and 120000 milliseconds.");
|
|
@@ -367,7 +382,7 @@ function systemdCredentials(options = {}) {
|
|
|
367
382
|
}
|
|
368
383
|
};
|
|
369
384
|
}
|
|
370
|
-
var VERSION = "0.1.
|
|
385
|
+
var VERSION = "0.1.7";
|
|
371
386
|
|
|
372
387
|
// src/providers.ts
|
|
373
388
|
var MISSING = new Set(["ENTRY_NOT_FOUND", "VERSION_NOT_FOUND"]);
|
package/dist/schema.js
CHANGED
|
@@ -71,7 +71,7 @@ function signerFromApiKey(secret) {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
var
|
|
74
|
+
var requestAgentOnce = (socketPath, request) => new Promise((resolveRequest, reject) => {
|
|
75
75
|
if (typeof process === "undefined" || typeof process.getBuiltinModule !== "function") {
|
|
76
76
|
reject(new VaultError("MANAGED_RUNTIME_UNAVAILABLE", "The managed agent socket needs a Node or Bun server runtime."));
|
|
77
77
|
return;
|
|
@@ -102,8 +102,23 @@ var requestAgent = (socketPath, request) => new Promise((resolveRequest, reject)
|
|
|
102
102
|
reject(new VaultError("AGENT_RESPONSE_MALFORMED", "The local ForgeZero agent response was malformed."));
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
+
socket.on("end", () => reject(new VaultError("AGENT_UNAVAILABLE", "The local ForgeZero agent closed during a supervised handover.")));
|
|
105
106
|
socket.on("error", (cause) => reject(new VaultError("AGENT_UNAVAILABLE", cause.message)));
|
|
106
107
|
});
|
|
108
|
+
var managedAgentTransport = async (socketPath, request) => {
|
|
109
|
+
let last;
|
|
110
|
+
for (let attempt = 0;attempt < 5; attempt += 1) {
|
|
111
|
+
try {
|
|
112
|
+
return await requestAgentOnce(socketPath, request);
|
|
113
|
+
} catch (cause) {
|
|
114
|
+
last = cause;
|
|
115
|
+
if (cause?.code !== "AGENT_UNAVAILABLE" || attempt === 4)
|
|
116
|
+
throw cause;
|
|
117
|
+
await new Promise((resolve) => setTimeout(resolve, 25 * 2 ** attempt));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
throw last;
|
|
121
|
+
};
|
|
107
122
|
var DEFAULT_API_URL = "https://api.forgezero.net";
|
|
108
123
|
var DEFAULT_REQUEST_TIMEOUT_MS = 15000;
|
|
109
124
|
function apiOrigin(value) {
|
|
@@ -134,7 +149,7 @@ class ForgeZero {
|
|
|
134
149
|
this.apiUrl = apiOrigin(options.apiUrl ?? DEFAULT_API_URL);
|
|
135
150
|
this.doFetch = options.fetch ?? globalThis.fetch;
|
|
136
151
|
this.signer = options.signer ?? (this.credential.mode === "external" ? signerFromApiKey(this.credential.apiKey) : undefined);
|
|
137
|
-
this.agentTransport = options.agentTransport ??
|
|
152
|
+
this.agentTransport = options.agentTransport ?? managedAgentTransport;
|
|
138
153
|
this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
139
154
|
if (!Number.isFinite(this.requestTimeoutMs) || this.requestTimeoutMs < 100 || this.requestTimeoutMs > 120000) {
|
|
140
155
|
throw new VaultError("INVALID_TIMEOUT", "requestTimeoutMs must be between 100 and 120000 milliseconds.");
|
|
@@ -367,7 +382,7 @@ function systemdCredentials(options = {}) {
|
|
|
367
382
|
}
|
|
368
383
|
};
|
|
369
384
|
}
|
|
370
|
-
var VERSION = "0.1.
|
|
385
|
+
var VERSION = "0.1.7";
|
|
371
386
|
|
|
372
387
|
// src/schema.ts
|
|
373
388
|
function managedSchemas(vault, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
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
3
|
"name": "@forgezero/vault",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|