@tokensrc/codex 1.14.16 → 1.14.18
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 +73 -71
- package/dist/client.d.ts +21 -16
- package/dist/client.js +198 -116
- package/dist/client.js.map +1 -1
- package/dist/command-directory.js +3 -2
- package/dist/command-directory.js.map +1 -1
- package/dist/commands.d.ts +0 -1
- package/dist/commands.js +479 -273
- package/dist/commands.js.map +1 -1
- package/dist/credentials.d.ts +3 -75
- package/dist/credentials.js +2 -338
- package/dist/credentials.js.map +1 -1
- package/dist/index.d.ts +2 -8
- package/dist/index.js +2 -8
- package/dist/index.js.map +1 -1
- package/dist/managed-credential-v3-envelope.d.ts +38 -14
- package/dist/managed-credential-v3-envelope.js +116 -25
- package/dist/managed-credential-v3-envelope.js.map +1 -1
- package/dist/managed-credential-v3-flow.d.ts +0 -17
- package/dist/managed-credential-v3-flow.js +107 -110
- package/dist/managed-credential-v3-flow.js.map +1 -1
- package/dist/managed-credential-v3.d.ts +0 -8
- package/dist/managed-credential-v3.js +0 -23
- package/dist/managed-credential-v3.js.map +1 -1
- package/dist/profile.d.ts +2 -6
- package/dist/profile.js +26 -23
- package/dist/profile.js.map +1 -1
- package/dist/protocol.d.ts +1284 -799
- package/dist/protocol.js +494 -277
- package/dist/protocol.js.map +1 -1
- package/dist/request-bound-device-v6-flow.d.ts +42 -0
- package/dist/request-bound-device-v6-flow.js +403 -0
- package/dist/request-bound-device-v6-flow.js.map +1 -0
- package/dist/request-bound-device-v6-state.d.ts +397 -0
- package/dist/request-bound-device-v6-state.js +221 -0
- package/dist/request-bound-device-v6-state.js.map +1 -0
- package/dist/selection.d.ts +5 -0
- package/dist/selection.js +20 -2
- package/dist/selection.js.map +1 -1
- package/dist/token-pool-v4-upload-flow.js +5 -1
- package/dist/token-pool-v4-upload-flow.js.map +1 -1
- package/package.json +2 -2
- package/dist/credential-supervisor.d.ts +0 -17
- package/dist/credential-supervisor.js +0 -84
- package/dist/credential-supervisor.js.map +0 -1
- package/dist/enrollment-envelope.d.ts +0 -18
- package/dist/enrollment-envelope.js +0 -112
- package/dist/enrollment-envelope.js.map +0 -1
- package/dist/enrollment-flow.d.ts +0 -27
- package/dist/enrollment-flow.js +0 -224
- package/dist/enrollment-flow.js.map +0 -1
- package/dist/migration-login-batch.d.ts +0 -66
- package/dist/migration-login-batch.js +0 -202
- package/dist/migration-login-batch.js.map +0 -1
- package/dist/retirement-flow.d.ts +0 -38
- package/dist/retirement-flow.js +0 -78
- package/dist/retirement-flow.js.map +0 -1
- package/dist/short-lived-delivery-flow.d.ts +0 -41
- package/dist/short-lived-delivery-flow.js +0 -141
- package/dist/short-lived-delivery-flow.js.map +0 -1
- package/dist/short-lived-delivery-journal.d.ts +0 -34
- package/dist/short-lived-delivery-journal.js +0 -137
- package/dist/short-lived-delivery-journal.js.map +0 -1
- package/dist/short-lived-delivery.d.ts +0 -26
- package/dist/short-lived-delivery.js +0 -139
- package/dist/short-lived-delivery.js.map +0 -1
package/dist/protocol.js
CHANGED
|
@@ -6,11 +6,6 @@ export const CODEX_ACCOUNTS_IMPORT_PATH = "/v1/admin/codex/accounts/import";
|
|
|
6
6
|
export const CODEX_ADMIN_ACCOUNTS_PATH = "/v1/admin/codex/accounts";
|
|
7
7
|
export const CODEX_ADMIN_ASSIGNMENTS_PATH = "/v1/admin/codex/assignments";
|
|
8
8
|
export const CODEX_ENROLLMENT_SCHEMA_VERSION = 2;
|
|
9
|
-
export const CODEX_ADMIN_ENROLLMENT_INTENTS_PATH = "/v2/admin/codex/enrollment-intents";
|
|
10
|
-
export const CODEX_CREDENTIAL_ASSIGNMENTS_PATH = "/v2/codex/credential-assignments";
|
|
11
|
-
export const CODEX_SHORT_LIVED_DELIVERIES_PATH = "/v2/codex/short-lived-credential-deliveries";
|
|
12
|
-
export const CODEX_ASSIGNMENT_RETIREMENTS_PATH = "/v2/codex/assignment-retirements";
|
|
13
|
-
export const CODEX_ADMIN_MIGRATION_PLANS_PATH = "/v2/admin/codex/migration-plans";
|
|
14
9
|
export const CODEX_MANAGED_CREDENTIALS_V3_SCHEMA_VERSION = 3;
|
|
15
10
|
// The configured service URL already includes the public `/api` prefix.
|
|
16
11
|
export const CODEX_MANAGED_CREDENTIALS_V3_PATH = "/v3/codex";
|
|
@@ -25,19 +20,20 @@ export const CODEX_TOKEN_POOL_V4_ENROLLMENT_CONFIGURATION_PATH = `${CODEX_TOKEN_
|
|
|
25
20
|
export const CODEX_TOKEN_POOL_V4_DIRECTORY_RESOLVE_PATH = `${CODEX_TOKEN_POOL_V4_PATH}/directory-users/resolve`;
|
|
26
21
|
export const CODEX_TOKEN_POOL_V4_UPLOADS_PATH = `${CODEX_TOKEN_POOL_V4_PATH}/token-pool/uploads`;
|
|
27
22
|
export const CODEX_TOKEN_POOL_V4_RUNTIME_PATH = "/v4/codex";
|
|
28
|
-
export const CODEX_TOKEN_POOL_V4_CREDENTIAL_ASSIGNMENTS_PATH = `${CODEX_TOKEN_POOL_V4_RUNTIME_PATH}/credential-assignments`;
|
|
29
|
-
export const CODEX_TOKEN_POOL_V4_FULL_CREDENTIAL_DELIVERIES_PATH = `${CODEX_TOKEN_POOL_V4_RUNTIME_PATH}/full-credential-deliveries`;
|
|
30
23
|
export const CODEX_TOKEN_POOL_V4_CREDENTIAL_LINEAGES_PATH = `${CODEX_TOKEN_POOL_V4_RUNTIME_PATH}/credential-lineages`;
|
|
31
24
|
export const CODEX_MULTI_DEVICE_V5_SCHEMA_VERSION = 5;
|
|
32
25
|
export const CODEX_MULTI_DEVICE_V5_RUNTIME_PATH = "/v5/codex";
|
|
33
26
|
export const CODEX_MULTI_DEVICE_V5_CREDENTIAL_ASSIGNMENTS_PATH = `${CODEX_MULTI_DEVICE_V5_RUNTIME_PATH}/credential-assignments`;
|
|
34
27
|
export const CODEX_MULTI_DEVICE_V5_DEVICE_SESSIONS_PATH = `${CODEX_MULTI_DEVICE_V5_RUNTIME_PATH}/device-sessions`;
|
|
35
28
|
export const CODEX_MULTI_DEVICE_V5_CREDENTIAL_LINEAGES_PATH = `${CODEX_MULTI_DEVICE_V5_RUNTIME_PATH}/credential-lineages`;
|
|
36
|
-
export const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
29
|
+
export const CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION = 6;
|
|
30
|
+
export const CODEX_REQUEST_BOUND_DEVICE_V6_RUNTIME_PATH = "/v6/codex";
|
|
31
|
+
export const CODEX_V6_ACCOUNT_REQUESTS_PATH = `${CODEX_REQUEST_BOUND_DEVICE_V6_RUNTIME_PATH}/account-requests`;
|
|
32
|
+
export const CODEX_V6_DEVICE_ACCESS_RECONCILIATIONS_PATH = `${CODEX_REQUEST_BOUND_DEVICE_V6_RUNTIME_PATH}/device-access/reconciliations`;
|
|
33
|
+
export const CODEX_V6_DEVICE_BINDINGS_PATH = `${CODEX_REQUEST_BOUND_DEVICE_V6_RUNTIME_PATH}/device-bindings`;
|
|
34
|
+
export const CODEX_REQUEST_BOUND_DEVICE_V6_ADMIN_PATH = "/v6/admin/codex";
|
|
35
|
+
export const CODEX_V6_ADMIN_ACCOUNT_REQUESTS_PATH = `${CODEX_REQUEST_BOUND_DEVICE_V6_ADMIN_PATH}/account-requests`;
|
|
36
|
+
export const CODEX_V6_ADMIN_DEVICE_BINDINGS_PATH = `${CODEX_REQUEST_BOUND_DEVICE_V6_ADMIN_PATH}/device-bindings`;
|
|
41
37
|
const CodexCompatibilityLabelSchema = z.string().max(256)
|
|
42
38
|
.transform((label) => label.trim() ? label : undefined)
|
|
43
39
|
.optional();
|
|
@@ -279,84 +275,11 @@ export const CodexAdminAssignmentDeleteResponseSchema = z.strictObject({
|
|
|
279
275
|
schemaVersion: z.literal(CODEX_DISTRIBUTION_SCHEMA_VERSION),
|
|
280
276
|
assignmentId: z.string().min(1).max(128)
|
|
281
277
|
});
|
|
282
|
-
export const CodexEnrollmentIntentReasonSchema = z.enum([
|
|
283
|
-
"NEW",
|
|
284
|
-
"REPLACE_LOST",
|
|
285
|
-
"REPLACE_REJECTED",
|
|
286
|
-
"REPLACE_DIVERGED",
|
|
287
|
-
"REPLACE_ADMIN"
|
|
288
|
-
]);
|
|
289
|
-
export const CodexEnrollmentIntentStatusSchema = z.enum([
|
|
290
|
-
"AWAITING_CLI",
|
|
291
|
-
"CLAIMED",
|
|
292
|
-
"LOGIN_IN_PROGRESS",
|
|
293
|
-
"UPLOADING",
|
|
294
|
-
"VALIDATING",
|
|
295
|
-
"READY",
|
|
296
|
-
"ACCOUNT_MISMATCH",
|
|
297
|
-
"IDENTITY_UNVERIFIABLE",
|
|
298
|
-
"TEMPORARILY_UNAVAILABLE",
|
|
299
|
-
"OUTCOME_AMBIGUOUS",
|
|
300
|
-
"EXPIRED",
|
|
301
|
-
"CANCELLED"
|
|
302
|
-
]);
|
|
303
278
|
const EnrollmentInstantSchema = z.string().datetime({ offset: true });
|
|
304
|
-
export const CodexEnrollmentIntentSchema = z.strictObject({
|
|
305
|
-
id: z.string().min(1).max(128),
|
|
306
|
-
type: z.enum(["ACCOUNT_DISCOVERY", "ASSIGNMENT_ENROLLMENT"]),
|
|
307
|
-
status: CodexEnrollmentIntentStatusSchema,
|
|
308
|
-
revision: z.number().int().nonnegative(),
|
|
309
|
-
reason: CodexEnrollmentIntentReasonSchema,
|
|
310
|
-
assignmentId: z.string().min(1).max(128).nullable(),
|
|
311
|
-
managedAccountId: z.string().min(1).max(128).nullable(),
|
|
312
|
-
userSubject: z.string().min(1).max(255).nullable(),
|
|
313
|
-
createdAt: EnrollmentInstantSchema,
|
|
314
|
-
expiresAt: EnrollmentInstantSchema,
|
|
315
|
-
claimedAt: EnrollmentInstantSchema.nullable(),
|
|
316
|
-
lastHeartbeatAt: EnrollmentInstantSchema.nullable(),
|
|
317
|
-
cancelledAt: EnrollmentInstantSchema.nullable(),
|
|
318
|
-
updatedAt: EnrollmentInstantSchema,
|
|
319
|
-
safeErrorCode: z.string().min(1).max(128).regex(/^[a-z][a-z0-9_.-]*$/i).nullable(),
|
|
320
|
-
resultManagedAccountId: z.string().min(1).max(128).nullable(),
|
|
321
|
-
resultLineageId: z.string().min(1).max(128).nullable(),
|
|
322
|
-
currentGenerationVersion: z.number().int().positive().nullable(),
|
|
323
|
-
allowedActions: z.array(z.string().min(1).max(64).regex(/^[A-Z][A-Z0-9_]*$/)).max(32)
|
|
324
|
-
});
|
|
325
|
-
export const CodexEnrollmentCandidateIngressSchema = z.strictObject({
|
|
326
|
-
envelopeVersion: z.literal(1),
|
|
327
|
-
algorithm: z.literal("X25519-HKDF-SHA256-AES-256-GCM"),
|
|
328
|
-
keyId: z.string().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/),
|
|
329
|
-
publicKey: z.string().length(43).regex(/^[A-Za-z0-9_-]+$/),
|
|
330
|
-
maxRequestBytes: z.number().int().min(1_024).max(196_608),
|
|
331
|
-
maxCiphertextBytes: z.number().int().min(256).max(131_072)
|
|
332
|
-
});
|
|
333
|
-
export const CodexEnrollmentCapabilitiesSchema = z.strictObject({
|
|
334
|
-
enrollmentIntents: z.boolean(),
|
|
335
|
-
candidateUpload: z.boolean(),
|
|
336
|
-
delivery: z.boolean(),
|
|
337
|
-
rotationSync: z.boolean(),
|
|
338
|
-
candidateIngress: CodexEnrollmentCandidateIngressSchema.optional()
|
|
339
|
-
}).superRefine((capabilities, context) => {
|
|
340
|
-
if (capabilities.candidateUpload && !capabilities.candidateIngress) {
|
|
341
|
-
context.addIssue({
|
|
342
|
-
code: "custom",
|
|
343
|
-
path: ["candidateIngress"],
|
|
344
|
-
message: "candidateIngress is required when candidateUpload is enabled."
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
export const CodexEnrollmentIntentResponseSchema = z.strictObject({
|
|
349
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
350
|
-
intent: CodexEnrollmentIntentSchema,
|
|
351
|
-
capabilities: CodexEnrollmentCapabilitiesSchema
|
|
352
|
-
});
|
|
353
279
|
export const CodexEnrollmentMutationInputSchema = z.strictObject({
|
|
354
280
|
idempotencyKey: z.string().min(8).max(255),
|
|
355
281
|
revision: z.number().int().nonnegative()
|
|
356
282
|
});
|
|
357
|
-
export const CodexEnrollmentHeartbeatInputSchema = CodexEnrollmentMutationInputSchema.extend({
|
|
358
|
-
phase: z.enum(["LOGIN_IN_PROGRESS", "UPLOADING"])
|
|
359
|
-
});
|
|
360
283
|
export const CodexEnrollmentCandidateEnvelopeSchema = z.strictObject({
|
|
361
284
|
version: z.literal(1),
|
|
362
285
|
algorithm: z.literal("X25519-HKDF-SHA256-AES-256-GCM"),
|
|
@@ -367,88 +290,6 @@ export const CodexEnrollmentCandidateEnvelopeSchema = z.strictObject({
|
|
|
367
290
|
ciphertext: z.string().min(1).max(174_764).regex(/^[A-Za-z0-9_-]+$/),
|
|
368
291
|
authenticationTag: z.string().length(22).regex(/^[A-Za-z0-9_-]+$/)
|
|
369
292
|
});
|
|
370
|
-
export const CodexEnrollmentCandidateInputSchema = z.strictObject({
|
|
371
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
372
|
-
revision: z.number().int().nonnegative(),
|
|
373
|
-
envelope: CodexEnrollmentCandidateEnvelopeSchema
|
|
374
|
-
});
|
|
375
|
-
export const CodexEnrollmentCandidateResultSchema = z.strictObject({
|
|
376
|
-
outcome: z.enum([
|
|
377
|
-
"READY",
|
|
378
|
-
"ACCOUNT_MISMATCH",
|
|
379
|
-
"IDENTITY_UNVERIFIABLE",
|
|
380
|
-
"TEMPORARILY_UNAVAILABLE",
|
|
381
|
-
"OUTCOME_AMBIGUOUS"
|
|
382
|
-
]),
|
|
383
|
-
managedAccountId: z.string().min(1).max(128).nullable(),
|
|
384
|
-
lineageId: z.string().min(1).max(128).nullable(),
|
|
385
|
-
generationVersion: z.number().int().positive().nullable(),
|
|
386
|
-
replayed: z.boolean()
|
|
387
|
-
});
|
|
388
|
-
export const CodexEnrollmentCandidateResponseSchema = CodexEnrollmentIntentResponseSchema.extend({
|
|
389
|
-
result: CodexEnrollmentCandidateResultSchema
|
|
390
|
-
});
|
|
391
|
-
export const CodexMigrationPlanStatusSchema = z.enum([
|
|
392
|
-
"ACTIVE",
|
|
393
|
-
"PAUSED",
|
|
394
|
-
"CANCELLED",
|
|
395
|
-
"COMPLETED"
|
|
396
|
-
]);
|
|
397
|
-
export const CodexMigrationTargetSchema = z.strictObject({
|
|
398
|
-
id: z.string().min(1).max(255),
|
|
399
|
-
assignmentId: z.string().min(1).max(255),
|
|
400
|
-
userSubject: z.string().min(1).max(255),
|
|
401
|
-
distributionMode: z.enum(["LEGACY", "MIGRATING", "USER_BOUND"]),
|
|
402
|
-
projectedStatus: z.enum([
|
|
403
|
-
"UNENROLLED",
|
|
404
|
-
"AWAITING_CLI",
|
|
405
|
-
"ENROLLING",
|
|
406
|
-
"VALIDATING",
|
|
407
|
-
"READY",
|
|
408
|
-
"DELIVERY_UNKNOWN",
|
|
409
|
-
"ACTIVE",
|
|
410
|
-
"SYNC_LAGGING",
|
|
411
|
-
"DIVERGED",
|
|
412
|
-
"LOST",
|
|
413
|
-
"NEEDS_REAUTH",
|
|
414
|
-
"RETIREMENT_PENDING",
|
|
415
|
-
"RETIRED",
|
|
416
|
-
"COMPROMISED",
|
|
417
|
-
"LEGACY_V1"
|
|
418
|
-
]),
|
|
419
|
-
enrollmentAttachment: z.enum(["CREATED", "REUSED", "NONE"]),
|
|
420
|
-
enrollmentIntent: z.strictObject({
|
|
421
|
-
id: z.string().min(1).max(255),
|
|
422
|
-
status: CodexEnrollmentIntentStatusSchema,
|
|
423
|
-
revision: z.number().int().nonnegative(),
|
|
424
|
-
expiresAt: EnrollmentInstantSchema,
|
|
425
|
-
updatedAt: EnrollmentInstantSchema,
|
|
426
|
-
safeErrorCode: z.string().min(1).max(128).regex(/^[a-z][a-z0-9_.-]*$/i).nullable()
|
|
427
|
-
}).nullable(),
|
|
428
|
-
allowedAction: z.enum(["LOGIN", "VIEW_ENROLLMENT", "NONE"])
|
|
429
|
-
});
|
|
430
|
-
export const CodexMigrationLoginQueueResponseSchema = z.strictObject({
|
|
431
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
432
|
-
plan: z.strictObject({
|
|
433
|
-
id: z.string().min(1).max(255),
|
|
434
|
-
status: CodexMigrationPlanStatusSchema,
|
|
435
|
-
revision: z.number().int().nonnegative(),
|
|
436
|
-
accountId: z.string().min(1).max(255),
|
|
437
|
-
sequentialRequired: z.literal(true)
|
|
438
|
-
}),
|
|
439
|
-
items: z.array(CodexMigrationTargetSchema).max(100),
|
|
440
|
-
total: z.number().int().nonnegative(),
|
|
441
|
-
page: z.number().int().min(1).max(1_000_000),
|
|
442
|
-
pageSize: z.number().int().min(1).max(100)
|
|
443
|
-
}).superRefine((value, context) => {
|
|
444
|
-
if (value.items.length > value.pageSize || value.items.length > value.total) {
|
|
445
|
-
context.addIssue({
|
|
446
|
-
code: "custom",
|
|
447
|
-
path: ["items"],
|
|
448
|
-
message: "Migration login queue pagination is inconsistent."
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
293
|
export const CodexUserCredentialAssignmentSchema = z.strictObject({
|
|
453
294
|
assignmentId: z.string().min(1).max(128),
|
|
454
295
|
managedAccountId: z.string().min(1).max(128),
|
|
@@ -491,10 +332,6 @@ export const CodexShortLivedDeliveryClientKeySchema = z.strictObject({
|
|
|
491
332
|
algorithm: z.literal("X25519-HKDF-SHA256-AES-256-GCM"),
|
|
492
333
|
publicKey: z.string().length(43).regex(/^[A-Za-z0-9_-]+$/)
|
|
493
334
|
});
|
|
494
|
-
export const CodexShortLivedDeliveryRequestSchema = z.strictObject({
|
|
495
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
496
|
-
clientKey: CodexShortLivedDeliveryClientKeySchema
|
|
497
|
-
});
|
|
498
335
|
export const CodexShortLivedDeliveryEnvelopeSchema = z.strictObject({
|
|
499
336
|
version: z.literal(1),
|
|
500
337
|
algorithm: z.literal("X25519-HKDF-SHA256-AES-256-GCM"),
|
|
@@ -504,90 +341,6 @@ export const CodexShortLivedDeliveryEnvelopeSchema = z.strictObject({
|
|
|
504
341
|
ciphertext: z.string().min(1).max(174_764).regex(/^[A-Za-z0-9_-]+$/),
|
|
505
342
|
authenticationTag: z.string().length(22).regex(/^[A-Za-z0-9_-]+$/)
|
|
506
343
|
});
|
|
507
|
-
const CodexShortLivedDeliveryMetadataSchema = z.strictObject({
|
|
508
|
-
id: z.string().min(1).max(128),
|
|
509
|
-
credentialKind: z.literal("SHORT_LIVED"),
|
|
510
|
-
assignmentId: z.string().min(1).max(128),
|
|
511
|
-
managedAccountId: z.string().min(1).max(128),
|
|
512
|
-
lineageId: z.string().min(1).max(128),
|
|
513
|
-
generationVersion: z.number().int().positive(),
|
|
514
|
-
status: z.enum(["AWAITING_ACK", "ACKED", "EXPIRED"]),
|
|
515
|
-
issuedAt: EnrollmentInstantSchema,
|
|
516
|
-
credentialExpiresAt: EnrollmentInstantSchema,
|
|
517
|
-
ackExpiresAt: EnrollmentInstantSchema,
|
|
518
|
-
ackedAt: EnrollmentInstantSchema.nullable()
|
|
519
|
-
});
|
|
520
|
-
export const CodexShortLivedDeliveryResponseSchema = z.strictObject({
|
|
521
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
522
|
-
delivery: CodexShortLivedDeliveryMetadataSchema.extend({
|
|
523
|
-
providerAccountId: z.string().min(1).max(512),
|
|
524
|
-
subject: z.string().min(1).max(255),
|
|
525
|
-
envelope: CodexShortLivedDeliveryEnvelopeSchema
|
|
526
|
-
}),
|
|
527
|
-
replayed: z.boolean()
|
|
528
|
-
});
|
|
529
|
-
export const CodexShortLivedDeliveryAckInputSchema = z.strictObject({
|
|
530
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
531
|
-
lineageId: z.string().min(1).max(128),
|
|
532
|
-
generationVersion: z.number().int().positive()
|
|
533
|
-
});
|
|
534
|
-
export const CodexShortLivedDeliveryAckResponseSchema = z.strictObject({
|
|
535
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
536
|
-
delivery: CodexShortLivedDeliveryMetadataSchema.extend({
|
|
537
|
-
status: z.literal("ACKED"),
|
|
538
|
-
ackedAt: EnrollmentInstantSchema
|
|
539
|
-
}),
|
|
540
|
-
replayed: z.boolean()
|
|
541
|
-
});
|
|
542
|
-
export const CodexShortLivedCredentialBundleSchema = z.strictObject({
|
|
543
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
544
|
-
deliveryId: z.string().min(1).max(128),
|
|
545
|
-
managedAccountId: z.string().min(1).max(128),
|
|
546
|
-
providerAccountId: z.string().min(1).max(512),
|
|
547
|
-
lineageId: z.string().min(1).max(128),
|
|
548
|
-
generationVersion: z.number().int().positive(),
|
|
549
|
-
accessToken: z.string().min(1).max(65_536),
|
|
550
|
-
idToken: z.string().min(1).max(65_536),
|
|
551
|
-
expiresAt: EnrollmentInstantSchema
|
|
552
|
-
});
|
|
553
|
-
export const CodexAssignmentRetirementSchema = z.strictObject({
|
|
554
|
-
id: z.string().min(1).max(200),
|
|
555
|
-
assignmentId: z.string().min(1).max(200),
|
|
556
|
-
revision: z.number().int().positive(),
|
|
557
|
-
reason: z.enum(["UNASSIGN", "COMPROMISED", "REPLACED"]),
|
|
558
|
-
status: z.enum(["RETIREMENT_PENDING", "COMPROMISED", "READY_TO_FINALIZE", "FINALIZED"]),
|
|
559
|
-
requestedAt: EnrollmentInstantSchema,
|
|
560
|
-
serverRefreshStoppedAt: EnrollmentInstantSchema,
|
|
561
|
-
shortLivedCredentialsExpireAt: EnrollmentInstantSchema,
|
|
562
|
-
localDeleteStatus: z.enum(["NOT_REQUIRED", "PENDING", "ACKNOWLEDGED", "EXPIRED"]),
|
|
563
|
-
localDeleteAcknowledgedAt: EnrollmentInstantSchema.nullable(),
|
|
564
|
-
serverSecretsShreddedAt: EnrollmentInstantSchema.nullable(),
|
|
565
|
-
upstreamRevocationStatus: z.literal("UNKNOWN"),
|
|
566
|
-
safeToFinalizeAt: EnrollmentInstantSchema
|
|
567
|
-
});
|
|
568
|
-
export const CodexAssignmentRetirementLocalDeleteAckInputSchema = z.strictObject({
|
|
569
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
570
|
-
expectedRevision: z.number().int().positive(),
|
|
571
|
-
targets: z.array(z.strictObject({
|
|
572
|
-
lineageId: z.string().min(1).max(200),
|
|
573
|
-
generationVersion: z.number().int().positive()
|
|
574
|
-
})).min(1).max(1_000)
|
|
575
|
-
});
|
|
576
|
-
const CodexAssignmentRetirementLocalDeleteTargetSchema = z.strictObject({
|
|
577
|
-
lineageId: z.string().min(1).max(200),
|
|
578
|
-
generationVersion: z.number().int().positive()
|
|
579
|
-
});
|
|
580
|
-
export const CodexAssignmentRetirementPreflightResponseSchema = z.strictObject({
|
|
581
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
582
|
-
retirement: CodexAssignmentRetirementSchema,
|
|
583
|
-
allowedLocalDeleteTargets: z.array(CodexAssignmentRetirementLocalDeleteTargetSchema).max(1_000),
|
|
584
|
-
allowedActions: z.array(z.literal("ACKNOWLEDGE_LOCAL_DELETE")).max(1)
|
|
585
|
-
});
|
|
586
|
-
export const CodexAssignmentRetirementLocalDeleteAckResponseSchema = z.strictObject({
|
|
587
|
-
schemaVersion: z.literal(CODEX_ENROLLMENT_SCHEMA_VERSION),
|
|
588
|
-
retirement: CodexAssignmentRetirementSchema,
|
|
589
|
-
replayed: z.boolean()
|
|
590
|
-
});
|
|
591
344
|
const CodexV3InstantSchema = z.string().datetime({ offset: true });
|
|
592
345
|
const CodexV3IdSchema = z.string().min(1).max(255);
|
|
593
346
|
const CodexV3ClientRequestIdSchema = z.string().min(8).max(255)
|
|
@@ -895,6 +648,436 @@ export const CodexV5GenerationReportResponseSchema = z.strictObject({
|
|
|
895
648
|
message: "Generation did not advance exactly once." });
|
|
896
649
|
}
|
|
897
650
|
});
|
|
651
|
+
/**
|
|
652
|
+
* v6 makes one complete upstream token set the property of exactly one
|
|
653
|
+
* request/device binding. A request may own several bindings for the same
|
|
654
|
+
* user, but lineages and installation ids may never be shared by bindings.
|
|
655
|
+
*/
|
|
656
|
+
export const CodexV6DeviceDescriptorSchema = z.strictObject({
|
|
657
|
+
installationId: CodexV5InstallationIdSchema,
|
|
658
|
+
label: z.string().trim().min(1).max(128),
|
|
659
|
+
platform: z.enum(["darwin", "linux", "win32", "unknown"])
|
|
660
|
+
});
|
|
661
|
+
export const CodexV6AccountRequestStatusSchema = z.enum([
|
|
662
|
+
"SUBMITTED",
|
|
663
|
+
"APPROVED",
|
|
664
|
+
"REJECTED",
|
|
665
|
+
"CANCELLED",
|
|
666
|
+
"EXPIRED"
|
|
667
|
+
]);
|
|
668
|
+
export const CodexV6AccountRequestAvailabilitySchema = z.enum([
|
|
669
|
+
"PENDING_APPROVAL",
|
|
670
|
+
"WAITING_FOR_BINDING",
|
|
671
|
+
"PARTIALLY_AVAILABLE",
|
|
672
|
+
"AVAILABLE",
|
|
673
|
+
"UNAVAILABLE",
|
|
674
|
+
"EXPIRED"
|
|
675
|
+
]);
|
|
676
|
+
export const CodexV6AccountRequestSchema = z.strictObject({
|
|
677
|
+
id: CodexV3IdSchema,
|
|
678
|
+
userSubject: CodexV3IdSchema,
|
|
679
|
+
username: z.string().trim().min(1).max(255),
|
|
680
|
+
userEmail: z.email().nullable(),
|
|
681
|
+
status: CodexV6AccountRequestStatusSchema,
|
|
682
|
+
availability: CodexV6AccountRequestAvailabilitySchema,
|
|
683
|
+
reason: z.string().trim().min(5).max(1_000),
|
|
684
|
+
requestedDeviceCount: z.number().int().min(1).max(32),
|
|
685
|
+
approvedDeviceLimit: z.number().int().min(1).max(32).nullable(),
|
|
686
|
+
activeBindingCount: z.number().int().min(0).max(32),
|
|
687
|
+
pendingBindingCount: z.number().int().min(0).max(32),
|
|
688
|
+
requestedValidUntil: CodexV3InstantSchema,
|
|
689
|
+
validFrom: CodexV3InstantSchema.nullable(),
|
|
690
|
+
validUntil: CodexV3InstantSchema.nullable(),
|
|
691
|
+
version: z.number().int().nonnegative(),
|
|
692
|
+
createdAt: CodexV3InstantSchema,
|
|
693
|
+
submittedAt: CodexV3InstantSchema,
|
|
694
|
+
reviewedAt: CodexV3InstantSchema.nullable(),
|
|
695
|
+
safeErrorCode: z.string().min(1).max(128).regex(/^[a-z][a-z0-9_.-]*$/u).nullable(),
|
|
696
|
+
allowedActions: z.array(z.enum(["CANCEL", "CLAIM_DEVICE", "VIEW_BINDINGS"])).max(3)
|
|
697
|
+
}).superRefine((value, context) => {
|
|
698
|
+
const approved = ["APPROVED", "EXPIRED"].includes(value.status);
|
|
699
|
+
if (approved !== (value.approvedDeviceLimit !== null && value.validFrom !== null
|
|
700
|
+
&& value.validUntil !== null)) {
|
|
701
|
+
context.addIssue({ code: "custom", message: "Request approval evidence is inconsistent." });
|
|
702
|
+
}
|
|
703
|
+
if (value.approvedDeviceLimit !== null
|
|
704
|
+
&& value.activeBindingCount + value.pendingBindingCount > value.approvedDeviceLimit) {
|
|
705
|
+
context.addIssue({ code: "custom", message: "Request binding counts exceed the approved limit." });
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
export const CodexV6CreateAccountRequestInputSchema = z.strictObject({
|
|
709
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
710
|
+
clientRequestId: CodexV3ClientRequestIdSchema,
|
|
711
|
+
reason: z.string().trim().min(5).max(1_000),
|
|
712
|
+
requestedDeviceCount: z.number().int().min(1).max(32),
|
|
713
|
+
requestedValidUntil: CodexV3InstantSchema,
|
|
714
|
+
initialDevice: CodexV6DeviceDescriptorSchema
|
|
715
|
+
});
|
|
716
|
+
export const CodexV6AccountRequestResponseSchema = z.strictObject({
|
|
717
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
718
|
+
request: CodexV6AccountRequestSchema,
|
|
719
|
+
replayed: z.boolean()
|
|
720
|
+
});
|
|
721
|
+
export const CodexV6AccountRequestListResponseSchema = z.strictObject({
|
|
722
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
723
|
+
items: z.array(CodexV6AccountRequestSchema).max(256),
|
|
724
|
+
total: z.number().int().min(0).max(256)
|
|
725
|
+
}).superRefine((value, context) => {
|
|
726
|
+
if (value.items.length !== value.total) {
|
|
727
|
+
context.addIssue({ code: "custom", path: ["total"], message: "Request total is inconsistent." });
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
export const CodexV6AdminAccountRequestListQuerySchema = z.strictObject({
|
|
731
|
+
expiresBefore: CodexV3InstantSchema.optional(),
|
|
732
|
+
includeTerminal: z.boolean().optional()
|
|
733
|
+
});
|
|
734
|
+
export const CodexV6AdminReplacementCandidateQuerySchema = z.strictObject({
|
|
735
|
+
replaceBefore: CodexV3InstantSchema
|
|
736
|
+
});
|
|
737
|
+
export const CodexV6CancelAccountRequestInputSchema = z.strictObject({
|
|
738
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
739
|
+
expectedRequestVersion: z.number().int().nonnegative()
|
|
740
|
+
});
|
|
741
|
+
export const CodexV6AdminReviewAccountRequestInputSchema = z.strictObject({
|
|
742
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
743
|
+
expectedRequestVersion: z.number().int().nonnegative(),
|
|
744
|
+
decision: z.enum(["APPROVE", "REJECT"]),
|
|
745
|
+
reason: z.string().trim().min(5).max(1_000),
|
|
746
|
+
approvedDeviceLimit: z.number().int().min(1).max(32).nullable(),
|
|
747
|
+
validFrom: CodexV3InstantSchema.nullable(),
|
|
748
|
+
validUntil: CodexV3InstantSchema.nullable()
|
|
749
|
+
}).superRefine((value, context) => {
|
|
750
|
+
const approval = value.approvedDeviceLimit !== null && value.validFrom !== null
|
|
751
|
+
&& value.validUntil !== null;
|
|
752
|
+
if ((value.decision === "APPROVE") !== approval) {
|
|
753
|
+
context.addIssue({ code: "custom", message: "Approval decision fields are inconsistent." });
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
export const CodexV6DeviceBindingStatusSchema = z.enum([
|
|
757
|
+
"PENDING_TOKEN",
|
|
758
|
+
"READY",
|
|
759
|
+
"ACTIVE",
|
|
760
|
+
"REPLACEMENT_PENDING",
|
|
761
|
+
"NEEDS_REAUTH",
|
|
762
|
+
"RETIREMENT_PENDING",
|
|
763
|
+
"RETIRED"
|
|
764
|
+
]);
|
|
765
|
+
export const CodexV6DeviceBindingSchema = z.strictObject({
|
|
766
|
+
id: CodexV3IdSchema,
|
|
767
|
+
requestId: CodexV3IdSchema,
|
|
768
|
+
userSubject: CodexV3IdSchema,
|
|
769
|
+
installationId: CodexV5InstallationIdSchema,
|
|
770
|
+
deviceLabel: z.string().trim().min(1).max(128),
|
|
771
|
+
platform: z.enum(["darwin", "linux", "win32", "unknown"]),
|
|
772
|
+
source: z.enum([
|
|
773
|
+
"REQUEST_INITIAL",
|
|
774
|
+
"ADMIN_ADDED",
|
|
775
|
+
"LEGACY_AUTO_MIGRATED",
|
|
776
|
+
"ACCOUNT_REPLACEMENT"
|
|
777
|
+
]),
|
|
778
|
+
status: CodexV6DeviceBindingStatusSchema,
|
|
779
|
+
predecessorBindingId: CodexV3IdSchema.nullable(),
|
|
780
|
+
managedAccountId: CodexV3IdSchema.nullable(),
|
|
781
|
+
providerAccountId: z.string().min(1).max(512).nullable(),
|
|
782
|
+
poolEntryId: CodexV3IdSchema.nullable(),
|
|
783
|
+
credentialLineageId: CodexV3IdSchema.nullable(),
|
|
784
|
+
generationVersion: z.number().int().positive().nullable(),
|
|
785
|
+
credentialExpiresAt: CodexV3InstantSchema.nullable(),
|
|
786
|
+
accountExpiresAt: CodexV3InstantSchema.nullable(),
|
|
787
|
+
replacementDueAt: CodexV3InstantSchema.nullable(),
|
|
788
|
+
replacementReason: z.enum([
|
|
789
|
+
"SUBSCRIPTION_EXPIRING",
|
|
790
|
+
"CREDENTIAL_UNHEALTHY",
|
|
791
|
+
"ADMIN_REQUESTED"
|
|
792
|
+
]).nullable(),
|
|
793
|
+
accessTokenHealth: CodexV3AccessTokenHealthSchema,
|
|
794
|
+
refreshTokenHealth: CodexV3RefreshTokenHealthSchema,
|
|
795
|
+
legacyAssignmentId: CodexV3IdSchema.nullable(),
|
|
796
|
+
createdAt: CodexV3InstantSchema,
|
|
797
|
+
activatedAt: CodexV3InstantSchema.nullable(),
|
|
798
|
+
retiredAt: CodexV3InstantSchema.nullable()
|
|
799
|
+
}).superRefine((value, context) => {
|
|
800
|
+
const complete = [value.managedAccountId, value.providerAccountId, value.poolEntryId,
|
|
801
|
+
value.credentialLineageId, value.generationVersion, value.credentialExpiresAt]
|
|
802
|
+
.every((item) => item !== null);
|
|
803
|
+
if ((value.status === "PENDING_TOKEN") === complete) {
|
|
804
|
+
context.addIssue({ code: "custom", message: "Device binding credential evidence is inconsistent." });
|
|
805
|
+
}
|
|
806
|
+
if ((value.source === "LEGACY_AUTO_MIGRATED") !== (value.legacyAssignmentId !== null)) {
|
|
807
|
+
context.addIssue({ code: "custom", message: "Legacy migration evidence is inconsistent." });
|
|
808
|
+
}
|
|
809
|
+
if ((value.source === "ACCOUNT_REPLACEMENT") !== (value.predecessorBindingId !== null)) {
|
|
810
|
+
context.addIssue({ code: "custom", message: "Replacement predecessor evidence is inconsistent." });
|
|
811
|
+
}
|
|
812
|
+
const replacementEvidence = value.replacementDueAt !== null && value.replacementReason !== null;
|
|
813
|
+
if ((value.replacementDueAt !== null) !== (value.replacementReason !== null)
|
|
814
|
+
|| (value.status === "REPLACEMENT_PENDING" || value.source === "ACCOUNT_REPLACEMENT")
|
|
815
|
+
!== replacementEvidence) {
|
|
816
|
+
context.addIssue({ code: "custom", message: "Replacement timing evidence is inconsistent." });
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
export const CodexV6DeviceBindingListResponseSchema = z.strictObject({
|
|
820
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
821
|
+
items: z.array(CodexV6DeviceBindingSchema).max(32),
|
|
822
|
+
total: z.number().int().min(0).max(32)
|
|
823
|
+
}).superRefine((value, context) => {
|
|
824
|
+
if (value.items.length !== value.total
|
|
825
|
+
|| new Set(value.items.map(({ id }) => id)).size !== value.items.length
|
|
826
|
+
|| new Set(value.items.filter(({ credentialLineageId }) => credentialLineageId !== null)
|
|
827
|
+
.map(({ credentialLineageId }) => credentialLineageId)).size
|
|
828
|
+
!== value.items.filter(({ credentialLineageId }) => credentialLineageId !== null).length) {
|
|
829
|
+
context.addIssue({ code: "custom", message: "Device bindings are duplicated or incomplete." });
|
|
830
|
+
}
|
|
831
|
+
const byId = new Map(value.items.map((item) => [item.id, item]));
|
|
832
|
+
const successors = new Set();
|
|
833
|
+
for (const item of value.items) {
|
|
834
|
+
if (item.predecessorBindingId === null)
|
|
835
|
+
continue;
|
|
836
|
+
const predecessor = byId.get(item.predecessorBindingId);
|
|
837
|
+
if (!predecessor || predecessor.installationId !== item.installationId
|
|
838
|
+
|| predecessor.requestId !== item.requestId || predecessor.userSubject !== item.userSubject
|
|
839
|
+
|| successors.has(predecessor.id)) {
|
|
840
|
+
context.addIssue({ code: "custom", message: "Replacement binding chain is inconsistent." });
|
|
841
|
+
break;
|
|
842
|
+
}
|
|
843
|
+
successors.add(predecessor.id);
|
|
844
|
+
}
|
|
845
|
+
const activeByInstallation = new Map();
|
|
846
|
+
for (const item of value.items.filter(({ status }) => status !== "RETIRED")) {
|
|
847
|
+
activeByInstallation.set(item.installationId, [...(activeByInstallation.get(item.installationId) ?? []), item]);
|
|
848
|
+
}
|
|
849
|
+
for (const items of activeByInstallation.values()) {
|
|
850
|
+
if (items.length > 2 || items.length === 2 && !items.some(({ status }) => status === "REPLACEMENT_PENDING") || items.length === 2 && !items.some(({ source }) => source === "ACCOUNT_REPLACEMENT")) {
|
|
851
|
+
context.addIssue({ code: "custom", message: "Installation has conflicting active bindings." });
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
export const CodexV6AdminReplacementCandidateListResponseSchema = z.strictObject({
|
|
857
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
858
|
+
items: z.array(z.strictObject({
|
|
859
|
+
request: CodexV6AccountRequestSchema,
|
|
860
|
+
binding: CodexV6DeviceBindingSchema,
|
|
861
|
+
recommendedReason: z.enum([
|
|
862
|
+
"SUBSCRIPTION_EXPIRING",
|
|
863
|
+
"CREDENTIAL_UNHEALTHY",
|
|
864
|
+
"ADMIN_REQUESTED"
|
|
865
|
+
]),
|
|
866
|
+
replaceBefore: CodexV3InstantSchema
|
|
867
|
+
})).max(256),
|
|
868
|
+
total: z.number().int().min(0).max(256)
|
|
869
|
+
}).superRefine((value, context) => {
|
|
870
|
+
if (value.items.length !== value.total || value.items.some(({ request, binding }) => binding.requestId !== request.id || binding.userSubject !== request.userSubject
|
|
871
|
+
|| !["ACTIVE", "NEEDS_REAUTH"].includes(binding.status))) {
|
|
872
|
+
context.addIssue({ code: "custom", message: "Replacement candidates are inconsistent." });
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
const CodexV6LegacyDeviceEvidenceSchema = z.strictObject({
|
|
876
|
+
assignmentId: CodexV3IdSchema,
|
|
877
|
+
managedAccountId: CodexV3IdSchema,
|
|
878
|
+
providerAccountId: z.string().min(1).max(512),
|
|
879
|
+
lineageId: CodexV3IdSchema,
|
|
880
|
+
generationVersion: z.number().int().positive()
|
|
881
|
+
});
|
|
882
|
+
export const CodexV6ReconcileDeviceAccessInputSchema = z.strictObject({
|
|
883
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
884
|
+
clientRequestId: CodexV3ClientRequestIdSchema,
|
|
885
|
+
device: CodexV6DeviceDescriptorSchema,
|
|
886
|
+
legacy: CodexV6LegacyDeviceEvidenceSchema.nullable()
|
|
887
|
+
});
|
|
888
|
+
export const CodexV6ReconcileDeviceAccessResponseSchema = z.strictObject({
|
|
889
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
890
|
+
accessStatus: z.enum([
|
|
891
|
+
"AVAILABLE",
|
|
892
|
+
"REQUEST_REQUIRED",
|
|
893
|
+
"REQUEST_PENDING",
|
|
894
|
+
"DEVICE_BINDING_REQUIRED",
|
|
895
|
+
"TOKEN_PENDING",
|
|
896
|
+
"REQUEST_EXPIRED",
|
|
897
|
+
"UNAVAILABLE"
|
|
898
|
+
]),
|
|
899
|
+
request: CodexV6AccountRequestSchema.nullable(),
|
|
900
|
+
binding: CodexV6DeviceBindingSchema.nullable(),
|
|
901
|
+
replacementBinding: CodexV6DeviceBindingSchema.nullable(),
|
|
902
|
+
migration: z.enum([
|
|
903
|
+
"NONE",
|
|
904
|
+
"AUTO_MIGRATED",
|
|
905
|
+
"ALREADY_MIGRATED",
|
|
906
|
+
"ADDITIONAL_DEVICE_DETECTED"
|
|
907
|
+
]),
|
|
908
|
+
guidanceCode: z.enum([
|
|
909
|
+
"account_request_required",
|
|
910
|
+
"account_request_pending",
|
|
911
|
+
"device_binding_admin_required",
|
|
912
|
+
"device_token_pending",
|
|
913
|
+
"account_request_expired",
|
|
914
|
+
"account_unavailable"
|
|
915
|
+
]).nullable(),
|
|
916
|
+
replayed: z.boolean()
|
|
917
|
+
}).superRefine((value, context) => {
|
|
918
|
+
if (value.accessStatus === "AVAILABLE" && (value.request === null || value.binding === null
|
|
919
|
+
|| !["READY", "ACTIVE", "REPLACEMENT_PENDING"].includes(value.binding.status))) {
|
|
920
|
+
context.addIssue({ code: "custom", message: "Available device access lacks an active binding." });
|
|
921
|
+
}
|
|
922
|
+
if (value.accessStatus === "DEVICE_BINDING_REQUIRED"
|
|
923
|
+
&& value.guidanceCode !== "device_binding_admin_required") {
|
|
924
|
+
context.addIssue({ code: "custom", message: "Unbound devices must receive administrator guidance." });
|
|
925
|
+
}
|
|
926
|
+
if (value.replacementBinding !== null && (value.request === null || value.binding === null
|
|
927
|
+
|| value.binding.status !== "REPLACEMENT_PENDING"
|
|
928
|
+
|| value.replacementBinding.status !== "READY"
|
|
929
|
+
|| value.replacementBinding.source !== "ACCOUNT_REPLACEMENT"
|
|
930
|
+
|| value.replacementBinding.predecessorBindingId !== value.binding.id
|
|
931
|
+
|| value.replacementBinding.requestId !== value.binding.requestId
|
|
932
|
+
|| value.replacementBinding.userSubject !== value.binding.userSubject
|
|
933
|
+
|| value.replacementBinding.installationId !== value.binding.installationId
|
|
934
|
+
|| value.replacementBinding.credentialLineageId === value.binding.credentialLineageId
|
|
935
|
+
|| value.replacementBinding.poolEntryId === value.binding.poolEntryId)) {
|
|
936
|
+
context.addIssue({ code: "custom", message: "Ready replacement binding is inconsistent." });
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
export const CodexV6AdminCreateDeviceBindingInputSchema = z.strictObject({
|
|
940
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
941
|
+
expectedRequestVersion: z.number().int().nonnegative(),
|
|
942
|
+
device: CodexV6DeviceDescriptorSchema,
|
|
943
|
+
poolEntryId: CodexV3IdSchema.nullable()
|
|
944
|
+
});
|
|
945
|
+
export const CodexV6AdminCreateDeviceBindingResponseSchema = z.strictObject({
|
|
946
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
947
|
+
request: CodexV6AccountRequestSchema,
|
|
948
|
+
binding: CodexV6DeviceBindingSchema,
|
|
949
|
+
replayed: z.boolean()
|
|
950
|
+
});
|
|
951
|
+
export const CodexV6AdminReplaceDeviceTokenInputSchema = z.strictObject({
|
|
952
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
953
|
+
expectedRequestVersion: z.number().int().nonnegative(),
|
|
954
|
+
reason: z.enum([
|
|
955
|
+
"SUBSCRIPTION_EXPIRING",
|
|
956
|
+
"CREDENTIAL_UNHEALTHY",
|
|
957
|
+
"ADMIN_REQUESTED"
|
|
958
|
+
]),
|
|
959
|
+
replaceBefore: CodexV3InstantSchema,
|
|
960
|
+
poolEntryId: CodexV3IdSchema.nullable()
|
|
961
|
+
});
|
|
962
|
+
export const CodexV6AdminReplaceDeviceTokenResponseSchema = z.strictObject({
|
|
963
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
964
|
+
request: CodexV6AccountRequestSchema,
|
|
965
|
+
currentBinding: CodexV6DeviceBindingSchema,
|
|
966
|
+
replacementBinding: CodexV6DeviceBindingSchema,
|
|
967
|
+
replayed: z.boolean()
|
|
968
|
+
}).superRefine((value, context) => {
|
|
969
|
+
if (value.currentBinding.requestId !== value.request.id
|
|
970
|
+
|| value.currentBinding.userSubject !== value.request.userSubject
|
|
971
|
+
|| value.currentBinding.status !== "REPLACEMENT_PENDING"
|
|
972
|
+
|| value.replacementBinding.requestId !== value.request.id
|
|
973
|
+
|| value.replacementBinding.userSubject !== value.request.userSubject
|
|
974
|
+
|| value.replacementBinding.source !== "ACCOUNT_REPLACEMENT"
|
|
975
|
+
|| value.replacementBinding.predecessorBindingId !== value.currentBinding.id
|
|
976
|
+
|| value.replacementBinding.installationId !== value.currentBinding.installationId
|
|
977
|
+
|| value.replacementBinding.poolEntryId !== null
|
|
978
|
+
&& value.replacementBinding.poolEntryId === value.currentBinding.poolEntryId
|
|
979
|
+
|| value.replacementBinding.credentialLineageId !== null
|
|
980
|
+
&& value.replacementBinding.credentialLineageId === value.currentBinding.credentialLineageId) {
|
|
981
|
+
context.addIssue({ code: "custom", message: "Replacement response identities are inconsistent." });
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
export const CodexV6FullCredentialDeliveryInputSchema = z.strictObject({
|
|
985
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
986
|
+
clientRequestId: CodexV3ClientRequestIdSchema,
|
|
987
|
+
installationId: CodexV5InstallationIdSchema,
|
|
988
|
+
clientKey: CodexShortLivedDeliveryClientKeySchema
|
|
989
|
+
});
|
|
990
|
+
const CodexV6FullCredentialDeliveryMetadataSchema = z.strictObject({
|
|
991
|
+
id: CodexV3IdSchema,
|
|
992
|
+
clientRequestId: CodexV3ClientRequestIdSchema,
|
|
993
|
+
requestId: CodexV3IdSchema,
|
|
994
|
+
bindingId: CodexV3IdSchema,
|
|
995
|
+
installationId: CodexV5InstallationIdSchema,
|
|
996
|
+
managedAccountId: CodexV3IdSchema,
|
|
997
|
+
providerAccountId: z.string().min(1).max(512),
|
|
998
|
+
credentialLineageId: CodexV3IdSchema,
|
|
999
|
+
generationVersion: z.number().int().positive(),
|
|
1000
|
+
status: z.enum(["AWAITING_ACK", "ACKED", "EXPIRED"]),
|
|
1001
|
+
issuedAt: CodexV3InstantSchema,
|
|
1002
|
+
credentialExpiresAt: CodexV3InstantSchema,
|
|
1003
|
+
ackExpiresAt: CodexV3InstantSchema,
|
|
1004
|
+
ackedAt: CodexV3InstantSchema.nullable()
|
|
1005
|
+
});
|
|
1006
|
+
export const CodexV6FullCredentialDeliveryResponseSchema = z.strictObject({
|
|
1007
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
1008
|
+
delivery: CodexV6FullCredentialDeliveryMetadataSchema.extend({
|
|
1009
|
+
status: z.literal("AWAITING_ACK"),
|
|
1010
|
+
envelope: CodexShortLivedDeliveryEnvelopeSchema
|
|
1011
|
+
}),
|
|
1012
|
+
replayed: z.boolean()
|
|
1013
|
+
});
|
|
1014
|
+
export const CodexV6FullCredentialBundleSchema = z.strictObject({
|
|
1015
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
1016
|
+
deliveryId: CodexV3IdSchema,
|
|
1017
|
+
requestId: CodexV3IdSchema,
|
|
1018
|
+
bindingId: CodexV3IdSchema,
|
|
1019
|
+
installationId: CodexV5InstallationIdSchema,
|
|
1020
|
+
managedAccountId: CodexV3IdSchema,
|
|
1021
|
+
providerAccountId: z.string().min(1).max(512),
|
|
1022
|
+
credentialLineageId: CodexV3IdSchema,
|
|
1023
|
+
generationVersion: z.number().int().positive(),
|
|
1024
|
+
refreshToken: z.string().min(1).max(65_536),
|
|
1025
|
+
accessToken: z.string().min(1).max(65_536),
|
|
1026
|
+
idToken: z.string().min(1).max(65_536),
|
|
1027
|
+
expiresAt: CodexV3InstantSchema
|
|
1028
|
+
});
|
|
1029
|
+
export const CodexV6AcknowledgeFullCredentialDeliveryInputSchema = z.strictObject({
|
|
1030
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
1031
|
+
installationId: CodexV5InstallationIdSchema,
|
|
1032
|
+
credentialLineageId: CodexV3IdSchema,
|
|
1033
|
+
generationVersion: z.number().int().positive(),
|
|
1034
|
+
installed: z.literal(true)
|
|
1035
|
+
});
|
|
1036
|
+
export const CodexV6AcknowledgeFullCredentialDeliveryResponseSchema = z.strictObject({
|
|
1037
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
1038
|
+
delivery: CodexV6FullCredentialDeliveryMetadataSchema.extend({
|
|
1039
|
+
status: z.literal("ACKED"),
|
|
1040
|
+
ackedAt: CodexV3InstantSchema
|
|
1041
|
+
}),
|
|
1042
|
+
replayed: z.boolean()
|
|
1043
|
+
});
|
|
1044
|
+
export const CodexV6GenerationReportInputSchema = z.strictObject({
|
|
1045
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
1046
|
+
clientRequestId: CodexV3ClientRequestIdSchema,
|
|
1047
|
+
bindingId: CodexV3IdSchema,
|
|
1048
|
+
installationId: CodexV5InstallationIdSchema,
|
|
1049
|
+
expectedGenerationVersion: z.number().int().positive(),
|
|
1050
|
+
rotationMode: z.enum(["ROTATED", "RETAINED"]),
|
|
1051
|
+
envelope: CodexV3CredentialEnvelopeSchema,
|
|
1052
|
+
accessTokenHealth: CodexV3AccessTokenHealthSchema,
|
|
1053
|
+
refreshTokenHealth: CodexV3RefreshTokenHealthSchema,
|
|
1054
|
+
observedAt: CodexV3InstantSchema
|
|
1055
|
+
});
|
|
1056
|
+
export const CodexV6GenerationReportResponseSchema = z.strictObject({
|
|
1057
|
+
schemaVersion: z.literal(CODEX_REQUEST_BOUND_DEVICE_V6_SCHEMA_VERSION),
|
|
1058
|
+
report: z.strictObject({
|
|
1059
|
+
id: CodexV3IdSchema,
|
|
1060
|
+
clientRequestId: CodexV3ClientRequestIdSchema,
|
|
1061
|
+
requestId: CodexV3IdSchema,
|
|
1062
|
+
bindingId: CodexV3IdSchema,
|
|
1063
|
+
installationId: CodexV5InstallationIdSchema,
|
|
1064
|
+
credentialLineageId: CodexV3IdSchema,
|
|
1065
|
+
previousGenerationVersion: z.number().int().positive(),
|
|
1066
|
+
generationVersion: z.number().int().positive(),
|
|
1067
|
+
rotationMode: z.enum(["ROTATED", "RETAINED"]),
|
|
1068
|
+
accessTokenHealth: CodexV3AccessTokenHealthSchema,
|
|
1069
|
+
refreshTokenHealth: CodexV3RefreshTokenHealthSchema,
|
|
1070
|
+
credentialExpiresAt: CodexV3InstantSchema,
|
|
1071
|
+
observedAt: CodexV3InstantSchema,
|
|
1072
|
+
status: z.literal("APPLIED")
|
|
1073
|
+
}),
|
|
1074
|
+
replayed: z.boolean()
|
|
1075
|
+
}).superRefine((value, context) => {
|
|
1076
|
+
if (value.report.generationVersion !== value.report.previousGenerationVersion + 1) {
|
|
1077
|
+
context.addIssue({ code: "custom", path: ["report", "generationVersion"],
|
|
1078
|
+
message: "Generation did not advance exactly once." });
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
898
1081
|
export const CodexV4AccessObservationStateSchema = z.enum([
|
|
899
1082
|
"VALID", "EXPIRING", "EXPIRED", "INVALID"
|
|
900
1083
|
]);
|
|
@@ -1026,28 +1209,6 @@ export function codexAdminRenewPath(accountId) {
|
|
|
1026
1209
|
export function codexAdminAssignmentPath(assignmentId) {
|
|
1027
1210
|
return `${CODEX_ADMIN_ASSIGNMENTS_PATH}/${encodeURIComponent(assignmentId)}`;
|
|
1028
1211
|
}
|
|
1029
|
-
export function codexAdminEnrollmentIntentPath(intentId) {
|
|
1030
|
-
return `${CODEX_ADMIN_ENROLLMENT_INTENTS_PATH}/${encodeURIComponent(intentId)}`;
|
|
1031
|
-
}
|
|
1032
|
-
export function codexAdminEnrollmentIntentActionPath(intentId, action) {
|
|
1033
|
-
return `${codexAdminEnrollmentIntentPath(intentId)}/${action}`;
|
|
1034
|
-
}
|
|
1035
|
-
export function codexAdminMigrationLoginQueuePath(planId, query) {
|
|
1036
|
-
return `${CODEX_ADMIN_MIGRATION_PLANS_PATH}/${encodeURIComponent(planId)}`
|
|
1037
|
-
+ `/login-queue?page=${query.page}&pageSize=${query.pageSize}`;
|
|
1038
|
-
}
|
|
1039
|
-
export function codexAssignmentShortLivedDeliveriesPath(assignmentId) {
|
|
1040
|
-
return `${CODEX_CREDENTIAL_ASSIGNMENTS_PATH}/${encodeURIComponent(assignmentId)}/short-lived-credential-deliveries`;
|
|
1041
|
-
}
|
|
1042
|
-
export function codexShortLivedDeliveryAckPath(deliveryId) {
|
|
1043
|
-
return `${CODEX_SHORT_LIVED_DELIVERIES_PATH}/${encodeURIComponent(deliveryId)}/ack`;
|
|
1044
|
-
}
|
|
1045
|
-
export function codexAssignmentRetirementLocalDeleteAckPath(retirementId) {
|
|
1046
|
-
return `${CODEX_ASSIGNMENT_RETIREMENTS_PATH}/${encodeURIComponent(retirementId)}/local-delete-ack`;
|
|
1047
|
-
}
|
|
1048
|
-
export function codexAssignmentRetirementPath(retirementId) {
|
|
1049
|
-
return `${CODEX_ASSIGNMENT_RETIREMENTS_PATH}/${encodeURIComponent(retirementId)}`;
|
|
1050
|
-
}
|
|
1051
1212
|
export function codexV3EnrollmentResolvePath(clientRequestId) {
|
|
1052
1213
|
return `${CODEX_V3_ENROLLMENTS_PATH}/resolve?clientRequestId=${encodeURIComponent(clientRequestId)}`;
|
|
1053
1214
|
}
|
|
@@ -1085,6 +1246,62 @@ export function codexV5DeviceSessionActionPath(sessionId, action) {
|
|
|
1085
1246
|
export function codexV5LineageGenerationReportsPath(lineageId) {
|
|
1086
1247
|
return `${CODEX_MULTI_DEVICE_V5_CREDENTIAL_LINEAGES_PATH}/${encodeURIComponent(lineageId)}/generations/report`;
|
|
1087
1248
|
}
|
|
1249
|
+
export function codexV6AccountRequestPath(requestId) {
|
|
1250
|
+
return `${CODEX_V6_ACCOUNT_REQUESTS_PATH}/${encodeURIComponent(requestId)}`;
|
|
1251
|
+
}
|
|
1252
|
+
export function codexV6AccountRequestActionPath(requestId, action) {
|
|
1253
|
+
return `${codexV6AccountRequestPath(requestId)}/${action}`;
|
|
1254
|
+
}
|
|
1255
|
+
export function codexV6AccountRequestDeviceBindingsPath(requestId) {
|
|
1256
|
+
return `${codexV6AccountRequestPath(requestId)}/device-bindings`;
|
|
1257
|
+
}
|
|
1258
|
+
export function codexV6AdminAccountRequestDeviceBindingsPath(requestId) {
|
|
1259
|
+
return `${CODEX_V6_ADMIN_ACCOUNT_REQUESTS_PATH}/${encodeURIComponent(requestId)}/device-bindings`;
|
|
1260
|
+
}
|
|
1261
|
+
export function codexV6AdminDeviceBindingReplacementPath(requestId, bindingId) {
|
|
1262
|
+
return `${codexV6AdminAccountRequestDeviceBindingsPath(requestId)}/`
|
|
1263
|
+
+ `${encodeURIComponent(bindingId)}/replacement`;
|
|
1264
|
+
}
|
|
1265
|
+
export function codexV6AdminAccountRequestPath(requestId) {
|
|
1266
|
+
return `${CODEX_V6_ADMIN_ACCOUNT_REQUESTS_PATH}/${encodeURIComponent(requestId)}`;
|
|
1267
|
+
}
|
|
1268
|
+
export function codexV6AdminAccountRequestsPath(query = {}) {
|
|
1269
|
+
const parsed = CodexV6AdminAccountRequestListQuerySchema.parse(query);
|
|
1270
|
+
const parameters = new URLSearchParams();
|
|
1271
|
+
if (parsed.expiresBefore)
|
|
1272
|
+
parameters.set("expiresBefore", parsed.expiresBefore);
|
|
1273
|
+
if (parsed.includeTerminal !== undefined) {
|
|
1274
|
+
parameters.set("includeTerminal", String(parsed.includeTerminal));
|
|
1275
|
+
}
|
|
1276
|
+
const suffix = parameters.toString();
|
|
1277
|
+
return `${CODEX_V6_ADMIN_ACCOUNT_REQUESTS_PATH}${suffix ? `?${suffix}` : ""}`;
|
|
1278
|
+
}
|
|
1279
|
+
export function codexV6AdminReplacementCandidatesPath(query) {
|
|
1280
|
+
const parsed = CodexV6AdminReplacementCandidateQuerySchema.parse(query);
|
|
1281
|
+
return `${CODEX_V6_ADMIN_DEVICE_BINDINGS_PATH}/replacement-candidates`
|
|
1282
|
+
+ `?replaceBefore=${encodeURIComponent(parsed.replaceBefore)}`;
|
|
1283
|
+
}
|
|
1284
|
+
export function codexV6AdminAccountRequestReviewPath(requestId) {
|
|
1285
|
+
return `${codexV6AdminAccountRequestPath(requestId)}/review`;
|
|
1286
|
+
}
|
|
1287
|
+
export function codexV6DeviceBindingFullCredentialDeliveriesPath(bindingId) {
|
|
1288
|
+
return `${CODEX_V6_DEVICE_BINDINGS_PATH}/${encodeURIComponent(bindingId)}/full-credential-deliveries`;
|
|
1289
|
+
}
|
|
1290
|
+
export function codexV6DeviceBindingFullCredentialDeliveryResolvePath(bindingId, clientRequestId) {
|
|
1291
|
+
return `${codexV6DeviceBindingFullCredentialDeliveriesPath(bindingId)}`
|
|
1292
|
+
+ `/resolve?clientRequestId=${encodeURIComponent(clientRequestId)}`;
|
|
1293
|
+
}
|
|
1294
|
+
export function codexV6FullCredentialDeliveryAckPath(deliveryId) {
|
|
1295
|
+
return `${CODEX_REQUEST_BOUND_DEVICE_V6_RUNTIME_PATH}/full-credential-deliveries/`
|
|
1296
|
+
+ `${encodeURIComponent(deliveryId)}/ack`;
|
|
1297
|
+
}
|
|
1298
|
+
export function codexV6BindingGenerationReportsPath(bindingId) {
|
|
1299
|
+
return `${CODEX_V6_DEVICE_BINDINGS_PATH}/${encodeURIComponent(bindingId)}/generations/report`;
|
|
1300
|
+
}
|
|
1301
|
+
export function codexV6BindingGenerationReportResolvePath(bindingId, clientRequestId) {
|
|
1302
|
+
return `${CODEX_V6_DEVICE_BINDINGS_PATH}/${encodeURIComponent(bindingId)}`
|
|
1303
|
+
+ `/generations/resolve?clientRequestId=${encodeURIComponent(clientRequestId)}`;
|
|
1304
|
+
}
|
|
1088
1305
|
export function codexTokenPoolV4DirectoryResolvePath(principal) {
|
|
1089
1306
|
return `${CODEX_TOKEN_POOL_V4_DIRECTORY_RESOLVE_PATH}?principal=${encodeURIComponent(principal)}`;
|
|
1090
1307
|
}
|