@amedia/user 0.1.1 → 0.2.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.
Files changed (54) hide show
  1. package/dist/actions/authentication.d.ts +4 -0
  2. package/dist/actions/authorization.d.ts +3 -0
  3. package/dist/cache/engines/global.d.ts +6 -0
  4. package/dist/cache/engines/indexeddb.d.ts +6 -0
  5. package/dist/cache/index.d.ts +9 -0
  6. package/dist/cache/types.d.ts +10 -0
  7. package/dist/eventHandlers/activation.d.ts +13 -0
  8. package/dist/eventHandlers/authentication.d.ts +15 -0
  9. package/dist/eventHandlers/userAttributes.d.ts +12 -0
  10. package/dist/index.d.ts +21 -206
  11. package/dist/index.js +1 -497
  12. package/dist/lib/authentication.d.ts +20 -0
  13. package/dist/lib/authorization.d.ts +15 -0
  14. package/dist/lib/cache/db.d.ts +6 -0
  15. package/dist/lib/cache/global.d.ts +9 -0
  16. package/dist/lib/cache/types.d.ts +5 -0
  17. package/dist/lib/dataOrganizer.d.ts +2 -0
  18. package/dist/lib/eventHandler.d.ts +3 -0
  19. package/dist/lib/queue.d.ts +5 -0
  20. package/dist/lib/types.d.ts +7 -0
  21. package/dist/lib/userAttributes.d.ts +12 -0
  22. package/dist/services/cache.d.ts +9 -0
  23. package/dist/services/jupiter.d.ts +29 -0
  24. package/dist/services/mercury.d.ts +15 -0
  25. package/dist/services/pluto.d.ts +8 -0
  26. package/dist/types.d.ts +12 -0
  27. package/dist/utils/customEventWrapper.d.ts +3 -0
  28. package/dist/utils/queue.d.ts +5 -0
  29. package/package.json +8 -5
  30. package/src/actions/authentication.ts +37 -0
  31. package/src/actions/authorization.ts +51 -0
  32. package/src/{lib/cache → cache/engines}/global.ts +5 -3
  33. package/src/{lib/cache/db.ts → cache/engines/indexeddb.ts} +5 -5
  34. package/src/cache/index.spec.ts +82 -0
  35. package/src/{services/cache.ts → cache/index.ts} +25 -13
  36. package/src/{lib/cache → cache}/types.ts +7 -1
  37. package/src/eventHandlers/activation.ts +29 -0
  38. package/src/eventHandlers/authentication.ts +29 -0
  39. package/src/{lib → eventHandlers}/userAttributes.ts +11 -12
  40. package/src/index.spec.ts +49 -30
  41. package/src/index.ts +14 -5
  42. package/src/lib/dataOrganizer.ts +33 -14
  43. package/src/services/pluto.spec.ts +3 -2
  44. package/src/services/pluto.ts +14 -10
  45. package/src/types.ts +13 -0
  46. package/src/utils/customEventWrapper.ts +42 -0
  47. package/src/utils/log.ts +7 -0
  48. package/tsconfig.json +2 -4
  49. package/webpack.config.js +25 -0
  50. package/src/lib/authentication.ts +0 -94
  51. package/src/lib/authorization.ts +0 -86
  52. package/src/lib/eventHandler.ts +0 -16
  53. package/src/lib/types.ts +0 -7
  54. /package/src/{lib → utils}/queue.ts +0 -0
@@ -0,0 +1,5 @@
1
+ export declare type Engine = {
2
+ get: (key: string) => Promise<unknown>;
3
+ set: (key: string, data: unknown, expires: number) => Promise<void>;
4
+ remove: (key: string) => Promise<void>;
5
+ };
@@ -0,0 +1,2 @@
1
+ import { UserAttributes } from '../types';
2
+ export declare const fetchDataBasedOnAttributes: (attributes: Array<keyof UserAttributes>, onDataUpdated: (attributes: UserAttributes) => void) => void;
@@ -0,0 +1,3 @@
1
+ export declare const setRootElement: (element: any) => void;
2
+ export declare const listen: <T extends keyof WindowEventMap>(type: T, listener: (this: Window, ev: WindowEventMap[T]) => void) => void;
3
+ export declare const dispatch: <T extends Event>(event: T) => void;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ add: (key: string, data: unknown) => void;
3
+ getAll: (key: string) => unknown[];
4
+ };
5
+ export default _default;
@@ -0,0 +1,7 @@
1
+ export declare type UserAttributes = {
2
+ isLoggedIn?: boolean;
3
+ name?: string;
4
+ email?: string;
5
+ phone?: string;
6
+ trackingKey?: string;
7
+ };
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,9 @@
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;
@@ -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,15 @@
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 default log;
@@ -0,0 +1,8 @@
1
+ import { Record, Static, String } from 'runtypes';
2
+ export declare const Session: Record<{
3
+ name: String;
4
+ trackingKey: String;
5
+ }, false>;
6
+ export declare type Session = Static<typeof Session>;
7
+ export declare const getCurrentSession: () => Promise<Session>;
8
+ export declare const removeSession: (domain: string) => Promise<void>;
@@ -0,0 +1,12 @@
1
+ export declare type UserAttributes = {
2
+ isLoggedIn: boolean;
3
+ name?: string;
4
+ email?: string;
5
+ phone?: string;
6
+ trackingKey?: string;
7
+ extraData: [];
8
+ access: string[];
9
+ };
10
+ export declare type AnonymousAttributes = {
11
+ age: number;
12
+ };
@@ -0,0 +1,3 @@
1
+ export declare const setRootElement: (element: any) => void;
2
+ export declare const listen: <T extends keyof WindowEventMap>(type: T, listener: (this: Window, ev: WindowEventMap[T]) => void, exclusivity?: boolean) => void;
3
+ export declare const dispatch: <T extends Event>(event: T) => void;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ add: (key: string, data: unknown) => void;
3
+ getAll: (key: string) => unknown[];
4
+ };
5
+ export default _default;
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@amedia/user",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Client lib for working with aID user",
5
+ "repository": "https://github.com/amedia/amedia-user-js",
6
+ "author": "Amedia Utvikling (ID og data)",
7
+ "main": "dist/index.js",
5
8
  "scripts": {
6
9
  "test": "jest",
7
- "build": "tsc"
10
+ "build": "webpack --mode=production"
8
11
  },
9
- "main": "dist/index.js",
10
- "author": "Amedia Utvikling (ID og data)",
11
12
  "dependencies": {
12
13
  "dexie": "3.0.3",
13
14
  "runtypes": "6.2.1"
@@ -29,6 +30,8 @@
29
30
  "prettier": "2.2.1",
30
31
  "ts-jest": "^26.5.5",
31
32
  "ts-loader": "9.1.0",
32
- "typescript": "4.2.4"
33
+ "typescript": "4.2.4",
34
+ "webpack": "5.36.2",
35
+ "webpack-cli": "4.6.0"
33
36
  }
34
37
  }
@@ -0,0 +1,37 @@
1
+ import { getCurrentSession, Session } from '../services/pluto';
2
+ import cache from '../cache';
3
+
4
+ const EXPIRES_10_SECONDS = 10000;
5
+
6
+ export const login = (requestedUrl: string) => {
7
+ // TODO Need to get environment smarts from incentive embed
8
+ const url = new URL('https://aid.no/logg_inn/');
9
+ url.searchParams.set('requestedUrl', requestedUrl || window.location.href);
10
+ window.location.href = url.href;
11
+ };
12
+
13
+ export const logout = () => {
14
+ // TODO Perform logout
15
+ };
16
+
17
+ let isFetchingSession = false;
18
+ const IS_LOGGED_IN_CACHE_KEY = 'is_logged_in';
19
+ export const getSession = async (): Promise<Session | null> => {
20
+ if (isFetchingSession) {
21
+ return null;
22
+ }
23
+ isFetchingSession = true;
24
+
25
+ // Try the cache first
26
+ const cacheResponse = await cache.get(IS_LOGGED_IN_CACHE_KEY, Session);
27
+ if (cacheResponse) {
28
+ isFetchingSession = false;
29
+ return cacheResponse;
30
+ }
31
+
32
+ // Actually perform a request against backend for the session
33
+ const session = await getCurrentSession();
34
+ cache.set(IS_LOGGED_IN_CACHE_KEY, session, Date.now() + EXPIRES_10_SECONDS);
35
+ isFetchingSession = false;
36
+ return session;
37
+ };
@@ -0,0 +1,51 @@
1
+ import {
2
+ AccessFeatures,
3
+ CheckAccessForPaper,
4
+ CheckAccessForPaperSchema,
5
+ checkForAccess,
6
+ } from '../services/jupiter';
7
+ import cache from '../cache';
8
+
9
+ const EXPIRES_OFFSET = 10000; // 10 seconds
10
+ const CHECK_FOR_ACCESS_CACHE_KEY = 'check_for_access_to_publication';
11
+
12
+ let isCheckingForAccess: boolean = false;
13
+ export const checkForAccessToPublication = async (
14
+ publicationDomain: string,
15
+ accessFeatures: AccessFeatures
16
+ ): Promise<CheckAccessForPaper | null> => {
17
+ if (isCheckingForAccess) {
18
+ return null;
19
+ }
20
+ isCheckingForAccess = true;
21
+
22
+ // Try the cache first
23
+ const cacheResponse = await cache.get(
24
+ CHECK_FOR_ACCESS_CACHE_KEY,
25
+ CheckAccessForPaperSchema
26
+ );
27
+ if (cacheResponse) {
28
+ isCheckingForAccess = false;
29
+ return cacheResponse;
30
+ }
31
+
32
+ // Actually perform a request against backend for the accessState
33
+ const accessState = await checkForAccess(publicationDomain, accessFeatures);
34
+ cache.set(
35
+ CHECK_FOR_ACCESS_CACHE_KEY,
36
+ accessState,
37
+ Date.now() + EXPIRES_OFFSET
38
+ );
39
+
40
+ isCheckingForAccess = false;
41
+
42
+ return accessState;
43
+ };
44
+
45
+ // TODO This is just mock implementation
46
+ export const activate = () =>
47
+ new Promise((resolve, reject) => {
48
+ setTimeout(() => {
49
+ resolve({ status: 'success' });
50
+ }, 1000);
51
+ });
@@ -1,7 +1,9 @@
1
+ import { CacheEntry, Engine } from '../types';
2
+
1
3
  // eslint-disable-next-line no-multi-assign
2
- const cache = ((window || global)['amedia-user-cache'] = {});
4
+ const cache = (window['amedia-user-cache'] = {});
3
5
 
4
- export const get = (key: string): Promise<unknown> => {
6
+ export const get = (key: string): Promise<CacheEntry> => {
5
7
  const data = cache[key];
6
8
  return Promise.resolve(data);
7
9
  };
@@ -20,4 +22,4 @@ export const remove = (key: string): Promise<void> => {
20
22
  return Promise.resolve();
21
23
  };
22
24
 
23
- export default { get, set, remove };
25
+ export default { get, set, remove } as Engine;
@@ -1,13 +1,13 @@
1
1
  import Dexie from 'dexie';
2
- import { Engine } from './types';
2
+ import { CacheEntry, Engine } from '../types';
3
3
 
4
- const db = new Dexie('amedia-user-cache');
5
- db.version(1).stores({
4
+ const indexeddb = new Dexie('amedia-user-cache');
5
+ indexeddb.version(1).stores({
6
6
  cache: 'key,data,expires',
7
7
  });
8
- const cache = db.table('cache');
8
+ const cache = indexeddb.table('cache');
9
9
 
10
- export const get = (key: string): Promise<unknown> => cache.get(key);
10
+ export const get = (key: string): Promise<CacheEntry> => cache.get(key);
11
11
  export const set = (
12
12
  key: string,
13
13
  data: unknown,
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+
5
+ import { Record, String } from 'runtypes';
6
+ import cache, { setCacheEngine } from '.';
7
+ import log from '../utils/log';
8
+ import resetAllMocks = jest.resetAllMocks;
9
+ import stringMatching = jasmine.stringMatching;
10
+
11
+ const TestDataSchema = Record({
12
+ test: String,
13
+ });
14
+
15
+ let mockEngine;
16
+ beforeEach(() => {
17
+ resetAllMocks();
18
+ // @ts-ignore
19
+ mockEngine = { get: jest.fn(), set: jest.fn(), remove: jest.fn() };
20
+ // @ts-ignore
21
+ setCacheEngine(mockEngine);
22
+ log.error = jest.fn();
23
+ });
24
+
25
+ describe('Cache', () => {
26
+ describe('get', () => {
27
+ it('should get from engine', () => {
28
+ mockEngine.get.mockReturnValueOnce(Promise.resolve(null));
29
+ expect(cache.get('foo', TestDataSchema)).resolves.toBeUndefined();
30
+ expect(mockEngine.get).toHaveBeenCalledWith('foo');
31
+ });
32
+
33
+ it('should validate valid data from engine', () => {
34
+ mockEngine.get.mockReturnValueOnce(
35
+ Promise.resolve({
36
+ key: 'foo',
37
+ data: {
38
+ test: 'cache',
39
+ },
40
+ expires: Date.now() + 1000,
41
+ })
42
+ );
43
+ expect(cache.get('foo', TestDataSchema)).resolves.toEqual({
44
+ test: 'cache',
45
+ });
46
+ });
47
+
48
+ it('should return undefined and delete record on invalid data', async () => {
49
+ mockEngine.get.mockReturnValueOnce(
50
+ Promise.resolve({
51
+ key: 'foo',
52
+ data: {
53
+ invalid: 'data',
54
+ },
55
+ expires: Date.now() + 1000,
56
+ })
57
+ );
58
+ await expect(cache.get('foo', TestDataSchema)).resolves.toBeUndefined();
59
+ expect(mockEngine.get).toHaveBeenCalledWith('foo');
60
+ expect(mockEngine.remove).toHaveBeenCalledWith('foo');
61
+ expect(log.error).toHaveBeenCalledWith('Failed validating data', {
62
+ data: { invalid: 'data' },
63
+ error: { test: 'Expected string, but was missing' },
64
+ });
65
+ });
66
+
67
+ it('deletes expired data', async () => {
68
+ mockEngine.get.mockReturnValueOnce(
69
+ Promise.resolve({
70
+ key: 'foo',
71
+ data: {
72
+ test: 'cache',
73
+ },
74
+ expires: Date.now() - 1000,
75
+ })
76
+ );
77
+ await expect(cache.get('foo', TestDataSchema)).resolves.toBeUndefined();
78
+ expect(mockEngine.get).toHaveBeenCalledWith('foo');
79
+ expect(mockEngine.remove).toHaveBeenCalledWith('foo');
80
+ });
81
+ });
82
+ });
@@ -1,6 +1,7 @@
1
- import { Record, Static } from 'runtypes';
2
- import globalCache from '../lib/cache/global';
3
- import { Engine } from '../lib/cache/types';
1
+ import { Record, Static, ValidationError } from 'runtypes';
2
+ import globalCache from './engines/global';
3
+ import { Engine } from './types';
4
+ import log from '../utils/log';
4
5
 
5
6
  let cacheEngine: Engine;
6
7
 
@@ -10,27 +11,38 @@ export const setCacheEngine = (engine: Engine) => {
10
11
 
11
12
  const getCacheEngine = (): Engine => cacheEngine || globalCache;
12
13
 
14
+ const set = (key: string, value: unknown, expires: number) =>
15
+ getCacheEngine().set(key, value, expires);
16
+
17
+ const remove = (key: string): Promise<void> => getCacheEngine().remove(key);
18
+
13
19
  const get = async <T extends Record<any, any>>(
14
20
  key: string,
15
21
  validator: T
16
22
  ): Promise<Static<T> | void> => {
17
- const data = await getCacheEngine().get(key);
18
- if (!data) {
23
+ const cacheEntry = await getCacheEngine().get(key);
24
+ if (!cacheEntry) {
25
+ return Promise.resolve();
26
+ }
27
+ if (Date.now() > cacheEntry.expires) {
28
+ remove(key);
19
29
  return Promise.resolve();
20
30
  }
21
31
  try {
22
- const typedData = validator.check(data);
32
+ const typedData = validator.check(cacheEntry.data);
23
33
  return typedData as T;
24
34
  } catch (error) {
25
- console.error('Failed validating data', { data, error });
26
- getCacheEngine().remove(key);
35
+ if (error instanceof ValidationError) {
36
+ log.error('Failed validating data', {
37
+ data: cacheEntry.data,
38
+ error: error.details,
39
+ });
40
+ } else {
41
+ log.error('Unknown error', error);
42
+ }
43
+ remove(key);
27
44
  return Promise.resolve();
28
45
  }
29
46
  };
30
47
 
31
- const set = (key: string, value: unknown, expires: number) =>
32
- getCacheEngine().set(key, value, expires);
33
-
34
- const remove = (key: string): Promise<void> => getCacheEngine().remove(key);
35
-
36
48
  export default { get, set, remove };
@@ -1,5 +1,11 @@
1
+ export type CacheEntry = {
2
+ key: string;
3
+ data: unknown;
4
+ expires: number;
5
+ };
6
+
1
7
  export type Engine = {
2
- get: (key: string) => Promise<unknown>;
8
+ get: (key: string) => Promise<CacheEntry | null>;
3
9
  set: (key: string, data: unknown, expires: number) => Promise<void>;
4
10
  remove: (key: string) => Promise<void>;
5
11
  };
@@ -0,0 +1,29 @@
1
+ import { dispatch, listenWithExclusivity } from '../utils/customEventWrapper';
2
+ import { activate } from '../actions/authorization';
3
+
4
+ export enum ActivationEvents {
5
+ REQUEST_ACTIVATION = 'amedia-user.activation.request-activation',
6
+ ON_ACTIVATION_COMPLETE = 'amedia-user.activation.on-activation-complete',
7
+ }
8
+
9
+ declare global {
10
+ interface WindowEventMap {
11
+ [ActivationEvents.REQUEST_ACTIVATION]: CustomEvent;
12
+ [ActivationEvents.ON_ACTIVATION_COMPLETE]: CustomEvent<{
13
+ status: 'success' | 'error';
14
+ }>;
15
+ }
16
+ }
17
+
18
+ export const listenForActivationRequests = () => {
19
+ listenWithExclusivity(ActivationEvents.REQUEST_ACTIVATION, () => {
20
+ activate().then((result) => {
21
+ dispatch(
22
+ new CustomEvent(ActivationEvents.ON_ACTIVATION_COMPLETE, {
23
+ detail: result,
24
+ })
25
+ );
26
+ });
27
+ });
28
+ };
29
+ listenForActivationRequests();
@@ -0,0 +1,29 @@
1
+ import { listenWithExclusivity } from '../utils/customEventWrapper';
2
+ import { login, logout } from '../actions/authentication';
3
+
4
+ export enum AuthenticationEvents {
5
+ REQUEST_LOGIN = 'amedia-user.authentication.request-login',
6
+ REQUEST_LOGOUT = 'amedia-user.authentication.request-logout',
7
+ }
8
+
9
+ declare global {
10
+ interface WindowEventMap {
11
+ [AuthenticationEvents.REQUEST_LOGIN]: CustomEvent<{
12
+ requestedUrl?: string;
13
+ }>;
14
+ [AuthenticationEvents.REQUEST_LOGOUT]: CustomEvent<{
15
+ requestedUrl?: string;
16
+ }>;
17
+ }
18
+ }
19
+
20
+ export const listenForAuthenticationRequests = () => {
21
+ listenWithExclusivity(AuthenticationEvents.REQUEST_LOGIN, (evt) => {
22
+ login(evt.detail.requestedUrl || window.location.href);
23
+ });
24
+
25
+ listenWithExclusivity(AuthenticationEvents.REQUEST_LOGOUT, () => {
26
+ logout();
27
+ });
28
+ };
29
+ listenForAuthenticationRequests();
@@ -1,6 +1,6 @@
1
- import { fetchDataBasedOnAttributes } from './dataOrganizer';
2
- import { dispatch, listen } from './eventHandler';
3
- import { UserAttributes } from './types';
1
+ import { fetchDataBasedOnAttributes } from '../lib/dataOrganizer';
2
+ import { dispatch, listenWithExclusivity } from '../utils/customEventWrapper';
3
+ import { UserAttributes } from '../types';
4
4
 
5
5
  export enum AmediaUserEvents {
6
6
  REQUEST_USER_ATTRIBUTES = 'amedia-user.request-user-attributes',
@@ -17,15 +17,14 @@ declare global {
17
17
  }
18
18
 
19
19
  export const listenForUserAttributeRequests = () => {
20
- listen(AmediaUserEvents.REQUEST_USER_ATTRIBUTES, (evt) => {
21
- // Prevent other instances of this package from further processing
22
- evt.stopImmediatePropagation();
23
-
24
- dispatch(
25
- new CustomEvent(AmediaUserEvents.ON_USER_ATTRIBUTES_UPDATED, {
26
- detail: fetchDataBasedOnAttributes(evt.detail),
27
- })
28
- );
20
+ listenWithExclusivity(AmediaUserEvents.REQUEST_USER_ATTRIBUTES, (evt) => {
21
+ fetchDataBasedOnAttributes(evt.detail, (attributes) => {
22
+ dispatch(
23
+ new CustomEvent(AmediaUserEvents.ON_USER_ATTRIBUTES_UPDATED, {
24
+ detail: attributes,
25
+ })
26
+ );
27
+ });
29
28
  });
30
29
  };
31
30