@ory/argus 0.13.8 → 0.14.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/README.md +2 -1
- package/assets/commands/dashboard.md +34 -0
- package/assets/skills/ory-build-agent/SKILL.md +11 -13
- package/assets/skills/ory-e2b-sandbox/SKILL.md +0 -1
- package/assets/skills/ory-temporal-worker/SKILL.md +8 -10
- package/assets/skills/permissions-onboarding/SKILL.md +3 -3
- package/dist/adapters.d.ts +27 -4
- package/dist/adapters.js +132 -32
- package/dist/agent-auth.d.ts +34 -3
- package/dist/agent-auth.js +58 -8
- package/dist/auth.d.ts +7 -0
- package/dist/auth.js +90 -5
- package/dist/branding.d.ts +67 -0
- package/dist/branding.js +81 -0
- package/dist/build-info.json +4 -4
- package/dist/cli.d.ts +3 -3
- package/dist/cli.js +13 -52
- package/dist/client.d.ts +31 -0
- package/dist/client.js +58 -0
- package/dist/config.d.ts +48 -19
- package/dist/config.js +31 -26
- package/dist/contract-suite.d.ts +5 -3
- package/dist/contract-suite.js +13 -22
- package/dist/dashboard-cli.d.ts +8 -0
- package/dist/dashboard-cli.js +70 -0
- package/dist/dev.js +3 -4
- package/dist/index.d.ts +12 -5
- package/dist/index.js +41 -3
- package/dist/interactive-setup.d.ts +144 -23
- package/dist/interactive-setup.js +412 -224
- package/dist/local/health.d.ts +14 -0
- package/dist/local/health.js +46 -0
- package/dist/local/manager.js +1 -3
- package/dist/local/seed.d.ts +9 -20
- package/dist/local/seed.js +26 -18
- package/dist/permissions-cli.js +12 -4
- package/dist/project-api-key.d.ts +69 -0
- package/dist/project-api-key.js +147 -0
- package/dist/registry/manager.js +62 -18
- package/dist/setup-actions.d.ts +232 -0
- package/dist/setup-actions.js +507 -0
- package/dist/setup.d.ts +19 -0
- package/dist/setup.js +44 -14
- package/dist/skills.js +7 -0
- package/dist/status-cli.d.ts +2 -2
- package/dist/status-cli.js +4 -30
- package/dist/status-data.d.ts +96 -0
- package/dist/status-data.js +250 -0
- package/dist/status-system.d.ts +24 -0
- package/dist/status-system.js +56 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.js +20 -1
- package/dist/uninstall.d.ts +33 -15
- package/dist/uninstall.js +65 -22
- package/dist/user-login.d.ts +16 -9
- package/dist/user-login.js +18 -28
- package/dist/web/api.d.ts +33 -0
- package/dist/web/api.js +294 -0
- package/dist/web/launch.d.ts +11 -0
- package/dist/web/launch.js +96 -0
- package/dist/web/server.d.ts +20 -0
- package/dist/web/server.js +233 -0
- package/dist/web/types.d.ts +65 -0
- package/dist/web/types.js +2 -0
- package/dist/webapp/assets/index-Wucl4SZs.css +1 -0
- package/dist/webapp/assets/index-m-GtEdq0.js +49 -0
- package/dist/webapp/favicon.ico +0 -0
- package/dist/webapp/index.html +15 -0
- package/package.json +17 -2
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Headless setup actions — the prompt-free, presentation-free core of the
|
|
3
|
+
* install walkthrough, driven by the local web installer's JSON API (and
|
|
4
|
+
* reusable anywhere the interactive TTY wizard's step *decisions* live outside
|
|
5
|
+
* the process, e.g. in a browser).
|
|
6
|
+
*
|
|
7
|
+
* Each function performs exactly one step of the same flow the TTY wizard in
|
|
8
|
+
* {@link file://./interactive-setup.ts} runs — sign in, pick / create a
|
|
9
|
+
* workspace and project, enable DCR, provision the OAuth2 client, grant tool
|
|
10
|
+
* permissions, provision the project API key — but returns a plain result
|
|
11
|
+
* object instead of prompting or printing. The heavy lifting (CLI arg shapes,
|
|
12
|
+
* OPL model inspection/merge, Console-API key minting) is imported from
|
|
13
|
+
* `interactive-setup.ts` so there is a single source of truth for it; only the
|
|
14
|
+
* thin, prompt-free orchestration lives here.
|
|
15
|
+
*
|
|
16
|
+
* Everything is fail-open: an action never throws for an expected failure
|
|
17
|
+
* (CLI error, network blip, missing session) — it returns `{ ok: false }` with
|
|
18
|
+
* a short message the UI can surface.
|
|
19
|
+
*/
|
|
20
|
+
import { type OryCliRunner, type OryWorkspace, type OryProject, type PermissionModel, type LoginUiState } from "./interactive-setup.js";
|
|
21
|
+
import { type CreateProjectApiKeyArgs, type ProjectApiKeyResult } from "./project-api-key.js";
|
|
22
|
+
import { type PermissionMode } from "./config.js";
|
|
23
|
+
import { ensureUserAuthenticated } from "./user-login.js";
|
|
24
|
+
import { ensureAgentIdentity } from "./agent-auth.js";
|
|
25
|
+
import { OryAgentClient } from "./client.js";
|
|
26
|
+
import { type UserSubjectRef } from "./subject.js";
|
|
27
|
+
import { ensureLocalOryStack, seedLocalEnvironment } from "./local/index.js";
|
|
28
|
+
/** Injectable dependencies so the web API layer and tests can stub the CLI,
|
|
29
|
+
* the login gates, the local stack, and the Console-API key minter. Mirrors
|
|
30
|
+
* the subset of {@link InteractiveSetupDeps} the headless actions need. */
|
|
31
|
+
export interface SetupActionDeps {
|
|
32
|
+
runner?: OryCliRunner;
|
|
33
|
+
installOryCliFn?: () => Promise<OryCliRunner | null>;
|
|
34
|
+
clientFactory?: (harness: string) => OryAgentClient;
|
|
35
|
+
userLoginFn?: typeof ensureUserAuthenticated;
|
|
36
|
+
agentGateFn?: typeof ensureAgentIdentity;
|
|
37
|
+
localStackFn?: typeof ensureLocalOryStack;
|
|
38
|
+
seedFn?: typeof seedLocalEnvironment;
|
|
39
|
+
createProjectApiKeyFn?: (args: CreateProjectApiKeyArgs) => Promise<ProjectApiKeyResult | null>;
|
|
40
|
+
validateApiKeyFn?: (apiKey: string, projectUrl: string) => Promise<boolean>;
|
|
41
|
+
}
|
|
42
|
+
export declare function resolveNamespace(): string;
|
|
43
|
+
export interface EnsureOryCliResult {
|
|
44
|
+
present: boolean;
|
|
45
|
+
installed: boolean;
|
|
46
|
+
/** The runner to use for subsequent CLI actions, or null if unavailable. */
|
|
47
|
+
runner: OryCliRunner | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Ensure the `ory` CLI is available. Probes the default (or injected) runner;
|
|
51
|
+
* if the binary isn't on `PATH`, installs `@ory/cli` into a plugin-managed dir
|
|
52
|
+
* and returns a runner bound to it. Never throws.
|
|
53
|
+
*/
|
|
54
|
+
export declare function ensureOryCli(deps?: SetupActionDeps): Promise<EnsureOryCliResult>;
|
|
55
|
+
/** Whether the `ory` CLI already holds a valid Ory Network session. */
|
|
56
|
+
export declare function isSignedIn(runner: OryCliRunner): boolean;
|
|
57
|
+
export interface SignInHandle {
|
|
58
|
+
/** Resolves to true when `ory auth` exits 0 (signed in), false otherwise. */
|
|
59
|
+
done: Promise<boolean>;
|
|
60
|
+
/** Best-effort cancel (kills the child). */
|
|
61
|
+
cancel(): void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Launch the interactive `ory auth` browser sign-in as a detached child so the
|
|
65
|
+
* HTTP server's event loop stays free (unlike `runner.exec`, which is
|
|
66
|
+
* spawnSync). The Ory CLI opens its own browser window and runs a local
|
|
67
|
+
* callback listener; we only watch its exit code. Returns a handle whose
|
|
68
|
+
* `done` promise resolves when sign-in completes. Requires `runner.bin`.
|
|
69
|
+
*/
|
|
70
|
+
export declare function startSignIn(runner: OryCliRunner): SignInHandle;
|
|
71
|
+
export declare function listWorkspaces(runner: OryCliRunner): OryWorkspace[] | null;
|
|
72
|
+
export interface CreateResult<T> {
|
|
73
|
+
ok: boolean;
|
|
74
|
+
value?: T;
|
|
75
|
+
error?: string;
|
|
76
|
+
}
|
|
77
|
+
export declare function createWorkspace(runner: OryCliRunner, name: string): CreateResult<OryWorkspace>;
|
|
78
|
+
export declare function listProjects(runner: OryCliRunner, workspaceId: string): OryProject[] | null;
|
|
79
|
+
export declare function createProject(runner: OryCliRunner, workspaceId: string, name: string): CreateResult<OryProject>;
|
|
80
|
+
/** Ory Network Developer-plan project cap per workspace. */
|
|
81
|
+
export declare const PROJECT_CAP = 2;
|
|
82
|
+
/**
|
|
83
|
+
* Resolve a project's canonical SDK URL from its slug, refusing a missing slug
|
|
84
|
+
* or one that is actually the project id (a UUID) — either would build a URL
|
|
85
|
+
* that points nowhere.
|
|
86
|
+
*/
|
|
87
|
+
export declare function resolveProjectUrl(project: OryProject): CreateResult<string>;
|
|
88
|
+
/** Current DCR state: true/false when known, null when it couldn't be read. */
|
|
89
|
+
export declare function getDcrState(runner: OryCliRunner, projectId: string): boolean | null;
|
|
90
|
+
/** Enable DCR on the project. Returns true on success. */
|
|
91
|
+
export declare function enableDcrAction(runner: OryCliRunner, projectId: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Ensure the project's OAuth2 login/consent UI works for a hosted browser
|
|
94
|
+
* login. A CLI-created project defaults these to the `localhost:3000`
|
|
95
|
+
* quickstart sample; this clears them so the Ory Managed Account Experience
|
|
96
|
+
* renders the login instead. Returns the resulting state so the UI can report
|
|
97
|
+
* it: `managed` (fixed or already managed), `custom_external` (a deliberate
|
|
98
|
+
* custom UI, left as-is), or `unknown` (couldn't read the config).
|
|
99
|
+
*/
|
|
100
|
+
export declare function ensureManagedLoginUi(runner: OryCliRunner, projectId: string): Exclude<LoginUiState, "loopback">;
|
|
101
|
+
/**
|
|
102
|
+
* Best-effort human-readable name for a signed-in identity, resolved via the
|
|
103
|
+
* admin `ory` CLI (`ory get identity`). The PKCE login's id_token carries only
|
|
104
|
+
* an opaque subject id under the default `openid` scope, so rather than show a
|
|
105
|
+
* UUID we look the identity up by id and read a display trait (email → username
|
|
106
|
+
* → name). Returns undefined on any CLI/parse failure so callers fall back to
|
|
107
|
+
* the id.
|
|
108
|
+
*/
|
|
109
|
+
export declare function resolveIdentityName(runner: OryCliRunner, projectId: string, subjectId: string): string | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Readable label for a signed-in user when naming a resource (e.g. a project
|
|
112
|
+
* API key), so a shared project's resource list shows an email/username rather
|
|
113
|
+
* than an opaque `user:<uuid>`. Looks the identity up via the admin CLI and
|
|
114
|
+
* falls back to the subject label when no name resolves (no runner, or the
|
|
115
|
+
* lookup fails). The raw subject id is read from either subject shape.
|
|
116
|
+
*/
|
|
117
|
+
export declare function resourceUserLabel(runner: OryCliRunner | null | undefined, projectId: string, subject: UserSubjectRef): string;
|
|
118
|
+
export interface OAuth2ClientResult {
|
|
119
|
+
ok: boolean;
|
|
120
|
+
clientId?: string;
|
|
121
|
+
/** Human-readable client name (for display in place of the opaque id). */
|
|
122
|
+
name: string;
|
|
123
|
+
/** True when an existing plugin client was reused rather than created. */
|
|
124
|
+
reused: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Find or create the public PKCE OAuth2 client the user login needs. Reuses an
|
|
128
|
+
* existing plugin-provisioned client on the project so a re-run never mints a
|
|
129
|
+
* duplicate.
|
|
130
|
+
*/
|
|
131
|
+
export declare function provisionOAuth2Client(runner: OryCliRunner, projectId: string): OAuth2ClientResult;
|
|
132
|
+
/** Persist the resolved Ory Network connection and enable the user login. */
|
|
133
|
+
export declare function saveNetworkConfig(input: {
|
|
134
|
+
projectUrl: string;
|
|
135
|
+
projectId: string;
|
|
136
|
+
oauth2ClientId: string;
|
|
137
|
+
projectName?: string;
|
|
138
|
+
workspaceName?: string;
|
|
139
|
+
}): void;
|
|
140
|
+
export interface FullSetupResult {
|
|
141
|
+
authenticated: boolean;
|
|
142
|
+
/** The resolved permission subject label (e.g. `user:<id>`), or null. */
|
|
143
|
+
subjectLabel: string | null;
|
|
144
|
+
/** The resolved subject reference, for a follow-up permission grant. */
|
|
145
|
+
subject: UserSubjectRef | null;
|
|
146
|
+
}
|
|
147
|
+
/** The project the wizard resolved this session, to pin the login against. */
|
|
148
|
+
export interface FullSetupTarget {
|
|
149
|
+
/** The selected SDK/project URL (authoritative for this install). */
|
|
150
|
+
projectUrl?: string;
|
|
151
|
+
/** The public OAuth2 client id the PKCE login should use. */
|
|
152
|
+
oauth2ClientId?: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Run the PKCE user login (opens a browser and awaits the loopback callback)
|
|
156
|
+
* and resolve the agent DCR identity, so the next session is fully wired.
|
|
157
|
+
* Best-effort: a declined or failed login just reports `authenticated: false`.
|
|
158
|
+
*
|
|
159
|
+
* `target` pins the project the wizard just selected. The login gate resolves
|
|
160
|
+
* its URL/client id through `resolveConfig()`, which is **env-first** — so a
|
|
161
|
+
* stale `ORY_PROJECT_URL` / `ORY_SDK_URL` / `ORY_OAUTH2_CLIENT_ID` left in the
|
|
162
|
+
* user's shell (e.g. `http://localhost:3000` from a local app) would otherwise
|
|
163
|
+
* override the project they just picked and launch the browser at the wrong
|
|
164
|
+
* URL. During install the fresh selection is ground truth, so we pin it into
|
|
165
|
+
* the environment for the login. (The process exits after install, so this
|
|
166
|
+
* doesn't leak into a long-lived session.)
|
|
167
|
+
*/
|
|
168
|
+
export declare function runFullSetup(binName: string, harness: string, deps?: SetupActionDeps, target?: FullSetupTarget): Promise<FullSetupResult>;
|
|
169
|
+
export interface PermissionModelState {
|
|
170
|
+
model: PermissionModel["kind"];
|
|
171
|
+
/** OPL source when the model exists and can be merged (kind === "merge"). */
|
|
172
|
+
opl?: string;
|
|
173
|
+
}
|
|
174
|
+
/** Inspect how the project's permission model relates to the namespace. */
|
|
175
|
+
export declare function inspectPermissions(runner: OryCliRunner, projectId: string, namespace?: string): Promise<PermissionModelState>;
|
|
176
|
+
/**
|
|
177
|
+
* Provision (or merge) the namespace into the project's permission model.
|
|
178
|
+
* Pass `opl` (from a prior `inspectPermissions` "merge" result) to append the
|
|
179
|
+
* namespace non-destructively; omit it to create a fresh minimal model.
|
|
180
|
+
*/
|
|
181
|
+
export declare function provisionPermissions(runner: OryCliRunner, projectId: string, namespace?: string, opl?: string): boolean;
|
|
182
|
+
export interface GrantResult {
|
|
183
|
+
ok: boolean;
|
|
184
|
+
count: number;
|
|
185
|
+
error?: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Grant `<subject>` the `use` relation on every built-in tool by writing the
|
|
189
|
+
* relation tuples through the admin-authenticated `ory` CLI. Assumes the
|
|
190
|
+
* namespace already exists (call {@link inspectPermissions} /
|
|
191
|
+
* {@link provisionPermissions} first).
|
|
192
|
+
*/
|
|
193
|
+
export declare function grantToolPermissions(runner: OryCliRunner, projectId: string, harness: string, subject: UserSubjectRef, namespace?: string): GrantResult;
|
|
194
|
+
export type ApiKeyStatus = "env" | "valid_existing" | "created" | "failed";
|
|
195
|
+
export interface ApiKeyResult {
|
|
196
|
+
status: ApiKeyStatus;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Ensure a valid project API key is stored for runtime permission *checks*.
|
|
200
|
+
* No-ops for an env-provided key; validates a stored key and re-mints if it is
|
|
201
|
+
* dead; otherwise mints one via the Console API and persists it. Best-effort.
|
|
202
|
+
*/
|
|
203
|
+
export declare function provisionProjectApiKey(input: {
|
|
204
|
+
projectId: string;
|
|
205
|
+
projectUrl: string;
|
|
206
|
+
harness: string;
|
|
207
|
+
user?: string;
|
|
208
|
+
}, deps?: SetupActionDeps): Promise<ApiKeyResult>;
|
|
209
|
+
/** Configure audit-only mode (no project, no auth, no checks). */
|
|
210
|
+
export declare function configureAuditOnly(): void;
|
|
211
|
+
/** Set the permission deny posture — `observe` (log) vs `enforce` (block). */
|
|
212
|
+
export declare function setPermissionMode(mode: PermissionMode): void;
|
|
213
|
+
export interface LocalStackResult {
|
|
214
|
+
running: boolean;
|
|
215
|
+
detail?: string;
|
|
216
|
+
seeded: boolean;
|
|
217
|
+
credentials?: {
|
|
218
|
+
email: string;
|
|
219
|
+
password: string;
|
|
220
|
+
};
|
|
221
|
+
seedError?: string;
|
|
222
|
+
projectUrl: string;
|
|
223
|
+
oauth2ClientId: string;
|
|
224
|
+
subjectNamespace: string;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Bring up and seed the local Ory stack, persisting the (stable) local
|
|
228
|
+
* connection details regardless of whether Docker came up. Mirrors the TTY
|
|
229
|
+
* wizard's local branch minus the login (the UI drives {@link runFullSetup}
|
|
230
|
+
* separately). Best-effort throughout.
|
|
231
|
+
*/
|
|
232
|
+
export declare function configureLocalStack(deps?: SetupActionDeps): Promise<LocalStackResult>;
|