@streamlayer/sdk-web-anonymous-auth 1.4.1 → 1.4.3

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.
package/lib/cjs/index.js CHANGED
@@ -3650,7 +3650,11 @@ const login = async (instance, opts = {}) => {
3650
3650
  const token = anonymous2.meta?.token;
3651
3651
  const pubKey = organization.pub;
3652
3652
  const pub = await jose.importJWK({ ...pubKey });
3653
- const deviceId = window.crypto.randomUUID();
3653
+ const b = crypto.getRandomValues(new Uint8Array(16));
3654
+ b[6] = b[6] & 15 | 64;
3655
+ b[8] = b[8] & 63 | 128;
3656
+ const h = Array.from(b, (v) => v.toString(16).padStart(2, "0")).join("");
3657
+ const deviceId = `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
3654
3658
  const jwe = await new jose.EncryptJWT({ ["device-id"]: deviceId, totp: token }).setProtectedHeader({ alg: pubKey.alg || "", enc: "A256CBC-HS512", kid: pubKey.kid }).setIssuedAt().setIssuer(issuer).setAudience(organization.id).setExpirationTime("2m").encrypt(pub);
3655
3659
  await instance.auth.login(schema, jwe);
3656
3660
  storage.setSchema("streamlayer:streamlayer");
package/lib/dist/index.js CHANGED
@@ -20,7 +20,11 @@ const login = async (instance, opts = {}) => {
20
20
  const token = anonymous.meta?.token;
21
21
  const pubKey = organization.pub;
22
22
  const pub = await importJWK({ ...pubKey });
23
- const deviceId = window.crypto.randomUUID();
23
+ const b = crypto.getRandomValues(new Uint8Array(16));
24
+ b[6] = (b[6] & 0x0f) | 0x40;
25
+ b[8] = (b[8] & 0x3f) | 0x80;
26
+ const h = Array.from(b, (v) => v.toString(16).padStart(2, '0')).join('');
27
+ const deviceId = `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
24
28
  const jwe = await new EncryptJWT({ ['device-id']: deviceId, totp: token })
25
29
  .setProtectedHeader({ alg: pubKey.alg || '', enc: 'A256CBC-HS512', kid: pubKey.kid })
26
30
  .setIssuedAt()
package/lib/es/index.js CHANGED
@@ -3648,7 +3648,11 @@ const login = async (instance, opts = {}) => {
3648
3648
  const token = anonymous2.meta?.token;
3649
3649
  const pubKey = organization.pub;
3650
3650
  const pub = await importJWK({ ...pubKey });
3651
- const deviceId = window.crypto.randomUUID();
3651
+ const b = crypto.getRandomValues(new Uint8Array(16));
3652
+ b[6] = b[6] & 15 | 64;
3653
+ b[8] = b[8] & 63 | 128;
3654
+ const h = Array.from(b, (v) => v.toString(16).padStart(2, "0")).join("");
3655
+ const deviceId = `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
3652
3656
  const jwe = await new EncryptJWT({ ["device-id"]: deviceId, totp: token }).setProtectedHeader({ alg: pubKey.alg || "", enc: "A256CBC-HS512", kid: pubKey.kid }).setIssuedAt().setIssuer(issuer).setAudience(organization.id).setExpirationTime("2m").encrypt(pub);
3653
3657
  await instance.auth.login(schema, jwe);
3654
3658
  storage.setSchema("streamlayer:streamlayer");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamlayer/sdk-web-anonymous-auth",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "author": "StreamLayer, Inc (https://streamlayer.io)",
5
5
  "maintainers": [
6
6
  {
@@ -29,7 +29,7 @@
29
29
  "peerDependencies": {
30
30
  "@streamlayer/sl-eslib": "^5.229.1",
31
31
  "jose": "^5.9.3",
32
- "@streamlayer/sdk-web": "^1.18.1"
32
+ "@streamlayer/sdk-web": "^1.18.3"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@nx/devkit": "20.4.2",
@@ -44,8 +44,8 @@
44
44
  "vite-plugin-node-polyfills": "^0.25.0",
45
45
  "vite-tsconfig-paths": "^6.1.1",
46
46
  "webpack": "^5.95.0",
47
- "@streamlayer/sdk-web-api": "^1.16.1",
48
- "@streamlayer/sdk-web-core": "^1.21.1",
49
- "@streamlayer/sdk-web-interfaces": "^1.9.9"
47
+ "@streamlayer/sdk-web-api": "^1.16.3",
48
+ "@streamlayer/sdk-web-core": "^1.21.3",
49
+ "@streamlayer/sdk-web-interfaces": "^1.9.11"
50
50
  }
51
51
  }