wao 0.36.3 → 0.36.6
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/cjs/adaptor-base.js +17 -17
- package/cjs/ao.js +2 -2
- package/cjs/aoconnect-base.js +278 -195
- package/cjs/bar.js +16 -11
- package/cjs/bundler.js +36 -32
- package/cjs/hb.js +364 -337
- package/esm/adaptor-base.js +1 -3
- package/esm/ao.js +2 -2
- package/esm/aoconnect-base.js +31 -3
- package/esm/bar.js +4 -2
- package/esm/bundler.js +67 -65
- package/esm/hb.js +24 -13
- package/package.json +1 -1
package/esm/adaptor-base.js
CHANGED
|
@@ -7,9 +7,6 @@ import {
|
|
|
7
7
|
toGraphObj,
|
|
8
8
|
} from "./utils.js"
|
|
9
9
|
import { keys, map, isNil, reverse, omit } from "ramda"
|
|
10
|
-
//import { httpbis, createVerifier } from "http-message-signatures"
|
|
11
|
-
//import { createPublicKey } from "node:crypto"
|
|
12
|
-
//const { verifyMessage } = httpbis
|
|
13
10
|
|
|
14
11
|
class Adaptor {
|
|
15
12
|
constructor({
|
|
@@ -406,6 +403,7 @@ class Adaptor {
|
|
|
406
403
|
let type = null
|
|
407
404
|
let item = null
|
|
408
405
|
if (valid || true) item = new DataItem(body)
|
|
406
|
+
await item.setSignature(item.rawSignature)
|
|
409
407
|
const _tags = tags(item.tags)
|
|
410
408
|
let err = null
|
|
411
409
|
if (_tags.Type === "Process") {
|
package/esm/ao.js
CHANGED
|
@@ -331,8 +331,8 @@ class AO {
|
|
|
331
331
|
: "ao.TN.1",
|
|
332
332
|
Type: "Module",
|
|
333
333
|
"Module-Format": "wasm64-unknown-emscripten-draft_2024_02_15",
|
|
334
|
-
"Input-Encoding": "JSON-
|
|
335
|
-
"Output-Encoding": "JSON-
|
|
334
|
+
"Input-Encoding": "JSON-1",
|
|
335
|
+
"Output-Encoding": "JSON-1",
|
|
336
336
|
"Memory-Limit": "1-gb",
|
|
337
337
|
"Compute-Limit": "9000000000000",
|
|
338
338
|
Extension: "WeaveDrive",
|
package/esm/aoconnect-base.js
CHANGED
|
@@ -6,7 +6,7 @@ const pkg = WarpArBundles.default ?? WarpArBundles
|
|
|
6
6
|
const { DataItem } = pkg
|
|
7
7
|
import crypto from "crypto"
|
|
8
8
|
import base64url from "base64url"
|
|
9
|
-
import { wait } from "./utils.js"
|
|
9
|
+
import { toAddr, wait } from "./utils.js"
|
|
10
10
|
import AO from "./ao.js"
|
|
11
11
|
import { connect, createSigner } from "@permaweb/aoconnect"
|
|
12
12
|
|
|
@@ -334,7 +334,10 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
// check: is owner=mu.addr right?
|
|
337
|
-
const
|
|
337
|
+
const _owner = opt.message_item?.owner
|
|
338
|
+
? toAddr(opt.message_item.owner)
|
|
339
|
+
: mu.addr
|
|
340
|
+
const msg = await genMsg(opt.message, p, data, _tags, from, _owner)
|
|
338
341
|
const _env = await genEnv({
|
|
339
342
|
pid: p.id,
|
|
340
343
|
owner: p.owner,
|
|
@@ -429,6 +432,32 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
|
|
|
429
432
|
target: opt.process,
|
|
430
433
|
})*/
|
|
431
434
|
}
|
|
435
|
+
} else if (t.__SU__) {
|
|
436
|
+
const sch = t.__SU__
|
|
437
|
+
const tar = v.Target
|
|
438
|
+
/*const procs =
|
|
439
|
+
(await fetch(sch).then(r => r.json()))?.Processes ?? []*/
|
|
440
|
+
const ao = await new AO({ port: sch.split(":").pop() - 2 }).init(
|
|
441
|
+
mu.jwk
|
|
442
|
+
)
|
|
443
|
+
try {
|
|
444
|
+
let _tags = {
|
|
445
|
+
...t,
|
|
446
|
+
"From-Process": opt.process,
|
|
447
|
+
"Pushed-For": id,
|
|
448
|
+
}
|
|
449
|
+
const pr = (await mem.getTx(opt.process))?.tags ?? []
|
|
450
|
+
const module = tags(pr).Module
|
|
451
|
+
if (module) _tags["From-Module"] = module
|
|
452
|
+
const { mid } = await ao.msg({
|
|
453
|
+
act: _tags["Action"] ?? null,
|
|
454
|
+
pid: tar,
|
|
455
|
+
tags: _tags,
|
|
456
|
+
data: v.Data ?? "",
|
|
457
|
+
})
|
|
458
|
+
} catch (e) {
|
|
459
|
+
console.log(e)
|
|
460
|
+
}
|
|
432
461
|
} else if (t.__Scheduler__) {
|
|
433
462
|
const sch = t.__Scheduler__
|
|
434
463
|
const tar = v.Target
|
|
@@ -526,7 +555,6 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
|
|
|
526
555
|
owner = opt.owner ?? ""
|
|
527
556
|
item = opt.item
|
|
528
557
|
}
|
|
529
|
-
|
|
530
558
|
const p = await mem.get("env", opt.process)
|
|
531
559
|
if (!p) return null
|
|
532
560
|
if (!opt.item && opt.signer) {
|
package/esm/bar.js
CHANGED
|
@@ -58,8 +58,10 @@ class AR extends MAR {
|
|
|
58
58
|
async dataitem({ target = "", data = "1984", tags = {}, signer, item }) {
|
|
59
59
|
let di = item
|
|
60
60
|
if (!di) {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
if (!item?.signature) {
|
|
62
|
+
const _item = await signer({ data, tags: buildTags(tags), target })
|
|
63
|
+
di = new DataItem(_item.raw)
|
|
64
|
+
}
|
|
63
65
|
} else tags = t(di.tags)
|
|
64
66
|
const owner = await this.owner(di)
|
|
65
67
|
return { id: await di.id, owner, item: di, tags }
|
package/esm/bundler.js
CHANGED
|
@@ -31,80 +31,82 @@ const bundler = ({ port = 4001, jwk, timeout = 1000 * 60 } = {}) => {
|
|
|
31
31
|
const out = structured_to(httpsig_from(toMsg(req)))
|
|
32
32
|
for (const k in out.body?.commitments ?? {}) {
|
|
33
33
|
const msg = out.body?.commitments[k]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const tags = []
|
|
42
|
-
let type = null
|
|
43
|
-
if (msg["original-tags"]) {
|
|
44
|
-
for (const tagObj of Object.values(msg["original-tags"])) {
|
|
45
|
-
tags.push({ name: tagObj.name, value: tagObj.value })
|
|
46
|
-
if (tagObj.name === "Type") {
|
|
47
|
-
type = tagObj.value
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
let opt = { tags }
|
|
52
|
-
if (type !== "Process") opt.target = out.process
|
|
53
|
-
const di = await createData(out.data || "", signer, opt)
|
|
54
|
-
await di.setSignature(msg.signature)
|
|
55
|
-
const res = await fetch("https://up.arweave.net:443/tx", {
|
|
56
|
-
method: "POST",
|
|
57
|
-
headers: {
|
|
58
|
-
"Content-Type": "application/octet-stream",
|
|
59
|
-
},
|
|
60
|
-
body: di.binary,
|
|
61
|
-
})
|
|
62
|
-
console.log(res?.status, di.tags)
|
|
63
|
-
const dis = [di]
|
|
64
|
-
if (type === "Message") {
|
|
65
|
-
if (!out["block-timestamp"]) {
|
|
66
|
-
try {
|
|
67
|
-
if (Date.now() - last_checked > timeout) {
|
|
68
|
-
const json = await fetch(
|
|
69
|
-
"https://arweave.net/block/current"
|
|
70
|
-
).then(r => r.json())
|
|
71
|
-
height = json.height
|
|
72
|
-
timestamp = json.timestamp
|
|
73
|
-
last_checked = Date.now()
|
|
74
|
-
}
|
|
75
|
-
} catch (e) {
|
|
76
|
-
console.log(e)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const atags = {
|
|
80
|
-
Process: out.process,
|
|
81
|
-
Epoch: out.epoch,
|
|
82
|
-
Nonce: Number(++nonce).toString(),
|
|
83
|
-
"Hash-Chain": out["hash-chain"],
|
|
84
|
-
"Block-Height": Number(out["block-height"] ?? height).toString(),
|
|
85
|
-
Tmestamp: Number(out["block-timestamp"] ?? timestamp).toString(),
|
|
86
|
-
"Data-Protocol": "ao",
|
|
87
|
-
Slot: Number(out.slot).toString(),
|
|
88
|
-
Variant: "ao.WDB.1",
|
|
89
|
-
Type: "Assignment",
|
|
90
|
-
Message: di.id,
|
|
34
|
+
if (msg["commitment-device"] === "ans104@1.0") {
|
|
35
|
+
const signer = {
|
|
36
|
+
signatureType: 1,
|
|
37
|
+
signatureLength: 512,
|
|
38
|
+
ownerLength: 512,
|
|
39
|
+
publicKey: msg.owner,
|
|
40
|
+
sign: async () => {},
|
|
91
41
|
}
|
|
92
42
|
const tags = []
|
|
43
|
+
let type = null
|
|
93
44
|
if (msg["original-tags"]) {
|
|
94
|
-
for (const
|
|
45
|
+
for (const tagObj of Object.values(msg["original-tags"])) {
|
|
46
|
+
tags.push({ name: tagObj.name, value: tagObj.value })
|
|
47
|
+
if (tagObj.name === "Type") {
|
|
48
|
+
type = tagObj.value
|
|
49
|
+
}
|
|
50
|
+
}
|
|
95
51
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
await
|
|
99
|
-
|
|
100
|
-
const
|
|
52
|
+
let opt = { tags }
|
|
53
|
+
if (type !== "Process") opt.target = out.process
|
|
54
|
+
const di = await createData(out.data || "", signer, opt)
|
|
55
|
+
await di.setSignature(msg.signature)
|
|
56
|
+
const res = await fetch("https://up.arweave.net:443/tx", {
|
|
101
57
|
method: "POST",
|
|
102
58
|
headers: {
|
|
103
59
|
"Content-Type": "application/octet-stream",
|
|
104
60
|
},
|
|
105
|
-
body:
|
|
61
|
+
body: di.binary,
|
|
106
62
|
})
|
|
107
|
-
console.log(
|
|
63
|
+
console.log(res?.status, di.tags)
|
|
64
|
+
const dis = [di]
|
|
65
|
+
if (type === "Message") {
|
|
66
|
+
if (!out["block-timestamp"]) {
|
|
67
|
+
try {
|
|
68
|
+
if (Date.now() - last_checked > timeout) {
|
|
69
|
+
const json = await fetch(
|
|
70
|
+
"https://arweave.net/block/current"
|
|
71
|
+
).then(r => r.json())
|
|
72
|
+
height = json.height
|
|
73
|
+
timestamp = json.timestamp
|
|
74
|
+
last_checked = Date.now()
|
|
75
|
+
}
|
|
76
|
+
} catch (e) {
|
|
77
|
+
console.log(e)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const atags = {
|
|
81
|
+
Process: out.process,
|
|
82
|
+
Epoch: out.epoch,
|
|
83
|
+
Nonce: Number(++nonce).toString(),
|
|
84
|
+
"Hash-Chain": out["hash-chain"],
|
|
85
|
+
"Block-Height": Number(out["block-height"] ?? height).toString(),
|
|
86
|
+
Tmestamp: Number(out["block-timestamp"] ?? timestamp).toString(),
|
|
87
|
+
"Data-Protocol": "ao",
|
|
88
|
+
Slot: Number(out.slot).toString(),
|
|
89
|
+
Variant: "ao.WDB.1",
|
|
90
|
+
Type: "Assignment",
|
|
91
|
+
Message: di.id,
|
|
92
|
+
}
|
|
93
|
+
const tags = []
|
|
94
|
+
if (msg["original-tags"]) {
|
|
95
|
+
for (const k in atags) tags.push({ name: k, value: atags[k] })
|
|
96
|
+
}
|
|
97
|
+
const signer = new ArweaveSigner(jwk)
|
|
98
|
+
const di2 = await createData("", signer, { tags })
|
|
99
|
+
await di2.sign(signer)
|
|
100
|
+
dis.push(di2)
|
|
101
|
+
const res2 = await fetch("https://up.arweave.net:443/tx", {
|
|
102
|
+
method: "POST",
|
|
103
|
+
headers: {
|
|
104
|
+
"Content-Type": "application/octet-stream",
|
|
105
|
+
},
|
|
106
|
+
body: di2.binary,
|
|
107
|
+
})
|
|
108
|
+
console.log(res2?.status, di2.tags)
|
|
109
|
+
}
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
} catch (e) {
|
package/esm/hb.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { createSigner } from "@permaweb/aoconnect"
|
|
2
|
-
import { httpsig_from, structured_to } from "hbsig"
|
|
3
2
|
import { isEmpty, last, isNotNil, mergeLeft, clone } from "ramda"
|
|
4
3
|
import { toAddr, buildTags, seed } from "./utils.js"
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
httpsig_from,
|
|
6
|
+
structured_to,
|
|
7
|
+
rsaid,
|
|
8
|
+
hmacid,
|
|
9
|
+
sign,
|
|
10
|
+
signer,
|
|
11
|
+
send as _send,
|
|
12
|
+
commit,
|
|
13
|
+
} from "hbsig"
|
|
6
14
|
import hyper_aos from "./hyper-aos.js"
|
|
7
15
|
import aos_wamr from "./aos_wamr.js"
|
|
8
16
|
import { from } from "./httpsig-utils.js"
|
|
@@ -160,27 +168,30 @@ class HB {
|
|
|
160
168
|
})
|
|
161
169
|
return { slot: res.out.slot, res, pid }
|
|
162
170
|
}
|
|
163
|
-
async
|
|
164
|
-
path = "/~process@1.0/schedule",
|
|
165
|
-
tags = {},
|
|
166
|
-
data = "1984",
|
|
167
|
-
target,
|
|
168
|
-
}) {
|
|
169
|
-
const _tags = buildTags(mergeLeft(tags, { signingFormat: "ANS-104" }))
|
|
170
|
-
const signer = new ArweaveSigner(this.jwk)
|
|
171
|
-
const di = createData(data, signer, { tags: _tags, target })
|
|
172
|
-
await di.sign(signer)
|
|
171
|
+
async send104({ path = "/~process@1.0/schedule", item }) {
|
|
173
172
|
let res = await fetch(`${this.url}${path}`, {
|
|
174
173
|
method: "POST",
|
|
175
174
|
headers: {
|
|
176
175
|
"codec-device": "ans104@1.0",
|
|
177
176
|
"Content-Type": "application/ans104",
|
|
178
177
|
},
|
|
179
|
-
body:
|
|
178
|
+
body: item.binary,
|
|
180
179
|
})
|
|
181
180
|
res.out = structured_to(httpsig_from(await toMsg(res)))
|
|
182
181
|
return res
|
|
183
182
|
}
|
|
183
|
+
async post104({
|
|
184
|
+
path = "/~process@1.0/schedule",
|
|
185
|
+
tags = {},
|
|
186
|
+
data = "1984",
|
|
187
|
+
target,
|
|
188
|
+
}) {
|
|
189
|
+
const _tags = buildTags(mergeLeft(tags, { signingFormat: "ANS-104" }))
|
|
190
|
+
const signer = new ArweaveSigner(this.jwk)
|
|
191
|
+
const item = createData(data, signer, { tags: _tags, target })
|
|
192
|
+
await item.sign(signer)
|
|
193
|
+
return await this.send104({ path, item })
|
|
194
|
+
}
|
|
184
195
|
|
|
185
196
|
async schedule({ pid, tags = {}, data } = {}) {
|
|
186
197
|
let res = null
|