toolcraft 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +77 -59
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +13 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.js +7 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +13 -0
- package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
- package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.js +26 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.js +27 -0
- package/node_modules/@poe-code/agent-defs/dist/types.d.ts +16 -0
- package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
- package/node_modules/@poe-code/agent-defs/package.json +20 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +5 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +552 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +58 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +46 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +31 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.js +140 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +72 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +73 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +45 -0
- package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
- package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +52 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +46 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +28 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +170 -0
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +156 -0
- package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
- package/node_modules/@poe-code/config-mutations/package.json +33 -0
- package/node_modules/@poe-code/file-lock/README.md +52 -0
- package/node_modules/@poe-code/file-lock/dist/index.d.ts +1 -0
- package/node_modules/@poe-code/file-lock/dist/index.js +1 -0
- package/node_modules/@poe-code/file-lock/dist/lock.d.ts +27 -0
- package/node_modules/@poe-code/file-lock/dist/lock.js +203 -0
- package/node_modules/@poe-code/file-lock/package.json +23 -0
- package/node_modules/auth-store/README.md +47 -0
- package/node_modules/auth-store/dist/create-secret-store.d.ts +2 -0
- package/node_modules/auth-store/dist/create-secret-store.js +35 -0
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +39 -0
- package/node_modules/auth-store/dist/encrypted-file-store.js +156 -0
- package/node_modules/auth-store/dist/index.d.ts +7 -0
- package/node_modules/auth-store/dist/index.js +4 -0
- package/node_modules/auth-store/dist/keychain-store.d.ts +22 -0
- package/node_modules/auth-store/dist/keychain-store.js +111 -0
- package/node_modules/auth-store/dist/provider-store.d.ts +10 -0
- package/node_modules/auth-store/dist/provider-store.js +28 -0
- package/node_modules/auth-store/dist/types.d.ts +20 -0
- package/node_modules/auth-store/dist/types.js +1 -0
- package/node_modules/auth-store/package.json +25 -0
- package/node_modules/mcp-oauth/README.md +31 -0
- package/node_modules/mcp-oauth/dist/client/auth-store-session-store.d.ts +14 -0
- package/node_modules/mcp-oauth/dist/client/auth-store-session-store.js +97 -0
- package/node_modules/mcp-oauth/dist/client/authorization-state.d.ts +8 -0
- package/node_modules/mcp-oauth/dist/client/authorization-state.js +34 -0
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.d.ts +3 -0
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +491 -0
- package/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +20 -0
- package/node_modules/mcp-oauth/dist/client/loopback-authorization.js +169 -0
- package/node_modules/mcp-oauth/dist/client/pkce.d.ts +2 -0
- package/node_modules/mcp-oauth/dist/client/pkce.js +7 -0
- package/node_modules/mcp-oauth/dist/client/token-endpoint.d.ts +40 -0
- package/node_modules/mcp-oauth/dist/client/token-endpoint.js +143 -0
- package/node_modules/mcp-oauth/dist/client/types.d.ts +113 -0
- package/node_modules/mcp-oauth/dist/client/types.js +1 -0
- package/node_modules/mcp-oauth/dist/index.d.ts +10 -0
- package/node_modules/mcp-oauth/dist/index.js +7 -0
- package/node_modules/mcp-oauth/dist/resource-indicator.d.ts +1 -0
- package/node_modules/mcp-oauth/dist/resource-indicator.js +11 -0
- package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.d.ts +27 -0
- package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +259 -0
- package/node_modules/mcp-oauth/dist/types.compile-check.d.ts +1 -0
- package/node_modules/mcp-oauth/dist/types.compile-check.js +22 -0
- package/node_modules/mcp-oauth/package.json +31 -0
- package/node_modules/tiny-mcp-client/.turbo/turbo-build.log +4 -0
- package/node_modules/tiny-mcp-client/dist/index.d.ts +2 -0
- package/node_modules/tiny-mcp-client/dist/index.js +1 -0
- package/node_modules/tiny-mcp-client/dist/internal.d.ts +547 -0
- package/node_modules/tiny-mcp-client/dist/internal.js +2404 -0
- package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.js +37 -0
- package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.js +50 -0
- package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.js +50 -0
- package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.js +51 -0
- package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.js +89 -0
- package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.js +56 -0
- package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.js +145 -0
- package/node_modules/tiny-mcp-client/dist/oauth-discovery.d.ts +24 -0
- package/node_modules/tiny-mcp-client/dist/oauth-discovery.js +385 -0
- package/node_modules/tiny-mcp-client/package.json +22 -0
- package/node_modules/tiny-mcp-client/src/http-oauth.integration.test.ts +823 -0
- package/node_modules/tiny-mcp-client/src/http-oauth.test.ts +882 -0
- package/node_modules/tiny-mcp-client/src/index.ts +94 -0
- package/node_modules/tiny-mcp-client/src/internal.ts +3566 -0
- package/node_modules/tiny-mcp-client/src/jsonrpc-types.compile-check.ts +66 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-http-transport.integration.test.ts +222 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-sdk.test.ts +1294 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-tiny-stdio-test-server-tools.test.ts +143 -0
- package/node_modules/tiny-mcp-client/src/mcp-lifecycle-types.compile-check.ts +65 -0
- package/node_modules/tiny-mcp-client/src/mcp-prompt-types.compile-check.ts +66 -0
- package/node_modules/tiny-mcp-client/src/mcp-resource-types.compile-check.ts +70 -0
- package/node_modules/tiny-mcp-client/src/mcp-tool-types.compile-check.ts +117 -0
- package/node_modules/tiny-mcp-client/src/mcp-transport-types.compile-check.ts +75 -0
- package/node_modules/tiny-mcp-client/src/mcp-utility-types.compile-check.ts +181 -0
- package/node_modules/tiny-mcp-client/src/mock-servers.test.ts +980 -0
- package/node_modules/tiny-mcp-client/src/oauth-discovery.ts +583 -0
- package/node_modules/tiny-mcp-client/src/transports.test.ts +8139 -0
- package/node_modules/tiny-mcp-client/src/utilities.test.ts +372 -0
- package/node_modules/tiny-mcp-client/tsconfig.json +11 -0
- package/package.json +24 -11
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function key(providerId) {
|
|
2
|
+
return `provider:${providerId}`;
|
|
3
|
+
}
|
|
4
|
+
export class MigratingSecretStore {
|
|
5
|
+
store;
|
|
6
|
+
legacyStore;
|
|
7
|
+
constructor(store, legacyStore = null) {
|
|
8
|
+
this.store = store;
|
|
9
|
+
this.legacyStore = legacyStore;
|
|
10
|
+
}
|
|
11
|
+
async get() {
|
|
12
|
+
const value = await this.store.get();
|
|
13
|
+
if (value !== null || !this.legacyStore) {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
const legacyValue = await this.legacyStore.get();
|
|
17
|
+
if (legacyValue !== null) {
|
|
18
|
+
await this.store.set(legacyValue);
|
|
19
|
+
}
|
|
20
|
+
return legacyValue;
|
|
21
|
+
}
|
|
22
|
+
async set(value) {
|
|
23
|
+
return this.store.set(value);
|
|
24
|
+
}
|
|
25
|
+
async delete() {
|
|
26
|
+
return this.store.delete();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EncryptedFileStoreInput } from "./encrypted-file-store.js";
|
|
2
|
+
import type { KeychainStoreInput } from "./keychain-store.js";
|
|
3
|
+
export interface SecretStore {
|
|
4
|
+
get(): Promise<string | null>;
|
|
5
|
+
set(value: string): Promise<void>;
|
|
6
|
+
delete(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export type StoreBackend = "file" | "keychain";
|
|
9
|
+
export interface CreateSecretStoreInput {
|
|
10
|
+
backend?: StoreBackend;
|
|
11
|
+
env?: NodeJS.ProcessEnv;
|
|
12
|
+
platform?: NodeJS.Platform;
|
|
13
|
+
backendEnvVar?: string;
|
|
14
|
+
fileStore?: EncryptedFileStoreInput;
|
|
15
|
+
keychainStore?: KeychainStoreInput;
|
|
16
|
+
}
|
|
17
|
+
export interface CreateSecretStoreResult {
|
|
18
|
+
store: SecretStore;
|
|
19
|
+
backend: StoreBackend;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "auth-store",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/poe-platform/poe-code.git",
|
|
23
|
+
"directory": "packages/auth-store"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# mcp-oauth
|
|
2
|
+
|
|
3
|
+
OAuth client primitives for MCP HTTP transports.
|
|
4
|
+
|
|
5
|
+
## Config
|
|
6
|
+
|
|
7
|
+
`createDefaultOAuthClientProvider(options)` accepts:
|
|
8
|
+
|
|
9
|
+
- `client`
|
|
10
|
+
- `mode: "dynamic"` with optional `metadata`
|
|
11
|
+
- `mode: "static"` with `clientId`, optional `clientSecret`, optional `metadata`
|
|
12
|
+
- `browser.openBrowser(url)`
|
|
13
|
+
- `browser.readLine()` optional
|
|
14
|
+
- `browser.createServer()` optional
|
|
15
|
+
- `browser.landingPage` optional
|
|
16
|
+
- `sessionStore` optional
|
|
17
|
+
- `authStore` optional `auth-store` backend config for the default session store
|
|
18
|
+
- `now()` optional clock override
|
|
19
|
+
|
|
20
|
+
`createJwksTokenVerifier(options)` accepts:
|
|
21
|
+
|
|
22
|
+
- `jwksUrl`
|
|
23
|
+
- `clockSkewSeconds` optional, defaults to `30`
|
|
24
|
+
- `allowedAlgorithms` optional asymmetric allow-list
|
|
25
|
+
- `fetch` optional override
|
|
26
|
+
|
|
27
|
+
`createAuthStoreSessionStore(options)` accepts the standard `auth-store` config.
|
|
28
|
+
|
|
29
|
+
## Environment Variables
|
|
30
|
+
|
|
31
|
+
None directly. When `authStore` is used, `auth-store` honors its own backend env var configuration.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CreateSecretStoreInput } from "auth-store";
|
|
2
|
+
import type { OAuthSessionStore } from "./types.js";
|
|
3
|
+
interface StoredOAuthClient {
|
|
4
|
+
clientId: string;
|
|
5
|
+
clientSecret?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface OAuthClientStore {
|
|
8
|
+
load(issuer: string): Promise<StoredOAuthClient | null>;
|
|
9
|
+
save(issuer: string, client: StoredOAuthClient): Promise<void>;
|
|
10
|
+
clear(issuer: string): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare function createAuthStoreSessionStore(options?: CreateSecretStoreInput): OAuthSessionStore;
|
|
13
|
+
export declare function createAuthStoreClientStore(options: CreateSecretStoreInput): OAuthClientStore;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createSecretStore, } from "auth-store";
|
|
4
|
+
import { canonicalizeResourceIndicator } from "../resource-indicator.js";
|
|
5
|
+
const DEFAULT_FILE_SALT = "poe-code:mcp-oauth:v1";
|
|
6
|
+
const DEFAULT_FILE_DIRECTORY = ".poe-code/mcp-oauth";
|
|
7
|
+
const DEFAULT_KEYCHAIN_SERVICE = "poe-code-mcp-oauth";
|
|
8
|
+
const DEFAULT_CLIENT_FILE_SALT = "poe-code:mcp-oauth:clients:v1";
|
|
9
|
+
const DEFAULT_CLIENT_FILE_DIRECTORY = ".poe-code/mcp-oauth/clients";
|
|
10
|
+
const DEFAULT_CLIENT_KEYCHAIN_SERVICE = "poe-code-mcp-oauth-clients";
|
|
11
|
+
export function createAuthStoreSessionStore(options = {}) {
|
|
12
|
+
return {
|
|
13
|
+
async load(resource) {
|
|
14
|
+
const store = createResourceSecretStore(resource, options);
|
|
15
|
+
const value = await store.get();
|
|
16
|
+
if (value === null) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const parsed = JSON.parse(value);
|
|
20
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
21
|
+
return parsed;
|
|
22
|
+
}
|
|
23
|
+
throw new Error("Stored OAuth session must be a JSON object");
|
|
24
|
+
},
|
|
25
|
+
async save(resource, session) {
|
|
26
|
+
const store = createResourceSecretStore(resource, options);
|
|
27
|
+
await store.set(JSON.stringify(session));
|
|
28
|
+
},
|
|
29
|
+
async clear(resource) {
|
|
30
|
+
const store = createResourceSecretStore(resource, options);
|
|
31
|
+
await store.delete();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function createAuthStoreClientStore(options) {
|
|
36
|
+
return {
|
|
37
|
+
async load(issuer) {
|
|
38
|
+
const store = createIssuerSecretStore(issuer, options);
|
|
39
|
+
const value = await store.get();
|
|
40
|
+
if (value === null) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const parsed = JSON.parse(value);
|
|
44
|
+
if (typeof parsed === "object"
|
|
45
|
+
&& parsed !== null
|
|
46
|
+
&& !Array.isArray(parsed)
|
|
47
|
+
&& typeof parsed.clientId === "string") {
|
|
48
|
+
return parsed;
|
|
49
|
+
}
|
|
50
|
+
throw new Error("Stored OAuth client must be a JSON object with clientId");
|
|
51
|
+
},
|
|
52
|
+
async save(issuer, client) {
|
|
53
|
+
const store = createIssuerSecretStore(issuer, options);
|
|
54
|
+
await store.set(JSON.stringify(client));
|
|
55
|
+
},
|
|
56
|
+
async clear(issuer) {
|
|
57
|
+
const store = createIssuerSecretStore(issuer, options);
|
|
58
|
+
await store.delete();
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function createNamedSecretStore(key, options, defaults) {
|
|
63
|
+
const hash = crypto.createHash("sha256").update(key).digest("hex");
|
|
64
|
+
const parsedFilePath = options.fileStore?.filePath === undefined ? null : path.parse(options.fileStore.filePath);
|
|
65
|
+
const fileStore = {
|
|
66
|
+
...options.fileStore,
|
|
67
|
+
salt: options.fileStore?.salt ?? defaults.salt,
|
|
68
|
+
defaultDirectory: parsedFilePath?.dir ||
|
|
69
|
+
options.fileStore?.defaultDirectory ||
|
|
70
|
+
defaults.directory,
|
|
71
|
+
defaultFileName: parsedFilePath === null
|
|
72
|
+
? `${hash}.enc`
|
|
73
|
+
: `${parsedFilePath.name}-${hash}${parsedFilePath.ext || ".enc"}`,
|
|
74
|
+
};
|
|
75
|
+
const keychainStore = {
|
|
76
|
+
...options.keychainStore,
|
|
77
|
+
service: options.keychainStore?.service ?? defaults.service,
|
|
78
|
+
account: `${options.keychainStore?.account ?? defaults.accountPrefix}:${hash}`,
|
|
79
|
+
};
|
|
80
|
+
return createSecretStore({ ...options, fileStore, keychainStore }).store;
|
|
81
|
+
}
|
|
82
|
+
function createResourceSecretStore(resource, options) {
|
|
83
|
+
return createNamedSecretStore(canonicalizeResourceIndicator(resource), options, {
|
|
84
|
+
salt: DEFAULT_FILE_SALT,
|
|
85
|
+
directory: DEFAULT_FILE_DIRECTORY,
|
|
86
|
+
service: DEFAULT_KEYCHAIN_SERVICE,
|
|
87
|
+
accountPrefix: "provider",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function createIssuerSecretStore(issuer, options) {
|
|
91
|
+
return createNamedSecretStore(issuer, options, {
|
|
92
|
+
salt: DEFAULT_CLIENT_FILE_SALT,
|
|
93
|
+
directory: DEFAULT_CLIENT_FILE_DIRECTORY,
|
|
94
|
+
service: DEFAULT_CLIENT_KEYCHAIN_SERVICE,
|
|
95
|
+
accountPrefix: "issuer",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
export function createAuthorizationState(input) {
|
|
3
|
+
const payload = {
|
|
4
|
+
v: 1,
|
|
5
|
+
n: crypto.randomBytes(16).toString("base64url"),
|
|
6
|
+
i: input.issuer,
|
|
7
|
+
r: input.requireIssuer,
|
|
8
|
+
};
|
|
9
|
+
return Buffer.from(JSON.stringify(payload), "utf8").toString("base64url");
|
|
10
|
+
}
|
|
11
|
+
export function parseAuthorizationState(value) {
|
|
12
|
+
if (value === null || value.length === 0) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const decoded = Buffer.from(value, "base64url").toString("utf8");
|
|
17
|
+
const parsed = JSON.parse(decoded);
|
|
18
|
+
if (parsed.v !== 1
|
|
19
|
+
|| typeof parsed.n !== "string"
|
|
20
|
+
|| parsed.n.length === 0
|
|
21
|
+
|| typeof parsed.i !== "string"
|
|
22
|
+
|| parsed.i.length === 0
|
|
23
|
+
|| typeof parsed.r !== "boolean") {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
issuer: parsed.i,
|
|
28
|
+
requireIssuer: parsed.r,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DefaultOAuthClientProviderOptions, OAuthClientProvider, OAuthClientProviderOptions } from "./types.js";
|
|
2
|
+
export declare function createOAuthClientProvider(options: OAuthClientProviderOptions): OAuthClientProvider;
|
|
3
|
+
export declare function createDefaultOAuthClientProvider(options: DefaultOAuthClientProviderOptions): OAuthClientProvider;
|