@faable/faable 1.5.30 → 1.5.32
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/dist/api/auth.js +10 -1
- package/dist/commands/login/index.js +4 -7
- package/package.json +1 -1
package/dist/api/auth.js
CHANGED
|
@@ -13,5 +13,14 @@ async function getDeviceToken(device_code) {
|
|
|
13
13
|
const res = await api.post(`/oauth/token`, { device_code, client_id: CLIENT_ID, grant_type: "urn:ietf:params:oauth:grant-type:device_code" });
|
|
14
14
|
return res.data;
|
|
15
15
|
}
|
|
16
|
+
// Validate a device-flow access token against the Faable Auth server. The token
|
|
17
|
+
// is issued by the auth server, so it must be introspected there — NOT against
|
|
18
|
+
// the deploy API (api.faable.com), which has no /me route and would 404.
|
|
19
|
+
async function getMe(access_token) {
|
|
20
|
+
const res = await api.get(`/me`, {
|
|
21
|
+
headers: { Authorization: `Bearer ${access_token}` },
|
|
22
|
+
});
|
|
23
|
+
return res.data;
|
|
24
|
+
}
|
|
16
25
|
|
|
17
|
-
export { getDeviceCode, getDeviceToken };
|
|
26
|
+
export { getDeviceCode, getDeviceToken, getMe };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FaableApi } from '../../api/FaableApi.js';
|
|
2
|
-
import { getDeviceCode, getDeviceToken } from '../../api/auth.js';
|
|
2
|
+
import { getDeviceCode, getDeviceToken, getMe } from '../../api/auth.js';
|
|
3
3
|
import { CredentialsStore } from '../../lib/CredentialsStore.js';
|
|
4
|
-
import { bearer_strategy } from '../../api/strategies/bearer.strategy.js';
|
|
5
4
|
import open from 'open';
|
|
6
5
|
import ora from 'ora';
|
|
7
6
|
import { log } from '../../log.js';
|
|
@@ -123,11 +122,9 @@ const login = {
|
|
|
123
122
|
const { access_token } = await getDeviceToken(device_code);
|
|
124
123
|
if (access_token) {
|
|
125
124
|
spinner.stop();
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
const me = await tempApi.getMe();
|
|
125
|
+
// Validate the freshly issued token against the Auth server (it
|
|
126
|
+
// issued the token). The deploy API has no /me route.
|
|
127
|
+
const me = await getMe(access_token);
|
|
131
128
|
await store.saveCredentials({ token: access_token, email: me.email });
|
|
132
129
|
log.info(`✅ Successfully logged in as ${me.email}`);
|
|
133
130
|
return;
|