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

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,8 +1,8 @@
1
- import { useState as E, useCallback as v, useEffect as b } from "react";
1
+ import { useState as v, useCallback as E, useEffect as b } from "react";
2
2
  import { LicenseType as y } from "../types.js";
3
- import { appConsole as l } from "../appConsole.js";
3
+ import { appConsole as c } 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-23T03:03:12.500Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", o = {
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}`,
@@ -23,71 +23,86 @@ function L(r) {
23
23
  }
24
24
  async function S(r, 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: n } = JSON.parse(atob(r)), i = I(`-----BEGIN PUBLIC KEY-----
27
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyrIi83Zr5AKaWO6zbZmX
28
+ qv3McVhtnPOnWCiFgf5xeaglLzEwMiXo3gALaPoBp5Q0WPOSBE9GTqwOyQUgpDNS
29
+ BuQ0cjOzQdFM3GPnKSqQThZJfjUmD9egMZDmfhcpFGPybUoicoIEFQOdX2vMFUfn
30
+ 6yjRsyvbK6UPTombYl785V8dXNnnIHa4tQC1JSaSe/bhG3e/6kbQCy9VJ23242q9
31
+ WJpx9c2sZ+bmyI0r9Zx0PfqcDJzDfKn45v96EtxGhV16OZhqkbj4ljiJ/mfqfCkx
32
+ ybkm9nvxz0hAwcEftQaxl/0cZ1RxtsRcL+V3msLsmGcs9nPqAuXecbfg9QVCi/+m
33
+ iwIDAQAB
34
+ -----END PUBLIC KEY-----`), s = await window.crypto.subtle.importKey(
27
35
  "spki",
28
36
  // str2ab(publicKeyContent), // Convert PEM string to ArrayBuffer
29
37
  i,
30
38
  { name: "RSA-PSS", hash: t },
31
39
  !0,
32
40
  ["verify"]
33
- );
34
- if (!await window.crypto.subtle.verify(
41
+ ), a = await window.crypto.subtle.verify(
35
42
  { name: "RSA-PSS", saltLength: 32 },
36
- a,
43
+ s,
37
44
  L(n),
38
45
  // Convert signature to ArrayBuffer
39
46
  new TextEncoder().encode(atob(e))
40
- ))
41
- throw new Error(s.invalidSignature);
47
+ );
48
+ if (c.debug(">>> Verified license key validity", a), !a)
49
+ throw new Error(o.invalidSignature);
42
50
  return JSON.parse(atob(e));
43
51
  } catch {
44
- throw new Error(s.invalidLicense);
52
+ throw new Error(o.invalidLicense);
45
53
  }
46
54
  }
47
- const x = (r, t) => r === "specific" ? t === window.location.host : window.location.host.includes(t), u = {
55
+ const x = (r, t) => {
56
+ switch (r) {
57
+ case "specific":
58
+ return t === window.location.host;
59
+ case "wildcard":
60
+ return t ? window.location.host.includes(t) : !1;
61
+ }
62
+ }, u = {
48
63
  isValid: !0,
49
- invalidatedMessage: s.invalidLicense,
64
+ invalidatedMessage: o.invalidLicense,
50
65
  type: void 0
51
66
  }, N = (r) => {
52
- const [t, e] = E(u), n = v(async () => {
53
- if (e((c) => ({ ...c, validating: !0 })), !r)
54
- throw e({ ...u, validating: !1 }), new Error(s.invalidLicense);
67
+ const [t, e] = v(u), n = E(async () => {
68
+ if (e((l) => ({ ...l, validating: !0 })), !r)
69
+ throw e({ ...u, validating: !1 }), new Error(o.invalidLicense);
55
70
  let i;
56
71
  try {
57
72
  i = await S(r);
58
- } catch (c) {
59
- throw l.warn(c.message), new Error(c.message);
73
+ } catch (l) {
74
+ throw c.warn(l.message), new Error(l.message);
60
75
  }
61
- l.debug(">>> validatedLicense", i);
62
- const { avu: a, exp: o, dmt: w, dm: p, t: m } = i;
63
- if (!o)
76
+ c.debug(">>> validatedLicense", i);
77
+ const { avu: s, exp: a, dmt: w, dm: p, t: f } = i;
78
+ if (!a)
64
79
  throw new Error("License is missing expiration timestamp");
65
- if (o > Number.MAX_SAFE_INTEGER / 1e3)
80
+ if (a > Number.MAX_SAFE_INTEGER / 1e3)
66
81
  throw new Error("Invalid expiration timestamp: value too large");
67
- const g = new Date(o * 1e3), h = (/* @__PURE__ */ new Date()).getTime();
82
+ const g = new Date(a * 1e3), h = (/* @__PURE__ */ new Date()).getTime();
68
83
  if (g.getTime() < h)
69
- throw new Error(s.expired);
70
- if (!a)
84
+ throw new Error(o.expired);
85
+ if (!s)
71
86
  throw new Error("License is missing available until version timestamp");
72
- if (a > Number.MAX_SAFE_INTEGER / 1e3)
87
+ if (s > Number.MAX_SAFE_INTEGER / 1e3)
73
88
  throw new Error("Invalid available until version timestamp: value too large");
74
- const f = new Date(a * 1e3);
75
- if (l.debug("availableUntilTimestamp", f), f.getTime() < A.getTime())
76
- throw new Error(s.exceededVersion);
77
- if (m !== y.Custom && !x(w, p))
78
- throw new Error(s.mismatchedDomain);
89
+ const m = new Date(s * 1e3);
90
+ if (c.debug("availableUntilTimestamp", m), m.getTime() < A.getTime())
91
+ throw new Error(o.exceededVersion);
92
+ if (f !== y.Custom && !x(w, p))
93
+ throw new Error(o.mismatchedDomain);
79
94
  return {
80
95
  isValid: !0,
81
- type: m,
96
+ type: f,
82
97
  invalidatedMessage: void 0
83
98
  };
84
99
  }, [r]);
85
100
  return b(() => {
86
- n().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
101
+ n().then(({ isValid: i, type: s, invalidatedMessage: a }) => {
87
102
  e({
88
103
  isValid: i,
89
- type: a,
90
- invalidatedMessage: o,
104
+ type: s,
105
+ invalidatedMessage: a,
91
106
  validating: !1
92
107
  });
93
108
  }).catch((i) => {
@@ -95,7 +110,7 @@ const x = (r, t) => r === "specific" ? t === window.location.host : window.locat
95
110
  ...u,
96
111
  isValid: !1,
97
112
  validating: !1
98
- }), l.warn(i.message);
113
+ }), c.warn(i.message);
99
114
  });
100
115
  }, [n]), t;
101
116
  };
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.8",
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": [