@tinycloud/operations 0.3.4-beta.6 → 0.4.0-beta.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.
@@ -1,34 +1,9 @@
1
1
  import { PermissionEntry } from '@tinycloud/sdk-core';
2
2
  import { z } from 'zod';
3
+ import { O as OperationSpaceResolver } from './authority-ofwbEqmj.js';
4
+ export { e as evaluateAuthority } from './authority-ofwbEqmj.js';
3
5
  import { T as TinyCloudPosture, O as OperationOperatorType } from './contract-xMIIMtpF.js';
4
6
 
5
- /**
6
- * A capability in the canonical form persisted in a v1 request artifact.
7
- *
8
- * The SDK remains the semantic authority for containment. This module only
9
- * establishes deterministic exact identity for persistence and display.
10
- */
11
- type CanonicalPermissionEntry = Readonly<PermissionEntry>;
12
- interface AuthorityEvaluation {
13
- readonly satisfied: boolean;
14
- readonly missing: readonly CanonicalPermissionEntry[];
15
- }
16
- /**
17
- * Operation-owned space resolution. The SDK's general capability evaluator
18
- * intentionally preserves its historical short/full-space compatibility; the
19
- * operation kernel supplies this narrower resolver when a space identifies a
20
- * remote owner's resource.
21
- */
22
- type OperationSpaceResolver = (space: string) => string;
23
- /**
24
- * Evaluates required authority with the SDK's public subset primitive.
25
- *
26
- * In particular, this intentionally does not implement matching rules or
27
- * manufacture wildcards. A wildcard can cover a requirement only when it was
28
- * already present in the supplied granted authority and the SDK says so.
29
- */
30
- declare function evaluateAuthority(granted: readonly PermissionEntry[], required: readonly PermissionEntry[]): AuthorityEvaluation;
31
-
32
7
  /** The shared wire schema for SDK PermissionEntry values, including signed ReCap caveats. */
33
8
  declare const PermissionEntrySchema: z.ZodObject<{
34
9
  service: z.ZodString;
@@ -44,19 +19,19 @@ declare const PermissionEntrySchema: z.ZodObject<{
44
19
  path: string;
45
20
  actions: string[];
46
21
  space?: string | undefined;
22
+ caveats?: Record<string, unknown>[] | undefined;
47
23
  skipPrefix?: boolean | undefined;
48
24
  expiry?: string | undefined;
49
25
  description?: string | undefined;
50
- caveats?: Record<string, unknown>[] | undefined;
51
26
  }, {
52
27
  service: string;
53
28
  path: string;
54
29
  actions: string[];
55
30
  space?: string | undefined;
31
+ caveats?: Record<string, unknown>[] | undefined;
56
32
  skipPrefix?: boolean | undefined;
57
33
  expiry?: string | undefined;
58
34
  description?: string | undefined;
59
- caveats?: Record<string, unknown>[] | undefined;
60
35
  }>;
61
36
  declare const LegacyPermissionRequestArtifactSchema: z.ZodObject<{
62
37
  kind: z.ZodLiteral<"tinycloud.auth.request">;
@@ -77,51 +52,51 @@ declare const LegacyPermissionRequestArtifactSchema: z.ZodObject<{
77
52
  path: string;
78
53
  actions: string[];
79
54
  space?: string | undefined;
55
+ caveats?: Record<string, unknown>[] | undefined;
80
56
  skipPrefix?: boolean | undefined;
81
57
  expiry?: string | undefined;
82
58
  description?: string | undefined;
83
- caveats?: Record<string, unknown>[] | undefined;
84
59
  }, {
85
60
  service: string;
86
61
  path: string;
87
62
  actions: string[];
88
63
  space?: string | undefined;
64
+ caveats?: Record<string, unknown>[] | undefined;
89
65
  skipPrefix?: boolean | undefined;
90
66
  expiry?: string | undefined;
91
67
  description?: string | undefined;
92
- caveats?: Record<string, unknown>[] | undefined;
93
68
  }>, "many">;
94
69
  requestedExpiry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
95
70
  }, "strict", z.ZodTypeAny, {
96
- requestId: string;
97
71
  kind: "tinycloud.auth.request";
98
- sessionDid: string;
99
72
  version: 1;
73
+ requestId: string;
74
+ sessionDid: string;
100
75
  requested: {
101
76
  service: string;
102
77
  path: string;
103
78
  actions: string[];
104
79
  space?: string | undefined;
80
+ caveats?: Record<string, unknown>[] | undefined;
105
81
  skipPrefix?: boolean | undefined;
106
82
  expiry?: string | undefined;
107
83
  description?: string | undefined;
108
- caveats?: Record<string, unknown>[] | undefined;
109
84
  }[];
110
85
  requestedExpiry?: string | number | undefined;
111
86
  }, {
112
- requestId: string;
113
87
  kind: "tinycloud.auth.request";
114
- sessionDid: string;
115
88
  version: 1;
89
+ requestId: string;
90
+ sessionDid: string;
116
91
  requested: {
117
92
  service: string;
118
93
  path: string;
119
94
  actions: string[];
120
95
  space?: string | undefined;
96
+ caveats?: Record<string, unknown>[] | undefined;
121
97
  skipPrefix?: boolean | undefined;
122
98
  expiry?: string | undefined;
123
99
  description?: string | undefined;
124
- caveats?: Record<string, unknown>[] | undefined;
125
100
  }[];
126
101
  requestedExpiry?: string | number | undefined;
127
102
  }>;
@@ -153,19 +128,19 @@ declare const PermissionRequestArtifactSchema: z.ZodObject<{
153
128
  path: string;
154
129
  actions: string[];
155
130
  space?: string | undefined;
131
+ caveats?: Record<string, unknown>[] | undefined;
156
132
  skipPrefix?: boolean | undefined;
157
133
  expiry?: string | undefined;
158
134
  description?: string | undefined;
159
- caveats?: Record<string, unknown>[] | undefined;
160
135
  }, {
161
136
  service: string;
162
137
  path: string;
163
138
  actions: string[];
164
139
  space?: string | undefined;
140
+ caveats?: Record<string, unknown>[] | undefined;
165
141
  skipPrefix?: boolean | undefined;
166
142
  expiry?: string | undefined;
167
143
  description?: string | undefined;
168
- caveats?: Record<string, unknown>[] | undefined;
169
144
  }>, "many">;
170
145
  command: z.ZodOptional<z.ZodObject<{
171
146
  argv: z.ZodArray<z.ZodString, "many">;
@@ -178,55 +153,55 @@ declare const PermissionRequestArtifactSchema: z.ZodObject<{
178
153
  cwd: string;
179
154
  }>>;
180
155
  }, "strict", z.ZodTypeAny, {
181
- createdAt: string;
182
- requestId: string;
183
156
  kind: "tinycloud.auth.request";
184
- operatorType: "human" | "agent";
185
- sessionDid: string;
186
157
  version: 1;
158
+ requestId: string;
159
+ sessionDid: string;
187
160
  requested: {
188
161
  service: string;
189
162
  path: string;
190
163
  actions: string[];
191
164
  space?: string | undefined;
165
+ caveats?: Record<string, unknown>[] | undefined;
192
166
  skipPrefix?: boolean | undefined;
193
167
  expiry?: string | undefined;
194
168
  description?: string | undefined;
195
- caveats?: Record<string, unknown>[] | undefined;
196
169
  }[];
197
170
  host: string;
171
+ createdAt: string;
198
172
  profile: string;
199
173
  posture: "owner-openkey" | "delegate-session" | "local-owner-key" | "unauthenticated";
200
- ownerDid?: string | undefined;
174
+ operatorType: "human" | "agent";
201
175
  requestedExpiry?: string | number | undefined;
202
176
  spaceId?: string | undefined;
177
+ ownerDid?: string | undefined;
203
178
  command?: {
204
179
  argv: string[];
205
180
  cwd: string;
206
181
  } | undefined;
207
182
  }, {
208
- createdAt: string;
209
- requestId: string;
210
183
  kind: "tinycloud.auth.request";
211
- operatorType: "human" | "agent";
212
- sessionDid: string;
213
184
  version: 1;
185
+ requestId: string;
186
+ sessionDid: string;
214
187
  requested: {
215
188
  service: string;
216
189
  path: string;
217
190
  actions: string[];
218
191
  space?: string | undefined;
192
+ caveats?: Record<string, unknown>[] | undefined;
219
193
  skipPrefix?: boolean | undefined;
220
194
  expiry?: string | undefined;
221
195
  description?: string | undefined;
222
- caveats?: Record<string, unknown>[] | undefined;
223
196
  }[];
224
197
  host: string;
198
+ createdAt: string;
225
199
  profile: string;
226
200
  posture: "owner-openkey" | "delegate-session" | "local-owner-key" | "unauthenticated";
227
- ownerDid?: string | undefined;
201
+ operatorType: "human" | "agent";
228
202
  requestedExpiry?: string | number | undefined;
229
203
  spaceId?: string | undefined;
204
+ ownerDid?: string | undefined;
230
205
  command?: {
231
206
  argv: string[];
232
207
  cwd: string;
@@ -253,26 +228,26 @@ declare const DelegationImportArtifactSchema: z.ZodObject<{
253
228
  path: string;
254
229
  actions: string[];
255
230
  space?: string | undefined;
231
+ caveats?: Record<string, unknown>[] | undefined;
256
232
  skipPrefix?: boolean | undefined;
257
233
  expiry?: string | undefined;
258
234
  description?: string | undefined;
259
- caveats?: Record<string, unknown>[] | undefined;
260
235
  }, {
261
236
  service: string;
262
237
  path: string;
263
238
  actions: string[];
264
239
  space?: string | undefined;
240
+ caveats?: Record<string, unknown>[] | undefined;
265
241
  skipPrefix?: boolean | undefined;
266
242
  expiry?: string | undefined;
267
243
  description?: string | undefined;
268
- caveats?: Record<string, unknown>[] | undefined;
269
244
  }>, "many">>;
270
245
  expiry: z.ZodOptional<z.ZodString>;
271
246
  prompted: z.ZodOptional<z.ZodBoolean>;
272
247
  }, "strict", z.ZodTypeAny, {
273
- requestId: string;
274
248
  kind: "tinycloud.auth.delegation";
275
249
  version: 1;
250
+ requestId: string;
276
251
  delegation: Record<string, unknown>;
277
252
  expiry?: string | undefined;
278
253
  delegationCid?: string | undefined;
@@ -281,16 +256,16 @@ declare const DelegationImportArtifactSchema: z.ZodObject<{
281
256
  path: string;
282
257
  actions: string[];
283
258
  space?: string | undefined;
259
+ caveats?: Record<string, unknown>[] | undefined;
284
260
  skipPrefix?: boolean | undefined;
285
261
  expiry?: string | undefined;
286
262
  description?: string | undefined;
287
- caveats?: Record<string, unknown>[] | undefined;
288
263
  }[] | undefined;
289
264
  prompted?: boolean | undefined;
290
265
  }, {
291
- requestId: string;
292
266
  kind: "tinycloud.auth.delegation";
293
267
  version: 1;
268
+ requestId: string;
294
269
  delegation: Record<string, unknown>;
295
270
  expiry?: string | undefined;
296
271
  delegationCid?: string | undefined;
@@ -299,13 +274,95 @@ declare const DelegationImportArtifactSchema: z.ZodObject<{
299
274
  path: string;
300
275
  actions: string[];
301
276
  space?: string | undefined;
277
+ caveats?: Record<string, unknown>[] | undefined;
302
278
  skipPrefix?: boolean | undefined;
303
279
  expiry?: string | undefined;
304
280
  description?: string | undefined;
305
- caveats?: Record<string, unknown>[] | undefined;
306
281
  }[] | undefined;
307
282
  prompted?: boolean | undefined;
308
283
  }>;
284
+ /**
285
+ * The stored request an imported delegation was checked against, persisted
286
+ * with the delegation. Its fields are exactly the request artifact's, so
287
+ * replay accepts every binding import can write.
288
+ */
289
+ declare const DelegationRequestBindingSchema: z.ZodObject<Pick<{
290
+ kind: z.ZodLiteral<"tinycloud.auth.request">;
291
+ version: z.ZodLiteral<1>;
292
+ requestId: z.ZodString;
293
+ createdAt: z.ZodString;
294
+ profile: z.ZodString;
295
+ posture: z.ZodEnum<["owner-openkey", "delegate-session", "local-owner-key", "unauthenticated"]>;
296
+ operatorType: z.ZodEnum<["human", "agent"]>;
297
+ host: z.ZodString;
298
+ sessionDid: z.ZodString;
299
+ ownerDid: z.ZodOptional<z.ZodString>;
300
+ spaceId: z.ZodOptional<z.ZodString>;
301
+ requestedExpiry: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
302
+ requested: z.ZodArray<z.ZodObject<{
303
+ service: z.ZodString;
304
+ space: z.ZodOptional<z.ZodString>;
305
+ path: z.ZodString;
306
+ actions: z.ZodArray<z.ZodString, "many">;
307
+ caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
308
+ skipPrefix: z.ZodOptional<z.ZodBoolean>;
309
+ expiry: z.ZodOptional<z.ZodString>;
310
+ description: z.ZodOptional<z.ZodString>;
311
+ }, "strict", z.ZodTypeAny, {
312
+ service: string;
313
+ path: string;
314
+ actions: string[];
315
+ space?: string | undefined;
316
+ caveats?: Record<string, unknown>[] | undefined;
317
+ skipPrefix?: boolean | undefined;
318
+ expiry?: string | undefined;
319
+ description?: string | undefined;
320
+ }, {
321
+ service: string;
322
+ path: string;
323
+ actions: string[];
324
+ space?: string | undefined;
325
+ caveats?: Record<string, unknown>[] | undefined;
326
+ skipPrefix?: boolean | undefined;
327
+ expiry?: string | undefined;
328
+ description?: string | undefined;
329
+ }>, "many">;
330
+ command: z.ZodOptional<z.ZodObject<{
331
+ argv: z.ZodArray<z.ZodString, "many">;
332
+ cwd: z.ZodString;
333
+ }, "strict", z.ZodTypeAny, {
334
+ argv: string[];
335
+ cwd: string;
336
+ }, {
337
+ argv: string[];
338
+ cwd: string;
339
+ }>>;
340
+ }, "requestId" | "requested">, "strict", z.ZodTypeAny, {
341
+ requestId: string;
342
+ requested: {
343
+ service: string;
344
+ path: string;
345
+ actions: string[];
346
+ space?: string | undefined;
347
+ caveats?: Record<string, unknown>[] | undefined;
348
+ skipPrefix?: boolean | undefined;
349
+ expiry?: string | undefined;
350
+ description?: string | undefined;
351
+ }[];
352
+ }, {
353
+ requestId: string;
354
+ requested: {
355
+ service: string;
356
+ path: string;
357
+ actions: string[];
358
+ space?: string | undefined;
359
+ caveats?: Record<string, unknown>[] | undefined;
360
+ skipPrefix?: boolean | undefined;
361
+ expiry?: string | undefined;
362
+ description?: string | undefined;
363
+ }[];
364
+ }>;
365
+ type DelegationRequestBinding = z.infer<typeof DelegationRequestBindingSchema>;
309
366
  type PermissionRequestArtifact = z.infer<typeof PermissionRequestArtifactSchema>;
310
367
  type DelegationImportArtifact = z.infer<typeof DelegationImportArtifactSchema>;
311
368
  /** The minimal public node-sdk request shape accepted by the legacy reader. */
@@ -388,4 +445,4 @@ interface PrunePermissionRequestsInput {
388
445
  /** Pure retention policy used by the locked persistence operation. */
389
446
  declare function prunePermissionRequests(records: readonly PermissionRequestArtifact[], input: PrunePermissionRequestsInput): PermissionRequestArtifact[];
390
447
 
391
- export { type ArtifactClock, type BuildPermissionRequestArtifactInput, type CreateOrReusePermissionRequestInput, type DelegationImportArtifact, DelegationImportArtifactSchema, type LegacyPermissionRequestArtifact, type LegacyRequestContext, PermissionEntrySchema, type PermissionRequestArtifact, PermissionRequestArtifactSchema, type PermissionRequestIdentityInput, type PermissionRequestResolution, type PrunePermissionRequestsInput, type RequestIdSource, buildPermissionRequestArtifact, createOrReusePermissionRequest, createPermissionRequestIdentity, evaluateAuthority, findPermissionRequest, isDelegationImportArtifact, isPermissionRequestArtifact, listPermissionRequests, prunePermissionRequests, validateDelegationImportArtifact, validatePermissionRequestArtifact };
448
+ export { type ArtifactClock, type BuildPermissionRequestArtifactInput, type CreateOrReusePermissionRequestInput, type DelegationImportArtifact, DelegationImportArtifactSchema, type DelegationRequestBinding, DelegationRequestBindingSchema, type LegacyPermissionRequestArtifact, type LegacyRequestContext, PermissionEntrySchema, type PermissionRequestArtifact, PermissionRequestArtifactSchema, type PermissionRequestIdentityInput, type PermissionRequestResolution, type PrunePermissionRequestsInput, type RequestIdSource, buildPermissionRequestArtifact, createOrReusePermissionRequest, createPermissionRequestIdentity, findPermissionRequest, isDelegationImportArtifact, isPermissionRequestArtifact, listPermissionRequests, prunePermissionRequests, validateDelegationImportArtifact, validatePermissionRequestArtifact };
package/dist/artifacts.js CHANGED
@@ -6945,8 +6945,13 @@ var TEST_LOCK_CLAIM_BARRIER_DIR = "TC_TEST_PROFILE_LOCK_CLAIM_BARRIER_DIR";
6945
6945
  var TEST_LOCK_CLAIMED_BARRIER_DIR = "TC_TEST_PROFILE_LOCK_CLAIMED_BARRIER_DIR";
6946
6946
  var TEST_LOCK_FENCED_BARRIER_DIR = "TC_TEST_PROFILE_LOCK_FENCED_BARRIER_DIR";
6947
6947
  var TEST_LOCK_VERIFIED_BARRIER_DIR = "TC_TEST_PROFILE_LOCK_VERIFIED_BARRIER_DIR";
6948
- var invocationStateRoot = new AsyncLocalStorage();
6949
- var heldProfileLocks = new AsyncLocalStorage();
6948
+ function processWideContext(key) {
6949
+ var _a;
6950
+ const registry = globalThis;
6951
+ return registry[_a = Symbol.for(key)] ?? (registry[_a] = new AsyncLocalStorage());
6952
+ }
6953
+ var invocationStateRoot = processWideContext("tinycloud.operations.invocationStateRoot.v1");
6954
+ var heldProfileLocks = processWideContext("tinycloud.operations.heldProfileLocks.v1");
6950
6955
  var ProfileLockTimeoutError = class extends Error {
6951
6956
  constructor(profile, timeoutMs) {
6952
6957
  super(`Timed out waiting for the profile lock for "${profile}" after ${timeoutMs}ms.`);
@@ -7310,6 +7315,7 @@ var DelegationImportArtifactSchema = z2.object({
7310
7315
  expiry: z2.string().datetime({ offset: true }).optional(),
7311
7316
  prompted: z2.boolean().optional()
7312
7317
  }).strict();
7318
+ var DelegationRequestBindingSchema = PermissionRequestArtifactSchema.pick({ requestId: true, requested: true }).strict();
7313
7319
  function validatePermissionRequestArtifact(value) {
7314
7320
  return PermissionRequestArtifactSchema.parse(value);
7315
7321
  }
@@ -7522,6 +7528,7 @@ function defaultRequestId(now) {
7522
7528
  }
7523
7529
  export {
7524
7530
  DelegationImportArtifactSchema,
7531
+ DelegationRequestBindingSchema,
7525
7532
  PermissionEntrySchema,
7526
7533
  PermissionRequestArtifactSchema,
7527
7534
  buildPermissionRequestArtifact,