formcrypt 0.2.0 → 0.3.0
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/README.md +1 -1
- package/formcrypt.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Encrypts the form fields you choose in the visitor's browser, each on its own, t
|
|
|
7
7
|
Create a key pair with `npx formdecrypt keygen`, then:
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
|
-
<script src="https://cdn.jsdelivr.net/npm/formcrypt@0.
|
|
10
|
+
<script src="https://cdn.jsdelivr.net/npm/formcrypt@0.3" defer></script>
|
|
11
11
|
|
|
12
12
|
<form name="contact" method="POST" data-netlify="true" data-formcrypt="fc1pk.…your public key…">
|
|
13
13
|
<input type="hidden" name="form-name" value="contact">
|
package/formcrypt.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/*! formcrypt 0.
|
|
1
|
+
/*! formcrypt 0.3.0 · MIT · Encrypts marked form fields in the browser, each on its own, before the form is sent. Format v1 (fc1-) */
|
|
2
2
|
(function () {
|
|
3
3
|
'use strict'
|
|
4
4
|
var subtle = globalThis.crypto && globalThis.crypto.subtle
|
|
5
5
|
var P256 = { name: 'ECDH', namedCurve: 'P-256' }
|
|
6
6
|
var enc = new TextEncoder()
|
|
7
7
|
|
|
8
|
-
function
|
|
8
|
+
function hex(u8) {
|
|
9
9
|
var s = ''
|
|
10
|
-
for (var i = 0; i < u8.length; i++) s +=
|
|
11
|
-
return
|
|
10
|
+
for (var i = 0; i < u8.length; i++) s += (u8[i] < 16 ? '0' : '') + u8[i].toString(16)
|
|
11
|
+
return s
|
|
12
12
|
}
|
|
13
13
|
function unb64(s) {
|
|
14
14
|
s = s.replace(/-/g, '+').replace(/_/g, '/')
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
out.set(ephRaw, 0)
|
|
33
33
|
out.set(iv, 65)
|
|
34
34
|
out.set(ct, 77)
|
|
35
|
-
return 'fc1
|
|
35
|
+
return 'fc1-' + hex(out)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
globalThis.formcrypt = { seal: seal }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "formcrypt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Encrypt chosen form fields in the browser, each under its own name, before the form is sent. Works with any form host. No config, no dependencies.",
|
|
5
5
|
"main": "formcrypt.js",
|
|
6
6
|
"files": [
|