Add getPublicData
This commit is contained in:
parent
4740f4a67c
commit
68f6b31a6c
@ -301,6 +301,42 @@ export default class MessageBus {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getPublicData(encodedData: number[]): Promise<any> {
|
||||||
|
return new Promise<any>((resolve: (data: any) => void, reject: (error: string) => void) => {
|
||||||
|
this.checkToken().then(() => {
|
||||||
|
const userStore = UserStore.getInstance();
|
||||||
|
const accessToken = userStore.getAccessToken()!;
|
||||||
|
|
||||||
|
const correlationId = uuidv4();
|
||||||
|
this.initMessageListener(correlationId);
|
||||||
|
|
||||||
|
const unsubscribe = EventBus.getInstance().on('PUBLIC_DATA_DECODED', (responseId: string, data: any) => {
|
||||||
|
if (responseId !== correlationId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unsubscribe();
|
||||||
|
this.destroyMessageListener();
|
||||||
|
resolve(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
const unsubscribeError = EventBus.getInstance().on('ERROR_PUBLIC_DATA_DECODED', (responseId: string, error: string) => {
|
||||||
|
if (responseId !== correlationId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unsubscribeError();
|
||||||
|
this.destroyMessageListener();
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sendMessage({
|
||||||
|
type: 'DECODE_PUBLIC_DATA',
|
||||||
|
encodedData,
|
||||||
|
accessToken
|
||||||
|
});
|
||||||
|
}).catch(console.error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public createProfile(profileData: ProfileData, profilePrivateData: string[], roles: Record<string, RoleDefinition>): Promise<ProfileCreated> {
|
public createProfile(profileData: ProfileData, profilePrivateData: string[], roles: Record<string, RoleDefinition>): Promise<ProfileCreated> {
|
||||||
return new Promise<ProfileCreated>((resolve: (profileCreated: ProfileCreated) => void, reject: (error: string) => void) => {
|
return new Promise<ProfileCreated>((resolve: (profileCreated: ProfileCreated) => void, reject: (error: string) => void) => {
|
||||||
this.checkToken().then(() => {
|
this.checkToken().then(() => {
|
||||||
@ -692,6 +728,17 @@ export default class MessageBus {
|
|||||||
EventBus.getInstance().emit('MESSAGE_RECEIVED', message);
|
EventBus.getInstance().emit('MESSAGE_RECEIVED', message);
|
||||||
EventBus.getInstance().emit('PROCESS_UPDATED', correlationId, message.updatedProcess);
|
EventBus.getInstance().emit('PROCESS_UPDATED', correlationId, message.updatedProcess);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'PUBLIC_DATA_DECODED':
|
||||||
|
if (this.errors[correlationId]) {
|
||||||
|
const error = this.errors[correlationId];
|
||||||
|
delete this.errors[correlationId];
|
||||||
|
EventBus.getInstance().emit('ERROR_PUBLIC_DATA_DECODED', correlationId, error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EventBus.getInstance().emit('MESSAGE_RECEIVED', message);
|
||||||
|
EventBus.getInstance().emit('PUBLIC_DATA_DECODED', correlationId, message.decodedData);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'ERROR':
|
case 'ERROR':
|
||||||
console.error('Error:', message);
|
console.error('Error:', message);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user