@amedia/user 1.1.6 → 1.2.1

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/index.d.ts +33 -18
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @amedia/user
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1217](https://github.com/amedia/amedia-user-js/pull/1217) [`470702b`](https://github.com/amedia/amedia-user-js/commit/470702b724b42a0f780701548289456ee81d80c1) Thanks [@csandven](https://github.com/csandven)! - Tests and classes refactor
8
+
9
+ ## 1.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#1212](https://github.com/amedia/amedia-user-js/pull/1212) [`26590e0`](https://github.com/amedia/amedia-user-js/commit/26590e06f4ccad0a7f5977bf54209b55aebfdb9f) Thanks [@pederfo](https://github.com/pederfo)! - Add replace param on goToLoginPage
14
+
15
+ ### Patch Changes
16
+
17
+ - [#1205](https://github.com/amedia/amedia-user-js/pull/1205) [`2473e6a`](https://github.com/amedia/amedia-user-js/commit/2473e6ad1aab9d763f3653cdf8d97dbee20247d5) Thanks [@csandven](https://github.com/csandven)! - tryParseJSON helper and error logging
18
+
19
+ - [#1211](https://github.com/amedia/amedia-user-js/pull/1211) [`d2812e7`](https://github.com/amedia/amedia-user-js/commit/d2812e7b43bdfc93269104f44a5623fcfcebb14c) Thanks [@hennikul](https://github.com/hennikul)! - Remove nebula backend integration. The nebula system is being shut down, so all calls to it have been removed. The `extraData` field is kept in the API for backwards compatibility but now always returns an empty object.
20
+
3
21
  ## 1.1.6
4
22
 
5
23
  ### Patch Changes
package/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import * as v from 'valibot';
2
2
 
3
3
  type AccessFeatures = string[];
4
- type UserAttributes = {
4
+ interface UserAttributes {
5
5
  uuid: string | null;
6
6
  name: string | null;
7
7
  trackingKey: string | null;
8
8
  avatar: string | null;
9
- /** @deprecated use data from [@amedia/user-datapoints](https://github.com/amedia/amedia-user-datapoints) instead */
9
+ /** @deprecated Always returns empty. Use data from [@amedia/user-datapoints](https://github.com/amedia/amedia-user-datapoints) instead. */
10
10
  extraData: {
11
11
  [index: string]: unknown;
12
12
  };
@@ -14,19 +14,24 @@ type UserAttributes = {
14
14
  /** @deprecated Returns false for all keys. CMP data is now used. */
15
15
  privacyPreferences: PrivacyPreferences | null;
16
16
  sessionTrackingKey: string | null;
17
- };
18
- type State = {
17
+ }
18
+ interface State {
19
19
  isLoggedIn: boolean;
20
20
  isCircuitBreakerTripped?: boolean;
21
21
  emergencyMode?: string[];
22
- };
22
+ }
23
23
  /**
24
24
  * @deprecated This is set to false as default. CMP data is now used.
25
25
  */
26
- type PrivacyPreferences = {
27
- allowResearchUsage: boolean;
28
- personalizedContent: boolean;
29
- };
26
+ declare class PrivacyPreferences {
27
+ readonly allowResearchUsage: boolean;
28
+ readonly personalizedContent: boolean;
29
+ constructor(data: {
30
+ allowResearchUsage: boolean;
31
+ personalizedContent: boolean;
32
+ });
33
+ static default(): PrivacyPreferences;
34
+ }
30
35
 
31
36
  type ClientId = string;
32
37
 
@@ -89,12 +94,21 @@ declare const PrimarySiteSchema: v.ObjectSchema<{
89
94
  }, undefined>;
90
95
  type PrimarySite = v.InferOutput<typeof PrimarySiteSchema>;
91
96
 
92
- type SiteAccessResponse = {
93
- isLoggedIn: boolean;
94
- hasAccess: boolean;
95
- primarySite?: null | PrimarySite;
96
- accessFeatures: string[];
97
- };
97
+ declare class SiteAccessResponse {
98
+ readonly isLoggedIn: boolean;
99
+ readonly hasAccess: boolean;
100
+ readonly primarySite?: PrimarySite | null;
101
+ readonly accessFeatures: string[];
102
+ constructor(data: {
103
+ isLoggedIn: boolean;
104
+ hasAccess: boolean;
105
+ primarySite?: PrimarySite | null;
106
+ accessFeatures: string[];
107
+ });
108
+ static notLoggedIn(): SiteAccessResponse;
109
+ static granted(accessFeatures: string[]): SiteAccessResponse;
110
+ static denied(accessFeatures: string[], primarySite?: PrimarySite | null): SiteAccessResponse;
111
+ }
98
112
  declare class SiteAccessRequest {
99
113
  private requiredAccessFeatures;
100
114
  private siteDomain;
@@ -128,10 +142,10 @@ declare class FetchTimeoutError extends Error {
128
142
  }
129
143
 
130
144
  declare class PaywallError extends Error {
145
+ code: string;
131
146
  static ERROR_RELOADED_NO_ACCESS: string;
132
147
  static ERROR_ENABLING_ACCESS_FAILED: string;
133
148
  static ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES: string;
134
- code: string;
135
149
  constructor(message: string, code: string);
136
150
  }
137
151
 
@@ -162,6 +176,7 @@ declare function pollForAccess(requiredAccessFeatures?: string[], timeout_millis
162
176
  type LoginPageParams = {
163
177
  requestedUrl?: string;
164
178
  context?: string;
179
+ replace?: boolean;
165
180
  };
166
181
  /**
167
182
  * This will, if necessary, trigger a redirect to www.aid.no and return
@@ -181,5 +196,5 @@ declare const aidUrls: {
181
196
  sites: URL;
182
197
  };
183
198
 
184
- export { EmergencyModeError, FetchTimeoutError, PaywallError, PaywallUnlockRequest, SiteAccessRequest, TimeoutError, UserDataRequest, ValidationError, aidUrls, getLoginUrl, goToLoginPage, logout, pollForAccess, requestDataRefresh };
185
- export type { PaywallUnlockResponse, PrivacyPreferences, SiteAccessResponse, State, UserAttributes };
199
+ export { EmergencyModeError, FetchTimeoutError, PaywallError, PaywallUnlockRequest, PrivacyPreferences, SiteAccessRequest, SiteAccessResponse, TimeoutError, UserDataRequest, ValidationError, aidUrls, getLoginUrl, goToLoginPage, logout, pollForAccess, requestDataRefresh };
200
+ export type { PaywallUnlockResponse, State, UserAttributes };
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "git+https://github.com/amedia/amedia-user-js.git"
7
7
  },
8
8
  "author": "Amedia Produkt og Teknologi AS (https://amedia.no)",
9
- "version": "1.1.6",
9
+ "version": "1.2.1",
10
10
  "type": "module",
11
11
  "types": "./index.d.ts",
12
12
  "publishConfig": {