@apex-actions/cli 0.75.0 → 0.76.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/README.md +22 -4
- package/dist/cli/grant/main.js +141 -0
- package/dist/cli/login/device.js +43 -0
- package/dist/cli/login/main.js +104 -31
- package/dist/cli/logout/main.js +13 -7
- package/dist/cli/program.js +2 -0
- package/dist/cli/reference.js +14 -1
- package/dist/cli/tenant/main.js +38 -2
- package/dist/cli/token/main.js +40 -19
- package/dist/src/application/authenticate.js +82 -1
- package/dist/src/application/manage-grants.js +21 -0
- package/dist/src/application/manage-tokens.js +3 -3
- package/dist/src/domain/credentials.js +70 -1
- package/dist/src/domain/grants.js +111 -0
- package/dist/src/infrastructure/control-plane-http.js +18 -2
- package/dist/src/infrastructure/credentials.js +23 -0
- package/dist/src/infrastructure/device-login.js +82 -0
- package/dist/src/infrastructure/loopback-login.js +33 -26
- package/package.json +1 -1
|
@@ -145,31 +145,38 @@ export class HttpLoginExchange {
|
|
|
145
145
|
const body = (await response.json().catch(() => ({})));
|
|
146
146
|
if (!response.ok)
|
|
147
147
|
throw new Error(typeof body['error'] === 'string' ? body['error'] : `the code exchange failed with ${response.status}`);
|
|
148
|
-
|
|
149
|
-
throw new Error('the control plane answered the code exchange without a token');
|
|
150
|
-
}
|
|
151
|
-
const str = (k) => {
|
|
152
|
-
const v = body[k];
|
|
153
|
-
return typeof v === 'string' ? { [k]: v } : {};
|
|
154
|
-
};
|
|
155
|
-
const list = (k) => {
|
|
156
|
-
const v = body[k];
|
|
157
|
-
return Array.isArray(v) ? { [k]: v.filter((r) => typeof r === 'string') } : {};
|
|
158
|
-
};
|
|
159
|
-
const source = body['source'];
|
|
160
|
-
return {
|
|
161
|
-
login: body['login'],
|
|
162
|
-
expiresAt: body['expiresAt'],
|
|
163
|
-
// An edit's answer carries no token: it changed one and minted nothing. The caller that needs one says so.
|
|
164
|
-
...str('token'),
|
|
165
|
-
...str('id'),
|
|
166
|
-
...str('name'),
|
|
167
|
-
...str('accountId'),
|
|
168
|
-
...str('last4'),
|
|
169
|
-
...str('createdAt'),
|
|
170
|
-
...list('repos'),
|
|
171
|
-
...list('permissions'),
|
|
172
|
-
...(source === 'dashboard' || source === 'login' || source === 'cli' ? { source } : {}),
|
|
173
|
-
};
|
|
148
|
+
return redeemedFrom(body);
|
|
174
149
|
}
|
|
175
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* What `POST /api/v1/cli/token` minted, from its answer — shared by the loopback's redemption and the
|
|
153
|
+
* device flow's poll, which end in the same token. Throws when the answer names nobody.
|
|
154
|
+
*/
|
|
155
|
+
export const redeemedFrom = (body) => {
|
|
156
|
+
if (typeof body['login'] !== 'string' || typeof body['expiresAt'] !== 'string') {
|
|
157
|
+
throw new Error('the control plane answered the code exchange without a token');
|
|
158
|
+
}
|
|
159
|
+
const str = (k) => {
|
|
160
|
+
const v = body[k];
|
|
161
|
+
return typeof v === 'string' ? { [k]: v } : {};
|
|
162
|
+
};
|
|
163
|
+
const list = (k) => {
|
|
164
|
+
const v = body[k];
|
|
165
|
+
return Array.isArray(v) ? { [k]: v.filter((r) => typeof r === 'string') } : {};
|
|
166
|
+
};
|
|
167
|
+
const source = body['source'];
|
|
168
|
+
return {
|
|
169
|
+
login: body['login'],
|
|
170
|
+
expiresAt: body['expiresAt'],
|
|
171
|
+
// An edit's answer carries no token: it changed one and minted nothing. The caller that needs one says so.
|
|
172
|
+
...str('token'),
|
|
173
|
+
...str('id'),
|
|
174
|
+
...str('name'),
|
|
175
|
+
...str('accountId'),
|
|
176
|
+
...str('last4'),
|
|
177
|
+
...str('createdAt'),
|
|
178
|
+
...list('repos'),
|
|
179
|
+
...list('permissions'),
|
|
180
|
+
...(source === 'dashboard' || source === 'login' || source === 'cli' ? { source } : {}),
|
|
181
|
+
};
|
|
182
|
+
};
|