@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.
Files changed (120) hide show
  1. package/@types/amedia-frontend-rpc.d.ts +11 -0
  2. package/@types/browserid.d.ts +4 -0
  3. package/dist/actions/authorization.d.ts +5 -5
  4. package/dist/autologin/index.d.ts +4 -0
  5. package/dist/clients/mercuryLog.d.ts +5 -4
  6. package/dist/index.d.ts +43 -29
  7. package/dist/index.esm.js +1 -1
  8. package/dist/index.esm.js.map +3 -3
  9. package/dist/index.js +1 -1
  10. package/dist/index.js.map +3 -3
  11. package/dist/janitor/jobs/daxsubCookie.d.ts +2 -1
  12. package/dist/lib/PaywallUnlockRequest.d.ts +1 -1
  13. package/dist/lib/UserDataRequest.d.ts +1 -1
  14. package/dist/lib/rpc.d.ts +5 -5
  15. package/dist/utils/customEventWrapper.d.ts +5 -3
  16. package/dist/utils/deepEquals.d.ts +0 -3
  17. package/dist/utils/log.d.ts +4 -4
  18. package/dist/utils/queue.d.ts +2 -2
  19. package/dist/utils/type.d.ts +6 -0
  20. package/eik.json +1 -1
  21. package/package.json +1 -2
  22. package/src/actions/authorization.spec.ts +13 -9
  23. package/src/actions/authorization.ts +7 -5
  24. package/src/autologin/index.spec.ts +3 -3
  25. package/src/autologin/index.ts +6 -1
  26. package/src/cache/index.spec.ts +2 -2
  27. package/src/cache/index.ts +1 -2
  28. package/src/clients/europa.spec.ts +3 -3
  29. package/src/clients/europa.ts +9 -4
  30. package/src/clients/mercuryLog.ts +19 -11
  31. package/src/clients/pluto.spec.ts +4 -3
  32. package/src/eventHandlers/state.spec.ts +2 -2
  33. package/src/eventHandlers/storage.spec.ts +2 -2
  34. package/src/eventHandlers/userAttributes.spec.ts +2 -2
  35. package/src/index-authentcation.spec.ts +1 -1
  36. package/src/index-storage.spec.ts +3 -3
  37. package/src/index-subscription.spec.ts +1 -1
  38. package/src/index.ts +4 -8
  39. package/src/janitor/jobs/accessCookieRefresher.spec.ts +8 -2
  40. package/src/janitor/jobs/daxsubCookie.spec.ts +8 -2
  41. package/src/janitor/jobs/daxsubCookie.ts +4 -3
  42. package/src/lib/PaywallUnlockRequest.spec.ts +12 -12
  43. package/src/lib/PaywallUnlockRequest.ts +6 -3
  44. package/src/lib/UserDataRequest.spec.ts +3 -2
  45. package/src/lib/UserDataRequest.ts +4 -4
  46. package/src/lib/rpc.ts +7 -9
  47. package/src/store/index.ts +2 -0
  48. package/src/utils/customEventWrapper.ts +6 -6
  49. package/src/utils/deepEquals.ts +12 -11
  50. package/src/utils/getOrUpdate.ts +1 -1
  51. package/src/utils/log.spec.ts +4 -4
  52. package/src/utils/log.ts +24 -13
  53. package/src/utils/queue.ts +4 -4
  54. package/src/utils/type.ts +19 -0
  55. package/tsconfig.eslint.json +2 -0
  56. package/tsconfig.json +2 -1
  57. package/amedia-user-js.iml +0 -9
  58. package/dist/cache/engines/indexeddb.d.ts +0 -7
  59. package/dist/index.js.LICENSE.txt +0 -14
  60. package/dist/janitor/index.spec.d.ts +0 -4
  61. package/dist/lib/PaywallUnlocker.d.ts +0 -16
  62. package/dist/lib/PaywallUnlocker.spec.d.ts +0 -4
  63. package/dist/lib/User.d.ts +0 -21
  64. package/dist/utils/logValidationError.d.ts +0 -1
  65. package/esm/actions/authentication.d.ts +0 -5
  66. package/esm/actions/authentication.spec.d.ts +0 -4
  67. package/esm/actions/authorization.d.ts +0 -9
  68. package/esm/actions/preferences.d.ts +0 -9
  69. package/esm/actions/preferences.spec.d.ts +0 -1
  70. package/esm/actions/storage.d.ts +0 -4
  71. package/esm/actions/userData.d.ts +0 -2
  72. package/esm/autologin/index.d.ts +0 -1
  73. package/esm/autologin/thirdPartyCookie.d.ts +0 -3
  74. package/esm/autologin/thirdPartyCookie.spec.d.ts +0 -1
  75. package/esm/cache/engines/global.d.ts +0 -21
  76. package/esm/cache/engines/global.spec.d.ts +0 -1
  77. package/esm/cache/engines/indexeddb.d.ts +0 -7
  78. package/esm/cache/index.d.ts +0 -11
  79. package/esm/cache/index.spec.d.ts +0 -4
  80. package/esm/cache/types.d.ts +0 -11
  81. package/esm/clients/europa.d.ts +0 -28
  82. package/esm/clients/europa.spec.d.ts +0 -1
  83. package/esm/clients/jupiter.d.ts +0 -30
  84. package/esm/clients/jupiter.spec.d.ts +0 -1
  85. package/esm/clients/mercury.d.ts +0 -18
  86. package/esm/clients/mercury.spec.d.ts +0 -4
  87. package/esm/clients/nebula.d.ts +0 -2
  88. package/esm/clients/nebula.spec.d.ts +0 -1
  89. package/esm/clients/pluto.d.ts +0 -3
  90. package/esm/clients/pluto.spec.d.ts +0 -1
  91. package/esm/eventHandlers/activation.d.ts +0 -15
  92. package/esm/eventHandlers/authentication.d.ts +0 -17
  93. package/esm/eventHandlers/userAttributes.d.ts +0 -24
  94. package/esm/exceptions/PaywallError.d.ts +0 -7
  95. package/esm/index-authentcation.spec.d.ts +0 -4
  96. package/esm/index-storage.spec.d.ts +0 -4
  97. package/esm/index-subscription.spec.d.ts +0 -4
  98. package/esm/index.d.ts +0 -26
  99. package/esm/janitor/index.d.ts +0 -10
  100. package/esm/janitor/jobs/accessCookieRefresher.d.ts +0 -1
  101. package/esm/janitor/jobs/accessCookieRefresher.spec.d.ts +0 -4
  102. package/esm/lib/PaywallUnlocker.d.ts +0 -16
  103. package/esm/lib/PaywallUnlocker.spec.d.ts +0 -4
  104. package/esm/lib/User.d.ts +0 -21
  105. package/esm/lib/cookie.d.ts +0 -5
  106. package/esm/lib/rpc.d.ts +0 -6
  107. package/esm/store/index.d.ts +0 -22
  108. package/esm/store/index.spec.d.ts +0 -1
  109. package/esm/types.d.ts +0 -22
  110. package/esm/user.js +0 -2
  111. package/esm/user.js.map +0 -1
  112. package/esm/utils/customEventWrapper.d.ts +0 -17
  113. package/esm/utils/deepEquals.d.ts +0 -4
  114. package/esm/utils/getOrUpdate.d.ts +0 -6
  115. package/esm/utils/getOrUpdate.spec.d.ts +0 -1
  116. package/esm/utils/location.d.ts +0 -3
  117. package/esm/utils/log.d.ts +0 -26
  118. package/esm/utils/queue.d.ts +0 -12
  119. package/esm/utils/url.d.ts +0 -6
  120. package/esm/utils/url.spec.d.ts +0 -1
@@ -0,0 +1,11 @@
1
+ declare module '@amedia/frontend-rpc' {
2
+ class RPCclient {
3
+ constructor(config: {
4
+ version: string;
5
+ component: string;
6
+ methods?: string[];
7
+ });
8
+
9
+ addMethod(method: string): void;
10
+ }
11
+ }
@@ -0,0 +1,4 @@
1
+ declare module "@amedia/browserid" {
2
+ // Not complete
3
+ export function getBrowserId(): Promise<string>;
4
+ }
@@ -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: any) => Promise<SetCookieResponse>;
10
- export declare const setNonUserAccessCookie: (publicationDomain: any) => Promise<SetCookieResponse>;
11
- export declare const setAccessCookies: (publicationDomain: any) => Promise<SetCookieResponse>;
12
- export declare const setHasPerformedPaywallReload: (requestedUrl?: any) => void;
13
- export declare const hasRecentlyPerformedPaywallReload: (requestedUrl?: any) => boolean;
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: Object) => void;
3
- warn: (message: string, context: Object) => void;
4
- info: (message: string, context: Object) => void;
5
- debug: (message: string, context: Object) => void;
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: 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;
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: Object) => void;
245
- warn: (message: string, context: Object) => void;
246
- info: (message: string, context: Object) => void;
247
- debug: (message: string, context: Object) => void;
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
- export function getCookieValue(attributes: any): string;
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
- let rpcSessionClient: {
544
- addMethod: (methodName: string) => void;
545
- userAuthenticated: (boolean: any) => void;
546
- };
547
- export const getRPCClient: () => Pick<typeof rpcSessionClient, 'userAuthenticated'>;
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
- export const setRootElement: (element: any) => void;
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: Window, ev: WindowEventMap[T]) => void) => void;
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: Window, ev: WindowEventMap[T]) => void) => void;
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?: Object) => void;
655
- info: (message: string | Error, context?: Object) => void;
656
- warn: (message: string | Error, context?: Object) => void;
657
- error: (message: string | Error, context?: Object) => void;
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: (PromiseLike: any) => void;
685
+ resolve: (arg0?: any) => void;
681
686
  reject: (reason?: any) => void;
682
687
  }) => void;
683
688
  getAll: (key: string) => {
684
- resolve: (PromiseLike: any) => void;
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;