@gravity-rail/cli 0.1.0 → 0.3.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 CHANGED
@@ -141,7 +141,7 @@ cat member.json | gr members update -w $WORKSPACE --id 42 --allow-write
141
141
 
142
142
  | Domain | Description |
143
143
  |---|---|
144
- | `tasks` | Workflow tasks — CRUD, archive, clone, convert-to-abilities |
144
+ | `tasks` | Workflow tasks — CRUD, archive, clone |
145
145
  | `chats` | Conversations — CRUD, labels, filters, messages, export, summaries |
146
146
  | `members` | Contacts and team — CRUD, labels, filters, roles, fields, import/export |
147
147
  | `workspaces` | Workspace management — CRUD, features, themes, invitations, export/import |
@@ -0,0 +1,86 @@
1
+ /**
2
+ * CLI configuration for remote environments
3
+ */
4
+ interface EnvironmentConfig {
5
+ apiUrl: string;
6
+ frontendUrl: string;
7
+ }
8
+ declare const ENVIRONMENTS: Record<string, EnvironmentConfig>;
9
+ declare const CALLBACK_PORT = 31337;
10
+ declare const CALLBACK_PATH = "/oauth/callback";
11
+ declare const REDIRECT_URI = "http://localhost:31337/oauth/callback";
12
+ declare function getEnvironmentConfig(env: string): EnvironmentConfig;
13
+
14
+ /**
15
+ * CLI OAuth2 authentication utilities
16
+ *
17
+ * Provides OAuth2 with PKCE flow for CLI tools, including:
18
+ * - Credential caching (per environment)
19
+ * - Dynamic client registration
20
+ * - Token refresh
21
+ * - Browser-based authorization
22
+ */
23
+
24
+ interface CLICredentials {
25
+ clientId: string;
26
+ clientSecret: string;
27
+ accessToken?: string;
28
+ refreshToken?: string;
29
+ expiresAt?: string;
30
+ }
31
+ interface AuthResult {
32
+ accessToken: string;
33
+ credentials?: CLICredentials;
34
+ }
35
+ /**
36
+ * Manages CLI credentials storage (flat format, one file per environment)
37
+ */
38
+ declare class CredentialsManager {
39
+ private cacheDir;
40
+ private apiUrl?;
41
+ constructor(rootDir: string, apiUrl?: string);
42
+ private getCredentialsPath;
43
+ load(env: string): CLICredentials | null;
44
+ save(env: string, creds: CLICredentials): void;
45
+ clear(env: string): void;
46
+ getCacheDir(): string;
47
+ }
48
+ /**
49
+ * Generate PKCE code verifier and challenge
50
+ */
51
+ declare function generatePKCE(): {
52
+ codeVerifier: string;
53
+ codeChallenge: string;
54
+ };
55
+ /**
56
+ * Open a URL in the default browser
57
+ */
58
+ declare function openBrowser(url: string): void;
59
+ /**
60
+ * Start a local HTTP server to receive the OAuth callback
61
+ */
62
+ declare function startCallbackServer(): Promise<{
63
+ code: string;
64
+ state: string;
65
+ }>;
66
+ interface OAuthFlowOptions {
67
+ env: string;
68
+ envConfig: EnvironmentConfig;
69
+ credentialsManager: CredentialsManager;
70
+ clientName?: string;
71
+ }
72
+ /**
73
+ * Perform the full OAuth2 browser-based flow with PKCE.
74
+ *
75
+ * This always opens the browser for authorization. It never returns a cached
76
+ * token — that's the job of createAuthenticatedContext. The only thing reused
77
+ * is the registered OAuth client ID (which is identity, not auth).
78
+ */
79
+ declare function performOAuthFlow(options: OAuthFlowOptions): Promise<AuthResult>;
80
+ /**
81
+ * Refresh an access token using a stored refresh token.
82
+ * Returns updated credentials on success, null on failure.
83
+ */
84
+ declare function refreshAccessToken(envConfig: EnvironmentConfig, creds: CLICredentials, credentialsManager: CredentialsManager, env: string): Promise<CLICredentials | null>;
85
+
86
+ export { type AuthResult as A, CredentialsManager as C, type EnvironmentConfig as E, type OAuthFlowOptions as O, REDIRECT_URI as R, CALLBACK_PATH as a, CALLBACK_PORT as b, type CLICredentials as c, ENVIRONMENTS as d, getEnvironmentConfig as e, generatePKCE as g, openBrowser as o, performOAuthFlow as p, refreshAccessToken as r, startCallbackServer as s };