web: do not parse the UUID
The UUID -> Number -> UUID transformation was lossy and incorrect. This commit preserves the UUID as-is, but parses the inbound element into a number if the API being called (i.e. anything but Mobile) requires a number for its PK.
This commit is contained in:
parent
afdf269869
commit
f0742ab313
|
@ -26,8 +26,10 @@ export const retrieveAuthenticatorsAdminAllList = (user: number) =>
|
||||||
api().authenticatorsAdminAllList({ user });
|
api().authenticatorsAdminAllList({ user });
|
||||||
|
|
||||||
export async function destroyAuthenticatorDevice(deviceType: string, id: number | string) {
|
export async function destroyAuthenticatorDevice(deviceType: string, id: number | string) {
|
||||||
id = typeof id === "string" ? parseInt(id, 10) : id;
|
|
||||||
deviceType = deviceType.toLowerCase();
|
deviceType = deviceType.toLowerCase();
|
||||||
|
const uuid = id;
|
||||||
|
id = typeof id === "string" ? parseInt(id, 10) : id;
|
||||||
|
|
||||||
switch (deviceType) {
|
switch (deviceType) {
|
||||||
case DeviceType.Duo:
|
case DeviceType.Duo:
|
||||||
return api().authenticatorsDuoDestroy({ id });
|
return api().authenticatorsDuoDestroy({ id });
|
||||||
|
@ -39,8 +41,12 @@ export async function destroyAuthenticatorDevice(deviceType: string, id: number
|
||||||
return api().authenticatorsStaticDestroy({ id });
|
return api().authenticatorsStaticDestroy({ id });
|
||||||
case DeviceType.WebAuthn:
|
case DeviceType.WebAuthn:
|
||||||
return api().authenticatorsWebauthnDestroy({ id });
|
return api().authenticatorsWebauthnDestroy({ id });
|
||||||
case DeviceType.Mobile:
|
case DeviceType.Mobile: {
|
||||||
return api().authenticatorsMobileDestroy({ uuid: `${id}` });
|
if (typeof uuid !== "string") {
|
||||||
|
throw new Error(`authenticatorMobile expects full UUID, received ${uuid}`);
|
||||||
|
}
|
||||||
|
return api().authenticatorsMobileDestroy({ uuid });
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return exhaustiveGuard(deviceType);
|
return exhaustiveGuard(deviceType);
|
||||||
}
|
}
|
||||||
|
@ -51,8 +57,10 @@ export async function updateAuthenticatorDevice(
|
||||||
id: number | string,
|
id: number | string,
|
||||||
device: Device,
|
device: Device,
|
||||||
) {
|
) {
|
||||||
id = typeof id === "string" ? parseInt(id, 10) : id;
|
|
||||||
deviceType = deviceType.toLowerCase();
|
deviceType = deviceType.toLowerCase();
|
||||||
|
const uuid = id;
|
||||||
|
id = typeof id === "string" ? parseInt(id, 10) : id;
|
||||||
|
|
||||||
switch (deviceType) {
|
switch (deviceType) {
|
||||||
case DeviceType.Duo:
|
case DeviceType.Duo:
|
||||||
return api().authenticatorsDuoUpdate({ id, duoDeviceRequest: device });
|
return api().authenticatorsDuoUpdate({ id, duoDeviceRequest: device });
|
||||||
|
@ -64,8 +72,12 @@ export async function updateAuthenticatorDevice(
|
||||||
return api().authenticatorsStaticUpdate({ id, staticDeviceRequest: device });
|
return api().authenticatorsStaticUpdate({ id, staticDeviceRequest: device });
|
||||||
case DeviceType.WebAuthn:
|
case DeviceType.WebAuthn:
|
||||||
return api().authenticatorsWebauthnUpdate({ id, webAuthnDeviceRequest: device });
|
return api().authenticatorsWebauthnUpdate({ id, webAuthnDeviceRequest: device });
|
||||||
case DeviceType.Mobile:
|
case DeviceType.Mobile: {
|
||||||
return api().authenticatorsMobileUpdate({ uuid: `${id}`, mobileDeviceRequest: device });
|
if (typeof uuid !== "string") {
|
||||||
|
throw new Error(`authenticatorMobile expects full UUID, received ${uuid}`);
|
||||||
|
}
|
||||||
|
return api().authenticatorsMobileUpdate({ uuid, mobileDeviceRequest: device });
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return exhaustiveGuard(deviceType);
|
return exhaustiveGuard(deviceType);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue