@tomato414941/foundation 0.6.0 → 0.8.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/guide.mjs +14 -5
- package/package.json +1 -1
- package/runtime.mjs +9 -6
package/guide.mjs
CHANGED
|
@@ -104,12 +104,21 @@ export function guide(connectors) {
|
|
|
104
104
|
' scopes are the service\'s own names for what the connection may do (see each connector\'s scopes.documentation_url).',
|
|
105
105
|
' Ask for what the work needs; the owner sees each one before agreeing, and decides. Foundation adds only the few',
|
|
106
106
|
' it needs to know who authorized (scopes.base). facts.missing_scopes lists any the service did not grant.',
|
|
107
|
-
'
|
|
108
|
-
'
|
|
109
|
-
'
|
|
110
|
-
'
|
|
107
|
+
' A connection is made through an OAuth app: Foundation\'s own for the service, or one the owner holds (or was lent).',
|
|
108
|
+
' GET /v1/holdings?kind=app the apps the owner may connect through, Foundation\'s included (foundation: true).',
|
|
109
|
+
' Add "app":"<app id>" inside input to connect through one; without it, Foundation\'s is used, or on reconnecting,',
|
|
110
|
+
' the app the connection was made through. With their own app the owner decides at the service which scopes can',
|
|
111
|
+
' be granted at all, and what name the consent screen shows.',
|
|
112
|
+
' POST /v1/requests {"kind":"app", "input":{"connector":"<id>"}, "purpose":"...", "steps":["..."]} asks the owner',
|
|
113
|
+
' to register one: they make it at the service (redirect URL <this server>/oauth/<connector id>/callback) and',
|
|
114
|
+
' type its client ID and secret on the page. result.app_id names it. You never see or handle its secret.',
|
|
115
|
+
' GET /v1/connectors says which connectors take apps (apps.fields: what registering one asks for).',
|
|
116
|
+
' A service with no connector of its own is reached through "oauth2": the owner registers an app for it naming the',
|
|
117
|
+
' service and where it authorizes and hands out tokens (and, if it has them, where it says who authorized and',
|
|
118
|
+
' where it takes a token back). Ask for that with {"kind":"app","input":{"connector":"oauth2"}} and steps that say',
|
|
119
|
+
' where those are for that service. Connections through it yield OAUTH_ACCESS_TOKEN.',
|
|
111
120
|
' To reconnect, add "connection_id":"<existing id>" inside input. This updates that connection and keeps its id,',
|
|
112
|
-
' its scopes (add more with scopes) and the app it was made
|
|
121
|
+
' its scopes (add more with scopes) and the app it was made through.',
|
|
113
122
|
' Without connection_id, authorization creates a separate connection, even for the same service user. List and use',
|
|
114
123
|
' an existing connection when no new authorization is needed. Provider consent and revocation may affect several connections.',
|
|
115
124
|
' A connector whose flow is "role" (aws.role) has the owner make a role for Foundation in their own console and',
|
package/package.json
CHANGED
package/runtime.mjs
CHANGED
|
@@ -109,7 +109,7 @@ Commands:
|
|
|
109
109
|
Run a command with saved values in its environment.
|
|
110
110
|
exec --inputs '<json>' -- <command> The same, with files, structured inputs, or a connected grant by id.
|
|
111
111
|
exec --output '<json>' -- <command> Also save a file the command writes.
|
|
112
|
-
guide
|
|
112
|
+
guide Read the server's API guide (bundled reference when offline).
|
|
113
113
|
version Print the version.
|
|
114
114
|
|
|
115
115
|
Environment:
|
|
@@ -126,15 +126,18 @@ async function main() {
|
|
|
126
126
|
const configured = process.env.FOUNDATION_URL || await savedUrl();
|
|
127
127
|
if (action === '--help' || action === '-h' || action === 'help' || !action) { console.log(HELP); return; }
|
|
128
128
|
if (action === 'guide') {
|
|
129
|
-
let connectors;
|
|
130
129
|
if (configured) {
|
|
131
130
|
try {
|
|
132
|
-
const response = await fetch(new URL('/
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
const response = await fetch(new URL('/start', serverUrl(configured)), { redirect: 'error', signal: AbortSignal.timeout(5_000) });
|
|
132
|
+
if (!response.ok || response.headers.get('content-type')?.split(';')[0].trim() !== 'text/plain') throw new Error('Guide unavailable');
|
|
133
|
+
const instructions = await response.text();
|
|
134
|
+
if (!instructions.trim()) throw new Error('Empty guide');
|
|
135
|
+
console.log(instructions.trimEnd());
|
|
136
|
+
return;
|
|
135
137
|
} catch {}
|
|
136
138
|
}
|
|
137
|
-
console.
|
|
139
|
+
console.error(`${configured ? 'Could not read the server guide.' : 'No Foundation server configured.'} Using the bundled reference from CLI ${VERSION}; it may differ from your server.`);
|
|
140
|
+
console.log(guide());
|
|
138
141
|
return;
|
|
139
142
|
}
|
|
140
143
|
const separatorAt = args.indexOf('--'), command = separatorAt >= 0 ? args.slice(separatorAt + 1) : [];
|