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