@amedia/user 0.6.0 → 0.7.0
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/.codeclimate.yml +7 -0
- package/cloudbuild.json +1 -1
- package/dist/index.d.ts +6 -17
- package/dist/index.js +7 -2
- package/dist/lib/authentication.d.ts +17 -0
- package/dist/lib/authentication.js +74 -0
- package/dist/lib/authorization.d.ts +14 -0
- package/dist/lib/authorization.js +51 -0
- package/dist/{cache/engines/indexeddb.d.ts → lib/cache/db.d.ts} +2 -3
- package/dist/lib/cache/db.js +13 -0
- package/dist/lib/cache/global.d.ts +9 -0
- package/dist/lib/cache/global.js +16 -0
- package/dist/lib/cache/types.d.ts +5 -0
- package/dist/lib/cache/types.js +2 -0
- package/dist/lib/queue.d.ts +5 -0
- package/dist/lib/queue.js +17 -0
- package/dist/lib/tools.d.ts +1 -0
- package/dist/lib/tools.js +2 -0
- package/dist/lib/user.d.ts +2 -0
- package/dist/lib/user.js +3 -0
- package/dist/services/cache.d.ts +9 -0
- package/dist/services/cache.js +34 -0
- package/dist/services/jupiter.d.ts +4 -4
- package/dist/services/jupiter.js +72 -0
- package/dist/services/pluto.d.ts +10 -6
- package/dist/services/pluto.js +40 -0
- package/package.json +2 -1
- package/src/actions/authentication.ts +5 -38
- package/src/actions/userData.ts +15 -19
- package/src/clients/europa.ts +5 -9
- package/src/clients/jupiter.spec.ts +5 -5
- package/src/clients/jupiter.ts +28 -22
- package/src/clients/nebula.spec.ts +11 -11
- package/src/clients/nebula.ts +33 -10
- package/src/clients/pluto.spec.ts +6 -3
- package/src/clients/pluto.ts +26 -16
- package/src/eventHandlers/userAttributes.ts +15 -8
- package/src/{index-userdata.spec.ts → index-subscription.spec.ts} +49 -57
- package/src/store/{store.spec.ts → index.spec.ts} +1 -1
- package/src/store/{store.ts → index.ts} +11 -6
- package/src/types.ts +1 -1
- package/src/utils/getOrUpdate.ts +12 -11
- package/dist/actions/authentication.d.ts +0 -4
- package/dist/actions/authorization.d.ts +0 -3
- package/dist/actions/preferences.d.ts +0 -9
- package/dist/actions/preferences.spec.d.ts +0 -1
- package/dist/actions/userData.d.ts +0 -2
- package/dist/cache/engines/global.d.ts +0 -21
- package/dist/cache/engines/global.spec.d.ts +0 -1
- package/dist/cache/index.d.ts +0 -11
- package/dist/cache/index.spec.d.ts +0 -4
- package/dist/cache/types.d.ts +0 -11
- package/dist/clients/europa.d.ts +0 -12
- package/dist/clients/europa.spec.d.ts +0 -1
- package/dist/clients/jupiter.d.ts +0 -29
- package/dist/clients/jupiter.spec.d.ts +0 -1
- package/dist/clients/mercury.d.ts +0 -18
- package/dist/clients/mercury.spec.d.ts +0 -4
- package/dist/clients/nebula.d.ts +0 -22
- package/dist/clients/nebula.spec.d.ts +0 -1
- package/dist/clients/pluto.d.ts +0 -8
- package/dist/clients/pluto.spec.d.ts +0 -1
- package/dist/eventHandlers/activation.d.ts +0 -15
- package/dist/eventHandlers/authentication.d.ts +0 -17
- package/dist/eventHandlers/userAttributes.d.ts +0 -14
- package/dist/index-authentcation.spec.d.ts +0 -4
- package/dist/index-userdata.spec.d.ts +0 -4
- package/dist/index.js.LICENSE.txt +0 -8
- package/dist/lib/cookie.d.ts +0 -5
- package/dist/lib/rpc.d.ts +0 -6
- package/dist/services/europa.d.ts +0 -12
- package/dist/services/europa.spec.d.ts +0 -1
- package/dist/services/jupiter.spec.d.ts +0 -1
- package/dist/services/mercury.d.ts +0 -18
- package/dist/services/mercury.spec.d.ts +0 -4
- package/dist/services/nebula.d.ts +0 -22
- package/dist/services/nebula.spec.d.ts +0 -1
- package/dist/services/pluto.spec.d.ts +0 -1
- package/dist/store/store.d.ts +0 -13
- package/dist/store/store.spec.d.ts +0 -1
- package/dist/types.d.ts +0 -22
- package/dist/utils/customEventWrapper.d.ts +0 -17
- package/dist/utils/getOrUpdate.d.ts +0 -3
- package/dist/utils/log.d.ts +0 -26
- package/dist/utils/queue.d.ts +0 -12
- package/dist/utils/url.d.ts +0 -3
- package/dist/utils/url.spec.d.ts +0 -1
package/dist/clients/nebula.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Static, Partial, Dictionary, Unknown, String, Number, Boolean } from 'runtypes';
|
|
2
|
-
declare const InfoSchema: import("runtypes").Intersect<[Dictionary<Unknown, string>, Partial<{
|
|
3
|
-
ad_segments: String;
|
|
4
|
-
ad_segments_user: String;
|
|
5
|
-
age: Number;
|
|
6
|
-
age_user: Number;
|
|
7
|
-
birth_year: String;
|
|
8
|
-
birth_year_user: String;
|
|
9
|
-
gender: String;
|
|
10
|
-
gender_user: String;
|
|
11
|
-
grunnkrets: String;
|
|
12
|
-
grunnkrets_user: String;
|
|
13
|
-
postcode: String;
|
|
14
|
-
postcode_user: String;
|
|
15
|
-
shared_account: Boolean;
|
|
16
|
-
shared_account_user: Boolean;
|
|
17
|
-
user_grouping_number: String;
|
|
18
|
-
user_grouping_number_user: String;
|
|
19
|
-
}, false>]>;
|
|
20
|
-
export declare type Info = Static<typeof InfoSchema>;
|
|
21
|
-
export declare const getInfo: (userKey: string, publicationDomain: string, browserId: string) => Promise<Info>;
|
|
22
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/clients/pluto.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Record, Static, String } from 'runtypes';
|
|
2
|
-
export declare const InternalSessionSchema: Record<{
|
|
3
|
-
name: String;
|
|
4
|
-
trackingKey: String;
|
|
5
|
-
}, false>;
|
|
6
|
-
export declare type Session = Static<typeof InternalSessionSchema>;
|
|
7
|
-
export declare const getCurrentSession: () => Promise<Session>;
|
|
8
|
-
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
|
-
accessFeature: string;
|
|
9
|
-
}>;
|
|
10
|
-
[ActivationEvents.ON_ACTIVATION_COMPLETE]: CustomEvent<{
|
|
11
|
-
hasAccess: boolean;
|
|
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,14 +0,0 @@
|
|
|
1
|
-
import { State, UserAttributes } from '../types';
|
|
2
|
-
export declare enum AmediaUserEvents {
|
|
3
|
-
REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
|
|
4
|
-
ON_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated",
|
|
5
|
-
ON_STATE_UPDATED = "amedia-user.on-state-updated"
|
|
6
|
-
}
|
|
7
|
-
declare global {
|
|
8
|
-
interface WindowEventMap {
|
|
9
|
-
[AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
|
|
10
|
-
[AmediaUserEvents.ON_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
|
|
11
|
-
[AmediaUserEvents.ON_STATE_UPDATED]: CustomEvent<State>;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export declare const listenForUserAttributeRequests: () => void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Lodash <https://lodash.com/>
|
|
4
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
5
|
-
* Released under MIT license <https://lodash.com/license>
|
|
6
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
7
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
8
|
-
*/
|
package/dist/lib/cookie.d.ts
DELETED
|
@@ -1,5 +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: any): void;
|
package/dist/lib/rpc.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Record, Partial } from 'runtypes';
|
|
2
|
-
export declare const EuropaSchema: Record<{
|
|
3
|
-
namespaces: Partial<{}, false>;
|
|
4
|
-
}, false>;
|
|
5
|
-
export declare const clearLocalCache: () => Promise<void>;
|
|
6
|
-
export declare const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
|
|
7
|
-
export declare const getNamespace: (namespace: string, options?: {
|
|
8
|
-
ignoreCache: boolean;
|
|
9
|
-
}) => Promise<any>;
|
|
10
|
-
export declare const saveNamespace: (namespace: string, data: Object) => Promise<any>;
|
|
11
|
-
export declare const getAllNamespaces: () => Promise<{}>;
|
|
12
|
-
export declare const deleteNamespaceKey: (namespace: string, key: string) => Promise<any>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare const log: {
|
|
2
|
-
error: (message: string, context: {
|
|
3
|
-
[index: string]: any;
|
|
4
|
-
}) => void;
|
|
5
|
-
warn: (message: string, context: {
|
|
6
|
-
[index: string]: any;
|
|
7
|
-
}) => void;
|
|
8
|
-
info: (message: string, context: {
|
|
9
|
-
[index: string]: any;
|
|
10
|
-
}) => void;
|
|
11
|
-
debug: (message: string, context: {
|
|
12
|
-
[index: string]: any;
|
|
13
|
-
}) => void;
|
|
14
|
-
};
|
|
15
|
-
export declare class UserDeactivatedError extends Error {
|
|
16
|
-
}
|
|
17
|
-
export declare const activateSubscription: (accessFeature: string) => Promise<boolean>;
|
|
18
|
-
export default log;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Static, Partial, Dictionary, Unknown, String, Number, Boolean } from 'runtypes';
|
|
2
|
-
declare const InfoSchema: import("runtypes").Intersect<[Dictionary<Unknown, string>, Partial<{
|
|
3
|
-
ad_segments: String;
|
|
4
|
-
ad_segments_user: String;
|
|
5
|
-
age: Number;
|
|
6
|
-
age_user: Number;
|
|
7
|
-
birth_year: String;
|
|
8
|
-
birth_year_user: String;
|
|
9
|
-
gender: String;
|
|
10
|
-
gender_user: String;
|
|
11
|
-
grunnkrets: String;
|
|
12
|
-
grunnkrets_user: String;
|
|
13
|
-
postcode: String;
|
|
14
|
-
postcode_user: String;
|
|
15
|
-
shared_account: Boolean;
|
|
16
|
-
shared_account_user: Boolean;
|
|
17
|
-
user_grouping_number: String;
|
|
18
|
-
user_grouping_number_user: String;
|
|
19
|
-
}, false>]>;
|
|
20
|
-
export declare type Info = Static<typeof InfoSchema>;
|
|
21
|
-
export declare const getInfo: (userKey: string, publicationDomain: string, browserId: string) => Promise<Info>;
|
|
22
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/store/store.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { State, UserAttributes } from '../types';
|
|
2
|
-
declare type StoreDataMap = {
|
|
3
|
-
userAttributes: UserAttributes;
|
|
4
|
-
state: State;
|
|
5
|
-
};
|
|
6
|
-
declare type Listener<T> = (data: T) => void;
|
|
7
|
-
declare const _default: {
|
|
8
|
-
set: (key: keyof StoreDataMap, value: UserAttributes | State) => void;
|
|
9
|
-
get: (key: keyof StoreDataMap) => UserAttributes | State | undefined;
|
|
10
|
-
on: (key: keyof StoreDataMap, listener: Listener<UserAttributes | State>) => void;
|
|
11
|
-
clear: () => void;
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare type UserAttributes = {
|
|
2
|
-
name?: string;
|
|
3
|
-
email?: string;
|
|
4
|
-
phone?: string;
|
|
5
|
-
trackingKey?: string;
|
|
6
|
-
extraData?: [];
|
|
7
|
-
access?: string[];
|
|
8
|
-
privacyPreferences?: PrivacyPreferences;
|
|
9
|
-
};
|
|
10
|
-
export declare type State = {
|
|
11
|
-
isLoggedIn: boolean;
|
|
12
|
-
emergencyMode?: string[];
|
|
13
|
-
};
|
|
14
|
-
export declare type AnonymousAttributes = {
|
|
15
|
-
age: number;
|
|
16
|
-
};
|
|
17
|
-
export declare type PrivacyPreferences = {
|
|
18
|
-
allowResearchUsage: Boolean;
|
|
19
|
-
connectWithSurveys: Boolean;
|
|
20
|
-
personalizedAds: Boolean;
|
|
21
|
-
personalizedContent: Boolean;
|
|
22
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const setRootElement: (element: any) => void;
|
|
2
|
-
/**
|
|
3
|
-
* This listener MUST be used by all listeners in ../eventHandlers
|
|
4
|
-
* We want to ensure that only _one_ instance of this package actually
|
|
5
|
-
* orchestrates data and performs requests against backends.
|
|
6
|
-
* @param type
|
|
7
|
-
* @param listener
|
|
8
|
-
*/
|
|
9
|
-
export declare const listenWithExclusivity: <T extends keyof WindowEventMap>(type: T, listener: (this: Window, ev: WindowEventMap[T]) => void) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Use this for response listeners. (../index.ts) where we want
|
|
12
|
-
* all updates with data - no matter who sent the actual request
|
|
13
|
-
* @param type
|
|
14
|
-
* @param listener
|
|
15
|
-
*/
|
|
16
|
-
export declare const listenForAllEvents: <T extends keyof WindowEventMap>(type: T, listener: (this: Window, ev: WindowEventMap[T]) => void) => void;
|
|
17
|
-
export declare const dispatch: <T extends Event>(event: T) => void;
|
package/dist/utils/log.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare type Logger = {
|
|
2
|
-
debug: (message: string | any, ...extra: any[]) => void;
|
|
3
|
-
info: (message: string | any, ...extra: any[]) => void;
|
|
4
|
-
warn: (message: string | any, ...extra: any[]) => void;
|
|
5
|
-
error: (message: string | any, ...extra: any[]) => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const setLogger: (engine: Logger) => void;
|
|
8
|
-
declare const _default: {
|
|
9
|
-
debug: {
|
|
10
|
-
(...data: any[]): void;
|
|
11
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
12
|
-
};
|
|
13
|
-
info: {
|
|
14
|
-
(...data: any[]): void;
|
|
15
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
16
|
-
};
|
|
17
|
-
warn: {
|
|
18
|
-
(...data: any[]): void;
|
|
19
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
20
|
-
};
|
|
21
|
-
error: {
|
|
22
|
-
(...data: any[]): void;
|
|
23
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export default _default;
|
package/dist/utils/queue.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
add: (key: string, promiseCallbacks: {
|
|
3
|
-
resolve: (PromiseLike: any) => void;
|
|
4
|
-
reject: (reason?: any) => void;
|
|
5
|
-
}) => void;
|
|
6
|
-
getAll: (key: string) => {
|
|
7
|
-
resolve: (PromiseLike: any) => void;
|
|
8
|
-
reject: (reason?: any) => void;
|
|
9
|
-
}[];
|
|
10
|
-
peekQueueSize: (key: string) => number;
|
|
11
|
-
};
|
|
12
|
-
export default _default;
|
package/dist/utils/url.d.ts
DELETED
package/dist/utils/url.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|