Page MenuHomePhabricator

D4587.id14774.diff
No OneTemporary

D4587.id14774.diff

diff --git a/web/utils/device-uuid.js b/web/utils/device-uuid.js
new file mode 100644
--- /dev/null
+++ b/web/utils/device-uuid.js
@@ -0,0 +1,24 @@
+// @flow
+import crypto from 'crypto';
+
+export const deviceUUIDTypes = Object.freeze({
+ KEYSERVER: 0,
+ WEB: 1,
+ MOBILE: 2,
+});
+export type DeviceUUIDType = $Values<typeof deviceUUIDTypes>;
+
+function getDeviceUUID(type: DeviceUUIDType): string {
+ const uuidSuffix = crypto.randomBytes(32).toString('hex');
+
+ if (type === deviceUUIDTypes.KEYSERVER) {
+ return `ks-${uuidSuffix}`;
+ } else if (type === deviceUUIDTypes.WEB) {
+ return `web-${uuidSuffix}`;
+ } else if (type === deviceUUIDTypes.MOBILE) {
+ return `mobile-${uuidSuffix}`;
+ }
+ return '';
+}
+
+export { getDeviceUUID };

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 11:10 PM (21 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2592031
Default Alt Text
D4587.id14774.diff (763 B)

Event Timeline