@knpkv/atlassian-common 0.2.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +25 -10
  3. package/dist/Brand.d.ts +15 -15
  4. package/dist/Brand.d.ts.map +1 -1
  5. package/dist/Brand.js +5 -5
  6. package/dist/Brand.js.map +1 -1
  7. package/dist/Hash.d.ts +12 -14
  8. package/dist/Hash.d.ts.map +1 -1
  9. package/dist/Hash.js +18 -24
  10. package/dist/Hash.js.map +1 -1
  11. package/dist/ast/BlockNode.d.ts +120 -177
  12. package/dist/ast/BlockNode.d.ts.map +1 -1
  13. package/dist/ast/BlockNode.js +28 -8
  14. package/dist/ast/BlockNode.js.map +1 -1
  15. package/dist/ast/Document.d.ts +114 -156
  16. package/dist/ast/Document.d.ts.map +1 -1
  17. package/dist/ast/Document.js +1 -1
  18. package/dist/ast/Document.js.map +1 -1
  19. package/dist/ast/InlineNode.d.ts +59 -247
  20. package/dist/ast/InlineNode.d.ts.map +1 -1
  21. package/dist/ast/InlineNode.js +28 -3
  22. package/dist/ast/InlineNode.js.map +1 -1
  23. package/dist/ast/MacroNode.d.ts +62 -102
  24. package/dist/ast/MacroNode.d.ts.map +1 -1
  25. package/dist/ast/MacroNode.js +12 -5
  26. package/dist/ast/MacroNode.js.map +1 -1
  27. package/dist/auth/OAuthOperations.d.ts +1 -1
  28. package/dist/auth/OAuthOperations.d.ts.map +1 -1
  29. package/dist/auth/OAuthOperations.js +5 -6
  30. package/dist/auth/OAuthOperations.js.map +1 -1
  31. package/dist/auth/OAuthResponseSchemas.d.ts +13 -13
  32. package/dist/bin.d.ts +3 -0
  33. package/dist/bin.d.ts.map +1 -0
  34. package/dist/bin.js +58 -0
  35. package/dist/bin.js.map +1 -0
  36. package/dist/config/AuthProfiles.d.ts +342 -0
  37. package/dist/config/AuthProfiles.d.ts.map +1 -0
  38. package/dist/config/AuthProfiles.js +275 -0
  39. package/dist/config/AuthProfiles.js.map +1 -0
  40. package/dist/config/ConfigPaths.d.ts +12 -26
  41. package/dist/config/ConfigPaths.d.ts.map +1 -1
  42. package/dist/config/ConfigPaths.js +33 -3
  43. package/dist/config/ConfigPaths.js.map +1 -1
  44. package/dist/config/OAuthSchemas.d.ts +24 -24
  45. package/dist/config/ProfileManager.d.ts +92 -0
  46. package/dist/config/ProfileManager.d.ts.map +1 -0
  47. package/dist/config/ProfileManager.js +175 -0
  48. package/dist/config/ProfileManager.js.map +1 -0
  49. package/dist/config/TokenStorage.d.ts +5 -24
  50. package/dist/config/TokenStorage.d.ts.map +1 -1
  51. package/dist/config/TokenStorage.js +35 -22
  52. package/dist/config/TokenStorage.js.map +1 -1
  53. package/dist/config/index.d.ts +3 -1
  54. package/dist/config/index.d.ts.map +1 -1
  55. package/dist/config/index.js +5 -1
  56. package/dist/config/index.js.map +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/package.json +17 -11
  62. package/src/Brand.ts +5 -17
  63. package/src/Hash.ts +27 -27
  64. package/src/ast/BlockNode.ts +13 -13
  65. package/src/ast/Document.ts +1 -1
  66. package/src/ast/InlineNode.ts +5 -5
  67. package/src/ast/MacroNode.ts +7 -6
  68. package/src/auth/OAuthOperations.ts +5 -6
  69. package/src/bin.ts +115 -0
  70. package/src/config/AuthProfiles.ts +384 -0
  71. package/src/config/ConfigPaths.ts +21 -7
  72. package/src/config/ProfileManager.ts +268 -0
  73. package/src/config/TokenStorage.ts +23 -27
  74. package/src/config/index.ts +42 -0
  75. package/src/index.ts +1 -1
  76. package/test/AuthProfiles.test.ts +131 -0
  77. package/test/Hash.test.ts +52 -0
  78. package/test/OAuthOperations.test.ts +2 -3
  79. package/test/ProfileManager.test.ts +188 -0
  80. package/tsconfig.tsbuildinfo +1 -1
@@ -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;;;;GAI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+1,275 @@
1
+ /**
2
+ * Multi-account/site auth profile storage for Atlassian CLIs.
3
+ *
4
+ * **Mental model**
5
+ *
6
+ * - `profiles.json` is the source of truth for multiple logged-in accounts/sites.
7
+ * - The active profile is mirrored to the legacy `auth.json` token file so older
8
+ * single-profile consumers keep working.
9
+ * - Existing single-token installs are treated as a one-profile store on read.
10
+ *
11
+ * @module
12
+ */
13
+ import * as Clock from "effect/Clock";
14
+ import * as Effect from "effect/Effect";
15
+ import * as FileSystem from "effect/FileSystem";
16
+ import * as Schema from "effect/Schema";
17
+ import { ensureConfigDir, getProfilesPath, writeSecureFile } from "./ConfigPaths.js";
18
+ import { OAuthTokenSchema } from "./OAuthSchemas.js";
19
+ import { deleteToken, FileSystemError, loadToken, saveToken } from "./TokenStorage.js";
20
+ /**
21
+ * A persisted Atlassian auth profile.
22
+ *
23
+ * @category Schema
24
+ */
25
+ export const AuthProfileSchema = Schema.Struct({
26
+ /** Stable identifier derived from account and cloud IDs. */
27
+ id: Schema.String,
28
+ /** Human-readable profile label. */
29
+ name: Schema.String,
30
+ /** OAuth token and selected site metadata. */
31
+ token: OAuthTokenSchema,
32
+ /** ISO timestamp when the profile was first created. */
33
+ created_at: Schema.String,
34
+ /** ISO timestamp when the profile was last updated. */
35
+ updated_at: Schema.String
36
+ });
37
+ /**
38
+ * Schema for the profile registry file.
39
+ *
40
+ * @category Schema
41
+ */
42
+ export const AuthProfilesFileSchema = Schema.Struct({
43
+ /** Active profile ID. Omitted when no profile is active. */
44
+ activeProfileId: Schema.optional(Schema.String),
45
+ /** Known auth profiles for this CLI. */
46
+ profiles: Schema.Array(AuthProfileSchema)
47
+ });
48
+ const emptyProfiles = () => ({ profiles: [] });
49
+ const parseJsonOrNull = (content) => {
50
+ try {
51
+ return JSON.parse(content);
52
+ }
53
+ catch {
54
+ return null;
55
+ }
56
+ };
57
+ const hostFromUrl = (url) => {
58
+ try {
59
+ return new URL(url).host;
60
+ }
61
+ catch {
62
+ return url;
63
+ }
64
+ };
65
+ const normalizeProfileIdPart = (value) => value.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
66
+ /**
67
+ * Build a stable profile ID from token site and user identity.
68
+ *
69
+ * @category Utilities
70
+ */
71
+ export const profileIdFromToken = (token) => {
72
+ const account = token.user?.account_id ? normalizeProfileIdPart(token.user.account_id) : "unknown-account";
73
+ const site = normalizeProfileIdPart(token.cloud_id || hostFromUrl(token.site_url));
74
+ return `${account}@${site}`;
75
+ };
76
+ /**
77
+ * Build a readable profile label from token site and user identity.
78
+ *
79
+ * @category Utilities
80
+ */
81
+ export const profileNameFromToken = (token) => {
82
+ const site = hostFromUrl(token.site_url);
83
+ if (!token.user)
84
+ return site;
85
+ const email = token.user.email.length > 0 ? ` (${token.user.email})` : "";
86
+ return `${token.user.name}${email} @ ${site}`;
87
+ };
88
+ /**
89
+ * Create a profile record from an OAuth token.
90
+ *
91
+ * @category Utilities
92
+ */
93
+ export const profileFromToken = (token, now) => {
94
+ const timestamp = now.toISOString();
95
+ return {
96
+ id: profileIdFromToken(token),
97
+ name: profileNameFromToken(token),
98
+ token,
99
+ created_at: timestamp,
100
+ updated_at: timestamp
101
+ };
102
+ };
103
+ const activeProfileFromStore = (store) => {
104
+ if (store.profiles.length === 0)
105
+ return null;
106
+ if (!store.activeProfileId)
107
+ return store.profiles[0] ?? null;
108
+ return store.profiles.find((profile) => profile.id === store.activeProfileId) ?? store.profiles[0] ?? null;
109
+ };
110
+ const storeFromLegacyToken = (token, now) => token === null
111
+ ? emptyProfiles()
112
+ : {
113
+ activeProfileId: profileIdFromToken(token),
114
+ profiles: [profileFromToken(token, now)]
115
+ };
116
+ const readProfilesFile = (toolName) => Effect.gen(function* () {
117
+ const fs = yield* FileSystem.FileSystem;
118
+ const profilesPath = yield* getProfilesPath(toolName);
119
+ const exists = yield* fs.exists(profilesPath).pipe(Effect.catch(() => Effect.succeed(false)));
120
+ if (!exists)
121
+ return null;
122
+ const content = yield* fs.readFileString(profilesPath).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "read", path: profilesPath, cause })));
123
+ const parsed = parseJsonOrNull(content);
124
+ if (parsed === null) {
125
+ yield* Effect.logWarning(`Corrupted profiles.json at ${profilesPath} - could not parse JSON`);
126
+ return null;
127
+ }
128
+ return yield* Schema.decodeUnknownEffect(AuthProfilesFileSchema)(parsed).pipe(Effect.catch((e) => Effect.logWarning(`Invalid profile schema in ${profilesPath}: ${e}`).pipe(Effect.map(() => null))));
129
+ });
130
+ /**
131
+ * Load all auth profiles for a tool.
132
+ *
133
+ * Falls back to the legacy single-token file when `profiles.json` does not exist.
134
+ *
135
+ * @category Profile Storage
136
+ */
137
+ export const loadProfiles = (toolName) => Effect.gen(function* () {
138
+ const profiles = yield* readProfilesFile(toolName);
139
+ if (profiles !== null)
140
+ return profiles;
141
+ const legacyToken = yield* loadToken(toolName);
142
+ const nowMs = yield* Clock.currentTimeMillis;
143
+ return storeFromLegacyToken(legacyToken, new Date(nowMs));
144
+ });
145
+ /**
146
+ * Save auth profiles and mirror the active profile to `auth.json`.
147
+ *
148
+ * @category Profile Storage
149
+ */
150
+ export const saveProfiles = (toolName, store) => Effect.gen(function* () {
151
+ const fs = yield* FileSystem.FileSystem;
152
+ yield* ensureConfigDir(toolName);
153
+ const profilesPath = yield* getProfilesPath(toolName);
154
+ const active = activeProfileFromStore(store);
155
+ const normalized = {
156
+ activeProfileId: active?.id,
157
+ profiles: store.profiles
158
+ };
159
+ yield* writeSecureFile(profilesPath, JSON.stringify(normalized, null, 2)).pipe(Effect.provideService(FileSystem.FileSystem, fs));
160
+ if (active) {
161
+ yield* saveToken(toolName, active.token);
162
+ }
163
+ else {
164
+ yield* deleteToken(toolName);
165
+ }
166
+ });
167
+ /**
168
+ * Insert or update a profile from a token and make it active.
169
+ *
170
+ * @category Profile Storage
171
+ */
172
+ export const saveProfileToken = (toolName, token) => Effect.gen(function* () {
173
+ const store = yield* loadProfiles(toolName);
174
+ const nowMs = yield* Clock.currentTimeMillis;
175
+ const next = profileFromToken(token, new Date(nowMs));
176
+ const existing = store.profiles.find((profile) => profile.id === next.id);
177
+ const profile = existing
178
+ ? { ...next, created_at: existing.created_at }
179
+ : next;
180
+ const profiles = [
181
+ profile,
182
+ ...store.profiles.filter((stored) => stored.id !== profile.id)
183
+ ];
184
+ yield* saveProfiles(toolName, { activeProfileId: profile.id, profiles });
185
+ return profile;
186
+ });
187
+ /**
188
+ * Load the active auth profile.
189
+ *
190
+ * @category Profile Storage
191
+ */
192
+ export const loadActiveProfile = (toolName) => loadProfiles(toolName).pipe(Effect.map(activeProfileFromStore));
193
+ /**
194
+ * Load the active OAuth token.
195
+ *
196
+ * @category Profile Storage
197
+ */
198
+ export const loadActiveProfileToken = (toolName) => loadActiveProfile(toolName).pipe(Effect.map((profile) => profile?.token ?? null));
199
+ /**
200
+ * Set the active profile by ID.
201
+ *
202
+ * @category Profile Storage
203
+ */
204
+ export const setActiveProfile = (toolName, profileId) => Effect.gen(function* () {
205
+ const store = yield* loadProfiles(toolName);
206
+ const profile = store.profiles.find((stored) => stored.id === profileId);
207
+ if (!profile)
208
+ return null;
209
+ yield* saveProfiles(toolName, { ...store, activeProfileId: profile.id });
210
+ return profile;
211
+ });
212
+ /**
213
+ * Resolve a profile by ID, name, site URL, cloud ID, or account ID.
214
+ *
215
+ * @category Utilities
216
+ */
217
+ export const findProfile = (profiles, selector) => profiles.find((profile) => profile.id === selector ||
218
+ profile.name === selector ||
219
+ profile.token.site_url === selector ||
220
+ profile.token.cloud_id === selector ||
221
+ profile.token.user?.account_id === selector) ?? null;
222
+ /**
223
+ * Set the active profile using a flexible selector.
224
+ *
225
+ * @category Profile Storage
226
+ */
227
+ export const setActiveProfileBySelector = (toolName, selector) => Effect.gen(function* () {
228
+ const store = yield* loadProfiles(toolName);
229
+ const profile = findProfile(store.profiles, selector);
230
+ if (!profile)
231
+ return null;
232
+ yield* saveProfiles(toolName, { ...store, activeProfileId: profile.id });
233
+ return profile;
234
+ });
235
+ /**
236
+ * Remove a profile by ID.
237
+ *
238
+ * @category Profile Storage
239
+ */
240
+ export const deleteProfile = (toolName, profileId) => Effect.gen(function* () {
241
+ const store = yield* loadProfiles(toolName);
242
+ const profile = store.profiles.find((stored) => stored.id === profileId);
243
+ if (!profile)
244
+ return null;
245
+ const profiles = store.profiles.filter((stored) => stored.id !== profile.id);
246
+ const activeProfileId = store.activeProfileId === profile.id ? profiles[0]?.id : store.activeProfileId;
247
+ yield* saveProfiles(toolName, { activeProfileId, profiles });
248
+ return profile;
249
+ });
250
+ /**
251
+ * Remove a profile using a flexible selector.
252
+ *
253
+ * @category Profile Storage
254
+ */
255
+ export const deleteProfileBySelector = (toolName, selector) => Effect.gen(function* () {
256
+ const store = yield* loadProfiles(toolName);
257
+ const profile = findProfile(store.profiles, selector);
258
+ if (!profile)
259
+ return null;
260
+ return yield* deleteProfile(toolName, profile.id);
261
+ });
262
+ /**
263
+ * Remove the active profile.
264
+ *
265
+ * @category Profile Storage
266
+ */
267
+ export const deleteActiveProfile = (toolName) => Effect.gen(function* () {
268
+ const active = yield* loadActiveProfile(toolName);
269
+ if (!active) {
270
+ yield* deleteToken(toolName);
271
+ return null;
272
+ }
273
+ return yield* deleteProfile(toolName, active.id);
274
+ });
275
+ //# sourceMappingURL=AuthProfiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthProfiles.js","sourceRoot":"","sources":["../../src/config/AuthProfiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAA;AAE/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EACL,eAAe,EACf,eAAe,EAGf,eAAe,EAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAmB,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,EA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