Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32400158
D12239.1765340283.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D12239.1765340283.diff
View Options
diff --git a/lib/shared/device-list-utils.js b/lib/shared/device-list-utils.js
--- a/lib/shared/device-list-utils.js
+++ b/lib/shared/device-list-utils.js
@@ -194,10 +194,35 @@
await updateDeviceList(signedDeviceList);
}
+async function removeDeviceFromDeviceList(
+ identityClient: IdentityServiceClient,
+ userID: string,
+ deviceIDToRemove: string,
+): Promise<void> {
+ const { updateDeviceList } = identityClient;
+ invariant(
+ updateDeviceList,
+ 'updateDeviceList() should be defined on native. ' +
+ 'Are you calling it on a non-primary device?',
+ );
+
+ const { devices } = await fetchLatestDeviceList(identityClient, userID);
+ const newDevices = devices.filter(it => it !== deviceIDToRemove);
+ if (devices.length === newDevices.length) {
+ // the device wasn't on the device list
+ return;
+ }
+
+ const newDeviceList = composeRawDeviceList(newDevices);
+ const signedDeviceList = await signDeviceListUpdate(newDeviceList);
+ await updateDeviceList(signedDeviceList);
+}
+
export {
verifyAndGetDeviceList,
createAndSignInitialDeviceList,
fetchLatestDeviceList,
addDeviceToDeviceList,
+ removeDeviceFromDeviceList,
signDeviceListUpdate,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 10, 4:18 AM (16 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5860821
Default Alt Text
D12239.1765340283.diff (1 KB)
Attached To
Mode
D12239: [lib] Add function to remove device from device list
Attached
Detach File
Event Timeline
Log In to Comment