@amedia/user 0.13.24 → 0.13.26
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/@types/amedia-frontend-rpc.d.ts +11 -0
- package/@types/browserid.d.ts +4 -0
- package/dist/actions/authorization.d.ts +5 -5
- package/dist/autologin/index.d.ts +4 -0
- package/dist/clients/mercuryLog.d.ts +5 -4
- package/dist/index.d.ts +43 -29
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/janitor/jobs/daxsubCookie.d.ts +2 -1
- package/dist/lib/PaywallUnlockRequest.d.ts +1 -1
- package/dist/lib/UserDataRequest.d.ts +1 -1
- package/dist/lib/rpc.d.ts +5 -5
- package/dist/utils/customEventWrapper.d.ts +5 -3
- package/dist/utils/deepEquals.d.ts +0 -3
- package/dist/utils/log.d.ts +4 -4
- package/dist/utils/queue.d.ts +2 -2
- package/dist/utils/type.d.ts +6 -0
- package/eik.json +1 -1
- package/package.json +1 -2
- package/src/actions/authorization.spec.ts +13 -9
- package/src/actions/authorization.ts +7 -5
- package/src/autologin/index.spec.ts +3 -3
- package/src/autologin/index.ts +6 -1
- package/src/cache/index.spec.ts +2 -2
- package/src/cache/index.ts +1 -2
- package/src/clients/europa.spec.ts +3 -3
- package/src/clients/europa.ts +9 -4
- package/src/clients/mercuryLog.ts +19 -11
- package/src/clients/pluto.spec.ts +4 -3
- package/src/eventHandlers/state.spec.ts +2 -2
- package/src/eventHandlers/storage.spec.ts +2 -2
- package/src/eventHandlers/userAttributes.spec.ts +2 -2
- package/src/index-authentcation.spec.ts +1 -1
- package/src/index-storage.spec.ts +3 -3
- package/src/index-subscription.spec.ts +1 -1
- package/src/index.ts +4 -8
- package/src/janitor/jobs/accessCookieRefresher.spec.ts +8 -2
- package/src/janitor/jobs/daxsubCookie.spec.ts +8 -2
- package/src/janitor/jobs/daxsubCookie.ts +4 -3
- package/src/lib/PaywallUnlockRequest.spec.ts +12 -12
- package/src/lib/PaywallUnlockRequest.ts +6 -3
- package/src/lib/UserDataRequest.spec.ts +3 -2
- package/src/lib/UserDataRequest.ts +4 -4
- package/src/lib/rpc.ts +7 -9
- package/src/store/index.ts +2 -0
- package/src/utils/customEventWrapper.ts +6 -6
- package/src/utils/deepEquals.ts +12 -11
- package/src/utils/getOrUpdate.ts +1 -1
- package/src/utils/log.spec.ts +4 -4
- package/src/utils/log.ts +24 -13
- package/src/utils/queue.ts +4 -4
- package/src/utils/type.ts +19 -0
- package/tsconfig.eslint.json +2 -0
- package/tsconfig.json +2 -1
- package/amedia-user-js.iml +0 -9
- package/dist/cache/engines/indexeddb.d.ts +0 -7
- package/dist/index.js.LICENSE.txt +0 -14
- package/dist/janitor/index.spec.d.ts +0 -4
- package/dist/lib/PaywallUnlocker.d.ts +0 -16
- package/dist/lib/PaywallUnlocker.spec.d.ts +0 -4
- package/dist/lib/User.d.ts +0 -21
- package/dist/utils/logValidationError.d.ts +0 -1
- package/esm/actions/authentication.d.ts +0 -5
- package/esm/actions/authentication.spec.d.ts +0 -4
- package/esm/actions/authorization.d.ts +0 -9
- package/esm/actions/preferences.d.ts +0 -9
- package/esm/actions/preferences.spec.d.ts +0 -1
- package/esm/actions/storage.d.ts +0 -4
- package/esm/actions/userData.d.ts +0 -2
- package/esm/autologin/index.d.ts +0 -1
- package/esm/autologin/thirdPartyCookie.d.ts +0 -3
- package/esm/autologin/thirdPartyCookie.spec.d.ts +0 -1
- package/esm/cache/engines/global.d.ts +0 -21
- package/esm/cache/engines/global.spec.d.ts +0 -1
- package/esm/cache/engines/indexeddb.d.ts +0 -7
- package/esm/cache/index.d.ts +0 -11
- package/esm/cache/index.spec.d.ts +0 -4
- package/esm/cache/types.d.ts +0 -11
- package/esm/clients/europa.d.ts +0 -28
- package/esm/clients/europa.spec.d.ts +0 -1
- package/esm/clients/jupiter.d.ts +0 -30
- package/esm/clients/jupiter.spec.d.ts +0 -1
- package/esm/clients/mercury.d.ts +0 -18
- package/esm/clients/mercury.spec.d.ts +0 -4
- package/esm/clients/nebula.d.ts +0 -2
- package/esm/clients/nebula.spec.d.ts +0 -1
- package/esm/clients/pluto.d.ts +0 -3
- package/esm/clients/pluto.spec.d.ts +0 -1
- package/esm/eventHandlers/activation.d.ts +0 -15
- package/esm/eventHandlers/authentication.d.ts +0 -17
- package/esm/eventHandlers/userAttributes.d.ts +0 -24
- package/esm/exceptions/PaywallError.d.ts +0 -7
- package/esm/index-authentcation.spec.d.ts +0 -4
- package/esm/index-storage.spec.d.ts +0 -4
- package/esm/index-subscription.spec.d.ts +0 -4
- package/esm/index.d.ts +0 -26
- package/esm/janitor/index.d.ts +0 -10
- package/esm/janitor/jobs/accessCookieRefresher.d.ts +0 -1
- package/esm/janitor/jobs/accessCookieRefresher.spec.d.ts +0 -4
- package/esm/lib/PaywallUnlocker.d.ts +0 -16
- package/esm/lib/PaywallUnlocker.spec.d.ts +0 -4
- package/esm/lib/User.d.ts +0 -21
- package/esm/lib/cookie.d.ts +0 -5
- package/esm/lib/rpc.d.ts +0 -6
- package/esm/store/index.d.ts +0 -22
- package/esm/store/index.spec.d.ts +0 -1
- package/esm/types.d.ts +0 -22
- package/esm/user.js +0 -2
- package/esm/user.js.map +0 -1
- package/esm/utils/customEventWrapper.d.ts +0 -17
- package/esm/utils/deepEquals.d.ts +0 -4
- package/esm/utils/getOrUpdate.d.ts +0 -6
- package/esm/utils/getOrUpdate.spec.d.ts +0 -1
- package/esm/utils/location.d.ts +0 -3
- package/esm/utils/log.d.ts +0 -26
- package/esm/utils/queue.d.ts +0 -12
- package/esm/utils/url.d.ts +0 -6
- package/esm/utils/url.spec.d.ts +0 -1
|
@@ -6,9 +6,9 @@ declare type SetCookieResponse = {
|
|
|
6
6
|
export declare const getAccess: (accessFeatures?: string[]) => Promise<Pick<UserAttributes, 'access'>>;
|
|
7
7
|
export declare const activate: (accessFeatures: string[]) => Promise<string[]>;
|
|
8
8
|
export declare const hasAccess: (currentAccessFeatures: string[], requestedAccessFeatures: string[]) => boolean;
|
|
9
|
-
export declare const setUserAccessCookie: (publicationDomain:
|
|
10
|
-
export declare const setNonUserAccessCookie: (publicationDomain:
|
|
11
|
-
export declare const setAccessCookies: (publicationDomain:
|
|
12
|
-
export declare const setHasPerformedPaywallReload: (requestedUrl?:
|
|
13
|
-
export declare const hasRecentlyPerformedPaywallReload: (requestedUrl?:
|
|
9
|
+
export declare const setUserAccessCookie: (publicationDomain: string) => Promise<SetCookieResponse>;
|
|
10
|
+
export declare const setNonUserAccessCookie: (publicationDomain: string) => Promise<SetCookieResponse>;
|
|
11
|
+
export declare const setAccessCookies: (publicationDomain: string) => Promise<SetCookieResponse>;
|
|
12
|
+
export declare const setHasPerformedPaywallReload: (requestedUrl?: string | undefined) => void;
|
|
13
|
+
export declare const hasRecentlyPerformedPaywallReload: (requestedUrl?: string | undefined) => boolean;
|
|
14
14
|
export {};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export declare type Strategies = Array<{
|
|
2
|
+
name: string;
|
|
3
|
+
handler: () => Promise<boolean>;
|
|
4
|
+
}>;
|
|
1
5
|
export declare const AUTOLOGIN_COOKIE_TTL = 60000;
|
|
2
6
|
export declare const attemptAutoLoginJob: () => Promise<void>;
|
|
3
7
|
export declare const attemptPaywallAutoLogin: () => Promise<void>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
declare type Context = Record<string, unknown>;
|
|
1
2
|
declare const log: {
|
|
2
|
-
error: (message: string, context:
|
|
3
|
-
warn: (message: string, context:
|
|
4
|
-
info: (message: string, context:
|
|
5
|
-
debug: (message: string, context:
|
|
3
|
+
error: (message: string, context: Context) => void;
|
|
4
|
+
warn: (message: string, context: Context) => void;
|
|
5
|
+
info: (message: string, context: Context) => void;
|
|
6
|
+
debug: (message: string, context: Context) => void;
|
|
6
7
|
};
|
|
7
8
|
export default log;
|
package/dist/index.d.ts
CHANGED
|
@@ -21,11 +21,11 @@ declare module '@amedia/user/actions/authorization' {
|
|
|
21
21
|
export const getAccess: (accessFeatures?: string[]) => Promise<Pick<UserAttributes, 'access'>>;
|
|
22
22
|
export const activate: (accessFeatures: string[]) => Promise<string[]>;
|
|
23
23
|
export const hasAccess: (currentAccessFeatures: string[], requestedAccessFeatures: string[]) => boolean;
|
|
24
|
-
export const setUserAccessCookie: (publicationDomain:
|
|
25
|
-
export const setNonUserAccessCookie: (publicationDomain:
|
|
26
|
-
export const setAccessCookies: (publicationDomain:
|
|
27
|
-
export const setHasPerformedPaywallReload: (requestedUrl?:
|
|
28
|
-
export const hasRecentlyPerformedPaywallReload: (requestedUrl?:
|
|
24
|
+
export const setUserAccessCookie: (publicationDomain: string) => Promise<SetCookieResponse>;
|
|
25
|
+
export const setNonUserAccessCookie: (publicationDomain: string) => Promise<SetCookieResponse>;
|
|
26
|
+
export const setAccessCookies: (publicationDomain: string) => Promise<SetCookieResponse>;
|
|
27
|
+
export const setHasPerformedPaywallReload: (requestedUrl?: string | undefined) => void;
|
|
28
|
+
export const hasRecentlyPerformedPaywallReload: (requestedUrl?: string | undefined) => boolean;
|
|
29
29
|
export {};
|
|
30
30
|
|
|
31
31
|
}
|
|
@@ -69,6 +69,10 @@ declare module '@amedia/user/actions/userData.spec' {
|
|
|
69
69
|
|
|
70
70
|
}
|
|
71
71
|
declare module '@amedia/user/autologin/index' {
|
|
72
|
+
export type Strategies = Array<{
|
|
73
|
+
name: string;
|
|
74
|
+
handler: () => Promise<boolean>;
|
|
75
|
+
}>;
|
|
72
76
|
export const AUTOLOGIN_COOKIE_TTL = 60000;
|
|
73
77
|
export const attemptAutoLoginJob: () => Promise<void>;
|
|
74
78
|
export const attemptPaywallAutoLogin: () => Promise<void>;
|
|
@@ -240,11 +244,12 @@ declare module '@amedia/user/clients/mercury.spec' {
|
|
|
240
244
|
|
|
241
245
|
}
|
|
242
246
|
declare module '@amedia/user/clients/mercuryLog' {
|
|
247
|
+
type Context = Record<string, unknown>;
|
|
243
248
|
const log: {
|
|
244
|
-
error: (message: string, context:
|
|
245
|
-
warn: (message: string, context:
|
|
246
|
-
info: (message: string, context:
|
|
247
|
-
debug: (message: string, context:
|
|
249
|
+
error: (message: string, context: Context) => void;
|
|
250
|
+
warn: (message: string, context: Context) => void;
|
|
251
|
+
info: (message: string, context: Context) => void;
|
|
252
|
+
debug: (message: string, context: Context) => void;
|
|
248
253
|
};
|
|
249
254
|
export default log;
|
|
250
255
|
|
|
@@ -452,7 +457,8 @@ declare module '@amedia/user/janitor/jobs/accessCookieRefresher.spec' {
|
|
|
452
457
|
|
|
453
458
|
}
|
|
454
459
|
declare module '@amedia/user/janitor/jobs/daxsubCookie' {
|
|
455
|
-
|
|
460
|
+
import { UserAttributes } from '@amedia/user/types';
|
|
461
|
+
export function getCookieValue(attributes: UserAttributes): string;
|
|
456
462
|
export default function daxSubCookieHandler(): Promise<void>;
|
|
457
463
|
|
|
458
464
|
}
|
|
@@ -472,7 +478,7 @@ declare module '@amedia/user/janitor/jobs/removeUserStorage.spec' {
|
|
|
472
478
|
|
|
473
479
|
}
|
|
474
480
|
declare module '@amedia/user/lib/PaywallUnlockRequest' {
|
|
475
|
-
type UnlockResponse = {
|
|
481
|
+
export type UnlockResponse = {
|
|
476
482
|
isLoggedIn: boolean;
|
|
477
483
|
hasAccess: boolean;
|
|
478
484
|
accessFeatures: string[];
|
|
@@ -502,7 +508,7 @@ declare module '@amedia/user/lib/UserDataRequest' {
|
|
|
502
508
|
import { State, UserAttributes } from '@amedia/user/types';
|
|
503
509
|
class UserDataRequest<UA extends UserAttributes, S extends {
|
|
504
510
|
[index: string]: unknown;
|
|
505
|
-
}, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends
|
|
511
|
+
}, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends Record<string, object> = {
|
|
506
512
|
state: State;
|
|
507
513
|
}> {
|
|
508
514
|
private attributes?;
|
|
@@ -540,11 +546,11 @@ declare module '@amedia/user/lib/cookie' {
|
|
|
540
546
|
|
|
541
547
|
}
|
|
542
548
|
declare module '@amedia/user/lib/rpc' {
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
userAuthenticated: (
|
|
546
|
-
}
|
|
547
|
-
export const getRPCClient: () =>
|
|
549
|
+
import { RPCclient } from '@amedia/frontend-rpc';
|
|
550
|
+
interface LocalRPCclient extends RPCclient {
|
|
551
|
+
userAuthenticated: (isLoggedIn: boolean) => void;
|
|
552
|
+
}
|
|
553
|
+
export const getRPCClient: () => LocalRPCclient;
|
|
548
554
|
export {};
|
|
549
555
|
|
|
550
556
|
}
|
|
@@ -604,7 +610,8 @@ declare module '@amedia/user/types' {
|
|
|
604
610
|
|
|
605
611
|
}
|
|
606
612
|
declare module '@amedia/user/utils/customEventWrapper' {
|
|
607
|
-
|
|
613
|
+
let rootElement: Window | Element;
|
|
614
|
+
export const setRootElement: (element: typeof rootElement) => void;
|
|
608
615
|
/**
|
|
609
616
|
* This listener MUST be used by all listeners in ../eventHandlers
|
|
610
617
|
* We want to ensure that only _one_ instance of this package actually
|
|
@@ -612,21 +619,19 @@ declare module '@amedia/user/utils/customEventWrapper' {
|
|
|
612
619
|
* @param type
|
|
613
620
|
* @param listener
|
|
614
621
|
*/
|
|
615
|
-
export const listenWithExclusivity: <T extends keyof WindowEventMap>(type: T, listener: (this:
|
|
622
|
+
export const listenWithExclusivity: <T extends keyof WindowEventMap>(type: T, listener: (this: typeof rootElement, ev: WindowEventMap[T]) => void) => void;
|
|
616
623
|
/**
|
|
617
624
|
* Use this for response listeners. (../index.ts) where we want
|
|
618
625
|
* all updates with data - no matter who sent the actual request
|
|
619
626
|
* @param type
|
|
620
627
|
* @param listener
|
|
621
628
|
*/
|
|
622
|
-
export const listenForAllEvents: <T extends keyof WindowEventMap>(type: T, listener: (this:
|
|
629
|
+
export const listenForAllEvents: <T extends keyof WindowEventMap>(type: T, listener: (this: typeof rootElement, ev: WindowEventMap[T]) => void) => void;
|
|
623
630
|
export const dispatch: <T extends Event>(event: T) => void;
|
|
631
|
+
export {};
|
|
624
632
|
|
|
625
633
|
}
|
|
626
634
|
declare module '@amedia/user/utils/deepEquals' {
|
|
627
|
-
/**
|
|
628
|
-
* @see https://dev.to/sanderdebr/deep-equality-checking-of-objects-in-vanilla-javascript-5592
|
|
629
|
-
*/
|
|
630
635
|
export const deepEquals: (a: unknown, b: unknown) => boolean;
|
|
631
636
|
|
|
632
637
|
}
|
|
@@ -651,10 +656,10 @@ declare module '@amedia/user/utils/location' {
|
|
|
651
656
|
}
|
|
652
657
|
declare module '@amedia/user/utils/log' {
|
|
653
658
|
export type Logger = {
|
|
654
|
-
debug: (message: string | Error, context?:
|
|
655
|
-
info: (message: string | Error, context?:
|
|
656
|
-
warn: (message: string | Error, context?:
|
|
657
|
-
error: (message: string | Error, context?:
|
|
659
|
+
debug: (message: string | Error, context?: any) => void;
|
|
660
|
+
info: (message: string | Error, context?: any) => void;
|
|
661
|
+
warn: (message: string | Error, context?: any) => void;
|
|
662
|
+
error: (message: string | Error, context?: any) => void;
|
|
658
663
|
};
|
|
659
664
|
export const setLogger: (engine: Logger) => void;
|
|
660
665
|
const _default: Logger;
|
|
@@ -677,17 +682,26 @@ declare module '@amedia/user/utils/networkError' {
|
|
|
677
682
|
declare module '@amedia/user/utils/queue' {
|
|
678
683
|
const _default: {
|
|
679
684
|
add: (key: string, promiseCallbacks: {
|
|
680
|
-
resolve: (
|
|
685
|
+
resolve: (arg0?: any) => void;
|
|
681
686
|
reject: (reason?: any) => void;
|
|
682
687
|
}) => void;
|
|
683
688
|
getAll: (key: string) => {
|
|
684
|
-
resolve: (
|
|
689
|
+
resolve: (arg0?: any) => void;
|
|
685
690
|
reject: (reason?: any) => void;
|
|
686
691
|
}[];
|
|
687
692
|
peekQueueSize: (key: string) => number;
|
|
688
693
|
};
|
|
689
694
|
export default _default;
|
|
690
695
|
|
|
696
|
+
}
|
|
697
|
+
declare module '@amedia/user/utils/type' {
|
|
698
|
+
export const isFunction: (argument: unknown) => argument is Function;
|
|
699
|
+
export const isRecord: (argument: unknown) => argument is Record<string, unknown>;
|
|
700
|
+
export const isError: (argument: unknown) => argument is Error;
|
|
701
|
+
export const isString: (argument: unknown) => argument is string;
|
|
702
|
+
export const isNumber: (argument: unknown) => argument is number;
|
|
703
|
+
export const isBoolean: (argument: unknown) => argument is boolean;
|
|
704
|
+
|
|
691
705
|
}
|
|
692
706
|
declare module '@amedia/user/utils/url' {
|
|
693
707
|
export const setCurrentHostname: (hostname: string) => void;
|