Skip to content

Commit

Permalink
feat(#84): [Pooja|Tilak] fix tuvali API interface change issues with…
Browse files Browse the repository at this point in the history
… connecting and verification status
  • Loading branch information
tilak-puli committed May 11, 2023
1 parent 9b3be73 commit e5a3b69
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 39 deletions.
2 changes: 1 addition & 1 deletion components/ActivityLogText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ function getActionLabel(activity: ActivityLog, language: string) {
locale: DateFnsLocale[language],
}),
]
.filter((label) => label.trim() !== '')
.filter((label) => label?.trim() !== '')
.join(' · ');
}
36 changes: 29 additions & 7 deletions machines/openIdBle/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const model = createModel(
receiverInfo: {} as DeviceInfo,
incomingVc: {} as VC,
storeError: null as Error,
connectionParams: '',
openId4VpUri: '',
loggers: [] as EmitterSubscription[],
sharingProtocol: (Platform.OS === 'ios'
? 'ONLINE'
Expand All @@ -47,6 +47,7 @@ const model = createModel(
DISMISS: () => ({}),
VC_RECEIVED: (vc: VC) => ({ vc }),
CONNECTION_DESTROYED: () => ({}),
ADV_STARTED: (openId4VpUri: string) => ({ openId4VpUri }),
CONNECTED: () => ({}),
DISCONNECT: () => ({}),
BLE_ERROR: () => ({}),
Expand All @@ -70,8 +71,6 @@ const model = createModel(
}
);

export const RequestEvents = model.events;

export const requestMachine =
/** @xstate-layout N4IgpgJg5mDOIC5QCcwEcCucAuBiAygMIBKAoqQHID6AQgDICqxA2gAwC6ioADgPawBLbAN4A7LiAAeiAOwA2ABwA6AKwBmAJwBGDazmaF6rQBoQAT0QBaDTIAsSgExrNttXLk61rgL7fTqTBwCEnJqADEAeUIGfDZOJBA+QWExCWkEFVYZJW0ZNQVbTIc5eRLTCwRrO0cvVgU61gcHVizff3QsWDx8AHUASQAVQgAJKgAFYgiBqIi6OIkkoRFxBPS1VjUlGVZbLJUtNwPbBTlyqxUFBxqvJsMHBQV8tpAAzrx6UipSYk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Vc1KAobra0dfUCfE1zbMxwLzXEFUvQKS43RbOxKXGrOrBrb8hyXcfIOscgyxbk1zWDLYLzHlBGKCFEXS0rfS5yYUb7X7ejYkUy48RwFoQ8YyeszEeGXnPFVwWDdwfNVy3HetfHQnYnUncnPyzMG0M-GDCy1ShAZwZcKHRidwH5cRCk6JKC6S7VKkiXQymXOhb83k7UQofjXiCRMKkbLOfIRuaKwSSC7HNy7VU3Gk2qlckwu3DwKHAyO9HQPaeGAxfKwoQqnESSnq887xY3SAb81VbUQCPRI0PIGweGY8MsUhAxZCXMU80q-TVAYfRqda4a23LS5QDcM-ZwTQQNWwT5dcwlNEbzYNfk1-IiHkKAVqYUYWYYUnMADajmI9XYESw0dKGynKisbZAZOHRCHEEqvTFa9-GRL-U4u6tJFwLYXpS0dYAtS7IbDEbUHYAoFHFEYNc6zGli7fXfHGgQQ-UeRgiG-GucLEBso6F+EhZGd3R6tKXRZoYKhmudLGlm-fNmyAHVJmoa2Skav3ImrEEmhyEocmjLbYQZa2Rqpw-iDGNAjAr6W65W+6i4rYAsQyFoaEk0c2VQAsH3YqZiZiOgiWRg6osAVglTX06wYdXko2UQ60PECQ3wXwIAA */
model.createMachine(
Expand Down Expand Up @@ -185,8 +184,12 @@ export const requestMachine =
src: 'advertiseDevice',
},
on: {
ADV_STARTED: {
actions: ['setOpenID4VpUri'],
},
CONNECTED: {
target: 'waitingForVc',
actions: ['setSenderInfo', 'setReceiverInfo'],
},

DISCONNECT: {
Expand Down Expand Up @@ -459,6 +462,24 @@ export const requestMachine =
},
}),

setOpenID4VpUri: assign({
openId4VpUri: (_context, event) => {
return event.openId4VpUri;
},
}),

setSenderInfo: assign({
senderInfo: () => {
return { name: 'Wallet', deviceName: 'Wallet', deviceId: '' };
},
}),

setReceiverInfo: assign({
receiverInfo: () => {
return { name: 'Verifier', deviceName: 'Verifier', deviceId: '' };
},
}),

setStoringError: assign({
storeError: (_context, event) => event.error,
}),
Expand Down Expand Up @@ -594,10 +615,11 @@ export const requestMachine =
},

advertiseDevice: () => (callback) => {
verifier.startAdvertisement('OVPMOSIP');
const openId4VpUri = verifier.startAdvertisement('OVPMOSIP');
callback({ type: 'ADV_STARTED', openId4VpUri });

const statusCallback = (event: VerifierDataEvent) => {
if (event.type === 'onConnected') {
if (event.type === 'onKeyExchangeSuccess') {
callback({ type: 'CONNECTED' });
}
};
Expand Down Expand Up @@ -680,8 +702,8 @@ export function selectSenderInfo(state: State) {
return state.context.senderInfo;
}

export function selectConnectionParams(state: State) {
return state.context.connectionParams;
export function selectOpenId4VpUri(state: State) {
return state.context.openId4VpUri;
}

export function selectIncomingVc(state: State) {
Expand Down
Loading

0 comments on commit e5a3b69

Please sign in to comment.