@machinemetrics/mm-react-embeddable 1.4.0-2 → 1.4.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.
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),h=require("prop-types"),j=require("styled-components"),B=e.createContext(null),Z=e.createContext({pending:[],authorize:()=>{},dismiss:()=>{},originEpochs:{},credentials:{},unsupported:{}}),v=typeof window!="undefined"&&window.location.protocol==="https:",te=8e3,A=r=>{try{return new URL(r).origin}catch{return null}},W=r=>{if(!r||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(r)||r.includes(":"))return r;const c=r.split(".");return c.length<=2?r:c.slice(-2).join(".")},H=(r,c)=>{try{const o=new URL(r),d=new URL(c);return o.protocol!==d.protocol?!0:W(o.hostname)!==W(d.hostname)}catch{return!0}},K=(r,{onBlocked:c,onClosed:o})=>{const d=window.open(r.authUrl,"mm-embed-auth","popup,width=600,height=700");if(!d)return c(),()=>{};const m=setInterval(()=>{d.closed&&(clearInterval(m),o())},1e3);return()=>clearInterval(m)},V=({children:r,launcher:c})=>{const o=e.useContext(B),[d,m]=e.useState({}),[E,R]=e.useState({}),[w,M]=e.useState({}),[P,k]=e.useState({}),S=e.useRef(w);S.current=w;const g=e.useRef(null),x=e.useRef({}),I=e.useRef({}),C=e.useCallback(t=>{const n=I.current[t];if(!n)return;const s=f=>!f[t]||f[t].clientId?f:{...f,[t]:{...f[t],clientId:n}};m(s),k(s)},[]),O=e.useCallback((t,n)=>{const s=A(t==null?void 0:t.authUrl);s&&(k(f=>f[s]?f:{...f,[s]:{origin:s,reason:n,clientId:I.current[s]||null}}),C(s))},[C]),z=e.useCallback((t,{v2:n=!1}={})=>{const s=A(t==null?void 0:t.authUrl);s&&(n&&S.current[s]||(m(f=>f[s]?f:{...f,[s]:{origin:s,authUrl:t.authUrl,silentUrl:t.silentUrl||null,status:n&&t.silentUrl&&v?"silent":"interactive",v2:n,clientId:t.clientId||I.current[s]||null,popupBlocked:!1}}),C(s)))},[C]),y=e.useCallback(t=>{m(n=>{if(!n[t])return n;const s={...n};return delete s[t],s})},[]),i=e.useCallback(t=>{t&&(y(t),R(n=>({...n,[t]:(n[t]||0)+1})))},[y]),l=e.useCallback(t=>{m(n=>!n[t]||n[t].status==="interactive"?n:{...n,[t]:{...n[t],status:"interactive"}})},[]),u=e.useCallback(t=>{y(t.origin)},[y]),a=e.useCallback(t=>{const n=A(t==null?void 0:t.authUrl);if(n&&H(n,window.location.origin)){O(t,"cross-site-legacy");return}z(t)},[z,O]);e.useEffect(()=>{if(!o)return;const t=[o.addListener("*","init",n=>{n!=null&&n.origin&&n.clientId&&(I.current[n.origin]=n.clientId,C(n.origin))}),o.addListener("*","authorize",a),o.addListener("*","login",a),o.addListener("*","credential-request",n=>z(n,{v2:!0})),o.addListener("*","authorized",n=>{n!=null&&n.accessToken||i(A(n==null?void 0:n.authUrl))})];return()=>t.forEach(n=>n())},[o,a,z,i,C]),e.useEffect(()=>{const t=n=>{const s=n==null?void 0:n.data;if(!s||s.type!=="authorized"&&s.type!=="authorize-failed")return;const f=A(s.authUrl);if(!(!f||n.origin!==f)){if(s.type==="authorized"&&s.accessToken){M(T=>({...T,[f]:{accessToken:s.accessToken}})),y(f);return}s.type==="authorize-failed"&&l(f)}};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[y,l]),e.useEffect(()=>{const t=x.current;Object.values(d).forEach(n=>{n.status==="silent"&&!t[n.origin]&&(t[n.origin]=setTimeout(()=>{delete t[n.origin],l(n.origin)},te))}),Object.keys(t).forEach(n=>{(!d[n]||d[n].status!=="silent")&&(clearTimeout(t[n]),delete t[n])})},[d,l]),e.useEffect(()=>()=>{g.current&&g.current(),Object.values(x.current).forEach(clearTimeout)},[]);const b=e.useCallback(t=>{g.current&&(g.current(),g.current=null);const n=c||K;g.current=n(t,{onBlocked:()=>{m(s=>s[t.origin]?{...s,[t.origin]:{...s[t.origin],popupBlocked:!0}}:s)},onClosed:()=>{if(t.v2){v&&m(s=>!s[t.origin]||!s[t.origin].silentUrl?s:{...s,[t.origin]:{...s[t.origin],status:"silent"}});return}i(t.origin)}})},[c,i]),p={pending:Object.values(d).filter(t=>t.status==="interactive"),authorize:b,dismiss:u,originEpochs:E,credentials:w,unsupported:P},U=Object.values(d).filter(t=>t.status==="silent"&&t.silentUrl);return e.createElement(Z.Provider,{value:p},r,U.map(t=>e.createElement("iframe",{key:`mm-silent-auth-${t.origin}`,src:t.silentUrl,title:`MachineMetrics silent authorization (${t.origin})`,"aria-hidden":"true",tabIndex:-1,style:{display:"none"}})))};V.propTypes={children:h.node,launcher:h.func};const G=()=>e.useContext(Z),J=r=>{const{originEpochs:c}=e.useContext(Z),o=A(r);return o&&c[o]||0},Q=r=>{const{credentials:c}=e.useContext(Z),o=A(r);return o&&c[o]||null},X=r=>{const{unsupported:c}=e.useContext(Z),o=A(r);return o&&c[o]||null},Y=({children:r,authorizationLauncher:c})=>{const[o,d]=e.useState({}),[m,E]=e.useState({}),R=e.useRef({}),w=e.useRef({}),M=e.useRef({}),P=e.useCallback((i,l)=>{var u;return!!((u=M.current[i])!=null&&u.has(l))},[]),k=e.useCallback((i,l,u)=>{d(a=>({...a,[i]:{origin:l,frameRef:u}}))},[]),S=e.useCallback(i=>{d(l=>{const u={...l};return delete u[i],u}),E(l=>{const u={...l};return delete u[i],u}),delete M.current[i]},[]);e.useEffect(()=>{const i=(u=[],a)=>{u.forEach(b=>b(a))},l=u=>{var U,t,n,s,f;if(!((U=u==null?void 0:u.data)!=null&&U.instanceId))return;const{instanceId:a,type:b}=u.data,p=R.current;if(b==="response"){const{callbackId:T,response:$,error:F}=u.data,L=w.current[T];L&&(L($,F),delete w.current[T]);return}if(b==="mark-registered"){const{requestType:T}=u.data;M.current[a]||(M.current[a]=new Set),M.current[a].add(T);return}b==="ready"&&E(T=>({...T,[a]:!0})),i((t=p[a])==null?void 0:t[b],u.data),i((n=p["*"])==null?void 0:n[b],u.data),i((s=p[a])==null?void 0:s["*"],u.data),i((f=p["*"])==null?void 0:f["*"],u.data)};return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}},[o]);const g=e.useCallback((i,l,u)=>{var b,p;const a=o[i];if(!a){console.warn(`Origin not set for id: ${i}. Unable to send message.`);return}(p=(b=a==null?void 0:a.frameRef)==null?void 0:b.current)!=null&&p.contentWindow&&a.frameRef.current.contentWindow.postMessage({type:l,...u,instanceId:i},a.origin)},[o]),x=e.useRef(0),I=e.useCallback(()=>`${Date.now()}-${++x.current}`,[]),C=e.useCallback(async(i,l,u={})=>new Promise((a,b)=>{const p=I(),U=(t,n)=>{delete w.current[p],n?b(n):a(t)};w.current[p]=U,g(i,"request",{callbackId:p,requestType:l,data:u})}),[g]),O=e.useCallback((i,l)=>{g(i,"load-options",l)},[g]),z=e.useCallback((i,l)=>{g(i,"validate",l)},[g]),y=e.useMemo(()=>({registerFrame:k,unregisterFrame:S,sendMessage:g,sendRequest:C,loadOptions:O,validate:z,hasHandler:P,readyFrames:m,addListener:(i,l,u)=>(R.current[i]||(R.current[i]={}),R.current[i][l]||(R.current[i][l]=[]),R.current[i][l].push(u),()=>{R.current[i][l]=R.current[i][l].filter(a=>a!==u)})}),[k,S,g,C,O,z,P,m]);return e.createElement(B.Provider,{value:y},e.createElement(V,{launcher:c},r))},q=(r,c,o)=>{const d=e.useContext(B);if(d===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const m=e.useRef(o);e.useEffect(()=>{m.current=o},[o]),e.useEffect(()=>{if(!(!r||!c)){if(c.startsWith("key:")){const E=c.substring(4);return d.readyFrames[r]&&d.sendMessage(r,"subscribe-key",{keyChord:E}),d.addListener(r,`key-pressed:${E}`,(...w)=>m.current(...w))}return d.addListener(r,c,(...E)=>m.current(...E))}},[d,r,c])};Y.propTypes={children:h.node.isRequired,authorizationLauncher:h.func};const _=j.default||j,ne=1e4,re="credentials",D=(r,c)=>`${r}/mm-embedded-interop?id=${c}&origin=${window.location.origin}&caps=${re}`,se=_.iframe`
|
|
2
2
|
width: 100%;
|
|
3
3
|
height: 100%;
|
|
4
4
|
border: none;
|
|
5
5
|
visibility: ${r=>r.$isReady?"visible":"hidden"};
|
|
6
|
-
`,
|
|
6
|
+
`,oe=_.div`
|
|
7
7
|
width: 100%;
|
|
8
8
|
height: 100%;
|
|
9
9
|
display: flex;
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
text-align: center;
|
|
17
17
|
color: #555;
|
|
18
18
|
font-size: 14px;
|
|
19
|
-
`,
|
|
19
|
+
`,N=({entry:r})=>e.createElement(oe,null,e.createElement("div",{style:{fontWeight:600}},r&&r.origin||"This app"," can’t be embedded here"),e.createElement("div",{style:{fontSize:12,color:"#888"}},"It needs an update to support embedding from a different domain."));N.propTypes={entry:h.shape({origin:h.string,name:h.string,reason:h.string})};const ie=_.div`
|
|
20
20
|
height: 100%;
|
|
21
21
|
display: flex;
|
|
22
22
|
flex: 1;
|
|
23
23
|
align-items: center;
|
|
24
24
|
justify-content: center;
|
|
25
|
-
`,
|
|
25
|
+
`,ce=()=>e.createElement(ie,null,e.createElement("div",{style:{textAlign:"center"}},"This app couldn’t be loaded as an embeddable widget.")),ee=({id:r,src:c,path:o,onInit:d=()=>{},onTimeout:m,context:E={},params:R={},renderUnsupported:w,renderTimeout:M,...P})=>{if("isConfiguring"in P)return console.error("isConfiguring must be passed via the params prop to MMEmbeddableZone"),null;if("colorMode"in E)return console.error("colorMode must be passed via the params prop to MMEmbeddableZone"),null;if("isFullScreen"in E)return console.error("isFullScreen must be passed via the params prop to MMEmbeddableZone"),null;const k=e.useRef(),[S,g]=e.useState(),[x,I]=e.useState(0),[C,O]=e.useState(!1),[z,y]=e.useState(!1),i=J(c),l=Q(c),u=X(c);e.useEffect(()=>{i>0&&I(0)},[i]);const{registerFrame:a,unregisterFrame:b,sendMessage:p}=e.useContext(B),[U,t]=e.useState(),n=e.useRef(),s=e.useRef(m),f=e.useRef(d),T=e.useRef(!1);e.useEffect(()=>{s.current=m},[m]),e.useEffect(()=>{f.current=d},[d]),e.useEffect(()=>{x&&p(r,"set-context",{context:{...E}})},[E,r,x]),e.useEffect(()=>{x&&p(r,"set-params",{params:R})},[R,r,x]),e.useEffect(()=>{o!==void 0&&t((o==null?void 0:o.indexOf("/"))===0?o:`/${o}`)},[o]),e.useEffect(()=>{U===void 0||!x||p(r,"navigate",{path:U})},[U,x,r,p]),e.useEffect(()=>{if(!c||!r||!k)return;const L=new URL(c);return a(r,L.origin,k),f.current(),g(D(L.origin,r)),()=>{b(r)}},[c,r,a,k]),e.useEffect(()=>{if(!(!S||T.current))return n.current=setTimeout(()=>{O(!0),s.current&&s.current()},ne),()=>clearTimeout(n.current)},[S]);const $=e.useCallback(()=>{T.current=!0,clearTimeout(n.current),O(!1)},[]);q(r,"init",$),q(r,"authorize",$),q(r,"login",$),q(r,"credential-request",()=>{$(),y(!0)}),e.useEffect(()=>{!z||!l||p(r,"credential",{accessToken:l.accessToken})},[z,l,r,p]),q(r,"ready",()=>{$(),I(L=>L+1)});const F=e.useRef();return q(r,"heartbeat",()=>{F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{if(k.current){const L=new URL(c);k.current.src=D(L.origin,r)}},6e3)}),e.useEffect(()=>()=>{F.current&&clearTimeout(F.current)},[]),u?w?w(u):e.createElement(N,{entry:u}):C&&!x?M?M():e.createElement(ce,null):e.createElement(se,{key:`auth-epoch-${i}`,$isReady:x,ref:k,src:S,...P})};ee.propTypes={id:h.string,src:h.string.isRequired,path:h.string,onInit:h.func,onTimeout:h.func,renderUnsupported:h.func,renderTimeout:h.func};const ue=j.div`
|
|
26
26
|
position: fixed;
|
|
27
27
|
inset: 0;
|
|
28
28
|
background: rgba(0, 0, 0, 0.45);
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
align-items: center;
|
|
31
31
|
justify-content: center;
|
|
32
32
|
z-index: 10000;
|
|
33
|
-
`,
|
|
33
|
+
`,le=j.div`
|
|
34
34
|
background: #fff;
|
|
35
35
|
border-radius: 8px;
|
|
36
36
|
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
max-width: calc(100vw - 32px);
|
|
40
40
|
font-family: sans-serif;
|
|
41
41
|
color: #222;
|
|
42
|
-
`,
|
|
42
|
+
`,ae=j.div`
|
|
43
43
|
display: flex;
|
|
44
44
|
align-items: center;
|
|
45
45
|
justify-content: space-between;
|
|
46
46
|
padding: 10px 0;
|
|
47
47
|
gap: 16px;
|
|
48
|
-
`,
|
|
48
|
+
`,de=j.button`
|
|
49
49
|
background: #16a500;
|
|
50
50
|
color: #fff;
|
|
51
51
|
border: none;
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
font-size: 14px;
|
|
55
55
|
cursor: pointer;
|
|
56
56
|
white-space: nowrap;
|
|
57
|
-
`,
|
|
57
|
+
`,fe=j.p`
|
|
58
58
|
color: #b3261e;
|
|
59
59
|
font-size: 13px;
|
|
60
60
|
margin: 4px 0 0;
|
|
61
|
-
`,
|
|
61
|
+
`,me=()=>{const{pending:r,authorize:c}=G();return r.length===0?null:e.createElement(ue,null,e.createElement(le,null,e.createElement("h3",{style:{margin:"0 0 8px"}},"Authorization Required"),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."),r.map(o=>e.createElement("div",{key:o.origin},e.createElement(ae,null,e.createElement("div",null,e.createElement("div",{style:{fontWeight:600}},o.origin)),e.createElement(de,{onClick:()=>c(o)},"Authorize")),o.popupBlocked&&e.createElement(fe,null,"The sign-in window was blocked. Allow popups for this site, then try again.")))))};exports.EmbeddedAuthorizationContext=Z;exports.EmbeddedAuthorizationPrompt=me;exports.MMEmbeddableZone=ee;exports.MMEmbeddableZoneContext=B;exports.MMEmbeddableZoneProvider=Y;exports.isCrossSite=H;exports.popupAuthorizationLauncher=K;exports.useEmbeddedAuthorizations=G;exports.useEmbeddedCredential=Q;exports.useEmbeddedEffect=q;exports.useEmbeddedOriginEpoch=J;exports.useEmbeddedUnsupported=X;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import f, { createContext as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const H =
|
|
1
|
+
import f, { createContext as Q, useContext as Z, useState as I, useRef as x, useCallback as h, useEffect as g, useMemo as N } from "react";
|
|
2
|
+
import w from "prop-types";
|
|
3
|
+
import W from "styled-components";
|
|
4
|
+
const H = Q(null), D = Q({
|
|
5
5
|
pending: [],
|
|
6
6
|
authorize: () => {
|
|
7
7
|
},
|
|
@@ -10,25 +10,25 @@ const H = J(null), D = J({
|
|
|
10
10
|
originEpochs: {},
|
|
11
11
|
credentials: {},
|
|
12
12
|
unsupported: {}
|
|
13
|
-
}),
|
|
13
|
+
}), V = typeof window != "undefined" && window.location.protocol === "https:", ee = 8e3, j = (n) => {
|
|
14
14
|
try {
|
|
15
15
|
return new URL(n).origin;
|
|
16
16
|
} catch {
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
},
|
|
19
|
+
}, G = (n) => {
|
|
20
20
|
if (!n || /^\d{1,3}(?:\.\d{1,3}){3}$/.test(n) || n.includes(":"))
|
|
21
21
|
return n;
|
|
22
22
|
const o = n.split(".");
|
|
23
23
|
return o.length <= 2 ? n : o.slice(-2).join(".");
|
|
24
|
-
},
|
|
24
|
+
}, te = (n, o) => {
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
return
|
|
26
|
+
const s = new URL(n), a = new URL(o);
|
|
27
|
+
return s.protocol !== a.protocol ? !0 : G(s.hostname) !== G(a.hostname);
|
|
28
28
|
} catch {
|
|
29
29
|
return !0;
|
|
30
30
|
}
|
|
31
|
-
},
|
|
31
|
+
}, ne = (n, { onBlocked: o, onClosed: s }) => {
|
|
32
32
|
const a = window.open(
|
|
33
33
|
n.authUrl,
|
|
34
34
|
"mm-embed-auth",
|
|
@@ -37,87 +37,88 @@ const H = J(null), D = J({
|
|
|
37
37
|
if (!a)
|
|
38
38
|
return o(), () => {
|
|
39
39
|
};
|
|
40
|
-
const
|
|
41
|
-
a.closed && (clearInterval(
|
|
40
|
+
const p = setInterval(() => {
|
|
41
|
+
a.closed && (clearInterval(p), s());
|
|
42
42
|
}, 1e3);
|
|
43
|
-
return () => clearInterval(
|
|
44
|
-
},
|
|
45
|
-
const
|
|
46
|
-
S.current =
|
|
47
|
-
const
|
|
48
|
-
const t =
|
|
43
|
+
return () => clearInterval(p);
|
|
44
|
+
}, X = ({ children: n, launcher: o }) => {
|
|
45
|
+
const s = Z(H), [a, p] = I({}), [R, T] = I({}), [k, L] = I({}), [q, U] = I({}), S = x(k);
|
|
46
|
+
S.current = k;
|
|
47
|
+
const b = x(null), y = x({}), F = x({}), z = h((e) => {
|
|
48
|
+
const t = F.current[e];
|
|
49
49
|
if (!t)
|
|
50
50
|
return;
|
|
51
51
|
const r = (d) => !d[e] || d[e].clientId ? d : { ...d, [e]: { ...d[e], clientId: t } };
|
|
52
|
-
|
|
53
|
-
}, []), A =
|
|
52
|
+
p(r), U(r);
|
|
53
|
+
}, []), A = h(
|
|
54
54
|
(e, t) => {
|
|
55
55
|
const r = j(e == null ? void 0 : e.authUrl);
|
|
56
56
|
r && (U((d) => d[r] ? d : {
|
|
57
57
|
...d,
|
|
58
|
-
[r]: { origin: r, reason: t, clientId:
|
|
59
|
-
}),
|
|
58
|
+
[r]: { origin: r, reason: t, clientId: F.current[r] || null }
|
|
59
|
+
}), z(r));
|
|
60
60
|
},
|
|
61
|
-
[
|
|
62
|
-
),
|
|
61
|
+
[z]
|
|
62
|
+
), O = h(
|
|
63
63
|
(e, { v2: t = !1 } = {}) => {
|
|
64
64
|
const r = j(e == null ? void 0 : e.authUrl);
|
|
65
|
-
r && (t && S.current[r] || (
|
|
65
|
+
r && (t && S.current[r] || (p((d) => d[r] ? d : {
|
|
66
66
|
...d,
|
|
67
67
|
[r]: {
|
|
68
68
|
origin: r,
|
|
69
69
|
authUrl: e.authUrl,
|
|
70
70
|
silentUrl: e.silentUrl || null,
|
|
71
|
-
// v2 entries try the invisible silent resolver first
|
|
72
|
-
// signals go straight to
|
|
73
|
-
|
|
71
|
+
// v2 entries try the invisible silent resolver first — but only on a host that can
|
|
72
|
+
// frame login (https). Otherwise (and for legacy signals) go straight to interactive,
|
|
73
|
+
// so an http host doesn't wait out a silent frame that can never load login.
|
|
74
|
+
status: t && e.silentUrl && V ? "silent" : "interactive",
|
|
74
75
|
v2: t,
|
|
75
76
|
// clientId from the request payload (v2) or the cached init (legacy);
|
|
76
77
|
// the host resolves the display name from it.
|
|
77
|
-
clientId: e.clientId ||
|
|
78
|
+
clientId: e.clientId || F.current[r] || null,
|
|
78
79
|
popupBlocked: !1
|
|
79
80
|
}
|
|
80
|
-
}),
|
|
81
|
+
}), z(r)));
|
|
81
82
|
},
|
|
82
|
-
[
|
|
83
|
-
),
|
|
84
|
-
|
|
83
|
+
[z]
|
|
84
|
+
), C = h((e) => {
|
|
85
|
+
p((t) => {
|
|
85
86
|
if (!t[e])
|
|
86
87
|
return t;
|
|
87
88
|
const r = { ...t };
|
|
88
89
|
return delete r[e], r;
|
|
89
90
|
});
|
|
90
|
-
}, []),
|
|
91
|
+
}, []), i = h(
|
|
91
92
|
(e) => {
|
|
92
|
-
e && (
|
|
93
|
+
e && (C(e), T((t) => ({
|
|
93
94
|
...t,
|
|
94
95
|
[e]: (t[e] || 0) + 1
|
|
95
96
|
})));
|
|
96
97
|
},
|
|
97
|
-
[
|
|
98
|
-
), u =
|
|
99
|
-
|
|
98
|
+
[C]
|
|
99
|
+
), u = h((e) => {
|
|
100
|
+
p((t) => !t[e] || t[e].status === "interactive" ? t : {
|
|
100
101
|
...t,
|
|
101
102
|
[e]: { ...t[e], status: "interactive" }
|
|
102
103
|
});
|
|
103
|
-
}, []), c =
|
|
104
|
+
}, []), c = h(
|
|
104
105
|
(e) => {
|
|
105
|
-
|
|
106
|
+
C(e.origin);
|
|
106
107
|
},
|
|
107
|
-
[
|
|
108
|
-
), l =
|
|
108
|
+
[C]
|
|
109
|
+
), l = h(
|
|
109
110
|
(e) => {
|
|
110
111
|
const t = j(e == null ? void 0 : e.authUrl);
|
|
111
|
-
if (t &&
|
|
112
|
+
if (t && te(t, window.location.origin)) {
|
|
112
113
|
A(e, "cross-site-legacy");
|
|
113
114
|
return;
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
O(e);
|
|
116
117
|
},
|
|
117
|
-
[
|
|
118
|
+
[O, A]
|
|
118
119
|
);
|
|
119
|
-
|
|
120
|
-
if (!
|
|
120
|
+
g(() => {
|
|
121
|
+
if (!s)
|
|
121
122
|
return;
|
|
122
123
|
const e = [
|
|
123
124
|
// `init` carries the app's OAuth clientId. Cache it by app origin and
|
|
@@ -125,22 +126,22 @@ const H = J(null), D = J({
|
|
|
125
126
|
// authorize/login/credential-request signals, so it is usually cached by
|
|
126
127
|
// the time an entry is created. The host resolves the display name from
|
|
127
128
|
// the clientId.
|
|
128
|
-
|
|
129
|
-
t != null && t.origin && t.clientId && (
|
|
129
|
+
s.addListener("*", "init", (t) => {
|
|
130
|
+
t != null && t.origin && t.clientId && (F.current[t.origin] = t.clientId, z(t.origin));
|
|
130
131
|
}),
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
s.addListener("*", "authorize", l),
|
|
133
|
+
s.addListener("*", "login", l),
|
|
134
|
+
s.addListener(
|
|
134
135
|
"*",
|
|
135
136
|
"credential-request",
|
|
136
|
-
(t) =>
|
|
137
|
+
(t) => O(t, { v2: !0 })
|
|
137
138
|
),
|
|
138
|
-
|
|
139
|
-
t != null && t.accessToken ||
|
|
139
|
+
s.addListener("*", "authorized", (t) => {
|
|
140
|
+
t != null && t.accessToken || i(j(t == null ? void 0 : t.authUrl));
|
|
140
141
|
})
|
|
141
142
|
];
|
|
142
143
|
return () => e.forEach((t) => t());
|
|
143
|
-
}, [
|
|
144
|
+
}, [s, l, O, i, z]), g(() => {
|
|
144
145
|
const e = (t) => {
|
|
145
146
|
const r = t == null ? void 0 : t.data;
|
|
146
147
|
if (!r || r.type !== "authorized" && r.type !== "authorize-failed")
|
|
@@ -148,67 +149,67 @@ const H = J(null), D = J({
|
|
|
148
149
|
const d = j(r.authUrl);
|
|
149
150
|
if (!(!d || t.origin !== d)) {
|
|
150
151
|
if (r.type === "authorized" && r.accessToken) {
|
|
151
|
-
L((
|
|
152
|
-
...
|
|
152
|
+
L((M) => ({
|
|
153
|
+
...M,
|
|
153
154
|
[d]: { accessToken: r.accessToken }
|
|
154
|
-
})),
|
|
155
|
+
})), C(d);
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
158
|
r.type === "authorize-failed" && u(d);
|
|
158
159
|
}
|
|
159
160
|
};
|
|
160
161
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
161
|
-
}, [
|
|
162
|
-
const e =
|
|
162
|
+
}, [C, u]), g(() => {
|
|
163
|
+
const e = y.current;
|
|
163
164
|
Object.values(a).forEach((t) => {
|
|
164
165
|
t.status === "silent" && !e[t.origin] && (e[t.origin] = setTimeout(() => {
|
|
165
166
|
delete e[t.origin], u(t.origin);
|
|
166
|
-
},
|
|
167
|
+
}, ee));
|
|
167
168
|
}), Object.keys(e).forEach((t) => {
|
|
168
169
|
(!a[t] || a[t].status !== "silent") && (clearTimeout(e[t]), delete e[t]);
|
|
169
170
|
});
|
|
170
|
-
}, [a, u]),
|
|
171
|
-
|
|
171
|
+
}, [a, u]), g(() => () => {
|
|
172
|
+
b.current && b.current(), Object.values(y.current).forEach(clearTimeout);
|
|
172
173
|
}, []);
|
|
173
|
-
const
|
|
174
|
+
const E = h(
|
|
174
175
|
(e) => {
|
|
175
|
-
|
|
176
|
-
const t = o ||
|
|
177
|
-
|
|
176
|
+
b.current && (b.current(), b.current = null);
|
|
177
|
+
const t = o || ne;
|
|
178
|
+
b.current = t(e, {
|
|
178
179
|
onBlocked: () => {
|
|
179
|
-
|
|
180
|
+
p((r) => r[e.origin] ? {
|
|
180
181
|
...r,
|
|
181
182
|
[e.origin]: { ...r[e.origin], popupBlocked: !0 }
|
|
182
183
|
} : r);
|
|
183
184
|
},
|
|
184
185
|
onClosed: () => {
|
|
185
186
|
if (e.v2) {
|
|
186
|
-
|
|
187
|
+
V && p((r) => !r[e.origin] || !r[e.origin].silentUrl ? r : {
|
|
187
188
|
...r,
|
|
188
189
|
[e.origin]: { ...r[e.origin], status: "silent" }
|
|
189
190
|
});
|
|
190
191
|
return;
|
|
191
192
|
}
|
|
192
|
-
|
|
193
|
+
i(e.origin);
|
|
193
194
|
}
|
|
194
195
|
});
|
|
195
196
|
},
|
|
196
|
-
[o,
|
|
197
|
-
),
|
|
197
|
+
[o, i]
|
|
198
|
+
), m = {
|
|
198
199
|
// Hosts render UI for interactive entries only; silent resolution is
|
|
199
200
|
// invisible by design.
|
|
200
201
|
pending: Object.values(a).filter(
|
|
201
202
|
(e) => e.status === "interactive"
|
|
202
203
|
),
|
|
203
|
-
authorize:
|
|
204
|
+
authorize: E,
|
|
204
205
|
dismiss: c,
|
|
205
|
-
originEpochs:
|
|
206
|
-
credentials:
|
|
206
|
+
originEpochs: R,
|
|
207
|
+
credentials: k,
|
|
207
208
|
unsupported: q
|
|
208
|
-
},
|
|
209
|
+
}, $ = Object.values(a).filter(
|
|
209
210
|
(e) => e.status === "silent" && e.silentUrl
|
|
210
211
|
);
|
|
211
|
-
return /* @__PURE__ */ f.createElement(D.Provider, { value:
|
|
212
|
+
return /* @__PURE__ */ f.createElement(D.Provider, { value: m }, n, $.map((e) => /* @__PURE__ */ f.createElement(
|
|
212
213
|
"iframe",
|
|
213
214
|
{
|
|
214
215
|
key: `mm-silent-auth-${e.origin}`,
|
|
@@ -220,159 +221,159 @@ const H = J(null), D = J({
|
|
|
220
221
|
}
|
|
221
222
|
)));
|
|
222
223
|
};
|
|
223
|
-
|
|
224
|
-
children:
|
|
225
|
-
launcher:
|
|
224
|
+
X.propTypes = {
|
|
225
|
+
children: w.node,
|
|
226
|
+
launcher: w.func
|
|
226
227
|
};
|
|
227
|
-
const
|
|
228
|
-
const { originEpochs: o } =
|
|
229
|
-
return
|
|
228
|
+
const re = () => Z(D), se = (n) => {
|
|
229
|
+
const { originEpochs: o } = Z(D), s = j(n);
|
|
230
|
+
return s && o[s] || 0;
|
|
230
231
|
}, ie = (n) => {
|
|
231
|
-
const { credentials: o } =
|
|
232
|
-
return
|
|
233
|
-
},
|
|
234
|
-
const { unsupported: o } =
|
|
235
|
-
return
|
|
236
|
-
},
|
|
237
|
-
const [
|
|
232
|
+
const { credentials: o } = Z(D), s = j(n);
|
|
233
|
+
return s && o[s] || null;
|
|
234
|
+
}, oe = (n) => {
|
|
235
|
+
const { unsupported: o } = Z(D), s = j(n);
|
|
236
|
+
return s && o[s] || null;
|
|
237
|
+
}, ce = ({ children: n, authorizationLauncher: o }) => {
|
|
238
|
+
const [s, a] = I({}), [p, R] = I({}), T = x({}), k = x({}), L = x({}), q = h((i, u) => {
|
|
238
239
|
var c;
|
|
239
|
-
return !!((c = L.current[
|
|
240
|
-
}, []), U =
|
|
241
|
-
a((l) => ({ ...l, [
|
|
242
|
-
}, []), S =
|
|
240
|
+
return !!((c = L.current[i]) != null && c.has(u));
|
|
241
|
+
}, []), U = h((i, u, c) => {
|
|
242
|
+
a((l) => ({ ...l, [i]: { origin: u, frameRef: c } }));
|
|
243
|
+
}, []), S = h((i) => {
|
|
243
244
|
a((u) => {
|
|
244
245
|
const c = { ...u };
|
|
245
|
-
return delete c[
|
|
246
|
-
}),
|
|
246
|
+
return delete c[i], c;
|
|
247
|
+
}), R((u) => {
|
|
247
248
|
const c = { ...u };
|
|
248
|
-
return delete c[
|
|
249
|
-
}), delete L.current[
|
|
249
|
+
return delete c[i], c;
|
|
250
|
+
}), delete L.current[i];
|
|
250
251
|
}, []);
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
c.forEach((
|
|
252
|
+
g(() => {
|
|
253
|
+
const i = (c = [], l) => {
|
|
254
|
+
c.forEach((E) => E(l));
|
|
254
255
|
}, u = (c) => {
|
|
255
|
-
var
|
|
256
|
-
if (!((
|
|
256
|
+
var $, e, t, r, d;
|
|
257
|
+
if (!(($ = c == null ? void 0 : c.data) != null && $.instanceId))
|
|
257
258
|
return;
|
|
258
|
-
const { instanceId: l, type:
|
|
259
|
-
if (
|
|
260
|
-
const { callbackId:
|
|
261
|
-
P && (P(B,
|
|
259
|
+
const { instanceId: l, type: E } = c.data, m = T.current;
|
|
260
|
+
if (E === "response") {
|
|
261
|
+
const { callbackId: M, response: B, error: _ } = c.data, P = k.current[M];
|
|
262
|
+
P && (P(B, _), delete k.current[M]);
|
|
262
263
|
return;
|
|
263
264
|
}
|
|
264
|
-
if (
|
|
265
|
-
const { requestType:
|
|
266
|
-
L.current[l] || (L.current[l] = /* @__PURE__ */ new Set()), L.current[l].add(
|
|
265
|
+
if (E === "mark-registered") {
|
|
266
|
+
const { requestType: M } = c.data;
|
|
267
|
+
L.current[l] || (L.current[l] = /* @__PURE__ */ new Set()), L.current[l].add(M);
|
|
267
268
|
return;
|
|
268
269
|
}
|
|
269
|
-
|
|
270
|
+
E === "ready" && R((M) => ({ ...M, [l]: !0 })), i((e = m[l]) == null ? void 0 : e[E], c.data), i((t = m["*"]) == null ? void 0 : t[E], c.data), i((r = m[l]) == null ? void 0 : r["*"], c.data), i((d = m["*"]) == null ? void 0 : d["*"], c.data);
|
|
270
271
|
};
|
|
271
272
|
return window.addEventListener("message", u), () => {
|
|
272
273
|
window.removeEventListener("message", u);
|
|
273
274
|
};
|
|
274
|
-
}, [
|
|
275
|
-
const
|
|
276
|
-
(
|
|
277
|
-
var
|
|
278
|
-
const l = i
|
|
275
|
+
}, [s]);
|
|
276
|
+
const b = h(
|
|
277
|
+
(i, u, c) => {
|
|
278
|
+
var E, m;
|
|
279
|
+
const l = s[i];
|
|
279
280
|
if (!l) {
|
|
280
|
-
console.warn(`Origin not set for id: ${
|
|
281
|
+
console.warn(`Origin not set for id: ${i}. Unable to send message.`);
|
|
281
282
|
return;
|
|
282
283
|
}
|
|
283
|
-
(
|
|
284
|
-
{ type: u, ...c, instanceId:
|
|
284
|
+
(m = (E = l == null ? void 0 : l.frameRef) == null ? void 0 : E.current) != null && m.contentWindow && l.frameRef.current.contentWindow.postMessage(
|
|
285
|
+
{ type: u, ...c, instanceId: i },
|
|
285
286
|
l.origin
|
|
286
287
|
);
|
|
287
288
|
},
|
|
288
|
-
[
|
|
289
|
-
),
|
|
290
|
-
async (
|
|
291
|
-
const
|
|
292
|
-
delete
|
|
289
|
+
[s]
|
|
290
|
+
), y = x(0), F = h(() => `${Date.now()}-${++y.current}`, []), z = h(
|
|
291
|
+
async (i, u, c = {}) => new Promise((l, E) => {
|
|
292
|
+
const m = F(), $ = (e, t) => {
|
|
293
|
+
delete k.current[m], t ? E(t) : l(e);
|
|
293
294
|
};
|
|
294
|
-
|
|
295
|
+
k.current[m] = $, b(i, "request", { callbackId: m, requestType: u, data: c });
|
|
295
296
|
}),
|
|
296
|
-
[
|
|
297
|
-
), A =
|
|
298
|
-
(
|
|
299
|
-
|
|
297
|
+
[b]
|
|
298
|
+
), A = h(
|
|
299
|
+
(i, u) => {
|
|
300
|
+
b(i, "load-options", u);
|
|
300
301
|
},
|
|
301
|
-
[
|
|
302
|
-
),
|
|
303
|
-
(
|
|
304
|
-
|
|
302
|
+
[b]
|
|
303
|
+
), O = h(
|
|
304
|
+
(i, u) => {
|
|
305
|
+
b(i, "validate", u);
|
|
305
306
|
},
|
|
306
|
-
[
|
|
307
|
-
),
|
|
307
|
+
[b]
|
|
308
|
+
), C = N(
|
|
308
309
|
() => ({
|
|
309
310
|
registerFrame: U,
|
|
310
311
|
unregisterFrame: S,
|
|
311
|
-
sendMessage:
|
|
312
|
-
sendRequest:
|
|
312
|
+
sendMessage: b,
|
|
313
|
+
sendRequest: z,
|
|
313
314
|
loadOptions: A,
|
|
314
|
-
validate:
|
|
315
|
+
validate: O,
|
|
315
316
|
hasHandler: q,
|
|
316
|
-
readyFrames:
|
|
317
|
-
addListener: (
|
|
318
|
-
|
|
317
|
+
readyFrames: p,
|
|
318
|
+
addListener: (i, u, c) => (T.current[i] || (T.current[i] = {}), T.current[i][u] || (T.current[i][u] = []), T.current[i][u].push(c), () => {
|
|
319
|
+
T.current[i][u] = T.current[i][u].filter((l) => l !== c);
|
|
319
320
|
})
|
|
320
321
|
}),
|
|
321
322
|
[
|
|
322
323
|
U,
|
|
323
324
|
S,
|
|
324
|
-
|
|
325
|
-
|
|
325
|
+
b,
|
|
326
|
+
z,
|
|
326
327
|
A,
|
|
327
|
-
|
|
328
|
+
O,
|
|
328
329
|
q,
|
|
329
|
-
|
|
330
|
+
p
|
|
330
331
|
]
|
|
331
332
|
);
|
|
332
|
-
return /* @__PURE__ */ f.createElement(H.Provider, { value:
|
|
333
|
-
}, v = (n, o,
|
|
334
|
-
const a =
|
|
333
|
+
return /* @__PURE__ */ f.createElement(H.Provider, { value: C }, /* @__PURE__ */ f.createElement(X, { launcher: o }, n));
|
|
334
|
+
}, v = (n, o, s) => {
|
|
335
|
+
const a = Z(H);
|
|
335
336
|
if (a === null)
|
|
336
337
|
throw new Error(
|
|
337
338
|
"useEmbeddedEffect must be used within a MMEmbeddableZoneProvider"
|
|
338
339
|
);
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}, [
|
|
340
|
+
const p = x(s);
|
|
341
|
+
g(() => {
|
|
342
|
+
p.current = s;
|
|
343
|
+
}, [s]), g(() => {
|
|
343
344
|
if (!(!n || !o)) {
|
|
344
345
|
if (o.startsWith("key:")) {
|
|
345
|
-
const
|
|
346
|
-
return a.readyFrames[n] && a.sendMessage(n, "subscribe-key", { keyChord:
|
|
346
|
+
const R = o.substring(4);
|
|
347
|
+
return a.readyFrames[n] && a.sendMessage(n, "subscribe-key", { keyChord: R }), a.addListener(
|
|
347
348
|
n,
|
|
348
|
-
`key-pressed:${
|
|
349
|
-
(...
|
|
349
|
+
`key-pressed:${R}`,
|
|
350
|
+
(...k) => p.current(...k)
|
|
350
351
|
);
|
|
351
352
|
}
|
|
352
353
|
return a.addListener(
|
|
353
354
|
n,
|
|
354
355
|
o,
|
|
355
|
-
(...
|
|
356
|
+
(...R) => p.current(...R)
|
|
356
357
|
);
|
|
357
358
|
}
|
|
358
359
|
}, [a, n, o]);
|
|
359
360
|
};
|
|
360
|
-
|
|
361
|
-
children:
|
|
361
|
+
ce.propTypes = {
|
|
362
|
+
children: w.node.isRequired,
|
|
362
363
|
/**
|
|
363
364
|
* Optional interactive-step launcher for embedded authorizations,
|
|
364
365
|
* `(entry, { onBlocked, onClosed }) => cleanup`. Defaults to a top-level
|
|
365
366
|
* popup. Hosts that cannot open windows (Android WebView shells) drive
|
|
366
367
|
* their own UI from useEmbeddedAuthorizations() instead.
|
|
367
368
|
*/
|
|
368
|
-
authorizationLauncher:
|
|
369
|
+
authorizationLauncher: w.func
|
|
369
370
|
};
|
|
370
|
-
const K =
|
|
371
|
+
const K = W.default || W, ue = 1e4, le = "credentials", J = (n, o) => `${n}/mm-embedded-interop?id=${o}&origin=${window.location.origin}&caps=${le}`, ae = K.iframe`
|
|
371
372
|
width: 100%;
|
|
372
373
|
height: 100%;
|
|
373
374
|
border: none;
|
|
374
375
|
visibility: ${(n) => n.$isReady ? "visible" : "hidden"};
|
|
375
|
-
`,
|
|
376
|
+
`, de = K.div`
|
|
376
377
|
width: 100%;
|
|
377
378
|
height: 100%;
|
|
378
379
|
display: flex;
|
|
@@ -385,30 +386,30 @@ const K = Z.default || Z, ce = 1e4, ue = "credentials", G = (n, o) => `${n}/mm-e
|
|
|
385
386
|
text-align: center;
|
|
386
387
|
color: #555;
|
|
387
388
|
font-size: 14px;
|
|
388
|
-
`,
|
|
389
|
-
|
|
390
|
-
entry:
|
|
391
|
-
origin:
|
|
392
|
-
name:
|
|
393
|
-
reason:
|
|
389
|
+
`, Y = ({ entry: n }) => /* @__PURE__ */ f.createElement(de, null, /* @__PURE__ */ f.createElement("div", { style: { fontWeight: 600 } }, n && n.origin || "This app", " can’t be embedded here"), /* @__PURE__ */ f.createElement("div", { style: { fontSize: 12, color: "#888" } }, "It needs an update to support embedding from a different domain."));
|
|
390
|
+
Y.propTypes = {
|
|
391
|
+
entry: w.shape({
|
|
392
|
+
origin: w.string,
|
|
393
|
+
name: w.string,
|
|
394
|
+
reason: w.string
|
|
394
395
|
})
|
|
395
396
|
};
|
|
396
|
-
const
|
|
397
|
+
const fe = K.div`
|
|
397
398
|
height: 100%;
|
|
398
399
|
display: flex;
|
|
399
400
|
flex: 1;
|
|
400
401
|
align-items: center;
|
|
401
402
|
justify-content: center;
|
|
402
|
-
`,
|
|
403
|
+
`, pe = () => /* @__PURE__ */ f.createElement(fe, null, /* @__PURE__ */ f.createElement("div", { style: { textAlign: "center" } }, "This app couldn’t be loaded as an embeddable widget.")), me = ({
|
|
403
404
|
id: n,
|
|
404
405
|
src: o,
|
|
405
|
-
path:
|
|
406
|
+
path: s,
|
|
406
407
|
onInit: a = () => {
|
|
407
408
|
},
|
|
408
|
-
onTimeout:
|
|
409
|
-
context:
|
|
410
|
-
params:
|
|
411
|
-
renderUnsupported:
|
|
409
|
+
onTimeout: p,
|
|
410
|
+
context: R = {},
|
|
411
|
+
params: T = {},
|
|
412
|
+
renderUnsupported: k,
|
|
412
413
|
renderTimeout: L,
|
|
413
414
|
...q
|
|
414
415
|
}) => {
|
|
@@ -416,104 +417,101 @@ const de = K.div`
|
|
|
416
417
|
return console.error(
|
|
417
418
|
"isConfiguring must be passed via the params prop to MMEmbeddableZone"
|
|
418
419
|
), null;
|
|
419
|
-
if ("colorMode" in
|
|
420
|
+
if ("colorMode" in R)
|
|
420
421
|
return console.error(
|
|
421
422
|
"colorMode must be passed via the params prop to MMEmbeddableZone"
|
|
422
423
|
), null;
|
|
423
|
-
if ("isFullScreen" in
|
|
424
|
+
if ("isFullScreen" in R)
|
|
424
425
|
return console.error(
|
|
425
426
|
"isFullScreen must be passed via the params prop to MMEmbeddableZone"
|
|
426
427
|
), null;
|
|
427
|
-
const U =
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}, [
|
|
431
|
-
const { registerFrame: l, unregisterFrame:
|
|
428
|
+
const U = x(), [S, b] = I(), [y, F] = I(0), [z, A] = I(!1), [O, C] = I(!1), i = se(o), u = ie(o), c = oe(o);
|
|
429
|
+
g(() => {
|
|
430
|
+
i > 0 && F(0);
|
|
431
|
+
}, [i]);
|
|
432
|
+
const { registerFrame: l, unregisterFrame: E, sendMessage: m } = Z(
|
|
432
433
|
H
|
|
433
|
-
), [
|
|
434
|
-
|
|
435
|
-
r.current =
|
|
436
|
-
}, [
|
|
434
|
+
), [$, e] = I(), t = x(), r = x(p), d = x(a), M = x(!1);
|
|
435
|
+
g(() => {
|
|
436
|
+
r.current = p;
|
|
437
|
+
}, [p]), g(() => {
|
|
437
438
|
d.current = a;
|
|
438
|
-
}, [a]),
|
|
439
|
-
|
|
439
|
+
}, [a]), g(() => {
|
|
440
|
+
y && m(n, "set-context", {
|
|
440
441
|
context: {
|
|
441
|
-
...
|
|
442
|
-
// TODO: Remove this once everything is migrated to params
|
|
443
|
-
colorMode: p.colorMode,
|
|
444
|
-
isFullScreen: p.isFullScreen
|
|
442
|
+
...R
|
|
445
443
|
}
|
|
446
444
|
});
|
|
447
|
-
}, [
|
|
448
|
-
|
|
449
|
-
}, [
|
|
450
|
-
|
|
451
|
-
}, [
|
|
452
|
-
|
|
453
|
-
}, [
|
|
445
|
+
}, [R, n, y]), g(() => {
|
|
446
|
+
y && m(n, "set-params", { params: T });
|
|
447
|
+
}, [T, n, y]), g(() => {
|
|
448
|
+
s !== void 0 && e((s == null ? void 0 : s.indexOf("/")) === 0 ? s : `/${s}`);
|
|
449
|
+
}, [s]), g(() => {
|
|
450
|
+
$ === void 0 || !y || m(n, "navigate", { path: $ });
|
|
451
|
+
}, [$, y, n, m]), g(() => {
|
|
454
452
|
if (!o || !n || !U)
|
|
455
453
|
return;
|
|
456
454
|
const P = new URL(o);
|
|
457
|
-
return l(n, P.origin, U), d.current(),
|
|
458
|
-
|
|
455
|
+
return l(n, P.origin, U), d.current(), b(J(P.origin, n)), () => {
|
|
456
|
+
E(n);
|
|
459
457
|
};
|
|
460
|
-
}, [o, n, l, U]),
|
|
461
|
-
if (!(!S ||
|
|
458
|
+
}, [o, n, l, U]), g(() => {
|
|
459
|
+
if (!(!S || M.current))
|
|
462
460
|
return t.current = setTimeout(() => {
|
|
463
461
|
A(!0), r.current && r.current();
|
|
464
|
-
},
|
|
462
|
+
}, ue), () => clearTimeout(t.current);
|
|
465
463
|
}, [S]);
|
|
466
|
-
const B =
|
|
467
|
-
|
|
464
|
+
const B = h(() => {
|
|
465
|
+
M.current = !0, clearTimeout(t.current), A(!1);
|
|
468
466
|
}, []);
|
|
469
467
|
v(n, "init", B), v(n, "authorize", B), v(n, "login", B), v(n, "credential-request", () => {
|
|
470
|
-
B(),
|
|
471
|
-
}),
|
|
472
|
-
!
|
|
473
|
-
}, [
|
|
474
|
-
B(),
|
|
468
|
+
B(), C(!0);
|
|
469
|
+
}), g(() => {
|
|
470
|
+
!O || !u || m(n, "credential", { accessToken: u.accessToken });
|
|
471
|
+
}, [O, u, n, m]), v(n, "ready", () => {
|
|
472
|
+
B(), F((P) => P + 1);
|
|
475
473
|
});
|
|
476
|
-
const
|
|
474
|
+
const _ = x();
|
|
477
475
|
return v(n, "heartbeat", () => {
|
|
478
|
-
|
|
476
|
+
_.current && clearTimeout(_.current), _.current = setTimeout(() => {
|
|
479
477
|
if (U.current) {
|
|
480
478
|
const P = new URL(o);
|
|
481
|
-
U.current.src =
|
|
479
|
+
U.current.src = J(P.origin, n);
|
|
482
480
|
}
|
|
483
481
|
}, 6e3);
|
|
484
|
-
}),
|
|
485
|
-
|
|
486
|
-
}, []), c ?
|
|
487
|
-
|
|
482
|
+
}), g(() => () => {
|
|
483
|
+
_.current && clearTimeout(_.current);
|
|
484
|
+
}, []), c ? k ? k(c) : /* @__PURE__ */ f.createElement(Y, { entry: c }) : z && !y ? L ? L() : /* @__PURE__ */ f.createElement(pe, null) : /* @__PURE__ */ f.createElement(
|
|
485
|
+
ae,
|
|
488
486
|
{
|
|
489
|
-
key: `auth-epoch-${
|
|
490
|
-
$isReady:
|
|
487
|
+
key: `auth-epoch-${i}`,
|
|
488
|
+
$isReady: y,
|
|
491
489
|
ref: U,
|
|
492
490
|
src: S,
|
|
493
491
|
...q
|
|
494
492
|
}
|
|
495
493
|
);
|
|
496
494
|
};
|
|
497
|
-
|
|
498
|
-
id:
|
|
499
|
-
src:
|
|
500
|
-
path:
|
|
501
|
-
onInit:
|
|
502
|
-
onTimeout:
|
|
495
|
+
me.propTypes = {
|
|
496
|
+
id: w.string,
|
|
497
|
+
src: w.string.isRequired,
|
|
498
|
+
path: w.string,
|
|
499
|
+
onInit: w.func,
|
|
500
|
+
onTimeout: w.func,
|
|
503
501
|
/**
|
|
504
502
|
* Optional host-styled renderer for the structurally-unsupported embed
|
|
505
503
|
* state (legacy app on a cross-site origin), `(entry) => ReactNode`. Falls
|
|
506
504
|
* back to a minimal built-in placeholder.
|
|
507
505
|
*/
|
|
508
|
-
renderUnsupported:
|
|
506
|
+
renderUnsupported: w.func,
|
|
509
507
|
/**
|
|
510
508
|
* Optional host-styled renderer for the handshake-timeout failure state
|
|
511
509
|
* (the app is not embeddable / could not load), `() => ReactNode`. Falls
|
|
512
510
|
* back to a minimal centered message.
|
|
513
511
|
*/
|
|
514
|
-
renderTimeout:
|
|
512
|
+
renderTimeout: w.func
|
|
515
513
|
};
|
|
516
|
-
const
|
|
514
|
+
const ge = W.div`
|
|
517
515
|
position: fixed;
|
|
518
516
|
inset: 0;
|
|
519
517
|
background: rgba(0, 0, 0, 0.45);
|
|
@@ -521,7 +519,7 @@ const me = Z.div`
|
|
|
521
519
|
align-items: center;
|
|
522
520
|
justify-content: center;
|
|
523
521
|
z-index: 10000;
|
|
524
|
-
`,
|
|
522
|
+
`, he = W.div`
|
|
525
523
|
background: #fff;
|
|
526
524
|
border-radius: 8px;
|
|
527
525
|
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
|
|
@@ -530,13 +528,13 @@ const me = Z.div`
|
|
|
530
528
|
max-width: calc(100vw - 32px);
|
|
531
529
|
font-family: sans-serif;
|
|
532
530
|
color: #222;
|
|
533
|
-
`,
|
|
531
|
+
`, be = W.div`
|
|
534
532
|
display: flex;
|
|
535
533
|
align-items: center;
|
|
536
534
|
justify-content: space-between;
|
|
537
535
|
padding: 10px 0;
|
|
538
536
|
gap: 16px;
|
|
539
|
-
`,
|
|
537
|
+
`, Ee = W.button`
|
|
540
538
|
background: #16a500;
|
|
541
539
|
color: #fff;
|
|
542
540
|
border: none;
|
|
@@ -545,25 +543,25 @@ const me = Z.div`
|
|
|
545
543
|
font-size: 14px;
|
|
546
544
|
cursor: pointer;
|
|
547
545
|
white-space: nowrap;
|
|
548
|
-
`,
|
|
546
|
+
`, we = W.p`
|
|
549
547
|
color: #b3261e;
|
|
550
548
|
font-size: 13px;
|
|
551
549
|
margin: 4px 0 0;
|
|
552
|
-
`,
|
|
553
|
-
const { pending: n, authorize: o } =
|
|
554
|
-
return n.length === 0 ? null : /* @__PURE__ */ f.createElement(
|
|
550
|
+
`, ke = () => {
|
|
551
|
+
const { pending: n, authorize: o } = re();
|
|
552
|
+
return n.length === 0 ? null : /* @__PURE__ */ f.createElement(ge, null, /* @__PURE__ */ f.createElement(he, null, /* @__PURE__ */ f.createElement("h3", { style: { margin: "0 0 8px" } }, "Authorization Required"), /* @__PURE__ */ f.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."), n.map((s) => /* @__PURE__ */ f.createElement("div", { key: s.origin }, /* @__PURE__ */ f.createElement(be, null, /* @__PURE__ */ f.createElement("div", null, /* @__PURE__ */ f.createElement("div", { style: { fontWeight: 600 } }, s.origin)), /* @__PURE__ */ f.createElement(Ee, { onClick: () => o(s) }, "Authorize")), s.popupBlocked && /* @__PURE__ */ f.createElement(we, null, "The sign-in window was blocked. Allow popups for this site, then try again.")))));
|
|
555
553
|
};
|
|
556
554
|
export {
|
|
557
555
|
D as EmbeddedAuthorizationContext,
|
|
558
|
-
|
|
559
|
-
|
|
556
|
+
ke as EmbeddedAuthorizationPrompt,
|
|
557
|
+
me as MMEmbeddableZone,
|
|
560
558
|
H as MMEmbeddableZoneContext,
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
559
|
+
ce as MMEmbeddableZoneProvider,
|
|
560
|
+
te as isCrossSite,
|
|
561
|
+
ne as popupAuthorizationLauncher,
|
|
562
|
+
re as useEmbeddedAuthorizations,
|
|
565
563
|
ie as useEmbeddedCredential,
|
|
566
564
|
v as useEmbeddedEffect,
|
|
567
|
-
|
|
568
|
-
|
|
565
|
+
se as useEmbeddedOriginEpoch,
|
|
566
|
+
oe as useEmbeddedUnsupported
|
|
569
567
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(m,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("react"),require("prop-types"),require("styled-components")):typeof define=="function"&&define.amd?define(["exports","react","prop-types","styled-components"],e):(m=typeof globalThis!="undefined"?globalThis:m||self,e(m["mm-react-embeddable"]={},m.React,m.PropTypes,m.styled))})(this,(function(m,e,E,q){"use strict";const W=e.createContext(null),v=e.createContext({pending:[],authorize:()=>{},dismiss:()=>{},originEpochs:{},credentials:{},unsupported:{}}),H=typeof window!="undefined"&&window.location.protocol==="https:",te=8e3,F=r=>{try{return new URL(r).origin}catch{return null}},P=r=>{if(!r||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(r)||r.includes(":"))return r;const u=r.split(".");return u.length<=2?r:u.slice(-2).join(".")},K=(r,u)=>{try{const i=new URL(r),f=new URL(u);return i.protocol!==f.protocol?!0:P(i.hostname)!==P(f.hostname)}catch{return!0}},V=(r,{onBlocked:u,onClosed:i})=>{const f=window.open(r.authUrl,"mm-embed-auth","popup,width=600,height=700");if(!f)return u(),()=>{};const g=setInterval(()=>{f.closed&&(clearInterval(g),i())},1e3);return()=>clearInterval(g)},G=({children:r,launcher:u})=>{const i=e.useContext(W),[f,g]=e.useState({}),[w,k]=e.useState({}),[C,S]=e.useState({}),[$,M]=e.useState({}),O=e.useRef(C);O.current=C;const h=e.useRef(null),x=e.useRef({}),y=e.useRef({}),z=e.useCallback(n=>{const t=y.current[n];if(!t)return;const s=a=>!a[n]||a[n].clientId?a:{...a,[n]:{...a[n],clientId:t}};g(s),M(s)},[]),j=e.useCallback((n,t)=>{const s=F(n==null?void 0:n.authUrl);s&&(M(a=>a[s]?a:{...a,[s]:{origin:s,reason:t,clientId:y.current[s]||null}}),z(s))},[z]),I=e.useCallback((n,{v2:t=!1}={})=>{const s=F(n==null?void 0:n.authUrl);s&&(t&&O.current[s]||(g(a=>a[s]?a:{...a,[s]:{origin:s,authUrl:n.authUrl,silentUrl:n.silentUrl||null,status:t&&n.silentUrl&&H?"silent":"interactive",v2:t,clientId:n.clientId||y.current[s]||null,popupBlocked:!1}}),z(s)))},[z]),T=e.useCallback(n=>{g(t=>{if(!t[n])return t;const s={...t};return delete s[n],s})},[]),o=e.useCallback(n=>{n&&(T(n),k(t=>({...t,[n]:(t[n]||0)+1})))},[T]),l=e.useCallback(n=>{g(t=>!t[n]||t[n].status==="interactive"?t:{...t,[n]:{...t[n],status:"interactive"}})},[]),c=e.useCallback(n=>{T(n.origin)},[T]),d=e.useCallback(n=>{const t=F(n==null?void 0:n.authUrl);if(t&&K(t,window.location.origin)){j(n,"cross-site-legacy");return}I(n)},[I,j]);e.useEffect(()=>{if(!i)return;const n=[i.addListener("*","init",t=>{t!=null&&t.origin&&t.clientId&&(y.current[t.origin]=t.clientId,z(t.origin))}),i.addListener("*","authorize",d),i.addListener("*","login",d),i.addListener("*","credential-request",t=>I(t,{v2:!0})),i.addListener("*","authorized",t=>{t!=null&&t.accessToken||o(F(t==null?void 0:t.authUrl))})];return()=>n.forEach(t=>t())},[i,d,I,o,z]),e.useEffect(()=>{const n=t=>{const s=t==null?void 0:t.data;if(!s||s.type!=="authorized"&&s.type!=="authorize-failed")return;const a=F(s.authUrl);if(!(!a||t.origin!==a)){if(s.type==="authorized"&&s.accessToken){S(U=>({...U,[a]:{accessToken:s.accessToken}})),T(a);return}s.type==="authorize-failed"&&l(a)}};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},[T,l]),e.useEffect(()=>{const n=x.current;Object.values(f).forEach(t=>{t.status==="silent"&&!n[t.origin]&&(n[t.origin]=setTimeout(()=>{delete n[t.origin],l(t.origin)},te))}),Object.keys(n).forEach(t=>{(!f[t]||f[t].status!=="silent")&&(clearTimeout(n[t]),delete n[t])})},[f,l]),e.useEffect(()=>()=>{h.current&&h.current(),Object.values(x.current).forEach(clearTimeout)},[]);const p=e.useCallback(n=>{h.current&&(h.current(),h.current=null);const t=u||V;h.current=t(n,{onBlocked:()=>{g(s=>s[n.origin]?{...s,[n.origin]:{...s[n.origin],popupBlocked:!0}}:s)},onClosed:()=>{if(n.v2){H&&g(s=>!s[n.origin]||!s[n.origin].silentUrl?s:{...s,[n.origin]:{...s[n.origin],status:"silent"}});return}o(n.origin)}})},[u,o]),b={pending:Object.values(f).filter(n=>n.status==="interactive"),authorize:p,dismiss:c,originEpochs:w,credentials:C,unsupported:$},L=Object.values(f).filter(n=>n.status==="silent"&&n.silentUrl);return e.createElement(v.Provider,{value:b},r,L.map(n=>e.createElement("iframe",{key:`mm-silent-auth-${n.origin}`,src:n.silentUrl,title:`MachineMetrics silent authorization (${n.origin})`,"aria-hidden":"true",tabIndex:-1,style:{display:"none"}})))};G.propTypes={children:E.node,launcher:E.func};const J=()=>e.useContext(v),Q=r=>{const{originEpochs:u}=e.useContext(v),i=F(r);return i&&u[i]||0},X=r=>{const{credentials:u}=e.useContext(v),i=F(r);return i&&u[i]||null},Y=r=>{const{unsupported:u}=e.useContext(v),i=F(r);return i&&u[i]||null},N=({children:r,authorizationLauncher:u})=>{const[i,f]=e.useState({}),[g,w]=e.useState({}),k=e.useRef({}),C=e.useRef({}),S=e.useRef({}),$=e.useCallback((o,l)=>{var c;return!!((c=S.current[o])!=null&&c.has(l))},[]),M=e.useCallback((o,l,c)=>{f(d=>({...d,[o]:{origin:l,frameRef:c}}))},[]),O=e.useCallback(o=>{f(l=>{const c={...l};return delete c[o],c}),w(l=>{const c={...l};return delete c[o],c}),delete S.current[o]},[]);e.useEffect(()=>{const o=(c=[],d)=>{c.forEach(p=>p(d))},l=c=>{var L,n,t,s,a;if(!((L=c==null?void 0:c.data)!=null&&L.instanceId))return;const{instanceId:d,type:p}=c.data,b=k.current;if(p==="response"){const{callbackId:U,response:B,error:_}=c.data,A=C.current[U];A&&(A(B,_),delete C.current[U]);return}if(p==="mark-registered"){const{requestType:U}=c.data;S.current[d]||(S.current[d]=new Set),S.current[d].add(U);return}p==="ready"&&w(U=>({...U,[d]:!0})),o((n=b[d])==null?void 0:n[p],c.data),o((t=b["*"])==null?void 0:t[p],c.data),o((s=b[d])==null?void 0:s["*"],c.data),o((a=b["*"])==null?void 0:a["*"],c.data)};return window.addEventListener("message",l),()=>{window.removeEventListener("message",l)}},[i]);const h=e.useCallback((o,l,c)=>{var p,b;const d=i[o];if(!d){console.warn(`Origin not set for id: ${o}. Unable to send message.`);return}(b=(p=d==null?void 0:d.frameRef)==null?void 0:p.current)!=null&&b.contentWindow&&d.frameRef.current.contentWindow.postMessage({type:l,...c,instanceId:o},d.origin)},[i]),x=e.useRef(0),y=e.useCallback(()=>`${Date.now()}-${++x.current}`,[]),z=e.useCallback(async(o,l,c={})=>new Promise((d,p)=>{const b=y(),L=(n,t)=>{delete C.current[b],t?p(t):d(n)};C.current[b]=L,h(o,"request",{callbackId:b,requestType:l,data:c})}),[h]),j=e.useCallback((o,l)=>{h(o,"load-options",l)},[h]),I=e.useCallback((o,l)=>{h(o,"validate",l)},[h]),T=e.useMemo(()=>({registerFrame:M,unregisterFrame:O,sendMessage:h,sendRequest:z,loadOptions:j,validate:I,hasHandler:$,readyFrames:g,addListener:(o,l,c)=>(k.current[o]||(k.current[o]={}),k.current[o][l]||(k.current[o][l]=[]),k.current[o][l].push(c),()=>{k.current[o][l]=k.current[o][l].filter(d=>d!==c)})}),[M,O,h,z,j,I,$,g]);return e.createElement(W.Provider,{value:T},e.createElement(G,{launcher:u},r))},Z=(r,u,i)=>{const f=e.useContext(W);if(f===null)throw new Error("useEmbeddedEffect must be used within a MMEmbeddableZoneProvider");const g=e.useRef(i);e.useEffect(()=>{g.current=i},[i]),e.useEffect(()=>{if(!(!r||!u)){if(u.startsWith("key:")){const w=u.substring(4);return f.readyFrames[r]&&f.sendMessage(r,"subscribe-key",{keyChord:w}),f.addListener(r,`key-pressed:${w}`,(...C)=>g.current(...C))}return f.addListener(r,u,(...w)=>g.current(...w))}},[f,r,u])};N.propTypes={children:E.node.isRequired,authorizationLauncher:E.func};const D=q.default||q,re=1e4,se="credentials",R=(r,u)=>`${r}/mm-embedded-interop?id=${u}&origin=${window.location.origin}&caps=${se}`,ie=D.iframe`
|
|
2
2
|
width: 100%;
|
|
3
3
|
height: 100%;
|
|
4
4
|
border: none;
|
|
5
5
|
visibility: ${r=>r.$isReady?"visible":"hidden"};
|
|
6
|
-
`,
|
|
6
|
+
`,oe=D.div`
|
|
7
7
|
width: 100%;
|
|
8
8
|
height: 100%;
|
|
9
9
|
display: flex;
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
text-align: center;
|
|
17
17
|
color: #555;
|
|
18
18
|
font-size: 14px;
|
|
19
|
-
`,
|
|
19
|
+
`,ee=({entry:r})=>e.createElement(oe,null,e.createElement("div",{style:{fontWeight:600}},r&&r.origin||"This app"," can’t be embedded here"),e.createElement("div",{style:{fontSize:12,color:"#888"}},"It needs an update to support embedding from a different domain."));ee.propTypes={entry:E.shape({origin:E.string,name:E.string,reason:E.string})};const ue=D.div`
|
|
20
20
|
height: 100%;
|
|
21
21
|
display: flex;
|
|
22
22
|
flex: 1;
|
|
23
23
|
align-items: center;
|
|
24
24
|
justify-content: center;
|
|
25
|
-
`,
|
|
25
|
+
`,ce=()=>e.createElement(ue,null,e.createElement("div",{style:{textAlign:"center"}},"This app couldn’t be loaded as an embeddable widget.")),ne=({id:r,src:u,path:i,onInit:f=()=>{},onTimeout:g,context:w={},params:k={},renderUnsupported:C,renderTimeout:S,...$})=>{if("isConfiguring"in $)return console.error("isConfiguring must be passed via the params prop to MMEmbeddableZone"),null;if("colorMode"in w)return console.error("colorMode must be passed via the params prop to MMEmbeddableZone"),null;if("isFullScreen"in w)return console.error("isFullScreen must be passed via the params prop to MMEmbeddableZone"),null;const M=e.useRef(),[O,h]=e.useState(),[x,y]=e.useState(0),[z,j]=e.useState(!1),[I,T]=e.useState(!1),o=Q(u),l=X(u),c=Y(u);e.useEffect(()=>{o>0&&y(0)},[o]);const{registerFrame:d,unregisterFrame:p,sendMessage:b}=e.useContext(W),[L,n]=e.useState(),t=e.useRef(),s=e.useRef(g),a=e.useRef(f),U=e.useRef(!1);e.useEffect(()=>{s.current=g},[g]),e.useEffect(()=>{a.current=f},[f]),e.useEffect(()=>{x&&b(r,"set-context",{context:{...w}})},[w,r,x]),e.useEffect(()=>{x&&b(r,"set-params",{params:k})},[k,r,x]),e.useEffect(()=>{i!==void 0&&n((i==null?void 0:i.indexOf("/"))===0?i:`/${i}`)},[i]),e.useEffect(()=>{L===void 0||!x||b(r,"navigate",{path:L})},[L,x,r,b]),e.useEffect(()=>{if(!u||!r||!M)return;const A=new URL(u);return d(r,A.origin,M),a.current(),h(R(A.origin,r)),()=>{p(r)}},[u,r,d,M]),e.useEffect(()=>{if(!(!O||U.current))return t.current=setTimeout(()=>{j(!0),s.current&&s.current()},re),()=>clearTimeout(t.current)},[O]);const B=e.useCallback(()=>{U.current=!0,clearTimeout(t.current),j(!1)},[]);Z(r,"init",B),Z(r,"authorize",B),Z(r,"login",B),Z(r,"credential-request",()=>{B(),T(!0)}),e.useEffect(()=>{!I||!l||b(r,"credential",{accessToken:l.accessToken})},[I,l,r,b]),Z(r,"ready",()=>{B(),y(A=>A+1)});const _=e.useRef();return Z(r,"heartbeat",()=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{if(M.current){const A=new URL(u);M.current.src=R(A.origin,r)}},6e3)}),e.useEffect(()=>()=>{_.current&&clearTimeout(_.current)},[]),c?C?C(c):e.createElement(ee,{entry:c}):z&&!x?S?S():e.createElement(ce,null):e.createElement(ie,{key:`auth-epoch-${o}`,$isReady:x,ref:M,src:O,...$})};ne.propTypes={id:E.string,src:E.string.isRequired,path:E.string,onInit:E.func,onTimeout:E.func,renderUnsupported:E.func,renderTimeout:E.func};const le=q.div`
|
|
26
26
|
position: fixed;
|
|
27
27
|
inset: 0;
|
|
28
28
|
background: rgba(0, 0, 0, 0.45);
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
align-items: center;
|
|
31
31
|
justify-content: center;
|
|
32
32
|
z-index: 10000;
|
|
33
|
-
`,
|
|
33
|
+
`,de=q.div`
|
|
34
34
|
background: #fff;
|
|
35
35
|
border-radius: 8px;
|
|
36
36
|
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
max-width: calc(100vw - 32px);
|
|
40
40
|
font-family: sans-serif;
|
|
41
41
|
color: #222;
|
|
42
|
-
`,
|
|
42
|
+
`,fe=q.div`
|
|
43
43
|
display: flex;
|
|
44
44
|
align-items: center;
|
|
45
45
|
justify-content: space-between;
|
|
46
46
|
padding: 10px 0;
|
|
47
47
|
gap: 16px;
|
|
48
|
-
`,
|
|
48
|
+
`,ae=q.button`
|
|
49
49
|
background: #16a500;
|
|
50
50
|
color: #fff;
|
|
51
51
|
border: none;
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
font-size: 14px;
|
|
55
55
|
cursor: pointer;
|
|
56
56
|
white-space: nowrap;
|
|
57
|
-
`,
|
|
57
|
+
`,me=q.p`
|
|
58
58
|
color: #b3261e;
|
|
59
59
|
font-size: 13px;
|
|
60
60
|
margin: 4px 0 0;
|
|
61
|
-
`,
|
|
61
|
+
`,ge=()=>{const{pending:r,authorize:u}=J();return r.length===0?null:e.createElement(le,null,e.createElement(de,null,e.createElement("h3",{style:{margin:"0 0 8px"}},"Authorization Required"),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."),r.map(i=>e.createElement("div",{key:i.origin},e.createElement(fe,null,e.createElement("div",null,e.createElement("div",{style:{fontWeight:600}},i.origin)),e.createElement(ae,{onClick:()=>u(i)},"Authorize")),i.popupBlocked&&e.createElement(me,null,"The sign-in window was blocked. Allow popups for this site, then try again.")))))};m.EmbeddedAuthorizationContext=v,m.EmbeddedAuthorizationPrompt=ge,m.MMEmbeddableZone=ne,m.MMEmbeddableZoneContext=W,m.MMEmbeddableZoneProvider=N,m.isCrossSite=K,m.popupAuthorizationLauncher=V,m.useEmbeddedAuthorizations=J,m.useEmbeddedCredential=X,m.useEmbeddedEffect=Z,m.useEmbeddedOriginEpoch=Q,m.useEmbeddedUnsupported=Y,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
|