wao 0.21.2 → 0.22.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/esm/test.js CHANGED
@@ -15,8 +15,10 @@ const blueprint = async pkg => {
15
15
  return readFileSync(resolve(await dirname(), `lua/${pkg}.lua`), "utf8")
16
16
  }
17
17
  const scheduler = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
18
+ const HyperBEAM = "./hyperbeam.js"
18
19
 
19
20
  export {
21
+ HyperBEAM,
20
22
  Adaptor,
21
23
  Testnet,
22
24
  Server,
package/esm/utils.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { graphql, parse, validate, buildSchema } from "graphql"
2
-
2
+ import sha256 from "fast-sha256"
3
3
  import {
4
4
  clone,
5
5
  is,
@@ -54,8 +54,10 @@ const tag = (name, value) => ({ name, value: jsonToStr(value) })
54
54
 
55
55
  const wait = ms => new Promise(res => setTimeout(() => res(), ms))
56
56
 
57
- const tags = tags => fromPairs(map(v => [v.name, v.value])(tags))
58
- const ltags = tags => fromPairs(map(v => [v.name.toLowerCase(), v.value])(tags))
57
+ const tags = (tags = []) => fromPairs(map(v => [v.name, v.value])(tags))
58
+
59
+ const ltags = (tags = []) =>
60
+ fromPairs(map(v => [v.name.toLowerCase(), v.value])(tags))
59
61
 
60
62
  const validAddress = addr => /^[a-zA-Z0-9_-]{43}$/.test(addr)
61
63
 
@@ -701,6 +703,31 @@ function parseSignatureInput(input) {
701
703
  return { label, fields, alg, keyid }
702
704
  }
703
705
 
706
+ function base64urlDecode(str) {
707
+ str = str.replace(/-/g, "+").replace(/_/g, "/")
708
+ const pad = str.length % 4
709
+ if (pad === 2) str += "=="
710
+ else if (pad === 3) str += "="
711
+ else if (pad !== 0) throw new Error("Invalid base64url string")
712
+ const bin = atob(str)
713
+ const bytes = new Uint8Array(bin.length)
714
+ for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i)
715
+ return bytes
716
+ }
717
+
718
+ function base64urlEncode(bytes) {
719
+ let bin = ""
720
+ for (const b of bytes) bin += String.fromCharCode(b)
721
+ let b64 = btoa(bin)
722
+ return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "")
723
+ }
724
+
725
+ function toAddr(n) {
726
+ const pubBytes = base64urlDecode(n)
727
+ const hash = sha256(pubBytes)
728
+ return base64urlEncode(hash)
729
+ }
730
+
704
731
  export {
705
732
  toANS104Request,
706
733
  parseSignatureInput,
@@ -732,4 +759,5 @@ export {
732
759
  udl,
733
760
  isJSON,
734
761
  dirname,
762
+ toAddr,
735
763
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.21.2",
3
+ "version": "0.22.0",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"
@@ -31,7 +31,7 @@
31
31
  "@bokuweb/zstd-wasm": "^0.0.22",
32
32
  "@dha-team/arbundles": "^1.0.1",
33
33
  "@permaweb/ao-loader": "^0.0.44",
34
- "@permaweb/aoconnect": "^0.0.84",
34
+ "@permaweb/aoconnect": "^0.0.85",
35
35
  "@permaweb/aoconnect-69": "npm:@permaweb/aoconnect@0.0.69",
36
36
  "arbundles": "^0.11.1",
37
37
  "arjson": "^0.0.2",
@@ -42,6 +42,7 @@
42
42
  "chokidar": "^4.0.3",
43
43
  "cors": "^2.8.5",
44
44
  "express": "^5.1.0",
45
+ "fast-sha256": "^1.3.0",
45
46
  "graphql": "^16.10.0",
46
47
  "http-message-signatures": "^1.0.4",
47
48
  "lmdb": "^3.2.2",