@arcgis/portal-components 5.2.0-next.121 → 5.2.0-next.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/H2BBKRIY.js +2 -0
- package/dist/cdn/L4YVQHX3.js +2 -0
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-portal-account-switcher/customElement.js +162 -161
- package/dist/components/arcgis-portal-account-switcher-accounts/customElement.js +6 -6
- package/dist/components/arcgis-portal-navigation/index.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +6 -6
- package/dist/cdn/7WLW7D3K.js +0 -2
- package/dist/cdn/PUYQ5NCE.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { c as L } from "../../chunks/runtime.js";
|
|
3
3
|
import { keyed as _ } from "lit/directives/keyed.js";
|
|
4
|
-
import { LitElement as C, createEvent as
|
|
4
|
+
import { LitElement as C, createEvent as k, safeClassMap as v, nothing as x } from "@arcgis/lumina";
|
|
5
5
|
import { html as d, svg as T } from "lit";
|
|
6
6
|
import { s as M } from "../../chunks/portal-account-switcher.js";
|
|
7
7
|
import { g as K, a as N, l as E, u as H } from "../../chunks/user.js";
|
|
@@ -11,112 +11,113 @@ import { u as W } from "../../chunks/useT9n.js";
|
|
|
11
11
|
import { m as B } from "../../chunks/icons.js";
|
|
12
12
|
import { substitute as m } from "@arcgis/core/intl.js";
|
|
13
13
|
import { g as R } from "../../chunks/services.js";
|
|
14
|
-
const U = 1260 * 1e3;
|
|
15
|
-
function I(
|
|
16
|
-
const n = window.screenLeft ?? 0, i = window.screenTop ?? 0, a = window.innerWidth || document.documentElement.clientWidth || window.screen.width,
|
|
14
|
+
const U = 1260 * 1e3, J = 2500;
|
|
15
|
+
function I(r, e = "_blank", s = 582, t = 670) {
|
|
16
|
+
const n = window.screenLeft ?? 0, i = window.screenTop ?? 0, a = window.innerWidth || document.documentElement.clientWidth || window.screen.width, o = window.innerHeight || document.documentElement.clientHeight || window.screen.height, c = a / 2 - s / 2 + n, u = o / 2 - t / 2 + i, l = window.open(r, e, `scrollbars=no, width=${s}, height=${t}, top=${u}, left=${c}`);
|
|
17
17
|
return l?.focus(), l;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
locale:
|
|
22
|
-
|
|
19
|
+
function D(r) {
|
|
20
|
+
const e = f.findOAuthInfo(r.url), { locale: s = "en", expiration: t = U } = e ?? {}, n = new URLSearchParams({
|
|
21
|
+
locale: s,
|
|
22
|
+
// Linking accounts ALWAYS uses the "arcgisonline" client id
|
|
23
|
+
client_id: "arcgisonline",
|
|
23
24
|
response_type: "token",
|
|
24
|
-
expiration: `${
|
|
25
|
+
expiration: `${t}`,
|
|
25
26
|
linkUserRequest: "true",
|
|
26
27
|
showSocialLogins: "true",
|
|
27
28
|
hideEnterpriseLogins: "false",
|
|
28
29
|
force_login: "true",
|
|
29
30
|
parent: window.location.origin,
|
|
30
|
-
redirect_uri: `https://${
|
|
31
|
+
redirect_uri: `https://${r.portalHostname}/home/link_account_callback.html`,
|
|
31
32
|
state: JSON.stringify({ useMessage: !0 })
|
|
32
|
-
}),
|
|
33
|
-
I(
|
|
33
|
+
}), i = `https://${r.portalHostname}/sharing/oauth2/authorize?${n.toString()}`;
|
|
34
|
+
I(i);
|
|
34
35
|
}
|
|
35
|
-
function A(
|
|
36
|
+
function A(r) {
|
|
36
37
|
const {
|
|
37
|
-
config:
|
|
38
|
+
config: e,
|
|
38
39
|
token: s,
|
|
39
|
-
clientId:
|
|
40
|
+
clientId: t = "arcgisonline",
|
|
40
41
|
redirectToClientUri: n = !1,
|
|
41
42
|
displaySignoutComplete: i = !1
|
|
42
|
-
} =
|
|
43
|
+
} = r, a = new URLSearchParams({
|
|
43
44
|
display: "iframe",
|
|
44
|
-
client_id:
|
|
45
|
+
client_id: t,
|
|
45
46
|
...s && { token: s },
|
|
46
47
|
parent: window.location.origin,
|
|
47
|
-
redirect_uri: `${
|
|
48
|
+
redirect_uri: `${e.baseUrl}signout_callback.html`,
|
|
48
49
|
state: JSON.stringify({
|
|
49
50
|
signout: !0,
|
|
50
51
|
origin: window.location.origin,
|
|
51
52
|
redirectToClientUri: n,
|
|
52
53
|
displaySignoutComplete: i
|
|
53
54
|
})
|
|
54
|
-
}),
|
|
55
|
-
c.src =
|
|
55
|
+
}), o = `${e.restBaseUrl}oauth2/signout?${a.toString()}`, c = document.createElement("iframe");
|
|
56
|
+
c.src = o, c.style.display = "none", document.body.appendChild(c);
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
-
const
|
|
58
|
+
function j(r, e, s) {
|
|
59
|
+
const t = g(r.orgUrlKey, e), n = f.findOAuthInfo(t), { appId: i, locale: a = "en", expiration: o = U } = n ?? {}, c = S(r.provider), u = new URLSearchParams({
|
|
59
60
|
locale: a,
|
|
60
61
|
client_id: s ?? i ?? "arcgisonline",
|
|
61
62
|
response_type: "token",
|
|
62
|
-
expiration: `${
|
|
63
|
+
expiration: `${o}`,
|
|
63
64
|
parent: window.location.origin,
|
|
64
|
-
...c === "social" && { socialLoginProviderName:
|
|
65
|
-
...c === "default" && { prepopulatedusername:
|
|
65
|
+
...c === "social" && { socialLoginProviderName: r.provider },
|
|
66
|
+
...c === "default" && { prepopulatedusername: r.username },
|
|
66
67
|
force_login: "true",
|
|
67
|
-
redirect_uri: `${
|
|
68
|
+
redirect_uri: `${t}/home/sign_in_callback.html`,
|
|
68
69
|
state: JSON.stringify({
|
|
69
|
-
user:
|
|
70
|
-
server:
|
|
71
|
-
portalUrl:
|
|
70
|
+
user: r.username,
|
|
71
|
+
server: t,
|
|
72
|
+
portalUrl: t,
|
|
72
73
|
origin: window.location.origin
|
|
73
74
|
})
|
|
74
|
-
}), l = `${y(
|
|
75
|
+
}), l = `${y(r, e)}?${u.toString()}`;
|
|
75
76
|
I(l);
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
accounts:
|
|
79
|
-
clientId:
|
|
78
|
+
function q({
|
|
79
|
+
accounts: r,
|
|
80
|
+
clientId: e = "arcgisonline",
|
|
80
81
|
usersToFilter: s = [],
|
|
81
|
-
accountsToFilter:
|
|
82
|
+
accountsToFilter: t = ""
|
|
82
83
|
}) {
|
|
83
84
|
const n = {};
|
|
84
|
-
return
|
|
85
|
-
const
|
|
85
|
+
return r.reduce((i, a) => {
|
|
86
|
+
const o = {
|
|
86
87
|
disabled: a.disabled ?? !1,
|
|
87
88
|
allowed: a.clientAppAccessAllowed ?? !0
|
|
88
89
|
};
|
|
89
|
-
return i[a.username] =
|
|
90
|
+
return i[a.username] = o, (s.includes(a.username) || s.includes(a.username.toLowerCase()) || t === "org" && a.orgUrlKey || e === "esriapps" && a.userType !== "both") && (o.allowed = !1), i;
|
|
90
91
|
}, n), n;
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
-
account:
|
|
94
|
-
credential:
|
|
93
|
+
function z({
|
|
94
|
+
account: r,
|
|
95
|
+
credential: e,
|
|
95
96
|
client_id: s,
|
|
96
|
-
portal:
|
|
97
|
+
portal: t
|
|
97
98
|
}) {
|
|
98
|
-
const n = S(
|
|
99
|
+
const n = S(r.provider), i = y(r, t), a = O(r, t), o = new URLSearchParams({
|
|
99
100
|
client_id: s,
|
|
100
101
|
redirect_uri: a,
|
|
101
102
|
parent: window.location.origin,
|
|
102
103
|
response_type: "token",
|
|
103
104
|
force_login: "false",
|
|
104
|
-
...
|
|
105
|
-
...n === "social" && { socialLoginProviderName:
|
|
106
|
-
expiration: `${(
|
|
105
|
+
...e.userId && { prepopulatedusername: e.userId },
|
|
106
|
+
...n === "social" && { socialLoginProviderName: r.provider },
|
|
107
|
+
expiration: `${(e?.expires ?? Date.now() + U) - Date.now()}`
|
|
107
108
|
});
|
|
108
|
-
return `${i}?${
|
|
109
|
+
return `${i}?${o.toString()}`;
|
|
109
110
|
}
|
|
110
|
-
function S(
|
|
111
|
-
return
|
|
111
|
+
function S(r) {
|
|
112
|
+
return F(r) ? "social" : r === "enterprise" ? "enterprise" : r.includes("oidc") ? "oidc" : "default";
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
-
return ["apple", "facebook", "github", "google"].includes(
|
|
114
|
+
function F(r) {
|
|
115
|
+
return ["apple", "facebook", "github", "google"].includes(r);
|
|
115
116
|
}
|
|
116
|
-
function y(
|
|
117
|
-
const s = g(
|
|
117
|
+
function y(r, e) {
|
|
118
|
+
const s = g(r.orgUrlKey, e).toLowerCase(), t = S(r.provider);
|
|
118
119
|
let n = "";
|
|
119
|
-
switch (
|
|
120
|
+
switch (t) {
|
|
120
121
|
case "social":
|
|
121
122
|
n = "social/";
|
|
122
123
|
break;
|
|
@@ -124,42 +125,42 @@ function y(o, t) {
|
|
|
124
125
|
n = "saml/";
|
|
125
126
|
break;
|
|
126
127
|
case "oidc":
|
|
127
|
-
n = `oidc/${
|
|
128
|
+
n = `oidc/${r.provider.split("_")[1]}/`;
|
|
128
129
|
break;
|
|
129
130
|
}
|
|
130
131
|
return `${s}/sharing/rest/oauth2/${n}authorize`;
|
|
131
132
|
}
|
|
132
|
-
function g(
|
|
133
|
-
return
|
|
133
|
+
function g(r, e) {
|
|
134
|
+
return r?.startsWith("https://") ? r : r && e.customBaseUrl ? `https://${r}.${e.customBaseUrl}` : `https://${e.portalHostname}`;
|
|
134
135
|
}
|
|
135
|
-
function O(
|
|
136
|
-
return `${g(
|
|
136
|
+
function O(r, e) {
|
|
137
|
+
return `${g(r.orgUrlKey, e)}/home/accountswitcher-callback.html`;
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
return f.findCredential(g(
|
|
139
|
+
function G(r, e) {
|
|
140
|
+
return f.findCredential(g(r.orgUrlKey, e), r.username);
|
|
140
141
|
}
|
|
141
|
-
function
|
|
142
|
-
const s =
|
|
142
|
+
function Q(r, e) {
|
|
143
|
+
const s = G(r, e);
|
|
143
144
|
if (s)
|
|
144
145
|
return s;
|
|
145
|
-
const
|
|
146
|
+
const t = g(r.orgUrlKey, e), n = `${t}/home/check_sign_in_status.html#state=${JSON.stringify({
|
|
146
147
|
origin: window.location.origin,
|
|
147
|
-
server:
|
|
148
|
-
orgKey:
|
|
148
|
+
server: t,
|
|
149
|
+
orgKey: t
|
|
149
150
|
})}`;
|
|
150
|
-
|
|
151
|
+
V(n, `iframe__for-${t}`);
|
|
151
152
|
}
|
|
152
|
-
function
|
|
153
|
+
function V(r, e) {
|
|
153
154
|
const s = document.createElement("iframe");
|
|
154
|
-
s.src =
|
|
155
|
+
s.src = r, s.id = e, s.style.display = "none", document.body.appendChild(s);
|
|
155
156
|
}
|
|
156
157
|
const $ = 100;
|
|
157
|
-
class
|
|
158
|
+
class X extends C {
|
|
158
159
|
constructor() {
|
|
159
160
|
super(), this.messages = W({ blocking: !0 }), this.targetUser = "", this.targetToken = "", this.accountAccess = {}, this.remainingSignouts = 0, this.signoutHandle = 0, this.linkedAccounts = [], this.loading = !1, this.signedInStatus = {}, this.showAssociatedAccountsWarning = !1, this.signedInAccounts = [], this.clientId = "arcgisonline", this.signout = !1, this.signoutOptions = {
|
|
160
161
|
redirectToClientUri: !1,
|
|
161
162
|
displaySignoutComplete: !1
|
|
162
|
-
}, this.arcgisAccountSwitch =
|
|
163
|
+
}, this.arcgisAccountSwitch = k(), this.arcgisClose = k(), this.arcgisSignoutComplete = k(), this.listenOn(window, "message", this.handleMessageEvent);
|
|
163
164
|
}
|
|
164
165
|
static {
|
|
165
166
|
this.properties = { linkedAccounts: 16, userAccounts: 16, user: 16, credential: 16, alertOptions: 16, loading: 16, signedInStatus: 16, showAssociatedAccountsWarning: 16, signedInAccounts: 16, portal: 0, clientId: 1, signout: 5, signoutOptions: 0 };
|
|
@@ -167,62 +168,62 @@ class V extends C {
|
|
|
167
168
|
static {
|
|
168
169
|
this.styles = M;
|
|
169
170
|
}
|
|
170
|
-
willUpdate(
|
|
171
|
-
if (
|
|
171
|
+
willUpdate(e) {
|
|
172
|
+
if (e.has("portal") && (this.user = this.portal?.user), (e.has("portal") || e.has("user")) && this.portal && this.user) {
|
|
172
173
|
this.findLinkedUsers();
|
|
173
174
|
return;
|
|
174
175
|
}
|
|
175
|
-
if (
|
|
176
|
+
if (e.has("linkedAccounts") || e.has("signedInStatus")) {
|
|
176
177
|
if (this.signout) {
|
|
177
|
-
const { signedInStatus: s, linkedAccounts:
|
|
178
|
-
this.remainingSignouts =
|
|
178
|
+
const { signedInStatus: s, linkedAccounts: t, portal: n, signoutOptions: i, clientId: a } = this, o = Object.keys(s).filter((p) => s[p] !== null).map((p) => t.find((w) => w.username === p));
|
|
179
|
+
this.remainingSignouts = o.length + 1;
|
|
179
180
|
const c = g(n.urlKey ?? "", n), u = `${c}/sharing/rest`;
|
|
180
181
|
let { displaySignoutComplete: l = !0, redirectToClientUri: h = !0 } = i;
|
|
181
|
-
|
|
182
|
+
o.length > 0 && (l = !1, h = !1), this.loading = !0, A({ displaySignoutComplete: l, redirectToClientUri: h, clientId: a, config: { baseUrl: c, restBaseUrl: u } }), this.signoutHandle = window.setTimeout(() => {
|
|
182
183
|
this.remainingSignouts -= 1, this.finishSignout({ accountOrigin: c, redirectToClientUri: h, displaySignoutComplete: l });
|
|
183
|
-
},
|
|
184
|
+
}, J);
|
|
184
185
|
}
|
|
185
186
|
return;
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
|
-
handleMessageEvent(
|
|
189
|
-
if (new URL(
|
|
190
|
-
if (typeof
|
|
191
|
-
JSON.parse(
|
|
189
|
+
handleMessageEvent(e) {
|
|
190
|
+
if (new URL(e.origin).hostname !== "localhost" && (e.origin.endsWith(".arcgis.com") || e.origin === window.location.origin)) {
|
|
191
|
+
if (typeof e.data == "string") {
|
|
192
|
+
JSON.parse(e.data).type === "token_exchange" && this.handleExchangeTokenMessage(e);
|
|
192
193
|
return;
|
|
193
194
|
}
|
|
194
|
-
if ("type" in
|
|
195
|
-
switch (
|
|
195
|
+
if ("type" in e.data)
|
|
196
|
+
switch (e.data.type) {
|
|
196
197
|
case "signin":
|
|
197
|
-
this.handleSigninMessage(
|
|
198
|
+
this.handleSigninMessage(e);
|
|
198
199
|
return;
|
|
199
200
|
case "signout":
|
|
200
|
-
this.handleSignoutMessage(
|
|
201
|
+
this.handleSignoutMessage(e);
|
|
201
202
|
return;
|
|
202
203
|
case "linkUser":
|
|
203
|
-
this.handleLinkUserMessage(
|
|
204
|
+
this.handleLinkUserMessage(e);
|
|
204
205
|
return;
|
|
205
206
|
case "token_exchange":
|
|
206
|
-
this.handleExchangeTokenMessage(
|
|
207
|
+
this.handleExchangeTokenMessage(e);
|
|
207
208
|
return;
|
|
208
209
|
}
|
|
209
|
-
if ("credential" in
|
|
210
|
-
this.handleSigninMessage(
|
|
210
|
+
if ("credential" in e.data) {
|
|
211
|
+
this.handleSigninMessage(e);
|
|
211
212
|
return;
|
|
212
213
|
}
|
|
213
|
-
this.handleCheckSignInStatusMessage(
|
|
214
|
+
this.handleCheckSignInStatusMessage(e);
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
|
-
handleSignoutMessage(
|
|
217
|
-
const { error: s, signout:
|
|
217
|
+
handleSignoutMessage(e) {
|
|
218
|
+
const { error: s, signout: t, accountOrigin: n, redirectToClientUri: i, displaySignoutComplete: a } = e.data;
|
|
218
219
|
if (this.remainingSignouts -= 1, s && s !== "unknown") {
|
|
219
220
|
console.error(s), this.showAlert("danger", this.messages.errors.signout);
|
|
220
221
|
return;
|
|
221
222
|
}
|
|
222
|
-
|
|
223
|
+
t && (this.user = void 0, this.credential = void 0, this.finishSignout({ accountOrigin: n, redirectToClientUri: i, displaySignoutComplete: a }));
|
|
223
224
|
}
|
|
224
|
-
handleSigninMessage(
|
|
225
|
-
const { messages: s, clientId:
|
|
225
|
+
handleSigninMessage(e) {
|
|
226
|
+
const { messages: s, clientId: t } = this, { error: n, status: i, state: a, access_token: o, ssl: c } = e.data;
|
|
226
227
|
if (n) {
|
|
227
228
|
console.error(n), this.showAlert("danger", s.errors.signin);
|
|
228
229
|
return;
|
|
@@ -233,123 +234,123 @@ class V extends C {
|
|
|
233
234
|
const p = {
|
|
234
235
|
server: a.portalUrl,
|
|
235
236
|
userId: a.user,
|
|
236
|
-
token:
|
|
237
|
-
expires: Number(
|
|
237
|
+
token: o,
|
|
238
|
+
expires: Number(e.data.expires_in) + Date.now(),
|
|
238
239
|
ssl: c === void 0 || c !== "false"
|
|
239
240
|
};
|
|
240
241
|
f.registerToken(p);
|
|
241
|
-
const
|
|
242
|
+
const w = z({
|
|
242
243
|
account: h,
|
|
243
244
|
credential: p,
|
|
244
245
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
245
|
-
client_id:
|
|
246
|
+
client_id: t,
|
|
246
247
|
portal: u
|
|
247
248
|
});
|
|
248
|
-
window.self !== window.top ? window.top?.postMessage({ type: "navigate", url:
|
|
249
|
+
window.self !== window.top ? window.top?.postMessage({ type: "navigate", url: w }) : window.location.href = w;
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
|
-
handleCheckSignInStatusMessage(
|
|
252
|
-
const { success: s, orgKey:
|
|
253
|
-
|
|
252
|
+
handleCheckSignInStatusMessage(e) {
|
|
253
|
+
const { success: s, orgKey: t, server: n, userId: i, token: a, expires: o, ssl: c } = e.data;
|
|
254
|
+
t && n && s && i && a && o && c !== void 0 && (this.signedInStatus[i] = { token: a, expires: o, ssl: c });
|
|
254
255
|
}
|
|
255
|
-
async handleLinkUserMessage(
|
|
256
|
-
const { error: s, username:
|
|
256
|
+
async handleLinkUserMessage(e) {
|
|
257
|
+
const { error: s, username: t, access_token: n } = e.data, { portal: i, user: a, linkedAccounts: o, messages: c } = this;
|
|
257
258
|
if (s) {
|
|
258
259
|
if (s.toString().toLowerCase().includes("user denied your request"))
|
|
259
260
|
return;
|
|
260
261
|
this.showAlert("danger", c.errors.accessAccount);
|
|
261
262
|
return;
|
|
262
263
|
}
|
|
263
|
-
if (
|
|
264
|
+
if (t === a?.username) {
|
|
264
265
|
this.showAlert("danger", c.errors.selfLink);
|
|
265
266
|
return;
|
|
266
267
|
}
|
|
267
|
-
if (
|
|
268
|
-
this.showAlert("danger", m(c.errors.alreadyLinked, { username:
|
|
268
|
+
if (o.find((l) => l.username === t)) {
|
|
269
|
+
this.showAlert("danger", m(c.errors.alreadyLinked, { username: t }));
|
|
269
270
|
return;
|
|
270
271
|
}
|
|
271
|
-
const u = await K(i,
|
|
272
|
+
const u = await K(i, t, n);
|
|
272
273
|
if (u?.length) {
|
|
273
|
-
this.userAccounts = u, this.targetUser =
|
|
274
|
+
this.userAccounts = u, this.targetUser = t ?? "", this.targetToken = n ?? "", this.showAssociatedAccountsWarning = !0;
|
|
274
275
|
return;
|
|
275
276
|
}
|
|
276
|
-
this.linkAccount(
|
|
277
|
+
this.linkAccount(t, n);
|
|
277
278
|
}
|
|
278
|
-
handleExchangeTokenMessage(
|
|
279
|
-
const s = typeof
|
|
279
|
+
handleExchangeTokenMessage(e) {
|
|
280
|
+
const s = typeof e.data == "string" ? JSON.parse(e.data) : e.data;
|
|
280
281
|
if (!(s.type && s.type !== "token_exchange")) {
|
|
281
282
|
if (s.error)
|
|
282
283
|
console.error(s);
|
|
283
284
|
else if (s.status === "success" && this.targetUser) {
|
|
284
|
-
const { portal:
|
|
285
|
-
if (!
|
|
285
|
+
const { portal: t, linkedAccounts: n, targetUser: i, clientId: a } = this, o = n.find((p) => p.username === i);
|
|
286
|
+
if (!o)
|
|
286
287
|
return;
|
|
287
|
-
const c = O(
|
|
288
|
+
const c = O(o, t), u = g(o.orgUrlKey, t), l = new URLSearchParams({
|
|
288
289
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
289
290
|
response_type: "token",
|
|
290
291
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
291
292
|
client_id: a,
|
|
292
293
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
293
294
|
redirect_uri: c,
|
|
294
|
-
state: JSON.stringify({ user:
|
|
295
|
-
}), h = `${y(
|
|
295
|
+
state: JSON.stringify({ user: o.username, portalUrl: u })
|
|
296
|
+
}), h = `${y(o, t)}?${l.toString()}`;
|
|
296
297
|
window.opener ? (window.opener.location.href = h, window.close()) : window.location.href = h;
|
|
297
298
|
}
|
|
298
299
|
}
|
|
299
300
|
}
|
|
300
|
-
finishSignout({ accountOrigin:
|
|
301
|
-
this.signoutHandle && window.clearTimeout(this.signoutHandle), console.info("Signout complete",
|
|
301
|
+
finishSignout({ accountOrigin: e, redirectToClientUri: s, displaySignoutComplete: t }) {
|
|
302
|
+
this.signoutHandle && window.clearTimeout(this.signoutHandle), e === window.location.origin && f.destroyCredentials(), console.info("Signout complete", e, s, t), this.remainingSignouts <= 0 && this.arcgisSignoutComplete.emit({ accountOrigin: e, redirectToClientUri: s, displaySignoutComplete: t });
|
|
302
303
|
}
|
|
303
304
|
async findLinkedUsers() {
|
|
304
305
|
if (this.loading = !0, !this.portal || !this.user) {
|
|
305
306
|
this.linkedAccounts = [], this.loading = !1;
|
|
306
307
|
return;
|
|
307
308
|
}
|
|
308
|
-
this.linkedAccounts = await N(this.portal, this.user), this.linkedAccounts.length && (this.signedInStatus = this.linkedAccounts.filter((
|
|
309
|
+
this.linkedAccounts = await N(this.portal, this.user), this.linkedAccounts.length && (this.signedInStatus = this.linkedAccounts.filter((e) => e.orgUrlKey !== this.portal.urlKey).reduce((e, s) => (e[s.username] = Q(s, this.portal) ?? null, e), {}), this.accountAccess = q({ accounts: this.linkedAccounts, clientId: this.clientId })), this.loading = !1;
|
|
309
310
|
}
|
|
310
|
-
async linkAccount(
|
|
311
|
-
const { portal:
|
|
312
|
-
if (!
|
|
311
|
+
async linkAccount(e, s) {
|
|
312
|
+
const { portal: t, user: n } = this;
|
|
313
|
+
if (!t || !n)
|
|
313
314
|
return;
|
|
314
|
-
const i = await E({ portal:
|
|
315
|
+
const i = await E({ portal: t, user: n, targetUser: e, targetToken: s }), { messages: a } = this;
|
|
315
316
|
if (i.error) {
|
|
316
|
-
this.showAlert("danger", m(a.errors.linkAccount, { username:
|
|
317
|
+
this.showAlert("danger", m(a.errors.linkAccount, { username: e })), this.targetUser = "", this.userAccounts = [];
|
|
317
318
|
return;
|
|
318
319
|
}
|
|
319
|
-
const
|
|
320
|
-
this.showAlert("success", m(
|
|
320
|
+
const o = this.userAccounts?.length ? a.success.linkAccountMultiple : a.success.linkAccount;
|
|
321
|
+
this.showAlert("success", m(o, { username: e })), this.targetUser = "", this.userAccounts = [], await P(350), this.findLinkedUsers();
|
|
321
322
|
}
|
|
322
|
-
async unlinkAccount(
|
|
323
|
+
async unlinkAccount(e) {
|
|
323
324
|
if (!this.portal || !this.user)
|
|
324
325
|
return;
|
|
325
|
-
const { messages: s, portal:
|
|
326
|
-
i ? this.showAlert("success", m(s.success.unlinkAccount, { username:
|
|
326
|
+
const { messages: s, portal: t, user: n } = this, { success: i } = await H({ portal: t, user: n, linkedUsername: e.username });
|
|
327
|
+
i ? this.showAlert("success", m(s.success.unlinkAccount, { username: e.username })) : this.showAlert("danger", m(s.errors.unlinkAccount, { username: e.username })), await this.findLinkedUsers();
|
|
327
328
|
}
|
|
328
329
|
startAccountLink() {
|
|
329
|
-
|
|
330
|
+
D(this.portal);
|
|
330
331
|
}
|
|
331
|
-
switchAccount(
|
|
332
|
-
const { portal: s, user:
|
|
333
|
-
if (!s || !
|
|
332
|
+
switchAccount(e) {
|
|
333
|
+
const { portal: s, user: t, clientId: n } = this;
|
|
334
|
+
if (!s || !t || !e)
|
|
334
335
|
return;
|
|
335
|
-
const i = g(
|
|
336
|
-
a && A({ config: { baseUrl: i, restBaseUrl: `${i}/sharing/rest` }, token: a?.token, clientId: n }),
|
|
336
|
+
const i = g(t.sourceJSON.orgUrlKey ?? "", s), a = f.findCredential(i, t.id || t.username);
|
|
337
|
+
a && A({ config: { baseUrl: i, restBaseUrl: `${i}/sharing/rest` }, token: a?.token, clientId: n }), j(e, s, n);
|
|
337
338
|
}
|
|
338
|
-
signoutAll(
|
|
339
|
-
const { portal: s, signedInStatus:
|
|
340
|
-
|
|
341
|
-
const a = g(i.orgUrlKey, s),
|
|
342
|
-
A({ config: { baseUrl: a, restBaseUrl:
|
|
339
|
+
signoutAll(e) {
|
|
340
|
+
const { portal: s, signedInStatus: t, clientId: n } = this;
|
|
341
|
+
e.forEach((i) => {
|
|
342
|
+
const a = g(i.orgUrlKey, s), o = `${a}/sharing/rest`, c = t[i.username];
|
|
343
|
+
A({ config: { baseUrl: a, restBaseUrl: o }, token: c?.token, clientId: n });
|
|
343
344
|
});
|
|
344
345
|
}
|
|
345
|
-
showAlert(
|
|
346
|
+
showAlert(e, s, t) {
|
|
346
347
|
this.alertOptions = {
|
|
347
|
-
kind:
|
|
348
|
-
title:
|
|
348
|
+
kind: e,
|
|
349
|
+
title: t,
|
|
349
350
|
message: s
|
|
350
351
|
};
|
|
351
352
|
}
|
|
352
|
-
showUnlinkConfirmation(
|
|
353
|
+
showUnlinkConfirmation(e) {
|
|
353
354
|
const { messages: s } = this;
|
|
354
355
|
this.alertOptions = {
|
|
355
356
|
kind: "danger",
|
|
@@ -361,40 +362,40 @@ class V extends C {
|
|
|
361
362
|
text: s.unlink,
|
|
362
363
|
kind: "danger",
|
|
363
364
|
clickHandler: () => {
|
|
364
|
-
this.alertOptions = void 0, this.unlinkAccount(
|
|
365
|
+
this.alertOptions = void 0, this.unlinkAccount(e);
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
368
|
]
|
|
368
369
|
};
|
|
369
370
|
}
|
|
370
371
|
render() {
|
|
371
|
-
const { linkedAccounts:
|
|
372
|
-
if (!n || !
|
|
372
|
+
const { linkedAccounts: e, accountAccess: s, user: t, portal: n, messages: i, signout: a } = this;
|
|
373
|
+
if (!n || !t)
|
|
373
374
|
return null;
|
|
374
375
|
if (a) {
|
|
375
|
-
const { signedInAccounts:
|
|
376
|
-
return
|
|
376
|
+
const { signedInAccounts: o } = this;
|
|
377
|
+
return o.length === 0 ? d`<calcite-loader .label=${i.signingOut} .text=${i.signingOut}></calcite-loader>` : d`<arcgis-portal-account-switcher-signout .portal=${n} .signedInAccounts=${o} @arcgisSwitchAccount=${(c) => {
|
|
377
378
|
this.switchAccount(c.detail.account);
|
|
378
379
|
}} @arcgisSignOutAll=${() => {
|
|
379
|
-
this.signoutAll(
|
|
380
|
+
this.signoutAll(o);
|
|
380
381
|
}}></arcgis-portal-account-switcher-signout>`;
|
|
381
382
|
}
|
|
382
|
-
return d`<calcite-dialog .heading=${i.switchAccounts} scale=m width=s open modal .loading=${this.loading} outside-close-disabled @calciteDialogClose=${() => {
|
|
383
|
+
return d`<calcite-dialog .heading=${i.switchAccounts} heading-level=2 scale=m width=s open modal .loading=${this.loading} outside-close-disabled @calciteDialogClose=${() => {
|
|
383
384
|
this.arcgisClose.emit();
|
|
384
|
-
}}><calcite-block .heading=${i.currentAccount} .description=${i.signedInAs} expanded class="current-account-block" tabindex=-1>${_(
|
|
385
|
-
this.switchAccount(
|
|
386
|
-
}} @arcgisAccountUnlink=${(
|
|
387
|
-
this.showUnlinkConfirmation(
|
|
388
|
-
}}></arcgis-portal-account-switcher-list></calcite-block>` : d`<calcite-block .heading=${i.linkedAccounts} expanded class="empty-accounts-block"><div class="empty-accounts-info"><svg class="empty-accounts-icon" width=48 height=48 viewBox="0 0 48 48" fill=none xmlns=http://www.w3.org/2000/svg>${T`<path d=${B.couple ??
|
|
385
|
+
}}><calcite-block .heading=${i.currentAccount} heading-level=3 .description=${i.signedInAs} expanded class="current-account-block" tabindex=-1>${_(t.id ?? t.username, d`<calcite-block class="current-account" .label=${n.urlKey ? `${t.username}, ${n.name}` : t.username} heading-level=4 .heading=${t.username} .description=${n.urlKey ? `${t.fullName ?? t.username}, ${n.name}` : t.fullName ?? t.username}><calcite-avatar slot=content-start inert .fullName=${t.fullName ?? void 0} .username=${t.username} .userId=${t.id} .thumbnail=${R(t, n) ?? void 0}></calcite-avatar></calcite-block>`)}</calcite-block>${e.length > 0 ? d`<calcite-block .heading=${i.linkedAccounts} heading-level=3 .description=${i.linkedAccountActions} expanded class="linked-accounts-block"><calcite-button slot=content-end icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${e.length >= $}>${i.addAccount}</calcite-button><arcgis-portal-account-switcher-list .portal=${n} .linkedAccounts=${e} .accountAccess=${s} .signedInUsers=${Object.keys(this.signedInStatus).filter((o) => this.signedInStatus[o] !== null)} interactive @arcgisAccountSwitch=${(o) => {
|
|
386
|
+
this.switchAccount(o.detail.account);
|
|
387
|
+
}} @arcgisAccountUnlink=${(o) => {
|
|
388
|
+
this.showUnlinkConfirmation(o.detail.account);
|
|
389
|
+
}}></arcgis-portal-account-switcher-list></calcite-block>` : d`<calcite-block .heading=${i.linkedAccounts} heading-level=3 expanded class="empty-accounts-block"><div class="empty-accounts-info"><svg class="empty-accounts-icon" width=48 height=48 viewBox="0 0 48 48" fill=none xmlns=http://www.w3.org/2000/svg>${T`<path d=${B.couple ?? x} fill=currentColor />`}</svg><h4>${i.emptyListTitle}</h4><p>${i.emptyList}</p><calcite-button icon-start=plus class="link-account-button" @click=${() => this.startAccountLink()} .disabled=${e.length >= $}>${i.linkAccount}</calcite-button></div></calcite-block>`}<calcite-notice kind=info .open=${e.length >= $}><div slot=message>${i.maxAccounts}</div></calcite-notice><calcite-alert .label=${i.alertLabel} slot=alerts .autoClose=${this.alertOptions?.kind !== "danger"} auto-close-duration=fast placement=bottom .kind=${this.alertOptions?.kind} .icon=${this.alertOptions?.icon} .open=${!!this.alertOptions} @calciteAlertClose=${() => {
|
|
389
390
|
this.alertOptions = void 0;
|
|
390
|
-
}}>${this.alertOptions?.title && d`<h4 slot=title class="alert-title">${this.alertOptions.title}</h4>` || ""}${this.alertOptions?.message && d`<p slot=message class=${
|
|
391
|
+
}}>${this.alertOptions?.title && d`<h4 slot=title class="alert-title">${this.alertOptions.title}</h4>` || ""}${this.alertOptions?.message && d`<p slot=message class=${v({ "alert-message": !0, "short-message": !!this.alertOptions?.actions?.length })}>${this.alertOptions.message}</p>` || ""}${this.alertOptions?.actions?.map((o) => d`<calcite-button slot=actions-end .kind=${o.kind} .appearance=${o.appearance} @click=${o.clickHandler}>${o.text}</calcite-button>`)}</calcite-alert></calcite-dialog>${this.showAssociatedAccountsWarning && d`<arcgis-portal-account-switcher-accounts .portal=${n} .targetUser=${this.targetUser} .accounts=${this.userAccounts ?? []} @arcgisLinkAll=${() => {
|
|
391
392
|
this.linkAccount(this.targetUser, this.targetToken);
|
|
392
393
|
}} @arcgisCloseDialog=${() => {
|
|
393
394
|
this.showAssociatedAccountsWarning = !1;
|
|
394
395
|
}}></arcgis-portal-account-switcher-accounts>` || ""}`;
|
|
395
396
|
}
|
|
396
397
|
}
|
|
397
|
-
L("arcgis-portal-account-switcher",
|
|
398
|
+
L("arcgis-portal-account-switcher", X);
|
|
398
399
|
export {
|
|
399
|
-
|
|
400
|
+
X as ArcgisPortalAccountSwitcher
|
|
400
401
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { html as
|
|
2
|
+
import { c as a } from "../../chunks/runtime.js";
|
|
3
|
+
import { html as o } from "lit";
|
|
4
4
|
import { LitElement as l, createEvent as e } from "@arcgis/lumina";
|
|
5
5
|
import { createRef as r, ref as n } from "lit/directives/ref.js";
|
|
6
6
|
import { u } from "../../chunks/useT9n.js";
|
|
7
7
|
import { s as g } from "../../chunks/portal-account-switcher.js";
|
|
8
8
|
import { substitute as m } from "@arcgis/core/intl.js";
|
|
9
|
-
class
|
|
9
|
+
class d extends l {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments), this.messages = u({ blocking: !0, name: "portal-account-switcher" }), this.dialogRef = r(), this.accounts = [], this.arcgisLinkAll = e(), this.arcgisCloseDialog = e();
|
|
12
12
|
}
|
|
@@ -18,14 +18,14 @@ class p extends l {
|
|
|
18
18
|
}
|
|
19
19
|
render() {
|
|
20
20
|
const { messages: t, portal: i, accounts: c, targetUser: s } = this;
|
|
21
|
-
return
|
|
21
|
+
return o`<calcite-dialog open modal width=s .heading=${t.linkTitle} heading-level=2 outside-close-disabled @calciteDialogClose=${() => this.arcgisCloseDialog.emit()} ${n(this.dialogRef)}><calcite-block .heading=${m(t.linkWarning, { targetUser: s })} expanded class="linked-accounts-block"><arcgis-portal-account-switcher-list .portal=${i} .linkedAccounts=${c}></arcgis-portal-account-switcher-list></calcite-block><calcite-button slot=footer-end appearance=outline @click=${() => {
|
|
22
22
|
this.dialogRef.value.open = !1;
|
|
23
23
|
}}>${t.cancel}</calcite-button><calcite-button slot=footer-end kind=brand @click=${() => {
|
|
24
24
|
this.arcgisLinkAll.emit(), this.dialogRef.value.open = !1;
|
|
25
25
|
}}>${t.linkAll}</calcite-button></calcite-dialog>`;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
a("arcgis-portal-account-switcher-accounts", d);
|
|
29
29
|
export {
|
|
30
|
-
|
|
30
|
+
d as ArcgisPortalAccountSwitcherAccounts
|
|
31
31
|
};
|
|
@@ -2,13 +2,13 @@ import "@esri/calcite-components/components/calcite-chip";
|
|
|
2
2
|
import "@esri/calcite-components/components/calcite-tooltip";
|
|
3
3
|
import "@esri/calcite-components/components/calcite-list-item";
|
|
4
4
|
import "@esri/calcite-components/components/calcite-action";
|
|
5
|
+
import "@esri/calcite-components/components/calcite-dropdown-item";
|
|
5
6
|
import "@esri/calcite-components/components/calcite-icon";
|
|
6
7
|
import "@esri/calcite-components/components/calcite-popover";
|
|
7
8
|
import "@esri/calcite-components/components/calcite-list";
|
|
8
9
|
import "../arcgis-portal-item-type/index.js";
|
|
9
10
|
import "@esri/calcite-components/components/calcite-loader";
|
|
10
11
|
import "@esri/calcite-components/components/calcite-button";
|
|
11
|
-
import "@esri/calcite-components/components/calcite-dropdown-item";
|
|
12
12
|
import "@esri/calcite-components/components/calcite-input";
|
|
13
13
|
import "@esri/calcite-components/components/calcite-dropdown";
|
|
14
14
|
import "../arcgis-portal-user-avatar/index.js";
|