-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
43a011b
commit 55c8780
Showing
7 changed files
with
3,974 additions
and
6,979 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
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>") |
Oops, something went wrong.