wao 0.36.3 → 0.36.4

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/bundler.js CHANGED
@@ -57,11 +57,15 @@ var bundler = function bundler() {
57
57
  _context2.t0 = _regeneratorRuntime().keys((_out$body$commitments = (_out$body = out.body) === null || _out$body === void 0 ? void 0 : _out$body.commitments) !== null && _out$body$commitments !== void 0 ? _out$body$commitments : {});
58
58
  case 7:
59
59
  if ((_context2.t1 = _context2.t0()).done) {
60
- _context2.next = 57;
60
+ _context2.next = 58;
61
61
  break;
62
62
  }
63
63
  k = _context2.t1.value;
64
64
  msg = (_out$body2 = out.body) === null || _out$body2 === void 0 ? void 0 : _out$body2.commitments[k];
65
+ if (!(msg["commitment-device"] === "ans104@1.0")) {
66
+ _context2.next = 56;
67
+ break;
68
+ }
65
69
  signer = {
66
70
  signatureType: 1,
67
71
  signatureLength: 512,
@@ -101,14 +105,14 @@ var bundler = function bundler() {
101
105
  tags: tags
102
106
  };
103
107
  if (type !== "Process") opt.target = out.process;
104
- _context2.next = 18;
108
+ _context2.next = 19;
105
109
  return (0, _arbundles.createData)(out.data || "", signer, opt);
106
- case 18:
110
+ case 19:
107
111
  di = _context2.sent;
108
- _context2.next = 21;
112
+ _context2.next = 22;
109
113
  return di.setSignature(msg.signature);
110
- case 21:
111
- _context2.next = 23;
114
+ case 22:
115
+ _context2.next = 24;
112
116
  return fetch("https://up.arweave.net:443/tx", {
113
117
  method: "POST",
114
118
  headers: {
@@ -116,40 +120,40 @@ var bundler = function bundler() {
116
120
  },
117
121
  body: di.binary
118
122
  });
119
- case 23:
123
+ case 24:
120
124
  _res = _context2.sent;
121
125
  console.log(_res === null || _res === void 0 ? void 0 : _res.status, di.tags);
122
126
  dis = [di];
123
127
  if (!(type === "Message")) {
124
- _context2.next = 55;
128
+ _context2.next = 56;
125
129
  break;
126
130
  }
127
131
  if (out["block-timestamp"]) {
128
- _context2.next = 41;
132
+ _context2.next = 42;
129
133
  break;
130
134
  }
131
- _context2.prev = 28;
135
+ _context2.prev = 29;
132
136
  if (!(Date.now() - last_checked > timeout)) {
133
- _context2.next = 36;
137
+ _context2.next = 37;
134
138
  break;
135
139
  }
136
- _context2.next = 32;
140
+ _context2.next = 33;
137
141
  return fetch("https://arweave.net/block/current").then(function (r) {
138
142
  return r.json();
139
143
  });
140
- case 32:
144
+ case 33:
141
145
  json = _context2.sent;
142
146
  height = json.height;
143
147
  timestamp = json.timestamp;
144
148
  last_checked = Date.now();
145
- case 36:
146
- _context2.next = 41;
149
+ case 37:
150
+ _context2.next = 42;
147
151
  break;
148
- case 38:
149
- _context2.prev = 38;
150
- _context2.t2 = _context2["catch"](28);
152
+ case 39:
153
+ _context2.prev = 39;
154
+ _context2.t2 = _context2["catch"](29);
151
155
  console.log(_context2.t2);
152
- case 41:
156
+ case 42:
153
157
  atags = {
154
158
  Process: out.process,
155
159
  Epoch: out.epoch,
@@ -171,17 +175,17 @@ var bundler = function bundler() {
171
175
  });
172
176
  }
173
177
  _signer = new _turboSdk.ArweaveSigner(jwk);
174
- _context2.next = 47;
178
+ _context2.next = 48;
175
179
  return (0, _arbundles.createData)("", _signer, {
176
180
  tags: _tags
177
181
  });
178
- case 47:
182
+ case 48:
179
183
  di2 = _context2.sent;
180
- _context2.next = 50;
184
+ _context2.next = 51;
181
185
  return di2.sign(_signer);
182
- case 50:
186
+ case 51:
183
187
  dis.push(di2);
184
- _context2.next = 53;
188
+ _context2.next = 54;
185
189
  return fetch("https://up.arweave.net:443/tx", {
186
190
  method: "POST",
187
191
  headers: {
@@ -189,24 +193,24 @@ var bundler = function bundler() {
189
193
  },
190
194
  body: di2.binary
191
195
  });
192
- case 53:
196
+ case 54:
193
197
  res2 = _context2.sent;
194
198
  console.log(res2 === null || res2 === void 0 ? void 0 : res2.status, di2.tags);
195
- case 55:
199
+ case 56:
196
200
  _context2.next = 7;
197
201
  break;
198
- case 57:
199
- _context2.next = 62;
202
+ case 58:
203
+ _context2.next = 63;
200
204
  break;
201
- case 59:
202
- _context2.prev = 59;
205
+ case 60:
206
+ _context2.prev = 60;
203
207
  _context2.t3 = _context2["catch"](4);
204
208
  console.log(_context2.t3);
205
- case 62:
209
+ case 63:
206
210
  case "end":
207
211
  return _context2.stop();
208
212
  }
209
- }, _callee2, null, [[4, 59], [28, 38]]);
213
+ }, _callee2, null, [[4, 60], [29, 39]]);
210
214
  }));
211
215
  return function (_x, _x2) {
212
216
  return _ref2.apply(this, arguments);
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
- const signer = {
35
- signatureType: 1,
36
- signatureLength: 512,
37
- ownerLength: 512,
38
- publicKey: msg.owner,
39
- sign: async () => {},
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 k in atags) tags.push({ name: k, value: atags[k] })
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
- const signer = new ArweaveSigner(jwk)
97
- const di2 = await createData("", signer, { tags })
98
- await di2.sign(signer)
99
- dis.push(di2)
100
- const res2 = await fetch("https://up.arweave.net:443/tx", {
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: di2.binary,
61
+ body: di.binary,
106
62
  })
107
- console.log(res2?.status, di2.tags)
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.36.3",
3
+ "version": "0.36.4",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"