@amedia/user 0.3.2 → 0.4.1
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/.eslintignore +2 -0
- package/.eslintrc +8 -3
- package/dist/actions/authentication.d.ts +1 -1
- package/dist/actions/authorization.d.ts +6 -2
- package/dist/cache/engines/global.d.ts +15 -0
- package/dist/cache/engines/global.spec.d.ts +1 -0
- package/dist/cache/engines/indexeddb.d.ts +1 -0
- package/dist/cache/index.d.ts +1 -0
- package/dist/cache/index.spec.d.ts +4 -0
- package/dist/cache/types.d.ts +1 -0
- package/dist/eventHandlers/authentication.d.ts +5 -3
- package/dist/index-authentcation.spec.d.ts +4 -0
- package/dist/index-userdata.spec.d.ts +4 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/dist/lib/cookie.d.ts +5 -0
- package/dist/lib/rpc.d.ts +1 -0
- package/dist/services/jupiter.spec.d.ts +1 -0
- package/dist/services/mercury.spec.d.ts +4 -0
- package/dist/services/pluto.d.ts +2 -2
- package/dist/services/pluto.spec.d.ts +1 -0
- package/dist/utils/log.d.ts +7 -0
- package/dist/utils/queue.d.ts +9 -2
- package/package.json +5 -4
- package/src/actions/authentication.ts +28 -5
- package/src/actions/authorization.ts +42 -38
- package/src/{lib/dataOrganizer.ts → actions/userData.ts} +5 -2
- package/src/cache/engines/global.spec.ts +62 -0
- package/src/cache/engines/global.ts +25 -7
- package/src/cache/engines/indexeddb.ts +3 -1
- package/src/cache/index.spec.ts +33 -1
- package/src/cache/index.ts +8 -1
- package/src/cache/types.ts +1 -0
- package/src/eventHandlers/authentication.ts +10 -5
- package/src/eventHandlers/userAttributes.ts +1 -1
- package/src/index-authentcation.spec.ts +44 -0
- package/src/{index.spec.ts → index-userdata.spec.ts} +8 -15
- package/src/index.ts +9 -6
- package/src/lib/cookie.ts +109 -0
- package/src/lib/rpc.ts +15 -0
- package/src/services/jupiter.spec.ts +5 -3
- package/src/services/jupiter.ts +5 -3
- package/src/services/pluto.ts +8 -6
- package/src/utils/log.ts +29 -2
- package/src/utils/queue.ts +19 -4
- package/tsconfig.json +2 -0
- package/webpack.config.js +1 -1
- package/.babelrc +0 -3
- package/dist/lib/authentication.d.ts +0 -20
- package/dist/lib/authorization.d.ts +0 -15
- package/dist/lib/cache/db.d.ts +0 -6
- package/dist/lib/cache/global.d.ts +0 -9
- package/dist/lib/cache/types.d.ts +0 -5
- package/dist/lib/eventHandler.d.ts +0 -3
- package/dist/lib/queue.d.ts +0 -5
- package/dist/lib/types.d.ts +0 -7
- package/dist/lib/userAttributes.d.ts +0 -12
- package/dist/services/cache.d.ts +0 -9
- /package/dist/{lib/dataOrganizer.d.ts → actions/userData.d.ts} +0 -0
package/src/utils/queue.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { Function } from 'runtypes';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const queue: {
|
|
4
|
+
[key: string]: {
|
|
5
|
+
resolve: (PromiseLike) => void;
|
|
6
|
+
reject: (reason?) => void;
|
|
7
|
+
}[];
|
|
8
|
+
} = {};
|
|
9
|
+
|
|
10
|
+
const add = (
|
|
11
|
+
key: string,
|
|
12
|
+
promiseCallbacks: {
|
|
13
|
+
resolve: (PromiseLike) => void;
|
|
14
|
+
reject: (reason?) => void;
|
|
15
|
+
}
|
|
16
|
+
): void => {
|
|
4
17
|
if (!queue[key]) {
|
|
5
18
|
queue[key] = [];
|
|
6
19
|
}
|
|
7
|
-
queue[key].push(
|
|
20
|
+
queue[key].push(promiseCallbacks);
|
|
8
21
|
};
|
|
9
22
|
|
|
10
23
|
const getAll = (key: string) => {
|
|
@@ -16,4 +29,6 @@ const getAll = (key: string) => {
|
|
|
16
29
|
return keyQueue;
|
|
17
30
|
};
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
const peekQueueSize = (key: string): number => queue[key]?.length || 0;
|
|
33
|
+
|
|
34
|
+
export default { add, getAll, peekQueueSize };
|
package/tsconfig.json
CHANGED
package/webpack.config.js
CHANGED
package/.babelrc
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Session } from '../services/pluto';
|
|
2
|
-
export declare enum AuthenticationEvents {
|
|
3
|
-
REQUEST_LOGIN = "amedia_user.authentication.request_login",
|
|
4
|
-
REQUEST_LOGOUT = "amedia_user.authentication.request_logout",
|
|
5
|
-
REQUEST_AUTH_STATE = "amedia_user.authentication.request_auth_state",
|
|
6
|
-
ON_AUTH_STATE_UPDATED = "amedia_user.authentication.on_auth_state_updated"
|
|
7
|
-
}
|
|
8
|
-
declare global {
|
|
9
|
-
interface WindowEventMap {
|
|
10
|
-
[AuthenticationEvents.REQUEST_LOGIN]: CustomEvent<{
|
|
11
|
-
requestedUrl?: string;
|
|
12
|
-
}>;
|
|
13
|
-
[AuthenticationEvents.REQUEST_LOGOUT]: CustomEvent<{
|
|
14
|
-
requestedUrl?: string;
|
|
15
|
-
}>;
|
|
16
|
-
[AuthenticationEvents.REQUEST_AUTH_STATE]: CustomEvent<Session>;
|
|
17
|
-
[AuthenticationEvents.ON_AUTH_STATE_UPDATED]: CustomEvent<Session>;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export declare const listenForAuthenticationRequests: () => void;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AccessFeatures, CheckAccessForPaper } from '../services/jupiter';
|
|
2
|
-
export declare enum AuthorizationEvents {
|
|
3
|
-
REQUEST_PUBLICATION_ACCESS_STATE_CHECK = "amedia_user.authorization.request_publication_access_state_check",
|
|
4
|
-
ON_PUBLICATION_ACCESS_STATE_UPDATED = "amedia_user.authorization.on_publication_access_state_updated"
|
|
5
|
-
}
|
|
6
|
-
declare global {
|
|
7
|
-
interface WindowEventMap {
|
|
8
|
-
[AuthorizationEvents.REQUEST_PUBLICATION_ACCESS_STATE_CHECK]: CustomEvent<{
|
|
9
|
-
publicationDomain: string;
|
|
10
|
-
accessFeatures: AccessFeatures;
|
|
11
|
-
}>;
|
|
12
|
-
[AuthorizationEvents.ON_PUBLICATION_ACCESS_STATE_UPDATED]: CustomEvent<CheckAccessForPaper>;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export declare const listenForAuthorizationRequests: () => void;
|
package/dist/lib/cache/db.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Engine } from './types';
|
|
2
|
-
export declare const get: (key: string) => Promise<unknown>;
|
|
3
|
-
export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
4
|
-
export declare const remove: (key: string) => Promise<void>;
|
|
5
|
-
declare const _default: Engine;
|
|
6
|
-
export default _default;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const get: (key: string) => Promise<unknown>;
|
|
2
|
-
export declare const set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
3
|
-
export declare const remove: (key: string) => Promise<void>;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
get: (key: string) => Promise<unknown>;
|
|
6
|
-
set: (key: string, data: unknown, expires: number) => Promise<void>;
|
|
7
|
-
remove: (key: string) => Promise<void>;
|
|
8
|
-
};
|
|
9
|
-
export default _default;
|
package/dist/lib/queue.d.ts
DELETED
package/dist/lib/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { UserAttributes } from './types';
|
|
2
|
-
export declare enum AmediaUserEvents {
|
|
3
|
-
REQUEST_USER_ATTRIBUTES = "amedia-user.request-user-attributes",
|
|
4
|
-
ON_USER_ATTRIBUTES_UPDATED = "amedia-user.on-user-attributes-updated"
|
|
5
|
-
}
|
|
6
|
-
declare global {
|
|
7
|
-
interface WindowEventMap {
|
|
8
|
-
[AmediaUserEvents.REQUEST_USER_ATTRIBUTES]: CustomEvent<Array<keyof UserAttributes>>;
|
|
9
|
-
[AmediaUserEvents.ON_USER_ATTRIBUTES_UPDATED]: CustomEvent<UserAttributes>;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export declare const listenForUserAttributeRequests: () => void;
|
package/dist/services/cache.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Record, Static } from 'runtypes';
|
|
2
|
-
import { Engine } from '../lib/cache/types';
|
|
3
|
-
export declare const setCacheEngine: (engine: Engine) => void;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
get: <T extends Record<any, any>>(key: string, validator: T) => Promise<void | Static<T>>;
|
|
6
|
-
set: (key: string, value: unknown, expires: number) => Promise<void>;
|
|
7
|
-
remove: (key: string) => Promise<void>;
|
|
8
|
-
};
|
|
9
|
-
export default _default;
|
|
File without changes
|