@amedia/user 0.5.2 → 0.6.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/README.md +2 -2
- package/cloudbuild.json +29 -0
- package/cop.json +8 -0
- package/dist/actions/authentication.d.ts +1 -1
- package/dist/actions/preferences.d.ts +9 -0
- package/dist/actions/preferences.spec.d.ts +1 -0
- package/dist/cache/index.d.ts +3 -2
- package/dist/clients/europa.d.ts +12 -0
- package/dist/clients/europa.spec.d.ts +1 -0
- package/dist/clients/jupiter.d.ts +29 -0
- package/dist/clients/jupiter.spec.d.ts +1 -0
- package/dist/clients/mercury.d.ts +18 -0
- package/dist/clients/mercury.spec.d.ts +4 -0
- package/dist/clients/nebula.d.ts +22 -0
- package/dist/clients/nebula.spec.d.ts +1 -0
- package/dist/clients/pluto.d.ts +8 -0
- package/dist/clients/pluto.spec.d.ts +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/lib/rpc.d.ts +6 -1
- package/dist/services/europa.d.ts +12 -0
- package/dist/services/europa.spec.d.ts +1 -0
- package/dist/services/nebula.d.ts +22 -0
- package/dist/services/nebula.spec.d.ts +1 -0
- package/dist/store/store.d.ts +13 -0
- package/dist/store/store.spec.d.ts +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/utils/getOrUpdate.d.ts +3 -0
- package/package.json +4 -3
- package/src/actions/authentication.ts +2 -2
- package/src/actions/authorization.ts +4 -7
- package/src/actions/preferences.spec.ts +54 -0
- package/src/actions/preferences.ts +69 -0
- package/src/actions/userData.ts +2 -0
- package/src/cache/index.spec.ts +7 -2
- package/src/cache/index.ts +4 -3
- package/src/clients/europa.spec.ts +93 -0
- package/src/clients/europa.ts +126 -0
- package/src/clients/jupiter.spec.ts +154 -0
- package/src/{services → clients}/jupiter.ts +0 -1
- package/src/clients/mercury.spec.ts +70 -0
- package/src/clients/nebula.spec.ts +71 -0
- package/src/clients/nebula.ts +51 -0
- package/src/index-authentcation.spec.ts +2 -2
- package/src/index-userdata.spec.ts +11 -11
- package/src/index.ts +4 -3
- package/src/lib/rpc.ts +9 -3
- package/src/store/store.spec.ts +34 -0
- package/src/store/store.ts +46 -0
- package/src/types.ts +8 -0
- package/src/utils/getOrUpdate.ts +41 -0
- package/src/utils/log.ts +2 -1
- package/src/utils/queue.ts +0 -2
- package/src/services/jupiter.spec.ts +0 -150
- package/src/services/mercury.spec.ts +0 -30
- /package/src/{services → clients}/mercury.ts +0 -0
- /package/src/{services → clients}/pluto.spec.ts +0 -0
- /package/src/{services → clients}/pluto.ts +0 -0
package/README.md
CHANGED
|
@@ -17,8 +17,8 @@ const onUserAttributesUpdated = (attributes) => {
|
|
|
17
17
|
console.log(attributes);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const onStateUpdated = (
|
|
21
|
-
console.log(
|
|
20
|
+
const onStateUpdated = (store) => {
|
|
21
|
+
console.log(store)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
subscribeToUserUpdates(['name', 'email'], onUserAttributesUpdated, onStateUpdated);
|
package/cloudbuild.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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=3bef6affe49c4a30d03c2acf478183da25266aace083a76157cb902c1348521a",
|
|
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
ADDED
|
@@ -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<UserAttributes>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cache/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Static } from 'runtypes';
|
|
2
|
+
import { RuntypeBase } from 'runtypes/lib/runtype';
|
|
2
3
|
import { Engine } from './types';
|
|
3
4
|
export declare const setCacheEngine: (engine: Engine) => void;
|
|
4
5
|
declare const _default: {
|
|
5
|
-
get: <T extends
|
|
6
|
+
get: <T extends RuntypeBase<unknown>>(key: string, validator: T) => Promise<void | Static<T>>;
|
|
6
7
|
set: (key: string, value: unknown, expires: number) => Promise<void>;
|
|
7
8
|
remove: (key: string) => Promise<void>;
|
|
8
9
|
clear: () => Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Array, Literal, Record, Static, String, Number, Union } from 'runtypes';
|
|
2
|
+
export declare type AccessFeatures = string[];
|
|
3
|
+
export declare const CheckAccessForPaperSchema: Record<{
|
|
4
|
+
status: Literal<"success">;
|
|
5
|
+
access: Union<[Literal<"granted">, Literal<"denied">]>;
|
|
6
|
+
publication: Record<{
|
|
7
|
+
id: Number;
|
|
8
|
+
domain: String;
|
|
9
|
+
}, false>;
|
|
10
|
+
access_features: Array<String, false>;
|
|
11
|
+
}, false>;
|
|
12
|
+
export declare type CheckAccessForPaper = Static<typeof CheckAccessForPaperSchema>;
|
|
13
|
+
declare const GetVstokenSchema: Record<{
|
|
14
|
+
status: Literal<"success">;
|
|
15
|
+
cookie: String;
|
|
16
|
+
access_features: Array<String, false>;
|
|
17
|
+
}, false>;
|
|
18
|
+
export declare type GetVstoken = Static<typeof GetVstokenSchema>;
|
|
19
|
+
declare const GetNonUserAccessSchema: Record<{
|
|
20
|
+
status: Literal<"success">;
|
|
21
|
+
vstoken_cookie: String;
|
|
22
|
+
uuid: String;
|
|
23
|
+
access_features: Array<String, false>;
|
|
24
|
+
}, false>;
|
|
25
|
+
export declare type GetNonUserAccess = Static<typeof GetNonUserAccessSchema>;
|
|
26
|
+
export declare const checkForAccess: (publicationDomain: string, accessFeatures: AccessFeatures) => Promise<CheckAccessForPaper>;
|
|
27
|
+
export declare const getVstoken: (publicationDomain: string) => Promise<GetVstoken>;
|
|
28
|
+
export declare const getNonUserAccess: (publicationDomain: string) => Promise<GetNonUserAccess>;
|
|
29
|
+
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: (accessFeature: string) => Promise<boolean>;
|
|
18
|
+
export default log;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,13 @@ import { State, UserAttributes } from './types';
|
|
|
4
4
|
* Enables you to subscribe to the user attributes you care about and
|
|
5
5
|
* get notified when something changes
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const subscribeToUserAttributes: <T extends (keyof UserAttributes)[]>(attributes: T, onUserUpdated: (attributes: Pick<UserAttributes, T[number]>) => void, onStateUpdated?: ((attributes: State) => void) | undefined) => void;
|
|
8
8
|
/**
|
|
9
9
|
* This will, if necessary, trigger a redirect to www.aid.no and return
|
|
10
10
|
* to the requestedUrl if supplied or the current url before redirecting away if not.
|
|
11
11
|
* @param requestedUrl
|
|
12
12
|
*/
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const goToLoginPage: (requestedUrl?: string | undefined) => void;
|
|
14
14
|
export declare const logout: () => Promise<void>;
|
|
15
15
|
export declare const tryActivateSubscriptionAccess: (access: string) => Promise<{
|
|
16
16
|
hasAccess: boolean;
|