@knpkv/atlassian-common 0.2.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 +11 -0
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/dist/Brand.d.ts +118 -0
- package/dist/Brand.d.ts.map +1 -0
- package/dist/Brand.js +107 -0
- package/dist/Brand.js.map +1 -0
- package/dist/Hash.d.ts +53 -0
- package/dist/Hash.d.ts.map +1 -0
- package/dist/Hash.js +63 -0
- package/dist/Hash.js.map +1 -0
- package/dist/SerializeError.d.ts +48 -0
- package/dist/SerializeError.d.ts.map +1 -0
- package/dist/SerializeError.js +42 -0
- package/dist/SerializeError.js.map +1 -0
- package/dist/ast/BlockNode.d.ts +429 -0
- package/dist/ast/BlockNode.d.ts.map +1 -0
- package/dist/ast/BlockNode.js +279 -0
- package/dist/ast/BlockNode.js.map +1 -0
- package/dist/ast/Document.d.ts +255 -0
- package/dist/ast/Document.d.ts.map +1 -0
- package/dist/ast/Document.js +80 -0
- package/dist/ast/Document.js.map +1 -0
- package/dist/ast/InlineNode.d.ts +483 -0
- package/dist/ast/InlineNode.d.ts.map +1 -0
- package/dist/ast/InlineNode.js +268 -0
- package/dist/ast/InlineNode.js.map +1 -0
- package/dist/ast/MacroNode.d.ts +214 -0
- package/dist/ast/MacroNode.d.ts.map +1 -0
- package/dist/ast/MacroNode.js +110 -0
- package/dist/ast/MacroNode.js.map +1 -0
- package/dist/ast/index.d.ts +10 -0
- package/dist/ast/index.d.ts.map +1 -0
- package/dist/ast/index.js +14 -0
- package/dist/ast/index.js.map +1 -0
- package/dist/auth/OAuthEndpoints.d.ts +95 -0
- package/dist/auth/OAuthEndpoints.d.ts.map +1 -0
- package/dist/auth/OAuthEndpoints.js +112 -0
- package/dist/auth/OAuthEndpoints.js.map +1 -0
- package/dist/auth/OAuthErrors.d.ts +76 -0
- package/dist/auth/OAuthErrors.d.ts.map +1 -0
- package/dist/auth/OAuthErrors.js +85 -0
- package/dist/auth/OAuthErrors.js.map +1 -0
- package/dist/auth/OAuthOperations.d.ts +87 -0
- package/dist/auth/OAuthOperations.d.ts.map +1 -0
- package/dist/auth/OAuthOperations.js +169 -0
- package/dist/auth/OAuthOperations.js.map +1 -0
- package/dist/auth/OAuthResponseSchemas.d.ts +65 -0
- package/dist/auth/OAuthResponseSchemas.d.ts.map +1 -0
- package/dist/auth/OAuthResponseSchemas.js +47 -0
- package/dist/auth/OAuthResponseSchemas.js.map +1 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +16 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/uuid.d.ts +14 -0
- package/dist/auth/uuid.d.ts.map +1 -0
- package/dist/auth/uuid.js +14 -0
- package/dist/auth/uuid.js.map +1 -0
- package/dist/config/ConfigPaths.d.ts +95 -0
- package/dist/config/ConfigPaths.d.ts.map +1 -0
- package/dist/config/ConfigPaths.js +102 -0
- package/dist/config/ConfigPaths.js.map +1 -0
- package/dist/config/OAuthSchemas.d.ts +144 -0
- package/dist/config/OAuthSchemas.d.ts.map +1 -0
- package/dist/config/OAuthSchemas.js +107 -0
- package/dist/config/OAuthSchemas.js.map +1 -0
- package/dist/config/TokenStorage.d.ts +96 -0
- package/dist/config/TokenStorage.d.ts.map +1 -0
- package/dist/config/TokenStorage.js +128 -0
- package/dist/config/TokenStorage.js.map +1 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +12 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/index.d.ts +7 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +8 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/serializers/MarkdownSerializer.d.ts +63 -0
- package/dist/serializers/MarkdownSerializer.d.ts.map +1 -0
- package/dist/serializers/MarkdownSerializer.js +367 -0
- package/dist/serializers/MarkdownSerializer.js.map +1 -0
- package/dist/serializers/index.d.ts +7 -0
- package/dist/serializers/index.d.ts.map +1 -0
- package/dist/serializers/index.js +7 -0
- package/dist/serializers/index.js.map +1 -0
- package/package.json +86 -0
- package/src/Brand.ts +142 -0
- package/src/Hash.ts +68 -0
- package/src/SerializeError.ts +50 -0
- package/src/ast/BlockNode.ts +386 -0
- package/src/ast/Document.ts +101 -0
- package/src/ast/InlineNode.ts +328 -0
- package/src/ast/MacroNode.ts +172 -0
- package/src/ast/index.ts +87 -0
- package/src/auth/OAuthEndpoints.ts +142 -0
- package/src/auth/OAuthErrors.ts +101 -0
- package/src/auth/OAuthOperations.ts +276 -0
- package/src/auth/OAuthResponseSchemas.ts +70 -0
- package/src/auth/index.ts +47 -0
- package/src/auth/uuid.ts +14 -0
- package/src/config/ConfigPaths.ts +179 -0
- package/src/config/OAuthSchemas.ts +146 -0
- package/src/config/TokenStorage.ts +228 -0
- package/src/config/index.ts +43 -0
- package/src/index.ts +34 -0
- package/src/parsers/index.ts +8 -0
- package/src/serializers/MarkdownSerializer.ts +498 -0
- package/src/serializers/index.ts +7 -0
- package/test/Brand.test.ts +90 -0
- package/test/MarkdownSerializer.test.ts +82 -0
- package/test/OAuthEndpoints.test.ts +109 -0
- package/test/OAuthOperations.test.ts +315 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect Schema definitions for Atlassian OAuth2 API response payloads.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **Schema = source of truth**: {@link TokenResponseSchema}, {@link AccessibleResourceSchema},
|
|
7
|
+
* and {@link UserInfoSchema} define the wire format. Companion `type` aliases are derived
|
|
8
|
+
* via `Schema.Schema.Type` — never hand-written.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
/**
|
|
14
|
+
* Schema for OAuth2 token response from Atlassian.
|
|
15
|
+
*
|
|
16
|
+
* @category Schema
|
|
17
|
+
*/
|
|
18
|
+
export declare const TokenResponseSchema: Schema.Struct<{
|
|
19
|
+
access_token: typeof Schema.String;
|
|
20
|
+
refresh_token: typeof Schema.String;
|
|
21
|
+
expires_in: typeof Schema.Number;
|
|
22
|
+
scope: typeof Schema.String;
|
|
23
|
+
token_type: typeof Schema.String;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Type for OAuth2 token response.
|
|
27
|
+
*
|
|
28
|
+
* @category Types
|
|
29
|
+
*/
|
|
30
|
+
export type TokenResponse = Schema.Schema.Type<typeof TokenResponseSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Schema for accessible resource (site) from Atlassian.
|
|
33
|
+
*
|
|
34
|
+
* @category Schema
|
|
35
|
+
*/
|
|
36
|
+
export declare const AccessibleResourceSchema: Schema.Struct<{
|
|
37
|
+
id: typeof Schema.String;
|
|
38
|
+
name: typeof Schema.String;
|
|
39
|
+
url: typeof Schema.String;
|
|
40
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
41
|
+
avatarUrl: Schema.optional<typeof Schema.String>;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Type for accessible resource.
|
|
45
|
+
*
|
|
46
|
+
* @category Types
|
|
47
|
+
*/
|
|
48
|
+
export type AccessibleResource = Schema.Schema.Type<typeof AccessibleResourceSchema>;
|
|
49
|
+
/**
|
|
50
|
+
* Schema for user info from /me endpoint.
|
|
51
|
+
*
|
|
52
|
+
* @category Schema
|
|
53
|
+
*/
|
|
54
|
+
export declare const UserInfoSchema: Schema.Struct<{
|
|
55
|
+
account_id: typeof Schema.String;
|
|
56
|
+
name: typeof Schema.String;
|
|
57
|
+
email: typeof Schema.String;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Type for user info.
|
|
61
|
+
*
|
|
62
|
+
* @category Types
|
|
63
|
+
*/
|
|
64
|
+
export type UserInfo = Schema.Schema.Type<typeof UserInfoSchema>;
|
|
65
|
+
//# sourceMappingURL=OAuthResponseSchemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthResponseSchemas.d.ts","sourceRoot":"","sources":["../../src/auth/OAuthResponseSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;;;;;;EAM9B,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;;;;EAMnC,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEpF;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;EAIzB,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,cAAc,CAAC,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect Schema definitions for Atlassian OAuth2 API response payloads.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **Schema = source of truth**: {@link TokenResponseSchema}, {@link AccessibleResourceSchema},
|
|
7
|
+
* and {@link UserInfoSchema} define the wire format. Companion `type` aliases are derived
|
|
8
|
+
* via `Schema.Schema.Type` — never hand-written.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import * as Schema from "effect/Schema";
|
|
13
|
+
/**
|
|
14
|
+
* Schema for OAuth2 token response from Atlassian.
|
|
15
|
+
*
|
|
16
|
+
* @category Schema
|
|
17
|
+
*/
|
|
18
|
+
export const TokenResponseSchema = Schema.Struct({
|
|
19
|
+
access_token: Schema.String,
|
|
20
|
+
refresh_token: Schema.String,
|
|
21
|
+
expires_in: Schema.Number,
|
|
22
|
+
scope: Schema.String,
|
|
23
|
+
token_type: Schema.String
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Schema for accessible resource (site) from Atlassian.
|
|
27
|
+
*
|
|
28
|
+
* @category Schema
|
|
29
|
+
*/
|
|
30
|
+
export const AccessibleResourceSchema = Schema.Struct({
|
|
31
|
+
id: Schema.String,
|
|
32
|
+
name: Schema.String,
|
|
33
|
+
url: Schema.String,
|
|
34
|
+
scopes: Schema.Array(Schema.String),
|
|
35
|
+
avatarUrl: Schema.optional(Schema.String)
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Schema for user info from /me endpoint.
|
|
39
|
+
*
|
|
40
|
+
* @category Schema
|
|
41
|
+
*/
|
|
42
|
+
export const UserInfoSchema = Schema.Struct({
|
|
43
|
+
account_id: Schema.String,
|
|
44
|
+
name: Schema.String,
|
|
45
|
+
email: Schema.String
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=OAuthResponseSchemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthResponseSchemas.js","sourceRoot":"","sources":["../../src/auth/OAuthResponseSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/C,YAAY,EAAE,MAAM,CAAC,MAAM;IAC3B,aAAa,EAAE,MAAM,CAAC,MAAM;IAC5B,UAAU,EAAE,MAAM,CAAC,MAAM;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM;CAC1B,CAAC,CAAA;AASF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,CAAC;IACpD,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,GAAG,EAAE,MAAM,CAAC,MAAM;IAClB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CAC1C,CAAC,CAAA;AASF;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,UAAU,EAAE,MAAM,CAAC,MAAM;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel export for Atlassian OAuth2 auth utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
export { AUTH_URL, buildAuthUrl, type BuildAuthUrlOptions, computeCodeChallenge, CONFLUENCE_SCOPES, generateCodeVerifier, JIRA_SCOPES, ME_URL, RESOURCES_URL, REVOKE_URL, TOKEN_URL } from "./OAuthEndpoints.js";
|
|
7
|
+
export { AuthMissingError, OAuthError, OAuthNotConfiguredError, type OAuthStep } from "./OAuthErrors.js";
|
|
8
|
+
export { buildOAuthToken, exchangeCodeForTokens, type ExchangeCodeOptions, getAccessibleResources, getUserInfo, refreshToken, revokeToken } from "./OAuthOperations.js";
|
|
9
|
+
export { type AccessibleResource, AccessibleResourceSchema, type TokenResponse, TokenResponseSchema, type UserInfo, UserInfoSchema } from "./OAuthResponseSchemas.js";
|
|
10
|
+
export { generateUUID } from "./uuid.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,KAAK,mBAAmB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,MAAM,EACN,aAAa,EACb,UAAU,EACV,SAAS,EACV,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,uBAAuB,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGxG,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,KAAK,mBAAmB,EACxB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,WAAW,EACZ,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACL,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,KAAK,aAAa,EAClB,mBAAmB,EACnB,KAAK,QAAQ,EACb,cAAc,EACf,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel export for Atlassian OAuth2 auth utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
// Endpoints and scopes
|
|
7
|
+
export { AUTH_URL, buildAuthUrl, computeCodeChallenge, CONFLUENCE_SCOPES, generateCodeVerifier, JIRA_SCOPES, ME_URL, RESOURCES_URL, REVOKE_URL, TOKEN_URL } from "./OAuthEndpoints.js";
|
|
8
|
+
// Errors
|
|
9
|
+
export { AuthMissingError, OAuthError, OAuthNotConfiguredError } from "./OAuthErrors.js";
|
|
10
|
+
// Operations
|
|
11
|
+
export { buildOAuthToken, exchangeCodeForTokens, getAccessibleResources, getUserInfo, refreshToken, revokeToken } from "./OAuthOperations.js";
|
|
12
|
+
// Response schemas
|
|
13
|
+
export { AccessibleResourceSchema, TokenResponseSchema, UserInfoSchema } from "./OAuthResponseSchemas.js";
|
|
14
|
+
// Utilities
|
|
15
|
+
export { generateUUID } from "./uuid.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uBAAuB;AACvB,OAAO,EACL,QAAQ,EACR,YAAY,EAEZ,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,MAAM,EACN,aAAa,EACb,UAAU,EACV,SAAS,EACV,MAAM,qBAAqB,CAAA;AAE5B,SAAS;AACT,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,uBAAuB,EAAkB,MAAM,kBAAkB,CAAA;AAExG,aAAa;AACb,OAAO,EACL,eAAe,EACf,qBAAqB,EAErB,sBAAsB,EACtB,WAAW,EACX,YAAY,EACZ,WAAW,EACZ,MAAM,sBAAsB,CAAA;AAE7B,mBAAmB;AACnB,OAAO,EAEL,wBAAwB,EAExB,mBAAmB,EAEnB,cAAc,EACf,MAAM,2BAA2B,CAAA;AAElC,YAAY;AACZ,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic UUID v4 generation via Web Crypto API.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
/**
|
|
8
|
+
* Generate a cryptographically secure UUID v4.
|
|
9
|
+
* Uses Web Crypto API randomUUID (Node.js 19+, all modern browsers).
|
|
10
|
+
*
|
|
11
|
+
* @category Utilities
|
|
12
|
+
*/
|
|
13
|
+
export declare const generateUUID: () => Effect.Effect<string>;
|
|
14
|
+
//# sourceMappingURL=uuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/auth/uuid.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAsD,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic UUID v4 generation via Web Crypto API.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
/**
|
|
8
|
+
* Generate a cryptographically secure UUID v4.
|
|
9
|
+
* Uses Web Crypto API randomUUID (Node.js 19+, all modern browsers).
|
|
10
|
+
*
|
|
11
|
+
* @category Utilities
|
|
12
|
+
*/
|
|
13
|
+
export const generateUUID = () => Effect.sync(() => globalThis.crypto.randomUUID());
|
|
14
|
+
//# sourceMappingURL=uuid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../src/auth/uuid.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAA0B,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XDG-compliant config path resolution and secure file I/O for Atlassian tools.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **Injectable home directory**: {@link HomeDirectoryTag} is an Effect service so tests
|
|
7
|
+
* can substitute a temp dir without touching env vars. {@link HomeDirectoryLive} reads
|
|
8
|
+
* `HOME` / `USERPROFILE` via Effect `Config`.
|
|
9
|
+
* - **XDG hierarchy**: `~/.config/atlassian/<toolName>/` — respects `XDG_CONFIG_HOME` override.
|
|
10
|
+
* - **Secure by default**: {@link ensureConfigDir} creates dirs at `0o700`;
|
|
11
|
+
* {@link writeSecureFile} writes at `0o600`.
|
|
12
|
+
*
|
|
13
|
+
* **Common tasks**
|
|
14
|
+
*
|
|
15
|
+
* - Resolve config dir: {@link getConfigDir}
|
|
16
|
+
* - Get auth file path: {@link getAuthPath}
|
|
17
|
+
* - Write credential files: {@link writeSecureFile}
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import type * as Error from "@effect/platform/Error";
|
|
22
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
23
|
+
import * as Path from "@effect/platform/Path";
|
|
24
|
+
import * as Context from "effect/Context";
|
|
25
|
+
import * as Effect from "effect/Effect";
|
|
26
|
+
import * as Layer from "effect/Layer";
|
|
27
|
+
declare const HomeDirectoryError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
28
|
+
readonly _tag: "HomeDirectoryError";
|
|
29
|
+
} & Readonly<A>;
|
|
30
|
+
/**
|
|
31
|
+
* Error when home directory cannot be determined.
|
|
32
|
+
*
|
|
33
|
+
* @category Errors
|
|
34
|
+
*/
|
|
35
|
+
export declare class HomeDirectoryError extends HomeDirectoryError_base<{
|
|
36
|
+
readonly cause?: unknown;
|
|
37
|
+
}> {
|
|
38
|
+
get message(): string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Service for getting the home directory.
|
|
42
|
+
* Allows mocking in tests.
|
|
43
|
+
*
|
|
44
|
+
* @category Services
|
|
45
|
+
*/
|
|
46
|
+
export interface HomeDirectory {
|
|
47
|
+
readonly get: () => Effect.Effect<string, HomeDirectoryError>;
|
|
48
|
+
}
|
|
49
|
+
declare const HomeDirectoryTag_base: Context.TagClass<HomeDirectoryTag, "@knpkv/atlassian-common/HomeDirectory", HomeDirectory>;
|
|
50
|
+
/**
|
|
51
|
+
* Tag for the HomeDirectory service.
|
|
52
|
+
*
|
|
53
|
+
* @category Services
|
|
54
|
+
*/
|
|
55
|
+
export declare class HomeDirectoryTag extends HomeDirectoryTag_base {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Default implementation using HOME/USERPROFILE env vars.
|
|
59
|
+
*
|
|
60
|
+
* @category Layers
|
|
61
|
+
*/
|
|
62
|
+
export declare const HomeDirectoryLive: Layer.Layer<HomeDirectoryTag>;
|
|
63
|
+
/**
|
|
64
|
+
* XDG config directory for Atlassian tools.
|
|
65
|
+
* Returns ~/.config/atlassian by default.
|
|
66
|
+
*
|
|
67
|
+
* @category Utilities
|
|
68
|
+
*/
|
|
69
|
+
export declare const getConfigDir: (toolName?: string) => Effect.Effect<string, HomeDirectoryError, HomeDirectoryTag | Path.Path>;
|
|
70
|
+
/**
|
|
71
|
+
* Get auth file path for a specific tool.
|
|
72
|
+
*
|
|
73
|
+
* @category Utilities
|
|
74
|
+
*/
|
|
75
|
+
export declare const getAuthPath: (toolName: string) => Effect.Effect<string, HomeDirectoryError, HomeDirectoryTag | Path.Path>;
|
|
76
|
+
/**
|
|
77
|
+
* Get OAuth config file path for a specific tool.
|
|
78
|
+
*
|
|
79
|
+
* @category Utilities
|
|
80
|
+
*/
|
|
81
|
+
export declare const getOAuthConfigPath: (toolName: string) => Effect.Effect<string, HomeDirectoryError, HomeDirectoryTag | Path.Path>;
|
|
82
|
+
/**
|
|
83
|
+
* Ensure config directory exists with secure permissions.
|
|
84
|
+
*
|
|
85
|
+
* @category Utilities
|
|
86
|
+
*/
|
|
87
|
+
export declare const ensureConfigDir: (toolName: string) => Effect.Effect<string, HomeDirectoryError | Error.PlatformError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
|
|
88
|
+
/**
|
|
89
|
+
* Write file with secure permissions (600).
|
|
90
|
+
*
|
|
91
|
+
* @category Utilities
|
|
92
|
+
*/
|
|
93
|
+
export declare const writeSecureFile: (filePath: string, content: string) => Effect.Effect<void, Error.PlatformError, FileSystem.FileSystem>;
|
|
94
|
+
export {};
|
|
95
|
+
//# sourceMappingURL=ConfigPaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigPaths.d.ts","sourceRoot":"","sources":["../../src/config/ConfigPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,KAAK,KAAK,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAE7C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;;;;AAGrC;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC7E,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;CAC9D;;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,qBAGnC;CAAG;AAMN;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAY3D,CAAA;AAID;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,WAAW,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAYrE,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,MAAM,KACf,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAKrE,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,KACf,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAKrE,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,KACf,MAAM,CAAC,MAAM,CACd,MAAM,EACN,kBAAkB,GAAG,KAAK,CAAC,aAAa,EACxC,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAYlD,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,SAAS,MAAM,KACd,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,UAAU,CAQ7D,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
2
|
+
import * as Path from "@effect/platform/Path";
|
|
3
|
+
import * as Config from "effect/Config";
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import * as Data from "effect/Data";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
/**
|
|
10
|
+
* Error when home directory cannot be determined.
|
|
11
|
+
*
|
|
12
|
+
* @category Errors
|
|
13
|
+
*/
|
|
14
|
+
export class HomeDirectoryError extends Data.TaggedError("HomeDirectoryError") {
|
|
15
|
+
get message() {
|
|
16
|
+
return "Cannot determine home directory: HOME/USERPROFILE not set";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tag for the HomeDirectory service.
|
|
21
|
+
*
|
|
22
|
+
* @category Services
|
|
23
|
+
*/
|
|
24
|
+
export class HomeDirectoryTag extends Context.Tag("@knpkv/atlassian-common/HomeDirectory")() {
|
|
25
|
+
}
|
|
26
|
+
const HomeConfig = Config.option(Config.string("HOME")).pipe(Config.orElse(() => Config.option(Config.string("USERPROFILE"))));
|
|
27
|
+
/**
|
|
28
|
+
* Default implementation using HOME/USERPROFILE env vars.
|
|
29
|
+
*
|
|
30
|
+
* @category Layers
|
|
31
|
+
*/
|
|
32
|
+
export const HomeDirectoryLive = Layer.succeed(HomeDirectoryTag, {
|
|
33
|
+
get: () => Effect.gen(function* () {
|
|
34
|
+
const opt = yield* Effect.orDie(HomeConfig);
|
|
35
|
+
return yield* Option.match(opt, {
|
|
36
|
+
onNone: () => Effect.fail(new HomeDirectoryError({})),
|
|
37
|
+
onSome: (home) => Effect.succeed(home)
|
|
38
|
+
});
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
const XdgConfigHome = Config.option(Config.string("XDG_CONFIG_HOME"));
|
|
42
|
+
/**
|
|
43
|
+
* XDG config directory for Atlassian tools.
|
|
44
|
+
* Returns ~/.config/atlassian by default.
|
|
45
|
+
*
|
|
46
|
+
* @category Utilities
|
|
47
|
+
*/
|
|
48
|
+
export const getConfigDir = (toolName) => Effect.gen(function* () {
|
|
49
|
+
const homeDir = yield* HomeDirectoryTag;
|
|
50
|
+
const pathSvc = yield* Path.Path;
|
|
51
|
+
const home = yield* homeDir.get();
|
|
52
|
+
// Use XDG_CONFIG_HOME if set, otherwise ~/.config
|
|
53
|
+
const xdgOpt = yield* Effect.orDie(XdgConfigHome);
|
|
54
|
+
const xdgConfig = Option.getOrElse(xdgOpt, () => pathSvc.join(home, ".config"));
|
|
55
|
+
const baseDir = pathSvc.join(xdgConfig, "atlassian");
|
|
56
|
+
return toolName ? pathSvc.join(baseDir, toolName) : baseDir;
|
|
57
|
+
});
|
|
58
|
+
/**
|
|
59
|
+
* Get auth file path for a specific tool.
|
|
60
|
+
*
|
|
61
|
+
* @category Utilities
|
|
62
|
+
*/
|
|
63
|
+
export const getAuthPath = (toolName) => Effect.gen(function* () {
|
|
64
|
+
const path = yield* Path.Path;
|
|
65
|
+
const configDir = yield* getConfigDir(toolName);
|
|
66
|
+
return path.join(configDir, "auth.json");
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* Get OAuth config file path for a specific tool.
|
|
70
|
+
*
|
|
71
|
+
* @category Utilities
|
|
72
|
+
*/
|
|
73
|
+
export const getOAuthConfigPath = (toolName) => Effect.gen(function* () {
|
|
74
|
+
const path = yield* Path.Path;
|
|
75
|
+
const configDir = yield* getConfigDir(toolName);
|
|
76
|
+
return path.join(configDir, "oauth.json");
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Ensure config directory exists with secure permissions.
|
|
80
|
+
*
|
|
81
|
+
* @category Utilities
|
|
82
|
+
*/
|
|
83
|
+
export const ensureConfigDir = (toolName) => Effect.gen(function* () {
|
|
84
|
+
const fs = yield* FileSystem.FileSystem;
|
|
85
|
+
const configDir = yield* getConfigDir(toolName);
|
|
86
|
+
yield* fs.makeDirectory(configDir, { recursive: true });
|
|
87
|
+
// Set secure permissions (owner only)
|
|
88
|
+
yield* fs.chmod(configDir, 0o700);
|
|
89
|
+
return configDir;
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Write file with secure permissions (600).
|
|
93
|
+
*
|
|
94
|
+
* @category Utilities
|
|
95
|
+
*/
|
|
96
|
+
export const writeSecureFile = (filePath, content) => Effect.gen(function* () {
|
|
97
|
+
const fs = yield* FileSystem.FileSystem;
|
|
98
|
+
yield* fs.writeFileString(filePath, content);
|
|
99
|
+
// Set secure permissions (owner only)
|
|
100
|
+
yield* fs.chmod(filePath, 0o600);
|
|
101
|
+
});
|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ChB,OAAe,EACkD,EAAE,CACnE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAA;IAEvC,KAAK,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAE5C,sCAAsC;IACtC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;AAClC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Effect Schema definitions for persisted OAuth credentials and site metadata.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **Storage schemas**: {@link OAuthTokenSchema} and {@link OAuthConfigSchema} define the
|
|
7
|
+
* JSON shape written to `auth.json` / `oauth.json` on disk. They are the single source
|
|
8
|
+
* of truth for token and config structure.
|
|
9
|
+
* - **Type derivation**: All companion types (`OAuthToken`, `OAuthConfig`, etc.) are derived
|
|
10
|
+
* from schemas — never duplicated.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
/**
|
|
16
|
+
* Schema for OAuth user info from Atlassian.
|
|
17
|
+
*
|
|
18
|
+
* @category Schema
|
|
19
|
+
*/
|
|
20
|
+
export declare const OAuthUserSchema: Schema.Struct<{
|
|
21
|
+
/** Atlassian account ID */
|
|
22
|
+
account_id: typeof Schema.String;
|
|
23
|
+
/** Display name */
|
|
24
|
+
name: typeof Schema.String;
|
|
25
|
+
/** Email address */
|
|
26
|
+
email: typeof Schema.String;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Type for OAuth user info.
|
|
30
|
+
*
|
|
31
|
+
* @category Types
|
|
32
|
+
*/
|
|
33
|
+
export type OAuthUser = Schema.Schema.Type<typeof OAuthUserSchema>;
|
|
34
|
+
/**
|
|
35
|
+
* Schema for stored OAuth token.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { OAuthTokenSchema } from "@knpkv/atlassian-common/config"
|
|
40
|
+
* import * as Schema from "effect/Schema"
|
|
41
|
+
*
|
|
42
|
+
* const token = Schema.decodeUnknownSync(OAuthTokenSchema)({
|
|
43
|
+
* access_token: "eyJ...",
|
|
44
|
+
* refresh_token: "eyJ...",
|
|
45
|
+
* expires_at: Date.now() + 3600000,
|
|
46
|
+
* scope: "read:confluence-content.all",
|
|
47
|
+
* cloud_id: "abc123",
|
|
48
|
+
* site_url: "https://mysite.atlassian.net"
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @category Schema
|
|
53
|
+
*/
|
|
54
|
+
export declare const OAuthTokenSchema: Schema.Struct<{
|
|
55
|
+
/** OAuth access token */
|
|
56
|
+
access_token: typeof Schema.String;
|
|
57
|
+
/** OAuth refresh token */
|
|
58
|
+
refresh_token: typeof Schema.String;
|
|
59
|
+
/** Token expiration timestamp (Unix ms) */
|
|
60
|
+
expires_at: typeof Schema.Number;
|
|
61
|
+
/** Granted scopes */
|
|
62
|
+
scope: typeof Schema.String;
|
|
63
|
+
/** Atlassian Cloud site ID */
|
|
64
|
+
cloud_id: typeof Schema.String;
|
|
65
|
+
/** Site URL */
|
|
66
|
+
site_url: typeof Schema.String;
|
|
67
|
+
/** Cached user info */
|
|
68
|
+
user: Schema.optional<Schema.Struct<{
|
|
69
|
+
/** Atlassian account ID */
|
|
70
|
+
account_id: typeof Schema.String;
|
|
71
|
+
/** Display name */
|
|
72
|
+
name: typeof Schema.String;
|
|
73
|
+
/** Email address */
|
|
74
|
+
email: typeof Schema.String;
|
|
75
|
+
}>>;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Type for stored OAuth token.
|
|
79
|
+
*
|
|
80
|
+
* @category Types
|
|
81
|
+
*/
|
|
82
|
+
export type OAuthToken = Schema.Schema.Type<typeof OAuthTokenSchema>;
|
|
83
|
+
/**
|
|
84
|
+
* Schema for OAuth client configuration.
|
|
85
|
+
*
|
|
86
|
+
* @category Schema
|
|
87
|
+
*/
|
|
88
|
+
export declare const OAuthConfigSchema: Schema.Struct<{
|
|
89
|
+
/** OAuth client ID from Atlassian Developer Console */
|
|
90
|
+
clientId: typeof Schema.String;
|
|
91
|
+
/** OAuth client secret */
|
|
92
|
+
clientSecret: typeof Schema.String;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Type for OAuth client configuration.
|
|
96
|
+
*
|
|
97
|
+
* @category Types
|
|
98
|
+
*/
|
|
99
|
+
export type OAuthConfig = Schema.Schema.Type<typeof OAuthConfigSchema>;
|
|
100
|
+
/**
|
|
101
|
+
* Schema for Atlassian Cloud site info.
|
|
102
|
+
*
|
|
103
|
+
* @category Schema
|
|
104
|
+
*/
|
|
105
|
+
export declare const AtlassianSiteSchema: Schema.Struct<{
|
|
106
|
+
/** Cloud ID */
|
|
107
|
+
id: typeof Schema.String;
|
|
108
|
+
/** Site name */
|
|
109
|
+
name: typeof Schema.String;
|
|
110
|
+
/** Site URL */
|
|
111
|
+
url: typeof Schema.String;
|
|
112
|
+
/** Available scopes */
|
|
113
|
+
scopes: Schema.Array$<typeof Schema.String>;
|
|
114
|
+
/** Avatar URL */
|
|
115
|
+
avatarUrl: Schema.optional<typeof Schema.String>;
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Type for Atlassian Cloud site.
|
|
119
|
+
*
|
|
120
|
+
* @category Types
|
|
121
|
+
*/
|
|
122
|
+
export type AtlassianSite = Schema.Schema.Type<typeof AtlassianSiteSchema>;
|
|
123
|
+
/**
|
|
124
|
+
* Schema for Atlassian user profile.
|
|
125
|
+
*
|
|
126
|
+
* @category Schema
|
|
127
|
+
*/
|
|
128
|
+
export declare const AtlassianUserSchema: Schema.Struct<{
|
|
129
|
+
/** Atlassian account ID */
|
|
130
|
+
accountId: typeof Schema.String;
|
|
131
|
+
/** Display name */
|
|
132
|
+
displayName: typeof Schema.String;
|
|
133
|
+
/** Email address (may be empty for privacy) */
|
|
134
|
+
email: Schema.optional<typeof Schema.String>;
|
|
135
|
+
/** Public name */
|
|
136
|
+
publicName: Schema.optional<typeof Schema.String>;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Type for Atlassian user profile.
|
|
140
|
+
*
|
|
141
|
+
* @category Types
|
|
142
|
+
*/
|
|
143
|
+
export type AtlassianUser = Schema.Schema.Type<typeof AtlassianUserSchema>;
|
|
144
|
+
//# sourceMappingURL=OAuthSchemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthSchemas.d.ts","sourceRoot":"","sources":["../../src/config/OAuthSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;GAIG;AACH,eAAO,MAAM,eAAe;IAC1B,2BAA2B;;IAE3B,mBAAmB;;IAEnB,oBAAoB;;EAEpB,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,eAAe,CAAC,CAAA;AAElE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,gBAAgB;IAC3B,yBAAyB;;IAEzB,0BAA0B;;IAE1B,2CAA2C;;IAE3C,qBAAqB;;IAErB,8BAA8B;;IAE9B,eAAe;;IAEf,uBAAuB;;QAhDvB,2BAA2B;;QAE3B,mBAAmB;;QAEnB,oBAAoB;;;EA8CpB,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAEpE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B,uDAAuD;;IAEvD,0BAA0B;;EAE1B,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEtE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;IAC9B,eAAe;;IAEf,gBAAgB;;IAEhB,eAAe;;IAEf,uBAAuB;;IAEvB,iBAAiB;;EAEjB,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE1E;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;IAC9B,2BAA2B;;IAE3B,mBAAmB;;IAEnB,+CAA+C;;IAE/C,kBAAkB;;EAElB,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Effect Schema definitions for persisted OAuth credentials and site metadata.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **Storage schemas**: {@link OAuthTokenSchema} and {@link OAuthConfigSchema} define the
|
|
7
|
+
* JSON shape written to `auth.json` / `oauth.json` on disk. They are the single source
|
|
8
|
+
* of truth for token and config structure.
|
|
9
|
+
* - **Type derivation**: All companion types (`OAuthToken`, `OAuthConfig`, etc.) are derived
|
|
10
|
+
* from schemas — never duplicated.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
/**
|
|
16
|
+
* Schema for OAuth user info from Atlassian.
|
|
17
|
+
*
|
|
18
|
+
* @category Schema
|
|
19
|
+
*/
|
|
20
|
+
export const OAuthUserSchema = Schema.Struct({
|
|
21
|
+
/** Atlassian account ID */
|
|
22
|
+
account_id: Schema.String,
|
|
23
|
+
/** Display name */
|
|
24
|
+
name: Schema.String,
|
|
25
|
+
/** Email address */
|
|
26
|
+
email: Schema.String
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* Schema for stored OAuth token.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { OAuthTokenSchema } from "@knpkv/atlassian-common/config"
|
|
34
|
+
* import * as Schema from "effect/Schema"
|
|
35
|
+
*
|
|
36
|
+
* const token = Schema.decodeUnknownSync(OAuthTokenSchema)({
|
|
37
|
+
* access_token: "eyJ...",
|
|
38
|
+
* refresh_token: "eyJ...",
|
|
39
|
+
* expires_at: Date.now() + 3600000,
|
|
40
|
+
* scope: "read:confluence-content.all",
|
|
41
|
+
* cloud_id: "abc123",
|
|
42
|
+
* site_url: "https://mysite.atlassian.net"
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @category Schema
|
|
47
|
+
*/
|
|
48
|
+
export const OAuthTokenSchema = Schema.Struct({
|
|
49
|
+
/** OAuth access token */
|
|
50
|
+
access_token: Schema.String,
|
|
51
|
+
/** OAuth refresh token */
|
|
52
|
+
refresh_token: Schema.String,
|
|
53
|
+
/** Token expiration timestamp (Unix ms) */
|
|
54
|
+
expires_at: Schema.Number,
|
|
55
|
+
/** Granted scopes */
|
|
56
|
+
scope: Schema.String,
|
|
57
|
+
/** Atlassian Cloud site ID */
|
|
58
|
+
cloud_id: Schema.String,
|
|
59
|
+
/** Site URL */
|
|
60
|
+
site_url: Schema.String,
|
|
61
|
+
/** Cached user info */
|
|
62
|
+
user: Schema.optional(OAuthUserSchema)
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Schema for OAuth client configuration.
|
|
66
|
+
*
|
|
67
|
+
* @category Schema
|
|
68
|
+
*/
|
|
69
|
+
export const OAuthConfigSchema = Schema.Struct({
|
|
70
|
+
/** OAuth client ID from Atlassian Developer Console */
|
|
71
|
+
clientId: Schema.String,
|
|
72
|
+
/** OAuth client secret */
|
|
73
|
+
clientSecret: Schema.String
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Schema for Atlassian Cloud site info.
|
|
77
|
+
*
|
|
78
|
+
* @category Schema
|
|
79
|
+
*/
|
|
80
|
+
export const AtlassianSiteSchema = Schema.Struct({
|
|
81
|
+
/** Cloud ID */
|
|
82
|
+
id: Schema.String,
|
|
83
|
+
/** Site name */
|
|
84
|
+
name: Schema.String,
|
|
85
|
+
/** Site URL */
|
|
86
|
+
url: Schema.String,
|
|
87
|
+
/** Available scopes */
|
|
88
|
+
scopes: Schema.Array(Schema.String),
|
|
89
|
+
/** Avatar URL */
|
|
90
|
+
avatarUrl: Schema.optional(Schema.String)
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Schema for Atlassian user profile.
|
|
94
|
+
*
|
|
95
|
+
* @category Schema
|
|
96
|
+
*/
|
|
97
|
+
export const AtlassianUserSchema = Schema.Struct({
|
|
98
|
+
/** Atlassian account ID */
|
|
99
|
+
accountId: Schema.String,
|
|
100
|
+
/** Display name */
|
|
101
|
+
displayName: Schema.String,
|
|
102
|
+
/** Email address (may be empty for privacy) */
|
|
103
|
+
email: Schema.optional(Schema.String),
|
|
104
|
+
/** Public name */
|
|
105
|
+
publicName: Schema.optional(Schema.String)
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=OAuthSchemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthSchemas.js","sourceRoot":"","sources":["../../src/config/OAuthSchemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC,MAAM;IACzB,mBAAmB;IACnB,I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