@knpkv/atlassian-common 0.3.0 → 0.4.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @knpkv/atlassian-common
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#103](https://github.com/knpkv/npm/pull/103) [`477e4c6`](https://github.com/knpkv/npm/commit/477e4c60fa5c501883be6c03629da5a3cc91444c) Thanks [@konopkov](https://github.com/konopkov)! - Add shared Atlassian auth profile storage for multi-account and multi-site OAuth use.
8
+
9
+ Jira and Confluence now expose `auth profiles`, `auth use <profile>`, and `auth remove <profile>` commands backed by shared profile management in `@knpkv/atlassian-common`. Confluence also migrates existing legacy auth/config files on first use. Agent skills and docs now describe the profile commands and active-profile checks.
10
+
11
+ - [#105](https://github.com/knpkv/npm/pull/105) [`a3a4d3a`](https://github.com/knpkv/npm/commit/a3a4d3a14fafe235bc901ed5015bb9bd82c59281) Thanks [@konopkov](https://github.com/konopkov)! - Add a unified Atlassian profile manager CLI with cross-tool profile listing, selection, diagnostics, token refresh, and scope validation helpers.
12
+
13
+ Update bundled Jira, Confluence, and Jira Clockify agent skills to recommend the unified profile diagnostics workflow.
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @knpkv/atlassian-common
2
2
 
3
- Shared utilities for Atlassian tools: OAuth2 + PKCE auth, token storage, config paths, AST types, and markdown serialization.
3
+ Shared utilities for Atlassian tools: OAuth2 + PKCE auth, shared auth profiles, token storage, config paths, AST types, and markdown serialization.
4
4
 
5
5
  ## Installation
6
6
 
@@ -15,7 +15,7 @@ pnpm add @knpkv/atlassian-common
15
15
  | `@knpkv/atlassian-common` | Everything (AST, auth, config, serializers) |
16
16
  | `@knpkv/atlassian-common/ast` | Inline, block, macro, and document AST nodes |
17
17
  | `@knpkv/atlassian-common/auth` | OAuth2 endpoints, PKCE, token exchange |
18
- | `@knpkv/atlassian-common/config` | Config paths, schemas, token storage |
18
+ | `@knpkv/atlassian-common/config` | Config paths, schemas, token/profile storage |
19
19
  | `@knpkv/atlassian-common/serializers` | Markdown serializer for AST nodes |
20
20
 
21
21
  ## OAuth2 + PKCE
@@ -59,15 +59,17 @@ const program = Effect.gen(function* () {
59
59
  })
60
60
  ```
61
61
 
62
- ## Token Storage
62
+ ## Token And Profile Storage
63
63
 
64
- Stores OAuth config and tokens in `~/.config/atlassian/` with 0600 permissions.
64
+ Stores OAuth config, auth profiles, and the active token mirror in `~/.config/atlassian/<tool>/` with 0600 permissions.
65
65
 
66
66
  ```typescript
67
67
  import { Effect } from "effect"
68
68
  import {
69
- saveToken,
70
- loadToken,
69
+ saveProfileToken,
70
+ loadActiveProfileToken,
71
+ loadProfiles,
72
+ setActiveProfileBySelector,
71
73
  isTokenExpired,
72
74
  saveOAuthConfig,
73
75
  loadOAuthConfig,
@@ -75,15 +77,28 @@ import {
75
77
  } from "@knpkv/atlassian-common/config"
76
78
 
77
79
  const program = Effect.gen(function* () {
78
- yield* saveOAuthConfig({ clientId: "...", clientSecret: "..." }, "jira")
80
+ yield* saveOAuthConfig("jira", { clientId: "...", clientSecret: "..." })
79
81
  const config = yield* loadOAuthConfig("jira")
80
82
 
81
- yield* saveToken({ access_token: "...", refresh_token: "...", expires_in: 3600 }, "jira")
82
- const token = yield* loadToken("jira")
83
- const expired = isTokenExpired(token)
83
+ yield* saveProfileToken("jira", {
84
+ access_token: "...",
85
+ refresh_token: "...",
86
+ expires_at: Date.now() + 3600_000,
87
+ scope: "read:jira-work offline_access",
88
+ cloud_id: "...",
89
+ site_url: "https://example.atlassian.net"
90
+ })
91
+
92
+ const profiles = yield* loadProfiles("jira")
93
+ yield* setActiveProfileBySelector("jira", "https://example.atlassian.net")
94
+
95
+ const token = yield* loadActiveProfileToken("jira")
96
+ const expired = token ? isTokenExpired(token) : true
84
97
  }).pipe(Effect.provide(HomeDirectoryLive))
85
98
  ```
86
99
 
100
+ `profiles.json` is the multi-account/site source of truth. `auth.json` is still mirrored to the active profile so older single-profile consumers keep working.
101
+
87
102
  ## AST Types
88
103
 
89
104
  Typed Atlassian Document Format nodes — used by `@knpkv/jira-cli` and `@knpkv/confluence-to-markdown`.
package/dist/bin.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=bin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
package/dist/bin.js ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env node
2
+ import { NodeFileSystem, NodeHttpClient, NodePath, NodeRuntime, NodeServices, NodeStdio } from "@effect/platform-node";
3
+ import * as Console from "effect/Console";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Layer from "effect/Layer";
6
+ import * as Stdio from "effect/Stdio";
7
+ import { Argument as Args, Command } from "effect/unstable/cli";
8
+ import pkg from "../package.json" with { type: "json" };
9
+ import { HomeDirectoryLive, inspectAllToolProfiles, migrateLegacyProfiles, refreshActiveProfiles, useProfileForAllTools } from "./config/index.js";
10
+ const profileArg = Args.string("profile").pipe(Args.withDescription("Profile ID, name, site URL, cloud ID, or account ID"));
11
+ const printStatuses = (statuses) => Effect.gen(function* () {
12
+ for (const status of statuses) {
13
+ const active = status.activeProfile;
14
+ yield* Console.log(`${status.tool.label} (${status.tool.toolName})`);
15
+ if (status.authStoreName !== status.tool.toolName) {
16
+ yield* Console.log(` Auth store: ${status.authStoreName}`);
17
+ }
18
+ yield* Console.log(` Active: ${active ? active.name : "none"}`);
19
+ if (active) {
20
+ yield* Console.log(` Profile ID: ${active.id}`);
21
+ yield* Console.log(` Site: ${active.token.site_url}`);
22
+ yield* Console.log(` Token: ${status.tokenStatus}`);
23
+ yield* Console.log(` Scopes: ${status.missingScopes.length === 0 ? "ok" : `missing ${status.missingScopes.join(", ")}`}`);
24
+ }
25
+ }
26
+ });
27
+ const profilesList = Command.make("list", {}, () => inspectAllToolProfiles().pipe(Effect.flatMap(printStatuses)))
28
+ .pipe(Command.withDescription("List active Atlassian profiles for all tools"));
29
+ const profilesUse = Command.make("use", { profile: profileArg }, ({ profile }) => useProfileForAllTools(profile).pipe(Effect.flatMap(printStatuses))).pipe(Command.withDescription("Use a profile across Atlassian tools"));
30
+ const profilesDoctor = Command.make("doctor", {}, () => inspectAllToolProfiles().pipe(Effect.flatMap((statuses) => Effect.gen(function* () {
31
+ yield* printStatuses(statuses);
32
+ for (const status of statuses) {
33
+ if (!status.activeProfile) {
34
+ yield* Console.log(`Suggestion: run '${status.tool.loginHint}' for ${status.tool.label}.`);
35
+ }
36
+ if (status.tokenStatus === "expired") {
37
+ yield* Console.log(`Suggestion: run 'atlassian auth refresh' or '${status.tool.loginHint}' for ${status.tool.label}.`);
38
+ }
39
+ if (status.missingScopes.length > 0) {
40
+ yield* Console.log(`Suggestion: re-login with ${status.tool.label}; missing scopes: ${status.missingScopes.join(", ")}.`);
41
+ }
42
+ }
43
+ })))).pipe(Command.withDescription("Diagnose tokens, scopes, and active profile usage"));
44
+ const profilesMigrate = Command.make("migrate", {}, () => migrateLegacyProfiles().pipe(Effect.flatMap(printStatuses)))
45
+ .pipe(Command.withDescription("Migrate legacy auth.json files into shared profiles.json storage"));
46
+ const profiles = Command.make("profiles").pipe(Command.withDescription("Manage shared Atlassian auth profiles"), Command.withSubcommands([profilesList, profilesUse, profilesDoctor, profilesMigrate]));
47
+ const authRefresh = Command.make("refresh", {}, () => refreshActiveProfiles().pipe(Effect.flatMap(printStatuses)))
48
+ .pipe(Command.withDescription("Refresh expired active OAuth tokens"));
49
+ const auth = Command.make("auth").pipe(Command.withDescription("Manage Atlassian authentication"), Command.withSubcommands([authRefresh]));
50
+ const atlassian = Command.make("atlassian", {}, () => Console.log("Usage: atlassian profiles|auth")).pipe(Command.withDescription("Unified Atlassian profile manager"), Command.withSubcommands([profiles, auth]));
51
+ const cli = Command.runWith(atlassian, { version: pkg.version });
52
+ const program = Effect.gen(function* () {
53
+ const stdio = yield* Stdio.Stdio;
54
+ const args = yield* stdio.args;
55
+ return yield* cli(args);
56
+ }).pipe(Effect.provide(NodeStdio.layer), Effect.provide(Layer.mergeAll(NodeServices.layer, NodeFileSystem.layer, NodePath.layer, NodeHttpClient.layerFetch, HomeDirectoryLive)), Effect.catch((error) => Console.error(String(error)).pipe(Effect.andThen(Effect.fail(error)))));
57
+ NodeRuntime.runMain(program);
58
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,QAAQ,IAAI,IAAI,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACvD,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EAErB,qBAAqB,EACtB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAC5C,IAAI,CAAC,eAAe,CAAC,qDAAqD,CAAC,CAC5E,CAAA;AAED,MAAM,aAAa,GAAG,CAAC,QAA0C,EAAE,EAAE,CACnE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,KAAK,MAAM,MAA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AAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC,CAAC,IAAI,CACvG,OAAO,CAAC,eAAe,CAAC,mCAAmC,CAAC,EAC5D,OAAO,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAC1C,CAAA;AAED,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;AAChE,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAA;IAChC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;IAC9B,OAAO,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAC,CAAC,IAAI,CACL,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAC/B,MAAM,CAAC,OAAO,CACZ,KAAK,CAAC,QAAQ,CACZ,YAAY,CAAC,KAAK,EAClB,cAAc,CAAC,KAAK,EACpB,QAAQ,CAAC,KAAK,EACd,cAAc,CAAC,UAAU,EACzB,iBAAiB,CAClB,CACF,EACD,MAAM,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CACxG,CAAA;AAED,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA"}
@@ -0,0 +1,342 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as FileSystem from "effect/FileSystem";
3
+ import type * as Path from "effect/Path";
4
+ import * as Schema from "effect/Schema";
5
+ import { type HomeDirectoryError, type HomeDirectoryTag } from "./ConfigPaths.js";
6
+ import { type OAuthToken } from "./OAuthSchemas.js";
7
+ import { FileSystemError } from "./TokenStorage.js";
8
+ /**
9
+ * A persisted Atlassian auth profile.
10
+ *
11
+ * @category Schema
12
+ */
13
+ export declare const AuthProfileSchema: Schema.Struct<{
14
+ /** Stable identifier derived from account and cloud IDs. */
15
+ readonly id: Schema.String;
16
+ /** Human-readable profile label. */
17
+ readonly name: Schema.String;
18
+ /** OAuth token and selected site metadata. */
19
+ readonly token: Schema.Struct<{
20
+ readonly access_token: Schema.String;
21
+ readonly refresh_token: Schema.String;
22
+ readonly expires_at: Schema.Number;
23
+ readonly scope: Schema.String;
24
+ readonly cloud_id: Schema.String;
25
+ readonly site_url: Schema.String;
26
+ readonly user: Schema.optional<Schema.Struct<{
27
+ readonly account_id: Schema.String;
28
+ readonly name: Schema.String;
29
+ readonly email: Schema.String;
30
+ }>>;
31
+ }>;
32
+ /** ISO timestamp when the profile was first created. */
33
+ readonly created_at: Schema.String;
34
+ /** ISO timestamp when the profile was last updated. */
35
+ readonly updated_at: Schema.String;
36
+ }>;
37
+ /**
38
+ * Type for a persisted Atlassian auth profile.
39
+ *
40
+ * @category Types
41
+ */
42
+ export type AuthProfile = Schema.Schema.Type<typeof AuthProfileSchema>;
43
+ /**
44
+ * Schema for the profile registry file.
45
+ *
46
+ * @category Schema
47
+ */
48
+ export declare const AuthProfilesFileSchema: Schema.Struct<{
49
+ /** Active profile ID. Omitted when no profile is active. */
50
+ readonly activeProfileId: Schema.optional<Schema.String>;
51
+ /** Known auth profiles for this CLI. */
52
+ readonly profiles: Schema.$Array<Schema.Struct<{
53
+ /** Stable identifier derived from account and cloud IDs. */
54
+ readonly id: Schema.String;
55
+ /** Human-readable profile label. */
56
+ readonly name: Schema.String;
57
+ /** OAuth token and selected site metadata. */
58
+ readonly token: Schema.Struct<{
59
+ readonly access_token: Schema.String;
60
+ readonly refresh_token: Schema.String;
61
+ readonly expires_at: Schema.Number;
62
+ readonly scope: Schema.String;
63
+ readonly cloud_id: Schema.String;
64
+ readonly site_url: Schema.String;
65
+ readonly user: Schema.optional<Schema.Struct<{
66
+ readonly account_id: Schema.String;
67
+ readonly name: Schema.String;
68
+ readonly email: Schema.String;
69
+ }>>;
70
+ }>;
71
+ /** ISO timestamp when the profile was first created. */
72
+ readonly created_at: Schema.String;
73
+ /** ISO timestamp when the profile was last updated. */
74
+ readonly updated_at: Schema.String;
75
+ }>>;
76
+ }>;
77
+ /**
78
+ * Type for the profile registry file.
79
+ *
80
+ * @category Types
81
+ */
82
+ export type AuthProfilesFile = Schema.Schema.Type<typeof AuthProfilesFileSchema>;
83
+ /**
84
+ * Build a stable profile ID from token site and user identity.
85
+ *
86
+ * @category Utilities
87
+ */
88
+ export declare const profileIdFromToken: (token: OAuthToken) => string;
89
+ /**
90
+ * Build a readable profile label from token site and user identity.
91
+ *
92
+ * @category Utilities
93
+ */
94
+ export declare const profileNameFromToken: (token: OAuthToken) => string;
95
+ /**
96
+ * Create a profile record from an OAuth token.
97
+ *
98
+ * @category Utilities
99
+ */
100
+ export declare const profileFromToken: (token: OAuthToken, now: Date) => AuthProfile;
101
+ /**
102
+ * Load all auth profiles for a tool.
103
+ *
104
+ * Falls back to the legacy single-token file when `profiles.json` does not exist.
105
+ *
106
+ * @category Profile Storage
107
+ */
108
+ export declare const loadProfiles: (toolName: string) => Effect.Effect<AuthProfilesFile, FileSystemError | HomeDirectoryError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
109
+ /**
110
+ * Save auth profiles and mirror the active profile to `auth.json`.
111
+ *
112
+ * @category Profile Storage
113
+ */
114
+ export declare const saveProfiles: (toolName: string, store: AuthProfilesFile) => Effect.Effect<void, import("effect/PlatformError").PlatformError | HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
115
+ /**
116
+ * Insert or update a profile from a token and make it active.
117
+ *
118
+ * @category Profile Storage
119
+ */
120
+ export declare const saveProfileToken: (toolName: string, token: OAuthToken) => Effect.Effect<Schema.Struct.ReadonlySide<{
121
+ /** Stable identifier derived from account and cloud IDs. */
122
+ readonly id: Schema.String;
123
+ /** Human-readable profile label. */
124
+ readonly name: Schema.String;
125
+ /** OAuth token and selected site metadata. */
126
+ readonly token: Schema.Struct<{
127
+ readonly access_token: Schema.String;
128
+ readonly refresh_token: Schema.String;
129
+ readonly expires_at: Schema.Number;
130
+ readonly scope: Schema.String;
131
+ readonly cloud_id: Schema.String;
132
+ readonly site_url: Schema.String;
133
+ readonly user: Schema.optional<Schema.Struct<{
134
+ readonly account_id: Schema.String;
135
+ readonly name: Schema.String;
136
+ readonly email: Schema.String;
137
+ }>>;
138
+ }>;
139
+ /** ISO timestamp when the profile was first created. */
140
+ readonly created_at: Schema.String;
141
+ /** ISO timestamp when the profile was last updated. */
142
+ readonly updated_at: Schema.String;
143
+ }, "Type">, import("effect/PlatformError").PlatformError | HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
144
+ /**
145
+ * Load the active auth profile.
146
+ *
147
+ * @category Profile Storage
148
+ */
149
+ export declare const loadActiveProfile: (toolName: string) => Effect.Effect<Schema.Struct.ReadonlySide<{
150
+ /** Stable identifier derived from account and cloud IDs. */
151
+ readonly id: Schema.String;
152
+ /** Human-readable profile label. */
153
+ readonly name: Schema.String;
154
+ /** OAuth token and selected site metadata. */
155
+ readonly token: Schema.Struct<{
156
+ readonly access_token: Schema.String;
157
+ readonly refresh_token: Schema.String;
158
+ readonly expires_at: Schema.Number;
159
+ readonly scope: Schema.String;
160
+ readonly cloud_id: Schema.String;
161
+ readonly site_url: Schema.String;
162
+ readonly user: Schema.optional<Schema.Struct<{
163
+ readonly account_id: Schema.String;
164
+ readonly name: Schema.String;
165
+ readonly email: Schema.String;
166
+ }>>;
167
+ }>;
168
+ /** ISO timestamp when the profile was first created. */
169
+ readonly created_at: Schema.String;
170
+ /** ISO timestamp when the profile was last updated. */
171
+ readonly updated_at: Schema.String;
172
+ }, "Type"> | null, HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
173
+ /**
174
+ * Load the active OAuth token.
175
+ *
176
+ * @category Profile Storage
177
+ */
178
+ export declare const loadActiveProfileToken: (toolName: string) => Effect.Effect<{
179
+ readonly access_token: string;
180
+ readonly refresh_token: string;
181
+ readonly expires_at: number;
182
+ readonly scope: string;
183
+ readonly cloud_id: string;
184
+ readonly site_url: string;
185
+ readonly user?: Schema.Struct.ReadonlySide<{
186
+ readonly account_id: Schema.String;
187
+ readonly name: Schema.String;
188
+ readonly email: Schema.String;
189
+ }, "Type"> | undefined;
190
+ } | null, HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
191
+ /**
192
+ * Set the active profile by ID.
193
+ *
194
+ * @category Profile Storage
195
+ */
196
+ export declare const setActiveProfile: (toolName: string, profileId: string) => Effect.Effect<Schema.Struct.ReadonlySide<{
197
+ /** Stable identifier derived from account and cloud IDs. */
198
+ readonly id: Schema.String;
199
+ /** Human-readable profile label. */
200
+ readonly name: Schema.String;
201
+ /** OAuth token and selected site metadata. */
202
+ readonly token: Schema.Struct<{
203
+ readonly access_token: Schema.String;
204
+ readonly refresh_token: Schema.String;
205
+ readonly expires_at: Schema.Number;
206
+ readonly scope: Schema.String;
207
+ readonly cloud_id: Schema.String;
208
+ readonly site_url: Schema.String;
209
+ readonly user: Schema.optional<Schema.Struct<{
210
+ readonly account_id: Schema.String;
211
+ readonly name: Schema.String;
212
+ readonly email: Schema.String;
213
+ }>>;
214
+ }>;
215
+ /** ISO timestamp when the profile was first created. */
216
+ readonly created_at: Schema.String;
217
+ /** ISO timestamp when the profile was last updated. */
218
+ readonly updated_at: Schema.String;
219
+ }, "Type"> | null, import("effect/PlatformError").PlatformError | HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
220
+ /**
221
+ * Resolve a profile by ID, name, site URL, cloud ID, or account ID.
222
+ *
223
+ * @category Utilities
224
+ */
225
+ export declare const findProfile: (profiles: ReadonlyArray<AuthProfile>, selector: string) => AuthProfile | null;
226
+ /**
227
+ * Set the active profile using a flexible selector.
228
+ *
229
+ * @category Profile Storage
230
+ */
231
+ export declare const setActiveProfileBySelector: (toolName: string, selector: string) => Effect.Effect<Schema.Struct.ReadonlySide<{
232
+ /** Stable identifier derived from account and cloud IDs. */
233
+ readonly id: Schema.String;
234
+ /** Human-readable profile label. */
235
+ readonly name: Schema.String;
236
+ /** OAuth token and selected site metadata. */
237
+ readonly token: Schema.Struct<{
238
+ readonly access_token: Schema.String;
239
+ readonly refresh_token: Schema.String;
240
+ readonly expires_at: Schema.Number;
241
+ readonly scope: Schema.String;
242
+ readonly cloud_id: Schema.String;
243
+ readonly site_url: Schema.String;
244
+ readonly user: Schema.optional<Schema.Struct<{
245
+ readonly account_id: Schema.String;
246
+ readonly name: Schema.String;
247
+ readonly email: Schema.String;
248
+ }>>;
249
+ }>;
250
+ /** ISO timestamp when the profile was first created. */
251
+ readonly created_at: Schema.String;
252
+ /** ISO timestamp when the profile was last updated. */
253
+ readonly updated_at: Schema.String;
254
+ }, "Type"> | null, import("effect/PlatformError").PlatformError | HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
255
+ /**
256
+ * Remove a profile by ID.
257
+ *
258
+ * @category Profile Storage
259
+ */
260
+ export declare const deleteProfile: (toolName: string, profileId: string) => Effect.Effect<Schema.Struct.ReadonlySide<{
261
+ /** Stable identifier derived from account and cloud IDs. */
262
+ readonly id: Schema.String;
263
+ /** Human-readable profile label. */
264
+ readonly name: Schema.String;
265
+ /** OAuth token and selected site metadata. */
266
+ readonly token: Schema.Struct<{
267
+ readonly access_token: Schema.String;
268
+ readonly refresh_token: Schema.String;
269
+ readonly expires_at: Schema.Number;
270
+ readonly scope: Schema.String;
271
+ readonly cloud_id: Schema.String;
272
+ readonly site_url: Schema.String;
273
+ readonly user: Schema.optional<Schema.Struct<{
274
+ readonly account_id: Schema.String;
275
+ readonly name: Schema.String;
276
+ readonly email: Schema.String;
277
+ }>>;
278
+ }>;
279
+ /** ISO timestamp when the profile was first created. */
280
+ readonly created_at: Schema.String;
281
+ /** ISO timestamp when the profile was last updated. */
282
+ readonly updated_at: Schema.String;
283
+ }, "Type"> | null, import("effect/PlatformError").PlatformError | HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
284
+ /**
285
+ * Remove a profile using a flexible selector.
286
+ *
287
+ * @category Profile Storage
288
+ */
289
+ export declare const deleteProfileBySelector: (toolName: string, selector: string) => Effect.Effect<Schema.Struct.ReadonlySide<{
290
+ /** Stable identifier derived from account and cloud IDs. */
291
+ readonly id: Schema.String;
292
+ /** Human-readable profile label. */
293
+ readonly name: Schema.String;
294
+ /** OAuth token and selected site metadata. */
295
+ readonly token: Schema.Struct<{
296
+ readonly access_token: Schema.String;
297
+ readonly refresh_token: Schema.String;
298
+ readonly expires_at: Schema.Number;
299
+ readonly scope: Schema.String;
300
+ readonly cloud_id: Schema.String;
301
+ readonly site_url: Schema.String;
302
+ readonly user: Schema.optional<Schema.Struct<{
303
+ readonly account_id: Schema.String;
304
+ readonly name: Schema.String;
305
+ readonly email: Schema.String;
306
+ }>>;
307
+ }>;
308
+ /** ISO timestamp when the profile was first created. */
309
+ readonly created_at: Schema.String;
310
+ /** ISO timestamp when the profile was last updated. */
311
+ readonly updated_at: Schema.String;
312
+ }, "Type"> | null, import("effect/PlatformError").PlatformError | HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
313
+ /**
314
+ * Remove the active profile.
315
+ *
316
+ * @category Profile Storage
317
+ */
318
+ export declare const deleteActiveProfile: (toolName: string) => Effect.Effect<Schema.Struct.ReadonlySide<{
319
+ /** Stable identifier derived from account and cloud IDs. */
320
+ readonly id: Schema.String;
321
+ /** Human-readable profile label. */
322
+ readonly name: Schema.String;
323
+ /** OAuth token and selected site metadata. */
324
+ readonly token: Schema.Struct<{
325
+ readonly access_token: Schema.String;
326
+ readonly refresh_token: Schema.String;
327
+ readonly expires_at: Schema.Number;
328
+ readonly scope: Schema.String;
329
+ readonly cloud_id: Schema.String;
330
+ readonly site_url: Schema.String;
331
+ readonly user: Schema.optional<Schema.Struct<{
332
+ readonly account_id: Schema.String;
333
+ readonly name: Schema.String;
334
+ readonly email: Schema.String;
335
+ }>>;
336
+ }>;
337
+ /** ISO timestamp when the profile was first created. */
338
+ readonly created_at: Schema.String;
339
+ /** ISO timestamp when the profile was last updated. */
340
+ readonly updated_at: Schema.String;
341
+ }, "Type"> | null, import("effect/PlatformError").PlatformError | HomeDirectoryError | FileSystemError, HomeDirectoryTag | Path.Path | FileSystem.FileSystem>;
342
+ //# sourceMappingURL=AuthProfiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProfiles.d.ts","sourceRoot":"","sources":["../../src/config/AuthProfiles.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,KAAK,IAAI,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EAEtB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,mBAAmB,CAAA;AACrE,OAAO,EAAe,eAAe,EAAwB,MAAM,mBAAmB,CAAA;AAEtF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B,4DAA4D;;IAE5D,oCAAoC;;IAEpC,8CAA8C;;;;;;;;;;;;;;IAE9C,wDAAwD;;IAExD,uDAAuD;;EAEvD,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEtE;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