@amedia/user 0.13.17 → 0.13.18
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/amedia-user-js.iml +9 -0
- package/build.js +0 -1
- package/dist/cache/engines/indexeddb.d.ts +7 -0
- package/dist/index.d.ts +12 -0
- 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.LICENSE.txt +14 -0
- package/dist/index.js.map +3 -3
- package/dist/janitor/index.spec.d.ts +4 -0
- package/dist/janitor/jobs/daxsubCookie.d.ts +2 -0
- package/dist/janitor/jobs/daxsubCookie.spec.d.ts +4 -0
- package/dist/lib/PaywallUnlocker.d.ts +16 -0
- package/dist/lib/PaywallUnlocker.spec.d.ts +4 -0
- package/dist/lib/User.d.ts +21 -0
- package/dist/utils/logValidationError.d.ts +1 -0
- package/esm/actions/authentication.d.ts +5 -0
- package/esm/actions/authentication.spec.d.ts +4 -0
- package/esm/actions/authorization.d.ts +9 -0
- package/esm/actions/preferences.d.ts +9 -0
- package/esm/actions/preferences.spec.d.ts +1 -0
- package/esm/actions/storage.d.ts +4 -0
- package/esm/actions/userData.d.ts +2 -0
- package/esm/autologin/index.d.ts +1 -0
- package/esm/autologin/thirdPartyCookie.d.ts +3 -0
- package/esm/autologin/thirdPartyCookie.spec.d.ts +1 -0
- package/esm/cache/engines/global.d.ts +21 -0
- package/esm/cache/engines/global.spec.d.ts +1 -0
- package/esm/cache/engines/indexeddb.d.ts +7 -0
- package/esm/cache/index.d.ts +11 -0
- package/esm/cache/index.spec.d.ts +4 -0
- package/esm/cache/types.d.ts +11 -0
- package/esm/clients/europa.d.ts +28 -0
- package/esm/clients/europa.spec.d.ts +1 -0
- package/esm/clients/jupiter.d.ts +30 -0
- package/esm/clients/jupiter.spec.d.ts +1 -0
- package/esm/clients/mercury.d.ts +18 -0
- package/esm/clients/mercury.spec.d.ts +4 -0
- package/esm/clients/nebula.d.ts +2 -0
- package/esm/clients/nebula.spec.d.ts +1 -0
- package/esm/clients/pluto.d.ts +3 -0
- package/esm/clients/pluto.spec.d.ts +1 -0
- package/esm/eventHandlers/activation.d.ts +15 -0
- package/esm/eventHandlers/authentication.d.ts +17 -0
- package/esm/eventHandlers/userAttributes.d.ts +24 -0
- package/esm/exceptions/PaywallError.d.ts +7 -0
- package/esm/index-authentcation.spec.d.ts +4 -0
- package/esm/index-storage.spec.d.ts +4 -0
- package/esm/index-subscription.spec.d.ts +4 -0
- package/esm/index.d.ts +26 -0
- package/esm/janitor/index.d.ts +10 -0
- package/esm/janitor/jobs/accessCookieRefresher.d.ts +1 -0
- package/esm/janitor/jobs/accessCookieRefresher.spec.d.ts +4 -0
- package/esm/lib/PaywallUnlocker.d.ts +16 -0
- package/esm/lib/PaywallUnlocker.spec.d.ts +4 -0
- package/esm/lib/User.d.ts +21 -0
- package/esm/lib/cookie.d.ts +5 -0
- package/esm/lib/rpc.d.ts +6 -0
- package/esm/store/index.d.ts +22 -0
- package/esm/store/index.spec.d.ts +1 -0
- package/esm/types.d.ts +22 -0
- package/esm/user.js +2 -0
- package/esm/user.js.map +1 -0
- package/esm/utils/customEventWrapper.d.ts +17 -0
- package/esm/utils/deepEquals.d.ts +4 -0
- package/esm/utils/getOrUpdate.d.ts +6 -0
- package/esm/utils/getOrUpdate.spec.d.ts +1 -0
- package/esm/utils/location.d.ts +3 -0
- package/esm/utils/log.d.ts +26 -0
- package/esm/utils/queue.d.ts +12 -0
- package/esm/utils/url.d.ts +6 -0
- package/esm/utils/url.spec.d.ts +1 -0
- package/package.json +2 -2
- package/src/actions/authentication.ts +1 -0
- package/src/janitor/index.ts +7 -1
- package/src/janitor/jobs/daxsubCookie.spec.ts +117 -0
- package/src/janitor/jobs/daxsubCookie.ts +37 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare class PaywallUnlocker {
|
|
2
|
+
private requestedAccessFeatures;
|
|
3
|
+
private reload;
|
|
4
|
+
private requestedUrl;
|
|
5
|
+
withAccessFeatures(accessFeatures: string[]): this;
|
|
6
|
+
reloadOnAccess(): this;
|
|
7
|
+
redirectOnAccess(requestedUrl: string): this;
|
|
8
|
+
tryUnlock(): Promise<{
|
|
9
|
+
isLoggedIn: boolean;
|
|
10
|
+
hasAccess: boolean;
|
|
11
|
+
accessFeatures: string[];
|
|
12
|
+
}>;
|
|
13
|
+
private resolveActualAccessFeatures;
|
|
14
|
+
private setAccessCookiesAndPerformRequestedActions;
|
|
15
|
+
}
|
|
16
|
+
export default PaywallUnlocker;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { State, UserAttributes } from '../types';
|
|
2
|
+
declare class User<UA extends UserAttributes, S extends {
|
|
3
|
+
[index: string]: unknown;
|
|
4
|
+
}, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends {} = {
|
|
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): User<UA, S, (Attributes[number] & NewAttributes[number])[], Namespaces, SubscribeResponse & {
|
|
11
|
+
attributes: Pick<UA, Attributes[number] & NewAttributes[number]>;
|
|
12
|
+
}>;
|
|
13
|
+
withStorage<NewNamespaces extends Array<string>>(...namespace: NewNamespaces): User<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
|
+
private processUserAttributesEvent;
|
|
18
|
+
private processStorageEvent;
|
|
19
|
+
private setupLocalCache;
|
|
20
|
+
}
|
|
21
|
+
export default User;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function logValidationError(name: string, error: Error, extra?: Object): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
5
|
+
export declare const isLoggedIn: () => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UserAttributes } from '../types';
|
|
2
|
+
export declare const getAccess: (accessFeatures?: string[]) => Promise<Pick<UserAttributes, 'access'>>;
|
|
3
|
+
export declare const activate: (accessFeatures: string[]) => Promise<boolean>;
|
|
4
|
+
export declare const hasAccess: (currentAccessFeatures: string[], requestedAccessFeatures: string[]) => boolean;
|
|
5
|
+
export declare const setUserAccessCookie: (publicationDomain: any) => Promise<boolean>;
|
|
6
|
+
export declare const setNonUserAccessCookie: (publicationDomain: any) => Promise<boolean>;
|
|
7
|
+
export declare const hasRecentlyTriedToUnlockPaywall: () => boolean;
|
|
8
|
+
export declare const setAccessCookies: (publicationDomain: any) => Promise<boolean>;
|
|
9
|
+
export declare const setHasTriedToUnlockPaywall: () => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
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'>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const attemptAutologin: () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CacheEntry, Engine } from '../types';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
amediaUserCache?: {
|
|
5
|
+
[index: string]: CacheEntry;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
namespace NodeJS {
|
|
9
|
+
interface Global {
|
|
10
|
+
amediaUserCache?: {
|
|
11
|
+
[index: string]: CacheEntry;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare const get: (key: string) => Promise<CacheEntry>;
|
|
17
|
+
export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
18
|
+
export declare const remove: (key: string) => Promise<void>;
|
|
19
|
+
export declare const clear: () => Promise<void>;
|
|
20
|
+
declare const _default: Engine;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CacheEntry, Engine } from '../types';
|
|
2
|
+
export declare const get: (key: string) => Promise<CacheEntry>;
|
|
3
|
+
export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
4
|
+
export declare const remove: (key: string) => Promise<void>;
|
|
5
|
+
export declare const clear: () => Promise<void>;
|
|
6
|
+
declare const _default: Engine;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Record, Unknown, Dictionary } from 'runtypes';
|
|
2
|
+
export declare const EuropaSchema: Record<{
|
|
3
|
+
namespaces: Dictionary<Unknown, string>;
|
|
4
|
+
}, false>;
|
|
5
|
+
export declare const clearLocalCache: () => Promise<void>;
|
|
6
|
+
export declare const updateNamespace: (namespace: string, data: Object) => Promise<void | {}>;
|
|
7
|
+
export declare const getNamespaces: <S extends {
|
|
8
|
+
[namespace: string]: {
|
|
9
|
+
[index: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
}, Namespaces extends (keyof S)[]>(namespaces: Namespaces, options?: {
|
|
12
|
+
ignoreCache: boolean;
|
|
13
|
+
}) => Promise<Pick<S, Namespaces[number]>>;
|
|
14
|
+
export declare const saveNamespace: (namespace: string, data: Object) => Promise<Pick<{
|
|
15
|
+
[namespace: string]: {
|
|
16
|
+
[index: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
}, string>>;
|
|
19
|
+
export declare const getAllNamespaces: () => Promise<{
|
|
20
|
+
namespaces: {
|
|
21
|
+
[x: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
24
|
+
export declare const deleteNamespaceKey: (namespace: string, key: string) => Promise<Pick<{
|
|
25
|
+
[namespace: string]: {
|
|
26
|
+
[index: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
}, string>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Array, Literal, Record, Static, String, Number, 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 getVstoken: (publicationDomain: string) => Promise<GetVstoken>;
|
|
29
|
+
export declare const getNonUserAccess: (publicationDomain: string) => Promise<GetNonUserAccess>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
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: (accessFeatures: string[]) => Promise<boolean>;
|
|
18
|
+
export default log;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { State, UserAttributes } from '../types';
|
|
2
|
+
export declare enum AmediaUserEvents {
|
|
3
|
+
REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
|
|
4
|
+
REQUEST_STORAGE_NAMESPACES = "amedia-user.request-storage-namespaces",
|
|
5
|
+
UPDATE_STORAGE = "amedua-user.update-storage-namespaces",
|
|
6
|
+
ON_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated",
|
|
7
|
+
ON_STATE_UPDATED = "amedia-user.on-state-updated",
|
|
8
|
+
ON_STORAGE_UPDATED = "amedia-user.on-storage-updated"
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface WindowEventMap {
|
|
12
|
+
[AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
|
|
13
|
+
[AmediaUserEvents.REQUEST_STORAGE_NAMESPACES]: CustomEvent<Array<string>>;
|
|
14
|
+
[AmediaUserEvents.UPDATE_STORAGE]: CustomEvent<{
|
|
15
|
+
[namespace: string]: object;
|
|
16
|
+
}>;
|
|
17
|
+
[AmediaUserEvents.ON_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
|
|
18
|
+
[AmediaUserEvents.ON_STATE_UPDATED]: CustomEvent<State>;
|
|
19
|
+
[AmediaUserEvents.ON_STORAGE_UPDATED]: CustomEvent<{
|
|
20
|
+
[index: string]: unknown;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const listenForUserAttributeRequests: () => void;
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import 'regenerator-runtime';
|
|
2
|
+
import User from './lib/User';
|
|
3
|
+
import PaywallUnlocker from './lib/PaywallUnlocker';
|
|
4
|
+
/**
|
|
5
|
+
* Enables you to subscribe to the user attributes you care about and
|
|
6
|
+
* get notified when something changes
|
|
7
|
+
*/
|
|
8
|
+
export declare const user: () => User<import("./types").UserAttributes, {
|
|
9
|
+
[index: string]: unknown;
|
|
10
|
+
}, (keyof import("./types").UserAttributes)[], string[], {
|
|
11
|
+
state: import("./types").State;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* This will, if necessary, trigger a redirect to www.aid.no and return
|
|
15
|
+
* to the requestedUrl if supplied or the current url before redirecting away if not.
|
|
16
|
+
* @param requestedUrl
|
|
17
|
+
*/
|
|
18
|
+
export declare const goToLoginPage: (requestedUrl?: string | undefined) => void;
|
|
19
|
+
export declare const logout: () => Promise<void>;
|
|
20
|
+
export declare const tryActivateSubscriptionAccess: (accessFeatures: string[]) => Promise<{
|
|
21
|
+
hasAccess: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const paywall: () => PaywallUnlocker;
|
|
24
|
+
export declare const updateStorage: (storage: {
|
|
25
|
+
[index: string]: Object;
|
|
26
|
+
}) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function accessCookieRefresher(): Promise<[void, void]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare class PaywallUnlocker {
|
|
2
|
+
private requestedAccessFeatures;
|
|
3
|
+
private reload;
|
|
4
|
+
private requestedUrl;
|
|
5
|
+
withAccessFeatures(accessFeatures: string[]): this;
|
|
6
|
+
reloadOnAccess(): this;
|
|
7
|
+
redirectOnAccess(requestedUrl: string): this;
|
|
8
|
+
tryUnlock(): Promise<{
|
|
9
|
+
isLoggedIn: boolean;
|
|
10
|
+
hasAccess: boolean;
|
|
11
|
+
accessFeatures: string[];
|
|
12
|
+
}>;
|
|
13
|
+
private resolveActualAccessFeatures;
|
|
14
|
+
private setAccessCookiesAndPerformRequestedActions;
|
|
15
|
+
}
|
|
16
|
+
export default PaywallUnlocker;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { State, UserAttributes } from '../types';
|
|
2
|
+
declare class User<UA extends UserAttributes, S extends {
|
|
3
|
+
[index: string]: unknown;
|
|
4
|
+
}, Attributes extends Array<keyof UA>, Namespaces extends Array<string>, SubscribeResponse extends {} = {
|
|
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): User<UA, S, (Attributes[number] & NewAttributes[number])[], Namespaces, SubscribeResponse & {
|
|
11
|
+
attributes: Pick<UA, Attributes[number] & NewAttributes[number]>;
|
|
12
|
+
}>;
|
|
13
|
+
withStorage<NewNamespaces extends Array<string>>(...namespace: NewNamespaces): User<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
|
+
private processUserAttributesEvent;
|
|
18
|
+
private processStorageEvent;
|
|
19
|
+
private setupLocalCache;
|
|
20
|
+
}
|
|
21
|
+
export default User;
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
package/esm/lib/rpc.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { State, UserAttributes } from '../types';
|
|
2
|
+
declare type StoreDataMap = {
|
|
3
|
+
userAttributes: UserAttributes;
|
|
4
|
+
state: State;
|
|
5
|
+
storage: {
|
|
6
|
+
[namespace: string]: {
|
|
7
|
+
[index: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
declare type Listener<T> = (data: T) => void;
|
|
12
|
+
declare const _default: {
|
|
13
|
+
set: (key: keyof StoreDataMap, value: UserAttributes | State | {
|
|
14
|
+
[namespace: string]: {
|
|
15
|
+
[index: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
}) => void;
|
|
18
|
+
get: <K extends keyof StoreDataMap, T = StoreDataMap[K]>(key: K) => T | undefined;
|
|
19
|
+
on: <K_1 extends keyof StoreDataMap, T_1 = StoreDataMap[K_1]>(key: K_1, listener: Listener<T_1>) => void;
|
|
20
|
+
clear: () => void;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/types.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare type UserAttributes = {
|
|
2
|
+
uuid?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
phone?: string;
|
|
6
|
+
trackingKey?: string;
|
|
7
|
+
extraData?: {
|
|
8
|
+
[index: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
access?: string[];
|
|
11
|
+
privacyPreferences?: PrivacyPreferences;
|
|
12
|
+
};
|
|
13
|
+
export declare type State = {
|
|
14
|
+
isLoggedIn: boolean;
|
|
15
|
+
emergencyMode?: string[];
|
|
16
|
+
};
|
|
17
|
+
export declare type PrivacyPreferences = {
|
|
18
|
+
allowResearchUsage: boolean;
|
|
19
|
+
connectWithSurveys: boolean;
|
|
20
|
+
personalizedAds: boolean;
|
|
21
|
+
personalizedContent: boolean;
|
|
22
|
+
};
|