@knpkv/confluence-to-markdown 0.2.0 → 0.4.2
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 +73 -0
- package/LICENSE +21 -0
- package/README.md +282 -14
- package/dist/ConfluenceAuth.d.ts +76 -0
- package/dist/ConfluenceAuth.d.ts.map +1 -0
- package/dist/ConfluenceAuth.js +366 -0
- package/dist/ConfluenceAuth.js.map +1 -0
- package/dist/ConfluenceClient.d.ts +26 -12
- package/dist/ConfluenceClient.d.ts.map +1 -1
- package/dist/ConfluenceClient.js +139 -97
- package/dist/ConfluenceClient.js.map +1 -1
- package/dist/ConfluenceConfig.d.ts +4 -24
- package/dist/ConfluenceConfig.d.ts.map +1 -1
- package/dist/ConfluenceConfig.js +45 -7
- package/dist/ConfluenceConfig.js.map +1 -1
- package/dist/ConfluenceError.d.ts +99 -16
- package/dist/ConfluenceError.d.ts.map +1 -1
- package/dist/ConfluenceError.js +88 -5
- package/dist/ConfluenceError.js.map +1 -1
- package/dist/GitError.d.ts +103 -0
- package/dist/GitError.d.ts.map +1 -0
- package/dist/GitError.js +85 -0
- package/dist/GitError.js.map +1 -0
- package/dist/GitService.d.ts +175 -0
- package/dist/GitService.d.ts.map +1 -0
- package/dist/GitService.js +431 -0
- package/dist/GitService.js.map +1 -0
- package/dist/LocalFileSystem.d.ts +29 -4
- package/dist/LocalFileSystem.d.ts.map +1 -1
- package/dist/LocalFileSystem.js +80 -6
- package/dist/LocalFileSystem.js.map +1 -1
- package/dist/MarkdownConverter.d.ts +49 -2
- package/dist/MarkdownConverter.d.ts.map +1 -1
- package/dist/MarkdownConverter.js +73 -111
- package/dist/MarkdownConverter.js.map +1 -1
- package/dist/SchemaConverterError.d.ts +108 -0
- package/dist/SchemaConverterError.d.ts.map +1 -0
- package/dist/SchemaConverterError.js +84 -0
- package/dist/SchemaConverterError.js.map +1 -0
- package/dist/Schemas.d.ts +225 -1
- package/dist/Schemas.d.ts.map +1 -1
- package/dist/Schemas.js +155 -6
- package/dist/Schemas.js.map +1 -1
- package/dist/SyncEngine.d.ts +30 -20
- package/dist/SyncEngine.d.ts.map +1 -1
- package/dist/SyncEngine.js +566 -117
- package/dist/SyncEngine.js.map +1 -1
- package/dist/ast/BlockNode.d.ts +468 -0
- package/dist/ast/BlockNode.d.ts.map +1 -0
- package/dist/ast/BlockNode.js +319 -0
- package/dist/ast/BlockNode.js.map +1 -0
- package/dist/ast/Document.d.ts +244 -0
- package/dist/ast/Document.d.ts.map +1 -0
- package/dist/ast/Document.js +69 -0
- package/dist/ast/Document.js.map +1 -0
- package/dist/ast/InlineNode.d.ts +477 -0
- package/dist/ast/InlineNode.d.ts.map +1 -0
- package/dist/ast/InlineNode.js +263 -0
- package/dist/ast/InlineNode.js.map +1 -0
- package/dist/ast/MacroNode.d.ts +267 -0
- package/dist/ast/MacroNode.d.ts.map +1 -0
- package/dist/ast/MacroNode.js +164 -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/bin.js +33 -149
- package/dist/bin.js.map +1 -1
- package/dist/commands/auth.d.ts +15 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +86 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/clone.d.ts +12 -0
- package/dist/commands/clone.d.ts.map +1 -0
- package/dist/commands/clone.js +93 -0
- package/dist/commands/clone.js.map +1 -0
- package/dist/commands/delete.d.ts +13 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +48 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/errorHandler.d.ts +14 -0
- package/dist/commands/errorHandler.d.ts.map +1 -0
- package/dist/commands/errorHandler.js +33 -0
- package/dist/commands/errorHandler.js.map +1 -0
- package/dist/commands/git.d.ts +22 -0
- package/dist/commands/git.d.ts.map +1 -0
- package/dist/commands/git.js +72 -0
- package/dist/commands/git.js.map +1 -0
- package/dist/commands/index.d.ts +11 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +11 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/layers.d.ts +31 -0
- package/dist/commands/layers.d.ts.map +1 -0
- package/dist/commands/layers.js +137 -0
- package/dist/commands/layers.js.map +1 -0
- package/dist/commands/new.d.ts +9 -0
- package/dist/commands/new.d.ts.map +1 -0
- package/dist/commands/new.js +80 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/pageTree.d.ts +18 -0
- package/dist/commands/pageTree.d.ts.map +1 -0
- package/dist/commands/pageTree.js +20 -0
- package/dist/commands/pageTree.js.map +1 -0
- package/dist/commands/shared.d.ts +15 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +27 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/sync.d.ts +15 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +101 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/NodeLayers.d.ts +7 -0
- package/dist/internal/NodeLayers.d.ts.map +1 -0
- package/dist/internal/NodeLayers.js +19 -0
- package/dist/internal/NodeLayers.js.map +1 -0
- package/dist/internal/frontmatter.d.ts +10 -0
- package/dist/internal/frontmatter.d.ts.map +1 -1
- package/dist/internal/frontmatter.js +16 -0
- package/dist/internal/frontmatter.js.map +1 -1
- package/dist/internal/gitCommands.d.ts +78 -0
- package/dist/internal/gitCommands.d.ts.map +1 -0
- package/dist/internal/gitCommands.js +156 -0
- package/dist/internal/gitCommands.js.map +1 -0
- package/dist/internal/hashUtils.d.ts +42 -1
- package/dist/internal/hashUtils.d.ts.map +1 -1
- package/dist/internal/hashUtils.js +38 -2
- package/dist/internal/hashUtils.js.map +1 -1
- package/dist/internal/oauthServer.d.ts +55 -0
- package/dist/internal/oauthServer.d.ts.map +1 -0
- package/dist/internal/oauthServer.js +110 -0
- package/dist/internal/oauthServer.js.map +1 -0
- package/dist/internal/pathUtils.d.ts +21 -4
- package/dist/internal/pathUtils.d.ts.map +1 -1
- package/dist/internal/pathUtils.js +24 -13
- package/dist/internal/pathUtils.js.map +1 -1
- package/dist/internal/tokenStorage.d.ts +75 -0
- package/dist/internal/tokenStorage.d.ts.map +1 -0
- package/dist/internal/tokenStorage.js +149 -0
- package/dist/internal/tokenStorage.js.map +1 -0
- package/dist/internal/userCache.d.ts +42 -0
- package/dist/internal/userCache.d.ts.map +1 -0
- package/dist/internal/userCache.js +51 -0
- package/dist/internal/userCache.js.map +1 -0
- package/dist/parsers/ConfluenceParser.d.ts +26 -0
- package/dist/parsers/ConfluenceParser.d.ts.map +1 -0
- package/dist/parsers/ConfluenceParser.js +792 -0
- package/dist/parsers/ConfluenceParser.js.map +1 -0
- package/dist/parsers/MarkdownParser.d.ts +26 -0
- package/dist/parsers/MarkdownParser.d.ts.map +1 -0
- package/dist/parsers/MarkdownParser.js +873 -0
- package/dist/parsers/MarkdownParser.js.map +1 -0
- package/dist/parsers/index.d.ts +8 -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/schemas/ConfluenceSchema.d.ts +21 -0
- package/dist/schemas/ConfluenceSchema.d.ts.map +1 -0
- package/dist/schemas/ConfluenceSchema.js +38 -0
- package/dist/schemas/ConfluenceSchema.js.map +1 -0
- package/dist/schemas/ConversionSchema.d.ts +35 -0
- package/dist/schemas/ConversionSchema.d.ts.map +1 -0
- package/dist/schemas/ConversionSchema.js +208 -0
- package/dist/schemas/ConversionSchema.js.map +1 -0
- package/dist/schemas/MarkdownSchema.d.ts +21 -0
- package/dist/schemas/MarkdownSchema.d.ts.map +1 -0
- package/dist/schemas/MarkdownSchema.js +38 -0
- package/dist/schemas/MarkdownSchema.js.map +1 -0
- package/dist/schemas/hast/HastFromHtml.d.ts +27 -0
- package/dist/schemas/hast/HastFromHtml.d.ts.map +1 -0
- package/dist/schemas/hast/HastFromHtml.js +107 -0
- package/dist/schemas/hast/HastFromHtml.js.map +1 -0
- package/dist/schemas/hast/HastSchema.d.ts +195 -0
- package/dist/schemas/hast/HastSchema.d.ts.map +1 -0
- package/dist/schemas/hast/HastSchema.js +183 -0
- package/dist/schemas/hast/HastSchema.js.map +1 -0
- package/dist/schemas/hast/index.d.ts +9 -0
- package/dist/schemas/hast/index.d.ts.map +1 -0
- package/dist/schemas/hast/index.js +3 -0
- package/dist/schemas/hast/index.js.map +1 -0
- package/dist/schemas/index.d.ts +14 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +16 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/mdast/MdastFromMarkdown.d.ts +30 -0
- package/dist/schemas/mdast/MdastFromMarkdown.d.ts.map +1 -0
- package/dist/schemas/mdast/MdastFromMarkdown.js +79 -0
- package/dist/schemas/mdast/MdastFromMarkdown.js.map +1 -0
- package/dist/schemas/mdast/MdastSchema.d.ts +385 -0
- package/dist/schemas/mdast/MdastSchema.d.ts.map +1 -0
- package/dist/schemas/mdast/MdastSchema.js +266 -0
- package/dist/schemas/mdast/MdastSchema.js.map +1 -0
- package/dist/schemas/mdast/index.d.ts +10 -0
- package/dist/schemas/mdast/index.d.ts.map +1 -0
- package/dist/schemas/mdast/index.js +4 -0
- package/dist/schemas/mdast/index.js.map +1 -0
- package/dist/schemas/mdast/mdastToString.d.ts +13 -0
- package/dist/schemas/mdast/mdastToString.d.ts.map +1 -0
- package/dist/schemas/mdast/mdastToString.js +85 -0
- package/dist/schemas/mdast/mdastToString.js.map +1 -0
- package/dist/schemas/nodes/block/BlockSchema.d.ts +43 -0
- package/dist/schemas/nodes/block/BlockSchema.d.ts.map +1 -0
- package/dist/schemas/nodes/block/BlockSchema.js +634 -0
- package/dist/schemas/nodes/block/BlockSchema.js.map +1 -0
- package/dist/schemas/nodes/block/index.d.ts +7 -0
- package/dist/schemas/nodes/block/index.d.ts.map +1 -0
- package/dist/schemas/nodes/block/index.js +7 -0
- package/dist/schemas/nodes/block/index.js.map +1 -0
- package/dist/schemas/nodes/index.d.ts +9 -0
- package/dist/schemas/nodes/index.d.ts.map +1 -0
- package/dist/schemas/nodes/index.js +12 -0
- package/dist/schemas/nodes/index.js.map +1 -0
- package/dist/schemas/nodes/inline/InlineSchema.d.ts +48 -0
- package/dist/schemas/nodes/inline/InlineSchema.d.ts.map +1 -0
- package/dist/schemas/nodes/inline/InlineSchema.js +436 -0
- package/dist/schemas/nodes/inline/InlineSchema.js.map +1 -0
- package/dist/schemas/nodes/inline/index.d.ts +7 -0
- package/dist/schemas/nodes/inline/index.d.ts.map +1 -0
- package/dist/schemas/nodes/inline/index.js +7 -0
- package/dist/schemas/nodes/inline/index.js.map +1 -0
- package/dist/schemas/nodes/macro/MacroSchema.d.ts +27 -0
- package/dist/schemas/nodes/macro/MacroSchema.d.ts.map +1 -0
- package/dist/schemas/nodes/macro/MacroSchema.js +162 -0
- package/dist/schemas/nodes/macro/MacroSchema.js.map +1 -0
- package/dist/schemas/nodes/macro/index.d.ts +7 -0
- package/dist/schemas/nodes/macro/index.d.ts.map +1 -0
- package/dist/schemas/nodes/macro/index.js +7 -0
- package/dist/schemas/nodes/macro/index.js.map +1 -0
- package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts +24 -0
- package/dist/schemas/preprocessing/ConfluencePreprocessor.d.ts.map +1 -0
- package/dist/schemas/preprocessing/ConfluencePreprocessor.js +351 -0
- package/dist/schemas/preprocessing/ConfluencePreprocessor.js.map +1 -0
- package/dist/schemas/preprocessing/index.d.ts +8 -0
- package/dist/schemas/preprocessing/index.d.ts.map +1 -0
- package/dist/schemas/preprocessing/index.js +2 -0
- package/dist/schemas/preprocessing/index.js.map +1 -0
- package/dist/serializers/ConfluenceSerializer.d.ts +30 -0
- package/dist/serializers/ConfluenceSerializer.d.ts.map +1 -0
- package/dist/serializers/ConfluenceSerializer.js +551 -0
- package/dist/serializers/ConfluenceSerializer.js.map +1 -0
- package/dist/serializers/MarkdownSerializer.d.ts +34 -0
- package/dist/serializers/MarkdownSerializer.d.ts.map +1 -0
- package/dist/serializers/MarkdownSerializer.js +355 -0
- package/dist/serializers/MarkdownSerializer.js.map +1 -0
- package/dist/serializers/index.d.ts +8 -0
- package/dist/serializers/index.d.ts.map +1 -0
- package/dist/serializers/index.js +8 -0
- package/dist/serializers/index.js.map +1 -0
- package/package.json +32 -21
- package/src/ConfluenceAuth.ts +581 -0
- package/src/ConfluenceClient.ts +230 -165
- package/src/ConfluenceConfig.ts +63 -7
- package/src/ConfluenceError.ts +110 -14
- package/src/GitError.ts +92 -0
- package/src/GitService.ts +859 -0
- package/src/LocalFileSystem.ts +179 -9
- package/src/MarkdownConverter.ts +126 -122
- package/src/SchemaConverterError.ts +108 -0
- package/src/Schemas.ts +223 -6
- package/src/SyncEngine.ts +745 -162
- package/src/ast/BlockNode.ts +425 -0
- package/src/ast/Document.ts +90 -0
- package/src/ast/InlineNode.ts +323 -0
- package/src/ast/MacroNode.ts +245 -0
- package/src/ast/index.ts +83 -0
- package/src/bin.ts +50 -249
- package/src/commands/auth.ts +117 -0
- package/src/commands/clone.ts +145 -0
- package/src/commands/delete.ts +57 -0
- package/src/commands/errorHandler.ts +32 -0
- package/src/commands/git.ts +114 -0
- package/src/commands/index.ts +10 -0
- package/src/commands/layers.ts +211 -0
- package/src/commands/new.ts +99 -0
- package/src/commands/pageTree.ts +40 -0
- package/src/commands/shared.ts +35 -0
- package/src/commands/sync.ts +129 -0
- package/src/index.ts +21 -1
- package/src/internal/NodeLayers.ts +21 -0
- package/src/internal/frontmatter.ts +21 -0
- package/src/internal/gitCommands.ts +229 -0
- package/src/internal/hashUtils.ts +65 -3
- package/src/internal/oauthServer.ts +199 -0
- package/src/internal/pathUtils.ts +34 -17
- package/src/internal/tokenStorage.ts +240 -0
- package/src/internal/userCache.ts +90 -0
- package/src/parsers/ConfluenceParser.ts +950 -0
- package/src/parsers/MarkdownParser.ts +1198 -0
- package/src/parsers/index.ts +8 -0
- package/src/schemas/ConfluenceSchema.ts +56 -0
- package/src/schemas/ConversionSchema.ts +318 -0
- package/src/schemas/MarkdownSchema.ts +56 -0
- package/src/schemas/hast/HastFromHtml.ts +153 -0
- package/src/schemas/hast/HastSchema.ts +274 -0
- package/src/schemas/hast/index.ts +35 -0
- package/src/schemas/index.ts +20 -0
- package/src/schemas/mdast/MdastFromMarkdown.ts +118 -0
- package/src/schemas/mdast/MdastSchema.ts +566 -0
- package/src/schemas/mdast/index.ts +59 -0
- package/src/schemas/mdast/mdastToString.ts +102 -0
- package/src/schemas/nodes/block/BlockSchema.ts +773 -0
- package/src/schemas/nodes/block/index.ts +13 -0
- package/src/schemas/nodes/index.ts +20 -0
- package/src/schemas/nodes/inline/InlineSchema.ts +523 -0
- package/src/schemas/nodes/inline/index.ts +14 -0
- package/src/schemas/nodes/macro/MacroSchema.ts +226 -0
- package/src/schemas/nodes/macro/index.ts +6 -0
- package/src/schemas/preprocessing/ConfluencePreprocessor.ts +446 -0
- package/src/schemas/preprocessing/index.ts +8 -0
- package/src/serializers/ConfluenceSerializer.ts +717 -0
- package/src/serializers/MarkdownSerializer.ts +493 -0
- package/src/serializers/index.ts +8 -0
- package/test/GitService.test.ts +209 -0
- package/test/MarkdownConverter.test.ts +37 -3
- package/test/Schemas.test.ts +97 -2
- package/test/ast/BlockNode.test.ts +265 -0
- package/test/ast/Document.test.ts +126 -0
- package/test/ast/InlineNode.test.ts +161 -0
- package/test/fixtures/integration-test.html.fixture +103 -0
- package/test/fixtures/integration-test.md.expected +257 -0
- package/test/integration.test.ts +269 -0
- package/test/oauthServer.test.ts +50 -0
- package/test/parsers/ConfluenceParser.test.ts +283 -0
- package/test/schemas/ConfluencePreprocessor.test.ts +180 -0
- package/test/schemas/ConversionSchema.test.ts +159 -0
- package/test/schemas/HastSchema.test.ts +138 -0
- package/test/schemas/MdastSchema.test.ts +145 -0
- package/test/schemas/nodes/block/BlockSchema.test.ts +173 -0
- package/test/schemas/nodes/inline/InlineSchema.test.ts +198 -0
- package/test/schemas/nodes/macro/MacroSchema.test.ts +142 -0
- package/test/tokenStorage.test.ts +99 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as HttpServer from "@effect/platform/HttpServer";
|
|
2
|
+
import type { ServeError } from "@effect/platform/HttpServerError";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import { OAuthError } from "../ConfluenceError.js";
|
|
7
|
+
/**
|
|
8
|
+
* Factory service for creating HTTP servers.
|
|
9
|
+
* This allows mocking the server creation in tests.
|
|
10
|
+
*
|
|
11
|
+
* @category Services
|
|
12
|
+
*/
|
|
13
|
+
export interface HttpServerFactory {
|
|
14
|
+
readonly createServerLayer: (port: number) => Layer.Layer<HttpServer.HttpServer, ServeError, never>;
|
|
15
|
+
}
|
|
16
|
+
declare const HttpServerFactoryTag_base: Context.TagClass<HttpServerFactoryTag, "@knpkv/confluence-to-markdown/HttpServerFactory", HttpServerFactory>;
|
|
17
|
+
/**
|
|
18
|
+
* Tag for the HttpServerFactory service.
|
|
19
|
+
*
|
|
20
|
+
* @category Services
|
|
21
|
+
*/
|
|
22
|
+
export declare class HttpServerFactoryTag extends HttpServerFactoryTag_base {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a HttpServerFactory layer from a layer factory function.
|
|
26
|
+
* This allows injecting platform-specific implementations.
|
|
27
|
+
*
|
|
28
|
+
* @param createLayerFn - Function that creates HttpServer layer for a given port
|
|
29
|
+
* @returns Layer providing HttpServerFactory
|
|
30
|
+
*
|
|
31
|
+
* @category Layers
|
|
32
|
+
*/
|
|
33
|
+
export declare const makeHttpServerFactory: (createLayerFn: (port: number) => Layer.Layer<HttpServer.HttpServer, ServeError, never>) => Layer.Layer<HttpServerFactoryTag>;
|
|
34
|
+
/**
|
|
35
|
+
* Result from the OAuth callback server.
|
|
36
|
+
*/
|
|
37
|
+
export interface CallbackServerResult {
|
|
38
|
+
/** Promise that resolves with the authorization code */
|
|
39
|
+
readonly codePromise: Effect.Effect<string, OAuthError>;
|
|
40
|
+
/** Shutdown the callback server */
|
|
41
|
+
readonly shutdown: Effect.Effect<void, never>;
|
|
42
|
+
/** The port the server is listening on */
|
|
43
|
+
readonly port: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Start a local HTTP server to receive OAuth callback.
|
|
47
|
+
*
|
|
48
|
+
* @param expectedState - The state parameter to verify against CSRF
|
|
49
|
+
* @returns Server control interface with code promise, shutdown, and port
|
|
50
|
+
*
|
|
51
|
+
* @category OAuth
|
|
52
|
+
*/
|
|
53
|
+
export declare const startCallbackServer: (expectedState: string) => Effect.Effect<CallbackServerResult, OAuthError, HttpServerFactoryTag>;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=oauthServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthServer.d.ts","sourceRoot":"","sources":["../../src/internal/oauthServer.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAGlE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAKlD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,KAAK,CACvD,UAAU,CAAC,UAAU,EACrB,UAAU,EACV,KAAK,CACN,CAAA;CACF;;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,yBAGvC;CAAG;AAEN;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAChC,eAAe,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,KACrF,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAG/B,CAAA;AAyCJ;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACvD,mCAAmC;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC7C,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAC9B,eAAe,MAAM,KACpB,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,UAAU,EAAE,oBAAoB,CA6EnE,CAAA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local HTTP server for OAuth callback.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import * as HttpRouter from "@effect/platform/HttpRouter";
|
|
7
|
+
import * as HttpServer from "@effect/platform/HttpServer";
|
|
8
|
+
import * as HttpServerRequest from "@effect/platform/HttpServerRequest";
|
|
9
|
+
import * as HttpServerResponse from "@effect/platform/HttpServerResponse";
|
|
10
|
+
import * as Context from "effect/Context";
|
|
11
|
+
import * as Deferred from "effect/Deferred";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Fiber from "effect/Fiber";
|
|
14
|
+
import * as Layer from "effect/Layer";
|
|
15
|
+
import { OAuthError } from "../ConfluenceError.js";
|
|
16
|
+
const DEFAULT_PORT = 8585;
|
|
17
|
+
const MAX_PORT_ATTEMPTS = 10;
|
|
18
|
+
/**
|
|
19
|
+
* Tag for the HttpServerFactory service.
|
|
20
|
+
*
|
|
21
|
+
* @category Services
|
|
22
|
+
*/
|
|
23
|
+
export class HttpServerFactoryTag extends Context.Tag("@knpkv/confluence-to-markdown/HttpServerFactory")() {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a HttpServerFactory layer from a layer factory function.
|
|
27
|
+
* This allows injecting platform-specific implementations.
|
|
28
|
+
*
|
|
29
|
+
* @param createLayerFn - Function that creates HttpServer layer for a given port
|
|
30
|
+
* @returns Layer providing HttpServerFactory
|
|
31
|
+
*
|
|
32
|
+
* @category Layers
|
|
33
|
+
*/
|
|
34
|
+
export const makeHttpServerFactory = (createLayerFn) => Layer.succeed(HttpServerFactoryTag, {
|
|
35
|
+
createServerLayer: createLayerFn
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Check if a port is available by attempting to start a server.
|
|
39
|
+
*/
|
|
40
|
+
const isPortAvailable = (port) => Effect.gen(function* () {
|
|
41
|
+
const factory = yield* HttpServerFactoryTag;
|
|
42
|
+
const serverLayer = factory.createServerLayer(port);
|
|
43
|
+
// Try to acquire and immediately release
|
|
44
|
+
const result = yield* Layer.build(serverLayer).pipe(Effect.scoped, Effect.as(true), Effect.catchAll(() => Effect.succeed(false)));
|
|
45
|
+
return result;
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Find an available port starting from the default.
|
|
49
|
+
*/
|
|
50
|
+
const findAvailablePort = () => Effect.gen(function* () {
|
|
51
|
+
for (let attempt = 0; attempt < MAX_PORT_ATTEMPTS; attempt++) {
|
|
52
|
+
const port = DEFAULT_PORT + attempt;
|
|
53
|
+
const available = yield* isPortAvailable(port);
|
|
54
|
+
if (available) {
|
|
55
|
+
return port;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return yield* Effect.fail(new OAuthError({
|
|
59
|
+
step: "authorize",
|
|
60
|
+
cause: `Could not find available port (tried ${DEFAULT_PORT}-${DEFAULT_PORT + MAX_PORT_ATTEMPTS - 1}). Close other applications using these ports.`
|
|
61
|
+
}));
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Start a local HTTP server to receive OAuth callback.
|
|
65
|
+
*
|
|
66
|
+
* @param expectedState - The state parameter to verify against CSRF
|
|
67
|
+
* @returns Server control interface with code promise, shutdown, and port
|
|
68
|
+
*
|
|
69
|
+
* @category OAuth
|
|
70
|
+
*/
|
|
71
|
+
export const startCallbackServer = (expectedState) => Effect.gen(function* () {
|
|
72
|
+
const factory = yield* HttpServerFactoryTag;
|
|
73
|
+
const port = yield* findAvailablePort();
|
|
74
|
+
const deferred = yield* Deferred.make();
|
|
75
|
+
const readyDeferred = yield* Deferred.make();
|
|
76
|
+
const app = HttpRouter.empty.pipe(HttpRouter.get("/callback", Effect.gen(function* () {
|
|
77
|
+
const req = yield* HttpServerRequest.HttpServerRequest;
|
|
78
|
+
const url = new URL(req.url, `http://localhost:${port}`);
|
|
79
|
+
const code = url.searchParams.get("code");
|
|
80
|
+
const state = url.searchParams.get("state");
|
|
81
|
+
const error = url.searchParams.get("error");
|
|
82
|
+
const errorDescription = url.searchParams.get("error_description");
|
|
83
|
+
if (error) {
|
|
84
|
+
yield* Deferred.fail(deferred, new OAuthError({ step: "authorize", cause: errorDescription || error }));
|
|
85
|
+
return HttpServerResponse.html("<html><body><h1>Authorization Failed</h1><p>You can close this window.</p></body></html>");
|
|
86
|
+
}
|
|
87
|
+
if (state !== expectedState) {
|
|
88
|
+
yield* Deferred.fail(deferred, new OAuthError({ step: "authorize", cause: "State mismatch - possible CSRF attack" }));
|
|
89
|
+
return HttpServerResponse.html("<html><body><h1>Security Error</h1><p>State verification failed.</p></body></html>");
|
|
90
|
+
}
|
|
91
|
+
if (!code) {
|
|
92
|
+
yield* Deferred.fail(deferred, new OAuthError({ step: "authorize", cause: "No authorization code received" }));
|
|
93
|
+
return HttpServerResponse.html("<html><body><h1>Error</h1><p>No authorization code received.</p></body></html>");
|
|
94
|
+
}
|
|
95
|
+
yield* Deferred.succeed(deferred, code);
|
|
96
|
+
return HttpServerResponse.html("<html><body><h1>Success!</h1><p>You can close this window and return to the terminal.</p></body></html>");
|
|
97
|
+
})));
|
|
98
|
+
const serverLayer = factory.createServerLayer(port);
|
|
99
|
+
const serverFiber = yield* HttpServer.serve(app).pipe(Layer.provide(serverLayer), Layer.build, Effect.tap(() => Deferred.succeed(readyDeferred, undefined)), Effect.tapError((err) => Deferred.fail(readyDeferred, new OAuthError({ step: "authorize", cause: err }))),
|
|
100
|
+
// Keep the layer alive until fiber is interrupted
|
|
101
|
+
Effect.flatMap(() => Effect.never), Effect.scoped, Effect.fork);
|
|
102
|
+
// Wait for server to be ready (or fail)
|
|
103
|
+
yield* Deferred.await(readyDeferred);
|
|
104
|
+
return {
|
|
105
|
+
codePromise: Deferred.await(deferred),
|
|
106
|
+
shutdown: Fiber.interrupt(serverFiber).pipe(Effect.asVoid),
|
|
107
|
+
port
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=oauthServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauthServer.js","sourceRoot":"","sources":["../../src/internal/oauthServer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AAEzD,OAAO,KAAK,iBAAiB,MAAM,oCAAoC,CAAA;AACvE,OAAO,KAAK,kBAAkB,MAAM,qCAAqC,CAAA;AACzE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc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C,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CACnD,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAC1B,KAAK,CAAC,KAAK,EACX,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,EAC5D,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACzG,kDAAkD;IAClD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAClC,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,IAAI,CACZ,CAAA;IAED,wCAAwC;IACxC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAEpC,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC1D,IAAI;KACL,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path utilities for converting page titles to file paths.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
import * as Path from "@effect/platform/Path";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
1
9
|
/**
|
|
2
10
|
* Convert a page title to a URL-safe slug.
|
|
3
11
|
* Prevents path traversal by only allowing alphanumeric characters and hyphens.
|
|
@@ -11,14 +19,23 @@ export declare const slugify: (title: string) => string;
|
|
|
11
19
|
/**
|
|
12
20
|
* Convert a page to a local file path.
|
|
13
21
|
*
|
|
22
|
+
* Pages are always stored as `slug.md`. If a page has children,
|
|
23
|
+
* the children are stored in a `slug/` directory alongside the parent file.
|
|
24
|
+
*
|
|
25
|
+
* Example structure:
|
|
26
|
+
* - guide.md (page with children)
|
|
27
|
+
* - guide/ (directory for children)
|
|
28
|
+
* - getting-started.md
|
|
29
|
+
* - advanced.md
|
|
30
|
+
*
|
|
14
31
|
* @param title - The page title
|
|
15
|
-
* @param
|
|
32
|
+
* @param _hasChildren - Whether the page has child pages (unused, kept for API compat)
|
|
16
33
|
* @param parentPath - The parent directory path
|
|
17
34
|
* @returns The local file path for the page
|
|
18
35
|
*
|
|
19
36
|
* @internal
|
|
20
37
|
*/
|
|
21
|
-
export declare const pageToPath: (title: string,
|
|
38
|
+
export declare const pageToPath: (title: string, _hasChildren: boolean, parentPath: string) => Effect.Effect<string, never, Path.Path>;
|
|
22
39
|
/**
|
|
23
40
|
* Get the directory path for a page (used when creating children).
|
|
24
41
|
*
|
|
@@ -28,7 +45,7 @@ export declare const pageToPath: (title: string, hasChildren: boolean, parentPat
|
|
|
28
45
|
*
|
|
29
46
|
* @internal
|
|
30
47
|
*/
|
|
31
|
-
export declare const pageToDir: (title: string, parentPath: string) => string
|
|
48
|
+
export declare const pageToDir: (title: string, parentPath: string) => Effect.Effect<string, never, Path.Path>;
|
|
32
49
|
/**
|
|
33
50
|
* Extract page slug from a file path.
|
|
34
51
|
*
|
|
@@ -37,5 +54,5 @@ export declare const pageToDir: (title: string, parentPath: string) => string;
|
|
|
37
54
|
*
|
|
38
55
|
* @internal
|
|
39
56
|
*/
|
|
40
|
-
export declare const pathToSlug: (filePath: string) => string
|
|
57
|
+
export declare const pathToSlug: (filePath: string) => Effect.Effect<string, never, Path.Path>;
|
|
41
58
|
//# sourceMappingURL=pathUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../src/internal/pathUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../src/internal/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,KAAG,MAWvC,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,MAAM,EACb,cAAc,OAAO,EACrB,YAAY,MAAM,KACjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAMrC,CAAA;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,MAAM,EACb,YAAY,MAAM,KACjB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAKrC,CAAA;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAIhF,CAAA"}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
import * as
|
|
7
|
+
import * as Path from "@effect/platform/Path";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
8
9
|
/**
|
|
9
10
|
* Convert a page title to a URL-safe slug.
|
|
10
11
|
* Prevents path traversal by only allowing alphanumeric characters and hyphens.
|
|
@@ -28,19 +29,28 @@ export const slugify = (title) => {
|
|
|
28
29
|
/**
|
|
29
30
|
* Convert a page to a local file path.
|
|
30
31
|
*
|
|
32
|
+
* Pages are always stored as `slug.md`. If a page has children,
|
|
33
|
+
* the children are stored in a `slug/` directory alongside the parent file.
|
|
34
|
+
*
|
|
35
|
+
* Example structure:
|
|
36
|
+
* - guide.md (page with children)
|
|
37
|
+
* - guide/ (directory for children)
|
|
38
|
+
* - getting-started.md
|
|
39
|
+
* - advanced.md
|
|
40
|
+
*
|
|
31
41
|
* @param title - The page title
|
|
32
|
-
* @param
|
|
42
|
+
* @param _hasChildren - Whether the page has child pages (unused, kept for API compat)
|
|
33
43
|
* @param parentPath - The parent directory path
|
|
34
44
|
* @returns The local file path for the page
|
|
35
45
|
*
|
|
36
46
|
* @internal
|
|
37
47
|
*/
|
|
38
|
-
export const pageToPath = (title,
|
|
48
|
+
export const pageToPath = (title, _hasChildren, parentPath) => Effect.gen(function* () {
|
|
49
|
+
const path = yield* Path.Path;
|
|
39
50
|
const slug = slugify(title);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
51
|
+
// Always use slug.md, children go in slug/ directory
|
|
52
|
+
return path.join(parentPath, `${slug}.md`);
|
|
53
|
+
});
|
|
44
54
|
/**
|
|
45
55
|
* Get the directory path for a page (used when creating children).
|
|
46
56
|
*
|
|
@@ -50,10 +60,11 @@ export const pageToPath = (title, hasChildren, parentPath) => {
|
|
|
50
60
|
*
|
|
51
61
|
* @internal
|
|
52
62
|
*/
|
|
53
|
-
export const pageToDir = (title, parentPath) => {
|
|
63
|
+
export const pageToDir = (title, parentPath) => Effect.gen(function* () {
|
|
64
|
+
const path = yield* Path.Path;
|
|
54
65
|
const slug = slugify(title);
|
|
55
66
|
return path.join(parentPath, slug);
|
|
56
|
-
};
|
|
67
|
+
});
|
|
57
68
|
/**
|
|
58
69
|
* Extract page slug from a file path.
|
|
59
70
|
*
|
|
@@ -62,8 +73,8 @@ export const pageToDir = (title, parentPath) => {
|
|
|
62
73
|
*
|
|
63
74
|
* @internal
|
|
64
75
|
*/
|
|
65
|
-
export const pathToSlug = (filePath) => {
|
|
66
|
-
const
|
|
67
|
-
return
|
|
68
|
-
};
|
|
76
|
+
export const pathToSlug = (filePath) => Effect.gen(function* () {
|
|
77
|
+
const path = yield* Path.Path;
|
|
78
|
+
return path.basename(filePath, ".md");
|
|
79
|
+
});
|
|
69
80
|
//# sourceMappingURL=pathUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/internal/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/internal/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE;IAC/C,MAAM,IAAI,GAAG,KAAK;SACf,WAAW,EAAE;SACb,SAAS,CAAC,KAAK,CAAC;SAChB,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,oBAAoB;SACpD,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,sEAAsE;SAClG,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,gCAAgC;SACxD,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA,CAAC,eAAe;IAEpC,6DAA6D;IAC7D,OAAO,IAAI,IAAI,UAAU,CAAA;AAC3B,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAa,EACb,YAAqB,EACrB,UAAkB,EACuB,EAAE,CAC3C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,qDAAqD;IACrD,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,KAAK,CAAC,CAAA;AAC5C,CAAC,CAAC,CAAA;AAEJ;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAa,EACb,UAAkB,EACuB,EAAE,CAC3C,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC,CAAC,CAAA;AAEJ;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,QAAgB,EAA2C,EAAE,CACtF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAA;IAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;AACvC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token storage for OAuth credentials.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
7
|
+
import * as Path from "@effect/platform/Path";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Layer from "effect/Layer";
|
|
11
|
+
import { FileSystemError } from "../ConfluenceError.js";
|
|
12
|
+
import { type OAuthConfig, type OAuthToken } from "../Schemas.js";
|
|
13
|
+
/**
|
|
14
|
+
* Service for getting the home directory.
|
|
15
|
+
* This allows mocking in tests.
|
|
16
|
+
*
|
|
17
|
+
* @category Services
|
|
18
|
+
*/
|
|
19
|
+
export interface HomeDirectory {
|
|
20
|
+
readonly get: () => Effect.Effect<string>;
|
|
21
|
+
}
|
|
22
|
+
declare const HomeDirectoryTag_base: Context.TagClass<HomeDirectoryTag, "@knpkv/confluence-to-markdown/HomeDirectory", HomeDirectory>;
|
|
23
|
+
/**
|
|
24
|
+
* Tag for the HomeDirectory service.
|
|
25
|
+
*
|
|
26
|
+
* @category Services
|
|
27
|
+
*/
|
|
28
|
+
export declare class HomeDirectoryTag extends HomeDirectoryTag_base {
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Default implementation using process.env.HOME.
|
|
32
|
+
*
|
|
33
|
+
* @category Layers
|
|
34
|
+
*/
|
|
35
|
+
export declare const HomeDirectoryLive: Layer.Layer<HomeDirectoryTag>;
|
|
36
|
+
/**
|
|
37
|
+
* Load stored OAuth token from disk.
|
|
38
|
+
*
|
|
39
|
+
* @returns The stored token or null if not found/invalid
|
|
40
|
+
*
|
|
41
|
+
* @category Token Storage
|
|
42
|
+
*/
|
|
43
|
+
export declare const loadToken: () => Effect.Effect<OAuthToken | null, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
|
|
44
|
+
/**
|
|
45
|
+
* Save OAuth token to disk with secure permissions.
|
|
46
|
+
*
|
|
47
|
+
* @param token - The token to save
|
|
48
|
+
*
|
|
49
|
+
* @category Token Storage
|
|
50
|
+
*/
|
|
51
|
+
export declare const saveToken: (token: OAuthToken) => Effect.Effect<void, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
|
|
52
|
+
/**
|
|
53
|
+
* Delete stored OAuth token.
|
|
54
|
+
*
|
|
55
|
+
* @category Token Storage
|
|
56
|
+
*/
|
|
57
|
+
export declare const deleteToken: () => Effect.Effect<void, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
|
|
58
|
+
/**
|
|
59
|
+
* Load OAuth client configuration from disk.
|
|
60
|
+
*
|
|
61
|
+
* @returns The stored config or null if not found/invalid
|
|
62
|
+
*
|
|
63
|
+
* @category OAuth Config
|
|
64
|
+
*/
|
|
65
|
+
export declare const loadOAuthConfig: () => Effect.Effect<OAuthConfig | null, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
|
|
66
|
+
/**
|
|
67
|
+
* Save OAuth client configuration to disk with secure permissions.
|
|
68
|
+
*
|
|
69
|
+
* @param config - The config to save
|
|
70
|
+
*
|
|
71
|
+
* @category OAuth Config
|
|
72
|
+
*/
|
|
73
|
+
export declare const saveOAuthConfig: (config: OAuthConfig) => Effect.Effect<void, FileSystemError, FileSystem.FileSystem | Path.Path | HomeDirectoryTag>;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=tokenStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenStorage.d.ts","sourceRoot":"","sources":["../../src/internal/tokenStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,KAAK,WAAW,EAAqB,KAAK,UAAU,EAAoB,MAAM,eAAe,CAAA;AAMtG;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;CAC1C;;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,qBAGnC;CAAG;AAEN;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAK3D,CAAA;AAiCD;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,QAAO,MAAM,CAAC,MAAM,CACxC,UAAU,GAAG,IAAI,EACjB,eAAe,EACf,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CA6BlD,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GACpB,OAAO,UAAU,KAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAkBxF,CAAA;AAEJ;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,MAAM,CAAC,MAAM,CAC1C,IAAI,EACJ,eAAe,EACf,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAUlD,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,QAAO,MAAM,CAAC,MAAM,CAC9C,WAAW,GAAG,IAAI,EAClB,eAAe,EACf,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CA6BlD,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,WAAW,KAClB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAkBxF,CAAA"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token storage for OAuth credentials.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import * as FileSystem from "@effect/platform/FileSystem";
|
|
7
|
+
import * as Path from "@effect/platform/Path";
|
|
8
|
+
import * as Context from "effect/Context";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import * as Layer from "effect/Layer";
|
|
11
|
+
import * as Schema from "effect/Schema";
|
|
12
|
+
import { FileSystemError } from "../ConfluenceError.js";
|
|
13
|
+
import { OAuthConfigSchema, OAuthTokenSchema } from "../Schemas.js";
|
|
14
|
+
const TOKEN_DIR_NAME = ".confluence";
|
|
15
|
+
const TOKEN_FILE_NAME = "auth.json";
|
|
16
|
+
const CONFIG_FILE_NAME = "config.json";
|
|
17
|
+
/**
|
|
18
|
+
* Tag for the HomeDirectory service.
|
|
19
|
+
*
|
|
20
|
+
* @category Services
|
|
21
|
+
*/
|
|
22
|
+
export class HomeDirectoryTag extends Context.Tag("@knpkv/confluence-to-markdown/HomeDirectory")() {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Default implementation using process.env.HOME.
|
|
26
|
+
*
|
|
27
|
+
* @category Layers
|
|
28
|
+
*/
|
|
29
|
+
export const HomeDirectoryLive = Layer.succeed(HomeDirectoryTag, {
|
|
30
|
+
get: () => Effect.sync(() => process.env.HOME ?? process.env.USERPROFILE ?? "/")
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Get the token directory path.
|
|
34
|
+
*/
|
|
35
|
+
const getTokenDir = () => Effect.gen(function* () {
|
|
36
|
+
const homeDir = yield* HomeDirectoryTag;
|
|
37
|
+
const path = yield* Path.Path;
|
|
38
|
+
const home = yield* homeDir.get();
|
|
39
|
+
return path.join(home, TOKEN_DIR_NAME);
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Get the token file path.
|
|
43
|
+
*/
|
|
44
|
+
const getTokenPath = () => Effect.gen(function* () {
|
|
45
|
+
const path = yield* Path.Path;
|
|
46
|
+
const tokenDir = yield* getTokenDir();
|
|
47
|
+
return path.join(tokenDir, TOKEN_FILE_NAME);
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Get the config file path.
|
|
51
|
+
*/
|
|
52
|
+
const getConfigPath = () => Effect.gen(function* () {
|
|
53
|
+
const path = yield* Path.Path;
|
|
54
|
+
const tokenDir = yield* getTokenDir();
|
|
55
|
+
return path.join(tokenDir, CONFIG_FILE_NAME);
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Load stored OAuth token from disk.
|
|
59
|
+
*
|
|
60
|
+
* @returns The stored token or null if not found/invalid
|
|
61
|
+
*
|
|
62
|
+
* @category Token Storage
|
|
63
|
+
*/
|
|
64
|
+
export const loadToken = () => Effect.gen(function* () {
|
|
65
|
+
const fs = yield* FileSystem.FileSystem;
|
|
66
|
+
const tokenPath = yield* getTokenPath();
|
|
67
|
+
const exists = yield* fs.exists(tokenPath).pipe(Effect.catchAll(() => Effect.succeed(false)));
|
|
68
|
+
if (!exists) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const content = yield* fs.readFileString(tokenPath).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "read", path: tokenPath, cause })));
|
|
72
|
+
let parsed;
|
|
73
|
+
try {
|
|
74
|
+
parsed = JSON.parse(content);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const decoded = yield* Schema.decodeUnknown(OAuthTokenSchema)(parsed).pipe(Effect.catchAll(() => Effect.succeed(null)));
|
|
80
|
+
return decoded;
|
|
81
|
+
});
|
|
82
|
+
/**
|
|
83
|
+
* Save OAuth token to disk with secure permissions.
|
|
84
|
+
*
|
|
85
|
+
* @param token - The token to save
|
|
86
|
+
*
|
|
87
|
+
* @category Token Storage
|
|
88
|
+
*/
|
|
89
|
+
export const saveToken = (token) => Effect.gen(function* () {
|
|
90
|
+
const fs = yield* FileSystem.FileSystem;
|
|
91
|
+
const tokenDir = yield* getTokenDir();
|
|
92
|
+
const tokenPath = yield* getTokenPath();
|
|
93
|
+
yield* fs.makeDirectory(tokenDir, { recursive: true }).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "mkdir", path: tokenDir, cause })));
|
|
94
|
+
yield* fs.writeFileString(tokenPath, JSON.stringify(token, null, 2)).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "write", path: tokenPath, cause })));
|
|
95
|
+
// Set secure permissions (owner only)
|
|
96
|
+
yield* fs.chmod(tokenPath, 0o600).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "write", path: tokenPath, cause })));
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Delete stored OAuth token.
|
|
100
|
+
*
|
|
101
|
+
* @category Token Storage
|
|
102
|
+
*/
|
|
103
|
+
export const deleteToken = () => Effect.gen(function* () {
|
|
104
|
+
const fs = yield* FileSystem.FileSystem;
|
|
105
|
+
const tokenPath = yield* getTokenPath();
|
|
106
|
+
yield* fs.remove(tokenPath).pipe(Effect.catchAll(() => Effect.void), Effect.mapError((cause) => new FileSystemError({ operation: "delete", path: tokenPath, cause })));
|
|
107
|
+
});
|
|
108
|
+
/**
|
|
109
|
+
* Load OAuth client configuration from disk.
|
|
110
|
+
*
|
|
111
|
+
* @returns The stored config or null if not found/invalid
|
|
112
|
+
*
|
|
113
|
+
* @category OAuth Config
|
|
114
|
+
*/
|
|
115
|
+
export const loadOAuthConfig = () => Effect.gen(function* () {
|
|
116
|
+
const fs = yield* FileSystem.FileSystem;
|
|
117
|
+
const configPath = yield* getConfigPath();
|
|
118
|
+
const exists = yield* fs.exists(configPath).pipe(Effect.catchAll(() => Effect.succeed(false)));
|
|
119
|
+
if (!exists) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const content = yield* fs.readFileString(configPath).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "read", path: configPath, cause })));
|
|
123
|
+
let parsed;
|
|
124
|
+
try {
|
|
125
|
+
parsed = JSON.parse(content);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const decoded = yield* Schema.decodeUnknown(OAuthConfigSchema)(parsed).pipe(Effect.catchAll(() => Effect.succeed(null)));
|
|
131
|
+
return decoded;
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* Save OAuth client configuration to disk with secure permissions.
|
|
135
|
+
*
|
|
136
|
+
* @param config - The config to save
|
|
137
|
+
*
|
|
138
|
+
* @category OAuth Config
|
|
139
|
+
*/
|
|
140
|
+
export const saveOAuthConfig = (config) => Effect.gen(function* () {
|
|
141
|
+
const fs = yield* FileSystem.FileSystem;
|
|
142
|
+
const tokenDir = yield* getTokenDir();
|
|
143
|
+
const configPath = yield* getConfigPath();
|
|
144
|
+
yield* fs.makeDirectory(tokenDir, { recursive: true }).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "mkdir", path: tokenDir, cause })));
|
|
145
|
+
yield* fs.writeFileString(configPath, JSON.stringify(config, null, 2)).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "write", path: configPath, cause })));
|
|
146
|
+
// Set secure permissions (owner only)
|
|
147
|
+
yield* fs.chmod(configPath, 0o600).pipe(Effect.mapError((cause) => new FileSystemError({ operation: "write", path: configPath, cause })));
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=tokenStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenStorage.js","sourceRoot":"","sources":["../../src/internal/tokenStorage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,UAAU,MAAM,6BAA6B,CAAA;AACzD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAoB,iBAAiB,EAAmB,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEtG,MAAM,cAAc,GAAG,aAAa,CAAA;AACpC,MAAM,eAAe,GAAG,WAAW,CAAA;AACnC,MAAM,gBAAgB,GAAG,aAAa,CAAA;AAYtC;;;;GAIG;AACH,MAAM,OAAO,gBAAiB,SA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,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CACzE,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CACjG,CAAA;IAED,sCAAsC;IACtC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,IAAI,CACrC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CACjG,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory cache for Atlassian user info.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import * as Context from "effect/Context";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
import type { AtlassianUser } from "../Schemas.js";
|
|
10
|
+
declare const UserCache_base: Context.TagClass<UserCache, "@knpkv/confluence-to-markdown/UserCache", {
|
|
11
|
+
/**
|
|
12
|
+
* Get user from cache, or fetch and cache if not present.
|
|
13
|
+
*/
|
|
14
|
+
readonly getOrFetch: (accountId: string, fetch: (accountId: string) => Effect.Effect<AtlassianUser, unknown>) => Effect.Effect<AtlassianUser, unknown>;
|
|
15
|
+
/**
|
|
16
|
+
* Get user from cache only (no fetch).
|
|
17
|
+
*/
|
|
18
|
+
readonly get: (accountId: string) => Effect.Effect<AtlassianUser | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Put user into cache.
|
|
21
|
+
*/
|
|
22
|
+
readonly put: (accountId: string, user: AtlassianUser) => Effect.Effect<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Clear the cache.
|
|
25
|
+
*/
|
|
26
|
+
readonly clear: () => Effect.Effect<void>;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* User cache service for caching Atlassian user lookups.
|
|
30
|
+
*
|
|
31
|
+
* @category Cache
|
|
32
|
+
*/
|
|
33
|
+
export declare class UserCache extends UserCache_base {
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Layer that provides UserCache.
|
|
37
|
+
*
|
|
38
|
+
* @category Layers
|
|
39
|
+
*/
|
|
40
|
+
export declare const UserCacheLayer: Layer.Layer<UserCache>;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=userCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"userCache.d.ts","sourceRoot":"","sources":["../../src/internal/userCache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;;IAU9C;;OAEG;yBACkB,CACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC,KAChE,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC;IAE1C;;OAEG;kBACW,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;IAE7E;;OAEG;kBACW,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IAE7E;;OAEG;oBACa,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;AA7B7C;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,cA0B5B;CAAG;AA0CN;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,SAAS,CAAiC,CAAA"}
|