WIP WIP WIP crypto
This commit is contained in:
parent
67da1e4922
commit
e5dc2242c4
7 changed files with 3497 additions and 12 deletions
3442
examples/publish-js/package-lock.json
generated
Normal file
3442
examples/publish-js/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
6
examples/publish-js/package.json
Normal file
6
examples/publish-js/package.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"browserify": "^17.0.0",
|
||||
"jose": "^4.8.3"
|
||||
}
|
||||
}
|
13
examples/publish-js/publish-encrypted.html
Normal file
13
examples/publish-js/publish-encrypted.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Publish to ntfy.sh</title>
|
||||
</head>
|
||||
<body>
|
||||
<input id="password" placeholder="Topic password"/>
|
||||
<button onclick="publish()">Publish encrypted message</button>
|
||||
</body>
|
||||
<script async src="https://unpkg.com/jose@4.8.3/dist/browser/jwe/compact/encrypt.js" type="module"></script>
|
||||
<script async src="publish-encrypted.js" type="module"></script>
|
||||
</html>
|
7
examples/publish-js/publish-encrypted.js
Normal file
7
examples/publish-js/publish-encrypted.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import * as jose from 'jose'
|
||||
|
||||
async function publish() {
|
||||
const jwe = await new jose.CompactEncrypt(new TextEncoder().encode('Secret message from JS!'))
|
||||
.setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
|
||||
.encrypt(publicKey)
|
||||
}
|
18
examples/publish-js/publish.html
Normal file
18
examples/publish-js/publish.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Publish to ntfy.sh</title>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="publish()">Publish</button>
|
||||
</body>
|
||||
<script>
|
||||
function publish() {
|
||||
fetch('https://ntfy.sh/mytopic', {
|
||||
method: 'POST', // PUT works too
|
||||
body: 'Backup successful 😀'
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue