@slates/cli 1.0.0-rc.10 → 1.0.0-rc.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slates/cli",
3
- "version": "1.0.0-rc.10",
3
+ "version": "1.0.0-rc.13",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -25,9 +25,9 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@inquirer/prompts": "^7.4.0",
28
- "@slates/client": "1.0.0-rc.12",
29
- "@slates/oauth-microsoft": "1.0.0-rc.5",
30
- "@slates/profiles": "1.0.0-rc.10",
28
+ "@slates/client": "1.0.0-rc.15",
29
+ "@slates/oauth-microsoft": "1.0.0-rc.6",
30
+ "@slates/profiles": "1.0.0-rc.13",
31
31
  "sade": "^1.8.1"
32
32
  },
33
33
  "devDependencies": {
@@ -388,12 +388,12 @@ let runAuthSetup = async (opts: AuthSetupOptions): Promise<SlatesStoredAuth> =>
388
388
  return stored;
389
389
  }
390
390
 
391
- output = (
392
- await client.getAuthOutput({
393
- authenticationMethodId: authMethod.id,
394
- input: authInput
395
- })
396
- ).output;
391
+ let authOutput = await client.getAuthOutput({
392
+ authenticationMethodId: authMethod.id,
393
+ input: authInput
394
+ });
395
+ output = authOutput.output;
396
+ scopes = authOutput.scopes ?? scopes;
397
397
 
398
398
  let profileInfo = authMethod.capabilities.getProfile?.enabled
399
399
  ? await client.getAuthProfile({
package/src/lib/oauth.ts CHANGED
@@ -4,6 +4,21 @@ import { createServer } from 'http';
4
4
 
5
5
  let DEFAULT_OAUTH_CALLBACK_PORT = 45873;
6
6
 
7
+ let resolveAdvertisedRedirectUri = (localPort: number) => {
8
+ let override = process.env.OAUTH_CALLBACK_OVERRIDE;
9
+ if (!override) return `http://127.0.0.1:${localPort}/callback`;
10
+
11
+ let url: URL;
12
+ try {
13
+ url = new URL(override);
14
+ } catch {
15
+ throw new Error(`OAUTH_CALLBACK_OVERRIDE must be an absolute URL, received: ${override}`);
16
+ }
17
+
18
+ if (url.pathname === '' || url.pathname === '/') url.pathname = '/callback';
19
+ return url.toString();
20
+ };
21
+
7
22
  export let chooseScopes = async (
8
23
  authMethod: any,
9
24
  initialScopes: string[]
@@ -153,7 +168,7 @@ export let createOAuthCallbackListener = async () => {
153
168
  }
154
169
 
155
170
  resolve({
156
- redirectUri: `http://127.0.0.1:${address.port}/callback`,
171
+ redirectUri: resolveAdvertisedRedirectUri(address.port),
157
172
  state: expectedState,
158
173
  wait: () => waiter.promise
159
174
  });