@sequenceholdings/studio-cli 0.1.13 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +94 -30
  2. package/dist/artifact/delegate.d.ts +2 -2
  3. package/dist/artifact/delegate.js +31 -73
  4. package/dist/atlas-client.js +52 -37
  5. package/dist/auth-cmds/commands.d.ts +1 -1
  6. package/dist/auth-cmds/commands.js +12 -7
  7. package/dist/auth.d.ts +97 -19
  8. package/dist/auth.js +376 -81
  9. package/dist/config.d.ts +3 -3
  10. package/dist/config.js +18 -13
  11. package/dist/env-catalog.js +13 -3
  12. package/dist/env-flags.d.ts +2 -0
  13. package/dist/env-flags.js +2 -0
  14. package/dist/env-registry.d.ts +27 -0
  15. package/dist/env-registry.js +204 -0
  16. package/dist/envs/commands.d.ts +1 -1
  17. package/dist/envs/commands.js +41 -3
  18. package/dist/file-lock.d.ts +5 -0
  19. package/dist/file-lock.js +187 -0
  20. package/dist/functions/commands.d.ts +9 -1
  21. package/dist/functions/commands.js +71 -29
  22. package/dist/functions/manifest.d.ts +1 -0
  23. package/dist/functions/manifest.js +36 -0
  24. package/dist/login.d.ts +8 -3
  25. package/dist/login.js +46 -34
  26. package/dist/main.d.ts +2 -1
  27. package/dist/main.js +35 -12
  28. package/dist/orm/delegate.js +15 -2
  29. package/dist/pat-hints.js +2 -2
  30. package/dist/pipeline/commands.d.ts +58 -0
  31. package/dist/pipeline/commands.js +330 -0
  32. package/dist/pipeline/lifecycle.d.ts +58 -0
  33. package/dist/pipeline/lifecycle.js +348 -0
  34. package/dist/pipeline/pinning.d.ts +5 -0
  35. package/dist/pipeline/pinning.js +9 -0
  36. package/dist/pipeline/templates.d.ts +11 -0
  37. package/dist/pipeline/templates.js +166 -0
  38. package/dist/process/build.d.ts +4 -0
  39. package/dist/process/build.js +31 -1
  40. package/dist/process/codegen.js +19 -1
  41. package/dist/process/commands.js +97 -47
  42. package/dist/process/compiler-subprocess.d.ts +29 -0
  43. package/dist/process/compiler-subprocess.js +99 -0
  44. package/dist/process/compiler-worker.d.ts +1 -0
  45. package/dist/process/compiler-worker.js +38 -0
  46. package/dist/process/lint.d.ts +8 -0
  47. package/dist/process/lint.js +76 -29
  48. package/dist/process/repo-install.js +18 -2
  49. package/dist/repos/commands.d.ts +1 -1
  50. package/dist/repos/commands.js +17 -12
  51. package/dist/secrets/commands.d.ts +1 -1
  52. package/dist/secrets/commands.js +18 -18
  53. package/package.json +8 -3
package/dist/auth.d.ts CHANGED
@@ -10,10 +10,10 @@
10
10
  * cloud agents with no interactive login can still push.
11
11
  * (M2M carries app scopes but NO user identity / workspace membership
12
12
  * — see the `atlas-test-access` rule.)
13
- * 2. Cached user token — read from the seqapi token file and refreshed
14
- * via the Auth0 refresh-token grant when near expiry.
13
+ * 2. Cached user access token — read from the seqapi token file. When it
14
+ * expires, an interactive session performs a bounded PKCE login again.
15
15
  *
16
- * Login and refresh both write the shared file. This mirrors
16
+ * Login writes the shared file. This mirrors
17
17
  * `seqapi._save_tokens` exactly:
18
18
  * same fields, same shape, same 0o600 permissions, atomic write via
19
19
  * tmpfile + rename. The M2M token is in-memory only (never persisted).
@@ -21,11 +21,50 @@
21
21
  export declare const AUTH0_DOMAIN = "dev-n1t8ts403fp8oyxp.us.auth0.com";
22
22
  export declare const AUTH0_CLIENT_ID = "GD9riCDWocfc66odpWBjwBiX43qqAX8r";
23
23
  export declare const AUTH0_AUDIENCE = "https://api.studio.com";
24
+ /** The realm name the built-in Sequence environments' tokens live under —
25
+ * also the implicit realm of the legacy flat fields in tokens.json. */
26
+ export declare const SEQUENCE_REALM = "sequence";
27
+ export declare function isSequenceAuthEnvName(envName: string): boolean;
28
+ /**
29
+ * One Auth0 login context. Mirrors seqapi's `AuthRealm`
30
+ * (`shared/seqapi/seqapi/config.py`): the Sequence realm is hard-coded;
31
+ * OpCo-environment realms are read from seqapi's config.json registry,
32
+ * written by `seq-studio envs add` or `seqapi env add` — both CLIs share one
33
+ * registry and one token file, so either can log in and the other picks the
34
+ * session up.
35
+ */
36
+ export interface AuthRealm {
37
+ name: string;
38
+ domain: string;
39
+ clientId: string;
40
+ audience: string;
41
+ organization?: string;
42
+ m2mClientId?: string;
43
+ }
44
+ /**
45
+ * A discovery response is not a trust anchor for the host that receives an
46
+ * M2M client secret. Even another valid *.auth0.com tenant is untrusted;
47
+ * additional Auth0 tenants/custom domains require an explicit code-reviewed
48
+ * allowlist entry.
49
+ */
50
+ export declare function validateAuth0Domain(domain: string): string;
51
+ export declare const SEQUENCE_AUTH_REALM: AuthRealm;
24
52
  export interface SeqapiTokens {
25
- refresh_token?: string;
26
53
  access_token?: string;
27
54
  expires_at?: number;
28
55
  }
56
+ /**
57
+ * Resolve the auth realm for an environment name. Undefined, built-ins, and
58
+ * per-PR preview targets map to the shared Sequence realm. Preview URLs are
59
+ * constrained to Sequence's preview domain by the environment resolver. Every
60
+ * other explicit name must have a valid seqapi registry entry; otherwise fail
61
+ * closed so a shared Sequence bearer token can never be sent to a tenant URL.
62
+ */
63
+ export declare function realmForEnv(envName?: string): Promise<AuthRealm>;
64
+ /** Env var(s) carrying a realm's M2M client secret — the Sequence realm keeps
65
+ * the legacy bare name; OpCo realms use a suffixed name so one shell can hold
66
+ * several credentials unambiguously. Mirrors seqapi's `_m2m_secret_env_names`. */
67
+ export declare function m2mSecretEnvName(realm: AuthRealm): string;
29
68
  /**
30
69
  * A configured M2M credential failed to mint a token. Typed so callers that
31
70
  * normally swallow discovery errors (lazy catalog refresh) can still surface
@@ -38,38 +77,77 @@ export declare function seqapiTokenDir(): string;
38
77
  export declare function seqapiTokenPath(): string;
39
78
  export declare class NotLoggedInError extends Error {
40
79
  readonly name = "NotLoggedInError";
41
- constructor();
80
+ constructor(realmName?: string, reason?: string);
42
81
  }
43
82
  /**
44
- * Return a valid access token. Tries the M2M service account first when
45
- * `AUTH0_M2M_CLIENT_SECRET` is set, then falls back to the cached user
46
- * token (refreshed via the Auth0 refresh-token grant when within 60s of
47
- * expiry). Same precedence as seqapi's `get_access_token`, so both CLIs
48
- * resolve the same identity for the same environment.
83
+ * Return a valid access token for an environment's auth realm. Tries the
84
+ * realm's M2M service account first (secret env var), then falls back to the
85
+ * cached user access token. Expired user sessions perform bounded PKCE login
86
+ * when browser auto-login is enabled. Same precedence and token file as seqapi's
87
+ * `get_access_token`, so both CLIs resolve the same identity for the same
88
+ * environment. No `env` (or a built-in Sequence env) means the shared
89
+ * Sequence realm — the legacy behavior every existing caller gets unchanged.
49
90
  */
50
- export declare function getAccessToken(): Promise<string>;
91
+ export declare class UnsafeAuthTargetError extends Error {
92
+ }
93
+ export type AuthMode = 'm2m' | 'user';
94
+ export interface ResolvedAccessToken {
95
+ authMode: AuthMode;
96
+ token: string;
97
+ }
98
+ export declare function getAccessTokenWithMode(options?: {
99
+ /** Disable browser PKCE fallback for probe-only and other non-interactive callers. */
100
+ allowInteractiveLogin?: boolean;
101
+ env?: string;
102
+ targetUrl?: string;
103
+ }): Promise<ResolvedAccessToken>;
104
+ export declare function getAccessToken(options?: {
105
+ /** Disable browser PKCE fallback for probe-only and other non-interactive callers. */
106
+ allowInteractiveLogin?: boolean;
107
+ env?: string;
108
+ targetUrl?: string;
109
+ }): Promise<string>;
51
110
  /**
52
111
  * Try to load a token without throwing. Returns `null` for any error
53
112
  * condition (missing file, parse error, no token fields). Used by
54
113
  * `doctor` for non-fatal "are you logged in?" checks.
55
114
  */
56
- export declare function tryGetAccessToken(options?: {
115
+ export declare function tryGetAccessTokenWithMode(options?: {
57
116
  /**
58
117
  * When the M2M secret is configured, failing to mint an M2M token should fail
59
118
  * closed (avoid silently falling back to some other cached identity).
60
119
  */
61
120
  failClosedForM2m?: boolean;
121
+ /** Environment name — selects the auth realm (default: Sequence). */
122
+ env?: string;
123
+ /** Resolved request origin — checked against the realm before returning credentials. */
124
+ targetUrl?: string;
125
+ }): Promise<ResolvedAccessToken | null>;
126
+ export declare function tryGetAccessToken(options?: {
127
+ failClosedForM2m?: boolean;
128
+ env?: string;
129
+ targetUrl?: string;
62
130
  }): Promise<string | null>;
63
131
  /**
64
- * Decode the `sub` claim from a JWT without verification. Verification is the
65
- * server's job this is only used to compare identities locally (e.g. to
66
- * bind the cached environment catalog to the identity that fetched it).
132
+ * Refuse to persist a token minted for another audience or Auth0
133
+ * organization. Auth0/server-side JWT verification remains authoritative;
134
+ * this local decode is only a cross-realm confusion check on a token received
135
+ * directly from the configured Auth0 tenant over TLS.
67
136
  */
137
+ export declare function verifyTokenMatchesRealm({ accessToken, realm, requireOrganization, }: {
138
+ accessToken: string;
139
+ realm: AuthRealm;
140
+ requireOrganization?: boolean;
141
+ }): void;
68
142
  export declare function decodeJwtSub(token: string): string | null;
69
143
  /**
70
144
  * The Auth0 subject the CLI would authenticate as right now, without any
71
- * network call: the fixed M2M client subject when the secret is configured,
72
- * else the `sub` of the cached user token, else null (anonymous).
145
+ * network call: the requested realm's M2M client subject when its secret is
146
+ * configured, else the `sub` of that realm's cached user token, else null.
73
147
  */
74
- export declare function currentIdentitySubject(): Promise<string | null>;
75
- export declare function saveTokens(tokens: SeqapiTokens): Promise<void>;
148
+ export declare function currentIdentitySubject(options?: {
149
+ env?: string;
150
+ }): Promise<string | null>;
151
+ export declare function loadCachedUserTokens(realmName?: string): Promise<SeqapiTokens | null>;
152
+ export declare function saveTokens(tokens: SeqapiTokens, realmName?: string): Promise<void>;
153
+ export declare function deleteRealmTokens(realmName: string): Promise<void>;