@amedia/user 0.14.10 → 0.14.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amedia/user",
3
- "version": "0.14.10",
3
+ "version": "0.14.12",
4
4
  "description": "Client lib for working with aID user and associated data",
5
5
  "repository": "https://github.com/amedia/amedia-user-js",
6
6
  "author": "Amedia Utvikling (ID og data)",
@@ -113,7 +113,7 @@ describe('attemptAutoLoginJob', () => {
113
113
  describe('when a strategy triggers auto login', () => {
114
114
  beforeEach(async () => {
115
115
  shouldPerformAutoLogin = true;
116
- await attemptAutoLoginJob();
116
+ attemptAutoLoginJob();
117
117
  });
118
118
 
119
119
  itShouldCallThirdPartyCookieStrategy();
@@ -121,7 +121,7 @@ describe('attemptAutoLoginJob', () => {
121
121
  });
122
122
  describe('when no strategy triggers auto login', () => {
123
123
  beforeEach(async () => {
124
- await attemptAutoLoginJob();
124
+ attemptAutoLoginJob();
125
125
  });
126
126
 
127
127
  itShouldCallThirdPartyCookieStrategy();
@@ -132,7 +132,7 @@ describe('attemptAutoLoginJob', () => {
132
132
  describe('when tried within the last minute', () => {
133
133
  beforeEach(async () => {
134
134
  getCookieSpy.and.returnValue(Date.now());
135
- await attemptAutoLoginJob();
135
+ attemptAutoLoginJob();
136
136
  });
137
137
  itShouldCallThirdPartyCookieStrategy();
138
138
  itShouldNotNavigateAway();
@@ -143,7 +143,7 @@ describe('attemptAutoLoginJob', () => {
143
143
  getCookieSpy.and.returnValue(
144
144
  Date.now() - AUTOLOGIN_COOKIE_TTL - 1000
145
145
  );
146
- await attemptAutoLoginJob();
146
+ attemptAutoLoginJob();
147
147
  });
148
148
  itShouldCallThirdPartyCookieStrategy();
149
149
  itShouldNotNavigateAway();
@@ -157,7 +157,7 @@ describe('attemptAutoLoginJob', () => {
157
157
  store.merge('state', {
158
158
  emergencyMode: ['aid'],
159
159
  });
160
- await attemptAutoLoginJob();
160
+ attemptAutoLoginJob();
161
161
  });
162
162
 
163
163
  it('should not try third party auto login', () => {
@@ -194,7 +194,7 @@ describe('attemptPaywallAutoLogin', () => {
194
194
  });
195
195
  });
196
196
  store.set('state', { isLoggedIn: true });
197
- await attemptPaywallAutoLogin();
197
+ attemptPaywallAutoLogin();
198
198
  });
199
199
  });
200
200
 
@@ -221,7 +221,7 @@ describe('attemptPaywallAutoLogin', () => {
221
221
  delete global.top; // Set window.top to something other than window.self
222
222
  // @ts-ignore
223
223
  global.top = {};
224
- await attemptPaywallAutoLogin();
224
+ attemptPaywallAutoLogin();
225
225
  });
226
226
  afterEach(() => {
227
227
  // @ts-ignore
@@ -235,7 +235,7 @@ describe('attemptPaywallAutoLogin', () => {
235
235
  describe('when already tried cookie is not found', () => {
236
236
  beforeEach(async () => {
237
237
  getCookieSpy.and.returnValue(undefined);
238
- await attemptPaywallAutoLogin();
238
+ attemptPaywallAutoLogin();
239
239
  });
240
240
  itShouldNavigateToAutoLogin('paywall');
241
241
  });
@@ -244,7 +244,7 @@ describe('attemptPaywallAutoLogin', () => {
244
244
  describe('when tried within the last minute', () => {
245
245
  beforeEach(async () => {
246
246
  getCookieSpy.and.returnValue(Date.now());
247
- await attemptPaywallAutoLogin();
247
+ attemptPaywallAutoLogin();
248
248
  });
249
249
  itShouldNotNavigateAway();
250
250
  });
@@ -254,7 +254,7 @@ describe('attemptPaywallAutoLogin', () => {
254
254
  getCookieSpy.and.returnValue(
255
255
  Date.now() - AUTOLOGIN_COOKIE_TTL - 1000
256
256
  );
257
- await attemptPaywallAutoLogin();
257
+ attemptPaywallAutoLogin();
258
258
  });
259
259
  itShouldNavigateToAutoLogin('paywall');
260
260
  });
@@ -78,7 +78,14 @@ const attemptAutologin = async (strategies: Strategies) => {
78
78
  url.searchParams.set('context', `auto_login_${strategy.name}`);
79
79
  url.searchParams.set('requestedUrl', getCurrentUrl());
80
80
  navigateTo(url.href);
81
- return false;
81
+
82
+ /**
83
+ * Don't resolve autologin promise when navigating away.
84
+ * This will cause waiting code to execute as if the user did/did not have access
85
+ * and will in turn cause flickering and unnecessary (and often aborted) request to
86
+ * various backends.
87
+ */
88
+ return new Promise(() => {});
82
89
  }
83
90
  return true;
84
91
  });
@@ -23,10 +23,13 @@ describe('activateSubscription()', () => {
23
23
  it('should return list if access features even if requested access is not "granted"', async () => {
24
24
  fetch.mockResponse(
25
25
  JSON.stringify({
26
- status: 'success',
26
+ status: 'subscription_not_found',
27
27
  access: 'denied',
28
28
  access_features: ['newspaper'],
29
- })
29
+ }),
30
+ {
31
+ status: 400,
32
+ }
30
33
  );
31
34
  await expect(
32
35
  activateSubscription(['newspaper'], 'www.telen.no')
@@ -36,7 +36,7 @@ export const activateSubscription = async (
36
36
  throw new UserDeactivatedError();
37
37
  }
38
38
  if (EXPECTED_ERRORS.includes(data?.status)) {
39
- return [];
39
+ return data?.access_features || [];
40
40
  }
41
41
  log.error(
42
42
  `Activate subscription failed. Mercury (HTTP/${response.status}: ${body})`,