-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
223 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,4 +116,8 @@ dist | |
.pnp.* | ||
|
||
.DS_Store | ||
*.html | ||
|
||
# example | ||
bun.lockb | ||
deno.lock | ||
example/runtime/pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
# eciesjs-example | ||
# example | ||
|
||
Run `pnpm install` first | ||
Make sure `pnpm build` under the parent directory is run before. | ||
|
||
## Basic usage | ||
## Browser example | ||
|
||
Run `node index.js` | ||
Run `cd browser && pnpm install && pnpm dev` | ||
|
||
## Check import | ||
For production, run `pnpm build && pnpm preview` | ||
|
||
Run `node import.js` | ||
## Runtime example (Node/Bun/Deno) | ||
|
||
## Browser | ||
Run `cd runtime && bun install` | ||
|
||
Run `pnpm dev` | ||
### Basic usage | ||
|
||
Run `node main.js` or `bun run main.js` or `deno run --allow-read main.js` | ||
|
||
### Check import | ||
|
||
Run `node import.js` or `bun run import.js` or `deno run --allow-read import.js` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defineConfig } from "vite"; | ||
|
||
export default defineConfig({ | ||
build: { | ||
rollupOptions: { | ||
output: { | ||
manualChunks(id) { | ||
if (id.includes("@noble")) { | ||
return "noble"; | ||
} else if (id.includes("buffer")) { | ||
return "buffer"; | ||
} | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ECIES_CONFIG, PrivateKey, decrypt, encrypt } from "eciesjs"; | ||
import { Buffer } from "node:buffer"; | ||
|
||
globalThis.Buffer = Buffer; | ||
|
||
// because deno does not support indirect conditional exports | ||
// it falls to node:crypto's implementation | ||
// despite that @ecies/ciphers exports @noble/ciphers implementation to deno | ||
// see: https://github.com/denoland/deno/discussions/17964#discussioncomment-10917259 | ||
// deno's node:crypto does not support 16 bytes iv | ||
// so aes-256-gcm (16 bytes iv) does not work | ||
ECIES_CONFIG.symmetricNonceLength = 12; | ||
// ECIES_CONFIG.symmetricAlgorithm = "xchacha20"; | ||
|
||
const sk = new PrivateKey(); | ||
const data = Buffer.from("hello world🌍"); | ||
const decrypted = decrypt(sk.secret, encrypt(sk.publicKey.toHex(), data)); | ||
console.log(Buffer.from(decrypted).toString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "runtime-example", | ||
"version": "0.1.0", | ||
"description": "", | ||
"main": "main.js", | ||
"type": "module", | ||
"scripts": {}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"eciesjs": "file:../.." | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.