Skip to content

Commit

Permalink
Merge branch 'main' into drop-mui
Browse files Browse the repository at this point in the history
  • Loading branch information
forgetso committed Dec 12, 2023
2 parents fde9443 + eabebd0 commit 0a0627d
Show file tree
Hide file tree
Showing 60 changed files with 1,173 additions and 4,178 deletions.
54 changes: 45 additions & 9 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:yaml/recommended',
'plugin:json/recommended',
'plugin:toml/standard',
Expand All @@ -21,22 +22,22 @@ module.exports = {
'@typescript-eslint',
'workspaces',
'unused-imports',
'@html-eslint',
'sort-imports-es6-autofix',
// do not add prettier to plugins otherwise rule conflicts will occur between prettier and eslint! run prettier as a separate command
],
root: true,
rules: {
'@typescript-eslint/no-unused-vars': 'warn', // allow unused vars
'@typescript-eslint/no-explicit-any': 'warn', // allow any type
'@typescript-eslint/prefer-for-of': 'warn', // allow indexed loops
'@typescript-eslint/consistent-type-assertions': 'off', // needs tsconfig to be set up
'@typescript-eslint/consistent-indexed-object-style': 'off', // allow indexed objects instead of Record<A, B>
'@typescript-eslint/array-type': 'off', // allow Array<A> or A[]
'@typescript-eslint/consistent-type-definitions': 'off', // allow type Foo = { a: string } or interface Foo { a: string }
'no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
{
vars: 'all',
varsIgnorePattern: '^_',
args: 'after-used',
argsIgnorePattern: '^_',
},
],
'unused-imports/no-unused-vars': 'off',
//"indent": ["error", 4],
//"indent": "off",
'sort-imports': [
Expand All @@ -56,4 +57,39 @@ module.exports = {
],
'json/*': ['error', { allowComments: true }],
},
overrides: [
{
files: ['*.html'],
parser: '@html-eslint/parser',
extends: ['plugin:@html-eslint/recommended'],
rules: {
'@html-eslint/no-extra-spacing-attrs': 'off',
'@html-eslint/require-closing-tags': 'off',
},
},
{
files: [
'*.ts',
'*.tsx',
'*.js',
'*.jsx',
'*.mjs',
'*.cjs',
'*.json',
'*.yaml',
'*.yml',
'*.toml',
'*.d.ts',
'*.cts',
'*.mts',
'.*.json',
'.*.js',
'.*.mjs',
'.*.cjs',
'.*.yaml',
'.*.yml',
'.*.toml',
],
},
],
}
28 changes: 28 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,32 @@ export default {
semi: false,
singleQuote: true,
printWidth: 120,
overrides: [
{
files: [
'*.md',
'*.html',
'*.ts',
'*.tsx',
'*.js',
'*.jsx',
'*.mjs',
'*.cjs',
'*.json',
'*.yaml',
'*.yml',
'*.toml',
'*.d.ts',
'*.cts',
'*.mts',
'.*.json',
'.*.js',
'.*.mjs',
'.*.cjs',
'.*.yaml',
'.*.yml',
'.*.toml',
],
},
],
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"files.autoSave": "onFocusChange",
"vs-code-prettier-eslint.prettierLast": "false",
"vs-code-prettier-eslint.prettierLast": "true",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true
Expand Down
52 changes: 23 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ via HTTPS and can
be placed anywhere on the page. Inside the <head> tag or immediately after the `.procaptcha` container are both fine.

```html

<script src="https://js.prosopo.io/js/procaptcha.bundle.js" async defer></script>
```

Expand All @@ -31,10 +30,9 @@ typically a `<div>` (but can be any element) and must have class `procaptcha` an
public
site key.

```html

```html
<body>
<div class="procaptcha" data-sitekey="your_site_key"></div>
<div class="procaptcha" data-sitekey="your_site_key"></div>
</body>
```

Expand All @@ -44,28 +42,27 @@ verification.
You can retrieve it server side with POST parameter `procaptcha-response`.

Here's a full example where Procaptcha is being used to protect a signup form from automated abuse. When the form is
submitted, the `procaptcha-response` JSON data will be included with the email and password POST data after the captcha
submitted, the `procaptcha-response` JSON data will be included with the email and password POST data after the captcha
is
solved.

#### Example of implicit rendering

```html

<html>
<head>
<title>Procaptcha Demo</title>
<script src="https://js.prosopo.io/js/procaptcha.bundle.js" async defer></script>
</head>
<body>
<form action="" method="POST">
<input type="text" name="email" placeholder="Email"/>
<input type="password" name="password" placeholder="Password"/>
<div class="procaptcha" data-sitekey="your_site_key"></div>
<br/>
<input type="submit" value="Submit"/>
</form>
</body>
<head>
<title>Procaptcha Demo</title>
<script src="https://js.prosopo.io/js/procaptcha.bundle.js" async defer></script>
</head>
<body>
<form action="" method="POST">
<input type="text" name="email" placeholder="Email" />
<input type="password" name="password" placeholder="Password" />
<div class="procaptcha" data-sitekey="your_site_key"></div>
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
```

Expand All @@ -80,14 +77,13 @@ The script is loaded in the head of the document and given the id `procaptcha-sc
id `procaptcha-container` where the widget will be rendered.

```html

<html>
<head>
<script id="procaptcha-script" src="https://js.prosopo.io/js/procaptcha.bundle.js" async defer></script>
</head>
<body>
<div id="procaptcha-container"></div>
</body>
<head>
<script id="procaptcha-script" src="https://js.prosopo.io/js/procaptcha.bundle.js" async defer></script>
</head>
<body>
<div id="procaptcha-container"></div>
</body>
</html>
```

Expand All @@ -96,7 +92,6 @@ An `onload` event is added to the script tag to call the render function when th
```javascript
// A function that will call the render Procaptcha function when the procaptcha script has loaded
document.getElementById('procaptcha-script').addEventListener('load', function () {

// Define a callback function to be called when the CAPTCHA is verified
window.onCaptchaVerified = function (output) {
console.log('Captcha verified, output: ' + JSON.stringify(output))
Expand All @@ -117,7 +112,7 @@ The output from the `onCaptchaVerified` function is the `procaptcha-response` JS
data contains the following fields:

| Key | Type | Description |
|--------------|--------|-------------------------------------------------------------------------------------------------------------------------------|
| ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------------- |
| commitmentId | string | The commitment ID of the captcha challenge. This is used to verify the user's response on-chain. |
| providerUrl | string | The URL of the provider that the user used to solve the captcha challenge. |
| dapp | string | The SITE_KEY of your application / website |
Expand All @@ -142,4 +137,3 @@ if (await prosopoServer.isVerified(payload[ApiParams.procaptchaResponse])) {

There is an example server side implementation
in [demos/client-example-server](https://github.com/prosopo/captcha/tree/main/demos/client-example-server).

8 changes: 6 additions & 2 deletions contracts/captcha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@
"clean": "tsc --build --clean",
"build": "tsc --build --verbose",
"build:cjs": "npx vite --config vite.cjs.config.ts build",
"lint": "npx eslint .",
"lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
"eslint": "npx eslint . --no-error-on-unmatched-pattern",
"eslint:fix": "npm run eslint -- --fix",
"prettier": "npx prettier . --check --no-error-on-unmatched-pattern",
"prettier:fix": "npm run prettier -- --write",
"lint": "npm run eslint && npm run prettier",
"lint:fix": "npm run eslint:fix && npm run prettier:fix"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion contracts/captcha/src/captcha.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source": {
"hash": "0x14647df58e0d35fa467371fb8d655151e814528246dc79649ced4cb3a49fdf83",
"hash": "0xc3e9367adefe6f9a6eade416c5cdf92aec41e19b7f0a0e341a8a07a1ae51e2af",
"language": "ink! 4.3.0",
"compiler": "rustc 1.69.0",
"build_info": {
Expand Down
4 changes: 2 additions & 2 deletions contracts/captcha/src/contract-info/captcha.ts

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions contracts/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
"scripts": {
"clean": "tsc --build --clean",
"build": "tsc --build --verbose",
"lint": "npx eslint .",
"lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
"eslint": "npx eslint . --no-error-on-unmatched-pattern",
"eslint:fix": "npm run eslint -- --fix",
"prettier": "npx prettier . --check --no-error-on-unmatched-pattern",
"prettier:fix": "npm run prettier -- --write",
"lint": "npm run eslint && npm run prettier",
"lint:fix": "npm run eslint:fix && npm run prettier:fix"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion contracts/common/src/common.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source": {
"hash": "0xa7a3f05a5bc911ab3649c713e14e5bab0424b9daa8ff557ebafb41274bdb6148",
"hash": "0x5ca7b28762b19db333dfea1e595b6b66a62e4f6391397eadbaf030de190b3248",
"language": "ink! 4.3.0",
"compiler": "rustc 1.69.0",
"build_info": {
Expand Down
4 changes: 2 additions & 2 deletions contracts/common/src/contract-info/common.ts

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions contracts/proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
"scripts": {
"clean": "tsc --build --clean",
"build": "tsc --build --verbose",
"lint": "npx eslint .",
"lint:fix": "npx eslint . --fix --config ../../.eslintrc.js"
"eslint": "npx eslint . --no-error-on-unmatched-pattern",
"eslint:fix": "npm run eslint -- --fix",
"prettier": "npx prettier . --check --no-error-on-unmatched-pattern",
"prettier:fix": "npm run prettier -- --write",
"lint": "npm run eslint && npm run prettier",
"lint:fix": "npm run eslint:fix && npm run prettier:fix"
},
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions contracts/proxy/src/contract-info/proxy.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/proxy/src/proxy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"source": {
"hash": "0x79d9d3275367b58a1d70d7085bf2aef7df9b10c74be7efed539d04f4f4fc54ee",
"hash": "0x6c943259434253b483113cea84f109257b388fcd8f572bd959abf53d8848a7d6",
"language": "ink! 4.3.0",
"compiler": "rustc 1.69.0",
"build_info": {
Expand Down
2 changes: 1 addition & 1 deletion demos/client-bundle-example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting Started with the Client Bundle Example

This project is a *minimal* example demonstrating how to include the Prosopo Procaptcha bundle in a client app.
This project is a _minimal_ example demonstrating how to include the Prosopo Procaptcha bundle in a client app.

## How to run locally

Expand Down
8 changes: 7 additions & 1 deletion demos/client-bundle-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
},
"scripts": {
"start": "light-server -s ./src -p 9232 -w \"**/*.html,**/*.css,**/*.js,**/*.gz\"",
"clean": "echo 'nothing to clean'"
"clean": "echo 'nothing to clean'",
"eslint": "npx eslint . --no-error-on-unmatched-pattern",
"eslint:fix": "npm run eslint -- --fix",
"prettier": "npx prettier . --check --no-error-on-unmatched-pattern",
"prettier:fix": "npm run prettier -- --write",
"lint": "npm run eslint && npm run prettier",
"lint:fix": "npm run eslint:fix && npm run prettier:fix"
},
"dependencies": {
"dotenv": "^16.0.1",
Expand Down
Loading

0 comments on commit 0a0627d

Please sign in to comment.