@beta-gamer/react-native 0.1.5 → 0.1.6

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/dist/index.js CHANGED
@@ -44,20 +44,37 @@ var import_react = require("react");
44
44
  var import_socket = require("socket.io-client");
45
45
  var import_jsx_runtime = require("react/jsx-runtime");
46
46
  function base64Decode(str) {
47
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
48
- const normalized = str.replace(/-/g, "+").replace(/_/g, "/");
49
- let output = "";
47
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
48
+ const normalized = str.replace(/-/g, "+").replace(/_/g, "/").padEnd(str.length + (4 - str.length % 4) % 4, "=");
49
+ const bytes = [];
50
50
  let i = 0;
51
51
  while (i < normalized.length) {
52
52
  const e1 = chars.indexOf(normalized[i++]);
53
53
  const e2 = chars.indexOf(normalized[i++]);
54
- const e3 = chars.indexOf(normalized[i++]);
55
- const e4 = chars.indexOf(normalized[i++]);
56
- output += String.fromCharCode(e1 << 2 | e2 >> 4);
57
- if (e3 !== 64) output += String.fromCharCode((e2 & 15) << 4 | e3 >> 2);
58
- if (e4 !== 64) output += String.fromCharCode((e3 & 3) << 6 | e4);
54
+ const e3 = normalized[i] === "=" ? 64 : chars.indexOf(normalized[i]);
55
+ i++;
56
+ const e4 = normalized[i] === "=" ? 64 : chars.indexOf(normalized[i]);
57
+ i++;
58
+ bytes.push(e1 << 2 | e2 >> 4);
59
+ if (e3 !== 64) bytes.push((e2 & 15) << 4 | e3 >> 2);
60
+ if (e4 !== 64) bytes.push((e3 & 3) << 6 | e4);
59
61
  }
60
- return decodeURIComponent(escape(output));
62
+ let out = "";
63
+ let j = 0;
64
+ while (j < bytes.length) {
65
+ const b = bytes[j++];
66
+ if (b < 128) {
67
+ out += String.fromCharCode(b);
68
+ } else if (b < 224) {
69
+ out += String.fromCharCode((b & 31) << 6 | bytes[j++] & 63);
70
+ } else if (b < 240) {
71
+ out += String.fromCharCode((b & 15) << 12 | (bytes[j++] & 63) << 6 | bytes[j++] & 63);
72
+ } else {
73
+ const cp = (b & 7) << 18 | (bytes[j++] & 63) << 12 | (bytes[j++] & 63) << 6 | bytes[j++] & 63;
74
+ out += String.fromCodePoint(cp);
75
+ }
76
+ }
77
+ return out;
61
78
  }
62
79
  function decodeToken(token) {
63
80
  if (!token || typeof token !== "string") {
package/dist/index.mjs CHANGED
@@ -3,20 +3,37 @@ import { createContext, useContext, useEffect, useState } from "react";
3
3
  import { io } from "socket.io-client";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  function base64Decode(str) {
6
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
7
- const normalized = str.replace(/-/g, "+").replace(/_/g, "/");
8
- let output = "";
6
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
7
+ const normalized = str.replace(/-/g, "+").replace(/_/g, "/").padEnd(str.length + (4 - str.length % 4) % 4, "=");
8
+ const bytes = [];
9
9
  let i = 0;
10
10
  while (i < normalized.length) {
11
11
  const e1 = chars.indexOf(normalized[i++]);
12
12
  const e2 = chars.indexOf(normalized[i++]);
13
- const e3 = chars.indexOf(normalized[i++]);
14
- const e4 = chars.indexOf(normalized[i++]);
15
- output += String.fromCharCode(e1 << 2 | e2 >> 4);
16
- if (e3 !== 64) output += String.fromCharCode((e2 & 15) << 4 | e3 >> 2);
17
- if (e4 !== 64) output += String.fromCharCode((e3 & 3) << 6 | e4);
13
+ const e3 = normalized[i] === "=" ? 64 : chars.indexOf(normalized[i]);
14
+ i++;
15
+ const e4 = normalized[i] === "=" ? 64 : chars.indexOf(normalized[i]);
16
+ i++;
17
+ bytes.push(e1 << 2 | e2 >> 4);
18
+ if (e3 !== 64) bytes.push((e2 & 15) << 4 | e3 >> 2);
19
+ if (e4 !== 64) bytes.push((e3 & 3) << 6 | e4);
18
20
  }
19
- return decodeURIComponent(escape(output));
21
+ let out = "";
22
+ let j = 0;
23
+ while (j < bytes.length) {
24
+ const b = bytes[j++];
25
+ if (b < 128) {
26
+ out += String.fromCharCode(b);
27
+ } else if (b < 224) {
28
+ out += String.fromCharCode((b & 31) << 6 | bytes[j++] & 63);
29
+ } else if (b < 240) {
30
+ out += String.fromCharCode((b & 15) << 12 | (bytes[j++] & 63) << 6 | bytes[j++] & 63);
31
+ } else {
32
+ const cp = (b & 7) << 18 | (bytes[j++] & 63) << 12 | (bytes[j++] & 63) << 6 | bytes[j++] & 63;
33
+ out += String.fromCodePoint(cp);
34
+ }
35
+ }
36
+ return out;
20
37
  }
21
38
  function decodeToken(token) {
22
39
  if (!token || typeof token !== "string") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beta-gamer/react-native",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "React Native SDK for Beta Gamer GaaS — composable game components",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",