@amedia/user 0.7.3 → 0.7.4
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 +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/{clients → services}/jupiter.d.ts +5 -6
- package/dist/services/jupiter.js +72 -0
- package/dist/services/pluto.d.ts +12 -0
- package/dist/services/pluto.js +40 -0
- package/package.json +1 -1
- package/src/actions/authorization.ts +2 -2
- package/src/actions/preferences.spec.ts +1 -3
- package/src/cache/index.spec.ts +2 -2
- package/src/clients/europa.spec.ts +0 -2
- package/src/clients/jupiter.spec.ts +26 -0
- package/src/clients/jupiter.ts +3 -2
- package/src/clients/mercury.spec.ts +5 -7
- package/src/clients/mercury.ts +4 -2
- package/src/clients/pluto.spec.ts +0 -2
- package/src/eventHandlers/activation.ts +2 -2
- package/src/index-authentcation.spec.ts +2 -1
- package/src/index-subscription.spec.ts +20 -13
- package/src/index.ts +58 -34
- package/src/utils/getOrUpdate.spec.ts +2 -2
- 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 -17
- package/dist/clients/europa.spec.d.ts +0 -1
- 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 -2
- package/dist/clients/nebula.spec.d.ts +0 -1
- package/dist/clients/pluto.d.ts +0 -3
- 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-subscription.spec.d.ts +0 -4
- package/dist/index.js.LICENSE.txt +0 -14
- package/dist/lib/cookie.d.ts +0 -5
- package/dist/lib/rpc.d.ts +0 -6
- package/dist/store/index.d.ts +0 -13
- package/dist/store/index.spec.d.ts +0 -1
- package/dist/types.d.ts +0 -27
- package/dist/utils/customEventWrapper.d.ts +0 -17
- package/dist/utils/deepEquals.d.ts +0 -4
- package/dist/utils/getOrUpdate.d.ts +0 -6
- package/dist/utils/getOrUpdate.spec.d.ts +0 -1
- 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/cache/types.d.ts
DELETED
|
@@ -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
|
-
};
|
package/dist/clients/europa.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Record, Unknown, Dictionary } from 'runtypes';
|
|
2
|
-
import { UserAttributes } from '../types';
|
|
3
|
-
export declare const EuropaSchema: Record<{
|
|
4
|
-
namespaces: Dictionary<Unknown, string>;
|
|
5
|
-
}, false>;
|
|
6
|
-
export declare const clearLocalCache: () => Promise<void>;
|
|
7
|
-
export declare const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
|
|
8
|
-
export declare const getNamespaces: (namespaces: string[], options?: {
|
|
9
|
-
ignoreCache: boolean;
|
|
10
|
-
}) => Promise<Pick<UserAttributes, 'storage'>>;
|
|
11
|
-
export declare const saveNamespace: (namespace: string, data: Object) => Promise<Pick<UserAttributes, "storage">>;
|
|
12
|
-
export declare const getAllNamespaces: () => Promise<{
|
|
13
|
-
namespaces: {
|
|
14
|
-
[x: string]: unknown;
|
|
15
|
-
};
|
|
16
|
-
}>;
|
|
17
|
-
export declare const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<UserAttributes, "storage">>;
|
|
@@ -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;
|
package/dist/clients/nebula.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/clients/pluto.d.ts
DELETED
|
@@ -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,14 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
localForage -- Offline Storage, Improved
|
|
3
|
-
Version 1.9.0
|
|
4
|
-
https://localforage.github.io/localForage
|
|
5
|
-
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/*!
|
|
9
|
-
* JavaScript Cookie v2.2.1
|
|
10
|
-
* https://github.com/js-cookie/js-cookie
|
|
11
|
-
*
|
|
12
|
-
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
|
13
|
-
* Released under the MIT license
|
|
14
|
-
*/
|
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
package/dist/store/index.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: <K extends keyof StoreDataMap, T = StoreDataMap[K]>(key: K) => T | undefined;
|
|
10
|
-
on: <K_1 extends keyof StoreDataMap, T_1 = StoreDataMap[K_1]>(key: K_1, listener: Listener<T_1>) => void;
|
|
11
|
-
clear: () => void;
|
|
12
|
-
};
|
|
13
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export declare type UserAttributes = {
|
|
2
|
-
name?: string;
|
|
3
|
-
email?: string;
|
|
4
|
-
phone?: string;
|
|
5
|
-
trackingKey?: string;
|
|
6
|
-
extraData?: {
|
|
7
|
-
[index: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
access?: string[];
|
|
10
|
-
privacyPreferences?: PrivacyPreferences;
|
|
11
|
-
storage?: {
|
|
12
|
-
[index: string]: unknown;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export declare type State = {
|
|
16
|
-
isLoggedIn: boolean;
|
|
17
|
-
emergencyMode?: string[];
|
|
18
|
-
};
|
|
19
|
-
export declare type AnonymousAttributes = {
|
|
20
|
-
age: number;
|
|
21
|
-
};
|
|
22
|
-
export declare type PrivacyPreferences = {
|
|
23
|
-
allowResearchUsage: Boolean;
|
|
24
|
-
connectWithSurveys: Boolean;
|
|
25
|
-
personalizedAds: Boolean;
|
|
26
|
-
personalizedContent: Boolean;
|
|
27
|
-
};
|
|
@@ -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;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Runtype, Static } from 'runtypes';
|
|
2
|
-
export declare type DataFetcherWithCacheTTL<T extends Runtype> = Promise<{
|
|
3
|
-
ttl: number;
|
|
4
|
-
data: Static<T>;
|
|
5
|
-
}>;
|
|
6
|
-
export default function getOrUpdate<T extends Runtype>(key: string, schema: T, fetch: () => DataFetcherWithCacheTTL<T>, cacheQualifier?: (cacheData: Static<T>) => boolean): Promise<Static<T>>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
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 {};
|