@prosopo/procaptcha-bundle 2.6.12 → 3.0.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.
Files changed (117) hide show
  1. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.d.ts.map +1 -1
  2. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.js +3 -2
  3. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.js.map +1 -1
  4. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.d.ts.map +1 -1
  5. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.js +4 -0
  6. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.js.map +1 -1
  7. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentsList.d.ts +1 -1
  8. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentsList.d.ts.map +1 -1
  9. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.d.ts.map +1 -1
  10. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.js +1 -1
  11. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.js.map +1 -1
  12. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/configCreator.d.ts +1 -1
  13. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/configCreator.d.ts.map +1 -1
  14. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/configCreator.js +2 -2
  15. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/configCreator.js.map +1 -1
  16. package/CHANGELOG.md +141 -0
  17. package/dist/bundle/ProcaptchaWidget-BpzncYOb.js +612 -0
  18. package/dist/bundle/ProcaptchaWidget-D961oZ27.js +148 -0
  19. package/dist/bundle/bnChunk-DRlDxTFg.js +1137 -0
  20. package/dist/bundle/{browser-ponyfill-Bctlk3uB.js → browser-ponyfill-CvzSbL_o.js} +31 -30
  21. package/dist/bundle/builder-CQlqPNRd.js +37 -0
  22. package/dist/bundle/captchaComponentProvider-Dw6ydLe3.js +802 -0
  23. package/dist/bundle/{captchaRenderer-BAMErqQN.js → captchaRenderer-CY8KuZK-.js} +22 -22
  24. package/dist/bundle/commonChunk-24zMb_mF.js +189 -0
  25. package/dist/bundle/emotion-element-5486c51c.browser.esm-PRDDgd_k.js +918 -0
  26. package/dist/bundle/{fp.esm-DYWeNGcH.js → fp.esm-BADUiinQ.js} +548 -648
  27. package/dist/bundle/index-BRg_gWPo.js +1328 -0
  28. package/dist/bundle/{index-ByKGlSkE.js → index-BzOMq-ud.js} +2 -2
  29. package/dist/bundle/{index-1qH2dz7u.js → index-DqwVRCwA.js} +166 -199
  30. package/dist/bundle/index.d.ts.map +1 -1
  31. package/dist/bundle/locales/ar/translation.json +4 -3
  32. package/dist/bundle/locales/az/translation.json +4 -3
  33. package/dist/bundle/locales/cs/translation.json +4 -3
  34. package/dist/bundle/locales/de/translation.json +4 -3
  35. package/dist/bundle/locales/el/translation.json +4 -3
  36. package/dist/bundle/locales/en/translation.json +4 -3
  37. package/dist/bundle/locales/es/translation.json +4 -3
  38. package/dist/bundle/locales/fi/translation.json +4 -3
  39. package/dist/bundle/locales/fr/translation.json +4 -3
  40. package/dist/bundle/locales/hi/translation.json +4 -3
  41. package/dist/bundle/locales/hu/translation.json +4 -3
  42. package/dist/bundle/locales/id/translation.json +4 -3
  43. package/dist/bundle/locales/it/translation.json +4 -3
  44. package/dist/bundle/locales/ja/translation.json +4 -3
  45. package/dist/bundle/locales/jv/translation.json +4 -3
  46. package/dist/bundle/locales/ko/translation.json +4 -3
  47. package/dist/bundle/locales/ml/translation.json +4 -3
  48. package/dist/bundle/locales/ms/translation.json +4 -3
  49. package/dist/bundle/locales/nl/translation.json +4 -3
  50. package/dist/bundle/locales/no/translation.json +4 -3
  51. package/dist/bundle/locales/pl/translation.json +4 -3
  52. package/dist/bundle/locales/pt/translation.json +4 -3
  53. package/dist/bundle/locales/{pt-br → pt-BR}/translation.json +4 -3
  54. package/dist/bundle/locales/ro/translation.json +4 -3
  55. package/dist/bundle/locales/ru/translation.json +4 -3
  56. package/dist/bundle/locales/sr/translation.json +4 -3
  57. package/dist/bundle/locales/sv/translation.json +4 -3
  58. package/dist/bundle/locales/th/translation.json +4 -3
  59. package/dist/bundle/locales/tr/translation.json +4 -3
  60. package/dist/bundle/locales/uk/translation.json +4 -3
  61. package/dist/bundle/locales/vi/translation.json +4 -3
  62. package/dist/bundle/locales/{zh-cn → zh-CN}/translation.json +4 -3
  63. package/dist/bundle/nobleChunk-Xl5XLrx3.js +3635 -0
  64. package/dist/bundle/procaptcha.bundle.js +6 -5
  65. package/dist/bundle/util/captcha/captchaComponentProvider.d.ts.map +1 -1
  66. package/dist/bundle/util/captcha/captchaComponentsList.d.ts +1 -1
  67. package/dist/bundle/util/captcha/captchaComponentsList.d.ts.map +1 -1
  68. package/dist/bundle/util/captcha/captchaRenderer.d.ts.map +1 -1
  69. package/dist/bundle/util/configCreator.d.ts +1 -1
  70. package/dist/bundle/util/configCreator.d.ts.map +1 -1
  71. package/dist/bundle/utilChunk-sqstc6C5.js +317 -0
  72. package/dist/bundle/utilCryptoChunk-CIPUtfoO.js +1256 -0
  73. package/dist/bundle/web2Chunk-7Vd8yt2r.js +3711 -0
  74. package/dist/bundle/{hash-CrwduMDb.js → web3Chunk-DrUvbVNW.js} +257 -695
  75. package/dist/bundle/{translations-DEL070wJ.js → zodChunk-wTu9ZHzV.js} +46 -82
  76. package/dist/cjs/index.cjs +8 -2
  77. package/dist/cjs/util/captcha/captchaComponentProvider.cjs +4 -0
  78. package/dist/cjs/util/captcha/captchaRenderer.cjs +2 -1
  79. package/dist/cjs/util/configCreator.cjs +2 -2
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +3 -2
  82. package/dist/index.js.map +1 -1
  83. package/dist/util/captcha/captchaComponentProvider.d.ts +1 -1
  84. package/dist/util/captcha/captchaComponentProvider.d.ts.map +1 -1
  85. package/dist/util/captcha/captchaComponentProvider.js +4 -0
  86. package/dist/util/captcha/captchaComponentProvider.js.map +1 -1
  87. package/dist/util/captcha/captchaComponentsList.d.ts +1 -1
  88. package/dist/util/captcha/captchaComponentsList.d.ts.map +1 -1
  89. package/dist/util/captcha/captchaRenderer.d.ts.map +1 -1
  90. package/dist/util/captcha/captchaRenderer.js +1 -1
  91. package/dist/util/captcha/captchaRenderer.js.map +1 -1
  92. package/dist/util/configCreator.d.ts +1 -1
  93. package/dist/util/configCreator.d.ts.map +1 -1
  94. package/dist/util/configCreator.js +2 -2
  95. package/dist/util/configCreator.js.map +1 -1
  96. package/package.json +21 -14
  97. package/stats.html +1 -1
  98. package/vite.config.ts +47 -4
  99. package/vite.serve.config.ts +2 -0
  100. package/vite.test.config.ts +1 -1
  101. package/webpack.config.cjs +5 -0
  102. package/dist/bundle/ProcaptchaWidget-DPyDGPiI.js +0 -156
  103. package/dist/bundle/ProcaptchaWidget-DoqUlwHS.js +0 -636
  104. package/dist/bundle/_commonjsHelpers-DaMA6jEr.js +0 -8
  105. package/dist/bundle/asU8a-BixKX-w0.js +0 -9
  106. package/dist/bundle/bip39-D7YSihxf.js +0 -260
  107. package/dist/bundle/captchaComponentProvider-BL18T1UE.js +0 -1242
  108. package/dist/bundle/emotion-element-5486c51c.browser.esm-Bjt1gs1F.js +0 -1807
  109. package/dist/bundle/i18nFrontend-DCv3P9jv.js +0 -2273
  110. package/dist/bundle/index-BeN3et18.js +0 -4844
  111. package/dist/bundle/index-BjRdPnnE.js +0 -1198
  112. package/dist/bundle/index-CBquknc2.js +0 -81
  113. package/dist/bundle/index-QVME9Prx.js +0 -32
  114. package/dist/bundle/sha256-CGE_4eEY.js +0 -171
  115. package/dist/bundle/spread-DEmVz7RJ.js +0 -15
  116. package/dist/bundle/toU8a-CPMbkkSw.js +0 -109
  117. package/dist/bundle/useTranslation-BJsfZyOx.js +0 -158
package/vite.config.ts CHANGED
@@ -14,7 +14,6 @@
14
14
 
15
15
  import * as fs from "node:fs";
16
16
  import * as path from "node:path";
17
- import { getLoggerDefault } from "@prosopo/common";
18
17
  import {
19
18
  ViteFrontendConfig,
20
19
  VitePluginRemoveUnusedTranslations,
@@ -27,8 +26,6 @@ import { defineConfig } from "vite";
27
26
  // load env using our util because vite loadEnv is not working for .env.development
28
27
  loadEnv();
29
28
 
30
- const logger = getLoggerDefault();
31
-
32
29
  // Vite doesn't find the tsconfig for some reason
33
30
  process.env.TS_NODE_PROJECT = path.resolve("./tsconfig.json");
34
31
 
@@ -84,6 +81,52 @@ export default defineConfig(async ({ command, mode }) => {
84
81
 
85
82
  return {
86
83
  ...frontendConfig,
84
+ build: {
85
+ ...frontendConfig.build,
86
+ rollupOptions: {
87
+ ...frontendConfig.build?.rollupOptions,
88
+ output: {
89
+ ...frontendConfig.build?.rollupOptions?.output,
90
+ manualChunks(id: string) {
91
+ if (id.includes("wasm-crypto-wasm")) {
92
+ return "web3Chunk";
93
+ }
94
+ // Split up the extension code into 2 chunks
95
+ if (id.includes("packages/account/dist/extension")) {
96
+ if (id.includes("ExtensionWeb3.js")) {
97
+ return "web3Chunk";
98
+ }
99
+ return "web2Chunk";
100
+ }
101
+ if (id.includes("packages/common/dist")) {
102
+ return "commonChunk";
103
+ }
104
+ if (id.includes("zod")) {
105
+ return "zodChunk";
106
+ }
107
+ if (id.includes("@polkadot/extension-dapp")) {
108
+ return "web3Chunk";
109
+ }
110
+ if (id.includes("@polkadot/keyring")) {
111
+ return "web3Chunk";
112
+ }
113
+ if (id.includes("packages/util-crypto/dist")) {
114
+ return "utilCryptoChunk";
115
+ }
116
+ if (id.includes("@noble/hash") || id.includes("@noble/curves")) {
117
+ return "nobleChunk";
118
+ }
119
+ if (id.includes("@polkadot/util") && !id.includes("util-crypto")) {
120
+ return "utilChunk";
121
+ }
122
+ if (id.includes("bn.js")) {
123
+ return "bnChunk";
124
+ }
125
+ return undefined;
126
+ },
127
+ },
128
+ },
129
+ },
87
130
  plugins: [
88
131
  {
89
132
  name: "copy-dir",
@@ -93,7 +136,7 @@ export default defineConfig(async ({ command, mode }) => {
93
136
  if (!fs.existsSync(containingFolder)) {
94
137
  fs.mkdirSync(containingFolder, { recursive: true });
95
138
  }
96
- logger.info(`Copying ${copyDir.srcDir} to ${copyDir.destDir}`);
139
+ console.log(`Copying ${copyDir.srcDir} to ${copyDir.destDir}`);
97
140
  fs.cpSync(copyDir.srcDir, copyDir.destDir, {
98
141
  recursive: true,
99
142
  });
@@ -18,6 +18,8 @@ import { defineConfig } from "vite";
18
18
  export default defineConfig({
19
19
  server: {
20
20
  port: 9269,
21
+ host: true,
22
+ cors: true,
21
23
  },
22
24
  // Change the default public directory if needed
23
25
  publicDir: "dist/bundle", // assets in the "assets" folder at the project root will be served
@@ -31,4 +31,4 @@ if (fs.existsSync(envFile)) {
31
31
 
32
32
  dotenv.config({ path: envPath });
33
33
 
34
- export default ViteTestConfig;
34
+ export default ViteTestConfig();
@@ -45,6 +45,11 @@ const bundleWebpackConfig = {
45
45
  ),
46
46
  },
47
47
  },
48
+ externals: {
49
+ ...webpackConfig.externals,
50
+ "node:crypto": "commonjs crypto",
51
+ "node:util": "commonjs util",
52
+ },
48
53
  };
49
54
  console.log(bundleWebpackConfig);
50
55
  module.exports = bundleWebpackConfig;
@@ -1,156 +0,0 @@
1
- import { g as k, p as M, c as E, d as D, e as G, E as F, j as S, C as W } from "./captchaComponentProvider-BL18T1UE.js";
2
- import { l as j, P as K, r as p, M as I } from "./emotion-element-5486c51c.browser.esm-Bjt1gs1F.js";
3
- import { b as L, a as V, s as Y, u as X, c as q } from "./useTranslation-BJsfZyOx.js";
4
- import { s as z } from "./sha256-CGE_4eEY.js";
5
- import { A as c, l as B, b as J, d as Q } from "./index-1qH2dz7u.js";
6
- const Z = (s, e) => {
7
- let t = 0;
8
- const l = "0".repeat(e);
9
- for (; ; ) {
10
- const n = new TextEncoder().encode(t + s);
11
- if ($(z(n)).startsWith(l))
12
- return t;
13
- t += 1;
14
- }
15
- }, $ = (s) => Array.from(s).map((e) => e.toString(16).padStart(2, "0")).join(""), ee = (s, e, t, l, n) => {
16
- const u = k(l), T = () => ({
17
- showModal: !1,
18
- loading: !1,
19
- index: 0,
20
- challenge: void 0,
21
- solutions: void 0,
22
- isHuman: !1,
23
- captchaApi: void 0,
24
- account: void 0
25
- }), d = () => {
26
- window.clearTimeout(Number(e.timeout)), o({ timeout: void 0 });
27
- }, v = () => {
28
- o({
29
- isHuman: !1,
30
- loading: !1
31
- }), u.onFailed(), r(n == null ? void 0 : n.restart);
32
- }, f = () => {
33
- window.clearTimeout(Number(e.successfullChallengeTimeout)), o({ successfullChallengeTimeout: void 0 });
34
- }, g = () => {
35
- const a = {
36
- userAccountAddress: "",
37
- ...s
38
- };
39
- return e.account && (a.userAccountAddress = e.account.account.address), K.parse(a);
40
- }, h = () => {
41
- if (!e.account)
42
- throw new E("GENERAL.ACCOUNT_NOT_FOUND", {
43
- context: { error: "Account not loaded" }
44
- });
45
- return { account: e.account };
46
- }, m = () => {
47
- if (!e.dappAccount)
48
- throw new E("GENERAL.SITE_KEY_MISSING");
49
- return e.dappAccount;
50
- }, o = L(e, t), r = (a) => {
51
- d(), f(), o(T()), u.onReset(), a && a();
52
- }, A = () => {
53
- const a = g().captchas.pow.solutionTimeout, P = setTimeout(() => {
54
- o({ isHuman: !1 }), u.onExpired(), r(n == null ? void 0 : n.restart);
55
- }, a);
56
- o({ successfullChallengeTimeout: P });
57
- }, w = async () => {
58
- await M(async () => {
59
- var y;
60
- if (e.loading || e.isHuman)
61
- return;
62
- r(), o({
63
- loading: !0
64
- }), o({ attemptCount: e.attemptCount + 1 });
65
- const a = g(), R = await (async () => n ? n.userAccount : new (await F(a.web2))().getAccount(a))(), C = R.account.address;
66
- if (o({
67
- account: { account: { address: C } }
68
- }), o({ dappAccount: a.account.address }), await V(100), !a.web2 && !a.userAccountAddress)
69
- throw new E("GENERAL.ACCOUNT_NOT_FOUND", {
70
- context: {
71
- error: "Account address has not been set for web3 mode"
72
- }
73
- });
74
- let x;
75
- n != null && n.provider ? x = n.provider : x = await D(g());
76
- const _ = x.provider.url, H = new G(_, m()), i = await H.getPowCaptchaChallenge(C, m(), n == null ? void 0 : n.sessionId);
77
- if (i.error)
78
- o({
79
- loading: !1,
80
- error: {
81
- message: i.error.message,
82
- key: i.error.key || "API.UNKNOWN_ERROR"
83
- }
84
- });
85
- else {
86
- const N = Z(i.challenge, i.difficulty), b = (y = R.extension) == null ? void 0 : y.signer;
87
- if (!b || !b.signRaw)
88
- throw new E("GENERAL.CANT_FIND_KEYRINGPAIR", {
89
- context: {
90
- error: "Signer is not defined, cannot sign message to prove account ownership"
91
- }
92
- });
93
- const O = await b.signRaw({
94
- address: C,
95
- data: Y(i[c.timestamp].toString()),
96
- type: "bytes"
97
- });
98
- (await H.submitPowCaptchaSolution(i, h().account.account.address, m(), N, O.signature.toString(), a.captchas.pow.verifiedTimeout))[c.verified] ? (o({
99
- isHuman: !0,
100
- loading: !1
101
- }), u.onHuman(j({
102
- [c.providerUrl]: _,
103
- [c.user]: h().account.account.address,
104
- [c.dapp]: m(),
105
- [c.challenge]: i.challenge,
106
- [c.nonce]: N,
107
- [c.timestamp]: i.timestamp,
108
- [c.signature]: {
109
- [c.provider]: i.signature.provider,
110
- [c.user]: {
111
- [c.timestamp]: O.signature.toString()
112
- }
113
- }
114
- })), A()) : v();
115
- }
116
- }, w, () => {
117
- r();
118
- }, e.attemptCount, 3);
119
- };
120
- return {
121
- start: w,
122
- resetState: r
123
- };
124
- }, U = "procaptcha:execute", se = (s) => {
125
- var o;
126
- const { t: e } = X(), t = s.config, l = s.i18n, n = t.theme === "light" ? J : Q, u = s.frictionlessState, T = s.callbacks || {}, [d, v] = q(p.useState, p.useRef), [f, g] = p.useState(!1), h = L(d, v), m = p.useRef(ee(t, d, h, T, u));
127
- return p.useEffect(() => {
128
- t.language && (l ? l.language !== t.language && l.changeLanguage(t.language).then((r) => r) : B().then((r) => {
129
- r.language !== t.language && r.changeLanguage(t.language).then((A) => A);
130
- }));
131
- }, [l, t.language]), p.useEffect(() => {
132
- d.error && (g(!1), d.error.key === "CAPTCHA.NO_SESSION_FOUND" && u && setTimeout(() => {
133
- u.restart();
134
- }, 3e3));
135
- }, [d.error, u]), p.useEffect(() => {
136
- if (t.mode === I.invisible) {
137
- const r = (A) => {
138
- try {
139
- m.current.start();
140
- } catch (w) {
141
- console.error("Error starting PoW verification:", w);
142
- }
143
- };
144
- return document.addEventListener(U, r), () => {
145
- document.removeEventListener(U, r);
146
- };
147
- }
148
- return () => {
149
- };
150
- }, [t.mode]), t.mode === I.invisible ? null : S(W, { checked: d.isHuman, onChange: async () => {
151
- f || (g(!0), await m.current.start(), g(!1));
152
- }, theme: n, labelText: e("WIDGET.I_AM_HUMAN"), error: (o = d.error) == null ? void 0 : o.message, "aria-label": "human checkbox", loading: f });
153
- };
154
- export {
155
- se as default
156
- };