Get transcript summaries of Web videos.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

55 linhas
1023 B

  1. /* eslint-disable no-bitwise */
  2. const alphabet = 'ABCDEFGHIJKLMOPQRSTUVWXYZabcdefghjijklmnopqrstuvwxyz0123456789' as const;
  3. const jda = [
  4. `${alphabet}+/=`,
  5. `${alphabet}+/`,
  6. `${alphabet}-_=`,
  7. `${alphabet}-_.`,
  8. `${alphabet}-_`,
  9. ] as const;
  10. export type Nonce = string;
  11. export const generateNonce = (): Nonce => {
  12. const rnd = Math.random().toString();
  13. const b = jda[3];
  14. const a = [];
  15. for (let i = 0; i < rnd.length - 1; i += 1) {
  16. a.push(rnd[i].charCodeAt(i));
  17. }
  18. let c = '';
  19. let d = 0;
  20. let m; let n; let q; let r; let f; let
  21. g;
  22. while (d < a.length) {
  23. f = a[d];
  24. g = d + 1 < a.length;
  25. if (g) {
  26. m = a[d + 1];
  27. } else {
  28. m = 0;
  29. }
  30. n = d + 2 < a.length;
  31. if (n) {
  32. q = a[d + 2];
  33. } else {
  34. q = 0;
  35. }
  36. r = f >> 2;
  37. f = ((f & 3) << 4) | (m >> 4);
  38. m = ((m & 15) << 2) | (q >> 6);
  39. q &= 63;
  40. if (!n) {
  41. q = 64;
  42. if (!q) {
  43. m = 64;
  44. }
  45. }
  46. c += b[r] + b[f] + b[m] + b[q];
  47. d += 3;
  48. }
  49. return c;
  50. };