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