@react-pdf-kit/viewer 0.0.0-experimental.7 → 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,51 +1,59 @@
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-19T08:41:30.523Z"), 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}`,
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(n) {
13
- const t = n.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s+/g, ""), e = atob(t), r = new Uint8Array(e.length);
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);
14
14
  for (let i = 0; i < e.length; i++)
15
- r[i] = e.charCodeAt(i);
16
- return r.buffer;
15
+ n[i] = e.charCodeAt(i);
16
+ return n.buffer;
17
17
  }
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);
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);
22
22
  return e.buffer;
23
23
  }
24
- async function S(n, t = "SHA-256") {
24
+ async function S(r, t = "SHA-256") {
25
25
  try {
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(
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,
37
- L(r),
43
+ s,
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 = (n, t) => {
48
- switch (n) {
55
+ const x = (r, t) => {
56
+ switch (r) {
49
57
  case "specific":
50
58
  return t === window.location.host;
51
59
  case "wildcard":
@@ -53,48 +61,48 @@ const x = (n, t) => {
53
61
  }
54
62
  }, u = {
55
63
  isValid: !0,
56
- invalidatedMessage: s.invalidLicense,
64
+ invalidatedMessage: o.invalidLicense,
57
65
  type: void 0
58
- }, N = (n) => {
59
- const [t, e] = E(u), r = v(async () => {
60
- if (e((c) => ({ ...c, validating: !0 })), !n)
61
- throw e({ ...u, validating: !1 }), new Error(s.invalidLicense);
66
+ }, N = (r) => {
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);
62
70
  let i;
63
71
  try {
64
- i = await S(n);
65
- } catch (c) {
66
- throw l.warn(c.message), new Error(c.message);
72
+ i = await S(r);
73
+ } catch (l) {
74
+ throw c.warn(l.message), new Error(l.message);
67
75
  }
68
- l.debug(">>> validatedLicense", i);
69
- const { avu: a, exp: o, dmt: w, dm: p, t: m } = i;
70
- if (!o)
76
+ c.debug(">>> validatedLicense", i);
77
+ const { avu: s, exp: a, dmt: w, dm: p, t: f } = i;
78
+ if (!a)
71
79
  throw new Error("License is missing expiration timestamp");
72
- if (o > Number.MAX_SAFE_INTEGER / 1e3)
80
+ if (a > Number.MAX_SAFE_INTEGER / 1e3)
73
81
  throw new Error("Invalid expiration timestamp: value too large");
74
- const g = new Date(o * 1e3), h = (/* @__PURE__ */ new Date()).getTime();
82
+ const g = new Date(a * 1e3), h = (/* @__PURE__ */ new Date()).getTime();
75
83
  if (g.getTime() < h)
76
- throw new Error(s.expired);
77
- if (!a)
84
+ throw new Error(o.expired);
85
+ if (!s)
78
86
  throw new Error("License is missing available until version timestamp");
79
- if (a > Number.MAX_SAFE_INTEGER / 1e3)
87
+ if (s > Number.MAX_SAFE_INTEGER / 1e3)
80
88
  throw new Error("Invalid available until version timestamp: value too large");
81
- const f = new Date(a * 1e3);
82
- if (l.debug("availableUntilTimestamp", f), f.getTime() < A.getTime())
83
- throw new Error(s.exceededVersion);
84
- if (m !== y.Custom && !x(w, p))
85
- 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);
86
94
  return {
87
95
  isValid: !0,
88
- type: m,
96
+ type: f,
89
97
  invalidatedMessage: void 0
90
98
  };
91
- }, [n]);
99
+ }, [r]);
92
100
  return b(() => {
93
- r().then(({ isValid: i, type: a, invalidatedMessage: o }) => {
101
+ n().then(({ isValid: i, type: s, invalidatedMessage: a }) => {
94
102
  e({
95
103
  isValid: i,
96
- type: a,
97
- invalidatedMessage: o,
104
+ type: s,
105
+ invalidatedMessage: a,
98
106
  validating: !1
99
107
  });
100
108
  }).catch((i) => {
@@ -102,9 +110,9 @@ const x = (n, t) => {
102
110
  ...u,
103
111
  isValid: !1,
104
112
  validating: !1
105
- }), l.warn(i.message);
113
+ }), c.warn(i.message);
106
114
  });
107
- }, [r]), t;
115
+ }, [n]), t;
108
116
  };
109
117
  export {
110
118
  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.7",
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": [