Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncolburne committed Nov 12, 2023
1 parent 43a011b commit 55c8780
Show file tree
Hide file tree
Showing 7 changed files with 3,974 additions and 6,979 deletions.
8 changes: 7 additions & 1 deletion wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ path = '..'
package = "cesride"

[dependencies]
wasm-bindgen = "0.2.84"
wasm-bindgen = "0.2.88"
js-sys = '0.3'
serde_json = "1.0"

[dev-dependencies]
wasm-bindgen-test = "0.3.38"

[profile.release]
opt_level = "s"
80 changes: 57 additions & 23 deletions wasm/demo/web/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,61 @@
// Note that a dynamic `import` statement here is required due to
// webpack/webpack#6615, but in theory `import { greet } from './pkg';`
// will work here one day as well!
const wasm = import('cesride-wasm');
import * as cesride from 'cesride-wasm';

wasm
.then(cesride => {
date = cesride.Dater.new_with_dts(dts = "2020-08-22T17:50:09.988921+00:00");
document.write("<p>Date:</p>");
document.write("dts: " + date.dts() + "<br/>");
document.write("dtsb: " + date.dtsb() + "<br/>");
document.write("code: " + date.code() + "<br/>");
document.write("size: " + date.size() + "<br/>");
document.write("raw: " + date.raw() + "<br/>");
document.write("qb64: " + date.qb64() + "<br/>");
document.write("qb64b: " + date.qb64b() + "<br/>");
document.write("qb2: " + date.qb2() + "<br/>");
try {
date = cesride.Dater.new_with_dts(dts = "asdf");
document.write("Wrong date: " + date.dts() + "<br/>");
} catch (error) {
document.write("Error: " + error + "<br/>");
document.write("Error name: " + error.name + "<br/>");
document.write("Error message: " + error.message + "<br/>");
}
})
.catch(console.error);
document.write(`
<style>
body {
background-color: black;
color: #cccccc;
}
</style>
`)

let dts = "2020-08-22T17:50:09.988921+00:00";
let dater = cesride.Dater.new_with_dts(dts);

const icp = {
"v": "KERI10JSON00015a_",
"t": "icp",
"d": "EBAjyPZ8Ed4XXl5cVZhqAy7SuaGivQp0WqQKVXvg7oqd",
"i": "BEy_EvE8OUMqj0AgCJ3wOCOrIVHVtwubYAysPyaAv9VI",
"s": "0",
"kt": "1",
"k": [
"BEy_EvE8OUMqj0AgCJ3wOCOrIVHVtwubYAysPyaAv9VI"
],
"nt": "0",
"n": [],
"bt": "2",
"b": [
"BC9Df6ssUZQFQZJYVUyfudw4WTQsugGcvVD_Z4ChFGE4",
"BEejlxZytU7gjUwtgkmNKmBWiFPKSsXjk_uxzoun8dtK"
],
"c": [],
"a": []
}

const raw = new TextEncoder().encode(JSON.stringify(icp))
const serder = cesride.Serder.new_with_raw(raw)
console.log(serder.saider().qb64())

document.write("<p>Date:</p>");
document.write("<code>")
document.write("dts: " + dater.dts() + "<br/>");
document.write("dtsb: " + dater.dtsb() + "<br/>");
document.write("code: " + dater.code() + "<br/>");
document.write("size: " + dater.size() + "<br/>");
document.write("raw: " + dater.raw() + "<br/>");
document.write("qb64: " + dater.qb64() + "<br/>");
document.write("qb64b: " + dater.qb64b() + "<br/>");
document.write("qb2: " + dater.qb2() + "<br/>");
try {
dater = cesride.Dater.new_with_dts(dts = "asdf");
document.write("Wrong dater: " + dater.dts() + "<br/>");
} catch (error) {
document.write("Error: " + error + "<br/>");
document.write("Error name: " + error.name + "<br/>");
document.write("Error message: " + error.message + "<br/>");
}
document.write("</code>")
Loading

0 comments on commit 55c8780

Please sign in to comment.