@pdf-viewer/react 0.9.0-beta.3 → 0.9.0-beta.4

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.
@@ -1,94 +1,102 @@
1
- import { useState as g, useCallback as h, useEffect as v } from "react";
1
+ import { useState as g, useCallback as E, useEffect as h } from "react";
2
2
  import { appConsole as l } from "../appConsole.js";
3
- const b = /* @__PURE__ */ new Date("2025-02-26T09:36:43.627Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
3
+ const A = /* @__PURE__ */ new Date("2025-02-26T10:08:29.736Z"), d = "Please visit https://www.react-pdf.dev/license-management/ to generate a new license key.", o = {
4
4
  invalidLicense: `You are currently using without a valid license. ${d}`,
5
5
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
6
6
  expired: `Your license key has expired. ${d}`,
7
7
  exceededVersion: "Your license does not support the current version of React PDF. The library version you are using exceeds the supported range of your license.",
8
8
  invalidSignature: "Invalid license key: Signature mismatch"
9
9
  };
10
- function y(r) {
11
- const i = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), t = atob(i), n = new Uint8Array(t.length);
12
- for (let e = 0; e < t.length; e++)
13
- n[e] = t.charCodeAt(e);
10
+ function b(r) {
11
+ const t = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), i = atob(t), n = new Uint8Array(i.length);
12
+ for (let e = 0; e < i.length; e++)
13
+ n[e] = i.charCodeAt(e);
14
14
  return n.buffer;
15
15
  }
16
- function A(r) {
17
- const i = atob(r), t = new Uint8Array(i.length);
18
- for (let n = 0; n < i.length; n++)
19
- t[n] = i.charCodeAt(n);
20
- return t.buffer;
16
+ function S(r) {
17
+ const t = atob(r), i = new Uint8Array(t.length);
18
+ for (let n = 0; n < t.length; n++)
19
+ i[n] = t.charCodeAt(n);
20
+ return i.buffer;
21
21
  }
22
- async function I(r, i = "SHA-256") {
22
+ async function I(r, t = "SHA-256") {
23
23
  try {
24
- const { data: t, signature: n } = JSON.parse(atob(r)), e = y("-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyrIi83Zr5AKaWO6zbZmXqv3McVhtnPOnWCiFgf5xeaglLzEwMiXo3gALaPoBp5Q0WPOSBE9GTqwOyQUgpDNSBuQ0cjOzQdFM3GPnKSqQThZJfjUmD9egMZDmfhcpFGPybUoicoIEFQOdX2vMFUfn6yjRsyvbK6UPTombYl785V8dXNnnIHa4tQC1JSaSe/bhG3e/6kbQCy9VJ23242q9WJpx9c2sZ+bmyI0r9Zx0PfqcDJzDfKn45v96EtxGhV16OZhqkbj4ljiJ/mfqfCkxybkm9nvxz0hAwcEftQaxl/0cZ1RxtsRcL+V3msLsmGcs9nPqAuXecbfg9QVCi/+miwIDAQAB-----END PUBLIC KEY-----"), a = await window.crypto.subtle.importKey(
24
+ const { data: i, signature: n } = JSON.parse(atob(r)), e = b(`-----BEGIN PUBLIC KEY-----
25
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx
26
+ gr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b
27
+ HLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y
28
+ Bm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W
29
+ vXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD
30
+ vzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR
31
+ kwIDAQAB
32
+ -----END PUBLIC KEY-----`), a = await window.crypto.subtle.importKey(
25
33
  "spki",
26
34
  // str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
27
35
  e,
28
- { name: "RSA-PSS", hash: i },
36
+ { name: "RSA-PSS", hash: t },
29
37
  !0,
30
38
  ["verify"]
31
39
  );
32
40
  if (!await window.crypto.subtle.verify(
33
41
  { name: "RSA-PSS", saltLength: 32 },
34
42
  a,
35
- A(n),
43
+ S(n),
36
44
  // Convert signature to ArrayBuffer
37
- new TextEncoder().encode(atob(t))
45
+ new TextEncoder().encode(atob(i))
38
46
  ))
39
47
  throw new Error(o.invalidSignature);
40
- return JSON.parse(atob(t));
48
+ return JSON.parse(atob(i));
41
49
  } catch {
42
50
  throw new Error(o.invalidLicense);
43
51
  }
44
52
  }
45
- const L = (r, i) => r === "specific" ? i === window.location.host : window.location.host.includes(i), c = {
53
+ const L = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), c = {
46
54
  isValid: !1,
47
55
  invalidatedMessage: o.invalidLicense,
48
56
  type: void 0
49
- }, T = (r) => {
50
- const [i, t] = g(c), n = h(async () => {
57
+ }, N = (r) => {
58
+ const [t, i] = g(c), n = E(async () => {
51
59
  if (!r)
52
- return t(c), c;
60
+ return i(c), c;
53
61
  try {
54
62
  const e = await I(r);
55
63
  l.debug(">>> validatedLicense", e);
56
- const { avu: a, exp: s, dmt: m, dm: f, t: w } = e;
64
+ const { avu: a, exp: s, dmt: m, dm: p, t: v } = e;
57
65
  if (!s)
58
66
  throw new Error("License is missing expiration timestamp");
59
67
  if (s > Number.MAX_SAFE_INTEGER / 1e3)
60
68
  throw new Error("Invalid expiration timestamp: value too large");
61
- const p = new Date(s * 1e3), E = (/* @__PURE__ */ new Date()).getTime();
62
- if (p.getTime() < E)
69
+ const f = new Date(s * 1e3), w = (/* @__PURE__ */ new Date()).getTime();
70
+ if (f.getTime() < w)
63
71
  throw new Error(o.expired);
64
72
  if (!a)
65
73
  throw new Error("License is missing available until version timestamp");
66
74
  if (a > Number.MAX_SAFE_INTEGER / 1e3)
67
75
  throw new Error("Invalid available until version timestamp: value too large");
68
76
  const u = new Date(a * 1e3);
69
- if (l.debug("availableUntilTimestamp", u), u.getTime() < b.getTime())
77
+ if (l.debug("availableUntilTimestamp", u), u.getTime() < A.getTime())
70
78
  throw new Error(o.exceededVersion);
71
- if (!L(m, f))
79
+ if (!L(m, p))
72
80
  throw new Error(o.mismatchedDomain);
73
81
  return {
74
82
  isValid: !0,
75
- type: w,
83
+ type: v,
76
84
  invalidatedMessage: void 0
77
85
  };
78
86
  } catch (e) {
79
87
  return l.warn(e.message), { ...c, invalidatedMessage: e.message };
80
88
  }
81
89
  }, [r]);
82
- return v(() => {
90
+ return h(() => {
83
91
  n().then(({ isValid: e, type: a, invalidatedMessage: s }) => {
84
- t({
92
+ i({
85
93
  isValid: e,
86
94
  type: a,
87
95
  invalidatedMessage: s
88
96
  });
89
97
  });
90
- }, [n]), i;
98
+ }, [n]), t;
91
99
  };
92
100
  export {
93
- T as useLicense
101
+ N as useLicense
94
102
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
- "version": "0.9.0-beta.3",
4
+ "version": "0.9.0-beta.4",
5
5
  "keywords": [
6
6
  "component",
7
7
  "frontend",