@postnord/pn-marketweb-components 2.0.41 → 2.0.45
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/cjs/{MarketWebLoginManager-865226ea.js → MarketWebLoginManager-9836a350.js} +13 -1
- package/cjs/pn-language-selector_9.cjs.entry.js +1 -1
- package/cjs/pn-marketweb-siteheader-login-links_2.cjs.entry.js +2 -4
- package/cjs/pn-marketweb-siteheader.cjs.entry.js +1 -1
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-profileselection.js +1 -6
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.stories.js +160 -1
- package/collection/globals/MarketWebLoginManager.js +13 -1
- package/custom-elements/index.js +15 -5
- package/esm/{MarketWebLoginManager-8fef95d2.js → MarketWebLoginManager-b8b046d3.js} +13 -1
- package/esm/pn-language-selector_9.entry.js +1 -1
- package/esm/pn-marketweb-siteheader-login-links_2.entry.js +2 -4
- package/esm/pn-marketweb-siteheader.entry.js +1 -1
- package/esm-es5/{MarketWebLoginManager-8fef95d2.js → MarketWebLoginManager-b8b046d3.js} +1 -1
- package/esm-es5/pn-language-selector_9.entry.js +1 -1
- package/esm-es5/pn-marketweb-siteheader-login-links_2.entry.js +1 -1
- package/esm-es5/pn-marketweb-siteheader.entry.js +1 -1
- package/package.json +1 -1
- package/pn-market-web-components/{p-8a269121.system.js → p-01e01d7d.system.js} +1 -1
- package/pn-market-web-components/{p-edd42748.entry.js → p-066e5f4c.entry.js} +1 -1
- package/pn-market-web-components/{p-042c2c02.system.entry.js → p-4784031f.system.entry.js} +1 -1
- package/pn-market-web-components/p-67887512.system.js +1 -1
- package/pn-market-web-components/{p-680fc0be.system.entry.js → p-974798a6.system.entry.js} +1 -1
- package/pn-market-web-components/{p-8af5b371.entry.js → p-a31a27bc.entry.js} +1 -1
- package/pn-market-web-components/{p-424fac62.js → p-b0ec61db.js} +1 -1
- package/pn-market-web-components/{p-949a287e.system.entry.js → p-b36c04ec.system.entry.js} +1 -1
- package/pn-market-web-components/{p-361afc38.entry.js → p-e7f57dce.entry.js} +1 -1
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/umd/pn-marketweb-salesforce.js +5 -13
- package/umd/pn-marketweb-wrongrembase.css +154 -0
|
@@ -165,10 +165,15 @@ class MarketWebLoginManager {
|
|
|
165
165
|
};
|
|
166
166
|
const response = await fetch(`${this.getBaseUrl()}${this.endpoints.userInfoEndpoint}`, reqConfig);
|
|
167
167
|
const data = await response.json();
|
|
168
|
-
if (data) {
|
|
168
|
+
if (data && data["idToken"]) {
|
|
169
169
|
try {
|
|
170
170
|
const { idToken, expiryTime } = data;
|
|
171
171
|
const userInfo = this.parseUserInfo(idToken);
|
|
172
|
+
if (!userInfo) {
|
|
173
|
+
console.error('Userdata is not valid');
|
|
174
|
+
this.clearUserData();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
172
177
|
this.store.set(this.keys.user, userInfo);
|
|
173
178
|
// 10 Min early expire
|
|
174
179
|
this.store.set(this.keys.expire, expiryTime);
|
|
@@ -179,6 +184,10 @@ class MarketWebLoginManager {
|
|
|
179
184
|
console.error('Unable to get user information', e);
|
|
180
185
|
}
|
|
181
186
|
}
|
|
187
|
+
else {
|
|
188
|
+
console.error('Unable to get user information. Clearing login state');
|
|
189
|
+
this.clearUserData();
|
|
190
|
+
}
|
|
182
191
|
}
|
|
183
192
|
clearUserData() {
|
|
184
193
|
this.store.remove(this.keys.user);
|
|
@@ -216,6 +225,9 @@ class MarketWebLoginManager {
|
|
|
216
225
|
return this.baseUrls.prod;
|
|
217
226
|
}
|
|
218
227
|
parseUserInfo(idToken) {
|
|
228
|
+
if (!idToken) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
219
231
|
var base64Url = idToken.split('.')[1];
|
|
220
232
|
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
221
233
|
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-e3e27c79.js');
|
|
6
6
|
const pnMainnavStore = require('./pn-mainnav-store-61a75ea0.js');
|
|
7
|
-
const MarketWebLoginManager = require('./MarketWebLoginManager-
|
|
7
|
+
const MarketWebLoginManager = require('./MarketWebLoginManager-9836a350.js');
|
|
8
8
|
const index$1 = require('./index-28bbc937.js');
|
|
9
9
|
|
|
10
10
|
const translations$1 = {
|
|
@@ -235,13 +235,11 @@ let PnMarketwebSiteheaderLoginProfileselection = class {
|
|
|
235
235
|
let hostElementAttribute = {};
|
|
236
236
|
return (index.h(index.Host, Object.assign({}, hostElementAttribute), this.heading ? index.h("strong", { class: "pn-marketweb-siteheader-login-profileselection-heading" }, this.heading) : null, index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-user" }, index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-name" }, this.userName), ((this.user && this.user.username) && this.userName !== this.user.username) ?
|
|
237
237
|
index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-description" }, this.user.username)
|
|
238
|
-
: null), this.
|
|
239
|
-
index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile" }, index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-name" }, this.currentProfile.name), index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-description" }, this.currentProfile.customerNumber))
|
|
240
|
-
: null, index.h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks.filter(x => x.isLogoutLink === false), loginManager: this.loginManager, idNamespace: this.idNamespace }), index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }), this.organizations.filter(x => x.selected !== true).map((organization) => {
|
|
238
|
+
: null), index.h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks.filter(x => x.isLogoutLink === false), loginManager: this.loginManager, idNamespace: this.idNamespace }), index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }), this.organizations.filter(x => x.selected !== true).map((organization) => {
|
|
241
239
|
let customerNumber = (organization.profiles.length > 0) ? organization.profiles[0].customerNumber : organization.customerNumber;
|
|
242
240
|
return (index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption" }, index.h("a", { href: `${this.endpoint}/api/user/setprofile?customernumber=${customerNumber}&returnUrl=${window.location.href}`, class: "pn-marketweb-siteheader-login-profileselection-profileoption-link" }, index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-content" }, index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-name" }, organization.name), index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-description" }, organization.customerNumber)), index.h("pn-icon", { symbol: "arrow-right", small: "false", color: "blue700" }))));
|
|
243
241
|
}), this.logoutLink ?
|
|
244
|
-
index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" }, index.h("a", { href: this.logoutLink.href, rel: "nofollower noopener", class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
|
|
242
|
+
index.h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" }, index.h("a", { href: this.logoutLink.href, rel: "nofollower noopener", onClick: () => this.loginManager.clearUserData(), class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
|
|
245
243
|
: null));
|
|
246
244
|
}
|
|
247
245
|
get hostElement() { return index.getElement(this); }
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-e3e27c79.js');
|
|
6
6
|
const FetchHelper = require('./FetchHelper-c6cee722.js');
|
|
7
|
-
const MarketWebLoginManager = require('./MarketWebLoginManager-
|
|
7
|
+
const MarketWebLoginManager = require('./MarketWebLoginManager-9836a350.js');
|
|
8
8
|
|
|
9
9
|
const translations = {
|
|
10
10
|
'sv': {
|
|
@@ -137,11 +137,6 @@ export class PnMarketwebSiteheaderLoginProfileselection {
|
|
|
137
137
|
((this.user && this.user.username) && this.userName !== this.user.username) ?
|
|
138
138
|
h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-description" }, this.user.username)
|
|
139
139
|
: null),
|
|
140
|
-
this.currentProfile !== null && this.currentProfile.name ?
|
|
141
|
-
h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile" },
|
|
142
|
-
h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-name" }, this.currentProfile.name),
|
|
143
|
-
h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-description" }, this.currentProfile.customerNumber))
|
|
144
|
-
: null,
|
|
145
140
|
h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks.filter(x => x.isLogoutLink === false), loginManager: this.loginManager, idNamespace: this.idNamespace }),
|
|
146
141
|
h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }),
|
|
147
142
|
this.organizations.filter(x => x.selected !== true).map((organization) => {
|
|
@@ -155,7 +150,7 @@ export class PnMarketwebSiteheaderLoginProfileselection {
|
|
|
155
150
|
}),
|
|
156
151
|
this.logoutLink ?
|
|
157
152
|
h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" },
|
|
158
|
-
h("a", { href: this.logoutLink.href, rel: "nofollower noopener", class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
|
|
153
|
+
h("a", { href: this.logoutLink.href, rel: "nofollower noopener", onClick: () => this.loginManager.clearUserData(), class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
|
|
159
154
|
: null));
|
|
160
155
|
}
|
|
161
156
|
static get is() { return "pn-marketweb-siteheader-login-profileselection"; }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import readme from "./readme.md";
|
|
2
2
|
|
|
3
|
-
const usertoken = '
|
|
3
|
+
const usertoken = 'c6ef1d2fd42311586015b8a342e4a19b659a7fd34c50aa93b538589';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
title: "Web Components/Market web site Header",
|
|
@@ -43,6 +43,165 @@ export default {
|
|
|
43
43
|
|
|
44
44
|
const PrimaryTemplate = ({ ...args }) => {
|
|
45
45
|
return `
|
|
46
|
+
<style>
|
|
47
|
+
:root {
|
|
48
|
+
font-size: 100%;
|
|
49
|
+
}
|
|
50
|
+
pn-marketweb-siteheader {
|
|
51
|
+
font-size:16px;
|
|
52
|
+
}
|
|
53
|
+
pn-marketweb-siteheader header {
|
|
54
|
+
box-shadow:0 0.6px 1.8px rgb(0 0 0 / 10%), 0 3.2px 7.2px rgb(0 0 0 / 13%)
|
|
55
|
+
}
|
|
56
|
+
pn-marketweb-siteheader .siteheader-row {
|
|
57
|
+
padding:0 16px;
|
|
58
|
+
}
|
|
59
|
+
pn-marketweb-siteheader .siteheader-row:not(:last-child) {
|
|
60
|
+
border-bottom:0.1px solid #F3F2F2;
|
|
61
|
+
}
|
|
62
|
+
.siteheader-topleft pn-site-selector {
|
|
63
|
+
padding:10px 0;
|
|
64
|
+
}
|
|
65
|
+
pn-site-selector {
|
|
66
|
+
max-height:52px;
|
|
67
|
+
}
|
|
68
|
+
.siteheader-topleft pn-site-selector {
|
|
69
|
+
margin-left:13px;
|
|
70
|
+
}
|
|
71
|
+
pn-nav-dropdown>button {
|
|
72
|
+
padding:4px;
|
|
73
|
+
border-radius:8px;
|
|
74
|
+
}
|
|
75
|
+
.nav-dropdown-content-container {
|
|
76
|
+
border-radius:16px;
|
|
77
|
+
box-shadow:0 2px 16rem rgb(0 0 0 / 20%);
|
|
78
|
+
}
|
|
79
|
+
.nav-dropdown-content {
|
|
80
|
+
padding:16px;
|
|
81
|
+
}
|
|
82
|
+
.siteselector-heading {
|
|
83
|
+
margin-bottom:16px;
|
|
84
|
+
}
|
|
85
|
+
pn-site-selector-item>div, pn-site-selector-item>a {
|
|
86
|
+
padding:8px 0;
|
|
87
|
+
}
|
|
88
|
+
pn-marketweb-siteheader .siteheader-logocontainer {
|
|
89
|
+
min-height:48px;
|
|
90
|
+
}
|
|
91
|
+
pn-marketweb-siteheader .siteheader-logolink {
|
|
92
|
+
max-height:64px;
|
|
93
|
+
}
|
|
94
|
+
pn-marketweb-siteheader .siteheader-logolink svg {
|
|
95
|
+
width:127px;
|
|
96
|
+
height:24px;
|
|
97
|
+
}
|
|
98
|
+
.siteheader-topright {
|
|
99
|
+
margin-left:16px;
|
|
100
|
+
}
|
|
101
|
+
.siteheader-topright>pn-language-selector, .siteheader-topright>pn-marketweb-siteheader-login, .siteheader-topright>a {
|
|
102
|
+
padding:10px 0;
|
|
103
|
+
}
|
|
104
|
+
@media screen and (min-width: 60em) {
|
|
105
|
+
.siteheader-topright>pn-language-selector, .siteheader-topright>pn-marketweb-siteheader-login, .siteheader-topright>a {
|
|
106
|
+
margin-left:16px;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
pn-marketweb-siteheader-login {
|
|
111
|
+
padding:10px 0;
|
|
112
|
+
max-height:52px;
|
|
113
|
+
}
|
|
114
|
+
pn-mainnav {
|
|
115
|
+
min-height:51px;
|
|
116
|
+
}
|
|
117
|
+
@media screen and (min-width: 48em) {
|
|
118
|
+
pn-mainnav>nav {
|
|
119
|
+
top: 65px;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
pn-mainnav>nav {
|
|
123
|
+
top:48px;
|
|
124
|
+
}
|
|
125
|
+
[data-level="1"] pn-mainnav-link>button, [data-level="1"] pn-mainnav-link>a {
|
|
126
|
+
border-bottom:1px solid #F3F2F2;
|
|
127
|
+
font-size:20px;
|
|
128
|
+
padding:19px 0 19px 30px;
|
|
129
|
+
}
|
|
130
|
+
@media screen and (min-width: 64em) {
|
|
131
|
+
[data-level="1"] pn-mainnav-link>button, [data-level="1"] pn-mainnav-link>a {
|
|
132
|
+
font-size:16px;
|
|
133
|
+
padding:16px;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@media screen and (min-width: 64em) {
|
|
138
|
+
[data-level="1"] pn-mainnav-link>button::before, [data-level="1"] pn-mainnav-link>a::before {
|
|
139
|
+
height:10px;
|
|
140
|
+
border-radius:10px 10px 0 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
@media screen and (min-width: 64em) {
|
|
144
|
+
pn-mainnav-level[data-level="2"][aria-hidden=false]:not([data-level-listcount="1"]) {
|
|
145
|
+
grid-template-columns: minmax(192px, 320px) 1fr;
|
|
146
|
+
gap: 0px 16px;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
@media screen and (min-width: 64em) {
|
|
150
|
+
pn-mainnav-level[data-level="2"] {
|
|
151
|
+
top:calc(100% + 10px);
|
|
152
|
+
border-radius:16px;
|
|
153
|
+
padding:16px 16px 0 16px;
|
|
154
|
+
box-shadow:0 0.6px 1.8px rgb(0 0 0 / 10%), 0 3.2px 7.2px rgb(0 0 0 / 13%);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
.mainnav-level-header>button {
|
|
158
|
+
padding:24px 0 24px 62px;
|
|
159
|
+
}
|
|
160
|
+
.mainnav-level-header>button>pn-icon {
|
|
161
|
+
height:24px;
|
|
162
|
+
width:24px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@media screen and (min-width: 64em) {
|
|
166
|
+
[data-level="2"] pn-mainnav-link {
|
|
167
|
+
margin-bottom:16px;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
[data-level="2"] .mainnav-level-header>pn-mainnav-link>a {
|
|
171
|
+
font-size:24px;
|
|
172
|
+
}
|
|
173
|
+
[data-level="2"] pn-mainnav-link>a {
|
|
174
|
+
font-size: 16px;
|
|
175
|
+
border-bottom: 1px solid #F3F2F2;
|
|
176
|
+
padding: 22px 0 22px 30px;
|
|
177
|
+
}
|
|
178
|
+
@media screen and (min-width: 64em) {
|
|
179
|
+
[data-level="2"] pn-mainnav-link>a {
|
|
180
|
+
min-width:256px;
|
|
181
|
+
border-radius:10px;
|
|
182
|
+
padding:14px 16px;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@media screen and (min-width: 64em) {
|
|
187
|
+
[data-level="2"]>pn-mainnav-list[data-navlist-showcolumns=true] {
|
|
188
|
+
column-gap: 16px;
|
|
189
|
+
padding-bottom: 16px;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.mainnav-list-heading {
|
|
194
|
+
font-size: 18px;
|
|
195
|
+
padding: 14px 14px 14px 48px;
|
|
196
|
+
}
|
|
197
|
+
@media screen and (min-width: 64em) {
|
|
198
|
+
.mainnav-list-heading {
|
|
199
|
+
padding:0 14px 14px 14px;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
</style>
|
|
204
|
+
|
|
46
205
|
<div style="background:#ddd;min-height:100vh;">
|
|
47
206
|
<pn-marketweb-siteheader
|
|
48
207
|
market="${ args.market }"
|
|
@@ -163,10 +163,15 @@ class MarketWebLoginManager {
|
|
|
163
163
|
};
|
|
164
164
|
const response = await fetch(`${this.getBaseUrl()}${this.endpoints.userInfoEndpoint}`, reqConfig);
|
|
165
165
|
const data = await response.json();
|
|
166
|
-
if (data) {
|
|
166
|
+
if (data && data["idToken"]) {
|
|
167
167
|
try {
|
|
168
168
|
const { idToken, expiryTime } = data;
|
|
169
169
|
const userInfo = this.parseUserInfo(idToken);
|
|
170
|
+
if (!userInfo) {
|
|
171
|
+
console.error('Userdata is not valid');
|
|
172
|
+
this.clearUserData();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
170
175
|
this.store.set(this.keys.user, userInfo);
|
|
171
176
|
// 10 Min early expire
|
|
172
177
|
this.store.set(this.keys.expire, expiryTime);
|
|
@@ -177,6 +182,10 @@ class MarketWebLoginManager {
|
|
|
177
182
|
console.error('Unable to get user information', e);
|
|
178
183
|
}
|
|
179
184
|
}
|
|
185
|
+
else {
|
|
186
|
+
console.error('Unable to get user information. Clearing login state');
|
|
187
|
+
this.clearUserData();
|
|
188
|
+
}
|
|
180
189
|
}
|
|
181
190
|
clearUserData() {
|
|
182
191
|
this.store.remove(this.keys.user);
|
|
@@ -214,6 +223,9 @@ class MarketWebLoginManager {
|
|
|
214
223
|
return this.baseUrls.prod;
|
|
215
224
|
}
|
|
216
225
|
parseUserInfo(idToken) {
|
|
226
|
+
if (!idToken) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
217
229
|
var base64Url = idToken.split('.')[1];
|
|
218
230
|
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
219
231
|
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
|
package/custom-elements/index.js
CHANGED
|
@@ -4270,10 +4270,15 @@ class MarketWebLoginManager {
|
|
|
4270
4270
|
};
|
|
4271
4271
|
const response = await fetch(`${this.getBaseUrl()}${this.endpoints.userInfoEndpoint}`, reqConfig);
|
|
4272
4272
|
const data = await response.json();
|
|
4273
|
-
if (data) {
|
|
4273
|
+
if (data && data["idToken"]) {
|
|
4274
4274
|
try {
|
|
4275
4275
|
const { idToken, expiryTime } = data;
|
|
4276
4276
|
const userInfo = this.parseUserInfo(idToken);
|
|
4277
|
+
if (!userInfo) {
|
|
4278
|
+
console.error('Userdata is not valid');
|
|
4279
|
+
this.clearUserData();
|
|
4280
|
+
return;
|
|
4281
|
+
}
|
|
4277
4282
|
this.store.set(this.keys.user, userInfo);
|
|
4278
4283
|
// 10 Min early expire
|
|
4279
4284
|
this.store.set(this.keys.expire, expiryTime);
|
|
@@ -4284,6 +4289,10 @@ class MarketWebLoginManager {
|
|
|
4284
4289
|
console.error('Unable to get user information', e);
|
|
4285
4290
|
}
|
|
4286
4291
|
}
|
|
4292
|
+
else {
|
|
4293
|
+
console.error('Unable to get user information. Clearing login state');
|
|
4294
|
+
this.clearUserData();
|
|
4295
|
+
}
|
|
4287
4296
|
}
|
|
4288
4297
|
clearUserData() {
|
|
4289
4298
|
this.store.remove(this.keys.user);
|
|
@@ -4321,6 +4330,9 @@ class MarketWebLoginManager {
|
|
|
4321
4330
|
return this.baseUrls.prod;
|
|
4322
4331
|
}
|
|
4323
4332
|
parseUserInfo(idToken) {
|
|
4333
|
+
if (!idToken) {
|
|
4334
|
+
return null;
|
|
4335
|
+
}
|
|
4324
4336
|
var base64Url = idToken.split('.')[1];
|
|
4325
4337
|
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
4326
4338
|
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
|
|
@@ -5053,13 +5065,11 @@ let PnMarketwebSiteheaderLoginProfileselection$1 = class extends HTMLElement {
|
|
|
5053
5065
|
let hostElementAttribute = {};
|
|
5054
5066
|
return (h(Host, Object.assign({}, hostElementAttribute), this.heading ? h("strong", { class: "pn-marketweb-siteheader-login-profileselection-heading" }, this.heading) : null, h("div", { class: "pn-marketweb-siteheader-login-profileselection-user" }, h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-name" }, this.userName), ((this.user && this.user.username) && this.userName !== this.user.username) ?
|
|
5055
5067
|
h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-description" }, this.user.username)
|
|
5056
|
-
: null), this.
|
|
5057
|
-
h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile" }, h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-name" }, this.currentProfile.name), h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-description" }, this.currentProfile.customerNumber))
|
|
5058
|
-
: null, h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks.filter(x => x.isLogoutLink === false), loginManager: this.loginManager, idNamespace: this.idNamespace }), h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }), this.organizations.filter(x => x.selected !== true).map((organization) => {
|
|
5068
|
+
: null), h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks.filter(x => x.isLogoutLink === false), loginManager: this.loginManager, idNamespace: this.idNamespace }), h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }), this.organizations.filter(x => x.selected !== true).map((organization) => {
|
|
5059
5069
|
let customerNumber = (organization.profiles.length > 0) ? organization.profiles[0].customerNumber : organization.customerNumber;
|
|
5060
5070
|
return (h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption" }, h("a", { href: `${this.endpoint}/api/user/setprofile?customernumber=${customerNumber}&returnUrl=${window.location.href}`, class: "pn-marketweb-siteheader-login-profileselection-profileoption-link" }, h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-content" }, h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-name" }, organization.name), h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-description" }, organization.customerNumber)), h("pn-icon", { symbol: "arrow-right", small: "false", color: "blue700" }))));
|
|
5061
5071
|
}), this.logoutLink ?
|
|
5062
|
-
h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" }, h("a", { href: this.logoutLink.href, rel: "nofollower noopener", class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
|
|
5072
|
+
h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" }, h("a", { href: this.logoutLink.href, rel: "nofollower noopener", onClick: () => this.loginManager.clearUserData(), class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
|
|
5063
5073
|
: null));
|
|
5064
5074
|
}
|
|
5065
5075
|
get hostElement() { return this; }
|
|
@@ -163,10 +163,15 @@ class MarketWebLoginManager {
|
|
|
163
163
|
};
|
|
164
164
|
const response = await fetch(`${this.getBaseUrl()}${this.endpoints.userInfoEndpoint}`, reqConfig);
|
|
165
165
|
const data = await response.json();
|
|
166
|
-
if (data) {
|
|
166
|
+
if (data && data["idToken"]) {
|
|
167
167
|
try {
|
|
168
168
|
const { idToken, expiryTime } = data;
|
|
169
169
|
const userInfo = this.parseUserInfo(idToken);
|
|
170
|
+
if (!userInfo) {
|
|
171
|
+
console.error('Userdata is not valid');
|
|
172
|
+
this.clearUserData();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
170
175
|
this.store.set(this.keys.user, userInfo);
|
|
171
176
|
// 10 Min early expire
|
|
172
177
|
this.store.set(this.keys.expire, expiryTime);
|
|
@@ -177,6 +182,10 @@ class MarketWebLoginManager {
|
|
|
177
182
|
console.error('Unable to get user information', e);
|
|
178
183
|
}
|
|
179
184
|
}
|
|
185
|
+
else {
|
|
186
|
+
console.error('Unable to get user information. Clearing login state');
|
|
187
|
+
this.clearUserData();
|
|
188
|
+
}
|
|
180
189
|
}
|
|
181
190
|
clearUserData() {
|
|
182
191
|
this.store.remove(this.keys.user);
|
|
@@ -214,6 +223,9 @@ class MarketWebLoginManager {
|
|
|
214
223
|
return this.baseUrls.prod;
|
|
215
224
|
}
|
|
216
225
|
parseUserInfo(idToken) {
|
|
226
|
+
if (!idToken) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
217
229
|
var base64Url = idToken.split('.')[1];
|
|
218
230
|
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
|
219
231
|
var jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, e as createEvent, h, a as Host, g as getElement } from './index-5397620b.js';
|
|
2
2
|
import { s as state$1, o as onChange$1 } from './pn-mainnav-store-28571e54.js';
|
|
3
|
-
import { M as MarketWebLoginManager } from './MarketWebLoginManager-
|
|
3
|
+
import { M as MarketWebLoginManager } from './MarketWebLoginManager-b8b046d3.js';
|
|
4
4
|
import { c as createStore } from './index-7b21ecff.js';
|
|
5
5
|
|
|
6
6
|
const translations$1 = {
|
|
@@ -231,13 +231,11 @@ let PnMarketwebSiteheaderLoginProfileselection = class {
|
|
|
231
231
|
let hostElementAttribute = {};
|
|
232
232
|
return (h(Host, Object.assign({}, hostElementAttribute), this.heading ? h("strong", { class: "pn-marketweb-siteheader-login-profileselection-heading" }, this.heading) : null, h("div", { class: "pn-marketweb-siteheader-login-profileselection-user" }, h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-name" }, this.userName), ((this.user && this.user.username) && this.userName !== this.user.username) ?
|
|
233
233
|
h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-description" }, this.user.username)
|
|
234
|
-
: null), this.
|
|
235
|
-
h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile" }, h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-name" }, this.currentProfile.name), h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-description" }, this.currentProfile.customerNumber))
|
|
236
|
-
: null, h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks.filter(x => x.isLogoutLink === false), loginManager: this.loginManager, idNamespace: this.idNamespace }), h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }), this.organizations.filter(x => x.selected !== true).map((organization) => {
|
|
234
|
+
: null), h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks.filter(x => x.isLogoutLink === false), loginManager: this.loginManager, idNamespace: this.idNamespace }), h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }), this.organizations.filter(x => x.selected !== true).map((organization) => {
|
|
237
235
|
let customerNumber = (organization.profiles.length > 0) ? organization.profiles[0].customerNumber : organization.customerNumber;
|
|
238
236
|
return (h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption" }, h("a", { href: `${this.endpoint}/api/user/setprofile?customernumber=${customerNumber}&returnUrl=${window.location.href}`, class: "pn-marketweb-siteheader-login-profileselection-profileoption-link" }, h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-content" }, h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-name" }, organization.name), h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-description" }, organization.customerNumber)), h("pn-icon", { symbol: "arrow-right", small: "false", color: "blue700" }))));
|
|
239
237
|
}), this.logoutLink ?
|
|
240
|
-
h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" }, h("a", { href: this.logoutLink.href, rel: "nofollower noopener", class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
|
|
238
|
+
h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" }, h("a", { href: this.logoutLink.href, rel: "nofollower noopener", onClick: () => this.loginManager.clearUserData(), class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
|
|
241
239
|
: null));
|
|
242
240
|
}
|
|
243
241
|
get hostElement() { return getElement(this); }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, e as createEvent, h, a as Host, g as getElement } from './index-5397620b.js';
|
|
2
2
|
import { F as FetchHelper, M as MarketWebContextService } from './FetchHelper-1dfe8514.js';
|
|
3
|
-
import { M as MarketWebLoginManager } from './MarketWebLoginManager-
|
|
3
|
+
import { M as MarketWebLoginManager } from './MarketWebLoginManager-b8b046d3.js';
|
|
4
4
|
|
|
5
5
|
const translations = {
|
|
6
6
|
'sv': {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __awaiter=this&&this.__awaiter||function(e,t,n,o){function
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(e,t,n,o){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(t){i(t)}}function a(e){try{c(o["throw"](e))}catch(t){i(t)}}function c(e){e.done?n(e.value):r(e.value).then(s,a)}c((o=o.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,r,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(e){return function(t){return c([e,t])}}function c(s){if(o)throw new TypeError("Generator is already executing.");while(n)try{if(o=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;r=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(i=n.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){n.label=s[1];break}if(s[0]===6&&n.label<i[1]){n.label=i[1];i=s;break}if(i&&n.label<i[2]){n.label=i[2];n.ops.push(s);break}if(i[2])n.ops.pop();n.trys.pop();continue}s=t.call(e,n)}catch(a){s=[6,a];r=0}finally{o=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};var MarketWebLoginManager=function(){function e(e){var t=this;if(e===void 0){e=null}var n;this.eventTarget=window!==null&&window!==void 0?window:document===null||document===void 0?void 0:document.body;this.endpoint="";this.storagePrefix="pn-user";this.baseUrls={at:"https://atportal.postnord.com/api/unified-login/backend",prod:"https://portal.postnord.com/api/unified-login/backend"};this.events={loginstatechange:"loginstatechange"};this.endpoints={authorizationEndpoint:"/authorization",tokenExchangeEndpoint:"/token",userInfoEndpoint:"/user",logoutEndpoint:"/logout"};this.keys={tokensource:"tokensource",token:"token",user:"user",expire:"expire",expireDate:"expiredate"};this.overridetokenValue="overridetokenValue";this.store={get:function(e){var n=window.sessionStorage.getItem("".concat(t.storagePrefix,"-").concat(e));if(!n){return n}if(n.indexOf("{")===0){try{return JSON.parse(n)}catch(o){}}if(n.indexOf(",")!==-1){return n.split(",")}return n},set:function(e,n){if(typeof n==="object"&&typeof n.length==="undefined"){window.sessionStorage.setItem("".concat(t.storagePrefix,"-").concat(e),JSON.stringify(n));return}window.sessionStorage.setItem("".concat(t.storagePrefix,"-").concat(e),n)},remove:function(e){window.sessionStorage.removeItem("".concat(t.storagePrefix,"-").concat(e))}};if(!e){return}this.eventTarget=e.eventTarget?e.eventTarget:this.eventTarget;this.endpoint=e.endpoint?e.endpoint:"".concat(window.location.protocol,"//").concat(window.location.host);(n=this.storagePrefix)!==null&&n!==void 0?n:this.storagePrefix=e.storagePrefix;if(e.userInfo){this.store.set(this.keys.user,e.userInfo);this.registerToken(this.overridetokenValue,"override")}}e.prototype.init=function(e){if(e===void 0){e=true}if(e){this.checkParameters();this.checkExpireTime();if(this.store.get(this.keys.token)&&!this.store.get(this.keys.user)){this.fetchUserInfo()}this.loginStateChange()}};e.prototype.isLoggedIn=function(e){if(e===void 0){e=false}if(e){return e}var t=this.store.get(this.keys.token)&&this.store.get(this.keys.user)?true:false;return t};e.prototype.registerToken=function(e,t){if(e===void 0){e=""}if(t===void 0){t="frontend"}if(!e||e===this.getToken()){return}this.clearUserData();this.store.set(this.keys.tokensource,t);this.store.set(this.keys.token,e);this.fetchUserInfo()};e.prototype.invalidateTokenOfType=function(e){if(e===void 0){e="frontend"}var t=this.store.get(this.keys.token);if(!t){return}var n=this.store.get(this.keys.tokensource);if(n!==e){return}this.clearUserData()};e.prototype.getLoginUrl=function(e){if(e===void 0){e=""}var t=window.location.href;e=e?e:t;return"".concat(this.getBaseUrl()).concat(this.endpoints.authorizationEndpoint,"?redirectionUrl=").concat(e)};e.prototype.getLogoutUrl=function(e){if(e===void 0){e=""}e=window.location.origin+"/logout";return"".concat(this.getBaseUrl()).concat(this.endpoints.logoutEndpoint,"?redirectionUrl=").concat(e,"&authorization=").concat(this.store.get(this.keys.token))};e.prototype.getUserInfo=function(){if(this.isLoggedIn()){return this.store.get(this.keys.user)}};e.prototype.getEventTarget=function(){return this.eventTarget};e.prototype.checkExpireTime=function(){var e=this.store.get(this.keys.expire);if(!e){return}var t=new Date;var n=new Date(Math.floor(parseInt(e,10)*1e3));if(t>n){console.info("Login time has expired");this.clearUserData();this.loginStateChange()}};e.prototype.checkParameters=function(){if(!(window===null||window===void 0?void 0:window.location)){return}var e=new URLSearchParams(window.location.search);if(e.get("oneTimeCode")){var t=e.get("oneTimeCode");this.exchangeToken(t).then((function(){var e=window.location.href;var n=e.indexOf("?oneTimeCode")!==-1?"?":"&";history.replaceState({},document.querySelector("title").innerText,e.replace("".concat(n,"oneTimeCode=").concat(t),""))}))}};e.prototype.fetchUserInfo=function(){return __awaiter(this,void 0,void 0,(function(){var e,t,n,o,r,i,s;return __generator(this,(function(a){switch(a.label){case 0:e=this.store.get(this.keys.token);if(this.store.get(this.keys.token)===this.overridetokenValue){console.info("Did not fetch user data since it was set by an override");return[2]}t={method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:e}};return[4,fetch("".concat(this.getBaseUrl()).concat(this.endpoints.userInfoEndpoint),t)];case 1:n=a.sent();return[4,n.json()];case 2:o=a.sent();if(o&&o["idToken"]){try{r=o.idToken,i=o.expiryTime;s=this.parseUserInfo(r);if(!s){console.error("Userdata is not valid");this.clearUserData();return[2]}this.store.set(this.keys.user,s);this.store.set(this.keys.expire,i);this.store.set(this.keys.expireDate,new Date(Math.floor(parseInt(i,10)*1e3)));this.loginStateChange()}catch(c){console.error("Unable to get user information",c)}}else{console.error("Unable to get user information. Clearing login state");this.clearUserData()}return[2]}}))}))};e.prototype.clearUserData=function(){this.store.remove(this.keys.user);this.store.remove(this.keys.tokensource);this.store.remove(this.keys.token);this.store.remove(this.keys.expire);this.store.remove(this.keys.expireDate)};e.prototype.getToken=function(){return this.store.get(this.keys.token)};e.prototype.exchangeToken=function(e){return __awaiter(this,void 0,void 0,(function(){var t,n;return __generator(this,(function(o){switch(o.label){case 0:this.clearUserData();return[4,fetch("".concat(this.getBaseUrl()).concat(this.endpoints.tokenExchangeEndpoint,"?oneTimeCode=").concat(e))];case 1:t=o.sent();return[4,t.json()];case 2:n=o.sent().token;if(typeof n==="string"&&n){this.store.set(this.keys.token,n)}this.fetchUserInfo();return[2]}}))}))};e.prototype.loginStateChange=function(){if(!this.eventTarget){return}this.eventTarget.dispatchEvent(new CustomEvent(this.events.loginstatechange,{detail:this.isLoggedIn()}))};e.prototype.getBaseUrl=function(){var e=this;var t=["localhost","integration.","local."];var n=t.filter((function(t){return e.endpoint.indexOf(t)!==-1})).length>0;if(n){return this.baseUrls.at}return this.baseUrls.prod};e.prototype.parseUserInfo=function(e){if(!e){return null}var t=e.split(".")[1];var n=t.replace(/-/g,"+").replace(/_/g,"/");var o=decodeURIComponent(atob(n).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""));return JSON.parse(o)};return e}();export{MarketWebLoginManager as M};
|