hmcp-gateway 0.0.2 → 0.1.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/LICENSE +77 -0
- package/README.md +41 -9
- package/bin/hmcp-gateway.js +20 -0
- package/catalog/atlassian.yaml +41 -0
- package/catalog/brave-search.yaml +57 -0
- package/catalog/context7.yaml +42 -0
- package/catalog/fetch.yaml +37 -0
- package/catalog/figma.yaml +48 -0
- package/catalog/filesystem.yaml +48 -0
- package/catalog/git.yaml +48 -0
- package/catalog/github.yaml +103 -0
- package/catalog/huggingface.yaml +59 -0
- package/catalog/linear.yaml +47 -0
- package/catalog/memory.yaml +47 -0
- package/catalog/notion.yaml +41 -0
- package/catalog/playwright.yaml +38 -0
- package/catalog/postgres.yaml +66 -0
- package/catalog/sentry.yaml +39 -0
- package/catalog/sequential-thinking.yaml +29 -0
- package/catalog/stripe.yaml +41 -0
- package/catalog/supabase.yaml +45 -0
- package/catalog/time.yaml +49 -0
- package/dist/adopt-cli.d.ts +351 -0
- package/dist/adopt-cli.js +1857 -0
- package/dist/adopt-emit.d.ts +64 -0
- package/dist/adopt-emit.js +248 -0
- package/dist/adopt-plan.d.ts +108 -0
- package/dist/adopt-plan.js +386 -0
- package/dist/catalog.d.ts +140 -0
- package/dist/catalog.js +250 -0
- package/dist/classify.d.ts +23 -0
- package/dist/classify.js +47 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +535 -0
- package/dist/client-allow.d.ts +42 -0
- package/dist/client-allow.js +95 -0
- package/dist/client-config.d.ts +200 -0
- package/dist/client-config.js +784 -0
- package/dist/config-source.d.ts +106 -0
- package/dist/config-source.js +156 -0
- package/dist/config.d.ts +159 -0
- package/dist/config.js +330 -0
- package/dist/connect-client.d.ts +49 -0
- package/dist/connect-client.js +249 -0
- package/dist/contracts.d.ts +251 -0
- package/dist/contracts.js +9 -0
- package/dist/credential.d.ts +63 -0
- package/dist/credential.js +136 -0
- package/dist/draft.d.ts +71 -0
- package/dist/draft.js +596 -0
- package/dist/exposure-cli.d.ts +28 -0
- package/dist/exposure-cli.js +119 -0
- package/dist/gateway.d.ts +756 -0
- package/dist/gateway.js +2106 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +26 -0
- package/dist/notify.d.ts +44 -0
- package/dist/notify.js +93 -0
- package/dist/oauth.d.ts +139 -0
- package/dist/oauth.js +641 -0
- package/dist/observe.d.ts +10 -0
- package/dist/observe.js +26 -0
- package/dist/open.d.ts +24 -0
- package/dist/open.js +31 -0
- package/dist/packs.d.ts +119 -0
- package/dist/packs.js +131 -0
- package/dist/pin-cli.d.ts +28 -0
- package/dist/pin-cli.js +103 -0
- package/dist/probe-upstream.d.ts +31 -0
- package/dist/probe-upstream.js +377 -0
- package/dist/registry-map.d.ts +39 -0
- package/dist/registry-map.js +390 -0
- package/dist/rule-cli.d.ts +51 -0
- package/dist/rule-cli.js +412 -0
- package/dist/serve-http.d.ts +67 -0
- package/dist/serve-http.js +478 -0
- package/dist/snippet.d.ts +20 -0
- package/dist/snippet.js +826 -0
- package/dist/status-cli.d.ts +61 -0
- package/dist/status-cli.js +195 -0
- package/dist/suggest-cli.d.ts +43 -0
- package/dist/suggest-cli.js +279 -0
- package/dist/toolname.d.ts +47 -0
- package/dist/toolname.js +149 -0
- package/dist/upstream-errors.d.ts +54 -0
- package/dist/upstream-errors.js +330 -0
- package/dist/upstream.d.ts +128 -0
- package/dist/upstream.js +413 -0
- package/dist/version.d.ts +10 -0
- package/dist/version.js +11 -0
- package/package.json +50 -6
- package/packs/brave-search.yaml +20 -0
- package/packs/context7.yaml +13 -0
- package/packs/fetch.yaml +14 -0
- package/packs/filesystem.yaml +79 -0
- package/packs/git.yaml +29 -0
- package/packs/github.yaml +47 -0
- package/packs/huggingface.yaml +16 -0
- package/packs/memory.yaml +23 -0
- package/packs/playwright.yaml +41 -0
- package/packs/sequential-thinking.yaml +13 -0
- package/packs/time.yaml +14 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from "./config.js";
|
|
2
|
+
export * from "./classify.js";
|
|
3
|
+
export * from "./upstream.js";
|
|
4
|
+
export * from "./gateway.js";
|
|
5
|
+
export * from "./credential.js";
|
|
6
|
+
export * from "./serve-http.js";
|
|
7
|
+
export * from "./client-config.js";
|
|
8
|
+
export * from "./adopt-plan.js";
|
|
9
|
+
export * from "./adopt-emit.js";
|
|
10
|
+
export * from "./open.js";
|
|
11
|
+
export * from "./client-allow.js";
|
|
12
|
+
export * from "./notify.js";
|
|
13
|
+
export * from "./adopt-cli.js";
|
|
14
|
+
export { buildSuggestion, type Suggestion, type SuggestedRule, type ToolObservation } from "./suggest-cli.js";
|
|
15
|
+
export { gatewayStatus, type GatewayStatus } from "./status-cli.js";
|
|
16
|
+
export * from "./contracts.js";
|
|
17
|
+
export * from "./catalog.js";
|
|
18
|
+
export * from "./draft.js";
|
|
19
|
+
export * from "./registry-map.js";
|
|
20
|
+
export * from "./snippet.js";
|
|
21
|
+
export * from "./upstream-errors.js";
|
|
22
|
+
export * from "./oauth.js";
|
|
23
|
+
export * from "./probe-upstream.js";
|
|
24
|
+
export * from "./connect-client.js";
|
|
25
|
+
export { configTextDigest, diffUpstreams } from "./config-source.js";
|
|
26
|
+
export { applyPack, loadPacks, type Pack, type PackRuleOut } from "./packs.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from "./config.js";
|
|
2
|
+
export * from "./classify.js";
|
|
3
|
+
export * from "./upstream.js";
|
|
4
|
+
export * from "./gateway.js";
|
|
5
|
+
export * from "./credential.js";
|
|
6
|
+
export * from "./serve-http.js";
|
|
7
|
+
export * from "./client-config.js";
|
|
8
|
+
export * from "./adopt-plan.js";
|
|
9
|
+
export * from "./adopt-emit.js";
|
|
10
|
+
export * from "./open.js";
|
|
11
|
+
export * from "./client-allow.js";
|
|
12
|
+
export * from "./notify.js";
|
|
13
|
+
export * from "./adopt-cli.js";
|
|
14
|
+
export { buildSuggestion } from "./suggest-cli.js";
|
|
15
|
+
export { gatewayStatus } from "./status-cli.js";
|
|
16
|
+
export * from "./contracts.js";
|
|
17
|
+
export * from "./catalog.js";
|
|
18
|
+
export * from "./draft.js";
|
|
19
|
+
export * from "./registry-map.js";
|
|
20
|
+
export * from "./snippet.js";
|
|
21
|
+
export * from "./upstream-errors.js";
|
|
22
|
+
export * from "./oauth.js";
|
|
23
|
+
export * from "./probe-upstream.js";
|
|
24
|
+
export * from "./connect-client.js";
|
|
25
|
+
export { configTextDigest, diffUpstreams } from "./config-source.js";
|
|
26
|
+
export { applyPack, loadPacks } from "./packs.js";
|
package/dist/notify.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telling the person at the machine that a call is waiting for them.
|
|
3
|
+
*
|
|
4
|
+
* A parked call is silent by default: the agent is told to wait, and the
|
|
5
|
+
* person finds out when they notice the agent has stopped. One desktop
|
|
6
|
+
* notification, carrying the command that releases the call, closes that gap.
|
|
7
|
+
*
|
|
8
|
+
* Everything here is best effort, and built so that it cannot be more than
|
|
9
|
+
* that. No notifier installed, no display, a platform this does not know: the
|
|
10
|
+
* call is still parked and still approvable, and the gateway carries on.
|
|
11
|
+
*
|
|
12
|
+
* The text shown comes partly from a tool name, which an upstream chose. So
|
|
13
|
+
* it is never written into a script. Each platform's script is a constant;
|
|
14
|
+
* the text travels beside it as an argument or an environment variable, where
|
|
15
|
+
* the worst a hostile name can do is look odd in a notification.
|
|
16
|
+
*/
|
|
17
|
+
export interface ParkedNotice {
|
|
18
|
+
readonly tool: string;
|
|
19
|
+
readonly approvalId: string;
|
|
20
|
+
}
|
|
21
|
+
export interface NotificationCommand {
|
|
22
|
+
readonly command: string;
|
|
23
|
+
readonly args: readonly string[];
|
|
24
|
+
/** Extra environment for the process, where the text is passed that way. */
|
|
25
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
26
|
+
}
|
|
27
|
+
/** The command that shows the notification on this platform, or undefined where there is none. */
|
|
28
|
+
export declare function notificationCommand(platform: string, notice: ParkedNotice): NotificationCommand | undefined;
|
|
29
|
+
export interface NotifierOptions {
|
|
30
|
+
readonly platform?: string;
|
|
31
|
+
/** Starts the command. Replaced in tests; must not be relied on to succeed. */
|
|
32
|
+
readonly spawn?: (command: string, args: readonly string[], env?: Readonly<Record<string, string>>) => void;
|
|
33
|
+
readonly now?: () => number;
|
|
34
|
+
/** The shortest gap between two notifications. */
|
|
35
|
+
readonly minIntervalMs?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A function that announces a parked call.
|
|
39
|
+
*
|
|
40
|
+
* Throttled, because held calls come in bursts and a stack of notifications
|
|
41
|
+
* is its own kind of noise: the first one already says how to see everything
|
|
42
|
+
* that is waiting.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createNotifier(options?: NotifierOptions): (notice: ParkedNotice) => void;
|
package/dist/notify.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { spawn as nodeSpawn } from "node:child_process";
|
|
2
|
+
const TITLE = "hmcp-gateway: approval needed";
|
|
3
|
+
/** One line, no control characters, short enough for a notification. */
|
|
4
|
+
function clean(text, max) {
|
|
5
|
+
// eslint-disable-next-line no-control-regex
|
|
6
|
+
const flat = text.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g, " ").trim();
|
|
7
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* What is shown. The tool and the command, and deliberately not the
|
|
11
|
+
* arguments: a notification is drawn over whatever else is on the screen.
|
|
12
|
+
*/
|
|
13
|
+
function bodyOf(notice) {
|
|
14
|
+
return (`Your AI is waiting for your OK: ${clean(notice.tool, 80)}. ` +
|
|
15
|
+
`Open the hardened-mcp console, then Waiting for you.`);
|
|
16
|
+
}
|
|
17
|
+
const WINDOWS_SCRIPT = [
|
|
18
|
+
"[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] | Out-Null",
|
|
19
|
+
"$t = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)",
|
|
20
|
+
"$n = $t.GetElementsByTagName('text')",
|
|
21
|
+
"$n.Item(0).AppendChild($t.CreateTextNode($env:HMCP_NOTIFY_TITLE)) | Out-Null",
|
|
22
|
+
"$n.Item(1).AppendChild($t.CreateTextNode($env:HMCP_NOTIFY_BODY)) | Out-Null",
|
|
23
|
+
"[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('hmcp-gateway').Show([Windows.UI.Notifications.ToastNotification]::new($t))"
|
|
24
|
+
].join("; ");
|
|
25
|
+
/** The command that shows the notification on this platform, or undefined where there is none. */
|
|
26
|
+
export function notificationCommand(platform, notice) {
|
|
27
|
+
const body = bodyOf(notice);
|
|
28
|
+
switch (platform) {
|
|
29
|
+
case "darwin":
|
|
30
|
+
return {
|
|
31
|
+
command: "osascript",
|
|
32
|
+
// `on run argv` hands the trailing arguments to the script as data.
|
|
33
|
+
args: [
|
|
34
|
+
"-e",
|
|
35
|
+
"on run argv",
|
|
36
|
+
"-e",
|
|
37
|
+
"display notification (item 1 of argv) with title (item 2 of argv)",
|
|
38
|
+
"-e",
|
|
39
|
+
"end run",
|
|
40
|
+
body,
|
|
41
|
+
TITLE
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
case "linux":
|
|
45
|
+
return { command: "notify-send", args: ["--app-name=hmcp-gateway", TITLE, body] };
|
|
46
|
+
case "win32":
|
|
47
|
+
return {
|
|
48
|
+
command: "powershell.exe",
|
|
49
|
+
args: ["-NoProfile", "-NonInteractive", "-Command", WINDOWS_SCRIPT],
|
|
50
|
+
env: { HMCP_NOTIFY_TITLE: TITLE, HMCP_NOTIFY_BODY: body }
|
|
51
|
+
};
|
|
52
|
+
default:
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function spawnDetached(command, args, env) {
|
|
57
|
+
const child = nodeSpawn(command, [...args], {
|
|
58
|
+
stdio: "ignore",
|
|
59
|
+
detached: true,
|
|
60
|
+
env: { ...process.env, ...(env ?? {}) }
|
|
61
|
+
});
|
|
62
|
+
// A missing notifier is reported as an 'error' event, not a throw.
|
|
63
|
+
child.on("error", () => undefined);
|
|
64
|
+
child.unref();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A function that announces a parked call.
|
|
68
|
+
*
|
|
69
|
+
* Throttled, because held calls come in bursts and a stack of notifications
|
|
70
|
+
* is its own kind of noise: the first one already says how to see everything
|
|
71
|
+
* that is waiting.
|
|
72
|
+
*/
|
|
73
|
+
export function createNotifier(options = {}) {
|
|
74
|
+
const platform = options.platform ?? process.platform;
|
|
75
|
+
const spawn = options.spawn ?? spawnDetached;
|
|
76
|
+
const now = options.now ?? Date.now;
|
|
77
|
+
const minInterval = options.minIntervalMs ?? 5000;
|
|
78
|
+
let last = Number.NEGATIVE_INFINITY;
|
|
79
|
+
return (notice) => {
|
|
80
|
+
try {
|
|
81
|
+
const command = notificationCommand(platform, notice);
|
|
82
|
+
if (!command)
|
|
83
|
+
return;
|
|
84
|
+
if (now() - last < minInterval)
|
|
85
|
+
return;
|
|
86
|
+
last = now();
|
|
87
|
+
spawn(command.command, command.args, command.env);
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
/* best effort: the call is parked and approvable whether or not this worked */
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
package/dist/oauth.d.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { EgressGuard, type OAuthClientRegistration, type OAuthServerMetadata, type SecretStore } from "hmcp-core";
|
|
2
|
+
import { type UpstreamTokenSource } from "./contracts.js";
|
|
3
|
+
export interface Discovered {
|
|
4
|
+
/** The protected resource (RFC 9728) -- the MCP server, canonicalised. */
|
|
5
|
+
resource: string;
|
|
6
|
+
authorizationServer: string;
|
|
7
|
+
metadata: OAuthServerMetadata;
|
|
8
|
+
scopes?: string[];
|
|
9
|
+
/** PKCE methods the server advertised, if it said; S256 is all we send. */
|
|
10
|
+
codeChallengeMethods?: string[];
|
|
11
|
+
/** Response types the server advertised; "code" is required. */
|
|
12
|
+
responseTypes?: string[];
|
|
13
|
+
}
|
|
14
|
+
export declare class NoDynamicRegistration extends Error {
|
|
15
|
+
readonly authorizationServer: string;
|
|
16
|
+
constructor(authorizationServer: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A sign-in step that failed for a reason worth telling apart. `code` is for
|
|
20
|
+
* the console to choose its words; `message` is already plain and never
|
|
21
|
+
* carries a token, a code or a secret.
|
|
22
|
+
*/
|
|
23
|
+
export type SignInProblemCode = "not-oauth" | "discovery" | "unsafe" | "denied" | "state" | "rejected";
|
|
24
|
+
export declare class SignInProblem extends Error {
|
|
25
|
+
readonly code: SignInProblemCode;
|
|
26
|
+
readonly oauthError?: string | undefined;
|
|
27
|
+
readonly detail?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* `message` is the plain sentence a person reads. `detail` carries the
|
|
30
|
+
* technical reason (a library's own words, the address refused) for
|
|
31
|
+
* support; it is never shown as the main text.
|
|
32
|
+
*/
|
|
33
|
+
constructor(code: SignInProblemCode, message: string, oauthError?: string | undefined, detail?: string | undefined);
|
|
34
|
+
}
|
|
35
|
+
export type FetchLike = (url: string | URL, init?: RequestInit) => Promise<Response>;
|
|
36
|
+
/**
|
|
37
|
+
* A fetch for the SDK's auth helpers that goes through `guard` and refuses redirects.
|
|
38
|
+
*
|
|
39
|
+
* The SDK calls fetch with `Headers` objects and `URLSearchParams` bodies; the
|
|
40
|
+
* guard takes plain records and strings, so both are converted here, and a
|
|
41
|
+
* form body gets its content type if the caller did not set one.
|
|
42
|
+
*
|
|
43
|
+
* Redirects are refused outright, whatever the guard's own `max_redirects`
|
|
44
|
+
* says: a token endpoint that answers with a redirect is asking for the code
|
|
45
|
+
* or refresh token to be re-sent somewhere else, and nothing in OAuth needs a
|
|
46
|
+
* back-channel request to follow one.
|
|
47
|
+
*/
|
|
48
|
+
export declare function egressFetchLike(guard: EgressGuard): FetchLike;
|
|
49
|
+
/**
|
|
50
|
+
* Checks for an address discovery found, applied the moment it is found --
|
|
51
|
+
* before anything is sent to it, and before it is shown to anyone.
|
|
52
|
+
*/
|
|
53
|
+
export interface DiscoverOptions {
|
|
54
|
+
/**
|
|
55
|
+
* The caller's own check (the console passes its sign-in guard's). Throw
|
|
56
|
+
* to refuse; a SignInProblem is passed on as it is.
|
|
57
|
+
*/
|
|
58
|
+
checkAddress?: (url: URL, what: string) => void | Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Protected resource metadata (RFC 9728), then the authorization server's own
|
|
62
|
+
* (RFC 8414, with the OIDC fallback the SDK implements).
|
|
63
|
+
*
|
|
64
|
+
* The resource the server claims is checked against the URL we were given:
|
|
65
|
+
* otherwise a server could have us ask for a token meant for some other
|
|
66
|
+
* service, and the token would be handed to it on the next request.
|
|
67
|
+
*/
|
|
68
|
+
export declare function discover(serverUrl: string, fetchFn: FetchLike, options?: DiscoverOptions): Promise<Discovered>;
|
|
69
|
+
/**
|
|
70
|
+
* Dynamic client registration (RFC 7591). A public client ("none") whenever
|
|
71
|
+
* the provider allows it: there is no server-side place to keep a client
|
|
72
|
+
* secret, and PKCE is what protects the code.
|
|
73
|
+
*/
|
|
74
|
+
export declare function register(d: Discovered, redirectUri: string, fetchFn: FetchLike, clientName?: string): Promise<OAuthClientRegistration>;
|
|
75
|
+
/** A fresh `state`: 32 random bytes, so it cannot be guessed or replayed. */
|
|
76
|
+
export declare function newState(): string;
|
|
77
|
+
export interface Begun {
|
|
78
|
+
authorizeUrl: string;
|
|
79
|
+
codeVerifier: string;
|
|
80
|
+
state: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The page to send the person to. PKCE S256 always (the SDK sends nothing
|
|
84
|
+
* else), the caller's `state`, and the RFC 8707 `resource` always, so the
|
|
85
|
+
* token is bound to this server and useless anywhere else.
|
|
86
|
+
*/
|
|
87
|
+
export declare function begin(d: Discovered, client: OAuthClientRegistration, redirectUri: string, state: string): Promise<Begun>;
|
|
88
|
+
/**
|
|
89
|
+
* The code from a callback URL, once its `state` is checked. A provider
|
|
90
|
+
* error (the person pressed Cancel) and a state that is not ours both throw.
|
|
91
|
+
*/
|
|
92
|
+
export declare function readCallback(callbackUrl: string | URL, expectedState: string): string;
|
|
93
|
+
/** The OAuth error code of an SDK failure, if it was one. */
|
|
94
|
+
export declare function oauthErrorCode(err: unknown): string | undefined;
|
|
95
|
+
/** Exchange the code and store the `oauth` entry under `secretName`. */
|
|
96
|
+
export declare function complete(args: {
|
|
97
|
+
d: Discovered;
|
|
98
|
+
client: OAuthClientRegistration;
|
|
99
|
+
code: string;
|
|
100
|
+
codeVerifier: string;
|
|
101
|
+
redirectUri: string;
|
|
102
|
+
serverUrl: string;
|
|
103
|
+
secretName: string;
|
|
104
|
+
label?: string;
|
|
105
|
+
}, store: SecretStore, fetchFn: FetchLike): Promise<void>;
|
|
106
|
+
export interface TokenSourceOptions {
|
|
107
|
+
/** Refresh when the token expires within this many ms. Default 60s. */
|
|
108
|
+
skewMs?: number;
|
|
109
|
+
/**
|
|
110
|
+
* After an invalid_grant, how long to watch the file for another process's
|
|
111
|
+
* rotation before deciding the sign-in really is gone. Default 2s.
|
|
112
|
+
*/
|
|
113
|
+
rotationWaitMs?: number;
|
|
114
|
+
now?: () => number;
|
|
115
|
+
/**
|
|
116
|
+
* The upstream URL this source serves. A sign-in saved for any other server
|
|
117
|
+
* is refused, so a name reused for a different server never sends that
|
|
118
|
+
* server's token here.
|
|
119
|
+
*/
|
|
120
|
+
expectedUrl?: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The gateway's token source for an upstream configured with `oauth: { secret }`.
|
|
124
|
+
*
|
|
125
|
+
* Several gateway processes (one per AI app) share one sign-in, and a refresh
|
|
126
|
+
* token that rotates can be spent only once. The file lock is synchronous and
|
|
127
|
+
* a refresh is a network call, so the lock cannot be held across it. Instead:
|
|
128
|
+
*
|
|
129
|
+
* 1. Re-read under the lock first. If another process has already refreshed,
|
|
130
|
+
* its token is used and nothing is spent.
|
|
131
|
+
* 2. Otherwise refresh, and write the new pair under the lock.
|
|
132
|
+
* 3. If the provider says the refresh token is no good, that may only mean
|
|
133
|
+
* another process spent it a moment earlier. Watch the file briefly; if a
|
|
134
|
+
* newer pair appears, use it. Only if none does is the sign-in marked
|
|
135
|
+
* as needing a person.
|
|
136
|
+
*
|
|
137
|
+
* Within one process, concurrent callers share one refresh.
|
|
138
|
+
*/
|
|
139
|
+
export declare function oauthTokenSource(secretName: string, store: SecretStore, fetchFn: FetchLike, options?: TokenSourceOptions): UpstreamTokenSource;
|