@canvas-js/client
Advanced tools
Comparing version 0.10.10 to 0.11.0
@@ -6,5 +6,20 @@ import * as json from "@ipld/dag-json"; | ||
constructor(signer, host, topic) { | ||
this.signer = signer; | ||
this.host = host; | ||
this.topic = topic; | ||
Object.defineProperty(this, "signer", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: signer | ||
}); | ||
Object.defineProperty(this, "host", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: host | ||
}); | ||
Object.defineProperty(this, "topic", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: topic | ||
}); | ||
} | ||
@@ -18,3 +33,3 @@ async sendAction(name, args) { | ||
const query = Object.entries({ | ||
address: session.payload.did, | ||
did: session.payload.did, | ||
publicKey: session.signer.publicKey, | ||
@@ -25,10 +40,10 @@ minExpiration: timestamp, | ||
.join("&"); | ||
const res = await fetch(`${this.host}/sessions?${query}`); | ||
const res = await fetch(`${this.host}/api/sessions/count?${query}`); | ||
assert(res.status === StatusCodes.OK); | ||
const sessions = await res.json(); | ||
if (sessions.length === 0) { | ||
const result = await res.json(); | ||
if (result.count === 0) { | ||
session = null; | ||
} | ||
} | ||
const head = await fetch(`${this.host}/clock`).then((res) => res.json()); | ||
const head = await fetch(`${this.host}/api/clock`).then((res) => res.json()); | ||
if (session === null) { | ||
@@ -60,3 +75,3 @@ session = await this.signer.newSession(this.topic); | ||
const signature = await delegateSigner.sign(message); | ||
const res = await fetch(`${this.host}/messages`, { | ||
const res = await fetch(`${this.host}/api/messages`, { | ||
method: "POST", | ||
@@ -63,0 +78,0 @@ headers: { "content-type": "application/json" }, |
{ | ||
"name": "@canvas-js/client", | ||
"version": "0.10.10", | ||
"version": "0.11.0", | ||
"author": "Canvas Technologies, Inc. (https://canvas.xyz)", | ||
@@ -22,8 +22,8 @@ "type": "module", | ||
"dependencies": { | ||
"@canvas-js/interfaces": "0.10.10", | ||
"@canvas-js/utils": "0.10.10", | ||
"@canvas-js/interfaces": "0.11.0", | ||
"@canvas-js/utils": "0.11.0", | ||
"@ipld/dag-json": "^10.2.2", | ||
"@noble/hashes": "^1.4.0", | ||
"@noble/hashes": "^1.5.0", | ||
"http-status-codes": "^2.3.0" | ||
} | ||
} |
4146
92
+ Added@canvas-js/interfaces@0.11.0(transitive)
+ Added@canvas-js/utils@0.11.0(transitive)
- Removed@canvas-js/interfaces@0.10.10(transitive)
- Removed@canvas-js/utils@0.10.10(transitive)
Updated@canvas-js/interfaces@0.11.0
Updated@canvas-js/utils@0.11.0
Updated@noble/hashes@^1.5.0