@amedia/user 0.13.35 → 0.13.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.
Files changed (179) hide show
  1. package/dist/user.cjs +1 -1
  2. package/dist/user.cjs.map +3 -3
  3. package/dist/user.d.ts +15 -1
  4. package/dist/user.js +1 -1
  5. package/dist/user.js.map +3 -3
  6. package/package.json +5 -2
  7. package/.codeclimate.yml +0 -8
  8. package/.eslintignore +0 -2
  9. package/.eslintrc +0 -11
  10. package/.prettierrc.json +0 -1
  11. package/@types/amedia-frontend-rpc.d.ts +0 -11
  12. package/@types/browserid.d.ts +0 -4
  13. package/build.js +0 -28
  14. package/checkVersion.cjs +0 -12
  15. package/cloudbuild.json +0 -29
  16. package/cop.json +0 -8
  17. package/dist/actions/authentication.d.ts +0 -4
  18. package/dist/actions/authentication.spec.d.ts +0 -1
  19. package/dist/actions/authorization.d.ts +0 -14
  20. package/dist/actions/authorization.spec.d.ts +0 -4
  21. package/dist/actions/preferences.d.ts +0 -9
  22. package/dist/actions/preferences.spec.d.ts +0 -1
  23. package/dist/actions/storage.d.ts +0 -7
  24. package/dist/actions/userData.d.ts +0 -2
  25. package/dist/actions/userData.spec.d.ts +0 -1
  26. package/dist/autologin/index.d.ts +0 -7
  27. package/dist/autologin/index.spec.d.ts +0 -1
  28. package/dist/autologin/thirdPartyCookie.d.ts +0 -3
  29. package/dist/autologin/thirdPartyCookie.spec.d.ts +0 -1
  30. package/dist/cache/engines/global.d.ts +0 -24
  31. package/dist/cache/engines/global.spec.d.ts +0 -1
  32. package/dist/cache/index.d.ts +0 -11
  33. package/dist/cache/index.spec.d.ts +0 -1
  34. package/dist/cache/types.d.ts +0 -11
  35. package/dist/clients/europa.d.ts +0 -24
  36. package/dist/clients/europa.spec.d.ts +0 -1
  37. package/dist/clients/jupiter.d.ts +0 -30
  38. package/dist/clients/jupiter.spec.d.ts +0 -1
  39. package/dist/clients/mercury.d.ts +0 -3
  40. package/dist/clients/mercury.spec.d.ts +0 -1
  41. package/dist/clients/mercuryLog.d.ts +0 -8
  42. package/dist/clients/mercuryLog.spec.d.ts +0 -1
  43. package/dist/clients/nebula.d.ts +0 -2
  44. package/dist/clients/nebula.spec.d.ts +0 -1
  45. package/dist/clients/pluto.d.ts +0 -4
  46. package/dist/clients/pluto.spec.d.ts +0 -1
  47. package/dist/eventHandlers/activation.d.ts +0 -15
  48. package/dist/eventHandlers/authentication.d.ts +0 -17
  49. package/dist/eventHandlers/eventMap.d.ts +0 -29
  50. package/dist/eventHandlers/state.d.ts +0 -1
  51. package/dist/eventHandlers/state.spec.d.ts +0 -1
  52. package/dist/eventHandlers/storage.d.ts +0 -1
  53. package/dist/eventHandlers/storage.spec.d.ts +0 -1
  54. package/dist/eventHandlers/userAttributes.d.ts +0 -1
  55. package/dist/eventHandlers/userAttributes.spec.d.ts +0 -1
  56. package/dist/exceptions/PaywallError.d.ts +0 -8
  57. package/dist/index-authentcation.spec.d.ts +0 -1
  58. package/dist/index-storage.spec.d.ts +0 -1
  59. package/dist/index-subscription.spec.d.ts +0 -1
  60. package/dist/index.d.ts +0 -20
  61. package/dist/janitor/index.d.ts +0 -10
  62. package/dist/janitor/index.spec.d.ts +0 -1
  63. package/dist/janitor/jobs/accessCookieRefresher.d.ts +0 -1
  64. package/dist/janitor/jobs/accessCookieRefresher.spec.d.ts +0 -1
  65. package/dist/janitor/jobs/daxsubCookie.d.ts +0 -3
  66. package/dist/janitor/jobs/daxsubCookie.spec.d.ts +0 -1
  67. package/dist/janitor/jobs/removeUserStorage.d.ts +0 -1
  68. package/dist/janitor/jobs/removeUserStorage.spec.d.ts +0 -1
  69. package/dist/lib/PaywallUnlockRequest.d.ts +0 -17
  70. package/dist/lib/PaywallUnlockRequest.spec.d.ts +0 -1
  71. package/dist/lib/UserDataRequest.d.ts +0 -22
  72. package/dist/lib/UserDataRequest.spec.d.ts +0 -1
  73. package/dist/lib/cookie.d.ts +0 -9
  74. package/dist/lib/rpc.d.ts +0 -6
  75. package/dist/store/index.d.ts +0 -23
  76. package/dist/store/index.spec.d.ts +0 -1
  77. package/dist/types.d.ts +0 -22
  78. package/dist/utils/customEventWrapper.d.ts +0 -19
  79. package/dist/utils/debouncer.d.ts +0 -26
  80. package/dist/utils/debouncer.spec.d.ts +0 -1
  81. package/dist/utils/deepEquals.d.ts +0 -1
  82. package/dist/utils/expectBootLogs.d.ts +0 -2
  83. package/dist/utils/getOrUpdate.d.ts +0 -6
  84. package/dist/utils/getOrUpdate.spec.d.ts +0 -1
  85. package/dist/utils/localhostCheck.d.ts +0 -1
  86. package/dist/utils/location.d.ts +0 -3
  87. package/dist/utils/log.d.ts +0 -9
  88. package/dist/utils/log.spec.d.ts +0 -1
  89. package/dist/utils/loginState.d.ts +0 -2
  90. package/dist/utils/networkError.d.ts +0 -1
  91. package/dist/utils/queue.d.ts +0 -12
  92. package/dist/utils/type.d.ts +0 -6
  93. package/dist/utils/url.d.ts +0 -6
  94. package/dist/utils/url.spec.d.ts +0 -1
  95. package/eik.json +0 -10
  96. package/global.d.ts +0 -1
  97. package/jest.config.js +0 -7
  98. package/setupJest.js +0 -1
  99. package/src/actions/authentication.spec.ts +0 -51
  100. package/src/actions/authentication.ts +0 -43
  101. package/src/actions/authorization.spec.ts +0 -369
  102. package/src/actions/authorization.ts +0 -117
  103. package/src/actions/preferences.spec.ts +0 -41
  104. package/src/actions/preferences.ts +0 -41
  105. package/src/actions/storage.ts +0 -22
  106. package/src/actions/userData.spec.ts +0 -133
  107. package/src/actions/userData.ts +0 -68
  108. package/src/autologin/index.spec.ts +0 -239
  109. package/src/autologin/index.ts +0 -92
  110. package/src/autologin/thirdPartyCookie.spec.ts +0 -95
  111. package/src/autologin/thirdPartyCookie.ts +0 -55
  112. package/src/cache/engines/global.spec.ts +0 -62
  113. package/src/cache/engines/global.ts +0 -48
  114. package/src/cache/index.spec.ts +0 -130
  115. package/src/cache/index.ts +0 -48
  116. package/src/cache/types.ts +0 -12
  117. package/src/clients/europa.spec.ts +0 -209
  118. package/src/clients/europa.ts +0 -183
  119. package/src/clients/jupiter.spec.ts +0 -179
  120. package/src/clients/jupiter.ts +0 -119
  121. package/src/clients/mercury.spec.ts +0 -59
  122. package/src/clients/mercury.ts +0 -48
  123. package/src/clients/mercuryLog.spec.ts +0 -20
  124. package/src/clients/mercuryLog.ts +0 -67
  125. package/src/clients/nebula.spec.ts +0 -70
  126. package/src/clients/nebula.ts +0 -83
  127. package/src/clients/pluto.spec.ts +0 -165
  128. package/src/clients/pluto.ts +0 -118
  129. package/src/eventHandlers/activation.ts +0 -35
  130. package/src/eventHandlers/authentication.ts +0 -34
  131. package/src/eventHandlers/eventMap.ts +0 -34
  132. package/src/eventHandlers/state.spec.ts +0 -48
  133. package/src/eventHandlers/state.ts +0 -23
  134. package/src/eventHandlers/storage.spec.ts +0 -114
  135. package/src/eventHandlers/storage.ts +0 -45
  136. package/src/eventHandlers/userAttributes.spec.ts +0 -93
  137. package/src/eventHandlers/userAttributes.ts +0 -31
  138. package/src/exceptions/PaywallError.ts +0 -16
  139. package/src/index-authentcation.spec.ts +0 -26
  140. package/src/index-storage.spec.ts +0 -144
  141. package/src/index-subscription.spec.ts +0 -213
  142. package/src/index.ts +0 -59
  143. package/src/janitor/index.spec.ts +0 -18
  144. package/src/janitor/index.ts +0 -59
  145. package/src/janitor/jobs/accessCookieRefresher.spec.ts +0 -213
  146. package/src/janitor/jobs/accessCookieRefresher.ts +0 -98
  147. package/src/janitor/jobs/daxsubCookie.spec.ts +0 -109
  148. package/src/janitor/jobs/daxsubCookie.ts +0 -38
  149. package/src/janitor/jobs/removeUserStorage.spec.ts +0 -34
  150. package/src/janitor/jobs/removeUserStorage.ts +0 -12
  151. package/src/lib/PaywallUnlockRequest.spec.ts +0 -363
  152. package/src/lib/PaywallUnlockRequest.ts +0 -143
  153. package/src/lib/UserDataRequest.spec.ts +0 -77
  154. package/src/lib/UserDataRequest.ts +0 -213
  155. package/src/lib/cookie.ts +0 -121
  156. package/src/lib/rpc.ts +0 -19
  157. package/src/store/index.spec.ts +0 -49
  158. package/src/store/index.ts +0 -64
  159. package/src/types.ts +0 -22
  160. package/src/utils/customEventWrapper.ts +0 -58
  161. package/src/utils/debouncer.spec.ts +0 -252
  162. package/src/utils/debouncer.ts +0 -123
  163. package/src/utils/deepEquals.ts +0 -42
  164. package/src/utils/expectBootLogs.ts +0 -9
  165. package/src/utils/getOrUpdate.spec.ts +0 -166
  166. package/src/utils/getOrUpdate.ts +0 -66
  167. package/src/utils/localhostCheck.ts +0 -9
  168. package/src/utils/location.ts +0 -31
  169. package/src/utils/log.spec.ts +0 -148
  170. package/src/utils/log.ts +0 -124
  171. package/src/utils/loginState.ts +0 -24
  172. package/src/utils/networkError.ts +0 -11
  173. package/src/utils/queue.ts +0 -32
  174. package/src/utils/type.ts +0 -19
  175. package/src/utils/url.spec.ts +0 -33
  176. package/src/utils/url.ts +0 -35
  177. package/testSetup.js +0 -19
  178. package/tsconfig.eslint.json +0 -24
  179. package/tsconfig.json +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amedia/user",
3
- "version": "0.13.35",
3
+ "version": "0.13.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)",
@@ -13,12 +13,15 @@
13
13
  "import": "./dist/index.js"
14
14
  }
15
15
  },
16
+ "files": [
17
+ "dist/*"
18
+ ],
16
19
  "typings": "dist/index.d.ts",
17
20
  "scripts": {
18
21
  "test": "jest --coverage",
19
22
  "lint": "eslint ./src --ext .ts",
20
23
  "build": "npm install && node build.js",
21
- "typings": "tsc",
24
+ "typings": "tsc --noEmit",
22
25
  "eik:package": "run-p typings lint && npm run test && npm run build && eik package",
23
26
  "prepublishOnly": "node checkVersion.cjs && run-p typings lint && npm run test && npm run build",
24
27
  "postpublish": "eik package"
package/.codeclimate.yml DELETED
@@ -1,8 +0,0 @@
1
- plugins:
2
- eslint:
3
- enabled: true
4
- exclude_patterns:
5
- - "!src"
6
- - "**/*.spec.ts"
7
- - "*.js"
8
- - "src/utils/deepEquals.ts" # This is an external lib
package/.eslintignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules
2
- dist
package/.eslintrc DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "@amedia/eslint-config-typescript",
3
- "plugins": ["prettier"],
4
- "parserOptions": {
5
- "project": "./tsconfig.eslint.json"
6
- },
7
- "rules": {
8
- "prettier/prettier": "warn",
9
- "import/prefer-default-export": "off"
10
- }
11
- }
package/.prettierrc.json DELETED
@@ -1 +0,0 @@
1
- "@amedia/eslint-config-base/prettier.config"
@@ -1,11 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- declare module "@amedia/browserid" {
2
- // Not complete
3
- export function getBrowserId(): Promise<string>;
4
- }
package/build.js DELETED
@@ -1,28 +0,0 @@
1
- import { build } from 'esbuild';
2
- import npmdts from 'npm-dts';
3
- const { Generator } = npmdts;
4
-
5
- const shared = {
6
- entryPoints: ['src/index.ts'],
7
- bundle: true,
8
- minify: true,
9
- sourcemap: true,
10
- keepNames: true,
11
- };
12
-
13
- build({
14
- ...shared,
15
- outfile: 'dist/user.cjs',
16
- format: 'cjs',
17
- });
18
-
19
- build({
20
- ...shared,
21
- outfile: 'dist/user.js',
22
- format: 'esm',
23
- });
24
-
25
- new Generator({
26
- entry: 'src/index.ts',
27
- output: 'dist/user.d.ts',
28
- }).generate();
package/checkVersion.cjs DELETED
@@ -1,12 +0,0 @@
1
- const pkg = require('./package.json');
2
- const eik = require('./eik.json');
3
-
4
- const FgRed = '\x1b[31m';
5
-
6
- if (pkg.version !== eik.version) {
7
- console.warn(`NPM: ${pkg.version} vs. ${eik.version} :EIK`);
8
- console.error(
9
- `${FgRed}NPM and EIK package versions must be identical. Exiting\n`
10
- );
11
- process.exit(1);
12
- }
package/cloudbuild.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "steps": [
3
- {
4
- "name": "eu.gcr.io/amedia-core/ci/images/npm:14.13.1",
5
- "args": ["install"]
6
- },
7
- {
8
- "name": "eu.gcr.io/amedia-core/ci/images/npm:14.13.1",
9
- "args": ["run", "lint"]
10
- },
11
- {
12
- "name": "eu.gcr.io/amedia-core/ci/images/npm:14.13.1",
13
- "args": ["test"]
14
- },
15
- {
16
- "name": "eu.gcr.io/amedia-core/ci/images/codeclimate-node:latest",
17
- "env": [
18
- "NODE_ENV=production",
19
- "GIT_COMMIT_SHA=$COMMIT_SHA",
20
- "GIT_BRANCH=$BRANCH_NAME",
21
- "CC_TEST_REPORTER_ID=452ebe79c5e6a52d702bf1be68a94575029148333692a6d8a8abf10d6be7a4c5",
22
- "COVERAGE_IN=/workspace/coverage/lcov.info",
23
- "COVERAGE_OUT=/workspace/coverage/lcov.json",
24
- "MODULE_PREFIX=/workspace"
25
- ],
26
- "dir": "${_DIR}"
27
- }
28
- ]
29
- }
package/cop.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "cop.version": 1.0,
3
- "ci": [
4
- {
5
- "buildfile": "cloudbuild.json"
6
- }
7
- ]
8
- }
@@ -1,4 +0,0 @@
1
- import { UserAttributes } from '../types';
2
- export declare const login: (requestedUrl: URL | string) => void;
3
- export declare const logout: () => Promise<void>;
4
- export declare const getSession: () => Promise<UserAttributes>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import { UserAttributes } from '../types';
2
- declare type SetCookieResponse = {
3
- success: boolean;
4
- accessFeatures: string[];
5
- };
6
- export declare const getAccess: (accessFeatures?: string[]) => Promise<Pick<UserAttributes, 'access'>>;
7
- export declare const activate: (accessFeatures: string[]) => Promise<string[]>;
8
- export declare const hasAccess: (currentAccessFeatures: string[], requestedAccessFeatures: string[]) => 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
- export {};
@@ -1,4 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- export {};
@@ -1,9 +0,0 @@
1
- import { Record, Boolean } from 'runtypes';
2
- import { UserAttributes } from '../types';
3
- export declare const PrivacyPreferencesSchema: Record<{
4
- allowResearchUsage: Boolean;
5
- connectWithSurveys: Boolean;
6
- personalizedAds: Boolean;
7
- personalizedContent: Boolean;
8
- }, false>;
9
- export declare const getPrivacyPreferences: () => Promise<Pick<UserAttributes, 'privacyPreferences'>>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export declare const requestStorage: (namespaces: string[]) => void;
2
- export declare const updateStorage: (storage: {
3
- [namespace: string]: object;
4
- }) => void;
5
- export declare const saveStorage: (storage: {
6
- [namespace: string]: object;
7
- }) => void;
@@ -1,2 +0,0 @@
1
- import { UserAttributes } from '../types';
2
- export declare const requestAttributes: (attributes: Array<keyof UserAttributes>) => Promise<void>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export declare type Strategies = Array<{
2
- name: string;
3
- handler: () => Promise<boolean>;
4
- }>;
5
- export declare const AUTOLOGIN_COOKIE_TTL = 60000;
6
- export declare const attemptAutoLoginJob: () => Promise<void>;
7
- export declare const attemptPaywallAutoLogin: () => Promise<void>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export declare const CACHE_KEY = "haveTriedThirdPartyLoginCheck";
2
- export declare const CACHE_TTL: number;
3
- export default function thirdPartyCookie(): Promise<boolean>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- import { CacheEntry, Engine } from '../types';
2
- declare global {
3
- export var amediaUserCache: {
4
- [index: string]: CacheEntry;
5
- };
6
- interface Window {
7
- amediaUserCache?: {
8
- [index: string]: CacheEntry;
9
- };
10
- }
11
- namespace NodeJS {
12
- interface Global {
13
- amediaUserCache?: {
14
- [index: string]: CacheEntry;
15
- };
16
- }
17
- }
18
- }
19
- export declare const get: (key: string) => Promise<CacheEntry>;
20
- export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
21
- export declare const remove: (key: string) => Promise<void>;
22
- export declare const clear: () => Promise<void>;
23
- declare const _default: Engine;
24
- export default _default;
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { Static } from 'runtypes';
2
- import { RuntypeBase } from 'runtypes/lib/runtype';
3
- import { Engine } from './types';
4
- export declare const setCacheEngine: (engine: Engine) => void;
5
- declare const _default: {
6
- get: <T extends RuntypeBase<unknown>>(key: string, validator: T) => Promise<void | Static<T>>;
7
- set: (key: string, value: unknown, expires: number) => Promise<void>;
8
- remove: (key: string) => Promise<void>;
9
- clear: () => Promise<void>;
10
- };
11
- export default _default;
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- export declare type CacheEntry = {
2
- key: string;
3
- data: unknown;
4
- expires: number;
5
- };
6
- export declare type Engine = {
7
- get: (key: string) => Promise<CacheEntry | null>;
8
- set: (key: string, data: unknown, expires: number) => Promise<void>;
9
- remove: (key: string) => Promise<void>;
10
- clear: () => Promise<void>;
11
- };
@@ -1,24 +0,0 @@
1
- import { Unknown, Dictionary } from 'runtypes';
2
- export declare const EuropaSchema: Dictionary<Unknown, string>;
3
- export declare const clearLocalCache: () => Promise<void>;
4
- export declare const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
5
- export declare const getNamespaces: <S extends {
6
- [namespace: string]: {
7
- [index: string]: unknown;
8
- };
9
- }, Namespaces extends (keyof S)[]>(namespaces: Namespaces, options?: {
10
- ignoreCache: boolean;
11
- }) => Promise<Pick<S, Namespaces[number]>>;
12
- export declare const saveNamespace: (namespace: string, data: Object) => Promise<Pick<{
13
- [namespace: string]: {
14
- [index: string]: unknown;
15
- };
16
- }, string>>;
17
- export declare const getAllNamespaces: () => Promise<{
18
- [x: string]: unknown;
19
- }>;
20
- export declare const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<{
21
- [namespace: string]: {
22
- [index: string]: unknown;
23
- };
24
- }, string>>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,30 +0,0 @@
1
- import { Array, Literal, Number, Record, Static, String, Union } from 'runtypes';
2
- import { UserAttributes } from '../types';
3
- export declare type AccessFeatures = string[];
4
- export declare const CheckAccessForPaperSchema: Record<{
5
- status: Literal<"success">;
6
- access: Union<[Literal<"granted">, Literal<"denied">]>;
7
- publication: Record<{
8
- id: Number;
9
- domain: String;
10
- }, false>;
11
- access_features: Array<String, false>;
12
- }, false>;
13
- export declare type CheckAccessForPaper = Static<typeof CheckAccessForPaperSchema>;
14
- declare const GetVstokenSchema: Record<{
15
- status: Literal<"success">;
16
- cookie: String;
17
- access_features: Array<String, false>;
18
- }, false>;
19
- export declare type GetVstoken = Static<typeof GetVstokenSchema>;
20
- declare const GetNonUserAccessSchema: Record<{
21
- status: Literal<"success">;
22
- vstoken_cookie: String;
23
- uuid: String;
24
- access_features: Array<String, false>;
25
- }, false>;
26
- export declare type GetNonUserAccess = Static<typeof GetNonUserAccessSchema>;
27
- export declare const checkForAccess: (publicationDomain: string, accessFeatures: AccessFeatures) => Promise<Pick<UserAttributes, 'access'>>;
28
- export declare const getUserAccess: (publicationDomain: string) => Promise<GetVstoken>;
29
- export declare const getNonUserAccess: (publicationDomain: string) => Promise<GetNonUserAccess>;
30
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export declare class UserDeactivatedError extends Error {
2
- }
3
- export declare const activateSubscription: (accessFeatures: string[]) => Promise<string[]>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- declare type Context = Record<string, unknown>;
2
- declare const log: {
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;
7
- };
8
- export default log;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import { UserAttributes } from '../types';
2
- export declare const getInfo: (publicationDomain: string, browserId: string, trackingKey?: string | undefined) => Promise<Pick<UserAttributes, 'extraData'>>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { UserAttributes } from '../types';
2
- export declare const resolveBadPlutoResponse: (response: Response) => Promise<void>;
3
- export declare const getCurrentSession: () => Promise<UserAttributes>;
4
- export declare const removeSession: (domain: string) => Promise<void>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- export declare enum ActivationEvents {
2
- REQUEST_ACTIVATION = "amedia-user.activation.request-activation",
3
- ON_ACTIVATION_COMPLETE = "amedia-user.activation.on-activation-complete"
4
- }
5
- declare global {
6
- interface WindowEventMap {
7
- [ActivationEvents.REQUEST_ACTIVATION]: CustomEvent<{
8
- accessFeatures: string[];
9
- }>;
10
- [ActivationEvents.ON_ACTIVATION_COMPLETE]: CustomEvent<{
11
- accessFeatures: string[];
12
- }>;
13
- }
14
- }
15
- export declare const listenForActivationRequests: () => void;
@@ -1,17 +0,0 @@
1
- export declare enum AuthenticationEvents {
2
- REQUEST_LOGIN = "amedia-user.authentication.request-login",
3
- REQUEST_LOGOUT = "amedia-user.authentication.request-logout",
4
- ON_LOGGED_OUT = "amedia-user.authentication.on-logged-out"
5
- }
6
- declare global {
7
- interface WindowEventMap {
8
- [AuthenticationEvents.REQUEST_LOGIN]: CustomEvent<{
9
- requestedUrl: string;
10
- }>;
11
- [AuthenticationEvents.REQUEST_LOGOUT]: CustomEvent<{
12
- onLoggedOut: () => void;
13
- }>;
14
- [AuthenticationEvents.ON_LOGGED_OUT]: CustomEvent;
15
- }
16
- }
17
- export declare const listenForAuthenticationRequests: () => void;
@@ -1,29 +0,0 @@
1
- import { State, UserAttributes } from '../types';
2
- export declare enum AmediaUserEvents {
3
- REQUEST_STATE = "amedia-user.request-state",
4
- REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
5
- REQUEST_STORAGE_NAMESPACES = "amedia-user.request-storage-namespaces",
6
- SAVE_STORAGE = "amedia-user.save-storage-namespaces",
7
- UPDATE_STORAGE = "amedia-user.update-storage-namespaces",
8
- ON_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated",
9
- ON_STATE_UPDATED = "amedia-user.on-state-updated",
10
- ON_STORAGE_UPDATED = "amedia-user.on-storage-updated"
11
- }
12
- declare global {
13
- interface WindowEventMap {
14
- [AmediaUserEvents.REQUEST_STATE]: CustomEvent;
15
- [AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
16
- [AmediaUserEvents.REQUEST_STORAGE_NAMESPACES]: CustomEvent<Array<string>>;
17
- [AmediaUserEvents.SAVE_STORAGE]: CustomEvent<{
18
- [namespace: string]: object;
19
- }>;
20
- [AmediaUserEvents.UPDATE_STORAGE]: CustomEvent<{
21
- [namespace: string]: object;
22
- }>;
23
- [AmediaUserEvents.ON_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
24
- [AmediaUserEvents.ON_STATE_UPDATED]: CustomEvent<State>;
25
- [AmediaUserEvents.ON_STORAGE_UPDATED]: CustomEvent<{
26
- [index: string]: unknown;
27
- }>;
28
- }
29
- }
@@ -1 +0,0 @@
1
- export declare const listenForStateRequests: () => void;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const listenForStorageRequests: () => void;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const listenForUserAttributeRequests: () => void;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- declare class PaywallError extends Error {
2
- static ERROR_RELOADED_NO_ACCESS: string;
3
- static ERROR_ENABLING_ACCESS_FAILED: string;
4
- static ERROR_NO_ACCESS_AFTER_SUCCESSFUL_ACTIVATION_WITH_REQUESTED_ACCESS_FEATURES: string;
5
- code: string;
6
- constructor(message: string, code: string);
7
- }
8
- export default PaywallError;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/dist/index.d.ts DELETED
@@ -1,20 +0,0 @@
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;
18
- export declare const saveStorage: (storage: {
19
- [index: string]: Object;
20
- }) => void;
@@ -1,10 +0,0 @@
1
- declare enum JanitorEvents {
2
- LOADED = "amedia-user.janitor.loaded"
3
- }
4
- declare global {
5
- interface WindowEventMap {
6
- [JanitorEvents.LOADED]: CustomEvent<{}>;
7
- }
8
- }
9
- export declare const runJanitor: () => Promise<void>;
10
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export default function accessCookieRefresher(): Promise<[void, void]>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { UserAttributes } from '../../types';
2
- export declare function getCookieValue(attributes: UserAttributes): string;
3
- export default function daxSubCookieHandler(): Promise<void>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare function removeUserStorage(): void;
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- export declare type UnlockResponse = {
2
- isLoggedIn: boolean;
3
- hasAccess: boolean;
4
- accessFeatures: string[];
5
- };
6
- declare class PaywallUnlockRequest {
7
- private requestedAccessFeatures;
8
- private reload;
9
- private requestedUrl;
10
- withAccessFeatures(accessFeatures: string[]): this;
11
- reloadOnAccess(): this;
12
- redirectOnAccess(requestedUrl: string): this;
13
- tryUnlock(): Promise<UnlockResponse>;
14
- private setAccessCookiesAndGetAccessFeatures;
15
- private activateAccess;
16
- }
17
- export default PaywallUnlockRequest;
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import { State, UserAttributes } from '../types';
2
- declare class UserDataRequest<UA extends UserAttributes, S extends {
3
- [index: string]: unknown;
4
- }, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends Record<string, object> = {
5
- state: State;
6
- }> {
7
- private attributes?;
8
- private namespaces?;
9
- constructor(attributes?: Attributes | undefined, namespaces?: Namespaces | undefined);
10
- withAttributes<NewAttributes extends Array<keyof UA>>(attributes: NewAttributes): UserDataRequest<UA, S, (Attributes[number] & NewAttributes[number])[], Namespaces, SubscribeResponse & {
11
- attributes: Pick<UA, Attributes[number] & NewAttributes[number]>;
12
- }>;
13
- withStorage<NewNamespaces extends Array<string>>(namespaces: NewNamespaces): UserDataRequest<UA, S, Attributes, (Namespaces[number] & NewNamespaces[number])[], SubscribeResponse & {
14
- storage: Pick<S, Namespaces[number] & NewNamespaces[number]>;
15
- }>;
16
- subscribe(onData: (data: SubscribeResponse) => void): void;
17
- fetch(): Promise<SubscribeResponse>;
18
- private processUserAttributesEvent;
19
- private processStorageEvent;
20
- private setupLocalCache;
21
- }
22
- export default UserDataRequest;
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- export declare const getCookie: (name: string) => string | {
2
- [index: string]: unknown;
3
- } | null | undefined;
4
- export declare function setCookie(name: string, value?: unknown, validTimeInDateOrDays?: Date | number, path?: string, secure?: boolean): string;
5
- export declare function removeCookie(name: string): void;
6
- /**
7
- * This function should only be used in tests, as it will remove all cookies a user has on the domain.
8
- */
9
- export declare function removeAllCookies(): void;
package/dist/lib/rpc.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { RPCclient } from '@amedia/frontend-rpc';
2
- interface LocalRPCclient extends RPCclient {
3
- userAuthenticated: (isLoggedIn: boolean) => void;
4
- }
5
- export declare const getRPCClient: () => LocalRPCclient;
6
- export {};