@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
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { CodexServiceClient } from "./client.js";
|
|
2
|
-
import { executeCodexEnrollmentLogin } from "./enrollment-flow.js";
|
|
3
|
-
import { CODEX_MIGRATION_CAPACITY, type CodexEnrollmentCandidateResponse, type CodexMigrationLoginQueueResponse, type CodexMigrationPlanStatus, type CodexMigrationTarget } from "./protocol.js";
|
|
4
|
-
type MigrationBatchClient = Pick<CodexServiceClient, "listMigrationLoginQueue" | "getEnrollmentIntent" | "claimEnrollmentIntent" | "heartbeatEnrollmentIntent" | "uploadEnrollmentCandidate">;
|
|
5
|
-
type EnrollmentExecutor = typeof executeCodexEnrollmentLogin;
|
|
6
|
-
export type CodexMigrationBatchStopReason = "DRY_RUN" | "QUEUE_EXHAUSTED" | "PAUSED" | "CANCELLED" | "COMPLETED" | "TARGET_UNCERTAIN" | "AUTHENTICATION_ERROR" | "SERVICE_ERROR" | "LOGIN_ERROR";
|
|
7
|
-
export interface CodexMigrationLoginBatchItemResult {
|
|
8
|
-
targetId: string;
|
|
9
|
-
assignmentId: string;
|
|
10
|
-
intentId: string | null;
|
|
11
|
-
requestedAction: "LOGIN" | "VIEW_ENROLLMENT" | "NONE";
|
|
12
|
-
action: "LOGIN" | "SKIP";
|
|
13
|
-
status: "PLANNED" | "COMPLETED" | "FAILED" | "SKIPPED";
|
|
14
|
-
outcome?: CodexEnrollmentCandidateResponse["result"]["outcome"];
|
|
15
|
-
intentStatus?: CodexEnrollmentCandidateResponse["intent"]["status"];
|
|
16
|
-
safeErrorCode?: string | null;
|
|
17
|
-
skipReason?: "VIEW_ENROLLMENT" | "ALREADY_USER_BOUND" | "NO_ACTION";
|
|
18
|
-
}
|
|
19
|
-
export interface CodexMigrationLoginBatchResult {
|
|
20
|
-
schemaVersion: 2;
|
|
21
|
-
plan: {
|
|
22
|
-
id: string;
|
|
23
|
-
status: CodexMigrationPlanStatus;
|
|
24
|
-
revision: number;
|
|
25
|
-
accountId: string;
|
|
26
|
-
sequentialRequired: true;
|
|
27
|
-
};
|
|
28
|
-
capacity: typeof CODEX_MIGRATION_CAPACITY;
|
|
29
|
-
dryRun: boolean;
|
|
30
|
-
stopReason: CodexMigrationBatchStopReason;
|
|
31
|
-
counts: {
|
|
32
|
-
observed: number;
|
|
33
|
-
plannedLogins: number;
|
|
34
|
-
attempted: number;
|
|
35
|
-
completed: number;
|
|
36
|
-
failed: number;
|
|
37
|
-
skipped: number;
|
|
38
|
-
};
|
|
39
|
-
items: CodexMigrationLoginBatchItemResult[];
|
|
40
|
-
}
|
|
41
|
-
interface QueueSnapshot {
|
|
42
|
-
plan: CodexMigrationLoginQueueResponse["plan"];
|
|
43
|
-
items: CodexMigrationTarget[];
|
|
44
|
-
}
|
|
45
|
-
/** Loads all pages and rejects a mixed-revision snapshot instead of reordering targets. */
|
|
46
|
-
export declare function loadCodexMigrationLoginQueueSnapshot(input: {
|
|
47
|
-
client: Pick<MigrationBatchClient, "listMigrationLoginQueue">;
|
|
48
|
-
planId: string;
|
|
49
|
-
pageSize?: number;
|
|
50
|
-
maxSnapshotAttempts?: number;
|
|
51
|
-
}): Promise<QueueSnapshot>;
|
|
52
|
-
/**
|
|
53
|
-
* Executes at most one isolated official login at a time. The queue is fetched
|
|
54
|
-
* again after every handled target so pause/cancel/completion takes effect before
|
|
55
|
-
* another refresh token can be generated.
|
|
56
|
-
*/
|
|
57
|
-
export declare function executeCodexMigrationLoginBatch(input: {
|
|
58
|
-
client: MigrationBatchClient;
|
|
59
|
-
tenantId: string;
|
|
60
|
-
planId: string;
|
|
61
|
-
deviceAuth?: boolean;
|
|
62
|
-
dryRun?: boolean;
|
|
63
|
-
pageSize?: number;
|
|
64
|
-
executeEnrollment?: EnrollmentExecutor;
|
|
65
|
-
}): Promise<CodexMigrationLoginBatchResult>;
|
|
66
|
-
export {};
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { executeCodexEnrollmentLogin } from "./enrollment-flow.js";
|
|
2
|
-
import { CodexServiceError } from "./errors.js";
|
|
3
|
-
import { CODEX_MIGRATION_CAPACITY } from "./protocol.js";
|
|
4
|
-
/** Loads all pages and rejects a mixed-revision snapshot instead of reordering targets. */
|
|
5
|
-
export async function loadCodexMigrationLoginQueueSnapshot(input) {
|
|
6
|
-
const pageSize = input.pageSize ?? 100;
|
|
7
|
-
const maxAttempts = input.maxSnapshotAttempts ?? 3;
|
|
8
|
-
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
9
|
-
const first = await input.client.listMigrationLoginQueue(input.planId, { page: 1, pageSize });
|
|
10
|
-
if (first.plan.status !== "ACTIVE" || first.total <= first.items.length) {
|
|
11
|
-
return { plan: first.plan, items: uniqueQueueItems(first.items, first.total) };
|
|
12
|
-
}
|
|
13
|
-
const items = [...first.items];
|
|
14
|
-
let stable = true;
|
|
15
|
-
const pageCount = Math.ceil(first.total / pageSize);
|
|
16
|
-
for (let page = 2; page <= pageCount; page += 1) {
|
|
17
|
-
const next = await input.client.listMigrationLoginQueue(input.planId, { page, pageSize });
|
|
18
|
-
if (!samePlanProjection(first.plan, next.plan) || next.total !== first.total) {
|
|
19
|
-
stable = false;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
items.push(...next.items);
|
|
23
|
-
}
|
|
24
|
-
if (stable && items.length === first.total) {
|
|
25
|
-
return { plan: first.plan, items: uniqueQueueItems(items, first.total) };
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
throw new CodexServiceError("Migration login queue changed while it was being paged; retry from a fresh snapshot.", "migration_queue_changed", 409);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Executes at most one isolated official login at a time. The queue is fetched
|
|
32
|
-
* again after every handled target so pause/cancel/completion takes effect before
|
|
33
|
-
* another refresh token can be generated.
|
|
34
|
-
*/
|
|
35
|
-
export async function executeCodexMigrationLoginBatch(input) {
|
|
36
|
-
const executeEnrollment = input.executeEnrollment ?? executeCodexEnrollmentLogin;
|
|
37
|
-
const handledTargets = new Set();
|
|
38
|
-
const items = [];
|
|
39
|
-
let latest = await loadCodexMigrationLoginQueueSnapshot(input);
|
|
40
|
-
if (input.dryRun) {
|
|
41
|
-
if (latest.plan.status === "ACTIVE") {
|
|
42
|
-
for (const target of latest.items)
|
|
43
|
-
items.push(dryRunItem(target));
|
|
44
|
-
}
|
|
45
|
-
return result(latest.plan, true, latest.plan.status === "ACTIVE"
|
|
46
|
-
? "DRY_RUN" : planStopReason(latest.plan.status), items);
|
|
47
|
-
}
|
|
48
|
-
while (true) {
|
|
49
|
-
const stopped = planStopReason(latest.plan.status);
|
|
50
|
-
if (stopped !== "QUEUE_EXHAUSTED")
|
|
51
|
-
return result(latest.plan, false, stopped, items);
|
|
52
|
-
const target = latest.items.find((candidate) => !handledTargets.has(candidate.id));
|
|
53
|
-
if (!target)
|
|
54
|
-
return result(latest.plan, false, "QUEUE_EXHAUSTED", items);
|
|
55
|
-
handledTargets.add(target.id);
|
|
56
|
-
const resumableClaim = target.allowedAction === "VIEW_ENROLLMENT"
|
|
57
|
-
&& target.enrollmentIntent !== null
|
|
58
|
-
&& ["CLAIMED", "LOGIN_IN_PROGRESS"].includes(target.enrollmentIntent.status);
|
|
59
|
-
if (target.allowedAction !== "LOGIN" && !resumableClaim) {
|
|
60
|
-
items.push(skippedItem(target));
|
|
61
|
-
latest = await loadCodexMigrationLoginQueueSnapshot(input);
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (!target.enrollmentIntent || (!resumableClaim && target.enrollmentIntent.status !== "AWAITING_CLI")) {
|
|
65
|
-
items.push({
|
|
66
|
-
...baseItem(target),
|
|
67
|
-
action: "LOGIN",
|
|
68
|
-
status: "FAILED",
|
|
69
|
-
safeErrorCode: "invalid_migration_login_target"
|
|
70
|
-
});
|
|
71
|
-
return result(latest.plan, false, "SERVICE_ERROR", items);
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
const response = await executeEnrollment({
|
|
75
|
-
client: input.client,
|
|
76
|
-
tenantId: input.tenantId,
|
|
77
|
-
intentId: target.enrollmentIntent.id,
|
|
78
|
-
deviceAuth: input.deviceAuth,
|
|
79
|
-
requireInitialAwaitingCli: true,
|
|
80
|
-
resumeClaimedIntent: resumableClaim
|
|
81
|
-
});
|
|
82
|
-
items.push({
|
|
83
|
-
...baseItem(target),
|
|
84
|
-
action: "LOGIN",
|
|
85
|
-
status: response.result.outcome === "READY" ? "COMPLETED" : "FAILED",
|
|
86
|
-
outcome: response.result.outcome,
|
|
87
|
-
intentStatus: response.intent.status,
|
|
88
|
-
safeErrorCode: response.intent.safeErrorCode
|
|
89
|
-
});
|
|
90
|
-
if (!["READY", "ACCOUNT_MISMATCH", "IDENTITY_UNVERIFIABLE"].includes(response.result.outcome)) {
|
|
91
|
-
latest = await loadCodexMigrationLoginQueueSnapshot(input);
|
|
92
|
-
const planStopped = planStopReason(latest.plan.status);
|
|
93
|
-
return result(latest.plan, false, planStopped === "QUEUE_EXHAUSTED" ? "TARGET_UNCERTAIN" : planStopped, items);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
latest = await safeReload(input, latest);
|
|
98
|
-
const refreshedTarget = latest.items.find(({ id }) => id === target.id);
|
|
99
|
-
if (["enrollment_intent_state_conflict", "enrollment_intent_claimed"].includes(String(error.code ?? ""))
|
|
100
|
-
&& refreshedTarget && refreshedTarget.allowedAction !== "LOGIN") {
|
|
101
|
-
items.push(skippedItem(refreshedTarget));
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
const classified = classifyBatchError(error);
|
|
105
|
-
items.push({
|
|
106
|
-
...baseItem(target),
|
|
107
|
-
action: "LOGIN",
|
|
108
|
-
status: "FAILED",
|
|
109
|
-
safeErrorCode: classified.safeErrorCode
|
|
110
|
-
});
|
|
111
|
-
const planStopped = planStopReason(latest.plan.status);
|
|
112
|
-
return result(latest.plan, false, planStopped === "QUEUE_EXHAUSTED" ? classified.stopReason : planStopped, items);
|
|
113
|
-
}
|
|
114
|
-
latest = await loadCodexMigrationLoginQueueSnapshot(input);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function samePlanProjection(left, right) {
|
|
118
|
-
return left.id === right.id && left.status === right.status && left.revision === right.revision
|
|
119
|
-
&& left.accountId === right.accountId && right.sequentialRequired === true;
|
|
120
|
-
}
|
|
121
|
-
function uniqueQueueItems(items, total) {
|
|
122
|
-
if (items.length !== total || new Set(items.map(({ id }) => id)).size !== items.length
|
|
123
|
-
|| new Set(items.map(({ assignmentId }) => assignmentId)).size !== items.length) {
|
|
124
|
-
throw new CodexServiceError("Migration login queue contains duplicate or incomplete targets.", "invalid_codex_service_response");
|
|
125
|
-
}
|
|
126
|
-
return items;
|
|
127
|
-
}
|
|
128
|
-
function baseItem(target) {
|
|
129
|
-
return {
|
|
130
|
-
targetId: target.id,
|
|
131
|
-
assignmentId: target.assignmentId,
|
|
132
|
-
intentId: target.enrollmentIntent?.id ?? null,
|
|
133
|
-
requestedAction: target.allowedAction
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function dryRunItem(target) {
|
|
137
|
-
if (target.allowedAction === "LOGIN" && target.enrollmentIntent?.status === "AWAITING_CLI") {
|
|
138
|
-
return { ...baseItem(target), action: "LOGIN", status: "PLANNED" };
|
|
139
|
-
}
|
|
140
|
-
return { ...skippedItem(target), status: "PLANNED" };
|
|
141
|
-
}
|
|
142
|
-
function skippedItem(target) {
|
|
143
|
-
return {
|
|
144
|
-
...baseItem(target),
|
|
145
|
-
action: "SKIP",
|
|
146
|
-
status: "SKIPPED",
|
|
147
|
-
intentStatus: target.enrollmentIntent?.status,
|
|
148
|
-
safeErrorCode: target.enrollmentIntent?.safeErrorCode,
|
|
149
|
-
skipReason: target.allowedAction === "VIEW_ENROLLMENT"
|
|
150
|
-
? "VIEW_ENROLLMENT"
|
|
151
|
-
: target.distributionMode === "USER_BOUND" && target.projectedStatus === "ACTIVE"
|
|
152
|
-
? "ALREADY_USER_BOUND"
|
|
153
|
-
: "NO_ACTION"
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
function planStopReason(status) {
|
|
157
|
-
return status === "ACTIVE" ? "QUEUE_EXHAUSTED" : status;
|
|
158
|
-
}
|
|
159
|
-
function classifyBatchError(error) {
|
|
160
|
-
const value = error;
|
|
161
|
-
const code = typeof value?.code === "string" && /^[a-z][a-z0-9_.-]{0,127}$/iu.test(value.code)
|
|
162
|
-
? value.code
|
|
163
|
-
: "official_login_failed";
|
|
164
|
-
const status = typeof value?.status === "number" ? value.status : undefined;
|
|
165
|
-
if (["auth_error", "login_required", "http_error", "issuer_mismatch", "codex_access_denied"]
|
|
166
|
-
.includes(code) || status === 401 || status === 403) {
|
|
167
|
-
return { stopReason: "AUTHENTICATION_ERROR", safeErrorCode: code };
|
|
168
|
-
}
|
|
169
|
-
if (["codex_service_unavailable", "invalid_codex_service_response", "codex_service_error",
|
|
170
|
-
"migration_queue_changed"].includes(code) || status !== undefined && status >= 500) {
|
|
171
|
-
return { stopReason: "SERVICE_ERROR", safeErrorCode: code };
|
|
172
|
-
}
|
|
173
|
-
return { stopReason: "LOGIN_ERROR", safeErrorCode: code };
|
|
174
|
-
}
|
|
175
|
-
async function safeReload(input, fallback) {
|
|
176
|
-
try {
|
|
177
|
-
return await loadCodexMigrationLoginQueueSnapshot(input);
|
|
178
|
-
}
|
|
179
|
-
catch {
|
|
180
|
-
return fallback;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function result(plan, dryRun, stopReason, items) {
|
|
184
|
-
return {
|
|
185
|
-
schemaVersion: 2,
|
|
186
|
-
plan,
|
|
187
|
-
capacity: CODEX_MIGRATION_CAPACITY,
|
|
188
|
-
dryRun,
|
|
189
|
-
stopReason,
|
|
190
|
-
counts: {
|
|
191
|
-
observed: items.length,
|
|
192
|
-
plannedLogins: items.filter(({ action }) => action === "LOGIN").length,
|
|
193
|
-
attempted: items.filter(({ action, status }) => action === "LOGIN"
|
|
194
|
-
&& status !== "PLANNED").length,
|
|
195
|
-
completed: items.filter(({ status }) => status === "COMPLETED").length,
|
|
196
|
-
failed: items.filter(({ status }) => status === "FAILED").length,
|
|
197
|
-
skipped: items.filter(({ action }) => action === "SKIP").length
|
|
198
|
-
},
|
|
199
|
-
items
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
//# sourceMappingURL=migration-login-batch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migration-login-batch.js","sourceRoot":"","sources":["../src/migration-login-batch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,wBAAwB,EAKzB,MAAM,eAAe,CAAC;AA+DvB,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,oCAAoC,CAAC,KAK1D;IACC,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,GA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,KAAK,QAAQ,CAAC,CAAC,MAAM;YAChE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,MAAM;SAChE;QACD,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { CodexServiceClient } from "./client.js";
|
|
2
|
-
interface RetirementClient {
|
|
3
|
-
getAssignmentRetirement: CodexServiceClient["getAssignmentRetirement"];
|
|
4
|
-
acknowledgeAssignmentRetirementLocalDelete: CodexServiceClient["acknowledgeAssignmentRetirementLocalDelete"];
|
|
5
|
-
}
|
|
6
|
-
export declare function executeCodexAssignmentRetirementLocalDelete(input: {
|
|
7
|
-
client: RetirementClient;
|
|
8
|
-
retirementId: string;
|
|
9
|
-
expectedRevision?: number;
|
|
10
|
-
idempotencyKey?: string;
|
|
11
|
-
env?: NodeJS.ProcessEnv;
|
|
12
|
-
now?: () => number;
|
|
13
|
-
}): Promise<{
|
|
14
|
-
schemaVersion: 2;
|
|
15
|
-
retirement: {
|
|
16
|
-
id: string;
|
|
17
|
-
assignmentId: string;
|
|
18
|
-
revision: number;
|
|
19
|
-
reason: "COMPROMISED" | "REPLACED" | "UNASSIGN";
|
|
20
|
-
status: "COMPROMISED" | "FINALIZED" | "READY_TO_FINALIZE" | "RETIREMENT_PENDING";
|
|
21
|
-
requestedAt: string;
|
|
22
|
-
serverRefreshStoppedAt: string;
|
|
23
|
-
shortLivedCredentialsExpireAt: string;
|
|
24
|
-
localDeleteStatus: "ACKNOWLEDGED" | "EXPIRED" | "NOT_REQUIRED" | "PENDING";
|
|
25
|
-
localDeleteAcknowledgedAt: string | null;
|
|
26
|
-
serverSecretsShreddedAt: string | null;
|
|
27
|
-
upstreamRevocationStatus: "UNKNOWN";
|
|
28
|
-
safeToFinalizeAt: string;
|
|
29
|
-
};
|
|
30
|
-
replayed: boolean;
|
|
31
|
-
local: {
|
|
32
|
-
assignmentId: string;
|
|
33
|
-
lineageId: string;
|
|
34
|
-
generationVersion: number;
|
|
35
|
-
deletedAt: string;
|
|
36
|
-
};
|
|
37
|
-
}>;
|
|
38
|
-
export {};
|
package/dist/retirement-flow.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { markManagedCodexRetirementAcknowledged, prepareManagedCodexLineageRetirement, readManagedCodexLineageState, readManagedCodexRetirementTombstone } from "./credentials.js";
|
|
3
|
-
import { CodexServiceError } from "./errors.js";
|
|
4
|
-
export async function executeCodexAssignmentRetirementLocalDelete(input) {
|
|
5
|
-
const env = input.env ?? process.env;
|
|
6
|
-
const now = input.now ?? Date.now;
|
|
7
|
-
const existing = await readManagedCodexRetirementTombstone(env);
|
|
8
|
-
const localState = await readManagedCodexLineageState(env);
|
|
9
|
-
const localTarget = existing?.retirementId === input.retirementId ? {
|
|
10
|
-
assignmentId: existing.assignmentId,
|
|
11
|
-
lineageId: existing.lineageId,
|
|
12
|
-
generationVersion: existing.generationVersion
|
|
13
|
-
} : localState ? {
|
|
14
|
-
assignmentId: localState.assignmentId,
|
|
15
|
-
lineageId: localState.lineageId,
|
|
16
|
-
generationVersion: localState.generationVersion
|
|
17
|
-
} : undefined;
|
|
18
|
-
if (!localTarget) {
|
|
19
|
-
throw new CodexServiceError("No local managed lineage matches this retirement request.", "assignment_retirement_local_state_not_found");
|
|
20
|
-
}
|
|
21
|
-
const preflight = await input.client.getAssignmentRetirement(input.retirementId);
|
|
22
|
-
const targetMatches = preflight.retirement.assignmentId === localTarget.assignmentId
|
|
23
|
-
&& preflight.allowedLocalDeleteTargets.some((target) => target.lineageId === localTarget.lineageId
|
|
24
|
-
&& target.generationVersion === localTarget.generationVersion);
|
|
25
|
-
if (!targetMatches) {
|
|
26
|
-
throw new CodexServiceError("The Server retirement does not authorize deletion of the locally installed lineage.", "assignment_retirement_local_delete_target_mismatch");
|
|
27
|
-
}
|
|
28
|
-
if (existing?.retirementId === input.retirementId
|
|
29
|
-
&& existing.acknowledgedAt === null
|
|
30
|
-
&& preflight.retirement.localDeleteAcknowledgedAt !== null) {
|
|
31
|
-
const recovered = await markManagedCodexRetirementAcknowledged(existing.retirementId, preflight.retirement.localDeleteAcknowledgedAt, env);
|
|
32
|
-
return {
|
|
33
|
-
schemaVersion: 2,
|
|
34
|
-
retirement: preflight.retirement,
|
|
35
|
-
replayed: true,
|
|
36
|
-
local: {
|
|
37
|
-
assignmentId: recovered.assignmentId,
|
|
38
|
-
lineageId: recovered.lineageId,
|
|
39
|
-
generationVersion: recovered.generationVersion,
|
|
40
|
-
deletedAt: recovered.deletedAt
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
if (input.expectedRevision !== undefined && input.expectedRevision !== preflight.retirement.revision) {
|
|
45
|
-
throw new CodexServiceError("The retirement revision changed before local deletion.", "assignment_retirement_revision_conflict");
|
|
46
|
-
}
|
|
47
|
-
if (!preflight.allowedActions.includes("ACKNOWLEDGE_LOCAL_DELETE")) {
|
|
48
|
-
throw new CodexServiceError("The Server retirement is not accepting local deletion evidence.", "assignment_retirement_local_delete_not_allowed");
|
|
49
|
-
}
|
|
50
|
-
const prepared = await prepareManagedCodexLineageRetirement({
|
|
51
|
-
retirementId: input.retirementId,
|
|
52
|
-
expectedRevision: preflight.retirement.revision,
|
|
53
|
-
idempotencyKey: input.idempotencyKey ?? randomUUID()
|
|
54
|
-
}, now(), env);
|
|
55
|
-
const response = await input.client.acknowledgeAssignmentRetirementLocalDelete(prepared.retirementId, {
|
|
56
|
-
schemaVersion: 2,
|
|
57
|
-
expectedRevision: prepared.expectedRevision,
|
|
58
|
-
targets: [{
|
|
59
|
-
lineageId: prepared.lineageId,
|
|
60
|
-
generationVersion: prepared.generationVersion
|
|
61
|
-
}]
|
|
62
|
-
}, prepared.idempotencyKey);
|
|
63
|
-
const acknowledgedAt = response.retirement.localDeleteAcknowledgedAt;
|
|
64
|
-
if (!acknowledgedAt) {
|
|
65
|
-
throw new CodexServiceError("Server accepted a local deletion ACK without acknowledgement metadata.", "invalid_codex_service_response");
|
|
66
|
-
}
|
|
67
|
-
await markManagedCodexRetirementAcknowledged(prepared.retirementId, acknowledgedAt, env);
|
|
68
|
-
return {
|
|
69
|
-
...response,
|
|
70
|
-
local: {
|
|
71
|
-
assignmentId: prepared.assignmentId,
|
|
72
|
-
lineageId: prepared.lineageId,
|
|
73
|
-
generationVersion: prepared.generationVersion,
|
|
74
|
-
deletedAt: prepared.deletedAt
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=retirement-flow.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retirement-flow.js","sourceRoot":"","sources":["../src/retirement-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,sCAAsC,EACtC,oCAAoC,EACpC,4BAA4B,EAC5B,mCAAmC,EACpC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQhD,MAAM,CAAC,KAAK,UAAU,2CAA2C,CAAC,KAOjE;IACC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACrC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IAClC,MAAM,QAAQ,GAAG,MAAM,mCAAmC,CAAC,GAAG,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,MAAM,4BAA4B,CAAC,GAAG,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,QAAQ,EAAE,YAAY,KAAK,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;QAClE,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,iBAAiB,EAAE,QAA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jC,CAAC;IACJ,CAAC;IACD,MAAM,sCAAsC,CAAC,QAAQ,CAAC,YAAY,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;IACzF,OAAO;QACL,GAAG,QAAQ;QACX,KAAK,EAAE;YACL,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;YAC7C,SAAS,EAAE,QAAQ,CAAC,SAAS;SAC9B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { CodexServiceClient } from "./client.js";
|
|
2
|
-
import { installManagedCodexLineageCredentials } from "./credentials.js";
|
|
3
|
-
interface ShortLivedDeliveryClient {
|
|
4
|
-
createShortLivedCredentialDelivery: CodexServiceClient["createShortLivedCredentialDelivery"];
|
|
5
|
-
acknowledgeShortLivedCredentialDelivery: CodexServiceClient["acknowledgeShortLivedCredentialDelivery"];
|
|
6
|
-
}
|
|
7
|
-
export interface CodexShortLivedDeliveryFlowResult {
|
|
8
|
-
deliveryId: string;
|
|
9
|
-
assignmentId: string;
|
|
10
|
-
managedAccountId: string;
|
|
11
|
-
providerAccountId: string;
|
|
12
|
-
lineageId: string;
|
|
13
|
-
generationVersion: number;
|
|
14
|
-
credentialExpiresAt: string;
|
|
15
|
-
installAction: "INSTALLED" | "UNCHANGED" | "RECOVERED";
|
|
16
|
-
issueReplayed: boolean;
|
|
17
|
-
ackReplayed: boolean;
|
|
18
|
-
resumed: boolean;
|
|
19
|
-
}
|
|
20
|
-
export declare function executeCodexShortLivedCredentialDelivery(input: {
|
|
21
|
-
client: ShortLivedDeliveryClient;
|
|
22
|
-
tenantId: string;
|
|
23
|
-
assignmentId: string;
|
|
24
|
-
env?: NodeJS.ProcessEnv;
|
|
25
|
-
now?: () => number;
|
|
26
|
-
newId?: () => string;
|
|
27
|
-
installHooks?: Parameters<typeof installManagedCodexLineageCredentials>[3];
|
|
28
|
-
allowNewDelivery?: boolean;
|
|
29
|
-
}): Promise<CodexShortLivedDeliveryFlowResult>;
|
|
30
|
-
export declare function resumePendingCodexShortLivedDeliveryAck(input: {
|
|
31
|
-
client: Pick<ShortLivedDeliveryClient, "acknowledgeShortLivedCredentialDelivery">;
|
|
32
|
-
tenantId: string;
|
|
33
|
-
assignmentId: string;
|
|
34
|
-
env?: NodeJS.ProcessEnv;
|
|
35
|
-
now?: number;
|
|
36
|
-
idempotencyKey?: string;
|
|
37
|
-
}): Promise<{
|
|
38
|
-
deliveryId: string;
|
|
39
|
-
replayed: boolean;
|
|
40
|
-
} | undefined>;
|
|
41
|
-
export {};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { installManagedCodexLineageCredentials, markManagedCodexLineageDeliveryAcknowledged, readManagedCodexLineageState } from "./credentials.js";
|
|
3
|
-
import { CodexServiceError } from "./errors.js";
|
|
4
|
-
import { createCodexShortLivedDeliveryKeyPair, openCodexShortLivedCredentialDelivery } from "./short-lived-delivery.js";
|
|
5
|
-
import { clearCodexShortLivedDeliveryJournal, loadOrCreateCodexShortLivedDeliveryJournal, markCodexShortLivedDeliveryJournalIssued, openCodexShortLivedDeliveryJournalPrivateKey, readCodexShortLivedDeliveryJournal } from "./short-lived-delivery-journal.js";
|
|
6
|
-
export async function executeCodexShortLivedCredentialDelivery(input) {
|
|
7
|
-
const now = input.now ?? Date.now;
|
|
8
|
-
const newId = input.newId ?? randomUUID;
|
|
9
|
-
const env = input.env ?? process.env;
|
|
10
|
-
const pending = await readManagedCodexLineageState(env);
|
|
11
|
-
const existingJournal = await readCodexShortLivedDeliveryJournal(env);
|
|
12
|
-
const pendingMatchesRequest = pending !== undefined && pending.assignmentId === input.assignmentId
|
|
13
|
-
&& (pending.tenantId === input.tenantId || pending.tenantId === null);
|
|
14
|
-
if (pending && pendingMatchesRequest && pending.phase === "INSTALLED_PENDING_ACK"
|
|
15
|
-
&& Date.parse(pending.ackExpiresAt) > now()) {
|
|
16
|
-
const resumed = await acknowledgeInstalledDelivery(input.client, pending, newId(), env);
|
|
17
|
-
const journal = await readCodexShortLivedDeliveryJournal(env);
|
|
18
|
-
if (journal?.deliveryId === pending.deliveryId) {
|
|
19
|
-
await clearCodexShortLivedDeliveryJournal(journal.idempotencyKey, env);
|
|
20
|
-
}
|
|
21
|
-
if (Date.parse(pending.credentialExpiresAt) > now()) {
|
|
22
|
-
return {
|
|
23
|
-
deliveryId: pending.deliveryId,
|
|
24
|
-
assignmentId: pending.assignmentId,
|
|
25
|
-
managedAccountId: pending.managedAccountId,
|
|
26
|
-
providerAccountId: pending.providerAccountId,
|
|
27
|
-
lineageId: pending.lineageId,
|
|
28
|
-
generationVersion: pending.generationVersion,
|
|
29
|
-
credentialExpiresAt: pending.credentialExpiresAt,
|
|
30
|
-
installAction: "UNCHANGED",
|
|
31
|
-
issueReplayed: true,
|
|
32
|
-
ackReplayed: resumed.replayed,
|
|
33
|
-
resumed: true
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const journalMatchesRequest = existingJournal?.tenantId === input.tenantId
|
|
38
|
-
&& existingJournal.assignmentId === input.assignmentId;
|
|
39
|
-
if (input.allowNewDelivery === false && !journalMatchesRequest) {
|
|
40
|
-
throw new CodexServiceError("The assignment is not eligible for a new short-lived credential delivery.", "short_lived_credential_lineage_not_ready", 409);
|
|
41
|
-
}
|
|
42
|
-
for (let journalAttempt = 0; journalAttempt < 2; journalAttempt += 1) {
|
|
43
|
-
const generated = createCodexShortLivedDeliveryKeyPair();
|
|
44
|
-
const journal = await loadOrCreateCodexShortLivedDeliveryJournal({
|
|
45
|
-
tenantId: input.tenantId,
|
|
46
|
-
assignmentId: input.assignmentId,
|
|
47
|
-
idempotencyKey: newId(),
|
|
48
|
-
clientKey: generated.clientKey,
|
|
49
|
-
privateKey: generated.privateKey,
|
|
50
|
-
now: now(),
|
|
51
|
-
env
|
|
52
|
-
});
|
|
53
|
-
const privateKey = openCodexShortLivedDeliveryJournalPrivateKey(journal);
|
|
54
|
-
let issue;
|
|
55
|
-
try {
|
|
56
|
-
issue = await input.client.createShortLivedCredentialDelivery(input.assignmentId, {
|
|
57
|
-
schemaVersion: 2,
|
|
58
|
-
clientKey: journal.clientKey
|
|
59
|
-
}, journal.idempotencyKey);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
if (journalAttempt === 0 && error instanceof CodexServiceError
|
|
63
|
-
&& [
|
|
64
|
-
"short_lived_credential_delivery_expired",
|
|
65
|
-
"short_lived_credential_delivery_already_acked",
|
|
66
|
-
"lineage_version_conflict"
|
|
67
|
-
].includes(error.code)) {
|
|
68
|
-
await clearCodexShortLivedDeliveryJournal(journal.idempotencyKey, env);
|
|
69
|
-
if (input.allowNewDelivery === false)
|
|
70
|
-
throw error;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
const issuedJournal = await markCodexShortLivedDeliveryJournalIssued(journal, issue.delivery.id, issue.delivery.ackExpiresAt, now(), env);
|
|
76
|
-
const bundle = openCodexShortLivedCredentialDelivery({
|
|
77
|
-
tenantId: input.tenantId,
|
|
78
|
-
response: issue,
|
|
79
|
-
privateKey,
|
|
80
|
-
now: now()
|
|
81
|
-
});
|
|
82
|
-
const installed = await installManagedCodexLineageCredentials({
|
|
83
|
-
tenantId: input.tenantId,
|
|
84
|
-
deliveryId: bundle.deliveryId,
|
|
85
|
-
assignmentId: issue.delivery.assignmentId,
|
|
86
|
-
managedAccountId: bundle.managedAccountId,
|
|
87
|
-
lineageId: bundle.lineageId,
|
|
88
|
-
generationVersion: bundle.generationVersion,
|
|
89
|
-
providerAccountId: bundle.providerAccountId,
|
|
90
|
-
accessToken: bundle.accessToken,
|
|
91
|
-
idToken: bundle.idToken,
|
|
92
|
-
credentialExpiresAt: bundle.expiresAt,
|
|
93
|
-
ackExpiresAt: issue.delivery.ackExpiresAt,
|
|
94
|
-
lastRefresh: issue.delivery.issuedAt
|
|
95
|
-
}, now(), env, input.installHooks);
|
|
96
|
-
const acknowledged = await input.client.acknowledgeShortLivedCredentialDelivery(bundle.deliveryId, {
|
|
97
|
-
schemaVersion: 2,
|
|
98
|
-
lineageId: bundle.lineageId,
|
|
99
|
-
generationVersion: bundle.generationVersion
|
|
100
|
-
}, newId());
|
|
101
|
-
await markManagedCodexLineageDeliveryAcknowledged(bundle.deliveryId, acknowledged.delivery.ackedAt, env);
|
|
102
|
-
await clearCodexShortLivedDeliveryJournal(issuedJournal.idempotencyKey, env);
|
|
103
|
-
return {
|
|
104
|
-
deliveryId: bundle.deliveryId,
|
|
105
|
-
assignmentId: issue.delivery.assignmentId,
|
|
106
|
-
managedAccountId: bundle.managedAccountId,
|
|
107
|
-
providerAccountId: bundle.providerAccountId,
|
|
108
|
-
lineageId: bundle.lineageId,
|
|
109
|
-
generationVersion: bundle.generationVersion,
|
|
110
|
-
credentialExpiresAt: bundle.expiresAt,
|
|
111
|
-
installAction: installed.action,
|
|
112
|
-
issueReplayed: issue.replayed,
|
|
113
|
-
ackReplayed: acknowledged.replayed,
|
|
114
|
-
resumed: false
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
throw new CodexServiceError("Unable to replace the expired short-lived credential delivery journal.", "short_lived_delivery_state_conflict");
|
|
118
|
-
}
|
|
119
|
-
export async function resumePendingCodexShortLivedDeliveryAck(input) {
|
|
120
|
-
const env = input.env ?? process.env;
|
|
121
|
-
const state = await readManagedCodexLineageState(env);
|
|
122
|
-
const stateMatchesRequest = state !== undefined && state.assignmentId === input.assignmentId
|
|
123
|
-
&& (state.tenantId === input.tenantId || state.tenantId === null);
|
|
124
|
-
if (!state || !stateMatchesRequest || state.phase !== "INSTALLED_PENDING_ACK")
|
|
125
|
-
return undefined;
|
|
126
|
-
if (Date.parse(state.ackExpiresAt) <= (input.now ?? Date.now())) {
|
|
127
|
-
throw new CodexServiceError("The pending short-lived credential ACK has expired; request a new delivery.", "short_lived_credential_delivery_expired");
|
|
128
|
-
}
|
|
129
|
-
const result = await acknowledgeInstalledDelivery(input.client, state, input.idempotencyKey ?? randomUUID(), env);
|
|
130
|
-
return { deliveryId: state.deliveryId, replayed: result.replayed };
|
|
131
|
-
}
|
|
132
|
-
async function acknowledgeInstalledDelivery(client, state, idempotencyKey, env) {
|
|
133
|
-
const acknowledged = await client.acknowledgeShortLivedCredentialDelivery(state.deliveryId, {
|
|
134
|
-
schemaVersion: 2,
|
|
135
|
-
lineageId: state.lineageId,
|
|
136
|
-
generationVersion: state.generationVersion
|
|
137
|
-
}, idempotencyKey);
|
|
138
|
-
await markManagedCodexLineageDeliveryAcknowledged(state.deliveryId, acknowledged.delivery.ackedAt, env);
|
|
139
|
-
return { replayed: acknowledged.replayed };
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=short-lived-delivery-flow.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"short-lived-delivery-flow.js","sourceRoot":"","sources":["../src/short-lived-delivery-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,qCAAqC,EACrC,2CAA2C,EAC3C,4BAA4B,EAC7B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,oCAAoC,EACpC,qCAAqC,EACtC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,mCAAmC,EACnC,0CAA0C,EAC1C,wCAAwC,EACxC,4CAA4C,EAC5C,kCAAkC,EACnC,MAAM,mCAAmC,CAAC;AAqB3C,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAAC,KAS9D;IACC,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IAClC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,UAAU,CAAC;IACxC,MAAM,GAAG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 +0,0 @@
|
|
|
1
|
-
import { type KeyObject } from "node:crypto";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import type { CodexShortLivedDeliveryClientKey } from "./protocol.js";
|
|
4
|
-
declare const JournalSchema: z.ZodObject<{
|
|
5
|
-
schemaVersion: z.ZodLiteral<2>;
|
|
6
|
-
tenantId: z.ZodString;
|
|
7
|
-
assignmentId: z.ZodString;
|
|
8
|
-
idempotencyKey: z.ZodString;
|
|
9
|
-
clientKey: z.ZodObject<{
|
|
10
|
-
version: z.ZodLiteral<1>;
|
|
11
|
-
algorithm: z.ZodLiteral<"X25519-HKDF-SHA256-AES-256-GCM">;
|
|
12
|
-
publicKey: z.ZodString;
|
|
13
|
-
}, z.core.$strict>;
|
|
14
|
-
privateKeyPkcs8: z.ZodString;
|
|
15
|
-
deliveryId: z.ZodNullable<z.ZodString>;
|
|
16
|
-
ackExpiresAt: z.ZodNullable<z.ZodString>;
|
|
17
|
-
createdAt: z.ZodString;
|
|
18
|
-
updatedAt: z.ZodString;
|
|
19
|
-
}, z.core.$strict>;
|
|
20
|
-
export type CodexShortLivedDeliveryJournal = z.infer<typeof JournalSchema>;
|
|
21
|
-
export declare function readCodexShortLivedDeliveryJournal(env?: NodeJS.ProcessEnv): Promise<CodexShortLivedDeliveryJournal | undefined>;
|
|
22
|
-
export declare function loadOrCreateCodexShortLivedDeliveryJournal(input: {
|
|
23
|
-
tenantId: string;
|
|
24
|
-
assignmentId: string;
|
|
25
|
-
idempotencyKey: string;
|
|
26
|
-
clientKey: CodexShortLivedDeliveryClientKey;
|
|
27
|
-
privateKey: KeyObject;
|
|
28
|
-
now: number;
|
|
29
|
-
env?: NodeJS.ProcessEnv;
|
|
30
|
-
}): Promise<CodexShortLivedDeliveryJournal>;
|
|
31
|
-
export declare function openCodexShortLivedDeliveryJournalPrivateKey(journal: CodexShortLivedDeliveryJournal): KeyObject;
|
|
32
|
-
export declare function markCodexShortLivedDeliveryJournalIssued(expected: CodexShortLivedDeliveryJournal, deliveryId: string, ackExpiresAt: string, now: number, env?: NodeJS.ProcessEnv): Promise<CodexShortLivedDeliveryJournal>;
|
|
33
|
-
export declare function clearCodexShortLivedDeliveryJournal(expectedIdempotencyKey: string, env?: NodeJS.ProcessEnv): Promise<void>;
|
|
34
|
-
export {};
|