@prosopo/procaptcha-bundle 0.1.16 → 0.1.18

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.
package/package.json CHANGED
@@ -1,28 +1,34 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha-bundle",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
7
+ "type": "module",
7
8
  "types": "./dist/index.d.ts",
8
- "source": "./src/index.ts",
9
+ "source": "./src/index.tsx",
9
10
  "scripts": {
10
11
  "clean": "tsc --build --clean",
11
12
  "build": "tsc --build --verbose",
12
- "start": "webpack serve --mode development",
13
- "build:webpack:prod": "webpack --mode production",
14
- "build:webpack:prod:copy": "webpack --mode production && cp dist/procaptcha_bundle.main.bundle.js ../../demos/client-bundle-example/src",
15
- "build:webpack:dev": "webpack --mode development",
16
- "build:webpack:dev:copy": "webpack --mode development && cp dist/procaptcha_bundle.main.bundle.js ../../demos/client-bundle-example/src",
13
+ "start": "vite serve --mode development --host",
14
+ "build:dev": "npm run build && vite build --mode development --debug",
15
+ "build:prod": "npm run build && vite build --mode production",
17
16
  "lint": "npx eslint .",
18
- "lint:fix": "npx eslint . --fix"
17
+ "lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
19
18
  },
20
19
  "browserslist": [
21
20
  "> 0.5%, last 2 versions, not dead"
22
21
  ],
23
22
  "dependencies": {
24
- "@prosopo/common": "^0.1.16",
25
- "@prosopo/procaptcha-react": "^0.1.16"
23
+ "@emotion/react": "^11.11.1",
24
+ "@emotion/styled": "^11.11.0",
25
+ "@mui/icons-material": "^5.14.3",
26
+ "@mui/material": "^5.14.5",
27
+ "@prosopo/common": "^0.1.18",
28
+ "@prosopo/procaptcha": "^0.1.18",
29
+ "@prosopo/procaptcha-react": "^0.1.18",
30
+ "@prosopo/types": "^0.1.18",
31
+ "@prosopo/util": "^0.1.18"
26
32
  },
27
33
  "repository": {
28
34
  "type": "git",
@@ -37,41 +43,12 @@
37
43
  "registry": "https://registry.npmjs.org"
38
44
  },
39
45
  "devDependencies": {
40
- "@babel/core": "^7.21.5",
41
- "@babel/plugin-proposal-class-properties": "^7.18.6",
42
- "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
43
- "@babel/preset-env": "^7.21.5",
44
- "@babel/preset-react": "^7.18.6",
45
- "@babel/preset-typescript": "^7.21.5",
46
- "@rollup/plugin-babel": "^6.0.3",
47
- "@rollup/plugin-commonjs": "^24.1.0",
48
- "@rollup/plugin-node-resolve": "^15.0.2",
49
- "@types/react": "^18.2.7",
50
- "@types/react-dom": "^18.2.4",
51
- "@typescript-eslint/eslint-plugin": "^5.59.5",
52
- "@typescript-eslint/parser": "^5.30.7",
53
- "babel-loader": "^9.1.2",
54
- "babel-plugin-lodash": "^3.3.4",
55
- "compression-webpack-plugin": "^10.0.0",
56
- "css-loader": "^6.7.3",
57
- "dotenv-webpack": "^8.0.1",
58
- "eslint": "^8.40.0",
59
- "eslint-config-prettier": "^8.5.0",
60
- "eslint-plugin-prettier": "^4.2.1",
61
- "eslint-plugin-unused-imports": "^2.0.0",
62
- "eslint-webpack-plugin": "^4.0.1",
63
- "html-webpack-plugin": "^5.5.1",
64
- "mini-css-extract-plugin": "^2.7.5",
65
- "parcel": "^2.8.3",
66
- "react": "^18.2.0",
67
- "react-dom": "^18.2.0",
68
- "style-loader": "^3.3.2",
69
- "terser-webpack-plugin": "^5.3.7",
70
- "typescript": "^4.7.4",
71
- "webpack": "^5.82.0",
72
- "webpack-bundle-analyzer": "^4.8.0",
73
- "webpack-dev-server": "^4.13.3",
74
- "webpack-json-access-optimizer": "^1.1.0",
75
- "webpack-cli": "^5.1.1"
46
+ "@originjs/vite-plugin-commonjs": "^1.0.3",
47
+ "@prosopo/config": "^0.1.18",
48
+ "@rollup/plugin-typescript": "^11.1.2",
49
+ "@vitejs/plugin-react": "^4.0.4",
50
+ "tslib": "^2.6.2",
51
+ "typescript": "^5.1.6",
52
+ "webpack-merge": "^5.9.0"
76
53
  }
77
54
  }
package/vite.config.ts ADDED
@@ -0,0 +1,47 @@
1
+ import * as fs from 'fs'
2
+ import * as path from 'path'
3
+ import { ViteFrontendConfig } from '@prosopo/config'
4
+ import { defineConfig } from 'vite'
5
+ import { loadEnv } from '@prosopo/cli'
6
+ // load env using our util because vite loadEnv is not working for .env.development
7
+ loadEnv()
8
+
9
+ // Vite doesn't find the tsconfig for some reason
10
+ process.env.TS_NODE_PROJECT = path.resolve('./tsconfig.json')
11
+
12
+ // Package specific config
13
+ const copyTo = '../../demos/client-bundle-example/src'
14
+ const bundleName = 'procaptcha'
15
+ const packageName = '@prosopo/procaptcha-bundle'
16
+ const entry = './src/index.tsx'
17
+ const copyOptions = copyTo
18
+ ? {
19
+ srcDir: './dist/bundle',
20
+ destDir: copyTo,
21
+ bundleName: bundleName,
22
+ }
23
+ : undefined
24
+ const tsConfigPaths = [path.resolve('./tsconfig.json')]
25
+ const packagesDir = path.resolve('..')
26
+ // Get all folders in packagesDir
27
+ const packages = fs.readdirSync(packagesDir).filter((f) => fs.statSync(path.join(packagesDir, f)).isDirectory())
28
+ for (const packageName of packages) {
29
+ // Add the tsconfig for each package to tsConfigPaths
30
+ tsConfigPaths.push(path.resolve(`../${packageName}/tsconfig.json`))
31
+ }
32
+ // Merge with generic frontend config
33
+ export default defineConfig(async ({ command, mode }) => {
34
+ const frontendConfig = await ViteFrontendConfig(
35
+ packageName,
36
+ bundleName,
37
+ path.resolve(),
38
+ entry,
39
+ command,
40
+ mode,
41
+ copyOptions,
42
+ tsConfigPaths
43
+ )
44
+ return {
45
+ ...frontendConfig,
46
+ }
47
+ })
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare function render(): void;
2
- export default function ready(fn: any): void;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AA6CA,wBAAgB,MAAM,SA8BrB;AAGD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAAE,KAAA,QAS/B"}
package/dist/index.html DELETED
@@ -1 +0,0 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>React App</title><script defer="defer" src="procaptcha_bundle.main.bundle.js"></script></head><body><div id="root"></div></body></html>
Binary file
package/dist/index.js DELETED
@@ -1,86 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ApiParams, EnvironmentTypesSchema } from '@prosopo/types';
3
- import { LogLevel } from '@prosopo/common';
4
- import { Procaptcha } from '@prosopo/procaptcha-react';
5
- import { createRoot } from 'react-dom/client';
6
- function getConfig(siteKey) {
7
- if (!siteKey) {
8
- siteKey = process.env.DAPP_SITE_KEY || process.env.PROSOPO_SITE_KEY || '';
9
- }
10
- return {
11
- logLevel: LogLevel.Info,
12
- defaultEnvironment: process.env.DEFAULT_ENVIRONMENT || EnvironmentTypesSchema.enum.development,
13
- userAccountAddress: '',
14
- web2: true,
15
- dappName: 'Prosopo',
16
- account: {
17
- address: siteKey,
18
- },
19
- networks: {
20
- [EnvironmentTypesSchema.enum.development]: {
21
- endpoint: process.env.SUBSTRATE_NODE_URL || 'ws://127.0.0.1:9944',
22
- contract: {
23
- address: process.env.PROTOCOL_CONTRACT_ADDRESS || '',
24
- name: 'prosopo',
25
- },
26
- accounts: [],
27
- },
28
- },
29
- solutionThreshold: 80,
30
- };
31
- }
32
- function getParentForm(element) {
33
- let parent = element.parentElement;
34
- while (parent) {
35
- if (parent.tagName === 'FORM') {
36
- return parent;
37
- }
38
- parent = parent.parentElement;
39
- }
40
- return null;
41
- }
42
- export function render() {
43
- const elements = Array.from(document.getElementsByClassName('procaptcha'));
44
- const siteKey = elements[0].getAttribute('data-sitekey') || undefined;
45
- const config = getConfig(siteKey);
46
- console.log('Config', config);
47
- for (const element of elements) {
48
- const callbacks = {
49
- // add a listener to the onSubmit event of the parent form of element, appending the payload as
50
- // procaptcha-response
51
- onHuman: (payload) => {
52
- // get form
53
- const form = getParentForm(element);
54
- // add a listener to the onSubmit event of the form
55
- if (form) {
56
- form.addEventListener('submit', (event) => {
57
- event.preventDefault();
58
- // add the payload to the form
59
- const input = document.createElement('input');
60
- input.type = 'hidden';
61
- (input.name = ApiParams.procaptchaResponse), (input.value = JSON.stringify(payload));
62
- form.appendChild(input);
63
- // submit the form
64
- form.submit();
65
- });
66
- }
67
- },
68
- };
69
- const root = createRoot(element);
70
- root.render(_jsx(Procaptcha, { config: config, callbacks: callbacks })); //wrap in fn and give user access to func
71
- }
72
- }
73
- //https://stackoverflow.com/questions/41174095/do-i-need-to-use-onload-to-start-my-webpack-bundled-code
74
- export default function ready(fn) {
75
- if (document && document.readyState != 'loading') {
76
- console.log('document.readyState ready!');
77
- fn();
78
- }
79
- else {
80
- console.log('DOMContentLoaded listener!');
81
- // note sure if this is the correct event listener
82
- document.addEventListener('DOMContentLoaded', fn);
83
- }
84
- }
85
- ready(render);
86
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAoB,sBAAsB,EAAoB,MAAM,gBAAgB,CAAA;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,SAAS,SAAS,CAAC,OAAgB;IAC/B,IAAI,CAAC,OAAO,EAAE;QACV,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAA;KAC5E;IACD,OAAO;QACH,QAAQ,EAAE,QAAQ,CA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