@amedia/user 0.14.35 → 0.14.37
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/README.md +3 -0
- package/dist/user.d.ts +113 -813
- package/package.json +20 -16
package/README.md
CHANGED
|
@@ -33,6 +33,9 @@ It's often nice to do development while testing on a real app. You may do so usi
|
|
|
33
33
|
|
|
34
34
|
PS: Remember to comment-out the module in import maps ;-)
|
|
35
35
|
|
|
36
|
+
### Testing live!
|
|
37
|
+
You can test your version live by utilizing a browser extension like Requestly or similar. Run `npm run dev` (which will build and watch for changes locally _and_ starts a webserver listening on localhost:9999). Then add a rule in the extension that replaces requests for @amedia/user/v0/user.js with http://localhost:9999/user.js. Now reload and watch your wonderful change do its thing.
|
|
38
|
+
|
|
36
39
|
## Getting user data
|
|
37
40
|
The most common use case for aID on newspapers is to get some kind of data about a user, this could be the user's name, some stored preference, access or data that has been derived about the user.
|
|
38
41
|
|
package/dist/user.d.ts
CHANGED
|
@@ -1,813 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
declare
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
declare
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
declare
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
export const get: (key: string) => Promise<CacheEntry>;
|
|
117
|
-
export const set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
118
|
-
export const remove: (key: string) => Promise<void>;
|
|
119
|
-
export const clear: () => Promise<void>;
|
|
120
|
-
const _default: Engine;
|
|
121
|
-
export default _default;
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
declare module '@amedia/user/cache/engines/global.spec' {
|
|
125
|
-
export {};
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
declare module '@amedia/user/cache/index' {
|
|
129
|
-
import { Static } from 'runtypes';
|
|
130
|
-
import { RuntypeBase } from 'runtypes/lib/runtype';
|
|
131
|
-
import { Engine } from '@amedia/user/cache/types';
|
|
132
|
-
export const setCacheEngine: (engine: Engine) => void;
|
|
133
|
-
const _default: {
|
|
134
|
-
get: <T extends RuntypeBase<unknown>>(key: string, validator: T) => Promise<void | Static<T>>;
|
|
135
|
-
set: (key: string, value: unknown, expires: number) => Promise<void>;
|
|
136
|
-
remove: (key: string) => Promise<void>;
|
|
137
|
-
clear: () => Promise<void>;
|
|
138
|
-
};
|
|
139
|
-
export default _default;
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
declare module '@amedia/user/cache/index.spec' {
|
|
143
|
-
export {};
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
declare module '@amedia/user/cache/types' {
|
|
147
|
-
export type CacheEntry = {
|
|
148
|
-
key: string;
|
|
149
|
-
data: unknown;
|
|
150
|
-
expires: number;
|
|
151
|
-
};
|
|
152
|
-
export type Engine = {
|
|
153
|
-
get: (key: string) => Promise<CacheEntry | null>;
|
|
154
|
-
set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
155
|
-
remove: (key: string) => Promise<void>;
|
|
156
|
-
clear: () => Promise<void>;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
declare module '@amedia/user/clients/europa' {
|
|
161
|
-
import * as rt from 'runtypes';
|
|
162
|
-
export const EuropaSchema: rt.Dictionary<rt.Unknown, string>;
|
|
163
|
-
export const clearLocalCache: () => Promise<void>;
|
|
164
|
-
export const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
|
|
165
|
-
export const getNamespaces: <S extends {
|
|
166
|
-
[namespace: string]: {
|
|
167
|
-
[index: string]: unknown;
|
|
168
|
-
};
|
|
169
|
-
}, Namespaces extends (keyof S)[]>(namespaces: Namespaces, options?: {
|
|
170
|
-
ignoreCache: boolean;
|
|
171
|
-
}) => Promise<Pick<S, Namespaces[number]>>;
|
|
172
|
-
export const saveNamespace: (namespace: string, data: Object) => Promise<Pick<{
|
|
173
|
-
[namespace: string]: {
|
|
174
|
-
[index: string]: unknown;
|
|
175
|
-
};
|
|
176
|
-
}, string>>;
|
|
177
|
-
export const getAllNamespaces: () => Promise<{
|
|
178
|
-
[x: string]: unknown;
|
|
179
|
-
}>;
|
|
180
|
-
export const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<{
|
|
181
|
-
[namespace: string]: {
|
|
182
|
-
[index: string]: unknown;
|
|
183
|
-
};
|
|
184
|
-
}, string>>;
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
declare module '@amedia/user/clients/europa.spec' {
|
|
188
|
-
export {};
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
declare module '@amedia/user/clients/jupiter' {
|
|
192
|
-
import * as rt from 'runtypes';
|
|
193
|
-
import { UserAttributes } from '@amedia/user/types';
|
|
194
|
-
export type AccessFeatures = string[];
|
|
195
|
-
export const CheckAccessForPaperSchema: rt.Record<{
|
|
196
|
-
status: rt.Literal<"success">;
|
|
197
|
-
access: rt.Union<[rt.Literal<"granted">, rt.Literal<"denied">]>;
|
|
198
|
-
publication: rt.Record<{
|
|
199
|
-
id: rt.Number;
|
|
200
|
-
domain: rt.String;
|
|
201
|
-
}, false>;
|
|
202
|
-
access_features: rt.Array<rt.String, false>;
|
|
203
|
-
}, false>;
|
|
204
|
-
export type CheckAccessForPaper = rt.Static<typeof CheckAccessForPaperSchema>;
|
|
205
|
-
const GetVstokenSchema: rt.Record<{
|
|
206
|
-
status: rt.Literal<"success">;
|
|
207
|
-
cookie: rt.String;
|
|
208
|
-
access_features: rt.Array<rt.String, false>;
|
|
209
|
-
}, false>;
|
|
210
|
-
export type GetVstoken = rt.Static<typeof GetVstokenSchema>;
|
|
211
|
-
const GetNonUserAccessSchema: rt.Record<{
|
|
212
|
-
status: rt.Literal<"success">;
|
|
213
|
-
vstoken_cookie: rt.String;
|
|
214
|
-
uuid: rt.String;
|
|
215
|
-
access_features: rt.Array<rt.String, false>;
|
|
216
|
-
}, false>;
|
|
217
|
-
export type GetNonUserAccess = rt.Static<typeof GetNonUserAccessSchema>;
|
|
218
|
-
export const checkForAccess: (siteDomain: string, accessFeatures: AccessFeatures) => Promise<Pick<UserAttributes, 'access'>>;
|
|
219
|
-
export const getUserAccess: (siteDomain: string) => Promise<GetVstoken>;
|
|
220
|
-
export const getNonUserAccess: (siteDomain: string) => Promise<GetNonUserAccess>;
|
|
221
|
-
export {};
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
declare module '@amedia/user/clients/jupiter.spec' {
|
|
225
|
-
export {};
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
declare module '@amedia/user/clients/mercury' {
|
|
229
|
-
import * as rt from 'runtypes';
|
|
230
|
-
export class UserDeactivatedError extends Error {
|
|
231
|
-
}
|
|
232
|
-
export enum AffiliationType {
|
|
233
|
-
ACCESS = "access",
|
|
234
|
-
FAMILY = "family",
|
|
235
|
-
SUBSCRIPTION = "subscription"
|
|
236
|
-
}
|
|
237
|
-
const PrimarySiteSchema: rt.Record<{
|
|
238
|
-
domain: rt.String;
|
|
239
|
-
name: rt.String;
|
|
240
|
-
affiliation: rt.Literal<AffiliationType.ACCESS>;
|
|
241
|
-
affiliations: rt.Array<rt.Union<[rt.Literal<AffiliationType.ACCESS>, rt.Literal<AffiliationType.FAMILY>, rt.Literal<AffiliationType.SUBSCRIPTION>]>, false>;
|
|
242
|
-
}, false>;
|
|
243
|
-
export type PrimarySite = rt.Static<typeof PrimarySiteSchema>;
|
|
244
|
-
export const activateSubscription: (accessFeatures: string[], siteDomain: string) => Promise<string[]>;
|
|
245
|
-
export const getPrimarySite: (accessFeatures: string[]) => Promise<PrimarySite | null>;
|
|
246
|
-
export {};
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
declare module '@amedia/user/clients/mercury.spec' {
|
|
250
|
-
export {};
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
declare module '@amedia/user/clients/mercuryLog' {
|
|
254
|
-
type Context = Record<string, unknown>;
|
|
255
|
-
const log: {
|
|
256
|
-
error: (message: string, context: Context) => void;
|
|
257
|
-
warn: (message: string, context: Context) => void;
|
|
258
|
-
info: (message: string, context: Context) => void;
|
|
259
|
-
debug: (message: string, context: Context) => void;
|
|
260
|
-
};
|
|
261
|
-
export default log;
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
declare module '@amedia/user/clients/mercuryLog.spec' {
|
|
265
|
-
export {};
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
declare module '@amedia/user/clients/nebula' {
|
|
269
|
-
import { UserAttributes } from '@amedia/user/types';
|
|
270
|
-
export const getInfo: (siteDomain: string, browserId: string, trackingKey?: string | undefined) => Promise<Pick<UserAttributes, 'extraData'>>;
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
declare module '@amedia/user/clients/nebula.spec' {
|
|
274
|
-
export {};
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
declare module '@amedia/user/clients/pluto' {
|
|
278
|
-
import { UserAttributes } from '@amedia/user/types';
|
|
279
|
-
export const resolveBadPlutoResponse: (response: Response) => Promise<void>;
|
|
280
|
-
export const getCurrentSession: () => Promise<UserAttributes>;
|
|
281
|
-
export const removeSession: (domain: string) => Promise<void>;
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
declare module '@amedia/user/clients/pluto.spec' {
|
|
285
|
-
export {};
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
declare module '@amedia/user/clients/user' {
|
|
289
|
-
import { UserAttributes } from '@amedia/user/types';
|
|
290
|
-
export const getCurrentUser: () => Promise<UserAttributes>;
|
|
291
|
-
export const compareWithCurrentUserAndLogDiff: (currentSession: UserAttributes) => Promise<UserAttributes>;
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
declare module '@amedia/user/clients/user.spec' {
|
|
295
|
-
export {};
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
declare module '@amedia/user/eventHandlers/activation' {
|
|
299
|
-
export enum ActivationEvents {
|
|
300
|
-
REQUEST_ACTIVATION = "amedia-user.activation.request-activation",
|
|
301
|
-
ON_ACTIVATION_COMPLETE = "amedia-user.activation.on-activation-complete"
|
|
302
|
-
}
|
|
303
|
-
global {
|
|
304
|
-
interface WindowEventMap {
|
|
305
|
-
[ActivationEvents.REQUEST_ACTIVATION]: CustomEvent<{
|
|
306
|
-
accessFeatures: string[];
|
|
307
|
-
siteDomain?: string;
|
|
308
|
-
}>;
|
|
309
|
-
[ActivationEvents.ON_ACTIVATION_COMPLETE]: CustomEvent<{
|
|
310
|
-
accessFeatures: string[];
|
|
311
|
-
}>;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
export const listenForActivationRequests: () => void;
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
declare module '@amedia/user/eventHandlers/authentication' {
|
|
318
|
-
export enum AuthenticationEvents {
|
|
319
|
-
REQUEST_LOGIN = "amedia-user.authentication.request-login",
|
|
320
|
-
REQUEST_LOGOUT = "amedia-user.authentication.request-logout",
|
|
321
|
-
ON_LOGGED_OUT = "amedia-user.authentication.on-logged-out"
|
|
322
|
-
}
|
|
323
|
-
global {
|
|
324
|
-
interface WindowEventMap {
|
|
325
|
-
[AuthenticationEvents.REQUEST_LOGIN]: CustomEvent<{
|
|
326
|
-
requestedUrl: string;
|
|
327
|
-
}>;
|
|
328
|
-
[AuthenticationEvents.REQUEST_LOGOUT]: CustomEvent<{
|
|
329
|
-
onLoggedOut: () => void;
|
|
330
|
-
}>;
|
|
331
|
-
[AuthenticationEvents.ON_LOGGED_OUT]: CustomEvent;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
export const listenForAuthenticationRequests: () => void;
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
declare module '@amedia/user/eventHandlers/eventMap' {
|
|
338
|
-
import { State, UserAttributes } from '@amedia/user/types';
|
|
339
|
-
export enum AmediaUserEvents {
|
|
340
|
-
REQUEST_STATE = "amedia-user.request-state",
|
|
341
|
-
REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
|
|
342
|
-
REQUEST_STORAGE_NAMESPACES = "amedia-user.request-storage-namespaces",
|
|
343
|
-
REQUEST_NAVIGATION = "amedia-user.request-navigation",
|
|
344
|
-
SAVE_STORAGE = "amedia-user.save-storage-namespaces",
|
|
345
|
-
UPDATE_STORAGE = "amedia-user.update-storage-namespaces",
|
|
346
|
-
ON_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated",
|
|
347
|
-
ON_STATE_UPDATED = "amedia-user.on-state-updated",
|
|
348
|
-
ON_STORAGE_UPDATED = "amedia-user.on-storage-updated"
|
|
349
|
-
}
|
|
350
|
-
global {
|
|
351
|
-
interface WindowEventMap {
|
|
352
|
-
[AmediaUserEvents.REQUEST_STATE]: CustomEvent;
|
|
353
|
-
[AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
|
|
354
|
-
[AmediaUserEvents.REQUEST_STORAGE_NAMESPACES]: CustomEvent<Array<string>>;
|
|
355
|
-
[AmediaUserEvents.REQUEST_NAVIGATION]: CustomEvent<{
|
|
356
|
-
type: 'reload' | 'location';
|
|
357
|
-
url?: string;
|
|
358
|
-
replace?: boolean;
|
|
359
|
-
}>;
|
|
360
|
-
[AmediaUserEvents.SAVE_STORAGE]: CustomEvent<{
|
|
361
|
-
[namespace: string]: object;
|
|
362
|
-
}>;
|
|
363
|
-
[AmediaUserEvents.UPDATE_STORAGE]: CustomEvent<{
|
|
364
|
-
[namespace: string]: object;
|
|
365
|
-
}>;
|
|
366
|
-
[AmediaUserEvents.ON_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
|
|
367
|
-
[AmediaUserEvents.ON_STATE_UPDATED]: CustomEvent<State>;
|
|
368
|
-
[AmediaUserEvents.ON_STORAGE_UPDATED]: CustomEvent<{
|
|
369
|
-
[index: string]: unknown;
|
|
370
|
-
}>;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
declare module '@amedia/user/eventHandlers/navigation' {
|
|
376
|
-
export const internalLocationHref: (url: string) => void;
|
|
377
|
-
export const internalLocationReload: () => void;
|
|
378
|
-
export const internalLocationReplace: (url: string) => void;
|
|
379
|
-
export const missingWindowContext: () => boolean;
|
|
380
|
-
export const listenForNavigationRequests: () => void;
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
declare module '@amedia/user/eventHandlers/navigation.spec' {
|
|
384
|
-
export {};
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
declare module '@amedia/user/eventHandlers/state' {
|
|
388
|
-
export const listenForStateRequests: () => void;
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
declare module '@amedia/user/eventHandlers/state.spec' {
|
|
392
|
-
export {};
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
declare module '@amedia/user/eventHandlers/storage' {
|
|
396
|
-
export const listenForStorageRequests: () => void;
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
declare module '@amedia/user/eventHandlers/storage.spec' {
|
|
400
|
-
export {};
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
declare module '@amedia/user/eventHandlers/userAttributes' {
|
|
404
|
-
export const listenForUserAttributeRequests: () => void;
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
declare module '@amedia/user/eventHandlers/userAttributes.spec' {
|
|
408
|
-
export {};
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
declare module '@amedia/user/exceptions/FetchTimeoutError' {
|
|
412
|
-
export default class FetchTimeoutError extends Error {
|
|
413
|
-
partialData: Record<string, object>;
|
|
414
|
-
constructor(message: string, partialData: Record<string, object>);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
declare module '@amedia/user/exceptions/PaywallError' {
|
|
419
|
-
class PaywallError extends Error {
|
|
420
|
-
static ERROR_RELOADED_NO_ACCESS: string;
|
|
421
|
-
static ERROR_ENABLING_ACCESS_FAILED: string;
|
|
422
|
-
static ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES: string;
|
|
423
|
-
code: string;
|
|
424
|
-
constructor(message: string, code: string);
|
|
425
|
-
}
|
|
426
|
-
export default PaywallError;
|
|
427
|
-
|
|
428
|
-
}
|
|
429
|
-
declare module '@amedia/user/index-authentcation.spec' {
|
|
430
|
-
export {};
|
|
431
|
-
|
|
432
|
-
}
|
|
433
|
-
declare module '@amedia/user/index-storage.spec' {
|
|
434
|
-
export {};
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
declare module '@amedia/user/index-subscription.spec' {
|
|
438
|
-
export {};
|
|
439
|
-
|
|
440
|
-
}
|
|
441
|
-
declare module '@amedia/user/index' {
|
|
442
|
-
export { default as UserDataRequest } from '@amedia/user/lib/UserDataRequest';
|
|
443
|
-
export { default as PaywallUnlockRequest } from '@amedia/user/lib/PaywallUnlockRequest';
|
|
444
|
-
export { default as FetchTimeoutError } from '@amedia/user/exceptions/FetchTimeoutError';
|
|
445
|
-
export { default as PaywallError } from '@amedia/user/exceptions/PaywallError';
|
|
446
|
-
/**
|
|
447
|
-
* This will, if necessary, trigger a redirect to www.aid.no and return
|
|
448
|
-
* to the requestedUrl if supplied or the current url before redirecting away if not.
|
|
449
|
-
* @param requestedUrl
|
|
450
|
-
*/
|
|
451
|
-
export const goToLoginPage: (requestedUrl?: string | undefined) => void;
|
|
452
|
-
export const getLoginUrl: (requestedUrl?: string | undefined) => URL;
|
|
453
|
-
export const logout: () => Promise<void>;
|
|
454
|
-
export const updateStorage: (storage: {
|
|
455
|
-
[index: string]: Object;
|
|
456
|
-
}) => void;
|
|
457
|
-
export const saveStorage: (storage: {
|
|
458
|
-
[index: string]: Object;
|
|
459
|
-
}) => void;
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
declare module '@amedia/user/janitor/index' {
|
|
463
|
-
enum JanitorEvents {
|
|
464
|
-
LOADED = "amedia-user.janitor.loaded"
|
|
465
|
-
}
|
|
466
|
-
global {
|
|
467
|
-
interface WindowEventMap {
|
|
468
|
-
[JanitorEvents.LOADED]: CustomEvent<{}>;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
export const runJanitor: () => Promise<void>;
|
|
472
|
-
export {};
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
declare module '@amedia/user/janitor/index.spec' {
|
|
476
|
-
export {};
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
declare module '@amedia/user/janitor/jobs/accessCookieRefresher' {
|
|
480
|
-
export default function accessCookieRefresher(): Promise<[void, void]>;
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
declare module '@amedia/user/janitor/jobs/accessCookieRefresher.spec' {
|
|
484
|
-
export {};
|
|
485
|
-
|
|
486
|
-
}
|
|
487
|
-
declare module '@amedia/user/janitor/jobs/daxsubCookie' {
|
|
488
|
-
import { UserAttributes } from '@amedia/user/types';
|
|
489
|
-
export function getCookieValue(attributes: UserAttributes): string;
|
|
490
|
-
export default function daxSubCookieHandler(): Promise<void>;
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
declare module '@amedia/user/janitor/jobs/daxsubCookie.spec' {
|
|
494
|
-
export {};
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
declare module '@amedia/user/janitor/jobs/removeUserStorage' {
|
|
498
|
-
export function removeUserStorage(): void;
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
declare module '@amedia/user/janitor/jobs/removeUserStorage.spec' {
|
|
502
|
-
export {};
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
declare module '@amedia/user/lib/PaywallUnlockRequest' {
|
|
506
|
-
import { PrimarySite } from '@amedia/user/clients/mercury';
|
|
507
|
-
export type UnlockResponse = {
|
|
508
|
-
isLoggedIn: boolean;
|
|
509
|
-
hasAccess: boolean;
|
|
510
|
-
primarySite?: null | PrimarySite;
|
|
511
|
-
accessFeatures: string[];
|
|
512
|
-
};
|
|
513
|
-
class PaywallUnlockRequest {
|
|
514
|
-
private requestedAccessFeatures;
|
|
515
|
-
private reload;
|
|
516
|
-
private requestedUrl;
|
|
517
|
-
private siteDomain;
|
|
518
|
-
withSiteDomain(domain: string): this;
|
|
519
|
-
withAccessFeatures(accessFeatures: string[]): this;
|
|
520
|
-
reloadOnAccess(): this;
|
|
521
|
-
redirectOnAccess(requestedUrl: string): this;
|
|
522
|
-
tryUnlock(): Promise<UnlockResponse>;
|
|
523
|
-
}
|
|
524
|
-
export default PaywallUnlockRequest;
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
declare module '@amedia/user/lib/PaywallUnlockRequest.spec' {
|
|
528
|
-
export {};
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
declare module '@amedia/user/lib/UserDataRequest' {
|
|
532
|
-
import { State, UserAttributes } from '@amedia/user/types';
|
|
533
|
-
type Millis = number;
|
|
534
|
-
class UserDataRequest<UA extends UserAttributes, S extends {
|
|
535
|
-
[index: string]: unknown;
|
|
536
|
-
}, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends Record<string, object> = {
|
|
537
|
-
state: State;
|
|
538
|
-
}> {
|
|
539
|
-
private attributes?;
|
|
540
|
-
private namespaces?;
|
|
541
|
-
static FETCH_TIMEOUT: Millis;
|
|
542
|
-
private fetchTimeoutId;
|
|
543
|
-
private lastReceivedData?;
|
|
544
|
-
constructor(attributes?: Attributes | undefined, namespaces?: Namespaces | undefined);
|
|
545
|
-
withAttributes<NewAttributes extends Array<keyof UA>>(attributes: NewAttributes): UserDataRequest<UA, S, (Attributes[number] & NewAttributes[number])[], Namespaces, SubscribeResponse & {
|
|
546
|
-
attributes: Pick<UA, Attributes[number] & NewAttributes[number]>;
|
|
547
|
-
}>;
|
|
548
|
-
withStorage<NewNamespaces extends Array<string>>(namespaces: NewNamespaces): UserDataRequest<UA, S, Attributes, (Namespaces[number] & NewNamespaces[number])[], SubscribeResponse & {
|
|
549
|
-
storage: Pick<S, Namespaces[number] & NewNamespaces[number]>;
|
|
550
|
-
}>;
|
|
551
|
-
subscribe(onData: (data: SubscribeResponse) => void): void;
|
|
552
|
-
fetch(options?: {
|
|
553
|
-
timeout?: Millis;
|
|
554
|
-
}): Promise<SubscribeResponse>;
|
|
555
|
-
private clearFetchTimeout;
|
|
556
|
-
private startFetchTimeout;
|
|
557
|
-
private processUserAttributesEvent;
|
|
558
|
-
private processStorageEvent;
|
|
559
|
-
private setupLocalCache;
|
|
560
|
-
}
|
|
561
|
-
export default UserDataRequest;
|
|
562
|
-
|
|
563
|
-
}
|
|
564
|
-
declare module '@amedia/user/lib/UserDataRequest.spec' {
|
|
565
|
-
export {};
|
|
566
|
-
|
|
567
|
-
}
|
|
568
|
-
declare module '@amedia/user/lib/cookie' {
|
|
569
|
-
export const getCookie: (name: string) => string | {
|
|
570
|
-
[index: string]: unknown;
|
|
571
|
-
} | null | undefined;
|
|
572
|
-
export function setCookie(name: string, value?: unknown, validTimeInDateOrDays?: Date | number, path?: string, secure?: boolean): string;
|
|
573
|
-
export function removeCookie(name: string): void;
|
|
574
|
-
/**
|
|
575
|
-
* This function should only be used in tests, as it will remove all cookies a user has on the domain.
|
|
576
|
-
*/
|
|
577
|
-
export function removeAllCookies(): void;
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
declare module '@amedia/user/lib/rpc' {
|
|
581
|
-
import { RPCclient } from '@amedia/frontend-rpc';
|
|
582
|
-
interface LocalRPCclient extends RPCclient {
|
|
583
|
-
userAuthenticated: (isLoggedIn: boolean) => void;
|
|
584
|
-
}
|
|
585
|
-
export const getRPCClient: () => LocalRPCclient;
|
|
586
|
-
export {};
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
declare module '@amedia/user/store/index' {
|
|
590
|
-
import { State, UserAttributes } from '@amedia/user/types';
|
|
591
|
-
type StoreDataMap = {
|
|
592
|
-
userAttributes: UserAttributes;
|
|
593
|
-
state: State;
|
|
594
|
-
storage: {
|
|
595
|
-
[namespace: string]: {
|
|
596
|
-
[index: string]: unknown;
|
|
597
|
-
};
|
|
598
|
-
};
|
|
599
|
-
internalState: {
|
|
600
|
-
isPoisoned: boolean;
|
|
601
|
-
};
|
|
602
|
-
};
|
|
603
|
-
type Listener<T> = (data: T) => void;
|
|
604
|
-
const _default: {
|
|
605
|
-
merge: <K extends keyof StoreDataMap>(key: K, value: Partial<StoreDataMap[K]>) => void;
|
|
606
|
-
set: (key: keyof StoreDataMap, value: UserAttributes | State | {
|
|
607
|
-
[namespace: string]: {
|
|
608
|
-
[index: string]: unknown;
|
|
609
|
-
};
|
|
610
|
-
} | {
|
|
611
|
-
isPoisoned: boolean;
|
|
612
|
-
}) => void;
|
|
613
|
-
get: <K_1 extends keyof StoreDataMap, T = StoreDataMap[K_1]>(key: K_1) => T | undefined;
|
|
614
|
-
on: <K_2 extends keyof StoreDataMap, T_1 = StoreDataMap[K_2]>(key: K_2, listener: Listener<T_1>) => void;
|
|
615
|
-
clear: () => void;
|
|
616
|
-
};
|
|
617
|
-
export default _default;
|
|
618
|
-
|
|
619
|
-
}
|
|
620
|
-
declare module '@amedia/user/store/index.spec' {
|
|
621
|
-
export {};
|
|
622
|
-
|
|
623
|
-
}
|
|
624
|
-
declare module '@amedia/user/types' {
|
|
625
|
-
export type UserAttributes = {
|
|
626
|
-
uuid?: string | null;
|
|
627
|
-
name?: string | null;
|
|
628
|
-
trackingKey?: string | null;
|
|
629
|
-
avatar?: string | null;
|
|
630
|
-
extraData?: {
|
|
631
|
-
[index: string]: unknown;
|
|
632
|
-
};
|
|
633
|
-
access?: string[];
|
|
634
|
-
privacyPreferences?: PrivacyPreferences | null;
|
|
635
|
-
};
|
|
636
|
-
export type State = {
|
|
637
|
-
isLoggedIn: boolean;
|
|
638
|
-
emergencyMode?: string[];
|
|
639
|
-
};
|
|
640
|
-
export type PrivacyPreferences = {
|
|
641
|
-
allowResearchUsage: boolean;
|
|
642
|
-
connectWithSurveys: boolean;
|
|
643
|
-
personalizedAds: boolean;
|
|
644
|
-
personalizedContent: boolean;
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
}
|
|
648
|
-
declare module '@amedia/user/utils/customEventWrapper' {
|
|
649
|
-
let rootElement: Window | Element | typeof globalThis;
|
|
650
|
-
export const setRootElement: (element: typeof rootElement) => void;
|
|
651
|
-
/**
|
|
652
|
-
* This listener MUST be used by all listeners in ../eventHandlers
|
|
653
|
-
* We want to ensure that only _one_ instance of this package actually
|
|
654
|
-
* orchestrates data and performs requests against backends.
|
|
655
|
-
* @param type
|
|
656
|
-
* @param listener
|
|
657
|
-
*/
|
|
658
|
-
export const listenWithExclusivity: <T extends keyof WindowEventMap>(type: T, listener: (this: typeof rootElement, ev: WindowEventMap[T]) => void) => void;
|
|
659
|
-
/**
|
|
660
|
-
* Use this for response listeners. (../index.ts) where we want
|
|
661
|
-
* all updates with data - no matter who sent the actual request
|
|
662
|
-
* @param type
|
|
663
|
-
* @param listener
|
|
664
|
-
*/
|
|
665
|
-
export const listenForAllEvents: <T extends keyof WindowEventMap>(type: T, listener: (this: typeof rootElement, ev: WindowEventMap[T]) => void) => void;
|
|
666
|
-
export const dispatch: <T extends Event>(event: T) => void;
|
|
667
|
-
export {};
|
|
668
|
-
|
|
669
|
-
}
|
|
670
|
-
declare module '@amedia/user/utils/customEventWrapper.spec' {
|
|
671
|
-
export {};
|
|
672
|
-
|
|
673
|
-
}
|
|
674
|
-
declare module '@amedia/user/utils/debouncer' {
|
|
675
|
-
/**
|
|
676
|
-
* The Debouncer can be used when we want a clean way to say 'I want to fetch this and that, and once it's done,
|
|
677
|
-
* resolve my promise', but instead of the fetch being performed right away, we want to wait for more users to
|
|
678
|
-
* request other stuff. This will keep us from performing lots of individual fetches to the backend.
|
|
679
|
-
*
|
|
680
|
-
* Our main use case is a standard site front page where one component on the page requests the euucp namespace
|
|
681
|
-
* from Europa, and then another component requests the privacy_preferences namespace. Instead of the Europa client
|
|
682
|
-
* calling two fetches to the server, one for euucp and another for privacy_preferences, we want the Debouncer to
|
|
683
|
-
* aggregate these calls into one call to the backend, that requests both euucp AND privacy_preferences, so the response
|
|
684
|
-
* to both components will be both namespaces (which the Europa client can filter before it actually reaches the
|
|
685
|
-
* component).
|
|
686
|
-
*/
|
|
687
|
-
class Debouncer<ParamsType, ResultType> {
|
|
688
|
-
private timeoutMs;
|
|
689
|
-
private defaultParams;
|
|
690
|
-
private paramAccumulator;
|
|
691
|
-
private workload;
|
|
692
|
-
private timer;
|
|
693
|
-
private params;
|
|
694
|
-
private queue;
|
|
695
|
-
constructor(timeoutMs: number, defaultParams: ParamsType, paramAccumulator: (previousParams: ParamsType, newParams: ParamsType) => ParamsType, workload: (params: ParamsType) => Promise<ResultType>);
|
|
696
|
-
static stringListParamsAccumulator(accumulatedParams: string[], newParams: string[]): string[];
|
|
697
|
-
static stringMapParamsAccumulator(previousParams: Record<string, any>, newParams: Record<string, any>): any;
|
|
698
|
-
perform(newParams: ParamsType): Promise<ResultType>;
|
|
699
|
-
}
|
|
700
|
-
export default Debouncer;
|
|
701
|
-
|
|
702
|
-
}
|
|
703
|
-
declare module '@amedia/user/utils/debouncer.spec' {
|
|
704
|
-
export {};
|
|
705
|
-
|
|
706
|
-
}
|
|
707
|
-
declare module '@amedia/user/utils/deepEquals' {
|
|
708
|
-
export const deepEquals: (a: unknown, b: unknown) => boolean;
|
|
709
|
-
|
|
710
|
-
}
|
|
711
|
-
declare module '@amedia/user/utils/expectBootLogs' {
|
|
712
|
-
const _default: () => void;
|
|
713
|
-
export default _default;
|
|
714
|
-
|
|
715
|
-
}
|
|
716
|
-
declare module '@amedia/user/utils/getGlobalThis' {
|
|
717
|
-
const getGlobalThis: () => typeof globalThis;
|
|
718
|
-
export default getGlobalThis;
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
declare module '@amedia/user/utils/getOrUpdate' {
|
|
722
|
-
import { Runtype, Static } from 'runtypes';
|
|
723
|
-
export type DataFetcherWithCacheTTL<T extends Runtype> = Promise<{
|
|
724
|
-
ttl: number;
|
|
725
|
-
data: Static<T>;
|
|
726
|
-
}>;
|
|
727
|
-
export default function getOrUpdate<T extends Runtype>(key: string, schema: T, fetch: () => DataFetcherWithCacheTTL<T>, cacheQualifier?: (cacheData: Static<T>) => boolean): Promise<Static<T>>;
|
|
728
|
-
|
|
729
|
-
}
|
|
730
|
-
declare module '@amedia/user/utils/getOrUpdate.spec' {
|
|
731
|
-
export {};
|
|
732
|
-
|
|
733
|
-
}
|
|
734
|
-
declare module '@amedia/user/utils/localhostCheck' {
|
|
735
|
-
export const isRunningOnLocalhost: () => boolean;
|
|
736
|
-
|
|
737
|
-
}
|
|
738
|
-
declare module '@amedia/user/utils/location' {
|
|
739
|
-
export const reload: () => void;
|
|
740
|
-
export const replace: (url: string) => void;
|
|
741
|
-
export const navigateTo: (url: string) => void;
|
|
742
|
-
|
|
743
|
-
}
|
|
744
|
-
declare module '@amedia/user/utils/location.spec' {
|
|
745
|
-
export {};
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
declare module '@amedia/user/utils/log' {
|
|
749
|
-
export type Logger = {
|
|
750
|
-
debug: (message: string | Error | any, context?: any) => void;
|
|
751
|
-
info: (message: string | Error | any, context?: any) => void;
|
|
752
|
-
warn: (message: string | Error | any, context?: any) => void;
|
|
753
|
-
error: (message: string | Error | any, context?: any) => void;
|
|
754
|
-
};
|
|
755
|
-
export const setLogger: (engine: Logger) => void;
|
|
756
|
-
const _default: Logger;
|
|
757
|
-
export default _default;
|
|
758
|
-
|
|
759
|
-
}
|
|
760
|
-
declare module '@amedia/user/utils/log.spec' {
|
|
761
|
-
export {};
|
|
762
|
-
|
|
763
|
-
}
|
|
764
|
-
declare module '@amedia/user/utils/loginState' {
|
|
765
|
-
export const whenLoginStateResolved: () => Promise<boolean>;
|
|
766
|
-
export const whenIsLoggedIn: () => Promise<void>;
|
|
767
|
-
|
|
768
|
-
}
|
|
769
|
-
declare module '@amedia/user/utils/networkError' {
|
|
770
|
-
export const isAbortedNetworkError: (message?: string | undefined) => boolean;
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
declare module '@amedia/user/utils/queue' {
|
|
774
|
-
const _default: {
|
|
775
|
-
add: (key: string, promiseCallbacks: {
|
|
776
|
-
resolve: (arg0?: any) => void;
|
|
777
|
-
reject: (reason?: any) => void;
|
|
778
|
-
}) => void;
|
|
779
|
-
getAll: (key: string) => {
|
|
780
|
-
resolve: (arg0?: any) => void;
|
|
781
|
-
reject: (reason?: any) => void;
|
|
782
|
-
}[];
|
|
783
|
-
peekQueueSize: (key: string) => number;
|
|
784
|
-
};
|
|
785
|
-
export default _default;
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
declare module '@amedia/user/utils/type' {
|
|
789
|
-
export const isFunction: (argument: unknown) => argument is Function;
|
|
790
|
-
export const isRecord: (argument: unknown) => argument is Record<string, unknown>;
|
|
791
|
-
export const isError: (argument: unknown) => argument is Error;
|
|
792
|
-
export const isString: (argument: unknown) => argument is string;
|
|
793
|
-
export const isNumber: (argument: unknown) => argument is number;
|
|
794
|
-
export const isBoolean: (argument: unknown) => argument is boolean;
|
|
795
|
-
|
|
796
|
-
}
|
|
797
|
-
declare module '@amedia/user/utils/url' {
|
|
798
|
-
export const setCurrentHostname: (hostname: string) => void;
|
|
799
|
-
export const getCurrentHostname: () => string;
|
|
800
|
-
export const getCurrentUrl: () => string;
|
|
801
|
-
export const getCurrentEnvironment: () => string | null;
|
|
802
|
-
export const getCurrentSiteDomain: () => string;
|
|
803
|
-
export const getAidDomain: () => string;
|
|
804
|
-
|
|
805
|
-
}
|
|
806
|
-
declare module '@amedia/user/utils/url.spec' {
|
|
807
|
-
export {};
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
declare module '@amedia/user' {
|
|
811
|
-
import main = require('@amedia/user/src/index');
|
|
812
|
-
export = main;
|
|
813
|
-
}
|
|
1
|
+
import * as rt from 'runtypes';
|
|
2
|
+
|
|
3
|
+
declare type UserAttributes = {
|
|
4
|
+
uuid?: string | null;
|
|
5
|
+
name?: string | null;
|
|
6
|
+
trackingKey?: string | null;
|
|
7
|
+
avatar?: string | null;
|
|
8
|
+
extraData?: {
|
|
9
|
+
[index: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
access?: string[];
|
|
12
|
+
privacyPreferences?: PrivacyPreferences | null;
|
|
13
|
+
};
|
|
14
|
+
declare type State = {
|
|
15
|
+
isLoggedIn: boolean;
|
|
16
|
+
emergencyMode?: string[];
|
|
17
|
+
};
|
|
18
|
+
declare type PrivacyPreferences = {
|
|
19
|
+
allowResearchUsage: boolean;
|
|
20
|
+
connectWithSurveys: boolean;
|
|
21
|
+
personalizedAds: boolean;
|
|
22
|
+
personalizedContent: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
declare type Millis = number;
|
|
26
|
+
declare class UserDataRequest<UA extends UserAttributes, S extends {
|
|
27
|
+
[index: string]: unknown;
|
|
28
|
+
}, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends Record<string, object> = {
|
|
29
|
+
state: State;
|
|
30
|
+
}> {
|
|
31
|
+
private attributes?;
|
|
32
|
+
private namespaces?;
|
|
33
|
+
static FETCH_TIMEOUT: Millis;
|
|
34
|
+
private fetchTimeoutId;
|
|
35
|
+
private lastReceivedData?;
|
|
36
|
+
constructor(attributes?: Attributes | undefined, namespaces?: Namespaces | undefined);
|
|
37
|
+
withAttributes<NewAttributes extends Array<keyof UA>>(attributes: NewAttributes): UserDataRequest<UA, S, (Attributes[number] & NewAttributes[number])[], Namespaces, SubscribeResponse & {
|
|
38
|
+
attributes: Pick<UA, Attributes[number] & NewAttributes[number]>;
|
|
39
|
+
}>;
|
|
40
|
+
withStorage<NewNamespaces extends Array<string>>(namespaces: NewNamespaces): UserDataRequest<UA, S, Attributes, (Namespaces[number] & NewNamespaces[number])[], SubscribeResponse & {
|
|
41
|
+
storage: Pick<S, Namespaces[number] & NewNamespaces[number]>;
|
|
42
|
+
}>;
|
|
43
|
+
subscribe(onData: (data: SubscribeResponse) => void): void;
|
|
44
|
+
fetch(options?: {
|
|
45
|
+
timeout?: Millis;
|
|
46
|
+
}): Promise<SubscribeResponse>;
|
|
47
|
+
private clearFetchTimeout;
|
|
48
|
+
private startFetchTimeout;
|
|
49
|
+
private processUserAttributesEvent;
|
|
50
|
+
private processStorageEvent;
|
|
51
|
+
private setupLocalCache;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare enum AffiliationType {
|
|
55
|
+
ACCESS = "access",
|
|
56
|
+
FAMILY = "family",
|
|
57
|
+
SUBSCRIPTION = "subscription"
|
|
58
|
+
}
|
|
59
|
+
declare const PrimarySiteSchema: rt.Record<{
|
|
60
|
+
domain: rt.String;
|
|
61
|
+
name: rt.String;
|
|
62
|
+
affiliation: rt.Literal<AffiliationType.ACCESS>;
|
|
63
|
+
affiliations: rt.Array<rt.Union<[rt.Literal<AffiliationType.ACCESS>, rt.Literal<AffiliationType.FAMILY>, rt.Literal<AffiliationType.SUBSCRIPTION>]>, false>;
|
|
64
|
+
}, false>;
|
|
65
|
+
declare type PrimarySite = rt.Static<typeof PrimarySiteSchema>;
|
|
66
|
+
|
|
67
|
+
declare type UnlockResponse = {
|
|
68
|
+
isLoggedIn: boolean;
|
|
69
|
+
hasAccess: boolean;
|
|
70
|
+
primarySite?: null | PrimarySite;
|
|
71
|
+
accessFeatures: string[];
|
|
72
|
+
};
|
|
73
|
+
declare class PaywallUnlockRequest {
|
|
74
|
+
private requestedAccessFeatures;
|
|
75
|
+
private reload;
|
|
76
|
+
private requestedUrl;
|
|
77
|
+
private siteDomain;
|
|
78
|
+
withSiteDomain(domain: string): this;
|
|
79
|
+
withAccessFeatures(accessFeatures: string[]): this;
|
|
80
|
+
reloadOnAccess(): this;
|
|
81
|
+
redirectOnAccess(requestedUrl: string): this;
|
|
82
|
+
tryUnlock(): Promise<UnlockResponse>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare class FetchTimeoutError extends Error {
|
|
86
|
+
partialData: Record<string, object>;
|
|
87
|
+
constructor(message: string, partialData: Record<string, object>);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare class PaywallError extends Error {
|
|
91
|
+
static ERROR_RELOADED_NO_ACCESS: string;
|
|
92
|
+
static ERROR_ENABLING_ACCESS_FAILED: string;
|
|
93
|
+
static ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES: string;
|
|
94
|
+
code: string;
|
|
95
|
+
constructor(message: string, code: string);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* This will, if necessary, trigger a redirect to www.aid.no and return
|
|
100
|
+
* to the requestedUrl if supplied or the current url before redirecting away if not.
|
|
101
|
+
* @param requestedUrl
|
|
102
|
+
*/
|
|
103
|
+
declare const goToLoginPage: (requestedUrl?: string | undefined) => void;
|
|
104
|
+
declare const getLoginUrl: (requestedUrl?: string | undefined) => URL;
|
|
105
|
+
declare const logout: () => Promise<void>;
|
|
106
|
+
declare const updateStorage: (storage: {
|
|
107
|
+
[index: string]: Object;
|
|
108
|
+
}) => void;
|
|
109
|
+
declare const saveStorage: (storage: {
|
|
110
|
+
[index: string]: Object;
|
|
111
|
+
}) => void;
|
|
112
|
+
|
|
113
|
+
export { FetchTimeoutError, PaywallError, PaywallUnlockRequest, PrivacyPreferences, State, UserAttributes, UserDataRequest, getLoginUrl, goToLoginPage, logout, saveStorage, updateStorage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amedia/user",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.37",
|
|
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)",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"module": "dist/user.js",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"import": "./dist/user.js"
|
|
11
|
+
"import": "./dist/user.js",
|
|
12
|
+
"default": "./dist/user.js"
|
|
12
13
|
}
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
@@ -19,8 +20,9 @@
|
|
|
19
20
|
"test": "jest --coverage",
|
|
20
21
|
"clean-dist": "rm -rf ./dist",
|
|
21
22
|
"lint": "eslint ./src --ext .ts",
|
|
22
|
-
"build": "npm install && node build.js",
|
|
23
|
-
"
|
|
23
|
+
"build": "npm install && node build.js & npm run build:types",
|
|
24
|
+
"build:types": "npx rollup -c ./types.js",
|
|
25
|
+
"dev": "concurrently --kill-others \"node build.js --watch\" \"node server.js\"",
|
|
24
26
|
"typings": "tsc --noEmit",
|
|
25
27
|
"checkVersion": "node --experimental-json-modules checkVersion.js",
|
|
26
28
|
"stub-npmjs-package": "find ./dist -type f ! -name '*.d.ts' -delete && cp -v stubs/* dist/.",
|
|
@@ -35,31 +37,33 @@
|
|
|
35
37
|
"ts-deepmerge": "^2.0.1"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
|
-
"@amedia/eslint-config-base": "
|
|
39
|
-
"@amedia/eslint-config-typescript": "
|
|
40
|
+
"@amedia/eslint-config-base": "6.0.0",
|
|
41
|
+
"@amedia/eslint-config-typescript": "6.0.0",
|
|
40
42
|
"@babel/eslint-parser": "^7.17.0",
|
|
41
43
|
"@eik/cli": "^2.0.22",
|
|
42
44
|
"@eik/esbuild-plugin": "^1.1.7",
|
|
43
45
|
"@types/jest": "^27.4.1",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
45
|
-
"@typescript-eslint/parser": "^5.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
47
|
+
"@typescript-eslint/parser": "^5.20.0",
|
|
48
|
+
"concurrently": "^7.1.0",
|
|
46
49
|
"cors": "^2.8.5",
|
|
47
|
-
"esbuild": "
|
|
48
|
-
"eslint": "^8.
|
|
49
|
-
"eslint-config-airbnb-typescript": "^
|
|
50
|
+
"esbuild": "0.14.36",
|
|
51
|
+
"eslint": "^8.13.0",
|
|
52
|
+
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
50
53
|
"eslint-config-prettier": "^8.5.0",
|
|
51
|
-
"eslint-plugin-import": "^2.
|
|
54
|
+
"eslint-plugin-import": "^2.26.0",
|
|
52
55
|
"eslint-plugin-prettier": "^4.0.0",
|
|
53
56
|
"express": "^4.17.3",
|
|
54
57
|
"jest": "^27.5.1",
|
|
55
58
|
"jest-extended": "^2.0.0",
|
|
56
59
|
"jest-fetch-mock": "^3.0.3",
|
|
57
60
|
"mockdate": "^3.0.5",
|
|
58
|
-
"npm-dts": "^1.3.11",
|
|
59
61
|
"npm-run-all": "^4.1.5",
|
|
60
|
-
"prettier": "^2.6.
|
|
61
|
-
"
|
|
62
|
+
"prettier": "^2.6.2",
|
|
63
|
+
"rollup": "2.70.2",
|
|
64
|
+
"rollup-plugin-dts": "4.2.1",
|
|
65
|
+
"ts-jest": "^27.1.4",
|
|
62
66
|
"tslib": "^2.3.1",
|
|
63
|
-
"typescript": "^4.6.
|
|
67
|
+
"typescript": "^4.6.3"
|
|
64
68
|
}
|
|
65
69
|
}
|