@absolutejs/secrets 0.7.0 → 0.7.2
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/README.md +53 -41
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +264 -0
- package/dist/agent.js.map +12 -0
- package/dist/broker.d.ts +340 -0
- package/dist/broker.js +825 -0
- package/dist/broker.js.map +11 -0
- package/dist/index.d.ts +2 -342
- package/dist/index.js +86 -60
- package/dist/index.js.map +7 -7
- package/dist/manifest.d.ts +1 -1
- package/dist/manifest.js +2 -4
- package/dist/manifest.js.map +3 -3
- package/dist/operations.d.ts +1 -1
- package/dist/postgres.d.ts +1 -1
- package/package.json +13 -3
package/dist/index.js
CHANGED
|
@@ -15,59 +15,6 @@ var __export = (target, all) => {
|
|
|
15
15
|
};
|
|
16
16
|
var __require = import.meta.require;
|
|
17
17
|
|
|
18
|
-
// node_modules/@absolutejs/telemetry/dist/index.js
|
|
19
|
-
var NOOP_SPAN_CONTEXT = {
|
|
20
|
-
spanId: "0000000000000000",
|
|
21
|
-
traceFlags: 0,
|
|
22
|
-
traceId: "00000000000000000000000000000000"
|
|
23
|
-
};
|
|
24
|
-
var noopSpan = {
|
|
25
|
-
addEvent: () => noopSpan,
|
|
26
|
-
end: () => {},
|
|
27
|
-
isRecording: () => false,
|
|
28
|
-
recordException: () => {},
|
|
29
|
-
setAttribute: () => noopSpan,
|
|
30
|
-
setAttributes: () => noopSpan,
|
|
31
|
-
setStatus: () => noopSpan,
|
|
32
|
-
spanContext: () => NOOP_SPAN_CONTEXT,
|
|
33
|
-
updateName: () => noopSpan
|
|
34
|
-
};
|
|
35
|
-
var startActiveSpanNoop = (_name, optionsOrFn, maybeFn) => {
|
|
36
|
-
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
37
|
-
return fn(noopSpan);
|
|
38
|
-
};
|
|
39
|
-
var noopTracer = {
|
|
40
|
-
startActiveSpan: startActiveSpanNoop,
|
|
41
|
-
startSpan: () => noopSpan
|
|
42
|
-
};
|
|
43
|
-
var tracerOrNoop = (provider, name, version) => provider !== undefined ? provider.getTracer(name, version) : noopTracer;
|
|
44
|
-
var ABS_ATTRS = {
|
|
45
|
-
tenant: "abs.tenant",
|
|
46
|
-
shardId: "abs.shard.id",
|
|
47
|
-
engineId: "abs.engine.id",
|
|
48
|
-
collection: "abs.collection",
|
|
49
|
-
mutation: "abs.mutation",
|
|
50
|
-
mutationAttempt: "abs.mutation.attempt",
|
|
51
|
-
subscriptionId: "abs.subscription.id",
|
|
52
|
-
batchSize: "abs.batch.size",
|
|
53
|
-
clusterMessageOrigin: "abs.cluster.origin",
|
|
54
|
-
jobId: "abs.job.id",
|
|
55
|
-
jobKind: "abs.job.kind",
|
|
56
|
-
jobAttempt: "abs.job.attempt",
|
|
57
|
-
jobMaxAttempts: "abs.job.max_attempts",
|
|
58
|
-
workerId: "abs.worker.id",
|
|
59
|
-
runtimeKey: "abs.runtime.key",
|
|
60
|
-
runtimePid: "abs.runtime.pid",
|
|
61
|
-
runtimePort: "abs.runtime.port",
|
|
62
|
-
runtimeExitReason: "abs.runtime.exit_reason",
|
|
63
|
-
runtimeReadinessMs: "abs.runtime.readiness_ms",
|
|
64
|
-
routeShard: "abs.route.shard",
|
|
65
|
-
routeDecision: "abs.route.decision",
|
|
66
|
-
secretName: "abs.secret.name",
|
|
67
|
-
secretFingerprint: "abs.secret.fingerprint",
|
|
68
|
-
auditKind: "abs.audit.kind"
|
|
69
|
-
};
|
|
70
|
-
|
|
71
18
|
// node_modules/@absolutejs/agency/dist/index.js
|
|
72
19
|
var normalize = (value) => {
|
|
73
20
|
if (Array.isArray(value))
|
|
@@ -274,7 +221,10 @@ CREATE TABLE IF NOT EXISTS ${ns}.pending_operations (
|
|
|
274
221
|
created_at timestamptz NOT NULL DEFAULT now(), data jsonb NOT NULL
|
|
275
222
|
);`;
|
|
276
223
|
};
|
|
277
|
-
var createPostgresCredentialGrantStore = ({
|
|
224
|
+
var createPostgresCredentialGrantStore = ({
|
|
225
|
+
client,
|
|
226
|
+
namespace = "secrets"
|
|
227
|
+
}) => {
|
|
278
228
|
const ns = namespaceOf(namespace);
|
|
279
229
|
return {
|
|
280
230
|
consume: async (grantId, now) => {
|
|
@@ -286,7 +236,16 @@ var createPostgresCredentialGrantStore = ({ client, namespace = "secrets" }) =>
|
|
|
286
236
|
put: async (grant) => {
|
|
287
237
|
if (grant.maximumUses < 1 || grant.used < 0 || grant.used > grant.maximumUses)
|
|
288
238
|
throw new Error("Invalid credential grant usage");
|
|
289
|
-
await client.query(`INSERT INTO ${ns}.credential_grants (grant_id, agent_id, user_id, provider, expires_at, maximum_uses, used, data) VALUES ($1,$2,$3,$4,$5,$6,$7,$8::jsonb) ON CONFLICT (grant_id) DO UPDATE SET expires_at=EXCLUDED.expires_at, maximum_uses=EXCLUDED.maximum_uses, used=EXCLUDED.used, data=EXCLUDED.data`, [
|
|
239
|
+
await client.query(`INSERT INTO ${ns}.credential_grants (grant_id, agent_id, user_id, provider, expires_at, maximum_uses, used, data) VALUES ($1,$2,$3,$4,$5,$6,$7,$8::jsonb) ON CONFLICT (grant_id) DO UPDATE SET expires_at=EXCLUDED.expires_at, maximum_uses=EXCLUDED.maximum_uses, used=EXCLUDED.used, data=EXCLUDED.data`, [
|
|
240
|
+
grant.grantId,
|
|
241
|
+
grant.agentId,
|
|
242
|
+
grant.userId,
|
|
243
|
+
grant.provider,
|
|
244
|
+
grant.expiresAt,
|
|
245
|
+
grant.maximumUses,
|
|
246
|
+
grant.used,
|
|
247
|
+
JSON.stringify(grant)
|
|
248
|
+
]);
|
|
290
249
|
},
|
|
291
250
|
putPending: async (pending) => {
|
|
292
251
|
await client.query(`INSERT INTO ${ns}.pending_operations (action_id, grant_id, data) VALUES ($1,$2,$3::jsonb) ON CONFLICT (action_id) DO UPDATE SET data=EXCLUDED.data`, [pending.actionId, pending.input.grantId, JSON.stringify(pending)]);
|
|
@@ -294,8 +253,60 @@ var createPostgresCredentialGrantStore = ({ client, namespace = "secrets" }) =>
|
|
|
294
253
|
revoke: async (grantId) => (await client.query(`DELETE FROM ${ns}.credential_grants WHERE grant_id = $1`, [grantId])).rowCount === 1
|
|
295
254
|
};
|
|
296
255
|
};
|
|
256
|
+
// node_modules/@absolutejs/telemetry/dist/index.js
|
|
257
|
+
var NOOP_SPAN_CONTEXT = {
|
|
258
|
+
spanId: "0000000000000000",
|
|
259
|
+
traceFlags: 0,
|
|
260
|
+
traceId: "00000000000000000000000000000000"
|
|
261
|
+
};
|
|
262
|
+
var noopSpan = {
|
|
263
|
+
addEvent: () => noopSpan,
|
|
264
|
+
end: () => {},
|
|
265
|
+
isRecording: () => false,
|
|
266
|
+
recordException: () => {},
|
|
267
|
+
setAttribute: () => noopSpan,
|
|
268
|
+
setAttributes: () => noopSpan,
|
|
269
|
+
setStatus: () => noopSpan,
|
|
270
|
+
spanContext: () => NOOP_SPAN_CONTEXT,
|
|
271
|
+
updateName: () => noopSpan
|
|
272
|
+
};
|
|
273
|
+
var startActiveSpanNoop = (_name, optionsOrFn, maybeFn) => {
|
|
274
|
+
const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
|
|
275
|
+
return fn(noopSpan);
|
|
276
|
+
};
|
|
277
|
+
var noopTracer = {
|
|
278
|
+
startActiveSpan: startActiveSpanNoop,
|
|
279
|
+
startSpan: () => noopSpan
|
|
280
|
+
};
|
|
281
|
+
var tracerOrNoop = (provider, name, version) => provider !== undefined ? provider.getTracer(name, version) : noopTracer;
|
|
282
|
+
var ABS_ATTRS = {
|
|
283
|
+
tenant: "abs.tenant",
|
|
284
|
+
shardId: "abs.shard.id",
|
|
285
|
+
engineId: "abs.engine.id",
|
|
286
|
+
collection: "abs.collection",
|
|
287
|
+
mutation: "abs.mutation",
|
|
288
|
+
mutationAttempt: "abs.mutation.attempt",
|
|
289
|
+
subscriptionId: "abs.subscription.id",
|
|
290
|
+
batchSize: "abs.batch.size",
|
|
291
|
+
clusterMessageOrigin: "abs.cluster.origin",
|
|
292
|
+
jobId: "abs.job.id",
|
|
293
|
+
jobKind: "abs.job.kind",
|
|
294
|
+
jobAttempt: "abs.job.attempt",
|
|
295
|
+
jobMaxAttempts: "abs.job.max_attempts",
|
|
296
|
+
workerId: "abs.worker.id",
|
|
297
|
+
runtimeKey: "abs.runtime.key",
|
|
298
|
+
runtimePid: "abs.runtime.pid",
|
|
299
|
+
runtimePort: "abs.runtime.port",
|
|
300
|
+
runtimeExitReason: "abs.runtime.exit_reason",
|
|
301
|
+
runtimeReadinessMs: "abs.runtime.readiness_ms",
|
|
302
|
+
routeShard: "abs.route.shard",
|
|
303
|
+
routeDecision: "abs.route.decision",
|
|
304
|
+
secretName: "abs.secret.name",
|
|
305
|
+
secretFingerprint: "abs.secret.fingerprint",
|
|
306
|
+
auditKind: "abs.audit.kind"
|
|
307
|
+
};
|
|
297
308
|
|
|
298
|
-
// src/
|
|
309
|
+
// src/broker.ts
|
|
299
310
|
class BrokerDrainedError extends Error {
|
|
300
311
|
constructor() {
|
|
301
312
|
super("[secrets] Broker is draining \u2014 resolve/rotate refused. " + "Use the broker before the shutdown handler fires.");
|
|
@@ -848,7 +859,12 @@ var createSecretBroker = (options) => {
|
|
|
848
859
|
counters.resolveHits += 1;
|
|
849
860
|
span.setAttribute(ABS_ATTRS.secretFingerprint, cached.fingerprint);
|
|
850
861
|
span.setAttribute("secrets.cache", "hit");
|
|
851
|
-
fireAudit({
|
|
862
|
+
fireAudit({
|
|
863
|
+
at: now,
|
|
864
|
+
event: "resolve.hit",
|
|
865
|
+
fingerprint: cached.fingerprint,
|
|
866
|
+
name
|
|
867
|
+
});
|
|
852
868
|
span.setStatus({ code: 1 });
|
|
853
869
|
return { fingerprint: cached.fingerprint, value: cached.value };
|
|
854
870
|
}
|
|
@@ -864,7 +880,12 @@ var createSecretBroker = (options) => {
|
|
|
864
880
|
}
|
|
865
881
|
const entry = cacheEntry(name, value, now);
|
|
866
882
|
span.setAttribute(ABS_ATTRS.secretFingerprint, entry.fingerprint);
|
|
867
|
-
fireAudit({
|
|
883
|
+
fireAudit({
|
|
884
|
+
at: now,
|
|
885
|
+
event: "resolve.miss",
|
|
886
|
+
fingerprint: entry.fingerprint,
|
|
887
|
+
name
|
|
888
|
+
});
|
|
868
889
|
span.setStatus({ code: 1 });
|
|
869
890
|
return { fingerprint: entry.fingerprint, value: entry.value };
|
|
870
891
|
} catch (error) {
|
|
@@ -903,7 +924,12 @@ var createSecretBroker = (options) => {
|
|
|
903
924
|
counters.rotates += 1;
|
|
904
925
|
span.setAttribute(ABS_ATTRS.secretFingerprint, entry.fingerprint);
|
|
905
926
|
span.setStatus({ code: 1 });
|
|
906
|
-
fireAudit({
|
|
927
|
+
fireAudit({
|
|
928
|
+
at: now,
|
|
929
|
+
event: "rotate",
|
|
930
|
+
fingerprint: entry.fingerprint,
|
|
931
|
+
name
|
|
932
|
+
});
|
|
907
933
|
fireRotation(name, entry.value, entry.fingerprint, now);
|
|
908
934
|
return { fingerprint: entry.fingerprint, value: entry.value };
|
|
909
935
|
} catch (error) {
|
|
@@ -1037,5 +1063,5 @@ export {
|
|
|
1037
1063
|
BrokerDrainedError
|
|
1038
1064
|
};
|
|
1039
1065
|
|
|
1040
|
-
//# debugId=
|
|
1066
|
+
//# debugId=A90019DE57677EBB64756E2164756E21
|
|
1041
1067
|
//# sourceMappingURL=index.js.map
|