@vardario/cognito-client 4.0.1 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/utils.js +2 -6
  2. package/package.json +2 -1
package/lib/utils.js CHANGED
@@ -2,11 +2,7 @@ import hashJs from 'hash.js';
2
2
  import { BigInteger } from 'jsbn';
3
3
  import { Buffer } from 'buffer';
4
4
  import formatInTimeZone from 'date-fns-tz/formatInTimeZone';
5
- let crypto = globalThis.crypto;
6
- if (!crypto) {
7
- const nodeCrypto = await import('node:crypto');
8
- crypto = nodeCrypto.webcrypto;
9
- }
5
+ import { random } from '@lukeed/csprng';
10
6
  const initN = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1' +
11
7
  '29024E088A67CC74020BBEA63B139B22514A08798E3404DD' +
12
8
  'EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245' +
@@ -118,7 +114,7 @@ export function decodeJwt(jwt) {
118
114
  };
119
115
  }
120
116
  export async function randomBytes(num) {
121
- return Buffer.from(crypto.getRandomValues(new Uint8Array(num)));
117
+ return random(num);
122
118
  }
123
119
  export function formatTimestamp(date) {
124
120
  return formatInTimeZone(date, 'UTC', "EEE MMM d HH:mm:ss 'UTC' yyyy");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vardario/cognito-client",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "Sahin Vardar",
@@ -22,6 +22,7 @@
22
22
  "watch": "tsc --build --watch"
23
23
  },
24
24
  "dependencies": {
25
+ "@lukeed/csprng": "^1.1.0",
25
26
  "buffer": "^6.0.3",
26
27
  "date-fns-tz": "^2.0.0",
27
28
  "hash.js": "^1.1.7",