@prisma/cli-engine 0.1.0 → 0.2.0

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,7 +1,7 @@
1
- import { a as okVoid, r as notOk, t as CliStructuredError } from "./protocol-D1CRNkhv.js";
1
+ import { a as okVoid, r as notOk, t as CliStructuredError } from "./protocol-TtNVkeVS.js";
2
2
  import { createRequire } from "node:module";
3
+ import { Buffer } from "node:buffer";
3
4
  import { FlagNotFoundError, buildApplication, buildCommand, buildRouteMap, run, text_en } from "@stricli/core";
4
- import vendors from "ci-info/vendors.json" with { type: "json" };
5
5
  import { randomUUID } from "node:crypto";
6
6
  import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
7
7
  import { dirname, join, resolve } from "node:path";
@@ -9,7 +9,232 @@ import { detect } from "package-manager-detector/detect";
9
9
  import { createColors } from "colorette";
10
10
  import stringWidth from "string-width";
11
11
  import { Readable, Writable } from "node:stream";
12
- import { Buffer } from "node:buffer";
12
+ //#region src/credential-errors.ts
13
+ const signInAction = {
14
+ kind: "user-choice",
15
+ label: "Sign in, then run the command again."
16
+ };
17
+ const useSessionAction = {
18
+ kind: "run-command",
19
+ label: "Make one of your workspace sessions current",
20
+ command: "prisma auth workspace use"
21
+ };
22
+ /**
23
+ * The single constructor of CLI.CREDENTIALS_REQUIRED. Raised
24
+ * identically by the needs check, ctx.activeCredential, and the
25
+ * engine's request path.
26
+ */
27
+ function credentialsRequiredError(reason = "unauthenticated") {
28
+ switch (reason) {
29
+ case "unauthenticated": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "You must be signed in to run this command.", { nextActions: [signInAction] });
30
+ case "expired": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "Your session has expired — sign in again.", { nextActions: [signInAction] });
31
+ case "expiring-soon": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "Your session expires too soon to run this command — sign in again.", {
32
+ why: "This command hands your credentials to another program, which cannot refresh them while it runs.",
33
+ nextActions: [signInAction]
34
+ });
35
+ case "session-ended": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "The workspace session this command was using has ended.", {
36
+ why: "It was ended while the command was running (for example by another prisma process).",
37
+ nextActions: [useSessionAction, signInAction]
38
+ });
39
+ case "sessions-held-none-selected": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "No workspace session is current.", {
40
+ why: "You have workspace sessions but none is current.",
41
+ nextActions: [useSessionAction, signInAction]
42
+ });
43
+ }
44
+ }
45
+ /**
46
+ * A refresh attempt failed transiently (the auth service, not the
47
+ * credentials): nothing was cleared, and signing in again is not the
48
+ * fix.
49
+ */
50
+ function authServiceError() {
51
+ return new CliStructuredError("CLI.AUTH_SERVICE_ERROR", "The authentication service could not refresh your session.", {
52
+ why: "The refresh attempt failed transiently; your stored credentials were left untouched.",
53
+ nextActions: [{
54
+ kind: "user-choice",
55
+ label: "Run the command again; sign in again only if the problem persists."
56
+ }]
57
+ });
58
+ }
59
+ /**
60
+ * The credential in force was rejected and could never be renewed — it
61
+ * carries no refresh token. The ONE place wording differs by origin;
62
+ * nothing else compares against `origin.source`.
63
+ */
64
+ function credentialRejectedError(origin, envVar) {
65
+ return origin.source === "environment" ? serviceTokenRejectedError({ envVar }) : credentialsRequiredError("expired");
66
+ }
67
+ /**
68
+ * A credential's workspace_id claim disagrees with the workspace it is
69
+ * being stored under, or a rotated token would re-scope a session.
70
+ * Raised by every CredentialManager, so a test sees what production
71
+ * raises.
72
+ */
73
+ function credentialWorkspaceMismatchError(workspaceId) {
74
+ return new CliStructuredError("AUTH.CREDENTIAL_WORKSPACE_MISMATCH", "That credential belongs to a different workspace.", {
75
+ why: `The token's workspace_id claim does not name workspace '${workspaceId}'.`,
76
+ nextActions: [{
77
+ kind: "run-command",
78
+ label: "Sign in again and pick the workspace you want",
79
+ command: "prisma auth login"
80
+ }]
81
+ });
82
+ }
83
+ /**
84
+ * The env var that supplies a session is set to a blank value. The one
85
+ * structured error for it, raised identically by activeCredential(),
86
+ * the needs check, and the engine's request path.
87
+ */
88
+ function emptyServiceTokenError(spec) {
89
+ return new CliStructuredError("AUTH.SERVICE_TOKEN_EMPTY", `${spec.envVar} is set but empty.`, {
90
+ why: `A blank token authenticates nothing, and ${spec.envVar} overrides your stored workspace sessions while it is set.`,
91
+ nextActions: [{
92
+ kind: "run-command",
93
+ label: `Unset ${spec.envVar}`,
94
+ command: `unset ${spec.envVar}`
95
+ }, {
96
+ kind: "user-choice",
97
+ label: `Or set ${spec.envVar} to a valid service token.`
98
+ }]
99
+ });
100
+ }
101
+ /**
102
+ * No session exists for the named workspace. Sessions are created by
103
+ * `prisma auth login` alone — `workspace use` selects among the ones
104
+ * you have.
105
+ */
106
+ function noSessionForWorkspaceError(workspaceRef) {
107
+ return new CliStructuredError("AUTH.NO_SESSION_FOR_WORKSPACE", `You have no session for workspace '${workspaceRef}'.`, { nextActions: [{
108
+ kind: "run-command",
109
+ label: `Sign in and pick '${workspaceRef}' in the browser`,
110
+ command: "prisma auth login"
111
+ }] });
112
+ }
113
+ /**
114
+ * Module-private on purpose: `credentialRejectedError` is the one place
115
+ * wording differs by origin (§11.1), and exporting this would be a
116
+ * second door into the environment-specific text that bypasses it.
117
+ *
118
+ * The management API rejected the env-supplied service token (401).
119
+ * There is no refresh for it and nothing stored is cleared.
120
+ */
121
+ function serviceTokenRejectedError(spec) {
122
+ return new CliStructuredError("AUTH.SERVICE_TOKEN_REJECTED", `The management API rejected the service token from ${spec.envVar}.`, { nextActions: [{
123
+ kind: "user-choice",
124
+ label: `Replace ${spec.envVar} with a valid service token, or unset it to use your stored sessions.`
125
+ }] });
126
+ }
127
+ //#endregion
128
+ //#region src/token-claims.ts
129
+ /**
130
+ * Reading a credential's own claims. This lives in the engine and is
131
+ * shared rather than reimplemented, because both credential managers
132
+ * need it and the two copies had already drifted: one knew a service
133
+ * token names its workspace through `sub`, the other did not, so a
134
+ * token that worked in production could not be reproduced in a test.
135
+ *
136
+ * Decoding only. Nothing here verifies a signature — the claims are the
137
+ * issuer's word, used for display and for keying, never for authorizing.
138
+ */
139
+ /** A service token's subject is its workspace, not a person. */
140
+ const WORKSPACE_SUBJECT_PREFIX = "workspace:";
141
+ function decodeTokenClaims(token) {
142
+ const payload = token.split(".")[1];
143
+ if (payload === void 0) return void 0;
144
+ try {
145
+ const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
146
+ return typeof parsed === "object" && parsed !== null ? parsed : void 0;
147
+ } catch {
148
+ return;
149
+ }
150
+ }
151
+ function claimedString(claims, name) {
152
+ const value = claims?.[name];
153
+ return typeof value === "string" && value.length > 0 ? value : void 0;
154
+ }
155
+ /**
156
+ * The workspace a credential names. One derivation, because a token
157
+ * says it one of two ways and every caller wants the same answer: an
158
+ * OAuth token carries `workspace_id`, while a service token names its
159
+ * workspace through `sub` and carries no `workspace_id` at all. Reading
160
+ * only the claim was a second path that happened to work because
161
+ * service tokens reached it by a different route — a split nothing
162
+ * enforced.
163
+ */
164
+ function credentialWorkspaceId(token) {
165
+ const claims = decodeTokenClaims(token);
166
+ const fromClaim = claimedString(claims, "workspace_id");
167
+ if (fromClaim !== void 0) return fromClaim;
168
+ const subject = claimedString(claims, "sub");
169
+ if (subject === void 0 || !subject.startsWith(WORKSPACE_SUBJECT_PREFIX)) return;
170
+ const derived = subject.slice(10).trim();
171
+ return derived.length > 0 ? derived : void 0;
172
+ }
173
+ function claimedExpiresAt(token) {
174
+ const exp = decodeTokenClaims(token)?.exp;
175
+ return typeof exp === "number" ? /* @__PURE__ */ new Date(exp * 1e3) : void 0;
176
+ }
177
+ /**
178
+ * Who a credential belongs to, from its own claims. A service token's
179
+ * subject names a workspace rather than a person, so it yields no user
180
+ * — reporting `workspace:ws_1` as a user id was a real defect.
181
+ */
182
+ function claimedIdentity(token) {
183
+ const claims = decodeTokenClaims(token);
184
+ const subject = claimedString(claims, "sub");
185
+ const userId = subject?.startsWith(WORKSPACE_SUBJECT_PREFIX) ? void 0 : subject;
186
+ const email = claimedString(claims, "email");
187
+ return userId === void 0 && email === void 0 ? void 0 : {
188
+ userId,
189
+ email,
190
+ name: void 0
191
+ };
192
+ }
193
+ //#endregion
194
+ //#region src/active-access-token.ts
195
+ /** Shared implementation used by every CredentialManager. */
196
+ async function readActiveAccessToken(storage, refreshCredential, options) {
197
+ const runLocked = storage.withRefreshLock ?? (async (fn) => fn());
198
+ try {
199
+ return await runLocked(async () => {
200
+ const current = await storage.getTokens();
201
+ if (current === null) return null;
202
+ if (!expiresSoon(current.accessToken, options, current.expiresAt)) return current.accessToken;
203
+ if (!current.refreshToken) throw credentialsRequiredError("expiring-soon");
204
+ if (refreshCredential === void 0) throw new Error("@prisma/cli-engine: delegated OAuth refresh requires Runtime.refreshCredential");
205
+ const refreshed = await refreshCredential({
206
+ refreshToken: current.refreshToken,
207
+ signal: options.signal
208
+ });
209
+ if (refreshed.kind === "invalid") {
210
+ await clearCurrentTokens(storage, current);
211
+ throw credentialsRequiredError("expired");
212
+ }
213
+ await storage.setTokens({
214
+ workspaceId: current.workspaceId,
215
+ accessToken: refreshed.accessToken,
216
+ refreshToken: refreshed.refreshToken
217
+ }, refreshed.expiresAt);
218
+ if (expiresSoon(refreshed.accessToken, options, refreshed.expiresAt)) throw new Error("the OAuth endpoint returned a short-lived token");
219
+ return refreshed.accessToken;
220
+ });
221
+ } catch (cause) {
222
+ if (CliStructuredError.is(cause) || options.signal.aborted) throw cause;
223
+ throw authServiceError();
224
+ }
225
+ }
226
+ function expiresSoon(token, options, fallbackExpiresAt) {
227
+ const expiresAt = claimedExpiresAt(token) ?? fallbackExpiresAt;
228
+ return expiresAt !== void 0 && expiresAt.getTime() - options.now.getTime() <= options.minimumValidityMs;
229
+ }
230
+ async function clearCurrentTokens(storage, current) {
231
+ if (storage.clearTokensIfCurrent !== void 0) {
232
+ await storage.clearTokensIfCurrent(current);
233
+ return;
234
+ }
235
+ await storage.clearTokens();
236
+ }
237
+ //#endregion
13
238
  //#region src/args.ts
14
239
  function flagRuntime(spec) {
15
240
  return spec;
@@ -171,14 +396,337 @@ function isChildStatusSettlement(value) {
171
396
  //#endregion
172
397
  //#region src/ci.ts
173
398
  /**
174
- * ci-info's own list of CI providers, read from the installed package
175
- * rather than copied here, so upgrading ci-info is what teaches the
176
- * engine a new provider. Its `isCI` export cannot be used instead: that
177
- * module evaluates against the real `process.env` the moment it is
178
- * imported, and the engine may only read the environment its host
179
- * injected.
399
+ * ci-info's provider table. Its `isCI` export is unusable — it reads
400
+ * the real `process.env` at import; the engine reads only host-injected
401
+ * env. The table is inlined into the build (tsdown `noExternal`): the
402
+ * file is CJS-owned by ci-info, and loading it as ESM at runtime breaks
403
+ * hosts that also require ci-info (Bun's dual registry; composer#234).
404
+ * Pinned by tests/no-esm-json-import-in-dist.test.ts.
180
405
  */
181
- const VENDORS = vendors;
406
+ const VENDORS = [
407
+ {
408
+ "name": "Agola CI",
409
+ "constant": "AGOLA",
410
+ "env": "AGOLA_GIT_REF",
411
+ "pr": "AGOLA_PULL_REQUEST_ID"
412
+ },
413
+ {
414
+ "name": "Alpic",
415
+ "constant": "ALPIC",
416
+ "env": "ALPIC_HOST"
417
+ },
418
+ {
419
+ "name": "Appcircle",
420
+ "constant": "APPCIRCLE",
421
+ "env": "AC_APPCIRCLE",
422
+ "pr": {
423
+ "env": "AC_GIT_PR",
424
+ "ne": "false"
425
+ }
426
+ },
427
+ {
428
+ "name": "AppVeyor",
429
+ "constant": "APPVEYOR",
430
+ "env": "APPVEYOR",
431
+ "pr": "APPVEYOR_PULL_REQUEST_NUMBER"
432
+ },
433
+ {
434
+ "name": "AWS CodeBuild",
435
+ "constant": "CODEBUILD",
436
+ "env": "CODEBUILD_BUILD_ARN",
437
+ "pr": {
438
+ "env": "CODEBUILD_WEBHOOK_EVENT",
439
+ "any": [
440
+ "PULL_REQUEST_CREATED",
441
+ "PULL_REQUEST_UPDATED",
442
+ "PULL_REQUEST_REOPENED"
443
+ ]
444
+ }
445
+ },
446
+ {
447
+ "name": "Azure Pipelines",
448
+ "constant": "AZURE_PIPELINES",
449
+ "env": "TF_BUILD",
450
+ "pr": { "BUILD_REASON": "PullRequest" }
451
+ },
452
+ {
453
+ "name": "Bamboo",
454
+ "constant": "BAMBOO",
455
+ "env": "bamboo_planKey"
456
+ },
457
+ {
458
+ "name": "Bitbucket Pipelines",
459
+ "constant": "BITBUCKET",
460
+ "env": "BITBUCKET_COMMIT",
461
+ "pr": "BITBUCKET_PR_ID"
462
+ },
463
+ {
464
+ "name": "Bitrise",
465
+ "constant": "BITRISE",
466
+ "env": "BITRISE_IO",
467
+ "pr": "BITRISE_PULL_REQUEST"
468
+ },
469
+ {
470
+ "name": "Buddy",
471
+ "constant": "BUDDY",
472
+ "env": "BUDDY_WORKSPACE_ID",
473
+ "pr": "BUDDY_EXECUTION_PULL_REQUEST_ID"
474
+ },
475
+ {
476
+ "name": "Buildkite",
477
+ "constant": "BUILDKITE",
478
+ "env": "BUILDKITE",
479
+ "pr": {
480
+ "env": "BUILDKITE_PULL_REQUEST",
481
+ "ne": "false"
482
+ }
483
+ },
484
+ {
485
+ "name": "CircleCI",
486
+ "constant": "CIRCLE",
487
+ "env": "CIRCLECI",
488
+ "pr": "CIRCLE_PULL_REQUEST"
489
+ },
490
+ {
491
+ "name": "Cirrus CI",
492
+ "constant": "CIRRUS",
493
+ "env": "CIRRUS_CI",
494
+ "pr": "CIRRUS_PR"
495
+ },
496
+ {
497
+ "name": "Cloudflare Pages",
498
+ "constant": "CLOUDFLARE_PAGES",
499
+ "env": "CF_PAGES"
500
+ },
501
+ {
502
+ "name": "Cloudflare Workers",
503
+ "constant": "CLOUDFLARE_WORKERS",
504
+ "env": "WORKERS_CI"
505
+ },
506
+ {
507
+ "name": "Codefresh",
508
+ "constant": "CODEFRESH",
509
+ "env": "CF_BUILD_ID",
510
+ "pr": { "any": ["CF_PULL_REQUEST_NUMBER", "CF_PULL_REQUEST_ID"] }
511
+ },
512
+ {
513
+ "name": "Codemagic",
514
+ "constant": "CODEMAGIC",
515
+ "env": "CM_BUILD_ID",
516
+ "pr": "CM_PULL_REQUEST"
517
+ },
518
+ {
519
+ "name": "Codeship",
520
+ "constant": "CODESHIP",
521
+ "env": { "CI_NAME": "codeship" }
522
+ },
523
+ {
524
+ "name": "Drone",
525
+ "constant": "DRONE",
526
+ "env": "DRONE",
527
+ "pr": { "DRONE_BUILD_EVENT": "pull_request" }
528
+ },
529
+ {
530
+ "name": "dsari",
531
+ "constant": "DSARI",
532
+ "env": "DSARI"
533
+ },
534
+ {
535
+ "name": "Earthly",
536
+ "constant": "EARTHLY",
537
+ "env": "EARTHLY_CI"
538
+ },
539
+ {
540
+ "name": "Expo Application Services",
541
+ "constant": "EAS",
542
+ "env": "EAS_BUILD"
543
+ },
544
+ {
545
+ "name": "Gerrit",
546
+ "constant": "GERRIT",
547
+ "env": "GERRIT_PROJECT"
548
+ },
549
+ {
550
+ "name": "Gitea Actions",
551
+ "constant": "GITEA_ACTIONS",
552
+ "env": "GITEA_ACTIONS"
553
+ },
554
+ {
555
+ "name": "GitHub Actions",
556
+ "constant": "GITHUB_ACTIONS",
557
+ "env": "GITHUB_ACTIONS",
558
+ "pr": { "GITHUB_EVENT_NAME": "pull_request" }
559
+ },
560
+ {
561
+ "name": "GitLab CI",
562
+ "constant": "GITLAB",
563
+ "env": "GITLAB_CI",
564
+ "pr": "CI_MERGE_REQUEST_ID"
565
+ },
566
+ {
567
+ "name": "GoCD",
568
+ "constant": "GOCD",
569
+ "env": "GO_PIPELINE_LABEL"
570
+ },
571
+ {
572
+ "name": "Google Cloud Build",
573
+ "constant": "GOOGLE_CLOUD_BUILD",
574
+ "env": "BUILDER_OUTPUT"
575
+ },
576
+ {
577
+ "name": "Harness CI",
578
+ "constant": "HARNESS",
579
+ "env": "HARNESS_BUILD_ID"
580
+ },
581
+ {
582
+ "name": "Heroku",
583
+ "constant": "HEROKU",
584
+ "env": {
585
+ "env": "NODE",
586
+ "includes": "/app/.heroku/node/bin/node"
587
+ }
588
+ },
589
+ {
590
+ "name": "Hudson",
591
+ "constant": "HUDSON",
592
+ "env": "HUDSON_URL"
593
+ },
594
+ {
595
+ "name": "Jenkins",
596
+ "constant": "JENKINS",
597
+ "env": ["JENKINS_URL", "BUILD_ID"],
598
+ "pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
599
+ },
600
+ {
601
+ "name": "LayerCI",
602
+ "constant": "LAYERCI",
603
+ "env": "LAYERCI",
604
+ "pr": "LAYERCI_PULL_REQUEST"
605
+ },
606
+ {
607
+ "name": "Magnum CI",
608
+ "constant": "MAGNUM",
609
+ "env": "MAGNUM"
610
+ },
611
+ {
612
+ "name": "Netlify CI",
613
+ "constant": "NETLIFY",
614
+ "env": "NETLIFY",
615
+ "pr": {
616
+ "env": "PULL_REQUEST",
617
+ "ne": "false"
618
+ }
619
+ },
620
+ {
621
+ "name": "Nevercode",
622
+ "constant": "NEVERCODE",
623
+ "env": "NEVERCODE",
624
+ "pr": {
625
+ "env": "NEVERCODE_PULL_REQUEST",
626
+ "ne": "false"
627
+ }
628
+ },
629
+ {
630
+ "name": "Prow",
631
+ "constant": "PROW",
632
+ "env": "PROW_JOB_ID"
633
+ },
634
+ {
635
+ "name": "ReleaseHub",
636
+ "constant": "RELEASEHUB",
637
+ "env": "RELEASE_BUILD_ID"
638
+ },
639
+ {
640
+ "name": "Render",
641
+ "constant": "RENDER",
642
+ "env": "RENDER",
643
+ "pr": { "IS_PULL_REQUEST": "true" }
644
+ },
645
+ {
646
+ "name": "Sail CI",
647
+ "constant": "SAIL",
648
+ "env": "SAILCI",
649
+ "pr": "SAIL_PULL_REQUEST_NUMBER"
650
+ },
651
+ {
652
+ "name": "Screwdriver",
653
+ "constant": "SCREWDRIVER",
654
+ "env": "SCREWDRIVER",
655
+ "pr": {
656
+ "env": "SD_PULL_REQUEST",
657
+ "ne": "false"
658
+ }
659
+ },
660
+ {
661
+ "name": "Semaphore",
662
+ "constant": "SEMAPHORE",
663
+ "env": "SEMAPHORE",
664
+ "pr": "PULL_REQUEST_NUMBER"
665
+ },
666
+ {
667
+ "name": "Sourcehut",
668
+ "constant": "SOURCEHUT",
669
+ "env": { "CI_NAME": "sourcehut" }
670
+ },
671
+ {
672
+ "name": "Strider CD",
673
+ "constant": "STRIDER",
674
+ "env": "STRIDER"
675
+ },
676
+ {
677
+ "name": "TaskCluster",
678
+ "constant": "TASKCLUSTER",
679
+ "env": ["TASK_ID", "RUN_ID"]
680
+ },
681
+ {
682
+ "name": "TeamCity",
683
+ "constant": "TEAMCITY",
684
+ "env": "TEAMCITY_VERSION"
685
+ },
686
+ {
687
+ "name": "Travis CI",
688
+ "constant": "TRAVIS",
689
+ "env": "TRAVIS",
690
+ "pr": {
691
+ "env": "TRAVIS_PULL_REQUEST",
692
+ "ne": "false"
693
+ }
694
+ },
695
+ {
696
+ "name": "Vela",
697
+ "constant": "VELA",
698
+ "env": "VELA",
699
+ "pr": { "VELA_PULL_REQUEST": "1" }
700
+ },
701
+ {
702
+ "name": "Vercel",
703
+ "constant": "VERCEL",
704
+ "env": { "any": ["NOW_BUILDER", "VERCEL"] },
705
+ "pr": "VERCEL_GIT_PULL_REQUEST_ID"
706
+ },
707
+ {
708
+ "name": "Visual Studio App Center",
709
+ "constant": "APPCENTER",
710
+ "env": "APPCENTER_BUILD_ID"
711
+ },
712
+ {
713
+ "name": "Woodpecker",
714
+ "constant": "WOODPECKER",
715
+ "env": { "CI": "woodpecker" },
716
+ "pr": { "CI_BUILD_EVENT": "pull_request" }
717
+ },
718
+ {
719
+ "name": "Xcode Cloud",
720
+ "constant": "XCODE_CLOUD",
721
+ "env": "CI_XCODE_PROJECT",
722
+ "pr": "CI_PULL_REQUEST_NUMBER"
723
+ },
724
+ {
725
+ "name": "Xcode Server",
726
+ "constant": "XCODE_SERVER",
727
+ "env": "XCS"
728
+ }
729
+ ];
182
730
  /**
183
731
  * The variables ci-info checks outside the vendor table, catching CI
184
732
  * systems that set a conventional variable but have no table entry.
@@ -682,122 +1230,6 @@ function runCommand(manager, request) {
682
1230
  //#region src/presentation.ts
683
1231
  const PRESENTED = Symbol.for("prisma.cli-engine.presented");
684
1232
  //#endregion
685
- //#region src/credential-errors.ts
686
- const signInAction = {
687
- kind: "user-choice",
688
- label: "Sign in, then run the command again."
689
- };
690
- const useSessionAction = {
691
- kind: "run-command",
692
- label: "Make one of your workspace sessions current",
693
- command: "prisma auth workspace use"
694
- };
695
- /**
696
- * The single constructor of CLI.CREDENTIALS_REQUIRED. Raised
697
- * identically by the needs check, ctx.activeCredential, and the
698
- * engine's request path.
699
- */
700
- function credentialsRequiredError(reason = "unauthenticated") {
701
- switch (reason) {
702
- case "unauthenticated": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "You must be signed in to run this command.", { nextActions: [signInAction] });
703
- case "expired": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "Your session has expired — sign in again.", { nextActions: [signInAction] });
704
- case "expiring-soon": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "Your session expires too soon to run this command — sign in again.", {
705
- why: "This command hands your credentials to another program, which cannot refresh them while it runs.",
706
- nextActions: [signInAction]
707
- });
708
- case "session-ended": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "The workspace session this command was using has ended.", {
709
- why: "It was ended while the command was running (for example by another prisma process).",
710
- nextActions: [useSessionAction, signInAction]
711
- });
712
- case "sessions-held-none-selected": return new CliStructuredError("CLI.CREDENTIALS_REQUIRED", "No workspace session is current.", {
713
- why: "You have workspace sessions but none is current.",
714
- nextActions: [useSessionAction, signInAction]
715
- });
716
- }
717
- }
718
- /**
719
- * A refresh attempt failed transiently (the auth service, not the
720
- * credentials): nothing was cleared, and signing in again is not the
721
- * fix.
722
- */
723
- function authServiceError() {
724
- return new CliStructuredError("CLI.AUTH_SERVICE_ERROR", "The authentication service could not refresh your session.", {
725
- why: "The refresh attempt failed transiently; your stored credentials were left untouched.",
726
- nextActions: [{
727
- kind: "user-choice",
728
- label: "Run the command again; sign in again only if the problem persists."
729
- }]
730
- });
731
- }
732
- /**
733
- * The credential in force was rejected and could never be renewed — it
734
- * carries no refresh token. The ONE place wording differs by origin;
735
- * nothing else compares against `origin.source`.
736
- */
737
- function credentialRejectedError(origin, envVar) {
738
- return origin.source === "environment" ? serviceTokenRejectedError({ envVar }) : credentialsRequiredError("expired");
739
- }
740
- /**
741
- * A credential's workspace_id claim disagrees with the workspace it is
742
- * being stored under, or a rotated token would re-scope a session.
743
- * Raised by every CredentialManager, so a test sees what production
744
- * raises.
745
- */
746
- function credentialWorkspaceMismatchError(workspaceId) {
747
- return new CliStructuredError("AUTH.CREDENTIAL_WORKSPACE_MISMATCH", "That credential belongs to a different workspace.", {
748
- why: `The token's workspace_id claim does not name workspace '${workspaceId}'.`,
749
- nextActions: [{
750
- kind: "run-command",
751
- label: "Sign in again and pick the workspace you want",
752
- command: "prisma auth login"
753
- }]
754
- });
755
- }
756
- /**
757
- * The env var that supplies a session is set to a blank value. The one
758
- * structured error for it, raised identically by activeCredential(),
759
- * the needs check, and the engine's request path.
760
- */
761
- function emptyServiceTokenError(spec) {
762
- return new CliStructuredError("AUTH.SERVICE_TOKEN_EMPTY", `${spec.envVar} is set but empty.`, {
763
- why: `A blank token authenticates nothing, and ${spec.envVar} overrides your stored workspace sessions while it is set.`,
764
- nextActions: [{
765
- kind: "run-command",
766
- label: `Unset ${spec.envVar}`,
767
- command: `unset ${spec.envVar}`
768
- }, {
769
- kind: "user-choice",
770
- label: `Or set ${spec.envVar} to a valid service token.`
771
- }]
772
- });
773
- }
774
- /**
775
- * No session exists for the named workspace. Sessions are created by
776
- * `prisma auth login` alone — `workspace use` selects among the ones
777
- * you have.
778
- */
779
- function noSessionForWorkspaceError(workspaceRef) {
780
- return new CliStructuredError("AUTH.NO_SESSION_FOR_WORKSPACE", `You have no session for workspace '${workspaceRef}'.`, { nextActions: [{
781
- kind: "run-command",
782
- label: `Sign in and pick '${workspaceRef}' in the browser`,
783
- command: "prisma auth login"
784
- }] });
785
- }
786
- /**
787
- * Module-private on purpose: `credentialRejectedError` is the one place
788
- * wording differs by origin (§11.1), and exporting this would be a
789
- * second door into the environment-specific text that bypasses it.
790
- *
791
- * The management API rejected the env-supplied service token (401).
792
- * There is no refresh for it and nothing stored is cleared.
793
- */
794
- function serviceTokenRejectedError(spec) {
795
- return new CliStructuredError("AUTH.SERVICE_TOKEN_REJECTED", `The management API rejected the service token from ${spec.envVar}.`, { nextActions: [{
796
- kind: "user-choice",
797
- label: `Replace ${spec.envVar} with a valid service token, or unset it to use your stored sessions.`
798
- }] });
799
- }
800
- //#endregion
801
1233
  //#region src/credential-manager.ts
802
1234
  /** The environment variables that supply a credential to a process: a
803
1235
  * service token, plus the workspace it acts in when the token's own
@@ -922,7 +1354,7 @@ function observedTokenStorage(storage, active, debug, probe) {
922
1354
  };
923
1355
  return {
924
1356
  getTokens: () => storage.getTokens(),
925
- setTokens: (tokens) => storage.setTokens(tokens),
1357
+ setTokens: (tokens, expiresAt) => storage.setTokens(tokens, expiresAt),
926
1358
  clearTokens: () => storage.clearTokens(),
927
1359
  ...storage.clearTokensIfCurrent === void 0 ? {} : { clearTokensIfCurrent: (tokens) => storage.clearTokensIfCurrent(tokens) },
928
1360
  withRefreshLock: (fn) => storage.withRefreshLock === void 0 ? observedRefresh(fn) : storage.withRefreshLock(() => observedRefresh(fn))
@@ -2015,7 +2447,7 @@ function reportEvent(invocation, event) {
2015
2447
  return;
2016
2448
  }
2017
2449
  const terminal = state.delegatedTerminal;
2018
- if (terminal !== void 0) {
2450
+ if (terminal !== void 0 && state.format !== "json") {
2019
2451
  if (terminal.buffered.length >= 1e3) {
2020
2452
  terminal.dropped += 1;
2021
2453
  return;
@@ -2117,11 +2549,11 @@ async function checkDependencies(needs, invocation) {
2117
2549
  * ctx.api raise identically. A host with no manager wired has no
2118
2550
  * credentials at all.
2119
2551
  *
2120
- * The `"child"` form resolves the same credential ONCE, additionally
2121
- * refuses a session about to expire — before the handler runs, not
2122
- * before the spawn: the work that precedes a spawn creates real
2123
- * platform resources, and the child cannot refresh the snapshot it is
2124
- * given — and carries the credential forward for the spawn path.
2552
+ * The `"child"` form resolves the same credential ONCE and prepares an
2553
+ * access-token snapshot before the handler runs. A refreshable stored
2554
+ * OAuth session inside the near-expiry window is rotated and persisted;
2555
+ * an unrefreshable credential is refused. This happens before the
2556
+ * handler because work preceding a spawn may create platform resources.
2125
2557
  */
2126
2558
  async function checkCredentials(needs, invocation) {
2127
2559
  if (needs.credentials === false) return {};
@@ -2136,13 +2568,17 @@ async function checkCredentials(needs, invocation) {
2136
2568
  }
2137
2569
  if (credential === null) return { failure: needsErrored(credentialsRequiredError()) };
2138
2570
  if (needs.credentials !== "child") return {};
2139
- const expiry = nearExpiryFailure(credential, invocation);
2140
- return expiry === void 0 ? { spawnCredential: credential } : { failure: expiry };
2141
- }
2142
- function nearExpiryFailure(credential, invocation) {
2143
- if (credential.expiresAt === void 0) return;
2144
- if (credential.expiresAt.getTime() - invocation.now().getTime() > 3e5) return;
2145
- return needsErrored(credentialsRequiredError("expiring-soon"));
2571
+ try {
2572
+ if (await manager.activeAccessToken({
2573
+ minimumValidityMs: 3e5,
2574
+ now: invocation.now(),
2575
+ signal: invocation.signal
2576
+ }) === null) return { failure: needsErrored(credentialsRequiredError("session-ended")) };
2577
+ return { spawnCredential: credential };
2578
+ } catch (cause) {
2579
+ if (CliStructuredError.is(cause)) return { failure: needsErrored(cause) };
2580
+ throw cause;
2581
+ }
2146
2582
  }
2147
2583
  /**
2148
2584
  * A top-level key in the config file that is not one of the sections
@@ -2911,7 +3347,8 @@ async function runDelegated(invocation, def, terminal, spawnChild, options) {
2911
3347
  command: options.command,
2912
3348
  args: options.args ?? [],
2913
3349
  cwd: options.cwd ?? invocation.runtime.cwd,
2914
- env: await composeChildEnv(invocation, def, options.env)
3350
+ env: await composeChildEnv(invocation, def, options.env),
3351
+ output: state.format === "json" ? "diagnostic" : "inherit"
2915
3352
  };
2916
3353
  debug(`spawn: ${request.command} ${request.args.join(" ")} (cwd ${request.cwd})`);
2917
3354
  const result = await runChild(invocation, terminal, spawnChild, request);
@@ -3022,13 +3459,21 @@ async function composeChildEnv(invocation, def, additions) {
3022
3459
  }
3023
3460
  /**
3024
3461
  * The child's copy of the credential: the manager's activeAccessToken()
3025
- * operation, read at spawn time. The refresh token is never injected:
3026
- * the child runs on a snapshot it cannot refresh.
3462
+ * operation, read fresh at spawn time. The near-expiry policy already ran
3463
+ * at preflight, before the handler; the spawn-time read refuses only a
3464
+ * token that is already expired, so a still-valid credential can never be
3465
+ * refused after the handler's pre-spawn work has created resources. The
3466
+ * refresh token is never injected: the child runs on a snapshot it cannot
3467
+ * refresh.
3027
3468
  */
3028
3469
  async function spawnToken(invocation) {
3029
3470
  const manager = invocation.runtime.credentialManager;
3030
3471
  if (manager === void 0) throw credentialsRequiredError();
3031
- const accessToken = await manager.activeAccessToken();
3472
+ const accessToken = await manager.activeAccessToken({
3473
+ minimumValidityMs: 0,
3474
+ now: invocation.now(),
3475
+ signal: invocation.signal
3476
+ });
3032
3477
  if (accessToken === null) throw credentialsRequiredError("session-ended");
3033
3478
  return accessToken;
3034
3479
  }
@@ -3360,27 +3805,19 @@ function commandParameters(def) {
3360
3805
  function resolveExample(example, cliName) {
3361
3806
  return example.includes("{bin}") ? example.replaceAll("{bin}", cliName) : `${cliName} ${example}`;
3362
3807
  }
3363
- /** The --json refusal is stated in help, so a machine consumer learns
3364
- * it without running the command. */
3365
- const NO_JSON_NOTE = "This command hands the terminal to another program and does not support --json.";
3366
3808
  function commandDocs(def, cliName) {
3367
3809
  const examples = def.help.examples.map((example) => resolveExample(example, cliName));
3368
- const notes = def.maySpawn ? ["", NO_JSON_NOTE] : [];
3369
- if (examples.length === 0 && notes.length === 0) return {
3810
+ if (examples.length === 0) return {
3370
3811
  brief: def.help.summary,
3371
3812
  fullDescription: def.help.description
3372
3813
  };
3373
3814
  return {
3374
3815
  brief: def.help.summary,
3375
- fullDescription: [
3376
- def.help.description ?? def.help.summary,
3377
- ...notes,
3378
- ...examples.length === 0 ? [] : [
3379
- "",
3380
- "Examples:",
3381
- ...examples.map((example) => ` ${example}`)
3382
- ]
3383
- ].join("\n")
3816
+ fullDescription: [def.help.description ?? def.help.summary, ...examples.length === 0 ? [] : [
3817
+ "",
3818
+ "Examples:",
3819
+ ...examples.map((example) => ` ${example}`)
3820
+ ]].join("\n")
3384
3821
  };
3385
3822
  }
3386
3823
  function toStricliCommand(entry, cliName, runEntry) {
@@ -3714,10 +4151,6 @@ function renderLeafHelp(spec, entry, path, paint, lines) {
3714
4151
  lines.push(rail(paint));
3715
4152
  proseLines(def.help.description, paint, lines);
3716
4153
  }
3717
- if (def.maySpawn) {
3718
- lines.push(rail(paint));
3719
- lines.push(rail(paint, paint("muted", NO_JSON_NOTE)));
3720
- }
3721
4154
  const positionalEntries = Object.values(def.args.positionals).map((spec) => positionalRuntime(spec));
3722
4155
  if (positionalEntries.length > 0) {
3723
4156
  lines.push(rail(paint));
@@ -3873,9 +4306,8 @@ function settleVerbatimExitCode(invocation, exitCode) {
3873
4306
  * The status comes from the engine's own record of the child, never
3874
4307
  * from the handler, so there is nothing here for a handler to state.
3875
4308
  * Two conditions fence it, both construction errors: the command must
3876
- * hand the terminal to another program — reachable from a
3877
- * non-declaring handler this would also end a json stream without its
3878
- * terminal result frame — and a child must actually have run.
4309
+ * declare that it can hand execution to another program, and a child must
4310
+ * actually have run.
3879
4311
  *
3880
4312
  * A signal-killed child overrules whatever the handler asked for. The
3881
4313
  * user stopped the run: it settles 128 + the signal number, with no
@@ -3885,8 +4317,50 @@ function settleChildStatus(invocation, def, settlement) {
3885
4317
  if (!def.maySpawn) throw new Error(`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus without declaring maySpawn — only a command that hands the terminal to another program may settle with that program's status`);
3886
4318
  const child = invocation.state.lastChild;
3887
4319
  if (child === void 0) throw new Error(`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus without a child having run — that settlement reports the status of a child ctx.spawn started, and this run started none`);
4320
+ const exitCode = childExitCode(child);
4321
+ if (invocation.state.format === "json") {
4322
+ settleStructuredChildStatus(invocation, settlement, child, exitCode);
4323
+ return;
4324
+ }
3888
4325
  if (child.signal === null) for (const action of settlement.nextActions) invocation.runtime.stderr.write(`${renderNextAction(action, makePaint(invocation.state.colorEnabled))}\n`);
3889
- settleVerbatimExitCode(invocation, childExitCode(child));
4326
+ settleVerbatimExitCode(invocation, exitCode);
4327
+ }
4328
+ function settleStructuredChildStatus(invocation, settlement, child, exitCode) {
4329
+ settleVerbatimExitCode(invocation, exitCode);
4330
+ const nextActions = child.signal === null ? settlement.nextActions : [];
4331
+ if (exitCode === 0) {
4332
+ emitFrame(invocation, {
4333
+ kind: "result",
4334
+ envelope: {
4335
+ ok: true,
4336
+ commandId: invocation.state.commandId,
4337
+ result: null,
4338
+ exitCode,
4339
+ diagnostics: [],
4340
+ nextActions
4341
+ },
4342
+ commandId: invocation.state.commandId,
4343
+ timestamp: invocation.now().toISOString()
4344
+ });
4345
+ return;
4346
+ }
4347
+ const how = child.signal === null ? `exited with code ${String(child.exitCode ?? "unknown")}` : `was terminated by ${child.signal}`;
4348
+ emitErrored(invocation, {
4349
+ ok: false,
4350
+ commandId: invocation.state.commandId,
4351
+ error: {
4352
+ code: "CLI.CHILD_PROCESS_FAILED",
4353
+ severity: "error",
4354
+ summary: `The delegated process ${how}.`,
4355
+ nextActions,
4356
+ meta: {
4357
+ exitCode: child.exitCode,
4358
+ signal: child.signal
4359
+ }
4360
+ },
4361
+ diagnostics: [],
4362
+ nextActions
4363
+ });
3890
4364
  }
3891
4365
  /** A session command that returned ok shut down cleanly: no
3892
4366
  * presentation, and exit 0 — unless a signal ended the run, which
@@ -4277,18 +4751,11 @@ var EngineImpl = class {
4277
4751
  hooks.onSettled(summary);
4278
4752
  } catch {}
4279
4753
  }
4280
- /** The refusals a maySpawn command can hit before anything runs: a
4281
- * child's terminal output cannot be framed as a json stream, and a
4282
- * host that mounts the command without a spawn adapter is
4283
- * misconfigured. Returns whether the run was settled here. */
4754
+ /** A host that mounts a maySpawn command without a spawn adapter is
4755
+ * misconfigured. Refuse before needs or handler side effects. */
4284
4756
  refuseUnspawnable(invocation, entry) {
4285
4757
  const state = invocation.state;
4286
4758
  if (!entry.def.maySpawn) return false;
4287
- if (formatFlagGiven(state.argv) === "json") {
4288
- state.format = "human";
4289
- settleErrored(invocation, jsonUnsupportedError(entry.id));
4290
- return true;
4291
- }
4292
4759
  if (invocation.runtime.spawn === void 0) {
4293
4760
  state.format = "human";
4294
4761
  settleBug(invocation, /* @__PURE__ */ new Error(`@prisma/cli-engine: command '${entry.id}' declares maySpawn but the Runtime supplies no spawn adapter`));
@@ -4345,10 +4812,9 @@ var EngineImpl = class {
4345
4812
  let needsOutcome;
4346
4813
  try {
4347
4814
  applySharedFlags(state, rawFlags, invocation.runtime);
4348
- if (entry.def.maySpawn) state.format = "human";
4349
4815
  needsOutcome = await checkNeeds(entry.def, invocation);
4350
4816
  } catch (cause) {
4351
- settleBug(invocation, cause);
4817
+ settleThrown(invocation, cause);
4352
4818
  return;
4353
4819
  }
4354
4820
  if (needsOutcome.kind === "errored") {
@@ -4396,7 +4862,7 @@ var EngineImpl = class {
4396
4862
  try {
4397
4863
  needsOutcome = await checkNeeds(entry.def, invocation);
4398
4864
  } catch (cause) {
4399
- settleBug(invocation, cause);
4865
+ settleThrown(invocation, cause);
4400
4866
  return;
4401
4867
  }
4402
4868
  if (needsOutcome.kind === "errored") {
@@ -4452,18 +4918,6 @@ function attemptedPath(argv) {
4452
4918
  function declaredConfigSections(spec) {
4453
4919
  return [...new Set([...spec.commandFamilies.map((commandFamily) => commandFamily.configSection?.name), ...Object.values(spec.commands).map((def) => def.needs.config?.name)].filter((name) => name !== void 0))];
4454
4920
  }
4455
- /** A command that may hand the terminal to a child cannot frame its
4456
- * output, so json is refused as soon as the command is known — before
4457
- * the needs check and before anything runs. */
4458
- function jsonUnsupportedError(commandId) {
4459
- return new CliStructuredError("CLI.JSON_UNSUPPORTED", `The '${commandId.replaceAll(".", " ")}' command does not support json output.`, {
4460
- why: "It hands the terminal to another program, whose output cannot be framed as a json stream.",
4461
- nextActions: [{
4462
- kind: "user-choice",
4463
- label: "Run it without --json or --format json."
4464
- }]
4465
- });
4466
- }
4467
4921
  function declaredCapabilities(def) {
4468
4922
  if (def.kind !== "result-command") return {
4469
4923
  managesCredentials: false,
@@ -4492,70 +4946,4 @@ function distributePositionals(def, values) {
4492
4946
  return positionals;
4493
4947
  }
4494
4948
  //#endregion
4495
- //#region src/token-claims.ts
4496
- /**
4497
- * Reading a credential's own claims. This lives in the engine and is
4498
- * shared rather than reimplemented, because both credential managers
4499
- * need it and the two copies had already drifted: one knew a service
4500
- * token names its workspace through `sub`, the other did not, so a
4501
- * token that worked in production could not be reproduced in a test.
4502
- *
4503
- * Decoding only. Nothing here verifies a signature — the claims are the
4504
- * issuer's word, used for display and for keying, never for authorizing.
4505
- */
4506
- /** A service token's subject is its workspace, not a person. */
4507
- const WORKSPACE_SUBJECT_PREFIX = "workspace:";
4508
- function decodeTokenClaims(token) {
4509
- const payload = token.split(".")[1];
4510
- if (payload === void 0) return void 0;
4511
- try {
4512
- const parsed = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
4513
- return typeof parsed === "object" && parsed !== null ? parsed : void 0;
4514
- } catch {
4515
- return;
4516
- }
4517
- }
4518
- function claimedString(claims, name) {
4519
- const value = claims?.[name];
4520
- return typeof value === "string" && value.length > 0 ? value : void 0;
4521
- }
4522
- /**
4523
- * The workspace a credential names. One derivation, because a token
4524
- * says it one of two ways and every caller wants the same answer: an
4525
- * OAuth token carries `workspace_id`, while a service token names its
4526
- * workspace through `sub` and carries no `workspace_id` at all. Reading
4527
- * only the claim was a second path that happened to work because
4528
- * service tokens reached it by a different route — a split nothing
4529
- * enforced.
4530
- */
4531
- function credentialWorkspaceId(token) {
4532
- const claims = decodeTokenClaims(token);
4533
- const fromClaim = claimedString(claims, "workspace_id");
4534
- if (fromClaim !== void 0) return fromClaim;
4535
- const subject = claimedString(claims, "sub");
4536
- if (subject === void 0 || !subject.startsWith(WORKSPACE_SUBJECT_PREFIX)) return;
4537
- const derived = subject.slice(10).trim();
4538
- return derived.length > 0 ? derived : void 0;
4539
- }
4540
- function claimedExpiresAt(token) {
4541
- const exp = decodeTokenClaims(token)?.exp;
4542
- return typeof exp === "number" ? /* @__PURE__ */ new Date(exp * 1e3) : void 0;
4543
- }
4544
- /**
4545
- * Who a credential belongs to, from its own claims. A service token's
4546
- * subject names a workspace rather than a person, so it yields no user
4547
- * — reporting `workspace:ws_1` as a user id was a real defect.
4548
- */
4549
- function claimedIdentity(token) {
4550
- const claims = decodeTokenClaims(token);
4551
- const subject = claimedString(claims, "sub");
4552
- const userId = subject?.startsWith(WORKSPACE_SUBJECT_PREFIX) ? void 0 : subject;
4553
- const email = claimedString(claims, "email");
4554
- return userId === void 0 && email === void 0 ? void 0 : {
4555
- userId,
4556
- email,
4557
- name: void 0
4558
- };
4559
- }
4560
- //#endregion
4561
- export { exitWithChildStatus as C, resolveGating as S, positional as T, noSessionForWorkspaceError as _, CONFIG_FILE_NAME as a, userConfigPath as b, loadConfig as c, WORKSPACE_ID_ENV_VAR as d, authServiceError as f, emptyServiceTokenError as g, credentialsRequiredError as h, buildEngine as i, PRISMA_CONFIG_VERSION as l, credentialWorkspaceMismatchError as m, claimedIdentity as n, defineConfig as o, credentialRejectedError as p, credentialWorkspaceId as r, definePrismaConfig as s, claimedExpiresAt as t, SERVICE_TOKEN_ENV_VAR as u, PRESENTED as v, flag as w, writeUserConfig as x, readUserConfig as y };
4949
+ export { credentialWorkspaceMismatchError as C, noSessionForWorkspaceError as E, credentialRejectedError as S, emptyServiceTokenError as T, readActiveAccessToken as _, loadConfig as a, credentialWorkspaceId as b, WORKSPACE_ID_ENV_VAR as c, userConfigPath as d, writeUserConfig as f, positional as g, flag as h, definePrismaConfig as i, PRESENTED as l, exitWithChildStatus as m, CONFIG_FILE_NAME as n, PRISMA_CONFIG_VERSION as o, resolveGating as p, defineConfig as r, SERVICE_TOKEN_ENV_VAR as s, buildEngine as t, readUserConfig as u, claimedExpiresAt as v, credentialsRequiredError as w, authServiceError as x, claimedIdentity as y };