@ora-ai/cli 0.23.0 → 0.25.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.
- package/CHANGELOG.md +77 -0
- package/README.md +44 -13
- package/dist/agent-skills/skills-command.d.ts.map +1 -1
- package/dist/agent-skills/skills-command.js +2 -2
- package/dist/agent-skills/skills-command.js.map +1 -1
- package/dist/auth-commands.d.ts +25 -9
- package/dist/auth-commands.d.ts.map +1 -1
- package/dist/auth-commands.js +59 -49
- package/dist/auth-commands.js.map +1 -1
- package/dist/core/auth.d.ts +2 -2
- package/dist/core/auth.d.ts.map +1 -1
- package/dist/core/auth.js +5 -4
- package/dist/core/auth.js.map +1 -1
- package/dist/core/cli-arguments.d.ts +21 -0
- package/dist/core/cli-arguments.d.ts.map +1 -0
- package/dist/core/cli-arguments.js +53 -0
- package/dist/core/cli-arguments.js.map +1 -0
- package/dist/core/config.d.ts +10 -5
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +10 -7
- package/dist/core/config.js.map +1 -1
- package/dist/core/credentials/api-key-credential.d.ts +29 -0
- package/dist/core/credentials/api-key-credential.d.ts.map +1 -0
- package/dist/core/credentials/api-key-credential.js +58 -0
- package/dist/core/credentials/api-key-credential.js.map +1 -0
- package/dist/core/credentials/ci-oidc-credential.d.ts +44 -0
- package/dist/core/credentials/ci-oidc-credential.d.ts.map +1 -0
- package/dist/core/credentials/ci-oidc-credential.js +82 -0
- package/dist/core/credentials/ci-oidc-credential.js.map +1 -0
- package/dist/core/credentials/credential-chain.d.ts +25 -0
- package/dist/core/credentials/credential-chain.d.ts.map +1 -0
- package/dist/core/credentials/credential-chain.js +39 -0
- package/dist/core/credentials/credential-chain.js.map +1 -0
- package/dist/core/credentials/credential.d.ts +73 -0
- package/dist/core/credentials/credential.d.ts.map +1 -0
- package/dist/core/credentials/credential.js +9 -0
- package/dist/core/credentials/credential.js.map +1 -0
- package/dist/core/credentials/device-session-credential.d.ts +27 -0
- package/dist/core/credentials/device-session-credential.d.ts.map +1 -0
- package/dist/core/credentials/device-session-credential.js +78 -0
- package/dist/core/credentials/device-session-credential.js.map +1 -0
- package/dist/core/credentials/identity-lines.d.ts +14 -0
- package/dist/core/credentials/identity-lines.d.ts.map +1 -0
- package/dist/core/credentials/identity-lines.js +45 -0
- package/dist/core/credentials/identity-lines.js.map +1 -0
- package/dist/core/credentials/refusal-words.d.ts +15 -0
- package/dist/core/credentials/refusal-words.d.ts.map +1 -0
- package/dist/core/credentials/refusal-words.js +56 -0
- package/dist/core/credentials/refusal-words.js.map +1 -0
- package/dist/core/credentials/sign-in-areas.d.ts +18 -0
- package/dist/core/credentials/sign-in-areas.d.ts.map +1 -0
- package/dist/core/credentials/sign-in-areas.js +22 -0
- package/dist/core/credentials/sign-in-areas.js.map +1 -0
- package/dist/core/http.d.ts +10 -4
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +7 -5
- package/dist/core/http.js.map +1 -1
- package/dist/core/identity.d.ts +11 -0
- package/dist/core/identity.d.ts.map +1 -0
- package/dist/core/identity.js +21 -0
- package/dist/core/identity.js.map +1 -0
- package/dist/core/limit-story.d.ts +11 -0
- package/dist/core/limit-story.d.ts.map +1 -0
- package/dist/core/limit-story.js +16 -0
- package/dist/core/limit-story.js.map +1 -0
- package/dist/core/login.d.ts +5 -3
- package/dist/core/login.d.ts.map +1 -1
- package/dist/core/login.js +5 -3
- package/dist/core/login.js.map +1 -1
- package/dist/core/oauth/metadata.d.ts +24 -0
- package/dist/core/oauth/metadata.d.ts.map +1 -0
- package/dist/core/oauth/metadata.js +99 -0
- package/dist/core/oauth/metadata.js.map +1 -0
- package/dist/core/oauth/oauth-client.d.ts +70 -0
- package/dist/core/oauth/oauth-client.d.ts.map +1 -0
- package/dist/core/oauth/oauth-client.js +136 -0
- package/dist/core/oauth/oauth-client.js.map +1 -0
- package/dist/core/oauth/oauth-error.d.ts +18 -0
- package/dist/core/oauth/oauth-error.d.ts.map +1 -0
- package/dist/core/oauth/oauth-error.js +31 -0
- package/dist/core/oauth/oauth-error.js.map +1 -0
- package/dist/core/oauth/sign-in-error.d.ts +15 -0
- package/dist/core/oauth/sign-in-error.d.ts.map +1 -0
- package/dist/core/oauth/sign-in-error.js +21 -0
- package/dist/core/oauth/sign-in-error.js.map +1 -0
- package/dist/core/oauth/sign-in-target.d.ts +31 -0
- package/dist/core/oauth/sign-in-target.d.ts.map +1 -0
- package/dist/core/oauth/sign-in-target.js +44 -0
- package/dist/core/oauth/sign-in-target.js.map +1 -0
- package/dist/core/output.d.ts +14 -3
- package/dist/core/output.d.ts.map +1 -1
- package/dist/core/output.js +38 -38
- package/dist/core/output.js.map +1 -1
- package/dist/core/retry-after.d.ts +8 -0
- package/dist/core/retry-after.d.ts.map +1 -0
- package/dist/core/retry-after.js +18 -0
- package/dist/core/retry-after.js.map +1 -0
- package/dist/core/run-operation.d.ts +26 -10
- package/dist/core/run-operation.d.ts.map +1 -1
- package/dist/core/run-operation.js +40 -21
- package/dist/core/run-operation.js.map +1 -1
- package/dist/core/session/device-session-auth.d.ts +29 -0
- package/dist/core/session/device-session-auth.d.ts.map +1 -0
- package/dist/core/session/device-session-auth.js +92 -0
- package/dist/core/session/device-session-auth.js.map +1 -0
- package/dist/core/session/file-lock.d.ts +33 -0
- package/dist/core/session/file-lock.d.ts.map +1 -0
- package/dist/core/session/file-lock.js +145 -0
- package/dist/core/session/file-lock.js.map +1 -0
- package/dist/core/session/session-refusals.d.ts +22 -0
- package/dist/core/session/session-refusals.d.ts.map +1 -0
- package/dist/core/session/session-refusals.js +23 -0
- package/dist/core/session/session-refusals.js.map +1 -0
- package/dist/core/session/session-store.d.ts +53 -0
- package/dist/core/session/session-store.d.ts.map +1 -0
- package/dist/core/session/session-store.js +71 -0
- package/dist/core/session/session-store.js.map +1 -0
- package/dist/core/sign-in.d.ts +2 -2
- package/dist/core/sign-in.js +2 -2
- package/dist/core/token-expiry.d.ts +9 -0
- package/dist/core/token-expiry.d.ts.map +1 -0
- package/dist/core/token-expiry.js +11 -0
- package/dist/core/token-expiry.js.map +1 -0
- package/dist/core/url.d.ts +5 -0
- package/dist/core/url.d.ts.map +1 -0
- package/dist/core/url.js +17 -0
- package/dist/core/url.js.map +1 -0
- package/dist/generated/operations.d.ts +2 -1
- package/dist/generated/operations.d.ts.map +1 -1
- package/dist/generated/operations.js +32 -5
- package/dist/generated/operations.js.map +1 -1
- package/dist/generated/types.d.ts +584 -0
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/generated/types.js +1 -1
- package/dist/interactive/menu.d.ts.map +1 -1
- package/dist/interactive/menu.js +4 -2
- package/dist/interactive/menu.js.map +1 -1
- package/dist/interactive/session.d.ts.map +1 -1
- package/dist/interactive/session.js +17 -8
- package/dist/interactive/session.js.map +1 -1
- package/dist/login/browser-opener.d.ts +20 -0
- package/dist/login/browser-opener.d.ts.map +1 -0
- package/dist/login/browser-opener.js +43 -0
- package/dist/login/browser-opener.js.map +1 -0
- package/dist/login/device-flow.d.ts +60 -0
- package/dist/login/device-flow.d.ts.map +1 -0
- package/dist/login/device-flow.js +98 -0
- package/dist/login/device-flow.js.map +1 -0
- package/dist/login/device-login.d.ts +27 -0
- package/dist/login/device-login.d.ts.map +1 -0
- package/dist/login/device-login.js +148 -0
- package/dist/login/device-login.js.map +1 -0
- package/dist/login/device-presenter.d.ts +24 -0
- package/dist/login/device-presenter.d.ts.map +1 -0
- package/dist/login/device-presenter.js +69 -0
- package/dist/login/device-presenter.js.map +1 -0
- package/dist/login/login-command.d.ts +14 -0
- package/dist/login/login-command.d.ts.map +1 -0
- package/dist/login/login-command.js +73 -0
- package/dist/login/login-command.js.map +1 -0
- package/dist/login/login-deps.d.ts +17 -0
- package/dist/login/login-deps.d.ts.map +1 -0
- package/dist/login/login-deps.js +18 -0
- package/dist/login/login-deps.js.map +1 -0
- package/dist/login/piped-input.d.ts +23 -0
- package/dist/login/piped-input.d.ts.map +1 -0
- package/dist/login/piped-input.js +36 -0
- package/dist/login/piped-input.js.map +1 -0
- package/dist/login/requested-scopes.d.ts +22 -0
- package/dist/login/requested-scopes.d.ts.map +1 -0
- package/dist/login/requested-scopes.js +43 -0
- package/dist/login/requested-scopes.js.map +1 -0
- package/dist/program.d.ts +16 -5
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +35 -10
- package/dist/program.js.map +1 -1
- package/dist/study-ci/ci-command.d.ts.map +1 -1
- package/dist/study-ci/ci-command.js +2 -2
- package/dist/study-ci/ci-command.js.map +1 -1
- package/dist/study-ci/ci-rehearse-command.d.ts.map +1 -1
- package/dist/study-ci/ci-rehearse-command.js +2 -2
- package/dist/study-ci/ci-rehearse-command.js.map +1 -1
- package/dist/tunnel/connection-end.d.ts +30 -0
- package/dist/tunnel/connection-end.d.ts.map +1 -0
- package/dist/tunnel/connection-end.js +29 -0
- package/dist/tunnel/connection-end.js.map +1 -0
- package/dist/tunnel-command.d.ts.map +1 -1
- package/dist/tunnel-command.js +24 -8
- package/dist/tunnel-command.js.map +1 -1
- package/package.json +3 -2
- package/dist/core/credential-sources.d.ts +0 -45
- package/dist/core/credential-sources.d.ts.map +0 -1
- package/dist/core/credential-sources.js +0 -65
- package/dist/core/credential-sources.js.map +0 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A browser sign-in (the device flow, RFC 8628): the person approved this CLI in their browser, and session.json
|
|
3
|
+
* holds the result. Requests carry the session's OAuth access token as it is; the API converts it internally, so
|
|
4
|
+
* the CLI holds no platform token and keeps no token cache for it.
|
|
5
|
+
*/
|
|
6
|
+
import { readIdentity } from "../identity.js";
|
|
7
|
+
import { OAuthClient } from "../oauth/oauth-client.js";
|
|
8
|
+
import { DeviceSessionAuth } from "../session/device-session-auth.js";
|
|
9
|
+
import { SessionStore } from "../session/session-store.js";
|
|
10
|
+
import { signInIdentityLines } from "./identity-lines.js";
|
|
11
|
+
import { DEVICE_SESSION_WORDS } from "./refusal-words.js";
|
|
12
|
+
/** The session's own authorization server, at the endpoints recorded when it was made. */
|
|
13
|
+
export function sessionOAuthClient(session, rt) {
|
|
14
|
+
return new OAuthClient({
|
|
15
|
+
endpoints: {
|
|
16
|
+
tokenEndpoint: session.tokenEndpoint,
|
|
17
|
+
...(session.revocationEndpoint ? { revocationEndpoint: session.revocationEndpoint } : {}),
|
|
18
|
+
},
|
|
19
|
+
clientId: session.clientId,
|
|
20
|
+
fetchFn: rt.fetchFn ?? fetch,
|
|
21
|
+
now: rt.now ?? Date.now,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/** Revokes a session's refresh token, which ends its grant. Best effort: false when it could not be revoked. */
|
|
25
|
+
export async function revokeSession(session, rt) {
|
|
26
|
+
if (!session.refreshToken)
|
|
27
|
+
return false;
|
|
28
|
+
try {
|
|
29
|
+
return await sessionOAuthClient(session, rt).revoke(session.refreshToken, "refresh_token");
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false; // unreachable server: the grant lapses on its own
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class DeviceSessionCredential {
|
|
36
|
+
session;
|
|
37
|
+
kind = "device_session";
|
|
38
|
+
source = "device sign-in";
|
|
39
|
+
words = DEVICE_SESSION_WORDS;
|
|
40
|
+
identityLines = signInIdentityLines(this.source);
|
|
41
|
+
constructor(session) {
|
|
42
|
+
this.session = session;
|
|
43
|
+
}
|
|
44
|
+
createAuth(rt) {
|
|
45
|
+
const refresher = {
|
|
46
|
+
refresh: (session) => {
|
|
47
|
+
if (!session.refreshToken)
|
|
48
|
+
throw new Error("no refresh token");
|
|
49
|
+
return sessionOAuthClient(session, rt).refresh(session.refreshToken, session.resource);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
return new DeviceSessionAuth({
|
|
53
|
+
apiUrl: rt.apiUrl,
|
|
54
|
+
store: new SessionStore(rt.dir),
|
|
55
|
+
refresher,
|
|
56
|
+
...(rt.now ? { now: rt.now } : {}),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** What the API says of the access token it is sent: the person, their organization, what they allowed. */
|
|
60
|
+
readIdentity({ client }) {
|
|
61
|
+
return readIdentity(client());
|
|
62
|
+
}
|
|
63
|
+
/** Revokes the refresh token (which ends the grant) when the server offers revocation, then removes the session. */
|
|
64
|
+
async forget(rt) {
|
|
65
|
+
const store = new SessionStore(rt.dir);
|
|
66
|
+
await revokeSession(store.read() ?? this.session, rt);
|
|
67
|
+
store.clear();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export const deviceSessionProvider = {
|
|
71
|
+
name: "device sign-in",
|
|
72
|
+
stored: true,
|
|
73
|
+
find: ({ dir }) => {
|
|
74
|
+
const session = new SessionStore(dir).read();
|
|
75
|
+
return session ? new DeviceSessionCredential(session) : null;
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=device-session-credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-session-credential.js","sourceRoot":"","sources":["../../../src/core/credentials/device-session-credential.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAsB,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,0FAA0F;AAC1F,MAAM,UAAU,kBAAkB,CAAC,OAAsB,EAAE,EAA8C;IACvG,OAAO,IAAI,WAAW,CAAC;QACrB,SAAS,EAAE;YACT,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,kBAAk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CAAC,MAAM;YACjB,KAAK,EAAE,IAAI,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC;YAC/B,SAAS;YACT,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACnC,CAAC,CAAC;IACL,CAAC;IAED,2GAA2G;IAC3G,YAAY,CAAC,EAAE,MAAM,EAAiB;QACpC,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IAChC,CAAC;IAED,oHAAoH;IACpH,KAAK,CAAC,MAAM,CAAC,EAAqB;QAChC,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACtD,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAuB;IACvD,IAAI,EAAE,gBAAgB;IACtB,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;QAChB,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7C,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/D,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How `ora whoami` words an identity, per credential kind. Pure data, carried by the credentials (like their refusal
|
|
3
|
+
* words), so the command prints what the credential says and never asks which kind it is.
|
|
4
|
+
*
|
|
5
|
+
* - An api key prints exactly what it always has — the organization, subject and scopes its traded token claims,
|
|
6
|
+
* and the API that answered. Byte for byte: these lines are a published output scripts read. A token traded by a
|
|
7
|
+
* keyless CI job (the key's own token) adds one `via:` line naming the job.
|
|
8
|
+
* - A browser sign-in also names the organization and the person, and says how they signed in.
|
|
9
|
+
*/
|
|
10
|
+
import type { IdentityLines } from "./credential.js";
|
|
11
|
+
export declare const API_KEY_IDENTITY_LINES: IdentityLines;
|
|
12
|
+
/** A sign-in's lines; `via` is the credential's own source ("device sign-in"). */
|
|
13
|
+
export declare function signInIdentityLines(via: string): IdentityLines;
|
|
14
|
+
//# sourceMappingURL=identity-lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-lines.d.ts","sourceRoot":"","sources":["../../../src/core/credentials/identity-lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAerD,eAAO,MAAM,sBAAsB,EAAE,aAMpC,CAAC;AAQF,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAS9D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How `ora whoami` words an identity, per credential kind. Pure data, carried by the credentials (like their refusal
|
|
3
|
+
* words), so the command prints what the credential says and never asks which kind it is.
|
|
4
|
+
*
|
|
5
|
+
* - An api key prints exactly what it always has — the organization, subject and scopes its traded token claims,
|
|
6
|
+
* and the API that answered. Byte for byte: these lines are a published output scripts read. A token traded by a
|
|
7
|
+
* keyless CI job (the key's own token) adds one `via:` line naming the job.
|
|
8
|
+
* - A browser sign-in also names the organization and the person, and says how they signed in.
|
|
9
|
+
*/
|
|
10
|
+
import { sanitizeTerminalText } from "../../render/sanitize.js";
|
|
11
|
+
const organization = (claims) => String(claims.org ?? claims.organizationId ?? "?");
|
|
12
|
+
const subject = (claims) => String(claims.sub ?? "?");
|
|
13
|
+
/** Which CI job signed in, when the token was minted for one (keyless CI sign-in). Display only. */
|
|
14
|
+
function federationLine(federation) {
|
|
15
|
+
if (!federation || typeof federation !== "object")
|
|
16
|
+
return [];
|
|
17
|
+
const { issuer, repository, ref } = federation;
|
|
18
|
+
if (typeof repository !== "string")
|
|
19
|
+
return [];
|
|
20
|
+
return [`via: ${[issuer, repository, ref].filter((part) => typeof part === "string").join(" ")} (keyless CI sign-in)`];
|
|
21
|
+
}
|
|
22
|
+
export const API_KEY_IDENTITY_LINES = (claims, apiUrl) => [
|
|
23
|
+
`org: ${organization(claims)}`,
|
|
24
|
+
`subject: ${subject(claims)}`,
|
|
25
|
+
...(Array.isArray(claims.scopes) ? [`scopes: ${claims.scopes.join(", ")}`] : []),
|
|
26
|
+
...federationLine(claims.federation),
|
|
27
|
+
`api: ${apiUrl}`,
|
|
28
|
+
];
|
|
29
|
+
/**
|
|
30
|
+
* A name or address the API sent, made safe to print: an organization's name is whatever its owner typed, and it is
|
|
31
|
+
* shown in every member's terminal.
|
|
32
|
+
*/
|
|
33
|
+
const printed = (value) => sanitizeTerminalText(String(value));
|
|
34
|
+
/** A sign-in's lines; `via` is the credential's own source ("device sign-in"). */
|
|
35
|
+
export function signInIdentityLines(via) {
|
|
36
|
+
return (claims, apiUrl) => [
|
|
37
|
+
`org: ${printed(organization(claims))}${typeof claims.organizationName === "string" ? ` (${printed(claims.organizationName)})` : ""}`,
|
|
38
|
+
`subject: ${printed(subject(claims))}`,
|
|
39
|
+
...(typeof claims.email === "string" ? [`email: ${printed(claims.email)}`] : []),
|
|
40
|
+
...(Array.isArray(claims.scopes) ? [`scopes: ${printed(claims.scopes.join(", "))}`] : []),
|
|
41
|
+
`api: ${apiUrl}`,
|
|
42
|
+
`via: ${via}`,
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=identity-lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-lines.js","sourceRoot":"","sources":["../../../src/core/credentials/identity-lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,oBA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Ac,EAAU,EAAE,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAEhF,kFAAkF;AAClF,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;QACzB,YAAY,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,MAAM,CAAC,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACzI,YAAY,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE;QACtC,GAAG,CAAC,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAClF,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1F,YAAY,MAAM,EAAE;QACpB,YAAY,GAAG,EAAE;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each credential kind tells the person when the API refuses it. Pure data, carried by the credentials. The
|
|
3
|
+
* advice that follows a refusal is chosen by the refusal's CODE, through first-match tables — never by reading its
|
|
4
|
+
* message, which is the server's (or the sign-in's) own sentence and is printed, not parsed.
|
|
5
|
+
*/
|
|
6
|
+
import type { RefusalWords } from "./credential.js";
|
|
7
|
+
/** A row of a first-match table: the first row whose `matches` holds for a refusal's code decides. */
|
|
8
|
+
export interface CodeRule<T> {
|
|
9
|
+
readonly matches: (code: string) => boolean;
|
|
10
|
+
readonly value: T;
|
|
11
|
+
}
|
|
12
|
+
export declare function firstMatch<T>(rules: readonly CodeRule<T>[], code: string, otherwise: T): T;
|
|
13
|
+
export declare const API_KEY_WORDS: RefusalWords;
|
|
14
|
+
export declare const DEVICE_SESSION_WORDS: RefusalWords;
|
|
15
|
+
//# sourceMappingURL=refusal-words.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal-words.d.ts","sourceRoot":"","sources":["../../../src/core/credentials/refusal-words.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,sGAAsG;AACtG,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAE1F;AAuBD,eAAO,MAAM,aAAa,EAAE,YAM3B,CAAC;AAcF,eAAO,MAAM,oBAAoB,EAAE,YAalC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each credential kind tells the person when the API refuses it. Pure data, carried by the credentials. The
|
|
3
|
+
* advice that follows a refusal is chosen by the refusal's CODE, through first-match tables — never by reading its
|
|
4
|
+
* message, which is the server's (or the sign-in's) own sentence and is printed, not parsed.
|
|
5
|
+
*/
|
|
6
|
+
import { SIGN_IN_AGAIN, isSessionRefusal } from "../session/session-refusals.js";
|
|
7
|
+
import { scopeOfAreaWithoutSignIn } from "./sign-in-areas.js";
|
|
8
|
+
export function firstMatch(rules, code, otherwise) {
|
|
9
|
+
return rules.find((rule) => rule.matches(code))?.value ?? otherwise;
|
|
10
|
+
}
|
|
11
|
+
/** Shown in place of the scopes when a refusal named none and the command declares none. */
|
|
12
|
+
const NO_SCOPE_NAMED = "unknown";
|
|
13
|
+
/** The scopes a refusal is about, as one line. */
|
|
14
|
+
const listed = (missing) => (missing.length > 0 ? missing.join(", ") : NO_SCOPE_NAMED);
|
|
15
|
+
/** What to do about a key's failed sign-in when no rule of its own matches the code. */
|
|
16
|
+
const LOG_IN_WITH_A_VALID_KEY = "Run `ora login` with a valid api key.";
|
|
17
|
+
/**
|
|
18
|
+
* What to do about a key's failed sign-in, by its code. A keyless CI job signs in as a key too, and has no key to log
|
|
19
|
+
* in with, so telling it to `ora login` would send its owner the wrong way.
|
|
20
|
+
*/
|
|
21
|
+
const KEY_SIGN_IN_HINTS = [
|
|
22
|
+
{ matches: (code) => code === "CI_IDENTITY_UNAVAILABLE", value: "Give the job `permissions: id-token: write`, then run it again." },
|
|
23
|
+
{
|
|
24
|
+
matches: (code) => code.startsWith("CI_"),
|
|
25
|
+
value: "Check that the api key trusts this repository, ref and environment (Settings, API keys, CI sign-in), and that ORA_API_KEY_ID is that key's ID.",
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
export const API_KEY_WORDS = {
|
|
29
|
+
missingScope: (missing) => [
|
|
30
|
+
`This api key is missing the required scope: ${listed(missing)}`,
|
|
31
|
+
"Mint a key with that scope (ora dashboard → Settings → API keys), then `ora login` again.",
|
|
32
|
+
],
|
|
33
|
+
signedOut: (code, message) => [`Authentication failed (${code}): ${message}`, firstMatch(KEY_SIGN_IN_HINTS, code, LOG_IN_WITH_A_VALID_KEY)],
|
|
34
|
+
};
|
|
35
|
+
/** A sign-in the API (or a tunnel) no longer accepts: it says so, with the code, and how to sign in again. */
|
|
36
|
+
const NO_LONGER_WORKS = (code, message) => [`Your sign-in no longer works (${code}): ${message}`, SIGN_IN_AGAIN];
|
|
37
|
+
/** How a browser sign-in's refusal reads, by its code. */
|
|
38
|
+
const SIGN_IN_REFUSALS = [
|
|
39
|
+
// The sign-in's own refusals are worded where they are thrown (session/session-refusals.ts), what to do included:
|
|
40
|
+
// sign in again, sign in to this API, or retry a command whose sign-in changed while it waited.
|
|
41
|
+
{ matches: isSessionRefusal, value: (_code, message) => [message] },
|
|
42
|
+
];
|
|
43
|
+
export const DEVICE_SESSION_WORDS = {
|
|
44
|
+
// A sign-in holds the permissions the person allowed on the approval page — all the CLI asked for, or fewer.
|
|
45
|
+
// Signing in again is how one more is allowed; a key that already holds it is the other way.
|
|
46
|
+
// A command of an area that takes no sign-in yet (Autopilot) needs a permission `ora login` never asks for:
|
|
47
|
+
// signing in again could not offer it, so the only advice that works is a key.
|
|
48
|
+
missingScope: (missing) => missing.length > 0 && missing.every(scopeOfAreaWithoutSignIn)
|
|
49
|
+
? [`This command does not take a browser sign-in yet (it needs ${listed(missing)}).`, "Use an api key for it: ora login --api-key"]
|
|
50
|
+
: [
|
|
51
|
+
`Your sign-in doesn't include the permission this needs: ${listed(missing)}`,
|
|
52
|
+
"Run `ora login` again and allow that permission, or use an api key that holds it (ora login --api-key).",
|
|
53
|
+
],
|
|
54
|
+
signedOut: (code, message) => firstMatch(SIGN_IN_REFUSALS, code, NO_LONGER_WORKS)(code, message),
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=refusal-words.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal-words.js","sourceRoot":"","sources":["../../../src/core/credentials/refusal-words.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAQ9D,MAAM,UAAU,UAAU,CAAI,KAA6B,EAAE,IAAY,EAAE,SAAY;IACrF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CA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AE,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE;CACpE,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAiB;IAChD,6GAA6G;IAC7G,6FAA6F;IAC7F,4GAA4G;IAC5G,+EAA+E;IAC/E,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,CACxB,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC;QAC3D,CAAC,CAAC,CAAC,8DAA8D,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,4CAA4C,CAAC;QACnI,CAAC,CAAC;YACE,2DAA2D,MAAM,CAAC,OAAO,CAAC,EAAE;YAC5E,yGAAyG;SAC1G;IACP,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC;CACjG,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Areas of the API that do not take a browser sign-in yet. The API refuses one there (403 `SIGN_IN_NOT_SUPPORTED`)
|
|
3
|
+
* and names an api key as the way in.
|
|
4
|
+
*
|
|
5
|
+
* ONE list, read twice, so the two can never disagree:
|
|
6
|
+
* - `ora login` does not ask for these areas' permissions, so the approval page never offers what would not work
|
|
7
|
+
* (login/requested-scopes.ts);
|
|
8
|
+
* - a command there, run with a sign-in, is told to use an api key, and never to "sign in again and allow the
|
|
9
|
+
* permission", which that sign-in could never be offered (refusal-words.ts).
|
|
10
|
+
*
|
|
11
|
+
* An area is the first segment of an operation id (`autopilot.teams.list`) and of its scopes (`autopilot:read`).
|
|
12
|
+
*/
|
|
13
|
+
export declare const AREAS_WITHOUT_SIGN_IN: readonly ["autopilot"];
|
|
14
|
+
/** Does an operation take a browser sign-in? One with no id (a bare scope source) does. */
|
|
15
|
+
export declare function operationTakesSignIn(operationId: string | undefined): boolean;
|
|
16
|
+
/** Is this scope one of an area that does not take a browser sign-in? */
|
|
17
|
+
export declare function scopeOfAreaWithoutSignIn(scope: string): boolean;
|
|
18
|
+
//# sourceMappingURL=sign-in-areas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in-areas.d.ts","sourceRoot":"","sources":["../../../src/core/credentials/sign-in-areas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,wBAAyB,CAAC;AAE5D,2FAA2F;AAC3F,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE7E;AAED,yEAAyE;AACzE,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE/D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Areas of the API that do not take a browser sign-in yet. The API refuses one there (403 `SIGN_IN_NOT_SUPPORTED`)
|
|
3
|
+
* and names an api key as the way in.
|
|
4
|
+
*
|
|
5
|
+
* ONE list, read twice, so the two can never disagree:
|
|
6
|
+
* - `ora login` does not ask for these areas' permissions, so the approval page never offers what would not work
|
|
7
|
+
* (login/requested-scopes.ts);
|
|
8
|
+
* - a command there, run with a sign-in, is told to use an api key, and never to "sign in again and allow the
|
|
9
|
+
* permission", which that sign-in could never be offered (refusal-words.ts).
|
|
10
|
+
*
|
|
11
|
+
* An area is the first segment of an operation id (`autopilot.teams.list`) and of its scopes (`autopilot:read`).
|
|
12
|
+
*/
|
|
13
|
+
export const AREAS_WITHOUT_SIGN_IN = ["autopilot"];
|
|
14
|
+
/** Does an operation take a browser sign-in? One with no id (a bare scope source) does. */
|
|
15
|
+
export function operationTakesSignIn(operationId) {
|
|
16
|
+
return !AREAS_WITHOUT_SIGN_IN.some((area) => operationId?.startsWith(`${area}.`));
|
|
17
|
+
}
|
|
18
|
+
/** Is this scope one of an area that does not take a browser sign-in? */
|
|
19
|
+
export function scopeOfAreaWithoutSignIn(scope) {
|
|
20
|
+
return AREAS_WITHOUT_SIGN_IN.some((area) => scope === area || scope.startsWith(`${area}:`));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=sign-in-areas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in-areas.js","sourceRoot":"","sources":["../../../src/core/credentials/sign-in-areas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,WAAW,CAAU,CAAC;AAE5D,2FAA2F;AAC3F,MAAM,UAAU,oBAAoB,CAAC,WAA+B;IAClE,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,wBAAwB,CAAC,KAAa;IACpD,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
package/dist/core/http.d.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* The one HTTP door for every generated command.
|
|
3
3
|
*
|
|
4
4
|
* Auth policy mirrors the platform's createServiceClient: on a 401 the token
|
|
5
|
-
* is force-
|
|
6
|
-
* retried — a POST /runs may
|
|
7
|
-
* the CLI's promise for
|
|
5
|
+
* is force-renewed (an api key re-exchanged, a browser sign-in refreshed) and
|
|
6
|
+
* the request retried EXACTLY once. 5xx is never retried — a POST /runs may
|
|
7
|
+
* have been admitted and billed; at-most-once is the CLI's promise for
|
|
8
|
+
* mutations.
|
|
8
9
|
*
|
|
9
10
|
* Non-ok responses map to ApiError carrying the platform envelope
|
|
10
11
|
* {error, code, details?} so output.ts can tell the 402/403 stories — read
|
|
@@ -31,7 +32,12 @@ export interface CallOptions {
|
|
|
31
32
|
/** The narrow auth port — both members required so a fake-retry can't hide. */
|
|
32
33
|
export interface TokenSource {
|
|
33
34
|
getToken(): Promise<string>;
|
|
34
|
-
|
|
35
|
+
/**
|
|
36
|
+
* A new bearer after the API refused one. `rejectedToken` is the bearer it refused: a source that can tell it was
|
|
37
|
+
* already replaced (a sign-in another `ora` process refreshed meanwhile) answers with the newer one instead of
|
|
38
|
+
* renewing twice. A source with nothing to compare (an api key's exchange) ignores it.
|
|
39
|
+
*/
|
|
40
|
+
forceRefresh(rejectedToken?: string): Promise<string>;
|
|
35
41
|
}
|
|
36
42
|
export interface HttpClientDeps {
|
|
37
43
|
apiUrl: string;
|
package/dist/core/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,qBAAa,QAAS,SAAQ,KAAK;IAG/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1C,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO;gBALvB,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;IAC1C,0GAA0G;IACjG,IAAI,CAAC,EAAE,OAAO,YAAA;CAK1B;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,+EAA+E;AAC/E,MAAM,WAAW,WAAW;IAC1B,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvD;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;CACxB;AAED,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAc;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAE3B,IAAI,EAAE,cAAc;IAMhC,0EAA0E;IACpE,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAW/C,0EAA0E;IACpE,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIhD,OAAO,CAAC,GAAG;YAQG,IAAI;CAqBnB"}
|
package/dist/core/http.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* The one HTTP door for every generated command.
|
|
3
3
|
*
|
|
4
4
|
* Auth policy mirrors the platform's createServiceClient: on a 401 the token
|
|
5
|
-
* is force-
|
|
6
|
-
* retried — a POST /runs may
|
|
7
|
-
* the CLI's promise for
|
|
5
|
+
* is force-renewed (an api key re-exchanged, a browser sign-in refreshed) and
|
|
6
|
+
* the request retried EXACTLY once. 5xx is never retried — a POST /runs may
|
|
7
|
+
* have been admitted and billed; at-most-once is the CLI's promise for
|
|
8
|
+
* mutations.
|
|
8
9
|
*
|
|
9
10
|
* Non-ok responses map to ApiError carrying the platform envelope
|
|
10
11
|
* {error, code, details?} so output.ts can tell the 402/403 stories — read
|
|
@@ -73,9 +74,10 @@ export class HttpClient {
|
|
|
73
74
|
...(opts.body !== undefined ? { body: JSON.stringify(opts.body) } : {}),
|
|
74
75
|
...(opts.signal ? { signal: opts.signal } : {}),
|
|
75
76
|
});
|
|
76
|
-
|
|
77
|
+
const token = await this.auth.getToken();
|
|
78
|
+
let res = await attempt(token);
|
|
77
79
|
if (res.status === 401) {
|
|
78
|
-
res = await attempt(await this.auth.forceRefresh());
|
|
80
|
+
res = await attempt(await this.auth.forceRefresh(token));
|
|
79
81
|
}
|
|
80
82
|
if (!res.ok)
|
|
81
83
|
throw await toApiError(res);
|
package/dist/core/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/core/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGtB;IACA;IACA;IAEA;IANX,YACE,OAAe,EACN,MAAc,EACd,IAAY,EACZ,OAAiC;IAC1C,0GAA0G;IACjG,IAAc;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAC;QANN,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAA0B;QAEjC,SAAI,GAAJ,IAAI,CAAU;QAGvB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AA2BD,MAAM,OAAO,UAAU;IACJ,MAAM,CAAS;IACf,IAAI,CAAc;IAClB,OAAO,CA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AK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,yEAAyE;IACzE,2DAA2D;IAC3D,2EAA2E;IAC3E,wEAAwE;IACxE,yEAAyE;IACzE,sEAAsE;IACtE,0EAA0E;IAC1E,wDAAwD;IACxD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACrE,OAAO,IAAI,QAAQ,CACjB,OAAO,IAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,EAC/B,GAAG,CAAC,MAAM,EACV,IAAI,IAAI,YAAY,EACpB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EACnD,GAAG,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HttpClient } from "./http.js";
|
|
2
|
+
/**
|
|
3
|
+
* Who a browser sign-in is: `GET /auth/identity` answers for the credential that asked — the person, their
|
|
4
|
+
* organization and the permissions they approved — and hands out no token. Never decoded from the access token the
|
|
5
|
+
* CLI holds: that token is the sign-in server's, and only the API says what it lets its bearer do.
|
|
6
|
+
*
|
|
7
|
+
* (An api key's identity is read differently — the claims of the token it is traded for — because that is what every
|
|
8
|
+
* Ora answers, old or new: credentials/api-key-credential.ts.)
|
|
9
|
+
*/
|
|
10
|
+
export declare function readIdentity(client: Pick<HttpClient, "call">): Promise<Record<string, unknown>>;
|
|
11
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/core/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAIrG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who a browser sign-in is: `GET /auth/identity` answers for the credential that asked — the person, their
|
|
3
|
+
* organization and the permissions they approved — and hands out no token. Never decoded from the access token the
|
|
4
|
+
* CLI holds: that token is the sign-in server's, and only the API says what it lets its bearer do.
|
|
5
|
+
*
|
|
6
|
+
* (An api key's identity is read differently — the claims of the token it is traded for — because that is what every
|
|
7
|
+
* Ora answers, old or new: credentials/api-key-credential.ts.)
|
|
8
|
+
*/
|
|
9
|
+
export async function readIdentity(client) {
|
|
10
|
+
const result = await client.call({ method: "GET", path: "/auth/identity" });
|
|
11
|
+
if (!isIdentity(result))
|
|
12
|
+
throw new Error("The API returned an invalid identity response.");
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
function isIdentity(value) {
|
|
16
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
17
|
+
return false;
|
|
18
|
+
const identity = value;
|
|
19
|
+
return typeof identity.sub === "string" && typeof identity.organizationId === "string";
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/core/identity.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAgC;IACjE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC5E,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAC3F,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtF,MAAM,QAAQ,GAAG,KAAgC,CAAC;IAClD,OAAO,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,QAAQ,CAAC,cAAc,KAAK,QAAQ,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface LimitDetails {
|
|
2
|
+
message?: unknown;
|
|
3
|
+
dimension?: unknown;
|
|
4
|
+
limit?: unknown;
|
|
5
|
+
used?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export declare function limitStory(fallback: string, details?: LimitDetails): {
|
|
8
|
+
headline: string;
|
|
9
|
+
lines: string[];
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=limit-story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limit-story.d.ts","sourceRoot":"","sources":["../../src/core/limit-story.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAU9G"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const SERVER_PREFIX = "Usage limit exceeded for ";
|
|
2
|
+
const MONTHLY = new Set(["agent_runs", "domain_scans"]);
|
|
3
|
+
const BILLING = "Upgrade in Studio → Settings → Plan & billing.";
|
|
4
|
+
export function limitStory(fallback, details = {}) {
|
|
5
|
+
const { message, dimension, limit, used } = details;
|
|
6
|
+
const label = typeof message === "string" && message.startsWith(SERVER_PREFIX) ? message.slice(SERVER_PREFIX.length) : null;
|
|
7
|
+
if (label && limit === 0)
|
|
8
|
+
return { headline: `No ${label} are available on your plan right now.`, lines: [BILLING] };
|
|
9
|
+
if (label && typeof limit === "number" && typeof used === "number" && used >= limit) {
|
|
10
|
+
const resets = typeof dimension === "string" && MONTHLY.has(dimension) ? ["ora usage shows when they reset."] : [];
|
|
11
|
+
return { headline: `You've used all ${limit.toLocaleString("en-US")} ${label} on your plan.`, lines: [...resets, BILLING] };
|
|
12
|
+
}
|
|
13
|
+
const count = typeof used === "number" && typeof limit === "number" ? [`Used ${used} of ${limit}.`] : [];
|
|
14
|
+
return { headline: typeof message === "string" ? message : fallback, lines: [...count, BILLING] };
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=limit-story.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limit-story.js","sourceRoot":"","sources":["../../src/core/limit-story.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,2BAA2B,CAAC;AAClD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,CAAC;AACxD,MAAM,OAAO,GAAG,gDAAgD,CAAC;AASjE,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,UAAwB,EAAE;IACrE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,O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Interactive api-key entry (`ora login --api-key` with no value). The key is
|
|
3
|
+
* masked while typed and NEVER echoed — the one hard rule of the login UX.
|
|
4
|
+
* Non-TTY stdin (pipes) degrades to a plain read to the end of stdin so
|
|
5
|
+
* `echo $KEY | ora login --api-key` works in scripts. (A key piped into a
|
|
6
|
+
* bare `ora login` is read by login/piped-input.ts, which prints no prompt.)
|
|
5
7
|
*
|
|
6
8
|
* Raw mode delivers a PASTE as one data event carrying the whole string
|
|
7
9
|
* (possibly with a trailing newline) — never one event per keypress. The
|
package/dist/core/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/core/login.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/core/login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,wBAAsB,YAAY,CAChC,KAAK,GAAE,MAAM,CAAC,UAA0B,EACxC,MAAM,GAAE,MAAM,CAAC,WAA4B,GAC1C,OAAO,CAAC,MAAM,CAAC,CA0DjB"}
|
package/dist/core/login.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Interactive api-key entry
|
|
3
|
-
* the one hard rule of the login UX.
|
|
4
|
-
*
|
|
2
|
+
* Interactive api-key entry (`ora login --api-key` with no value). The key is
|
|
3
|
+
* masked while typed and NEVER echoed — the one hard rule of the login UX.
|
|
4
|
+
* Non-TTY stdin (pipes) degrades to a plain read to the end of stdin so
|
|
5
|
+
* `echo $KEY | ora login --api-key` works in scripts. (A key piped into a
|
|
6
|
+
* bare `ora login` is read by login/piped-input.ts, which prints no prompt.)
|
|
5
7
|
*
|
|
6
8
|
* Raw mode delivers a PASTE as one data event carrying the whole string
|
|
7
9
|
* (possibly with a trailing newline) — never one event per keypress. The
|
package/dist/core/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/core/login.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/core/login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,GAAG,QAAQ,CAAC;AACxB,MAAM,GAAG,GAAG,QAAQ,CAAC;AAErB,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAA2B,OAAO,CAAC,KAAK,EACxC,SAA6B,OAAO,CAAC,MAAM;IAE3C,MAAM,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IAEhD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,GAAG,GAAG,EAAE,CAAC;YACb,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC1B,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;gBACjC,GAAG,IAAI,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;YACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACvB,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE1B,MAAM,MAAM,GAAG,GAAS,EAAE;YACxB,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACxB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC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* Authorization-server metadata (RFC 8414), read from the issuer instead of guessed: the CLI never builds an OAuth
|
|
3
|
+
* endpoint path itself. oidc-provider serves both well-known documents at the issuer root while its endpoints live
|
|
4
|
+
* under `/oauth2`; whichever document answers first wins.
|
|
5
|
+
*
|
|
6
|
+
* RFC 8414 §3.3: the `issuer` a document names MUST equal the issuer it was fetched from, or the document is refused
|
|
7
|
+
* — a mix-up defence, so a token request can never be steered to a server other than the one the person signs in to.
|
|
8
|
+
*
|
|
9
|
+
* When no document can be used, the failure says which of three things happened, because each has its own fix:
|
|
10
|
+
* - nothing is published there (an Ora that predates browser sign-in) → use an api key, which works as before;
|
|
11
|
+
* - a document is published, for ANOTHER issuer → the api url or auth url is not the one that server serves;
|
|
12
|
+
* - the server could not be asked (unreachable, its own error, told to wait) → try again.
|
|
13
|
+
*/
|
|
14
|
+
export interface AuthorizationServerMetadata {
|
|
15
|
+
issuer: string;
|
|
16
|
+
tokenEndpoint: string;
|
|
17
|
+
/** Absent when the server does not offer device sign-in (RFC 8628). */
|
|
18
|
+
deviceAuthorizationEndpoint?: string;
|
|
19
|
+
revocationEndpoint?: string;
|
|
20
|
+
}
|
|
21
|
+
/** The metadata a document carries, or null when it is not a usable document for `issuer`. */
|
|
22
|
+
export declare function parseMetadata(body: unknown, issuer: string): AuthorizationServerMetadata | null;
|
|
23
|
+
export declare function discoverMetadata(issuer: string, fetchFn: typeof fetch): Promise<AuthorizationServerMetadata>;
|
|
24
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/core/oauth/metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AASD,8FAA8F;AAC9F,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,2BAA2B,GAAG,IAAI,CAW/F;AA2ED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,2BAA2B,CAAC,CASlH"}
|