@react-pdf-kit/viewer 0.0.0-experimental.6 → 0.0.0-experimental.7

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.
@@ -2,28 +2,28 @@ import { useState as E, useCallback as v, useEffect as b } from "react";
2
2
  import { LicenseType as y } from "../types.js";
3
3
  import { appConsole as l } from "../appConsole.js";
4
4
  import "../../de_DE-a553b162.js";
5
- const A = /* @__PURE__ */ new Date("2026-03-19T04:24:51.186Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
5
+ const A = /* @__PURE__ */ new Date("2026-03-19T08:41:30.523Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
6
6
  invalidLicense: `You are currently using without a valid license. ${d}`,
7
7
  mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
8
8
  expired: `Your license key has expired. ${d}`,
9
9
  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.",
10
10
  invalidSignature: "Invalid license key: Signature mismatch"
11
11
  };
12
- function I(r) {
13
- const t = r.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), e = atob(t), n = new Uint8Array(e.length);
12
+ function I(n) {
13
+ const t = n.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), e = atob(t), r = new Uint8Array(e.length);
14
14
  for (let i = 0; i < e.length; i++)
15
- n[i] = e.charCodeAt(i);
16
- return n.buffer;
15
+ r[i] = e.charCodeAt(i);
16
+ return r.buffer;
17
17
  }
18
- function L(r) {
19
- const t = atob(r), e = new Uint8Array(t.length);
20
- for (let n = 0; n < t.length; n++)
21
- e[n] = t.charCodeAt(n);
18
+ function L(n) {
19
+ const t = atob(n), e = new Uint8Array(t.length);
20
+ for (let r = 0; r < t.length; r++)
21
+ e[r] = t.charCodeAt(r);
22
22
  return e.buffer;
23
23
  }
24
- async function S(r, t = "SHA-256") {
24
+ async function S(n, t = "SHA-256") {
25
25
  try {
26
- const { data: e, signature: n } = JSON.parse(atob(r)), i = I("-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyrIi83Zr5AKaWO6zbZmXqv3McVhtnPOnWCiFgf5xeaglLzEwMiXo3gALaPoBp5Q0WPOSBE9GTqwOyQUgpDNSBuQ0cjOzQdFM3GPnKSqQThZJfjUmD9egMZDmfhcpFGPybUoicoIEFQOdX2vMFUfn6yjRsyvbK6UPTombYl785V8dXNnnIHa4tQC1JSaSe/bhG3e/6kbQCy9VJ23242q9WJpx9c2sZ+bmyI0r9Zx0PfqcDJzDfKn45v96EtxGhV16OZhqkbj4ljiJ/mfqfCkxybkm9nvxz0hAwcEftQaxl/0cZ1RxtsRcL+V3msLsmGcs9nPqAuXecbfg9QVCi/+miwIDAQAB-----END PUBLIC KEY-----"), a = await window.crypto.subtle.importKey(
26
+ const { data: e, signature: r } = JSON.parse(atob(n)), i = I("-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyrIi83Zr5AKaWO6zbZmXqv3McVhtnPOnWCiFgf5xeaglLzEwMiXo3gALaPoBp5Q0WPOSBE9GTqwOyQUgpDNSBuQ0cjOzQdFM3GPnKSqQThZJfjUmD9egMZDmfhcpFGPybUoicoIEFQOdX2vMFUfn6yjRsyvbK6UPTombYl785V8dXNnnIHa4tQC1JSaSe/bhG3e/6kbQCy9VJ23242q9WJpx9c2sZ+bmyI0r9Zx0PfqcDJzDfKn45v96EtxGhV16OZhqkbj4ljiJ/mfqfCkxybkm9nvxz0hAwcEftQaxl/0cZ1RxtsRcL+V3msLsmGcs9nPqAuXecbfg9QVCi/+miwIDAQAB-----END PUBLIC KEY-----"), a = await window.crypto.subtle.importKey(
27
27
  "spki",
28
28
  // str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
29
29
  i,
@@ -34,7 +34,7 @@ async function S(r, t = "SHA-256") {
34
34
  if (!await window.crypto.subtle.verify(
35
35
  { name: "RSA-PSS", saltLength: 32 },
36
36
  a,
37
- L(n),
37
+ L(r),
38
38
  // Convert signature to ArrayBuffer
39
39
  new TextEncoder().encode(atob(e))
40
40
  ))
@@ -44,17 +44,24 @@ async function S(r, t = "SHA-256") {
44
44
  throw new Error(s.invalidLicense);
45
45
  }
46
46
  }
47
- const x = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), u = {
47
+ const x = (n, t) => {
48
+ switch (n) {
49
+ case "specific":
50
+ return t === window.location.host;
51
+ case "wildcard":
52
+ return t ? window.location.host.includes(t) : !1;
53
+ }
54
+ }, u = {
48
55
  isValid: !0,
49
56
  invalidatedMessage: s.invalidLicense,
50
57
  type: void 0
51
- }, N = (r) => {
52
- const [t, e] = E(u), n = v(async () => {
53
- if (e((c) => ({ ...c, validating: !0 })), !r)
58
+ }, N = (n) => {
59
+ const [t, e] = E(u), r = v(async () => {
60
+ if (e((c) => ({ ...c, validating: !0 })), !n)
54
61
  throw e({ ...u, validating: !1 }), new Error(s.invalidLicense);
55
62
  let i;
56
63
  try {
57
- i = await S(r);
64
+ i = await S(n);
58
65
  } catch (c) {
59
66
  throw l.warn(c.message), new Error(c.message);
60
67
  }
@@ -81,9 +88,9 @@ const x = (r, t) => r === "specific" ? t === window.location.host : window.locat
81
88
  type: m,
82
89
  invalidatedMessage: void 0
83
90
  };
84
- }, [r]);
91
+ }, [n]);
85
92
  return b(() => {
86
- n().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
93
+ r().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
87
94
  e({
88
95
  isValid: i,
89
96
  type: a,
@@ -97,7 +104,7 @@ const x = (r, t) => r === "specific" ? t === window.location.host : window.locat
97
104
  validating: !1
98
105
  }), l.warn(i.message);
99
106
  });
100
- }, [n]), t;
107
+ }, [r]), t;
101
108
  };
102
109
  export {
103
110
  N as useLicense
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pdf-kit/viewer",
3
- "version": "0.0.0-experimental.6",
3
+ "version": "0.0.0-experimental.7",
4
4
  "private": false,
5
5
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
6
6
  "keywords": [