@burdenoff/fe-libs 2026.1119.8 → 2026.1119.9
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/connections/ConnectionDialogPanel.js +222 -203
- package/dist/connections/ConnectionFormTab.d.ts +6 -0
- package/dist/connections/ConnectionFormTab.js +2 -2
- package/dist/connections/api.d.ts +28 -0
- package/dist/connections/api.js +107 -71
- package/dist/connections/connectionFlow.d.ts +63 -1
- package/dist/connections/connectionFlow.js +139 -47
- package/dist/connections/index.d.ts +2 -2
- package/dist/connections/oauthPopup.d.ts +16 -1
- package/dist/connections/oauthPopup.js +45 -37
- package/dist/connections/useConnectionSubmit.d.ts +7 -2
- package/dist/connections/useConnectionSubmit.js +69 -55
- package/dist/connections.js +6 -6
- package/package.json +1 -1
|
@@ -1,75 +1,145 @@
|
|
|
1
|
-
import { isSchemaComplete as e,
|
|
2
|
-
import { checkSecretReferences as
|
|
1
|
+
import { isSchemaComplete as e, isVisible as t, parseFormSchema as n, visibleValues as r } from "../credentials/schema.js";
|
|
2
|
+
import { checkSecretReferences as i } from "./secretReferences.js";
|
|
3
3
|
// src/connections/connectionFlow.ts
|
|
4
|
-
function
|
|
4
|
+
function a(e) {
|
|
5
5
|
return e === "oauth2" ? "oauth2" : e === "service_account" || e === "workspace_app_token" ? "minted" : "fields";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function o(e) {
|
|
8
8
|
return e.authMethods.filter((e) => e.isEnabled);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
let n =
|
|
10
|
+
function s(e, t) {
|
|
11
|
+
let n = o(e);
|
|
12
12
|
return n.find((e) => e.key === t) ?? n.find((e) => e.isConfigured) ?? n[0] ?? null;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return t?.flow ??
|
|
14
|
+
function c(e, t) {
|
|
15
|
+
return t?.flow ?? a(e.authType);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
let r = t
|
|
19
|
-
return r && Object.keys(r.properties).length > 0 ? r :
|
|
17
|
+
function l(e, t) {
|
|
18
|
+
let r = n(t?.configSchema);
|
|
19
|
+
return r && Object.keys(r.properties).length > 0 ? r : n(e.configSchema) ?? r;
|
|
20
20
|
}
|
|
21
|
-
var
|
|
22
|
-
function
|
|
21
|
+
var u = ["managed", "existing"], d = [];
|
|
22
|
+
function f(e) {
|
|
23
23
|
if (!e || !Object.prototype.hasOwnProperty.call(e, "supportedStorageModes")) return null;
|
|
24
24
|
let t = e.supportedStorageModes;
|
|
25
|
-
if (!Array.isArray(t) || t.length === 0) return
|
|
25
|
+
if (!Array.isArray(t) || t.length === 0) return d;
|
|
26
26
|
let n = [];
|
|
27
27
|
for (let e of t) {
|
|
28
|
-
if (e !== "managed" && e !== "existing" || n.includes(e)) return
|
|
28
|
+
if (e !== "managed" && e !== "existing" || n.includes(e)) return d;
|
|
29
29
|
n.push(e);
|
|
30
30
|
}
|
|
31
31
|
return n;
|
|
32
32
|
}
|
|
33
|
-
function f(e, t) {
|
|
34
|
-
let n = d(e.configSchema), r = d(t?.configSchema);
|
|
35
|
-
return n ? r ? r.filter((e) => n.includes(e)) : n : r ?? l;
|
|
36
|
-
}
|
|
37
33
|
function p(e, t) {
|
|
34
|
+
let n = f(e.configSchema), r = f(t?.configSchema);
|
|
35
|
+
return n ? r ? r.filter((e) => n.includes(e)) : n : r ?? u;
|
|
36
|
+
}
|
|
37
|
+
function m(e, t) {
|
|
38
38
|
return t.includes(e.mode) ? e : {
|
|
39
39
|
...e,
|
|
40
40
|
mode: t[0] ?? "managed",
|
|
41
41
|
secretId: ""
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function h(e) {
|
|
45
45
|
return !!(e && Object.prototype.hasOwnProperty.call(e.properties, "clientId"));
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function g(e, t) {
|
|
48
48
|
return e !== "minted" && t.authType !== "service_account";
|
|
49
49
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
50
|
+
function _(e, t) {
|
|
51
|
+
return t === "clientSecret" || e?.properties[t]?.secret === !0;
|
|
52
|
+
}
|
|
53
|
+
function v(e) {
|
|
54
|
+
return e === "oauth2";
|
|
55
|
+
}
|
|
56
|
+
function y(e, t, n) {
|
|
57
|
+
if (!e || !v(t)) return e;
|
|
58
|
+
let r = Object.keys(e.properties).filter((t) => _(e, t));
|
|
59
|
+
if (r.length === 0) return e;
|
|
60
|
+
let i = { ...e.properties };
|
|
61
|
+
for (let e of r) i[e] = {
|
|
62
|
+
...i[e],
|
|
63
|
+
placeholder: n
|
|
64
|
+
};
|
|
65
|
+
let a = new Set(r);
|
|
66
|
+
return {
|
|
67
|
+
...e,
|
|
68
|
+
properties: i,
|
|
69
|
+
required: e.required.filter((e) => !a.has(e))
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function b(e, t, n, r) {
|
|
73
|
+
if (!e || !v(t)) return n;
|
|
74
|
+
let i = { ...n };
|
|
75
|
+
for (let t of Object.keys(e.properties)) {
|
|
76
|
+
if (_(e, t)) {
|
|
77
|
+
delete i[t];
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
let n = r[t];
|
|
81
|
+
n != null && (i[t] = n);
|
|
82
|
+
}
|
|
83
|
+
return i;
|
|
84
|
+
}
|
|
85
|
+
function x(e, t) {
|
|
86
|
+
return typeof e == "string" && typeof t == "string" ? e.trim() === t.trim() : JSON.stringify(e) === JSON.stringify(t);
|
|
87
|
+
}
|
|
88
|
+
function S(e, n, r, i) {
|
|
89
|
+
if (!e) return null;
|
|
90
|
+
let a = D(e, n), o = i ? D(e, i) : null, s = { ...r }, c = !1;
|
|
91
|
+
for (let [i, l] of Object.entries(e.properties)) {
|
|
92
|
+
if (!t(l, n, e)) continue;
|
|
93
|
+
let u = a[i];
|
|
94
|
+
_(e, i) ? u !== void 0 && (s[i] = u, c = !0) : o && x(u, o[i]) || (u === void 0 ? r[i] !== void 0 && r[i] !== null && (delete s[i], c = !0) : x(u, r[i]) || (s[i] = u, c = !0));
|
|
95
|
+
}
|
|
96
|
+
return c ? s : null;
|
|
97
|
+
}
|
|
98
|
+
function C(e, t) {
|
|
99
|
+
let n = {}, r = e.name.trim();
|
|
100
|
+
r && r !== t.name.trim() && (n.name = r);
|
|
101
|
+
let i = e.description.trim();
|
|
102
|
+
if (i !== (t.description ?? "").trim() && (n.description = i), v(c(e.provider, e.method))) {
|
|
103
|
+
let r = S(l(e.provider, e.method), e.values, t.config, t.formValues);
|
|
104
|
+
r && (n.config = r);
|
|
105
|
+
}
|
|
106
|
+
return Object.keys(n).length > 0 ? n : null;
|
|
107
|
+
}
|
|
108
|
+
function w(e, t, n, r) {
|
|
109
|
+
let i = t.config ? Object.fromEntries(Object.entries(t.config).filter(([e]) => !_(n, e))) : e.config;
|
|
110
|
+
return {
|
|
111
|
+
...e,
|
|
112
|
+
name: t.name ?? e.name,
|
|
113
|
+
description: t.description ?? e.description,
|
|
114
|
+
config: i,
|
|
115
|
+
formValues: r ? Object.fromEntries(Object.entries(r).filter(([e]) => !_(n, e))) : e.formValues
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function T(t, n) {
|
|
119
|
+
let r = c(t.provider, t.method), a = l(t.provider, t.method);
|
|
52
120
|
if (!t.name.trim()) return n("integrations.addConnection.errors.nameRequired", "Connection name is required");
|
|
121
|
+
if (t.reconnect && t.reconnectMethodKey && t.method?.key !== t.reconnectMethodKey) return n("integrations.addConnection.reconnect.methodUnavailable", "This connection's sign-in method is no longer available. Remove the connection and connect the app again.");
|
|
53
122
|
if (t.method && !t.method.isConfigured) return n("integrations.addConnection.authentication.methodNotConfigured", "This authentication method is not configured in this environment. Ask an administrator to add its credentials, or pick another method.");
|
|
54
|
-
if (!t.reconnect &&
|
|
55
|
-
if (!
|
|
123
|
+
if (!t.reconnect && g(r, t.provider)) {
|
|
124
|
+
if (!p(t.provider, t.method).includes(t.storage.mode)) return n("integrations.addConnection.errors.storageModeUnsupported", "This authentication method does not support the selected credential storage mode.");
|
|
56
125
|
if (t.storage.mode === "existing") {
|
|
57
126
|
if (!t.storage.vaultId) return n("integrations.addConnection.errors.vaultRequired", "Please select a vault for storing or referencing credentials");
|
|
58
127
|
if (!t.storage.secretId) return n("integrations.addConnection.errors.secretRequired", "Please select an existing vault secret to reuse");
|
|
59
128
|
} else if (t.requireVault && !t.storage.vaultId) return n("integrations.addConnection.errors.vaultRequired", "Please select a vault for storing or referencing credentials");
|
|
60
129
|
}
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
130
|
+
let o = t.reconnect ? y(a, r, "") : a;
|
|
131
|
+
if (r !== "minted" && o && !e(o, t.values)) return n("integrations.addConnection.errors.fieldsRequired", "Please fill in all required fields");
|
|
132
|
+
if (r !== "minted" && a) {
|
|
133
|
+
let e = i(D(a, t.values));
|
|
64
134
|
if (!e.ok) {
|
|
65
135
|
let t = a.properties[e.field]?.title ?? e.field;
|
|
66
|
-
return
|
|
136
|
+
return E(e.problem, t, n);
|
|
67
137
|
}
|
|
68
|
-
if (e.references.length > 0 &&
|
|
138
|
+
if (e.references.length > 0 && r !== "fields") return n("integrations.addConnection.secretReferences.fieldsOnly", "External secret references can only be used with sign-in methods that take field values.");
|
|
69
139
|
}
|
|
70
140
|
return null;
|
|
71
141
|
}
|
|
72
|
-
function
|
|
142
|
+
function E(e, t, n) {
|
|
73
143
|
switch (e) {
|
|
74
144
|
case "notClosed": return n("integrations.addConnection.secretReferences.notClosed", "\"{{field}}\" has a secret reference that is not closed with two closing braces.", { field: t });
|
|
75
145
|
case "badProvider": return n("integrations.addConnection.secretReferences.badProvider", "\"{{field}}\" has a secret reference with an invalid provider key. Use the key shown under Security, External secrets.", { field: t });
|
|
@@ -78,25 +148,25 @@ function _(e, t, n) {
|
|
|
78
148
|
case "tooMany": return n("integrations.addConnection.secretReferences.tooMany", "A connection can reference at most 20 external secrets.");
|
|
79
149
|
}
|
|
80
150
|
}
|
|
81
|
-
function
|
|
82
|
-
let
|
|
83
|
-
for (let [i, a] of Object.entries(
|
|
151
|
+
function D(e, t) {
|
|
152
|
+
let n = {};
|
|
153
|
+
for (let [i, a] of Object.entries(r(e, t))) if (typeof a == "string") {
|
|
84
154
|
let e = a.trim();
|
|
85
|
-
e && (
|
|
86
|
-
} else a != null && (
|
|
87
|
-
return
|
|
155
|
+
e && (n[i] = e);
|
|
156
|
+
} else a != null && (n[i] = a);
|
|
157
|
+
return n;
|
|
88
158
|
}
|
|
89
|
-
function
|
|
90
|
-
let t =
|
|
159
|
+
function O(e) {
|
|
160
|
+
let t = c(e.provider, e.method), n = l(e.provider, e.method), r = t === "oauth2" ? D(n, e.values) : {}, i = {
|
|
91
161
|
...e.extraConfig ?? {},
|
|
92
162
|
...r
|
|
93
163
|
}, a = {
|
|
94
164
|
name: e.name.trim(),
|
|
95
165
|
providerId: e.provider.id
|
|
96
166
|
}, o = e.description.trim();
|
|
97
|
-
if (o && (a.description = o), e.method && (a.authMethodKey = e.method.key), Object.keys(i).length > 0 && (a.config = i), e.visibility && (a.visibility = e.visibility),
|
|
167
|
+
if (o && (a.description = o), e.method && (a.authMethodKey = e.method.key), Object.keys(i).length > 0 && (a.config = i), e.visibility && (a.visibility = e.visibility), g(t, e.provider)) {
|
|
98
168
|
let { storage: t } = e;
|
|
99
|
-
if (!
|
|
169
|
+
if (!p(e.provider, e.method).includes(t.mode)) throw Error("This authentication method does not support the selected credential storage mode.");
|
|
100
170
|
if (t.mode === "existing") {
|
|
101
171
|
if (!t.vaultId) throw Error("Please select a vault for storing or referencing credentials");
|
|
102
172
|
if (!t.secretId) throw Error("Please select an existing vault secret to reuse");
|
|
@@ -112,9 +182,21 @@ function y(e) {
|
|
|
112
182
|
}
|
|
113
183
|
return a;
|
|
114
184
|
}
|
|
115
|
-
async function
|
|
116
|
-
let r =
|
|
117
|
-
|
|
185
|
+
async function k(e, t, n) {
|
|
186
|
+
let r = c(t.provider, t.method), i = n.existing;
|
|
187
|
+
if (!i) i = await e.createConnection(O(t)), n.onCreated?.(i);
|
|
188
|
+
else if (n.reconnectFrom) {
|
|
189
|
+
let r = C(t, n.reconnectFrom);
|
|
190
|
+
if (r) {
|
|
191
|
+
let a = await e.updateConnection(i.id, r);
|
|
192
|
+
if (!a) throw Error("The connection could not be updated");
|
|
193
|
+
i = {
|
|
194
|
+
...i,
|
|
195
|
+
...a
|
|
196
|
+
}, n.onReconnectSaved?.(w(n.reconnectFrom, r, l(t.provider, t.method), t.values));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
switch (r) {
|
|
118
200
|
case "oauth2": {
|
|
119
201
|
let { redirectUrl: t } = await e.initiateOAuth({
|
|
120
202
|
connectionId: i.id,
|
|
@@ -122,10 +204,20 @@ async function b(e, t, n) {
|
|
|
122
204
|
...n.scopes ? { scopes: n.scopes } : {}
|
|
123
205
|
});
|
|
124
206
|
if (!t) throw Error("Failed to initiate OAuth flow");
|
|
207
|
+
let r = { status: "PENDING_AUTH" };
|
|
208
|
+
if (n.existing) {
|
|
209
|
+
let t = await e.getConnection(i.id);
|
|
210
|
+
if (!t) throw Error("Failed to initiate OAuth flow");
|
|
211
|
+
r = {
|
|
212
|
+
status: t.status,
|
|
213
|
+
updatedAt: t.updatedAt ?? null
|
|
214
|
+
};
|
|
215
|
+
}
|
|
125
216
|
return {
|
|
126
217
|
kind: "oauth",
|
|
127
218
|
connection: i,
|
|
128
|
-
redirectUrl: t
|
|
219
|
+
redirectUrl: t,
|
|
220
|
+
baseline: r
|
|
129
221
|
};
|
|
130
222
|
}
|
|
131
223
|
case "minted": return (t.method?.authType ?? t.provider.authType) === "service_account" ? {
|
|
@@ -143,9 +235,9 @@ async function b(e, t, n) {
|
|
|
143
235
|
connection: await e.authenticateConnection({
|
|
144
236
|
connectionId: i.id,
|
|
145
237
|
...t.method ? { authMethodKey: t.method.key } : {},
|
|
146
|
-
values:
|
|
238
|
+
values: D(l(t.provider, t.method), t.values)
|
|
147
239
|
}) ?? i
|
|
148
240
|
};
|
|
149
241
|
}
|
|
150
242
|
}
|
|
151
|
-
export {
|
|
243
|
+
export { w as applyReconnectUpdate, O as buildCreateInput, C as buildReconnectUpdate, h as collectsOwnClientId, a as flowForAuthType, _ as isSecretField, g as needsCredentialStorage, m as normalizeStorageMode, v as reconnectEditsConfig, b as reconnectInitialValues, y as reconnectSchema, c as resolveFlow, s as resolveMethod, l as resolveSchema, o as selectableMethods, k as submitConnection, D as submittedValues, p as supportedStorageModes, T as validateDraft };
|
|
@@ -21,8 +21,8 @@ export { CONNECT_MORE_OPTIONS_KEY, OneScreenConnectionForm } from './OneScreenCo
|
|
|
21
21
|
export { compatibleSecrets, defaultVault, EMPTY_STORAGE, withDefaultVault } from './storage';
|
|
22
22
|
export { groupByCategory, isPopularProvider, needsAdminSetup, pickableProviders, POPULAR_PROVIDER_KEYS, popularFirst, } from './picker';
|
|
23
23
|
export { ScopePicker } from './ScopePicker';
|
|
24
|
-
export { createConnectionsApi, mapProvider, normalizeAuthType, type ConnectionRecord, type ConnectionsApi, type ConnectionsApiOptions, type CreateConnectionInput, } from './api';
|
|
25
|
-
export { buildCreateInput, collectsOwnClientId, flowForAuthType, resolveFlow, resolveMethod, resolveSchema, submitConnection, submittedValues, validateDraft, type ConnectionDraft, type FlowStep, } from './connectionFlow';
|
|
24
|
+
export { createConnectionsApi, mapProvider, normalizeAuthType, type ConnectionRecord, type ConnectionSettings, type ConnectionsApi, type ConnectionsApiOptions, type CreateConnectionInput, type UpdateConnectionInput, } from './api';
|
|
25
|
+
export { applyReconnectUpdate, buildCreateInput, buildReconnectUpdate, collectsOwnClientId, flowForAuthType, isSecretField, reconnectEditsConfig, reconnectInitialValues, reconnectSchema, resolveFlow, resolveMethod, resolveSchema, submitConnection, submittedValues, validateDraft, type ConnectionDraft, type FlowStep, } from './connectionFlow';
|
|
26
26
|
export { waitForOAuthCompletion, isOAuthCallbackMessage } from './oauthPopup';
|
|
27
27
|
export { getProviderAccent, getProviderIconName, getProviderImageSource, getProviderTextIcon, normalizeProviderCategory, type ProviderIdentity, } from './providerIdentity';
|
|
28
28
|
export { isScopeChecked, parseScopeOptions, requestedScopes, toggleScope, type ScopeOption, type ScopeSelection, } from './scopes';
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Previously the integrations screens only listened and the workflow builder
|
|
12
12
|
* only polled; each missed the cases the other handled.
|
|
13
|
+
*
|
|
14
|
+
* Polling reports only a change. Reconnect signs in again on a connection that
|
|
15
|
+
* already reads as ERROR (or ACTIVE), and a poll that took that state for the
|
|
16
|
+
* new sign-in's result closed the popup within two seconds and showed the old
|
|
17
|
+
* error. So the state the connection is in when the wait starts is read first
|
|
18
|
+
* and kept as the baseline, and a later read counts as the outcome only once
|
|
19
|
+
* its status or `updatedAt` differs from it.
|
|
13
20
|
*/
|
|
14
21
|
/** What the callback page posts. */
|
|
15
22
|
interface OAuthCallbackMessage {
|
|
@@ -22,6 +29,8 @@ interface OAuthCallbackMessage {
|
|
|
22
29
|
export interface OAuthConnectionStatus {
|
|
23
30
|
status?: string | null;
|
|
24
31
|
errorMessage?: string | null;
|
|
32
|
+
/** When the service last wrote the record. */
|
|
33
|
+
updatedAt?: string | null;
|
|
25
34
|
}
|
|
26
35
|
type EventSource = Pick<Window, 'addEventListener' | 'removeEventListener'>;
|
|
27
36
|
export interface WaitForOAuthOptions<T extends OAuthConnectionStatus> {
|
|
@@ -37,11 +46,17 @@ export interface WaitForOAuthOptions<T extends OAuthConnectionStatus> {
|
|
|
37
46
|
timeoutMs?: number;
|
|
38
47
|
/** Where messages and storage events arrive; the window by default. */
|
|
39
48
|
eventSource?: EventSource | null;
|
|
49
|
+
/**
|
|
50
|
+
* The connection as it was before the person signed in, read before the
|
|
51
|
+
* popup opened. Without it the wait's first read is taken as the baseline,
|
|
52
|
+
* which is only safe while nothing can have completed yet.
|
|
53
|
+
*/
|
|
54
|
+
baseline?: OAuthConnectionStatus | null;
|
|
40
55
|
}
|
|
41
56
|
export declare function isOAuthCallbackMessage(value: unknown): value is OAuthCallbackMessage;
|
|
42
57
|
/**
|
|
43
58
|
* Start waiting. Returns a cancel function that stops every listener and timer
|
|
44
59
|
* without reporting an outcome — for when the dialog closes mid-wait.
|
|
45
60
|
*/
|
|
46
|
-
export declare function waitForOAuthCompletion<T extends OAuthConnectionStatus>({ connectionId, popup, fetchConnection, onSuccess, onError, onSettled, pollIntervalMs, timeoutMs, eventSource, }: WaitForOAuthOptions<T>): () => void;
|
|
61
|
+
export declare function waitForOAuthCompletion<T extends OAuthConnectionStatus>({ connectionId, popup, fetchConnection, onSuccess, onError, onSettled, pollIntervalMs, timeoutMs, eventSource, baseline: knownBaseline, }: WaitForOAuthOptions<T>): () => void;
|
|
47
62
|
export {};
|
|
@@ -1,68 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
var e = "PENDING_AUTH";
|
|
3
|
-
function t(e) {
|
|
1
|
+
function e(e) {
|
|
4
2
|
return typeof e == "object" && !!e;
|
|
5
3
|
}
|
|
6
|
-
function
|
|
7
|
-
return t
|
|
4
|
+
function t(t) {
|
|
5
|
+
return e(t) && t.type === "OAUTH_CALLBACK" && typeof t.success == "boolean" && (t.connectionId === void 0 || typeof t.connectionId == "string") && (t.error === void 0 || typeof t.error == "string");
|
|
8
6
|
}
|
|
9
|
-
function
|
|
7
|
+
function n(e) {
|
|
10
8
|
if (!e) return null;
|
|
11
9
|
try {
|
|
12
|
-
let
|
|
13
|
-
return n
|
|
10
|
+
let n = JSON.parse(e);
|
|
11
|
+
return t(n) ? n : null;
|
|
14
12
|
} catch {
|
|
15
13
|
return null;
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
|
-
function
|
|
16
|
+
function r({ connectionId: e, popup: r, fetchConnection: i, onSuccess: a, onError: o, onSettled: s, pollIntervalMs: c = 2e3, timeoutMs: l = 3e5, eventSource: u = typeof window > "u" ? null : window, baseline: d = null }) {
|
|
19
17
|
let f = !1, p = null, m = null, h = null, g = () => {
|
|
20
|
-
m && clearInterval(m), h && clearTimeout(h), m = null, h = null,
|
|
18
|
+
m && clearInterval(m), h && clearTimeout(h), m = null, h = null, u?.removeEventListener("message", C), u?.removeEventListener("storage", w), p?.close(), p = null;
|
|
21
19
|
}, _ = (e) => {
|
|
22
20
|
if (!f) {
|
|
23
|
-
f = !0, g(),
|
|
21
|
+
f = !0, g(), r.closed || r.close();
|
|
24
22
|
try {
|
|
25
23
|
e();
|
|
26
24
|
} finally {
|
|
27
|
-
|
|
25
|
+
s();
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
|
-
}, v =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
}, v = d ? {
|
|
29
|
+
status: d.status ?? null,
|
|
30
|
+
updatedAt: d.updatedAt ?? null
|
|
31
|
+
} : null, y = (e) => !e?.status || e.status === "PENDING_AUTH", b = (e) => v === null || e.status !== v.status || (e.updatedAt ?? null) !== (v.updatedAt ?? null), x = (e) => {
|
|
32
|
+
e ? e.status === "ACTIVE" ? a(e) : o(e.errorMessage || "OAuth authorization failed") : o("Connection not found. It may have been deleted.");
|
|
33
|
+
}, S = async (t) => {
|
|
34
|
+
if (f || t.connectionId && t.connectionId !== e) return;
|
|
35
|
+
if (!t.success) {
|
|
36
|
+
_(() => o(t.error || "OAuth authorization failed"));
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
|
-
let
|
|
39
|
+
let n;
|
|
39
40
|
try {
|
|
40
|
-
|
|
41
|
+
n = await i();
|
|
41
42
|
} catch {
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
|
-
(
|
|
45
|
+
n && y(n) || (!n || b(n)) && _(() => x(n));
|
|
45
46
|
};
|
|
46
|
-
function
|
|
47
|
-
let
|
|
48
|
-
n
|
|
47
|
+
function C(e) {
|
|
48
|
+
let n = e.data;
|
|
49
|
+
t(n) && S(n);
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
+
function w(e) {
|
|
51
52
|
let t = e;
|
|
52
53
|
if (t.key !== "oauth_callback_result") return;
|
|
53
|
-
let
|
|
54
|
-
|
|
54
|
+
let r = n(t.newValue);
|
|
55
|
+
r && S(r);
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
u?.addEventListener("message", C), u?.addEventListener("storage", w), typeof BroadcastChannel < "u" && (p = new BroadcastChannel("oauth_callback"), p.onmessage = (e) => {
|
|
58
|
+
t(e.data) && S(e.data);
|
|
59
|
+
});
|
|
60
|
+
let T = !1, E = () => {
|
|
61
|
+
T || f || (T = !0, i().then((e) => {
|
|
62
|
+
!f && e?.status && (v === null ? v = {
|
|
63
|
+
status: e.status,
|
|
64
|
+
updatedAt: e.updatedAt ?? null
|
|
65
|
+
} : !y(e) && b(e) && _(() => x(e)));
|
|
66
|
+
}).catch(() => void 0).finally(() => {
|
|
67
|
+
T = !1;
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
return v === null && E(), m = setInterval(E, c), h = setTimeout(() => {
|
|
71
|
+
_(() => o("OAuth authorization timed out"));
|
|
72
|
+
}, l), () => {
|
|
65
73
|
f || (f = !0, g());
|
|
66
74
|
};
|
|
67
75
|
}
|
|
68
|
-
export {
|
|
76
|
+
export { t as isOAuthCallbackMessage, r as waitForOAuthCompletion };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Translator } from '../credentials/translate';
|
|
2
|
-
import { ConnectionRecord, ConnectionsApi } from './api';
|
|
2
|
+
import { ConnectionRecord, ConnectionSettings, ConnectionsApi } from './api';
|
|
3
3
|
import { ConnectionDraft } from './connectionFlow';
|
|
4
4
|
import { ConnectionDialogEvent, CreatedConnection } from './types';
|
|
5
5
|
interface UseConnectionSubmitOptions {
|
|
@@ -14,6 +14,11 @@ interface UseConnectionSubmitOptions {
|
|
|
14
14
|
* (Reconnect). The record keeps its id, so nothing that uses it breaks.
|
|
15
15
|
*/
|
|
16
16
|
reconnectConnection?: ConnectionRecord | null;
|
|
17
|
+
/**
|
|
18
|
+
* The reconnected connection's values as the form opened with them. What
|
|
19
|
+
* the person changed is saved before signing in again.
|
|
20
|
+
*/
|
|
21
|
+
reconnectSettings?: ConnectionSettings | null;
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* The connection the last attempt created, and the create input that made it.
|
|
@@ -42,7 +47,7 @@ export declare function reusableRecord(reconnect: ConnectionRecord | null | unde
|
|
|
42
47
|
* earlier one failed before announcing it.
|
|
43
48
|
*/
|
|
44
49
|
export declare function shouldAnnounce(connectionId: string, previous: PreviousAttempt | null, reconnect: ConnectionRecord | null | undefined): boolean;
|
|
45
|
-
export declare function useConnectionSubmit({ api, callbackUrl, translate: tr, onConnectionCreated, onError, onEvent, reconnectConnection, }: UseConnectionSubmitOptions): {
|
|
50
|
+
export declare function useConnectionSubmit({ api, callbackUrl, translate: tr, onConnectionCreated, onError, onEvent, reconnectConnection, reconnectSettings, }: UseConnectionSubmitOptions): {
|
|
46
51
|
submit: (draft: ConnectionDraft, scopes: string[] | undefined) => Promise<void>;
|
|
47
52
|
busy: boolean;
|
|
48
53
|
oauthWaiting: boolean;
|