fix(calendar-sync) remove unneeded function

A GUID is just a UUID v4, so let's use that.
This commit is contained in:
Saúl Ibarra Corretgé 2022-01-28 12:38:57 +01:00 committed by Дамян Минков
parent fe2c5f6447
commit 9d829003b4
1 changed files with 3 additions and 35 deletions

View File

@ -3,6 +3,7 @@
import { Client } from '@microsoft/microsoft-graph-client';
import base64js from 'base64-js';
import type { Dispatch } from 'redux';
import { v4 as uuidV4 } from 'uuid';
import { findWindows } from 'windows-iana';
import { createDeferred } from '../../../../modules/util/helpers';
@ -153,8 +154,8 @@ export const microsoftCalendarApi = {
const signInDeferred = createDeferred();
const guids = {
authState: generateGuid(),
authNonce: generateGuid()
authState: uuidV4(),
authNonce: uuidV4()
};
dispatch(setCalendarAPIAuthState(guids));
@ -339,21 +340,6 @@ function formatCalendarEntry(entry) {
};
}
/**
* Generate a guid to be used for verifying token validity.
*
* @private
* @returns {string} The generated string.
*/
function generateGuid() {
const buf = new Uint16Array(8);
window.crypto.getRandomValues(buf);
return `${s4(buf[0])}${s4(buf[1])}-${s4(buf[2])}-${s4(buf[3])}-${
s4(buf[4])}-${s4(buf[5])}${s4(buf[6])}${s4(buf[7])}`;
}
/**
* Constructs and returns the URL to use for renewing an auth token.
*
@ -582,24 +568,6 @@ function requestCalendarEvents( // eslint-disable-line max-params
}));
}
/**
* Converts the passed in number to a string and ensure it is at least 4
* characters in length, prepending 0's as needed.
*
* @param {number} num - The number to pad and convert to a string.
* @private
* @returns {string} - The number converted to a string.
*/
function s4(num) {
let ret = num.toString(16);
while (ret.length < 4) {
ret = `0${ret}`;
}
return ret;
}
/**
* Convert a Base64URL encoded string to a UTF-8 encoded string including CJK or Latin.
*