@absolutejs/secrets 0.5.3 → 0.6.1

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "contract": 1,
2
+ "contract": 2,
3
3
  "identity": {
4
4
  "accent": "#0d9488",
5
5
  "category": "infrastructure",
@@ -186,6 +186,14 @@
186
186
  "annotations": {
187
187
  "readOnlyHint": true
188
188
  },
189
+ "authorization": {
190
+ "effects": [
191
+ "read"
192
+ ],
193
+ "requiredScopes": [
194
+ "secrets:inspect"
195
+ ]
196
+ },
189
197
  "description": "Check whether a named secret is configured. Reports presence and a log-safe sha256 fingerprint — never the value.",
190
198
  "input": {
191
199
  "type": "object",
@@ -205,6 +213,14 @@
205
213
  "annotations": {
206
214
  "readOnlyHint": true
207
215
  },
216
+ "authorization": {
217
+ "effects": [
218
+ "read"
219
+ ],
220
+ "requiredScopes": [
221
+ "secrets:redact"
222
+ ]
223
+ },
208
224
  "description": "Preview redaction: returns the given text with every known (cached) secret replaced by [REDACTED:name]. Useful to check a log line or error message is safe to share. Only secrets the broker has already resolved are scrubbed.",
209
225
  "input": {
210
226
  "type": "object",
@@ -223,6 +239,14 @@
223
239
  "annotations": {
224
240
  "readOnlyHint": true
225
241
  },
242
+ "authorization": {
243
+ "effects": [
244
+ "read"
245
+ ],
246
+ "requiredScopes": [
247
+ "secrets:inspect"
248
+ ]
249
+ },
226
250
  "description": "Cumulative broker counters since the server started: resolves (hits/misses/errors), rotations, and how often redaction actually fired.",
227
251
  "input": {
228
252
  "type": "object",
@@ -0,0 +1,87 @@
1
+ import { type ActionDecision, type Agency, type AgentActor } from "@absolutejs/agency";
2
+ import type { SecretBroker } from "./index";
3
+ export type CredentialGrant = {
4
+ agentId: string;
5
+ allowedOrigins: ReadonlyArray<string>;
6
+ createdAt: number;
7
+ expiresAt: number;
8
+ grantId: string;
9
+ maximumUses: number;
10
+ provider: string;
11
+ scopes: ReadonlyArray<string>;
12
+ secretName: string;
13
+ used: number;
14
+ userId: string;
15
+ };
16
+ export type CredentialOperationInput = {
17
+ actor: AgentActor;
18
+ destination: string;
19
+ grantId: string;
20
+ idempotencyKey?: string;
21
+ input?: unknown;
22
+ operation: string;
23
+ };
24
+ export type CredentialOperationContext = {
25
+ credential: string;
26
+ destination: URL;
27
+ input: unknown;
28
+ signal?: AbortSignal;
29
+ };
30
+ export type CredentialProvider = {
31
+ operations: Record<string, (context: CredentialOperationContext) => Promise<unknown> | unknown>;
32
+ provider: string;
33
+ };
34
+ export type PendingCredentialOperation = {
35
+ actionId: string;
36
+ input: CredentialOperationInput;
37
+ };
38
+ export type CredentialGrantStore = {
39
+ consume: (grantId: string, now: number) => Promise<CredentialGrant | undefined>;
40
+ get: (grantId: string) => Promise<CredentialGrant | undefined>;
41
+ getPending: (actionId: string) => Promise<PendingCredentialOperation | undefined>;
42
+ put: (grant: CredentialGrant) => Promise<void>;
43
+ putPending: (pending: PendingCredentialOperation) => Promise<void>;
44
+ revoke: (grantId: string) => Promise<boolean>;
45
+ };
46
+ export type CredentialOperationEvent = {
47
+ actionId?: string;
48
+ destinationOrigin: string;
49
+ grantId: string;
50
+ operation: string;
51
+ provider: string;
52
+ type: "credential.operation.requested";
53
+ } | {
54
+ actionId?: string;
55
+ destinationOrigin: string;
56
+ grantId: string;
57
+ operation: string;
58
+ provider: string;
59
+ resultDigest?: string;
60
+ status: "failed" | "succeeded";
61
+ type: "credential.operation.completed";
62
+ };
63
+ export type CredentialOperationResult = {
64
+ actionId: string;
65
+ decision: ActionDecision;
66
+ kind: "pending";
67
+ } | {
68
+ actionId?: string;
69
+ kind: "completed";
70
+ result: unknown;
71
+ resultDigest: string;
72
+ };
73
+ export type CredentialOperationBrokerOptions = {
74
+ agency?: Agency;
75
+ emit?: (event: CredentialOperationEvent) => Promise<void> | void;
76
+ now?: () => number;
77
+ providers: ReadonlyArray<CredentialProvider>;
78
+ secrets: SecretBroker;
79
+ store: CredentialGrantStore;
80
+ };
81
+ export declare const createMemoryCredentialGrantStore: () => CredentialGrantStore;
82
+ export declare const createCredentialOperationBroker: ({ agency, emit, now, providers, secrets, store, }: CredentialOperationBrokerOptions) => {
83
+ request: (input: CredentialOperationInput, signal?: AbortSignal) => Promise<CredentialOperationResult>;
84
+ resume: (actionId: string, signal?: AbortSignal) => Promise<CredentialOperationResult>;
85
+ revoke: (grantId: string) => Promise<boolean>;
86
+ };
87
+ export type CredentialOperationBroker = ReturnType<typeof createCredentialOperationBroker>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/secrets",
3
- "version": "0.5.3",
3
+ "version": "0.6.1",
4
4
  "description": "Host-side secret broker for multi-tenant Bun runtimes. Pluggable adapters (env-var, in-memory, composite, encrypted-file); audit hook per resolve; safe fingerprints for logs; redact() walks known secrets out of arbitrary text before it lands in a log sink.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "license": "BSL-1.1",
18
18
  "author": "Alex Kahn",
19
19
  "absolutejs": {
20
- "manifestContract": 1
20
+ "manifestContract": 2
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "public"
@@ -41,7 +41,8 @@
41
41
  "release": "bun run format && bun run check:package && bun publish"
42
42
  },
43
43
  "dependencies": {
44
- "@absolutejs/manifest": "^0.1.0",
44
+ "@absolutejs/agency": "^0.2.0",
45
+ "@absolutejs/manifest": "^0.2.0",
45
46
  "@absolutejs/telemetry": "^0.1.1",
46
47
  "@sinclair/typebox": "^0.34.0"
47
48
  },