@machinemetrics/mm-react-embeddable 2.0.0-2 → 2.0.0-3
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 +10 -9
- package/dist/mm-react-embeddable.cjs.js +4 -40
- package/dist/mm-react-embeddable.es.js +335 -413
- package/dist/mm-react-embeddable.umd.js +4 -40
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import z, { createContext as oe, useContext as v, useState as C, useRef as R, useCallback as h, useEffect as k, useMemo as ue } from "react";
|
|
2
|
+
import T from "prop-types";
|
|
3
|
+
import te from "styled-components";
|
|
4
|
+
const X = oe(null), V = oe({
|
|
5
5
|
pending: [],
|
|
6
6
|
authorize: () => {
|
|
7
7
|
},
|
|
@@ -14,69 +14,74 @@ const Y = ce(null), J = ce({
|
|
|
14
14
|
originEpochs: {},
|
|
15
15
|
credentials: {},
|
|
16
16
|
unsupported: {}
|
|
17
|
-
}),
|
|
18
|
-
kind:
|
|
17
|
+
}), le = "access_token", re = (r) => r ? r.kind ? r : r.accessToken ? {
|
|
18
|
+
kind: le,
|
|
19
19
|
accessToken: r.accessToken,
|
|
20
20
|
expiresAt: r.expiresAt || null
|
|
21
|
-
} : null : null,
|
|
21
|
+
} : null : null, ae = /* @__PURE__ */ new Set([
|
|
22
|
+
"host_not_allowed",
|
|
23
|
+
"unbound_host_bound_guest",
|
|
24
|
+
"invalid_token",
|
|
25
|
+
"provider_unavailable"
|
|
26
|
+
]), Q = typeof window != "undefined" && window.location.protocol === "https:", de = 8e3, J = (r) => {
|
|
22
27
|
try {
|
|
23
28
|
return new URL(r).origin;
|
|
24
29
|
} catch {
|
|
25
30
|
return null;
|
|
26
31
|
}
|
|
27
|
-
}, ne = (r,
|
|
28
|
-
const
|
|
29
|
-
return !
|
|
30
|
-
},
|
|
32
|
+
}, ne = (r, i) => {
|
|
33
|
+
const u = i == null ? void 0 : i.origin;
|
|
34
|
+
return !u || J(r == null ? void 0 : r.authUrl) !== u ? null : u;
|
|
35
|
+
}, se = (r) => {
|
|
31
36
|
if (!r || /^\d{1,3}(?:\.\d{1,3}){3}$/.test(r) || r.includes(":"))
|
|
32
37
|
return r;
|
|
33
|
-
const
|
|
34
|
-
return
|
|
35
|
-
},
|
|
38
|
+
const i = r.split(".");
|
|
39
|
+
return i.length <= 2 ? r : i.slice(-2).join(".");
|
|
40
|
+
}, fe = (r, i) => {
|
|
36
41
|
try {
|
|
37
|
-
const
|
|
38
|
-
return
|
|
42
|
+
const u = new URL(r), d = new URL(i);
|
|
43
|
+
return u.protocol !== d.protocol ? !0 : se(u.hostname) !== se(d.hostname);
|
|
39
44
|
} catch {
|
|
40
45
|
return !0;
|
|
41
46
|
}
|
|
42
|
-
},
|
|
43
|
-
const
|
|
47
|
+
}, pe = (r, { onBlocked: i, onClosed: u }) => {
|
|
48
|
+
const d = window.open(
|
|
44
49
|
r.authUrl,
|
|
45
50
|
"mm-embed-auth",
|
|
46
51
|
"popup,width=600,height=700"
|
|
47
52
|
);
|
|
48
|
-
if (!
|
|
49
|
-
return
|
|
53
|
+
if (!d)
|
|
54
|
+
return i(), () => {
|
|
50
55
|
};
|
|
51
56
|
const p = setInterval(() => {
|
|
52
|
-
|
|
57
|
+
d.closed && (clearInterval(p), u());
|
|
53
58
|
}, 1e3);
|
|
54
59
|
return () => clearInterval(p);
|
|
55
|
-
},
|
|
56
|
-
const
|
|
57
|
-
|
|
60
|
+
}, ie = ({ children: r, launcher: i, broker: u }) => {
|
|
61
|
+
const d = v(X), [p, m] = C({}), [j, I] = C({}), [L, O] = C({}), [P, S] = C({}), Z = R(L);
|
|
62
|
+
Z.current = L;
|
|
58
63
|
const b = R(p);
|
|
59
64
|
b.current = p;
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const t =
|
|
65
|
+
const x = R(null), K = R({}), _ = R({}), q = R({}), F = R(u);
|
|
66
|
+
F.current = u;
|
|
67
|
+
const U = h((e) => {
|
|
68
|
+
const t = _.current[e];
|
|
64
69
|
if (!t)
|
|
65
70
|
return;
|
|
66
|
-
const n = (
|
|
67
|
-
m(n),
|
|
68
|
-
}, []),
|
|
71
|
+
const n = (o) => !o[e] || o[e].clientId ? o : { ...o, [e]: { ...o[e], clientId: t } };
|
|
72
|
+
m(n), S(n);
|
|
73
|
+
}, []), c = h(
|
|
69
74
|
(e, t) => {
|
|
70
|
-
e && (
|
|
75
|
+
e && (S((n) => n[e] ? n : {
|
|
71
76
|
...n,
|
|
72
|
-
[e]: { origin: e, reason: t, clientId:
|
|
73
|
-
}),
|
|
77
|
+
[e]: { origin: e, reason: t, clientId: _.current[e] || null }
|
|
78
|
+
}), U(e));
|
|
74
79
|
},
|
|
75
|
-
[
|
|
76
|
-
), l =
|
|
80
|
+
[U]
|
|
81
|
+
), l = h(
|
|
77
82
|
(e, { v2: t = !1, origin: n = null } = {}) => {
|
|
78
|
-
n && (t &&
|
|
79
|
-
...
|
|
83
|
+
n && (t && Z.current[n] || (m((o) => o[n] ? o : {
|
|
84
|
+
...o,
|
|
80
85
|
[n]: {
|
|
81
86
|
origin: n,
|
|
82
87
|
authUrl: e.authUrl,
|
|
@@ -84,61 +89,61 @@ const Y = ce(null), J = ce({
|
|
|
84
89
|
// v2 entries try the invisible silent resolver first — but only on a host that can
|
|
85
90
|
// frame login (https). Otherwise (and for legacy signals) go straight to interactive,
|
|
86
91
|
// so an http host doesn't wait out a silent frame that can never load login.
|
|
87
|
-
status: t &&
|
|
92
|
+
status: t && F.current ? "broker" : t && e.silentUrl && Q ? "silent" : "interactive",
|
|
88
93
|
v2: t,
|
|
89
94
|
// v1.9: the scope the guest asked for; forwarded verbatim to the broker.
|
|
90
95
|
scope: e.scope || null,
|
|
91
|
-
acceptsCredentials:
|
|
96
|
+
acceptsCredentials: q.current[n] || null,
|
|
92
97
|
consent: null,
|
|
93
98
|
error: null,
|
|
94
99
|
// clientId from the request payload (v2) or the cached init (legacy);
|
|
95
100
|
// the host resolves the display name from it.
|
|
96
|
-
clientId: e.clientId ||
|
|
101
|
+
clientId: e.clientId || _.current[n] || null,
|
|
97
102
|
popupBlocked: !1
|
|
98
103
|
}
|
|
99
|
-
}),
|
|
104
|
+
}), U(n)));
|
|
100
105
|
},
|
|
101
|
-
[
|
|
102
|
-
), s =
|
|
106
|
+
[U]
|
|
107
|
+
), s = h((e) => {
|
|
103
108
|
m((t) => {
|
|
104
109
|
if (!t[e])
|
|
105
110
|
return t;
|
|
106
111
|
const n = { ...t };
|
|
107
112
|
return delete n[e], n;
|
|
108
113
|
});
|
|
109
|
-
}, []),
|
|
114
|
+
}, []), a = h(
|
|
110
115
|
(e) => {
|
|
111
|
-
e && (s(e),
|
|
116
|
+
e && (s(e), I((t) => ({
|
|
112
117
|
...t,
|
|
113
118
|
[e]: (t[e] || 0) + 1
|
|
114
119
|
})));
|
|
115
120
|
},
|
|
116
121
|
[s]
|
|
117
|
-
),
|
|
122
|
+
), E = h((e) => {
|
|
118
123
|
m((t) => !t[e] || t[e].status === "interactive" ? t : {
|
|
119
124
|
...t,
|
|
120
125
|
[e]: { ...t[e], status: "interactive" }
|
|
121
126
|
});
|
|
122
|
-
}, []),
|
|
127
|
+
}, []), w = h(
|
|
123
128
|
(e) => {
|
|
124
129
|
s(e.origin);
|
|
125
130
|
},
|
|
126
131
|
[s]
|
|
127
|
-
),
|
|
132
|
+
), $ = h(
|
|
128
133
|
(e, t) => {
|
|
129
134
|
const n = ne(e, t);
|
|
130
135
|
if (n) {
|
|
131
|
-
if (
|
|
132
|
-
|
|
136
|
+
if (fe(n, window.location.origin)) {
|
|
137
|
+
c(n, "cross-site-legacy");
|
|
133
138
|
return;
|
|
134
139
|
}
|
|
135
140
|
l(e, { origin: n });
|
|
136
141
|
}
|
|
137
142
|
},
|
|
138
|
-
[l,
|
|
143
|
+
[l, c]
|
|
139
144
|
);
|
|
140
|
-
|
|
141
|
-
if (!
|
|
145
|
+
k(() => {
|
|
146
|
+
if (!d)
|
|
142
147
|
return;
|
|
143
148
|
const e = [
|
|
144
149
|
// `init` carries the app's OAuth clientId. Cache it by the ATTESTED app
|
|
@@ -147,132 +152,132 @@ const Y = ce(null), J = ce({
|
|
|
147
152
|
// signals, so it is usually cached by the time an entry is created. The
|
|
148
153
|
// clientId is only a lookup key: the host resolves the display name from
|
|
149
154
|
// it, and a broker binds it to the attested origin server-side.
|
|
150
|
-
|
|
151
|
-
n != null && n.origin && (t != null && t.clientId) && (
|
|
155
|
+
d.addListener("*", "init", (t, n) => {
|
|
156
|
+
n != null && n.origin && (t != null && t.clientId) && (_.current[n.origin] = t.clientId, U(n.origin)), n != null && n.origin && Array.isArray(t == null ? void 0 : t.acceptsCredentials) && (q.current[n.origin] = t.acceptsCredentials);
|
|
152
157
|
}),
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
d.addListener("*", "authorize", $),
|
|
159
|
+
d.addListener("*", "login", $),
|
|
160
|
+
d.addListener(
|
|
156
161
|
"*",
|
|
157
162
|
"credential-request",
|
|
158
163
|
(t, n) => l(t, { v2: !0, origin: ne(t, n) })
|
|
159
164
|
)
|
|
160
165
|
];
|
|
161
166
|
return () => e.forEach((t) => t());
|
|
162
|
-
}, [
|
|
167
|
+
}, [d, $, l, U]), k(() => {
|
|
163
168
|
const e = (t) => {
|
|
164
169
|
const n = t == null ? void 0 : t.data;
|
|
165
170
|
if (!n || n.type !== "authorized" && n.type !== "authorize-failed")
|
|
166
171
|
return;
|
|
167
|
-
const
|
|
168
|
-
if (!(!
|
|
172
|
+
const o = J(n.authUrl);
|
|
173
|
+
if (!(!o || t.origin !== o)) {
|
|
169
174
|
if (n.type === "authorized") {
|
|
170
175
|
if (n.accessToken) {
|
|
171
|
-
if (!b.current[
|
|
176
|
+
if (!b.current[o])
|
|
172
177
|
return;
|
|
173
|
-
|
|
174
|
-
...
|
|
175
|
-
[
|
|
176
|
-
})), s(
|
|
178
|
+
O((f) => ({
|
|
179
|
+
...f,
|
|
180
|
+
[o]: re({ accessToken: n.accessToken })
|
|
181
|
+
})), s(o);
|
|
177
182
|
} else
|
|
178
|
-
|
|
183
|
+
a(o);
|
|
179
184
|
return;
|
|
180
185
|
}
|
|
181
|
-
|
|
186
|
+
E(o);
|
|
182
187
|
}
|
|
183
188
|
};
|
|
184
189
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
185
|
-
}, [s,
|
|
186
|
-
const
|
|
190
|
+
}, [s, a, E]);
|
|
191
|
+
const M = h(
|
|
187
192
|
(e, t) => {
|
|
188
|
-
const n = e == null ? void 0 : e.origin,
|
|
189
|
-
!n || !
|
|
193
|
+
const n = e == null ? void 0 : e.origin, o = re(t);
|
|
194
|
+
!n || !o || (O((f) => ({ ...f, [n]: o })), s(n));
|
|
190
195
|
},
|
|
191
196
|
[s]
|
|
192
|
-
),
|
|
197
|
+
), g = h((e, t) => {
|
|
193
198
|
m((n) => n[e] ? { ...n, [e]: { ...n[e], ...t } } : n);
|
|
194
|
-
}, []),
|
|
199
|
+
}, []), A = h(
|
|
195
200
|
async (e, { approve: t } = {}) => {
|
|
196
|
-
const n =
|
|
197
|
-
let
|
|
201
|
+
const n = F.current, { origin: o } = e;
|
|
202
|
+
let f;
|
|
198
203
|
try {
|
|
199
|
-
|
|
200
|
-
{ origin:
|
|
204
|
+
f = await n(
|
|
205
|
+
{ origin: o, clientId: e.clientId, scope: e.scope, authUrl: e.authUrl },
|
|
201
206
|
{ approve: t }
|
|
202
207
|
);
|
|
203
208
|
} catch {
|
|
204
|
-
t ?
|
|
205
|
-
status: e.silentUrl &&
|
|
209
|
+
t ? g(o, { error: { reason: "broker_unavailable" } }) : g(o, {
|
|
210
|
+
status: e.silentUrl && Q ? "silent" : "interactive"
|
|
206
211
|
});
|
|
207
212
|
return;
|
|
208
213
|
}
|
|
209
|
-
if ((
|
|
210
|
-
|
|
214
|
+
if ((f == null ? void 0 : f.status) === 200 && f.credential) {
|
|
215
|
+
M(e, f.credential);
|
|
211
216
|
return;
|
|
212
217
|
}
|
|
213
|
-
if ((
|
|
214
|
-
|
|
218
|
+
if ((f == null ? void 0 : f.status) === 409 && f.consentRequired) {
|
|
219
|
+
g(o, {
|
|
215
220
|
status: "interactive",
|
|
216
221
|
consent: {
|
|
217
|
-
client:
|
|
218
|
-
stepUp: !!
|
|
219
|
-
scope:
|
|
222
|
+
client: f.client || null,
|
|
223
|
+
stepUp: !!f.stepUp,
|
|
224
|
+
scope: f.scope || e.scope
|
|
220
225
|
},
|
|
221
226
|
error: null
|
|
222
227
|
});
|
|
223
228
|
return;
|
|
224
229
|
}
|
|
225
|
-
const
|
|
226
|
-
if (!t &&
|
|
227
|
-
|
|
228
|
-
status: e.silentUrl &&
|
|
230
|
+
const Y = (f == null ? void 0 : f.error) || "broker_error";
|
|
231
|
+
if (!t && ae.has(Y)) {
|
|
232
|
+
g(o, {
|
|
233
|
+
status: e.silentUrl && Q ? "silent" : "interactive"
|
|
229
234
|
});
|
|
230
235
|
return;
|
|
231
236
|
}
|
|
232
|
-
if (t &&
|
|
233
|
-
|
|
237
|
+
if (t && Y === "consent_denied") {
|
|
238
|
+
g(o, { error: null });
|
|
234
239
|
return;
|
|
235
240
|
}
|
|
236
|
-
s(
|
|
237
|
-
...
|
|
238
|
-
[
|
|
239
|
-
origin:
|
|
240
|
-
reason: `broker:${
|
|
241
|
-
detail:
|
|
242
|
-
clientId: e.clientId ||
|
|
241
|
+
s(o), S((ee) => ({
|
|
242
|
+
...ee,
|
|
243
|
+
[o]: {
|
|
244
|
+
origin: o,
|
|
245
|
+
reason: `broker:${Y}`,
|
|
246
|
+
detail: f || null,
|
|
247
|
+
clientId: e.clientId || _.current[o] || null
|
|
243
248
|
}
|
|
244
249
|
}));
|
|
245
250
|
},
|
|
246
|
-
[
|
|
247
|
-
),
|
|
248
|
-
|
|
251
|
+
[M, g, s]
|
|
252
|
+
), B = R({});
|
|
253
|
+
k(() => {
|
|
249
254
|
Object.values(p).forEach((e) => {
|
|
250
|
-
e.status !== "broker" ||
|
|
251
|
-
delete
|
|
255
|
+
e.status !== "broker" || B.current[e.origin] || (B.current[e.origin] = !0, A(e).finally(() => {
|
|
256
|
+
delete B.current[e.origin];
|
|
252
257
|
}));
|
|
253
258
|
});
|
|
254
|
-
}, [p,
|
|
255
|
-
const
|
|
256
|
-
(e) => !
|
|
257
|
-
[
|
|
259
|
+
}, [p, A]);
|
|
260
|
+
const y = h(
|
|
261
|
+
(e) => !F.current || !(e != null && e.consent) ? Promise.resolve() : A(e, { approve: !0 }),
|
|
262
|
+
[A]
|
|
258
263
|
);
|
|
259
|
-
|
|
260
|
-
const e =
|
|
264
|
+
k(() => {
|
|
265
|
+
const e = K.current;
|
|
261
266
|
Object.values(p).forEach((t) => {
|
|
262
267
|
t.status === "silent" && !e[t.origin] && (e[t.origin] = setTimeout(() => {
|
|
263
|
-
delete e[t.origin],
|
|
264
|
-
},
|
|
268
|
+
delete e[t.origin], E(t.origin);
|
|
269
|
+
}, de));
|
|
265
270
|
}), Object.keys(e).forEach((t) => {
|
|
266
271
|
(!p[t] || p[t].status !== "silent") && (clearTimeout(e[t]), delete e[t]);
|
|
267
272
|
});
|
|
268
|
-
}, [p,
|
|
269
|
-
|
|
273
|
+
}, [p, E]), k(() => () => {
|
|
274
|
+
x.current && x.current(), Object.values(K.current).forEach(clearTimeout);
|
|
270
275
|
}, []);
|
|
271
|
-
const
|
|
276
|
+
const W = h(
|
|
272
277
|
(e) => {
|
|
273
|
-
|
|
274
|
-
const t =
|
|
275
|
-
|
|
278
|
+
x.current && (x.current(), x.current = null);
|
|
279
|
+
const t = i || pe;
|
|
280
|
+
x.current = t(e, {
|
|
276
281
|
onBlocked: () => {
|
|
277
282
|
m((n) => n[e.origin] ? {
|
|
278
283
|
...n,
|
|
@@ -281,34 +286,34 @@ const Y = ce(null), J = ce({
|
|
|
281
286
|
},
|
|
282
287
|
onClosed: () => {
|
|
283
288
|
if (e.v2) {
|
|
284
|
-
|
|
289
|
+
Q && m((n) => !n[e.origin] || !n[e.origin].silentUrl ? n : {
|
|
285
290
|
...n,
|
|
286
291
|
[e.origin]: { ...n[e.origin], status: "silent" }
|
|
287
292
|
});
|
|
288
293
|
return;
|
|
289
294
|
}
|
|
290
|
-
|
|
295
|
+
a(e.origin);
|
|
291
296
|
}
|
|
292
297
|
});
|
|
293
298
|
},
|
|
294
|
-
[
|
|
295
|
-
),
|
|
299
|
+
[i, a]
|
|
300
|
+
), D = {
|
|
296
301
|
// Hosts render UI for interactive entries only; silent resolution is
|
|
297
302
|
// invisible by design.
|
|
298
303
|
pending: Object.values(p).filter(
|
|
299
304
|
(e) => e.status === "interactive"
|
|
300
305
|
),
|
|
301
|
-
authorize:
|
|
302
|
-
approve:
|
|
303
|
-
complete:
|
|
304
|
-
dismiss:
|
|
305
|
-
originEpochs:
|
|
306
|
-
credentials:
|
|
307
|
-
unsupported:
|
|
308
|
-
},
|
|
306
|
+
authorize: W,
|
|
307
|
+
approve: y,
|
|
308
|
+
complete: M,
|
|
309
|
+
dismiss: w,
|
|
310
|
+
originEpochs: j,
|
|
311
|
+
credentials: L,
|
|
312
|
+
unsupported: P
|
|
313
|
+
}, H = Object.values(p).filter(
|
|
309
314
|
(e) => e.status === "silent" && e.silentUrl
|
|
310
315
|
);
|
|
311
|
-
return /* @__PURE__ */
|
|
316
|
+
return /* @__PURE__ */ z.createElement(V.Provider, { value: D }, r, H.map((e) => /* @__PURE__ */ z.createElement(
|
|
312
317
|
"iframe",
|
|
313
318
|
{
|
|
314
319
|
key: `mm-silent-auth-${e.origin}`,
|
|
@@ -320,9 +325,9 @@ const Y = ce(null), J = ce({
|
|
|
320
325
|
}
|
|
321
326
|
)));
|
|
322
327
|
};
|
|
323
|
-
|
|
324
|
-
children:
|
|
325
|
-
launcher:
|
|
328
|
+
ie.propTypes = {
|
|
329
|
+
children: T.node,
|
|
330
|
+
launcher: T.func,
|
|
326
331
|
/**
|
|
327
332
|
* `async (request, { approve }) => result` where request =
|
|
328
333
|
* `{ origin, clientId, scope, authUrl }` (origin is the zone-attested frame origin) and result
|
|
@@ -330,169 +335,169 @@ ue.propTypes = {
|
|
|
330
335
|
* client }`, `{ status: 409, consentRequired: true, client: { name, hostname }, stepUp }`, or
|
|
331
336
|
* `{ status, error }`. Provided only by hosts that are themselves first-party clients.
|
|
332
337
|
*/
|
|
333
|
-
broker:
|
|
338
|
+
broker: T.func
|
|
334
339
|
};
|
|
335
|
-
const
|
|
336
|
-
const { originEpochs:
|
|
337
|
-
return
|
|
338
|
-
},
|
|
339
|
-
const { credentials:
|
|
340
|
-
return
|
|
341
|
-
},
|
|
342
|
-
const { unsupported:
|
|
343
|
-
return
|
|
344
|
-
},
|
|
345
|
-
const [
|
|
340
|
+
const Oe = () => v(V), he = (r) => {
|
|
341
|
+
const { originEpochs: i } = v(V), u = J(r);
|
|
342
|
+
return u && i[u] || 0;
|
|
343
|
+
}, ge = (r) => {
|
|
344
|
+
const { credentials: i } = v(V), u = J(r);
|
|
345
|
+
return u && i[u] || null;
|
|
346
|
+
}, me = (r) => {
|
|
347
|
+
const { unsupported: i } = v(V), u = J(r);
|
|
348
|
+
return u && i[u] || null;
|
|
349
|
+
}, be = ({ children: r, authorizationLauncher: i, credentialBroker: u }) => {
|
|
350
|
+
const [d, p] = C({}), [m, j] = C({}), I = R({}), L = R({}), O = R({}), P = h((c, l) => {
|
|
346
351
|
var s;
|
|
347
|
-
return !!((s =
|
|
348
|
-
}, []),
|
|
349
|
-
p((
|
|
350
|
-
}, []),
|
|
352
|
+
return !!((s = O.current[c]) != null && s.has(l));
|
|
353
|
+
}, []), S = h((c, l, s) => {
|
|
354
|
+
p((a) => ({ ...a, [c]: { origin: l, frameRef: s } }));
|
|
355
|
+
}, []), Z = h((c) => {
|
|
351
356
|
p((l) => {
|
|
352
357
|
const s = { ...l };
|
|
353
|
-
return delete s[
|
|
354
|
-
}),
|
|
358
|
+
return delete s[c], s;
|
|
359
|
+
}), j((l) => {
|
|
355
360
|
const s = { ...l };
|
|
356
|
-
return delete s[
|
|
357
|
-
}), delete
|
|
361
|
+
return delete s[c], s;
|
|
362
|
+
}), delete O.current[c];
|
|
358
363
|
}, []);
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
s.forEach((
|
|
364
|
+
k(() => {
|
|
365
|
+
const c = (s = [], a, E) => {
|
|
366
|
+
s.forEach((w) => w(a, E));
|
|
362
367
|
}, l = (s) => {
|
|
363
|
-
var
|
|
364
|
-
if (!((
|
|
368
|
+
var A, B, y, W, D, H, e;
|
|
369
|
+
if (!((A = s == null ? void 0 : s.data) != null && A.instanceId))
|
|
365
370
|
return;
|
|
366
|
-
const { instanceId:
|
|
367
|
-
if (
|
|
371
|
+
const { instanceId: a, type: E } = s.data, w = d[a], $ = (y = (B = w == null ? void 0 : w.frameRef) == null ? void 0 : B.current) == null ? void 0 : y.contentWindow;
|
|
372
|
+
if (!$ || s.source !== $ || s.origin !== w.origin)
|
|
368
373
|
return;
|
|
369
|
-
const
|
|
370
|
-
if (
|
|
371
|
-
const { callbackId: t, response: n, error:
|
|
372
|
-
|
|
374
|
+
const M = { origin: s.origin }, g = I.current;
|
|
375
|
+
if (E === "response") {
|
|
376
|
+
const { callbackId: t, response: n, error: o } = s.data, f = L.current[t];
|
|
377
|
+
f && (f(n, o), delete L.current[t]);
|
|
373
378
|
return;
|
|
374
379
|
}
|
|
375
|
-
if (
|
|
380
|
+
if (E === "mark-registered") {
|
|
376
381
|
const { requestType: t } = s.data;
|
|
377
|
-
|
|
382
|
+
O.current[a] || (O.current[a] = /* @__PURE__ */ new Set()), O.current[a].add(t);
|
|
378
383
|
return;
|
|
379
384
|
}
|
|
380
|
-
|
|
385
|
+
E === "ready" && j((t) => ({ ...t, [a]: !0 })), c((W = g[a]) == null ? void 0 : W[E], s.data, M), c((D = g["*"]) == null ? void 0 : D[E], s.data, M), c((H = g[a]) == null ? void 0 : H["*"], s.data, M), c((e = g["*"]) == null ? void 0 : e["*"], s.data, M);
|
|
381
386
|
};
|
|
382
387
|
return window.addEventListener("message", l), () => {
|
|
383
388
|
window.removeEventListener("message", l);
|
|
384
389
|
};
|
|
385
|
-
}, [
|
|
386
|
-
const b =
|
|
387
|
-
(
|
|
388
|
-
var
|
|
389
|
-
const
|
|
390
|
-
if (!
|
|
391
|
-
console.warn(`Origin not set for id: ${
|
|
390
|
+
}, [d]);
|
|
391
|
+
const b = h(
|
|
392
|
+
(c, l, s) => {
|
|
393
|
+
var E, w;
|
|
394
|
+
const a = d[c];
|
|
395
|
+
if (!a) {
|
|
396
|
+
console.warn(`Origin not set for id: ${c}. Unable to send message.`);
|
|
392
397
|
return;
|
|
393
398
|
}
|
|
394
|
-
(
|
|
395
|
-
{ type: l, ...s, instanceId:
|
|
396
|
-
|
|
399
|
+
(w = (E = a == null ? void 0 : a.frameRef) == null ? void 0 : E.current) != null && w.contentWindow && a.frameRef.current.contentWindow.postMessage(
|
|
400
|
+
{ type: l, ...s, instanceId: c },
|
|
401
|
+
a.origin
|
|
397
402
|
);
|
|
398
403
|
},
|
|
399
|
-
[
|
|
400
|
-
),
|
|
401
|
-
async (
|
|
402
|
-
const
|
|
403
|
-
delete
|
|
404
|
+
[d]
|
|
405
|
+
), x = R(0), K = h(() => `${Date.now()}-${++x.current}`, []), _ = h(
|
|
406
|
+
async (c, l, s = {}) => new Promise((a, E) => {
|
|
407
|
+
const w = K(), $ = (M, g) => {
|
|
408
|
+
delete L.current[w], g ? E(g) : a(M);
|
|
404
409
|
};
|
|
405
|
-
|
|
410
|
+
L.current[w] = $, b(c, "request", { callbackId: w, requestType: l, data: s });
|
|
406
411
|
}),
|
|
407
412
|
[b]
|
|
408
|
-
),
|
|
409
|
-
(
|
|
410
|
-
b(
|
|
413
|
+
), q = h(
|
|
414
|
+
(c, l) => {
|
|
415
|
+
b(c, "load-options", l);
|
|
411
416
|
},
|
|
412
417
|
[b]
|
|
413
|
-
),
|
|
414
|
-
(
|
|
415
|
-
b(
|
|
418
|
+
), F = h(
|
|
419
|
+
(c, l) => {
|
|
420
|
+
b(c, "validate", l);
|
|
416
421
|
},
|
|
417
422
|
[b]
|
|
418
|
-
),
|
|
423
|
+
), U = ue(
|
|
419
424
|
() => ({
|
|
420
|
-
registerFrame:
|
|
421
|
-
unregisterFrame:
|
|
425
|
+
registerFrame: S,
|
|
426
|
+
unregisterFrame: Z,
|
|
422
427
|
sendMessage: b,
|
|
423
|
-
sendRequest:
|
|
424
|
-
loadOptions:
|
|
425
|
-
validate:
|
|
426
|
-
hasHandler:
|
|
428
|
+
sendRequest: _,
|
|
429
|
+
loadOptions: q,
|
|
430
|
+
validate: F,
|
|
431
|
+
hasHandler: P,
|
|
427
432
|
readyFrames: m,
|
|
428
|
-
addListener: (
|
|
429
|
-
|
|
433
|
+
addListener: (c, l, s) => (I.current[c] || (I.current[c] = {}), I.current[c][l] || (I.current[c][l] = []), I.current[c][l].push(s), () => {
|
|
434
|
+
I.current[c][l] = I.current[c][l].filter((a) => a !== s);
|
|
430
435
|
})
|
|
431
436
|
}),
|
|
432
437
|
[
|
|
433
|
-
|
|
434
|
-
|
|
438
|
+
S,
|
|
439
|
+
Z,
|
|
435
440
|
b,
|
|
436
|
-
|
|
437
|
-
|
|
441
|
+
_,
|
|
442
|
+
q,
|
|
443
|
+
F,
|
|
438
444
|
P,
|
|
439
|
-
I,
|
|
440
445
|
m
|
|
441
446
|
]
|
|
442
447
|
);
|
|
443
|
-
return /* @__PURE__ */
|
|
444
|
-
},
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
448
|
+
return /* @__PURE__ */ z.createElement(X.Provider, { value: U }, /* @__PURE__ */ z.createElement(ie, { launcher: i, broker: u }, r));
|
|
449
|
+
}, G = (r, i, u) => {
|
|
450
|
+
const d = v(X);
|
|
451
|
+
if (d === null)
|
|
447
452
|
throw new Error(
|
|
448
453
|
"useEmbeddedEffect must be used within a MMEmbeddableZoneProvider"
|
|
449
454
|
);
|
|
450
|
-
const p = R(
|
|
451
|
-
|
|
452
|
-
p.current =
|
|
453
|
-
}, [
|
|
454
|
-
if (!(!r || !
|
|
455
|
-
if (
|
|
456
|
-
const m =
|
|
457
|
-
return
|
|
455
|
+
const p = R(u);
|
|
456
|
+
k(() => {
|
|
457
|
+
p.current = u;
|
|
458
|
+
}, [u]), k(() => {
|
|
459
|
+
if (!(!r || !i)) {
|
|
460
|
+
if (i.startsWith("key:")) {
|
|
461
|
+
const m = i.substring(4);
|
|
462
|
+
return d.readyFrames[r] && d.sendMessage(r, "subscribe-key", { keyChord: m }), d.addListener(
|
|
458
463
|
r,
|
|
459
464
|
`key-pressed:${m}`,
|
|
460
|
-
(...
|
|
465
|
+
(...I) => p.current(...I)
|
|
461
466
|
);
|
|
462
467
|
}
|
|
463
|
-
return
|
|
468
|
+
return d.addListener(
|
|
464
469
|
r,
|
|
465
|
-
|
|
470
|
+
i,
|
|
466
471
|
(...m) => p.current(...m)
|
|
467
472
|
);
|
|
468
473
|
}
|
|
469
|
-
}, [
|
|
474
|
+
}, [d, r, i]);
|
|
470
475
|
};
|
|
471
|
-
|
|
472
|
-
children:
|
|
476
|
+
be.propTypes = {
|
|
477
|
+
children: T.node.isRequired,
|
|
473
478
|
/**
|
|
474
479
|
* Optional interactive-step launcher for embedded authorizations,
|
|
475
480
|
* `(entry, { onBlocked, onClosed }) => cleanup`. Defaults to a top-level
|
|
476
481
|
* popup. Hosts that cannot open windows (Android WebView shells) drive
|
|
477
482
|
* their own UI from useEmbeddedAuthorizations() instead.
|
|
478
483
|
*/
|
|
479
|
-
authorizationLauncher:
|
|
484
|
+
authorizationLauncher: T.func,
|
|
480
485
|
/**
|
|
481
486
|
* Optional credential broker for hosts that are first-party MachineMetrics clients
|
|
482
487
|
* (`async (request, { approve }) => result`, see EmbeddedAuthorizationManager). When present,
|
|
483
488
|
* v2 credential requests are brokered server-side (no popup, no hidden frame) and consent is
|
|
484
489
|
* rendered natively by the host from the broker's `client` identity.
|
|
485
490
|
*/
|
|
486
|
-
credentialBroker:
|
|
491
|
+
credentialBroker: T.func
|
|
487
492
|
};
|
|
488
|
-
const
|
|
493
|
+
const N = te.default || te, Ee = 1e4, ke = "credentials", Re = (r, i) => `${r}/mm-embedded-interop?id=${encodeURIComponent(i)}&origin=${encodeURIComponent(
|
|
489
494
|
window.location.origin
|
|
490
|
-
)}&caps=${
|
|
495
|
+
)}&caps=${ke}`, we = N.iframe`
|
|
491
496
|
width: 100%;
|
|
492
497
|
height: 100%;
|
|
493
498
|
border: none;
|
|
494
499
|
visibility: ${(r) => r.$isReady ? "visible" : "hidden"};
|
|
495
|
-
`,
|
|
500
|
+
`, Te = N.div`
|
|
496
501
|
width: 100%;
|
|
497
502
|
height: 100%;
|
|
498
503
|
display: flex;
|
|
@@ -505,66 +510,66 @@ const ee = K.default || K, Re = 1e4, xe = "credentials", Te = (r, o) => `${r}/mm
|
|
|
505
510
|
text-align: center;
|
|
506
511
|
color: #555;
|
|
507
512
|
font-size: 14px;
|
|
508
|
-
`,
|
|
509
|
-
const
|
|
510
|
-
switch (
|
|
513
|
+
`, Ie = (r) => {
|
|
514
|
+
const i = r && r.origin || "This app", u = r && r.reason || "";
|
|
515
|
+
switch (u) {
|
|
511
516
|
case "broker:scope_above_ceiling":
|
|
512
517
|
return {
|
|
513
|
-
title: `${
|
|
518
|
+
title: `${i} can’t be authorized here`,
|
|
514
519
|
detail: "It asks for permissions your role doesn’t have."
|
|
515
520
|
};
|
|
516
521
|
case "broker:origin_mismatch":
|
|
517
522
|
case "broker:unknown_client":
|
|
518
523
|
return {
|
|
519
|
-
title: `${
|
|
524
|
+
title: `${i} can’t be authorized here`,
|
|
520
525
|
detail: "It isn’t registered to run at this address."
|
|
521
526
|
};
|
|
522
527
|
case "broker:cross_company_principal":
|
|
523
528
|
return {
|
|
524
|
-
title: `${
|
|
529
|
+
title: `${i} can’t be authorized here`,
|
|
525
530
|
detail: "It can’t be authorized for this account."
|
|
526
531
|
};
|
|
527
532
|
default:
|
|
528
|
-
return
|
|
529
|
-
title: `${
|
|
533
|
+
return u.startsWith("broker:") ? {
|
|
534
|
+
title: `${i} can’t be authorized here`,
|
|
530
535
|
detail: "Authorization was refused."
|
|
531
536
|
} : {
|
|
532
|
-
title: `${
|
|
537
|
+
title: `${i} can’t be embedded here`,
|
|
533
538
|
detail: "It needs an update to support embedding from a different domain."
|
|
534
539
|
};
|
|
535
540
|
}
|
|
536
|
-
},
|
|
537
|
-
const
|
|
538
|
-
return /* @__PURE__ */
|
|
541
|
+
}, ce = ({ entry: r }) => {
|
|
542
|
+
const i = Ie(r);
|
|
543
|
+
return /* @__PURE__ */ z.createElement(Te, { "data-reason": r && r.reason || void 0 }, /* @__PURE__ */ z.createElement("div", { style: { fontWeight: 600 } }, i.title), /* @__PURE__ */ z.createElement("div", { style: { fontSize: 12, color: "#888" } }, i.detail));
|
|
539
544
|
};
|
|
540
|
-
|
|
541
|
-
entry:
|
|
542
|
-
origin:
|
|
543
|
-
name:
|
|
544
|
-
reason:
|
|
545
|
-
detail:
|
|
545
|
+
ce.propTypes = {
|
|
546
|
+
entry: T.shape({
|
|
547
|
+
origin: T.string,
|
|
548
|
+
name: T.string,
|
|
549
|
+
reason: T.string,
|
|
550
|
+
detail: T.object
|
|
546
551
|
})
|
|
547
552
|
};
|
|
548
|
-
const
|
|
553
|
+
const Ue = N.div`
|
|
549
554
|
height: 100%;
|
|
550
555
|
display: flex;
|
|
551
556
|
flex: 1;
|
|
552
557
|
align-items: center;
|
|
553
558
|
justify-content: center;
|
|
554
|
-
`, Ce = () => /* @__PURE__ */
|
|
559
|
+
`, Ce = () => /* @__PURE__ */ z.createElement(Ue, null, /* @__PURE__ */ z.createElement("div", { style: { textAlign: "center" } }, "This app couldn’t be loaded as an embeddable widget.")), _e = ({
|
|
555
560
|
id: r,
|
|
556
|
-
src:
|
|
557
|
-
path:
|
|
558
|
-
onInit:
|
|
561
|
+
src: i,
|
|
562
|
+
path: u,
|
|
563
|
+
onInit: d = () => {
|
|
559
564
|
},
|
|
560
565
|
onTimeout: p,
|
|
561
566
|
context: m = {},
|
|
562
|
-
params:
|
|
563
|
-
renderUnsupported:
|
|
564
|
-
renderTimeout:
|
|
565
|
-
...
|
|
567
|
+
params: j = {},
|
|
568
|
+
renderUnsupported: I,
|
|
569
|
+
renderTimeout: L,
|
|
570
|
+
...O
|
|
566
571
|
}) => {
|
|
567
|
-
if ("isConfiguring" in
|
|
572
|
+
if ("isConfiguring" in O)
|
|
568
573
|
return console.error(
|
|
569
574
|
"isConfiguring must be passed via the params prop to MMEmbeddableZone"
|
|
570
575
|
), null;
|
|
@@ -576,194 +581,111 @@ const ye = ee.div`
|
|
|
576
581
|
return console.error(
|
|
577
582
|
"isFullScreen must be passed via the params prop to MMEmbeddableZone"
|
|
578
583
|
), null;
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
), [
|
|
582
|
-
|
|
584
|
+
const P = R(), [S, Z] = C(), [b, x] = C(0), [K, _] = C(!1), [q, F] = C(!1), U = he(i), c = ge(i), l = me(i), [s, a] = C(0), [E, w] = C(null), { registerFrame: $, unregisterFrame: M, sendMessage: g } = v(
|
|
585
|
+
X
|
|
586
|
+
), [A, B] = C(), y = R(), W = R(p), D = R(d), H = R(!1), e = h(() => {
|
|
587
|
+
H.current = !1, clearTimeout(y.current), x(0), _(!1), F(!1), w(null);
|
|
583
588
|
}, []);
|
|
584
|
-
|
|
585
|
-
(
|
|
586
|
-
}, [
|
|
587
|
-
|
|
588
|
-
}, [p]),
|
|
589
|
-
|
|
590
|
-
}, [
|
|
591
|
-
b &&
|
|
589
|
+
k(() => {
|
|
590
|
+
(U > 0 || s > 0) && e();
|
|
591
|
+
}, [U, s, e]), k(() => {
|
|
592
|
+
W.current = p;
|
|
593
|
+
}, [p]), k(() => {
|
|
594
|
+
D.current = d;
|
|
595
|
+
}, [d]), k(() => {
|
|
596
|
+
b && g(r, "set-context", {
|
|
592
597
|
context: {
|
|
593
598
|
...m
|
|
594
599
|
}
|
|
595
600
|
});
|
|
596
|
-
}, [m, r, b]),
|
|
597
|
-
b &&
|
|
598
|
-
}, [
|
|
599
|
-
|
|
600
|
-
}, [
|
|
601
|
-
|
|
602
|
-
}, [
|
|
603
|
-
if (!
|
|
601
|
+
}, [m, r, b]), k(() => {
|
|
602
|
+
b && g(r, "set-params", { params: j });
|
|
603
|
+
}, [j, r, b]), k(() => {
|
|
604
|
+
u !== void 0 && B((u == null ? void 0 : u.indexOf("/")) === 0 ? u : `/${u}`);
|
|
605
|
+
}, [u]), k(() => {
|
|
606
|
+
A === void 0 || !b || g(r, "navigate", { path: A });
|
|
607
|
+
}, [A, b, r, g]), k(() => {
|
|
608
|
+
if (!i || !r || !P)
|
|
604
609
|
return;
|
|
605
610
|
e();
|
|
606
|
-
const
|
|
607
|
-
return
|
|
608
|
-
|
|
611
|
+
const o = new URL(i);
|
|
612
|
+
return $(r, o.origin, P), D.current(), Z(Re(o.origin, r)), () => {
|
|
613
|
+
M(r);
|
|
609
614
|
};
|
|
610
|
-
}, [
|
|
611
|
-
if (!(!
|
|
612
|
-
return
|
|
613
|
-
|
|
614
|
-
},
|
|
615
|
-
}, [
|
|
616
|
-
const t =
|
|
617
|
-
|
|
615
|
+
}, [i, r, $, P, e]), k(() => {
|
|
616
|
+
if (!(!S || H.current))
|
|
617
|
+
return y.current = setTimeout(() => {
|
|
618
|
+
_(!0), W.current && W.current();
|
|
619
|
+
}, Ee), () => clearTimeout(y.current);
|
|
620
|
+
}, [S, i, U, s]);
|
|
621
|
+
const t = h(() => {
|
|
622
|
+
H.current = !0, clearTimeout(y.current), _(!1);
|
|
618
623
|
}, []);
|
|
619
|
-
|
|
620
|
-
t(), Array.isArray(
|
|
621
|
-
}),
|
|
622
|
-
t(),
|
|
623
|
-
}),
|
|
624
|
-
if (!
|
|
624
|
+
G(r, "init", (o) => {
|
|
625
|
+
t(), Array.isArray(o == null ? void 0 : o.acceptsCredentials) && w(o.acceptsCredentials);
|
|
626
|
+
}), G(r, "authorize", t), G(r, "login", t), G(r, "credential-request", () => {
|
|
627
|
+
t(), F(!0);
|
|
628
|
+
}), k(() => {
|
|
629
|
+
if (!q || !c)
|
|
625
630
|
return;
|
|
626
|
-
const
|
|
627
|
-
if (Array.isArray(
|
|
631
|
+
const o = E;
|
|
632
|
+
if (Array.isArray(o) && !o.includes(c.kind))
|
|
628
633
|
return;
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
}, [
|
|
632
|
-
t(),
|
|
634
|
+
const f = c.kind === "access_token" ? { accessToken: c.accessToken } : {};
|
|
635
|
+
g(r, "credential", { ...f, credential: c });
|
|
636
|
+
}, [q, c, E, r, g]), G(r, "ready", () => {
|
|
637
|
+
t(), x((o) => o + 1);
|
|
633
638
|
});
|
|
634
639
|
const n = R();
|
|
635
|
-
return
|
|
640
|
+
return G(r, "heartbeat", () => {
|
|
636
641
|
n.current && clearTimeout(n.current), n.current = setTimeout(() => {
|
|
637
|
-
|
|
642
|
+
a((o) => o + 1);
|
|
638
643
|
}, 6e3);
|
|
639
|
-
}),
|
|
644
|
+
}), k(() => () => {
|
|
640
645
|
n.current && clearTimeout(n.current);
|
|
641
|
-
}, []), l ?
|
|
642
|
-
|
|
646
|
+
}, []), l ? I ? I(l) : /* @__PURE__ */ z.createElement(ce, { entry: l }) : K && !b ? L ? L() : /* @__PURE__ */ z.createElement(Ce, null) : /* @__PURE__ */ z.createElement(
|
|
647
|
+
we,
|
|
643
648
|
{
|
|
644
|
-
key: `auth-epoch-${
|
|
649
|
+
key: `auth-epoch-${U}-frame-${s}`,
|
|
645
650
|
$isReady: b,
|
|
646
|
-
ref:
|
|
647
|
-
src:
|
|
648
|
-
...
|
|
651
|
+
ref: P,
|
|
652
|
+
src: S,
|
|
653
|
+
...O
|
|
649
654
|
}
|
|
650
655
|
);
|
|
651
656
|
};
|
|
652
|
-
|
|
653
|
-
id:
|
|
654
|
-
src:
|
|
655
|
-
path:
|
|
656
|
-
onInit:
|
|
657
|
-
onTimeout:
|
|
657
|
+
_e.propTypes = {
|
|
658
|
+
id: T.string,
|
|
659
|
+
src: T.string.isRequired,
|
|
660
|
+
path: T.string,
|
|
661
|
+
onInit: T.func,
|
|
662
|
+
onTimeout: T.func,
|
|
658
663
|
/**
|
|
659
664
|
* Optional host-styled renderer for the structurally-unsupported embed
|
|
660
665
|
* state (legacy app on a cross-site origin), `(entry) => ReactNode`. Falls
|
|
661
666
|
* back to a minimal built-in placeholder.
|
|
662
667
|
*/
|
|
663
|
-
renderUnsupported:
|
|
668
|
+
renderUnsupported: T.func,
|
|
664
669
|
/**
|
|
665
670
|
* Optional host-styled renderer for the handshake-timeout failure state
|
|
666
671
|
* (the app is not embeddable / could not load), `() => ReactNode`. Falls
|
|
667
672
|
* back to a minimal centered message.
|
|
668
673
|
*/
|
|
669
|
-
renderTimeout:
|
|
670
|
-
};
|
|
671
|
-
const Me = K.div`
|
|
672
|
-
position: fixed;
|
|
673
|
-
inset: 0;
|
|
674
|
-
background: rgba(0, 0, 0, 0.45);
|
|
675
|
-
display: flex;
|
|
676
|
-
align-items: center;
|
|
677
|
-
justify-content: center;
|
|
678
|
-
z-index: 10000;
|
|
679
|
-
`, Oe = K.div`
|
|
680
|
-
background: #fff;
|
|
681
|
-
border-radius: 8px;
|
|
682
|
-
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
|
|
683
|
-
padding: 24px;
|
|
684
|
-
width: 480px;
|
|
685
|
-
max-width: calc(100vw - 32px);
|
|
686
|
-
font-family: sans-serif;
|
|
687
|
-
color: #222;
|
|
688
|
-
`, _e = K.div`
|
|
689
|
-
display: flex;
|
|
690
|
-
align-items: center;
|
|
691
|
-
justify-content: space-between;
|
|
692
|
-
padding: 10px 0;
|
|
693
|
-
gap: 16px;
|
|
694
|
-
`, Le = K.button`
|
|
695
|
-
background: #16a500;
|
|
696
|
-
color: #fff;
|
|
697
|
-
border: none;
|
|
698
|
-
border-radius: 6px;
|
|
699
|
-
padding: 9px 18px;
|
|
700
|
-
font-size: 14px;
|
|
701
|
-
cursor: pointer;
|
|
702
|
-
white-space: nowrap;
|
|
703
|
-
`, $e = K.p`
|
|
704
|
-
color: #b3261e;
|
|
705
|
-
font-size: 13px;
|
|
706
|
-
margin: 4px 0 0;
|
|
707
|
-
`, se = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
708
|
-
let ie = !1;
|
|
709
|
-
const Pe = () => {
|
|
710
|
-
const { pending: r, authorize: o, dismiss: c } = ge(), a = r.filter((d) => !d.consent), p = r.length - a.length, m = R(null), L = R(null), T = a.length > 0;
|
|
711
|
-
if (w(() => {
|
|
712
|
-
p > 0 && !ie && (ie = !0, console.error(
|
|
713
|
-
"[mm-react-embeddable] EmbeddedAuthorizationPrompt received a brokered consent entry. A host with a credentialBroker must render its own consent UI (useEmbeddedAuthorizations: approve/dismiss); this default prompt only handles the popup path."
|
|
714
|
-
));
|
|
715
|
-
}, [p]), w(() => {
|
|
716
|
-
if (!T || !m.current)
|
|
717
|
-
return;
|
|
718
|
-
L.current = document.activeElement;
|
|
719
|
-
const d = m.current.querySelector(se);
|
|
720
|
-
return d && d.focus(), () => {
|
|
721
|
-
const I = L.current;
|
|
722
|
-
I && typeof I.focus == "function" && I.focus();
|
|
723
|
-
};
|
|
724
|
-
}, [T]), !T)
|
|
725
|
-
return null;
|
|
726
|
-
const y = (d) => {
|
|
727
|
-
if (d.key === "Escape") {
|
|
728
|
-
d.preventDefault(), a.forEach((b) => c(b));
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
if (d.key !== "Tab" || !m.current)
|
|
732
|
-
return;
|
|
733
|
-
const I = Array.from(m.current.querySelectorAll(se));
|
|
734
|
-
if (I.length === 0)
|
|
735
|
-
return;
|
|
736
|
-
const C = I[0], v = I[I.length - 1];
|
|
737
|
-
d.shiftKey && document.activeElement === C ? (d.preventDefault(), v.focus()) : !d.shiftKey && document.activeElement === v && (d.preventDefault(), C.focus());
|
|
738
|
-
};
|
|
739
|
-
return /* @__PURE__ */ E.createElement(Me, null, /* @__PURE__ */ E.createElement(
|
|
740
|
-
Oe,
|
|
741
|
-
{
|
|
742
|
-
ref: m,
|
|
743
|
-
role: "dialog",
|
|
744
|
-
"aria-modal": "true",
|
|
745
|
-
"aria-labelledby": "mm-embedded-authorization-title",
|
|
746
|
-
onKeyDown: y
|
|
747
|
-
},
|
|
748
|
-
/* @__PURE__ */ E.createElement("h3", { id: "mm-embedded-authorization-title", style: { margin: "0 0 8px" } }, "Authorization Required"),
|
|
749
|
-
/* @__PURE__ */ E.createElement("p", { style: { margin: "0 0 12px", fontSize: 14, color: "#555" } }, "The following apps need you to sign in and authorize them before they can load."),
|
|
750
|
-
a.map((d) => /* @__PURE__ */ E.createElement("div", { key: d.origin }, /* @__PURE__ */ E.createElement(_e, null, /* @__PURE__ */ E.createElement("div", null, /* @__PURE__ */ E.createElement("div", { style: { fontWeight: 600 } }, d.origin)), /* @__PURE__ */ E.createElement(Le, { onClick: () => o(d) }, "Authorize")), d.popupBlocked && /* @__PURE__ */ E.createElement($e, null, "The sign-in window was blocked. Allow popups for this site, then try again.")))
|
|
751
|
-
));
|
|
674
|
+
renderTimeout: T.func
|
|
752
675
|
};
|
|
753
676
|
export {
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
me as isCrossSite,
|
|
677
|
+
le as CREDENTIAL_KIND_ACCESS_TOKEN,
|
|
678
|
+
V as EmbeddedAuthorizationContext,
|
|
679
|
+
_e as MMEmbeddableZone,
|
|
680
|
+
X as MMEmbeddableZoneContext,
|
|
681
|
+
be as MMEmbeddableZoneProvider,
|
|
682
|
+
fe as isCrossSite,
|
|
761
683
|
re as normalizeCredential,
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
684
|
+
pe as popupAuthorizationLauncher,
|
|
685
|
+
Ie as unsupportedCopy,
|
|
686
|
+
Oe as useEmbeddedAuthorizations,
|
|
687
|
+
ge as useEmbeddedCredential,
|
|
688
|
+
G as useEmbeddedEffect,
|
|
689
|
+
he as useEmbeddedOriginEpoch,
|
|
690
|
+
me as useEmbeddedUnsupported
|
|
769
691
|
};
|