@amedia/user 0.13.12 → 0.13.15

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/index.d.ts CHANGED
@@ -1,17 +1,696 @@
1
- import { hasAccess } from './actions/authorization';
2
- export { default as UserDataRequest } from './lib/UserDataRequest';
3
- export { default as PaywallUnlockRequest } from './lib/PaywallUnlockRequest';
4
- /**
5
- * This will, if necessary, trigger a redirect to www.aid.no and return
6
- * to the requestedUrl if supplied or the current url before redirecting away if not.
7
- * @param requestedUrl
8
- */
9
- export declare const goToLoginPage: (requestedUrl?: string | undefined) => void;
10
- export declare const logout: () => Promise<void>;
11
- export declare const tryActivateSubscriptionAccess: (requestedAccessFeatures: string[]) => Promise<{
12
- hasAccess: boolean;
13
- accessFeatures: string[];
14
- }>;
15
- export declare const updateStorage: (storage: {
16
- [index: string]: Object;
17
- }) => void;
1
+ declare module '@amedia/user/actions/authentication' {
2
+ import { UserAttributes } from '@amedia/user/types';
3
+ export const login: (requestedUrl: URL | string) => void;
4
+ export const logout: () => Promise<void>;
5
+ export const getSession: () => Promise<UserAttributes>;
6
+
7
+ }
8
+ declare module '@amedia/user/actions/authentication.spec' {
9
+ /**
10
+ * @jest-environment jsdom
11
+ */
12
+ export {};
13
+
14
+ }
15
+ declare module '@amedia/user/actions/authorization' {
16
+ import { UserAttributes } from '@amedia/user/types';
17
+ type SetCookieResponse = {
18
+ success: boolean;
19
+ accessFeatures: string[];
20
+ };
21
+ export const getAccess: (accessFeatures?: string[]) => Promise<Pick<UserAttributes, 'access'>>;
22
+ export const activate: (accessFeatures: string[]) => Promise<string[]>;
23
+ export const hasAccess: (currentAccessFeatures: string[], requestedAccessFeatures: string[]) => boolean;
24
+ export const setUserAccessCookie: (publicationDomain: any) => Promise<SetCookieResponse>;
25
+ export const setNonUserAccessCookie: (publicationDomain: any) => Promise<SetCookieResponse>;
26
+ export const setAccessCookies: (publicationDomain: any) => Promise<SetCookieResponse>;
27
+ export const setHasPerformedPaywallReload: (requestedUrl?: any) => void;
28
+ export const hasRecentlyPerformedPaywallReload: (requestedUrl?: any) => boolean;
29
+ export {};
30
+
31
+ }
32
+ declare module '@amedia/user/actions/authorization.spec' {
33
+ /**
34
+ * @jest-environment jsdom
35
+ */
36
+ export {};
37
+
38
+ }
39
+ declare module '@amedia/user/actions/preferences' {
40
+ import { Record, Boolean } from 'runtypes';
41
+ import { UserAttributes } from '@amedia/user/types';
42
+ export const PrivacyPreferencesSchema: Record<{
43
+ allowResearchUsage: Boolean;
44
+ connectWithSurveys: Boolean;
45
+ personalizedAds: Boolean;
46
+ personalizedContent: Boolean;
47
+ }, false>;
48
+ export const getPrivacyPreferences: () => Promise<Pick<UserAttributes, 'privacyPreferences'>>;
49
+
50
+ }
51
+ declare module '@amedia/user/actions/preferences.spec' {
52
+ export {};
53
+
54
+ }
55
+ declare module '@amedia/user/actions/storage' {
56
+ export const requestStorage: (namespaces: string[]) => void;
57
+ export const updateStorage: (storage: {
58
+ [namespace: string]: object;
59
+ }) => void;
60
+
61
+ }
62
+ declare module '@amedia/user/actions/userData' {
63
+ import { UserAttributes } from '@amedia/user/types';
64
+ export const requestAttributes: (attributes: Array<keyof UserAttributes>) => Promise<void>;
65
+
66
+ }
67
+ declare module '@amedia/user/actions/userData.spec' {
68
+ export {};
69
+
70
+ }
71
+ declare module '@amedia/user/autologin/index' {
72
+ export const AUTOLOGIN_COOKIE_TTL = 60000;
73
+ export const attemptAutoLoginJob: () => Promise<void>;
74
+ export const attemptPaywallAutoLogin: () => Promise<void>;
75
+
76
+ }
77
+ declare module '@amedia/user/autologin/index.spec' {
78
+ /**
79
+ * @jest-environment jsdom
80
+ */
81
+ export {};
82
+
83
+ }
84
+ declare module '@amedia/user/autologin/thirdPartyCookie' {
85
+ export const CACHE_KEY = "haveTriedThirdPartyLoginCheck";
86
+ export const CACHE_TTL: number;
87
+ export default function thirdPartyCookie(): Promise<boolean>;
88
+
89
+ }
90
+ declare module '@amedia/user/autologin/thirdPartyCookie.spec' {
91
+ export {};
92
+
93
+ }
94
+ declare module '@amedia/user/cache/engines/global' {
95
+ import { CacheEntry, Engine } from '@amedia/user/cache/types';
96
+ global {
97
+ interface Window {
98
+ amediaUserCache?: {
99
+ [index: string]: CacheEntry;
100
+ };
101
+ }
102
+ namespace NodeJS {
103
+ interface Global {
104
+ amediaUserCache?: {
105
+ [index: string]: CacheEntry;
106
+ };
107
+ }
108
+ }
109
+ }
110
+ export const get: (key: string) => Promise<CacheEntry>;
111
+ export const set: (key: string, data: unknown, expires: number) => Promise<void>;
112
+ export const remove: (key: string) => Promise<void>;
113
+ export const clear: () => Promise<void>;
114
+ const _default: Engine;
115
+ export default _default;
116
+
117
+ }
118
+ declare module '@amedia/user/cache/engines/global.spec' {
119
+ export {};
120
+
121
+ }
122
+ declare module '@amedia/user/cache/index' {
123
+ import { Static } from 'runtypes';
124
+ import { RuntypeBase } from 'runtypes/lib/runtype';
125
+ import { Engine } from '@amedia/user/cache/types';
126
+ export const setCacheEngine: (engine: Engine) => void;
127
+ const _default: {
128
+ get: <T extends RuntypeBase<unknown>>(key: string, validator: T) => Promise<void | Static<T>>;
129
+ set: (key: string, value: unknown, expires: number) => Promise<void>;
130
+ remove: (key: string) => Promise<void>;
131
+ clear: () => Promise<void>;
132
+ };
133
+ export default _default;
134
+
135
+ }
136
+ declare module '@amedia/user/cache/index.spec' {
137
+ /**
138
+ * @jest-environment jsdom
139
+ */
140
+ export {};
141
+
142
+ }
143
+ declare module '@amedia/user/cache/types' {
144
+ export type CacheEntry = {
145
+ key: string;
146
+ data: unknown;
147
+ expires: number;
148
+ };
149
+ export type Engine = {
150
+ get: (key: string) => Promise<CacheEntry | null>;
151
+ set: (key: string, data: unknown, expires: number) => Promise<void>;
152
+ remove: (key: string) => Promise<void>;
153
+ clear: () => Promise<void>;
154
+ };
155
+
156
+ }
157
+ declare module '@amedia/user/clients/europa' {
158
+ import { Record, Unknown, Dictionary } from 'runtypes';
159
+ export const EuropaSchema: Record<{
160
+ namespaces: Dictionary<Unknown, string>;
161
+ }, false>;
162
+ export const clearLocalCache: () => Promise<void>;
163
+ export const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
164
+ export const getNamespaces: <S extends {
165
+ [namespace: string]: {
166
+ [index: string]: unknown;
167
+ };
168
+ }, Namespaces extends (keyof S)[]>(namespaces: Namespaces, options?: {
169
+ ignoreCache: boolean;
170
+ }) => Promise<Pick<S, Namespaces[number]>>;
171
+ export const saveNamespace: (namespace: string, data: Object) => Promise<Pick<{
172
+ [namespace: string]: {
173
+ [index: string]: unknown;
174
+ };
175
+ }, string>>;
176
+ export const getAllNamespaces: () => Promise<{
177
+ namespaces: {
178
+ [x: string]: unknown;
179
+ };
180
+ }>;
181
+ export const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<{
182
+ [namespace: string]: {
183
+ [index: string]: unknown;
184
+ };
185
+ }, string>>;
186
+
187
+ }
188
+ declare module '@amedia/user/clients/europa.spec' {
189
+ export {};
190
+
191
+ }
192
+ declare module '@amedia/user/clients/jupiter' {
193
+ import { Array, Literal, Number, Record, Static, String, Union } from 'runtypes';
194
+ import { UserAttributes } from '@amedia/user/types';
195
+ export type AccessFeatures = string[];
196
+ export const CheckAccessForPaperSchema: Record<{
197
+ status: Literal<"success">;
198
+ access: Union<[Literal<"granted">, Literal<"denied">]>;
199
+ publication: Record<{
200
+ id: Number;
201
+ domain: String;
202
+ }, false>;
203
+ access_features: Array<String, false>;
204
+ }, false>;
205
+ export type CheckAccessForPaper = Static<typeof CheckAccessForPaperSchema>;
206
+ const GetVstokenSchema: Record<{
207
+ status: Literal<"success">;
208
+ cookie: String;
209
+ access_features: Array<String, false>;
210
+ }, false>;
211
+ export type GetVstoken = Static<typeof GetVstokenSchema>;
212
+ const GetNonUserAccessSchema: Record<{
213
+ status: Literal<"success">;
214
+ vstoken_cookie: String;
215
+ uuid: String;
216
+ access_features: Array<String, false>;
217
+ }, false>;
218
+ export type GetNonUserAccess = Static<typeof GetNonUserAccessSchema>;
219
+ export const checkForAccess: (publicationDomain: string, accessFeatures: AccessFeatures) => Promise<Pick<UserAttributes, 'access'>>;
220
+ export const getUserAccess: (publicationDomain: string) => Promise<GetVstoken>;
221
+ export const getNonUserAccess: (publicationDomain: string) => Promise<GetNonUserAccess>;
222
+ export {};
223
+
224
+ }
225
+ declare module '@amedia/user/clients/jupiter.spec' {
226
+ export {};
227
+
228
+ }
229
+ declare module '@amedia/user/clients/mercury' {
230
+ export class UserDeactivatedError extends Error {
231
+ }
232
+ export const activateSubscription: (accessFeatures: string[]) => Promise<string[]>;
233
+
234
+ }
235
+ declare module '@amedia/user/clients/mercury.spec' {
236
+ /**
237
+ * @jest-environment jsdom
238
+ */
239
+ export {};
240
+
241
+ }
242
+ declare module '@amedia/user/clients/mercuryLog' {
243
+ const log: {
244
+ error: (message: string, context: Object) => void;
245
+ warn: (message: string, context: Object) => void;
246
+ info: (message: string, context: Object) => void;
247
+ debug: (message: string, context: Object) => void;
248
+ };
249
+ export default log;
250
+
251
+ }
252
+ declare module '@amedia/user/clients/mercuryLog.spec' {
253
+ /**
254
+ * @jest-environment jsdom
255
+ */
256
+ export {};
257
+
258
+ }
259
+ declare module '@amedia/user/clients/nebula' {
260
+ import { UserAttributes } from '@amedia/user/types';
261
+ export const getInfo: (publicationDomain: string, browserId: string, trackingKey?: string | undefined) => Promise<Pick<UserAttributes, 'extraData'>>;
262
+
263
+ }
264
+ declare module '@amedia/user/clients/nebula.spec' {
265
+ export {};
266
+
267
+ }
268
+ declare module '@amedia/user/clients/pluto' {
269
+ import { UserAttributes } from '@amedia/user/types';
270
+ export const resolveBadPlutoResponse: (response: Response) => Promise<void>;
271
+ export const getCurrentSession: () => Promise<UserAttributes>;
272
+ export const removeSession: (domain: string) => Promise<void>;
273
+
274
+ }
275
+ declare module '@amedia/user/clients/pluto.spec' {
276
+ export {};
277
+
278
+ }
279
+ declare module '@amedia/user/eventHandlers/activation' {
280
+ export enum ActivationEvents {
281
+ REQUEST_ACTIVATION = "amedia-user.activation.request-activation",
282
+ ON_ACTIVATION_COMPLETE = "amedia-user.activation.on-activation-complete"
283
+ }
284
+ global {
285
+ interface WindowEventMap {
286
+ [ActivationEvents.REQUEST_ACTIVATION]: CustomEvent<{
287
+ accessFeatures: string[];
288
+ }>;
289
+ [ActivationEvents.ON_ACTIVATION_COMPLETE]: CustomEvent<{
290
+ accessFeatures: string[];
291
+ }>;
292
+ }
293
+ }
294
+ export const listenForActivationRequests: () => void;
295
+
296
+ }
297
+ declare module '@amedia/user/eventHandlers/authentication' {
298
+ export enum AuthenticationEvents {
299
+ REQUEST_LOGIN = "amedia-user.authentication.request-login",
300
+ REQUEST_LOGOUT = "amedia-user.authentication.request-logout",
301
+ ON_LOGGED_OUT = "amedia-user.authentication.on-logged-out"
302
+ }
303
+ global {
304
+ interface WindowEventMap {
305
+ [AuthenticationEvents.REQUEST_LOGIN]: CustomEvent<{
306
+ requestedUrl: string;
307
+ }>;
308
+ [AuthenticationEvents.REQUEST_LOGOUT]: CustomEvent<{
309
+ onLoggedOut: () => void;
310
+ }>;
311
+ [AuthenticationEvents.ON_LOGGED_OUT]: CustomEvent;
312
+ }
313
+ }
314
+ export const listenForAuthenticationRequests: () => void;
315
+
316
+ }
317
+ declare module '@amedia/user/eventHandlers/eventMap' {
318
+ import { State, UserAttributes } from '@amedia/user/types';
319
+ export enum AmediaUserEvents {
320
+ REQUEST_STATE = "amedia-user.request-state",
321
+ REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
322
+ REQUEST_STORAGE_NAMESPACES = "amedia-user.request-storage-namespaces",
323
+ UPDATE_STORAGE = "amedua-user.update-storage-namespaces",
324
+ ON_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated",
325
+ ON_STATE_UPDATED = "amedia-user.on-state-updated",
326
+ ON_STORAGE_UPDATED = "amedia-user.on-storage-updated"
327
+ }
328
+ global {
329
+ interface WindowEventMap {
330
+ [AmediaUserEvents.REQUEST_STATE]: CustomEvent;
331
+ [AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
332
+ [AmediaUserEvents.REQUEST_STORAGE_NAMESPACES]: CustomEvent<Array<string>>;
333
+ [AmediaUserEvents.UPDATE_STORAGE]: CustomEvent<{
334
+ [namespace: string]: object;
335
+ }>;
336
+ [AmediaUserEvents.ON_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
337
+ [AmediaUserEvents.ON_STATE_UPDATED]: CustomEvent<State>;
338
+ [AmediaUserEvents.ON_STORAGE_UPDATED]: CustomEvent<{
339
+ [index: string]: unknown;
340
+ }>;
341
+ }
342
+ }
343
+
344
+ }
345
+ declare module '@amedia/user/eventHandlers/state' {
346
+ export const listenForStateRequests: () => void;
347
+
348
+ }
349
+ declare module '@amedia/user/eventHandlers/state.spec' {
350
+ /**
351
+ * @jest-environment jsdom
352
+ */
353
+ export {};
354
+
355
+ }
356
+ declare module '@amedia/user/eventHandlers/storage' {
357
+ export const listenForStorageRequests: () => void;
358
+
359
+ }
360
+ declare module '@amedia/user/eventHandlers/storage.spec' {
361
+ /**
362
+ * @jest-environment jsdom
363
+ */
364
+ export {};
365
+
366
+ }
367
+ declare module '@amedia/user/eventHandlers/userAttributes' {
368
+ export const listenForUserAttributeRequests: () => void;
369
+
370
+ }
371
+ declare module '@amedia/user/eventHandlers/userAttributes.spec' {
372
+ /**
373
+ * @jest-environment jsdom
374
+ */
375
+ export {};
376
+
377
+ }
378
+ declare module '@amedia/user/exceptions/PaywallError' {
379
+ class PaywallError extends Error {
380
+ static ERROR_RELOADED_NO_ACCESS: string;
381
+ static ERROR_ENABLING_ACCESS_FAILED: string;
382
+ static ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES: string;
383
+ code: string;
384
+ constructor(message: string, code: string);
385
+ }
386
+ export default PaywallError;
387
+
388
+ }
389
+ declare module '@amedia/user/index-authentcation.spec' {
390
+ /**
391
+ * @jest-environment jsdom
392
+ */
393
+ export {};
394
+
395
+ }
396
+ declare module '@amedia/user/index-storage.spec' {
397
+ /**
398
+ * @jest-environment jsdom
399
+ */
400
+ export {};
401
+
402
+ }
403
+ declare module '@amedia/user/index-subscription.spec' {
404
+ /**
405
+ * @jest-environment jsdom
406
+ */
407
+ export {};
408
+
409
+ }
410
+ declare module '@amedia/user/index' {
411
+ import { hasAccess } from '@amedia/user/actions/authorization';
412
+ export { default as UserDataRequest } from '@amedia/user/lib/UserDataRequest';
413
+ export { default as PaywallUnlockRequest } from '@amedia/user/lib/PaywallUnlockRequest';
414
+ /**
415
+ * This will, if necessary, trigger a redirect to www.aid.no and return
416
+ * to the requestedUrl if supplied or the current url before redirecting away if not.
417
+ * @param requestedUrl
418
+ */
419
+ export const goToLoginPage: (requestedUrl?: string | undefined) => void;
420
+ export const logout: () => Promise<void>;
421
+ export const tryActivateSubscriptionAccess: (requestedAccessFeatures: string[]) => Promise<{
422
+ hasAccess: boolean;
423
+ accessFeatures: string[];
424
+ }>;
425
+ export const updateStorage: (storage: {
426
+ [index: string]: Object;
427
+ }) => void;
428
+
429
+ }
430
+ declare module '@amedia/user/janitor/index' {
431
+ enum JanitorEvents {
432
+ LOADED = "amedia-user.janitor.loaded"
433
+ }
434
+ global {
435
+ interface WindowEventMap {
436
+ [JanitorEvents.LOADED]: CustomEvent<{}>;
437
+ }
438
+ }
439
+ export const runJanitor: () => Promise<void>;
440
+ export {};
441
+
442
+ }
443
+ declare module '@amedia/user/janitor/jobs/accessCookieRefresher' {
444
+ export default function accessCookieRefresher(): Promise<[void, void]>;
445
+
446
+ }
447
+ declare module '@amedia/user/janitor/jobs/accessCookieRefresher.spec' {
448
+ /**
449
+ * @jest-environment jsdom
450
+ */
451
+ export {};
452
+
453
+ }
454
+ declare module '@amedia/user/janitor/jobs/removeUserStorage' {
455
+ export function removeUserStorage(): void;
456
+
457
+ }
458
+ declare module '@amedia/user/janitor/jobs/removeUserStorage.spec' {
459
+ export {};
460
+
461
+ }
462
+ declare module '@amedia/user/lib/PaywallUnlockRequest' {
463
+ type UnlockResponse = {
464
+ isLoggedIn: boolean;
465
+ hasAccess: boolean;
466
+ accessFeatures: string[];
467
+ };
468
+ class PaywallUnlockRequest {
469
+ private requestedAccessFeatures;
470
+ private reload;
471
+ private requestedUrl;
472
+ withAccessFeatures(accessFeatures: string[]): this;
473
+ reloadOnAccess(): this;
474
+ redirectOnAccess(requestedUrl: string): this;
475
+ tryUnlock(): Promise<UnlockResponse>;
476
+ private setAccessCookiesAndGetAccessFeatures;
477
+ private activateAccess;
478
+ }
479
+ export default PaywallUnlockRequest;
480
+
481
+ }
482
+ declare module '@amedia/user/lib/PaywallUnlockRequest.spec' {
483
+ /**
484
+ * @jest-environment jsdom
485
+ */
486
+ export {};
487
+
488
+ }
489
+ declare module '@amedia/user/lib/UserDataRequest' {
490
+ import { State, UserAttributes } from '@amedia/user/types';
491
+ class UserDataRequest<UA extends UserAttributes, S extends {
492
+ [index: string]: unknown;
493
+ }, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends {} = {
494
+ state: State;
495
+ }> {
496
+ private attributes?;
497
+ private namespaces?;
498
+ constructor(attributes?: Attributes | undefined, namespaces?: Namespaces | undefined);
499
+ withAttributes<NewAttributes extends Array<keyof UA>>(attributes: NewAttributes): UserDataRequest<UA, S, (Attributes[number] & NewAttributes[number])[], Namespaces, SubscribeResponse & {
500
+ attributes: Pick<UA, Attributes[number] & NewAttributes[number]>;
501
+ }>;
502
+ withStorage<NewNamespaces extends Array<string>>(namespaces: NewNamespaces): UserDataRequest<UA, S, Attributes, (Namespaces[number] & NewNamespaces[number])[], SubscribeResponse & {
503
+ storage: Pick<S, Namespaces[number] & NewNamespaces[number]>;
504
+ }>;
505
+ subscribe(onData: (data: SubscribeResponse) => void): void;
506
+ fetch(): Promise<SubscribeResponse>;
507
+ private processUserAttributesEvent;
508
+ private processStorageEvent;
509
+ private setupLocalCache;
510
+ }
511
+ export default UserDataRequest;
512
+
513
+ }
514
+ declare module '@amedia/user/lib/UserDataRequest.spec' {
515
+ export {};
516
+
517
+ }
518
+ declare module '@amedia/user/lib/cookie' {
519
+ export const getCookie: (name: string) => string | {
520
+ [index: string]: unknown;
521
+ } | null | undefined;
522
+ export function setCookie(name: string, value?: unknown, validTimeInDateOrDays?: Date | number, path?: string, secure?: boolean): string;
523
+ export function removeCookie(name: string): void;
524
+ /**
525
+ * This function should only be used in tests, as it will remove all cookies a user has on the domain.
526
+ */
527
+ export function removeAllCookies(): void;
528
+
529
+ }
530
+ declare module '@amedia/user/lib/rpc' {
531
+ let rpcSessionClient: {
532
+ addMethod: (methodName: string) => void;
533
+ userAuthenticated: (boolean: any) => void;
534
+ };
535
+ export const getRPCClient: () => Pick<typeof rpcSessionClient, 'userAuthenticated'>;
536
+ export {};
537
+
538
+ }
539
+ declare module '@amedia/user/store/index' {
540
+ import { State, UserAttributes } from '@amedia/user/types';
541
+ type StoreDataMap = {
542
+ userAttributes: UserAttributes;
543
+ state: State;
544
+ storage: {
545
+ [namespace: string]: {
546
+ [index: string]: unknown;
547
+ };
548
+ };
549
+ };
550
+ type Listener<T> = (data: T) => void;
551
+ const _default: {
552
+ merge: <K extends keyof StoreDataMap>(key: K, value: Partial<StoreDataMap[K]>) => void;
553
+ set: (key: keyof StoreDataMap, value: UserAttributes | State | {
554
+ [namespace: string]: {
555
+ [index: string]: unknown;
556
+ };
557
+ }) => void;
558
+ get: <K_1 extends keyof StoreDataMap, T = StoreDataMap[K_1]>(key: K_1) => T | undefined;
559
+ on: <K_2 extends keyof StoreDataMap, T_1 = StoreDataMap[K_2]>(key: K_2, listener: Listener<T_1>) => void;
560
+ clear: () => void;
561
+ };
562
+ export default _default;
563
+
564
+ }
565
+ declare module '@amedia/user/store/index.spec' {
566
+ export {};
567
+
568
+ }
569
+ declare module '@amedia/user/types' {
570
+ export type UserAttributes = {
571
+ uuid?: string;
572
+ name?: string;
573
+ email?: string;
574
+ phone?: string;
575
+ trackingKey?: string;
576
+ extraData?: {
577
+ [index: string]: unknown;
578
+ };
579
+ access?: string[];
580
+ privacyPreferences?: PrivacyPreferences;
581
+ };
582
+ export type State = {
583
+ isLoggedIn: boolean;
584
+ emergencyMode?: string[];
585
+ };
586
+ export type PrivacyPreferences = {
587
+ allowResearchUsage: boolean;
588
+ connectWithSurveys: boolean;
589
+ personalizedAds: boolean;
590
+ personalizedContent: boolean;
591
+ };
592
+
593
+ }
594
+ declare module '@amedia/user/utils/customEventWrapper' {
595
+ export const setRootElement: (element: any) => void;
596
+ /**
597
+ * This listener MUST be used by all listeners in ../eventHandlers
598
+ * We want to ensure that only _one_ instance of this package actually
599
+ * orchestrates data and performs requests against backends.
600
+ * @param type
601
+ * @param listener
602
+ */
603
+ export const listenWithExclusivity: <T extends keyof WindowEventMap>(type: T, listener: (this: Window, ev: WindowEventMap[T]) => void) => void;
604
+ /**
605
+ * Use this for response listeners. (../index.ts) where we want
606
+ * all updates with data - no matter who sent the actual request
607
+ * @param type
608
+ * @param listener
609
+ */
610
+ export const listenForAllEvents: <T extends keyof WindowEventMap>(type: T, listener: (this: Window, ev: WindowEventMap[T]) => void) => void;
611
+ export const dispatch: <T extends Event>(event: T) => void;
612
+
613
+ }
614
+ declare module '@amedia/user/utils/deepEquals' {
615
+ /**
616
+ * @see https://dev.to/sanderdebr/deep-equality-checking-of-objects-in-vanilla-javascript-5592
617
+ */
618
+ export const deepEquals: (a: unknown, b: unknown) => boolean;
619
+
620
+ }
621
+ declare module '@amedia/user/utils/getOrUpdate' {
622
+ import { Runtype, Static } from 'runtypes';
623
+ export type DataFetcherWithCacheTTL<T extends Runtype> = Promise<{
624
+ ttl: number;
625
+ data: Static<T>;
626
+ }>;
627
+ export default function getOrUpdate<T extends Runtype>(key: string, schema: T, fetch: () => DataFetcherWithCacheTTL<T>, cacheQualifier?: (cacheData: Static<T>) => boolean): Promise<Static<T>>;
628
+
629
+ }
630
+ declare module '@amedia/user/utils/getOrUpdate.spec' {
631
+ export {};
632
+
633
+ }
634
+ declare module '@amedia/user/utils/location' {
635
+ export const reload: () => void;
636
+ export const replace: (requestedUrl: string) => void;
637
+ export const navigateTo: (url: string) => void;
638
+
639
+ }
640
+ declare module '@amedia/user/utils/log' {
641
+ export type Logger = {
642
+ debug: (message: string | Error, context?: Object) => void;
643
+ info: (message: string | Error, context?: Object) => void;
644
+ warn: (message: string | Error, context?: Object) => void;
645
+ error: (message: string | Error, context?: Object) => void;
646
+ };
647
+ export const setLogger: (engine: Logger) => void;
648
+ const _default: Logger;
649
+ export default _default;
650
+
651
+ }
652
+ declare module '@amedia/user/utils/log.spec' {
653
+ export {};
654
+
655
+ }
656
+ declare module '@amedia/user/utils/loginState' {
657
+ export const whenLoginStateResolved: () => Promise<boolean>;
658
+ export const whenIsLoggedIn: () => Promise<void>;
659
+
660
+ }
661
+ declare module '@amedia/user/utils/networkError' {
662
+ export const isAbortedNetworkError: (message: string) => boolean;
663
+
664
+ }
665
+ declare module '@amedia/user/utils/queue' {
666
+ const _default: {
667
+ add: (key: string, promiseCallbacks: {
668
+ resolve: (PromiseLike: any) => void;
669
+ reject: (reason?: any) => void;
670
+ }) => void;
671
+ getAll: (key: string) => {
672
+ resolve: (PromiseLike: any) => void;
673
+ reject: (reason?: any) => void;
674
+ }[];
675
+ peekQueueSize: (key: string) => number;
676
+ };
677
+ export default _default;
678
+
679
+ }
680
+ declare module '@amedia/user/utils/url' {
681
+ export const setCurrentHostname: (hostname: string) => void;
682
+ export const getCurrentHostname: () => string;
683
+ export const getCurrentUrl: () => string;
684
+ export const getCurrentEnvironment: () => string | null;
685
+ export const getCurrentPublicationDomain: () => string;
686
+ export const getAidDomain: () => string;
687
+
688
+ }
689
+ declare module '@amedia/user/utils/url.spec' {
690
+ export {};
691
+
692
+ }
693
+ declare module '@amedia/user' {
694
+ import main = require('@amedia/user/src/index');
695
+ export = main;
696
+ }