synomem 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +47 -68
- package/dist/backend.d.ts +18 -6
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +55 -41
- package/dist/backend.js.map +1 -1
- package/dist/cli.d.ts +20 -33
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1391 -1321
- package/dist/cli.js.map +1 -1
- package/dist/configure.d.ts +12 -46
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +51 -192
- package/dist/configure.js.map +1 -1
- package/dist/credentials.d.ts +73 -33
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +167 -43
- package/dist/credentials.js.map +1 -1
- package/dist/discover.d.ts +8 -35
- package/dist/discover.d.ts.map +1 -1
- package/dist/discover.js +42 -38
- package/dist/discover.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -1
- package/dist/import.d.ts +3 -0
- package/dist/import.d.ts.map +1 -1
- package/dist/import.js +3 -0
- package/dist/import.js.map +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +18 -18
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +402 -231
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp-server.d.ts +5 -1
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +27 -105
- package/dist/mcp-server.js.map +1 -1
- package/dist/oauth.d.ts +31 -33
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +178 -125
- package/dist/oauth.js.map +1 -1
- package/dist/profiles.d.ts +243 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +465 -0
- package/dist/profiles.js.map +1 -0
- package/dist/project.d.ts +8 -39
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +36 -94
- package/dist/project.js.map +1 -1
- package/dist/remote.d.ts +24 -17
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +54 -52
- package/dist/remote.js.map +1 -1
- package/dist/resolvers.d.ts +47 -0
- package/dist/resolvers.d.ts.map +1 -0
- package/dist/resolvers.js +255 -0
- package/dist/resolvers.js.map +1 -0
- package/dist/service.d.ts +3 -2
- package/dist/service.d.ts.map +1 -1
- package/dist/skill-install.d.ts +4 -6
- package/dist/skill-install.d.ts.map +1 -1
- package/dist/skill-install.js +13 -12
- package/dist/skill-install.js.map +1 -1
- package/dist/types.d.ts +45 -15
- package/dist/types.d.ts.map +1 -1
- package/docs/cli.md +173 -196
- package/docs/mcp.md +69 -65
- package/package.json +1 -1
- package/skills/synomem/SKILL.md +29 -26
- package/skills/synomem/references/examples.md +13 -11
- package/src/backend.ts +66 -64
- package/src/cli.ts +2131 -2222
- package/src/configure.ts +62 -241
- package/src/credentials.ts +208 -84
- package/src/discover.ts +53 -59
- package/src/errors.ts +4 -0
- package/src/import.ts +5 -0
- package/src/index.ts +15 -19
- package/src/mcp/index.ts +473 -277
- package/src/mcp-server.ts +32 -114
- package/src/oauth.ts +229 -130
- package/src/profiles.ts +644 -0
- package/src/project.ts +42 -108
- package/src/remote.ts +69 -63
- package/src/resolvers.ts +299 -0
- package/src/service.ts +2 -7
- package/src/skill-install.ts +17 -18
- package/src/types.ts +40 -15
package/dist/oauth.js
CHANGED
|
@@ -1,26 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's own OAuth 2.1 client (RFC 8252 native app).
|
|
3
|
+
*
|
|
4
|
+
* Authorization code + PKCE S256 through the system browser and a loopback
|
|
5
|
+
* redirect, against the pre-registered public client `synomem-cli`. The token
|
|
6
|
+
* is audienced to the Synomem API itself: discovery starts from the API's own
|
|
7
|
+
* protected-resource metadata (RFC 9728), never from the MCP gateway, and the
|
|
8
|
+
* discovered issuer and resource are validated before any browser opens.
|
|
9
|
+
*
|
|
10
|
+
* Which agent and workspace the resulting connection may act as is chosen on
|
|
11
|
+
* the consent screen and enforced by the API; nothing here names an actor.
|
|
12
|
+
*/
|
|
1
13
|
import { createServer } from 'node:http';
|
|
2
14
|
import { spawn } from 'node:child_process';
|
|
3
|
-
import { randomBytes } from 'node:crypto';
|
|
4
|
-
import { discoverOAuthServerInfo, startAuthorization, } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
15
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
5
16
|
import { SynomemError } from './errors.js';
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
export const DEFAULT_CLI_CLIENT_ID = 'synomem-cli';
|
|
18
|
+
export const DEFAULT_CALLBACK_PORT = 43_817;
|
|
19
|
+
export const DEFAULT_CLI_SCOPE = 'openid offline_access synomem:read synomem:write';
|
|
20
|
+
const maximumDocumentBytes = 64 * 1024;
|
|
21
|
+
/** Access tokens are treated as expired this long before they actually are. */
|
|
22
|
+
const expirySafetyMs = 30_000;
|
|
23
|
+
function trimSlash(value) {
|
|
24
|
+
return value.replace(/\/+$/, '');
|
|
25
|
+
}
|
|
26
|
+
/** HTTPS, or loopback HTTP (development against a local stack). */
|
|
27
|
+
export function secureUrl(value, label) {
|
|
28
|
+
let url;
|
|
29
|
+
try {
|
|
30
|
+
url = new URL(value);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new SynomemError('AUTH_REQUIRED', `${label} is not a valid URL.`);
|
|
34
|
+
}
|
|
35
|
+
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
36
|
+
if (url.protocol !== 'https:' && !(url.protocol === 'http:' && loopback)) {
|
|
11
37
|
throw new SynomemError('AUTH_REQUIRED', `${label} must use HTTPS.`);
|
|
12
38
|
}
|
|
39
|
+
if (url.username || url.password) {
|
|
40
|
+
throw new SynomemError('AUTH_REQUIRED', `${label} must not carry credentials.`);
|
|
41
|
+
}
|
|
13
42
|
return url;
|
|
14
43
|
}
|
|
15
|
-
async function
|
|
44
|
+
async function readJson(url, fetchImplementation, label) {
|
|
16
45
|
let response;
|
|
17
46
|
try {
|
|
18
|
-
response = await fetchImplementation(
|
|
47
|
+
response = await fetchImplementation(url, {
|
|
48
|
+
redirect: 'error',
|
|
49
|
+
headers: { accept: 'application/json' },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new SynomemError('REMOTE_UNAVAILABLE', `${label} is unavailable.`);
|
|
54
|
+
}
|
|
55
|
+
const text = await response.text();
|
|
56
|
+
if (Buffer.byteLength(text) > maximumDocumentBytes) {
|
|
57
|
+
throw new SynomemError('REMOTE_PROTOCOL', `${label} exceeded the safe size limit.`);
|
|
58
|
+
}
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
throw new SynomemError('REMOTE_PROTOCOL', `${label} returned HTTP ${response.status}.`);
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const parsed = JSON.parse(text);
|
|
64
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
65
|
+
throw new Error();
|
|
66
|
+
return parsed;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
throw new SynomemError('REMOTE_PROTOCOL', `${label} is not valid JSON.`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Where to sign in for this API, validated.
|
|
74
|
+
*
|
|
75
|
+
* The protected-resource metadata must name THIS API as its resource and at
|
|
76
|
+
* least one authorization server; the authorization server's metadata must
|
|
77
|
+
* name itself as issuer, publish HTTPS endpoints and support S256. A mismatch
|
|
78
|
+
* anywhere stops the login before a browser opens.
|
|
79
|
+
*/
|
|
80
|
+
export async function discoverApiAuthorization(apiUrl, fetchImplementation = fetch) {
|
|
81
|
+
const api = secureUrl(apiUrl, 'Synomem API URL');
|
|
82
|
+
const resourceMetadata = await readJson(new URL('/.well-known/oauth-protected-resource', api.origin), fetchImplementation, 'API protected-resource metadata');
|
|
83
|
+
const resource = resourceMetadata.resource;
|
|
84
|
+
if (typeof resource !== 'string' || trimSlash(resource) !== trimSlash(api.origin)) {
|
|
85
|
+
throw new SynomemError('AUTH_REQUIRED', 'The API protected-resource metadata does not describe this API.');
|
|
86
|
+
}
|
|
87
|
+
const servers = resourceMetadata.authorization_servers;
|
|
88
|
+
const issuerValue = Array.isArray(servers) ? servers[0] : undefined;
|
|
89
|
+
if (typeof issuerValue !== 'string') {
|
|
90
|
+
throw new SynomemError('AUTH_REQUIRED', 'The API names no authorization server.');
|
|
91
|
+
}
|
|
92
|
+
const issuer = secureUrl(issuerValue, 'Authorization server');
|
|
93
|
+
const asMetadata = await readJson(new URL(`/.well-known/oauth-authorization-server${issuer.pathname === '/' ? '' : trimSlash(issuer.pathname)}`, issuer.origin), fetchImplementation, 'Authorization server metadata');
|
|
94
|
+
if (typeof asMetadata.issuer !== 'string' ||
|
|
95
|
+
trimSlash(asMetadata.issuer) !== trimSlash(issuer.href)) {
|
|
96
|
+
throw new SynomemError('AUTH_REQUIRED', 'The authorization server metadata issuer does not match.');
|
|
97
|
+
}
|
|
98
|
+
const authorizationEndpoint = asMetadata.authorization_endpoint;
|
|
99
|
+
const tokenEndpoint = asMetadata.token_endpoint;
|
|
100
|
+
if (typeof authorizationEndpoint !== 'string' || typeof tokenEndpoint !== 'string') {
|
|
101
|
+
throw new SynomemError('AUTH_REQUIRED', 'Authorization server discovery is incomplete.');
|
|
102
|
+
}
|
|
103
|
+
secureUrl(authorizationEndpoint, 'OAuth authorization endpoint');
|
|
104
|
+
secureUrl(tokenEndpoint, 'OAuth token endpoint');
|
|
105
|
+
const methods = asMetadata.code_challenge_methods_supported;
|
|
106
|
+
if (!Array.isArray(methods) || !methods.includes('S256')) {
|
|
107
|
+
throw new SynomemError('AUTH_REQUIRED', 'The authorization server must support PKCE S256.');
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
resource: trimSlash(resource),
|
|
111
|
+
issuer: trimSlash(asMetadata.issuer),
|
|
112
|
+
authorizationEndpoint,
|
|
113
|
+
tokenEndpoint,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
async function tokenRequest(endpoint, parameters, fetchImplementation) {
|
|
117
|
+
let response;
|
|
118
|
+
try {
|
|
119
|
+
response = await fetchImplementation(secureUrl(endpoint, 'OAuth token endpoint'), {
|
|
19
120
|
method: 'POST',
|
|
20
121
|
redirect: 'error',
|
|
21
122
|
headers: { 'content-type': 'application/x-www-form-urlencoded', accept: 'application/json' },
|
|
22
123
|
body: parameters,
|
|
23
|
-
...(signal ? { signal } : {}),
|
|
24
124
|
});
|
|
25
125
|
}
|
|
26
126
|
catch (error) {
|
|
@@ -29,7 +129,7 @@ async function tokenRequest(endpoint, parameters, fetchImplementation, signal) {
|
|
|
29
129
|
throw new SynomemError('REMOTE_UNAVAILABLE', 'The OAuth token endpoint is unavailable.');
|
|
30
130
|
}
|
|
31
131
|
const text = await response.text();
|
|
32
|
-
if (Buffer.byteLength(text) >
|
|
132
|
+
if (Buffer.byteLength(text) > maximumDocumentBytes) {
|
|
33
133
|
throw new SynomemError('REMOTE_PROTOCOL', 'OAuth token response exceeded the safe limit.');
|
|
34
134
|
}
|
|
35
135
|
let parsed;
|
|
@@ -44,11 +144,16 @@ async function tokenRequest(endpoint, parameters, fetchImplementation, signal) {
|
|
|
44
144
|
}
|
|
45
145
|
return parsed;
|
|
46
146
|
}
|
|
147
|
+
function expiresAt(expiresIn) {
|
|
148
|
+
// A token without a lifetime is still refreshed on the API's schedule: 10
|
|
149
|
+
// minutes is the contract's maximum access-token lifetime.
|
|
150
|
+
return Date.now() + Math.max(0, (expiresIn ?? 600) * 1_000 - expirySafetyMs);
|
|
151
|
+
}
|
|
47
152
|
function launchBrowser(url) {
|
|
48
|
-
const command = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
49
153
|
if (process.platform !== 'darwin' && process.platform !== 'linux') {
|
|
50
154
|
throw new SynomemError('CONFIG_INVALID', `Open this URL in a browser: ${url.href}`);
|
|
51
155
|
}
|
|
156
|
+
const command = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
52
157
|
const child = spawn(command, [url.href], { detached: true, stdio: 'ignore' });
|
|
53
158
|
child.once('error', () => undefined);
|
|
54
159
|
child.unref();
|
|
@@ -67,7 +172,9 @@ async function authorizationCode(authorizationUrl, state, callbackPort, openBrow
|
|
|
67
172
|
if (oauthError || !code || returnedState !== state) {
|
|
68
173
|
response.writeHead(400, { 'content-type': 'text/plain; charset=utf-8' });
|
|
69
174
|
response.end('Synomem authorization failed. Return to your terminal.');
|
|
70
|
-
finish(new SynomemError('AUTH_REQUIRED',
|
|
175
|
+
finish(new SynomemError('AUTH_REQUIRED', oauthError === 'access_denied'
|
|
176
|
+
? 'Authorization was declined.'
|
|
177
|
+
: 'OAuth callback validation failed.'));
|
|
71
178
|
return;
|
|
72
179
|
}
|
|
73
180
|
response.writeHead(200, {
|
|
@@ -97,132 +204,78 @@ async function authorizationCode(authorizationUrl, state, callbackPort, openBrow
|
|
|
97
204
|
});
|
|
98
205
|
});
|
|
99
206
|
}
|
|
207
|
+
/** Runs the browser flow and returns the credential for the caller to store. */
|
|
100
208
|
export async function loginWithOAuth(options) {
|
|
101
209
|
const fetchImplementation = options.fetch ?? fetch;
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
secureEndpoint(metadata.authorization_endpoint, 'OAuth authorization endpoint');
|
|
109
|
-
secureEndpoint(metadata.token_endpoint, 'OAuth token endpoint');
|
|
110
|
-
if (!metadata.code_challenge_methods_supported?.includes('S256')) {
|
|
111
|
-
throw new SynomemError('AUTH_REQUIRED', 'The OAuth server must support PKCE S256.');
|
|
112
|
-
}
|
|
113
|
-
const callbackPort = options.callbackPort ?? 43_817;
|
|
114
|
-
const redirectUrl = new URL(`http://127.0.0.1:${callbackPort}/callback`);
|
|
210
|
+
const metadata = await discoverApiAuthorization(options.apiUrl, fetchImplementation);
|
|
211
|
+
const clientId = options.clientId ?? DEFAULT_CLI_CLIENT_ID;
|
|
212
|
+
const scope = options.scope ?? DEFAULT_CLI_SCOPE;
|
|
213
|
+
const callbackPort = options.callbackPort ?? DEFAULT_CALLBACK_PORT;
|
|
214
|
+
const redirectUri = `http://127.0.0.1:${callbackPort}/callback`;
|
|
115
215
|
const state = randomBytes(32).toString('base64url');
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const
|
|
216
|
+
const verifier = randomBytes(32).toString('base64url');
|
|
217
|
+
const challenge = createHash('sha256').update(verifier).digest('base64url');
|
|
218
|
+
const authorizationUrl = new URL(metadata.authorizationEndpoint);
|
|
219
|
+
authorizationUrl.searchParams.set('response_type', 'code');
|
|
220
|
+
authorizationUrl.searchParams.set('client_id', clientId);
|
|
221
|
+
authorizationUrl.searchParams.set('redirect_uri', redirectUri);
|
|
222
|
+
authorizationUrl.searchParams.set('scope', scope);
|
|
223
|
+
authorizationUrl.searchParams.set('state', state);
|
|
224
|
+
authorizationUrl.searchParams.set('code_challenge', challenge);
|
|
225
|
+
authorizationUrl.searchParams.set('code_challenge_method', 'S256');
|
|
226
|
+
authorizationUrl.searchParams.set('resource', metadata.resource);
|
|
227
|
+
const code = await authorizationCode(authorizationUrl, state, callbackPort, options.openBrowser ?? launchBrowser, options.timeoutMs ?? 5 * 60_000);
|
|
228
|
+
const tokens = await tokenRequest(metadata.tokenEndpoint, new URLSearchParams({
|
|
128
229
|
grant_type: 'authorization_code',
|
|
129
|
-
client_id:
|
|
230
|
+
client_id: clientId,
|
|
130
231
|
code,
|
|
131
|
-
code_verifier:
|
|
132
|
-
redirect_uri:
|
|
133
|
-
resource: resource
|
|
232
|
+
code_verifier: verifier,
|
|
233
|
+
redirect_uri: redirectUri,
|
|
234
|
+
resource: metadata.resource,
|
|
134
235
|
}), fetchImplementation);
|
|
135
|
-
|
|
236
|
+
return {
|
|
237
|
+
kind: 'oauth',
|
|
238
|
+
issuer: metadata.issuer,
|
|
239
|
+
resource: metadata.resource,
|
|
240
|
+
clientId,
|
|
241
|
+
tokenEndpoint: metadata.tokenEndpoint,
|
|
242
|
+
scope: tokens.scope ?? scope,
|
|
136
243
|
accessToken: tokens.access_token,
|
|
137
244
|
...(tokens.refresh_token ? { refreshToken: tokens.refresh_token } : {}),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
tokenEndpoint: metadata.token_endpoint,
|
|
142
|
-
clientId: options.clientId,
|
|
143
|
-
resource: resource.href,
|
|
144
|
-
scope: tokens.scope ?? scope,
|
|
145
|
-
});
|
|
245
|
+
expiresAt: expiresAt(tokens.expires_in),
|
|
246
|
+
generation: 0,
|
|
247
|
+
};
|
|
146
248
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
/** Set when the stored credential is an access key rather than an OAuth grant. */
|
|
156
|
-
staticAccessToken;
|
|
157
|
-
loaded = false;
|
|
158
|
-
constructor(reference, store, env = process.env, fetchImplementation = fetch,
|
|
159
|
-
/**
|
|
160
|
-
* Where `synomem config`'s restricted-file credential store, if chosen,
|
|
161
|
-
* would have written an access key. Optional because local-only and
|
|
162
|
-
* environment-only callers have no such file to fall back to.
|
|
163
|
-
*/
|
|
164
|
-
home) {
|
|
165
|
-
this.reference = reference;
|
|
166
|
-
this.store = store;
|
|
167
|
-
this.env = env;
|
|
168
|
-
this.fetchImplementation = fetchImplementation;
|
|
169
|
-
this.home = home;
|
|
170
|
-
}
|
|
171
|
-
async getAccessToken(signal) {
|
|
172
|
-
if (this.env.SYNOMEM_ACCESS_TOKEN)
|
|
173
|
-
return this.env.SYNOMEM_ACCESS_TOKEN;
|
|
174
|
-
if (!this.loaded) {
|
|
175
|
-
const stored = await this.store.get(this.reference);
|
|
176
|
-
/*
|
|
177
|
-
* An access key is not an OAuth credential: it cannot be refreshed and
|
|
178
|
-
* has no client or token endpoint. It is used exactly as stored,
|
|
179
|
-
* whichever of the two places it was found.
|
|
180
|
-
*/
|
|
181
|
-
if (stored && 'kind' in stored) {
|
|
182
|
-
this.staticAccessToken = stored.accessToken;
|
|
183
|
-
}
|
|
184
|
-
else if (stored) {
|
|
185
|
-
this.credential = stored;
|
|
186
|
-
}
|
|
187
|
-
else if (this.home) {
|
|
188
|
-
this.staticAccessToken = readCredentialFile(this.home);
|
|
189
|
-
}
|
|
190
|
-
this.loaded = true;
|
|
191
|
-
}
|
|
192
|
-
if (this.staticAccessToken)
|
|
193
|
-
return this.staticAccessToken;
|
|
194
|
-
const credential = this.credential;
|
|
195
|
-
if (!credential)
|
|
196
|
-
return undefined;
|
|
197
|
-
if (!credential.expiresAt || credential.expiresAt > Date.now())
|
|
198
|
-
return credential.accessToken;
|
|
199
|
-
if (!credential.refreshToken)
|
|
200
|
-
return undefined;
|
|
201
|
-
this.refresh ??= this.refreshCredential(credential, signal).finally(() => {
|
|
202
|
-
this.refresh = undefined;
|
|
203
|
-
});
|
|
204
|
-
return await this.refresh;
|
|
249
|
+
/**
|
|
250
|
+
* Spends the refresh token once. Callers hold the credential lock and write the
|
|
251
|
+
* result before releasing it; a failure here is never retried with the same
|
|
252
|
+
* (possibly consumed) refresh token.
|
|
253
|
+
*/
|
|
254
|
+
export async function refreshOAuthCredential(credential, fetchImplementation = fetch) {
|
|
255
|
+
if (!credential.refreshToken) {
|
|
256
|
+
throw new SynomemError('REAUTHORIZATION_REQUIRED', 'The stored credential cannot be refreshed.');
|
|
205
257
|
}
|
|
206
|
-
|
|
207
|
-
|
|
258
|
+
let tokens;
|
|
259
|
+
try {
|
|
260
|
+
tokens = await tokenRequest(credential.tokenEndpoint, new URLSearchParams({
|
|
208
261
|
grant_type: 'refresh_token',
|
|
209
262
|
client_id: credential.clientId,
|
|
210
263
|
refresh_token: credential.refreshToken,
|
|
211
264
|
resource: credential.resource,
|
|
212
|
-
|
|
213
|
-
}), this.fetchImplementation, signal);
|
|
214
|
-
const updated = {
|
|
215
|
-
...credential,
|
|
216
|
-
accessToken: tokens.access_token,
|
|
217
|
-
refreshToken: tokens.refresh_token ?? credential.refreshToken,
|
|
218
|
-
...(tokens.expires_in
|
|
219
|
-
? { expiresAt: Date.now() + Math.max(0, tokens.expires_in - 30) * 1_000 }
|
|
220
|
-
: { expiresAt: undefined }),
|
|
221
|
-
scope: tokens.scope ?? credential.scope,
|
|
222
|
-
};
|
|
223
|
-
await this.store.set(this.reference, updated);
|
|
224
|
-
this.credential = updated;
|
|
225
|
-
return updated.accessToken;
|
|
265
|
+
}), fetchImplementation);
|
|
226
266
|
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
if (error instanceof SynomemError && error.code === 'REMOTE_UNAVAILABLE')
|
|
269
|
+
throw error;
|
|
270
|
+
throw new SynomemError('REAUTHORIZATION_REQUIRED', 'The stored credential was refused when refreshing.');
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
...credential,
|
|
274
|
+
accessToken: tokens.access_token,
|
|
275
|
+
...(tokens.refresh_token ? { refreshToken: tokens.refresh_token } : {}),
|
|
276
|
+
scope: tokens.scope ?? credential.scope,
|
|
277
|
+
expiresAt: expiresAt(tokens.expires_in),
|
|
278
|
+
generation: credential.generation + 1,
|
|
279
|
+
};
|
|
227
280
|
}
|
|
228
281
|
//# sourceMappingURL=oauth.js.map
|
package/dist/oauth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,M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,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK;QACvC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC;QACvC,UAAU,EAAE,UAAU,CAAC,UAAU,GAAG,CAAC;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type CredentialStore, type CredentialStores } from './credentials.js';
|
|
3
|
+
import { SynomemError } from './errors.js';
|
|
4
|
+
import { createLocalResolver, createRemoteResolver, type ContextResolver, type RemoteCredentialSource } from './resolvers.js';
|
|
5
|
+
import type { ActorIdentity, ContextSummary } from './types.js';
|
|
6
|
+
export declare const PROFILES_FILE = "profiles.json";
|
|
7
|
+
declare const credentialEntrySchema: z.ZodObject<{
|
|
8
|
+
kind: z.ZodEnum<{
|
|
9
|
+
oauth: "oauth";
|
|
10
|
+
"access-key": "access-key";
|
|
11
|
+
}>;
|
|
12
|
+
apiUrl: z.ZodString;
|
|
13
|
+
store: z.ZodEnum<{
|
|
14
|
+
file: "file";
|
|
15
|
+
keychain: "keychain";
|
|
16
|
+
environment: "environment";
|
|
17
|
+
}>;
|
|
18
|
+
secretRef: z.ZodOptional<z.ZodString>;
|
|
19
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
20
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
21
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
22
|
+
connectionId: z.ZodOptional<z.ZodString>;
|
|
23
|
+
label: z.ZodOptional<z.ZodString>;
|
|
24
|
+
createdAt: z.ZodString;
|
|
25
|
+
}, z.core.$strict>;
|
|
26
|
+
declare const localProfileSchema: z.ZodObject<{
|
|
27
|
+
backend: z.ZodLiteral<"local">;
|
|
28
|
+
home: z.ZodOptional<z.ZodString>;
|
|
29
|
+
actorId: z.ZodString;
|
|
30
|
+
actorName: z.ZodOptional<z.ZodString>;
|
|
31
|
+
contextId: z.ZodString;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
declare const remoteProfileSchema: z.ZodObject<{
|
|
34
|
+
backend: z.ZodOptional<z.ZodLiteral<"remote">>;
|
|
35
|
+
credentialRef: z.ZodString;
|
|
36
|
+
contextId: z.ZodString;
|
|
37
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
38
|
+
workspaceName: z.ZodOptional<z.ZodString>;
|
|
39
|
+
actor: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
kind: z.ZodEnum<{
|
|
41
|
+
human: "human";
|
|
42
|
+
agent: "agent";
|
|
43
|
+
system: "system";
|
|
44
|
+
}>;
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, z.core.$strict>>;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
export declare const profileSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
50
|
+
backend: z.ZodLiteral<"local">;
|
|
51
|
+
home: z.ZodOptional<z.ZodString>;
|
|
52
|
+
actorId: z.ZodString;
|
|
53
|
+
actorName: z.ZodOptional<z.ZodString>;
|
|
54
|
+
contextId: z.ZodString;
|
|
55
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
56
|
+
backend: z.ZodOptional<z.ZodLiteral<"remote">>;
|
|
57
|
+
credentialRef: z.ZodString;
|
|
58
|
+
contextId: z.ZodString;
|
|
59
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
60
|
+
workspaceName: z.ZodOptional<z.ZodString>;
|
|
61
|
+
actor: z.ZodOptional<z.ZodObject<{
|
|
62
|
+
kind: z.ZodEnum<{
|
|
63
|
+
human: "human";
|
|
64
|
+
agent: "agent";
|
|
65
|
+
system: "system";
|
|
66
|
+
}>;
|
|
67
|
+
id: z.ZodString;
|
|
68
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strict>>;
|
|
70
|
+
}, z.core.$strict>]>;
|
|
71
|
+
export declare const profilesConfigSchema: z.ZodObject<{
|
|
72
|
+
version: z.ZodLiteral<1>;
|
|
73
|
+
credentials: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
74
|
+
kind: z.ZodEnum<{
|
|
75
|
+
oauth: "oauth";
|
|
76
|
+
"access-key": "access-key";
|
|
77
|
+
}>;
|
|
78
|
+
apiUrl: z.ZodString;
|
|
79
|
+
store: z.ZodEnum<{
|
|
80
|
+
file: "file";
|
|
81
|
+
keychain: "keychain";
|
|
82
|
+
environment: "environment";
|
|
83
|
+
}>;
|
|
84
|
+
secretRef: z.ZodOptional<z.ZodString>;
|
|
85
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
86
|
+
resource: z.ZodOptional<z.ZodString>;
|
|
87
|
+
clientId: z.ZodOptional<z.ZodString>;
|
|
88
|
+
connectionId: z.ZodOptional<z.ZodString>;
|
|
89
|
+
label: z.ZodOptional<z.ZodString>;
|
|
90
|
+
createdAt: z.ZodString;
|
|
91
|
+
}, z.core.$strict>>>;
|
|
92
|
+
profiles: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
|
|
93
|
+
backend: z.ZodLiteral<"local">;
|
|
94
|
+
home: z.ZodOptional<z.ZodString>;
|
|
95
|
+
actorId: z.ZodString;
|
|
96
|
+
actorName: z.ZodOptional<z.ZodString>;
|
|
97
|
+
contextId: z.ZodString;
|
|
98
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
99
|
+
backend: z.ZodOptional<z.ZodLiteral<"remote">>;
|
|
100
|
+
credentialRef: z.ZodString;
|
|
101
|
+
contextId: z.ZodString;
|
|
102
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
103
|
+
workspaceName: z.ZodOptional<z.ZodString>;
|
|
104
|
+
actor: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
kind: z.ZodEnum<{
|
|
106
|
+
human: "human";
|
|
107
|
+
agent: "agent";
|
|
108
|
+
system: "system";
|
|
109
|
+
}>;
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strict>>;
|
|
113
|
+
}, z.core.$strict>]>>>;
|
|
114
|
+
harnessPresets: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
|
|
115
|
+
defaultProfile: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strict>;
|
|
117
|
+
export type CredentialEntry = z.infer<typeof credentialEntrySchema>;
|
|
118
|
+
export type LocalProfile = z.infer<typeof localProfileSchema>;
|
|
119
|
+
export type RemoteProfile = z.infer<typeof remoteProfileSchema>;
|
|
120
|
+
export type Profile = z.infer<typeof profileSchema>;
|
|
121
|
+
export type ProfilesConfig = z.infer<typeof profilesConfigSchema>;
|
|
122
|
+
export declare function isLocalProfile(profile: Profile): profile is LocalProfile;
|
|
123
|
+
export declare function emptyProfilesConfig(): ProfilesConfig;
|
|
124
|
+
export declare function assertName(name: string, what: string): string;
|
|
125
|
+
/** Reads and writes `<home>/profiles.json`. Injected in tests. */
|
|
126
|
+
export declare class ProfileStore {
|
|
127
|
+
readonly home: string;
|
|
128
|
+
constructor(explicitHome?: string);
|
|
129
|
+
get path(): string;
|
|
130
|
+
read(): ProfilesConfig;
|
|
131
|
+
write(config: ProfilesConfig): void;
|
|
132
|
+
}
|
|
133
|
+
export type Selection = {
|
|
134
|
+
kind: 'profile';
|
|
135
|
+
name: string;
|
|
136
|
+
source: string;
|
|
137
|
+
} | {
|
|
138
|
+
kind: 'preset';
|
|
139
|
+
name: string;
|
|
140
|
+
source: string;
|
|
141
|
+
};
|
|
142
|
+
export interface SelectionInput {
|
|
143
|
+
profile?: string;
|
|
144
|
+
preset?: string;
|
|
145
|
+
env?: NodeJS.ProcessEnv;
|
|
146
|
+
cwd?: string;
|
|
147
|
+
/** The Synomem home, so it is never mistaken for a project directory. */
|
|
148
|
+
home?: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Which profile or preset a process acts through. One implementation, used by
|
|
152
|
+
* the CLI and both stdio entrypoints:
|
|
153
|
+
*
|
|
154
|
+
* 1. `--profile` / `--preset` on this invocation
|
|
155
|
+
* 2. `SYNOMEM_PROFILE` / `SYNOMEM_PRESET` for this process
|
|
156
|
+
* 3. the nearest project `.synomem/project.json` (names a profile/preset only)
|
|
157
|
+
* 4. `defaultProfile` in profiles.json
|
|
158
|
+
*
|
|
159
|
+
* Returns undefined when nothing selects anything. Naming something that does
|
|
160
|
+
* not exist is an error, never a fall-through to the next source.
|
|
161
|
+
*/
|
|
162
|
+
export declare function resolveSelection(config: ProfilesConfig, input: SelectionInput): Selection | undefined;
|
|
163
|
+
export declare function noSelectionError(): SynomemError;
|
|
164
|
+
export interface CredentialSourceOptions {
|
|
165
|
+
home: string;
|
|
166
|
+
name: string;
|
|
167
|
+
entry: CredentialEntry;
|
|
168
|
+
stores: CredentialStores;
|
|
169
|
+
env?: NodeJS.ProcessEnv;
|
|
170
|
+
fetch?: typeof fetch;
|
|
171
|
+
}
|
|
172
|
+
export declare function storeFor(stores: CredentialStores, entry: CredentialEntry): CredentialStore;
|
|
173
|
+
/**
|
|
174
|
+
* A connection's current bearer: an access key as stored, or an OAuth access
|
|
175
|
+
* token, refreshed under the cross-process lock when it has expired.
|
|
176
|
+
*
|
|
177
|
+
* After taking the lock the stored credential is re-read: if another process
|
|
178
|
+
* already refreshed it (a newer generation), that token is used and the
|
|
179
|
+
* refresh token is not spent again. A refused refresh is never retried — the
|
|
180
|
+
* connection must be logged in again.
|
|
181
|
+
*/
|
|
182
|
+
export declare class ConnectionCredentialSource implements RemoteCredentialSource {
|
|
183
|
+
private readonly options;
|
|
184
|
+
private cached?;
|
|
185
|
+
private cachedExpiry;
|
|
186
|
+
private pending?;
|
|
187
|
+
constructor(options: CredentialSourceOptions);
|
|
188
|
+
bearer(): Promise<string>;
|
|
189
|
+
private reauthorize;
|
|
190
|
+
private load;
|
|
191
|
+
private remember;
|
|
192
|
+
}
|
|
193
|
+
export interface ResolverDependencies {
|
|
194
|
+
stores: CredentialStores;
|
|
195
|
+
env?: NodeJS.ProcessEnv;
|
|
196
|
+
fetch?: typeof fetch;
|
|
197
|
+
createRemoteResolver?: typeof createRemoteResolver;
|
|
198
|
+
createLocalResolver?: typeof createLocalResolver;
|
|
199
|
+
}
|
|
200
|
+
export declare function credentialSourceFor(home: string, config: ProfilesConfig, name: string, deps: ResolverDependencies): ConnectionCredentialSource;
|
|
201
|
+
/** The canonical local actor for a local profile, after checking its store. */
|
|
202
|
+
export declare function localProfileTarget(rootHome: string, profile: LocalProfile): {
|
|
203
|
+
home: string;
|
|
204
|
+
actor: ActorIdentity;
|
|
205
|
+
};
|
|
206
|
+
/** A fixed-mode resolver for one profile. */
|
|
207
|
+
export declare function profileResolver(rootHome: string, config: ProfilesConfig, name: string, deps: ResolverDependencies): ContextResolver;
|
|
208
|
+
interface Route {
|
|
209
|
+
profile: string;
|
|
210
|
+
contextId: string;
|
|
211
|
+
resolver: ContextResolver;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* An explicit-context resolver over a preset's profiles.
|
|
215
|
+
*
|
|
216
|
+
* Remote profiles sharing a connection share one remote resolver, restricted
|
|
217
|
+
* to exactly the contexts the preset names (the server still authorizes each).
|
|
218
|
+
* Every operation must name its context; there is no default and no switch.
|
|
219
|
+
*/
|
|
220
|
+
export declare class PresetResolver implements ContextResolver {
|
|
221
|
+
private readonly name;
|
|
222
|
+
private readonly routes;
|
|
223
|
+
constructor(name: string, routes: Route[]);
|
|
224
|
+
mode(): 'explicit';
|
|
225
|
+
resolve(contextId?: string): Promise<import("./resolvers.js").ResolvedContext>;
|
|
226
|
+
list(): Promise<{
|
|
227
|
+
mode: "explicit";
|
|
228
|
+
fixedContextId: null;
|
|
229
|
+
contexts: ContextSummary[];
|
|
230
|
+
}>;
|
|
231
|
+
close(): Promise<void>;
|
|
232
|
+
}
|
|
233
|
+
export declare function presetResolver(rootHome: string, config: ProfilesConfig, name: string, deps: ResolverDependencies): PresetResolver;
|
|
234
|
+
/**
|
|
235
|
+
* The single entry point for the CLI and both stdio servers: selection flags
|
|
236
|
+
* and environment in, one resolver out.
|
|
237
|
+
*/
|
|
238
|
+
export declare function resolverForSelection(rootHome: string, config: ProfilesConfig, selection: Selection, deps: ResolverDependencies): ContextResolver;
|
|
239
|
+
export declare function describeContext(context: ContextSummary): string;
|
|
240
|
+
/** One line describing a profile, for list/show. Never a secret. */
|
|
241
|
+
export declare function describeProfile(name: string, profile: Profile): string;
|
|
242
|
+
export {};
|
|
243
|
+
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AA4BA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAEtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EAEpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhE,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAS7C,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;kBAsBvB,CAAC;AAUL,QAAA,MAAM,kBAAkB;;;;;;kBASb,CAAC;AAEZ,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;kBAUd,CAAC;AAEZ,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;oBAAqD,CAAC;AAEhF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA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