@slates/cli 1.0.0-rc.5 → 1.0.0-rc.6
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 +4 -4
- package/src/commands/auth.test.ts +24 -0
- package/src/commands/auth.ts +10 -1
- package/src/lib/oauth.ts +20 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slates/cli",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.6",
|
|
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.
|
|
29
|
-
"@slates/oauth-microsoft": "1.0.0-rc.
|
|
30
|
-
"@slates/profiles": "1.0.0-rc.
|
|
28
|
+
"@slates/client": "1.0.0-rc.8",
|
|
29
|
+
"@slates/oauth-microsoft": "1.0.0-rc.3",
|
|
30
|
+
"@slates/profiles": "1.0.0-rc.6",
|
|
31
31
|
"sade": "^1.8.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -8,6 +8,30 @@ describe('normalizeCallbackRedirectUriForIntegration', () => {
|
|
|
8
8
|
).toBe('http://localhost:45873/callback');
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
+
it('normalizes Intercom loopback redirects to localhost', () => {
|
|
12
|
+
expect(
|
|
13
|
+
normalizeCallbackRedirectUriForIntegration('intercom', 'http://127.0.0.1:45873/callback')
|
|
14
|
+
).toBe('http://localhost:45873/callback');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('normalizes Typeform loopback redirects to localhost', () => {
|
|
18
|
+
expect(
|
|
19
|
+
normalizeCallbackRedirectUriForIntegration('typeform', 'http://127.0.0.1:45873/callback')
|
|
20
|
+
).toBe('http://localhost:45873/callback');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('normalizes Xero loopback redirects to localhost', () => {
|
|
24
|
+
expect(
|
|
25
|
+
normalizeCallbackRedirectUriForIntegration('xero', 'http://127.0.0.1:45873/callback')
|
|
26
|
+
).toBe('http://localhost:45873/callback');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('normalizes Zendesk loopback redirects to localhost', () => {
|
|
30
|
+
expect(
|
|
31
|
+
normalizeCallbackRedirectUriForIntegration('zendesk', 'http://127.0.0.1:45873/callback')
|
|
32
|
+
).toBe('http://localhost:45873/callback');
|
|
33
|
+
});
|
|
34
|
+
|
|
11
35
|
it('leaves unrelated integration redirects unchanged', () => {
|
|
12
36
|
expect(
|
|
13
37
|
normalizeCallbackRedirectUriForIntegration('attio', 'http://127.0.0.1:45873/callback')
|
package/src/commands/auth.ts
CHANGED
|
@@ -22,11 +22,19 @@ import { JsonInput, WithProfile } from '../lib/types';
|
|
|
22
22
|
type JsonObject = Record<string, any>;
|
|
23
23
|
let NOTION_INTEGRATION_KEY = 'notion';
|
|
24
24
|
let SALESFORCE_INTEGRATION_KEY = 'salesforce';
|
|
25
|
+
let INTERCOM_INTEGRATION_KEY = 'intercom';
|
|
26
|
+
let TYPEFORM_INTEGRATION_KEY = 'typeform';
|
|
27
|
+
let XERO_INTEGRATION_KEY = 'xero';
|
|
28
|
+
let ZENDESK_INTEGRATION_KEY = 'zendesk';
|
|
25
29
|
let HUBSPOT_INTEGRATION_KEY = 'hubspot';
|
|
26
30
|
let HUBSPOT_DEVELOPER_PLATFORM_OAUTH_METHOD_ID = 'developer_platform_oauth';
|
|
27
31
|
let LOOPBACK_REDIRECT_NORMALIZED_INTEGRATIONS = new Set([
|
|
32
|
+
INTERCOM_INTEGRATION_KEY,
|
|
28
33
|
NOTION_INTEGRATION_KEY,
|
|
29
|
-
SALESFORCE_INTEGRATION_KEY
|
|
34
|
+
SALESFORCE_INTEGRATION_KEY,
|
|
35
|
+
TYPEFORM_INTEGRATION_KEY,
|
|
36
|
+
XERO_INTEGRATION_KEY,
|
|
37
|
+
ZENDESK_INTEGRATION_KEY
|
|
30
38
|
]);
|
|
31
39
|
|
|
32
40
|
type AuthSetupOptions = WithProfile &
|
|
@@ -345,6 +353,7 @@ let runAuthSetup = async (opts: AuthSetupOptions): Promise<SlatesStoredAuth> =>
|
|
|
345
353
|
clientId,
|
|
346
354
|
clientSecret,
|
|
347
355
|
scopes,
|
|
356
|
+
callbackParams: callbackResult.callbackParams,
|
|
348
357
|
callbackState: callbackState ?? undefined
|
|
349
358
|
});
|
|
350
359
|
|
package/src/lib/oauth.ts
CHANGED
|
@@ -34,7 +34,11 @@ export let createOAuthCallbackListener = async () => {
|
|
|
34
34
|
return new Promise<{
|
|
35
35
|
redirectUri: string;
|
|
36
36
|
state: string;
|
|
37
|
-
wait: () => Promise<{
|
|
37
|
+
wait: () => Promise<{
|
|
38
|
+
code: string;
|
|
39
|
+
state: string;
|
|
40
|
+
callbackParams: Record<string, string>;
|
|
41
|
+
}>;
|
|
38
42
|
}>((resolve, reject) => {
|
|
39
43
|
let expectedState = randomUUID();
|
|
40
44
|
let settled = false;
|
|
@@ -79,7 +83,11 @@ export let createOAuthCallbackListener = async () => {
|
|
|
79
83
|
res.end('Authentication complete. You can close this window.');
|
|
80
84
|
server.close();
|
|
81
85
|
settled = true;
|
|
82
|
-
waiter.resolve({
|
|
86
|
+
waiter.resolve({
|
|
87
|
+
code,
|
|
88
|
+
state,
|
|
89
|
+
callbackParams: Object.fromEntries(url.searchParams.entries())
|
|
90
|
+
});
|
|
83
91
|
} catch (error) {
|
|
84
92
|
server.close();
|
|
85
93
|
settled = true;
|
|
@@ -88,9 +96,17 @@ export let createOAuthCallbackListener = async () => {
|
|
|
88
96
|
});
|
|
89
97
|
|
|
90
98
|
let waiter = (() => {
|
|
91
|
-
let resolvePromise!: (value: {
|
|
99
|
+
let resolvePromise!: (value: {
|
|
100
|
+
code: string;
|
|
101
|
+
state: string;
|
|
102
|
+
callbackParams: Record<string, string>;
|
|
103
|
+
}) => void;
|
|
92
104
|
let rejectPromise!: (error: unknown) => void;
|
|
93
|
-
let promise = new Promise<{
|
|
105
|
+
let promise = new Promise<{
|
|
106
|
+
code: string;
|
|
107
|
+
state: string;
|
|
108
|
+
callbackParams: Record<string, string>;
|
|
109
|
+
}>((resolveFn, rejectFn) => {
|
|
94
110
|
resolvePromise = resolveFn;
|
|
95
111
|
rejectPromise = rejectFn;
|
|
96
112
|
});
|