diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 899b28d4..cceeb3aa 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -24,12 +24,12 @@ jobs: uses: actions/checkout@v4 - name: Install nix - uses: cachix/install-nix-action@v27 + uses: cachix/install-nix-action@v30 with: - install_url: https://releases.nixos.org/nix/nix-2.22.0/install + install_url: https://releases.nixos.org/nix/nix-2.24.9/install - name: Set up cachix - uses: cachix/cachix-action@v14 + uses: cachix/cachix-action@v15 with: name: holochain-ci diff --git a/CHANGELOG.md b/CHANGELOG.md index a097dbd0..7af86c39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added ### Fixed ### Changed +- Zome call signing has been changed in Holochain to remove the requirement of imitating Holochain serialization. Signing is now a simplified process of serializing zome call parameters using MessagePack, then computing a SHA2 512-bit hash of the serialized bytes and signing the hash. The zome call payload consists of the serialized bytes and the signature. ### Removed ## 2024-11-12: v0.19.0-dev.2 diff --git a/Cargo.lock b/Cargo.lock index a87e4cfd..e721888f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -143,9 +143,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "shlex", ] @@ -470,9 +470,9 @@ checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "hdi" -version = "0.6.0-dev.2" +version = "0.6.0-dev.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53159bb4f411ea083642d2fb48ccf0648c761ee292212fceb9fa7a013d298e29" +checksum = "fd2b81d1ca8036deba19b4d55ece09def176eeb062a49391369ccb424223c917" dependencies = [ "getrandom", "hdk_derive", @@ -488,9 +488,9 @@ dependencies = [ [[package]] name = "hdk" -version = "0.5.0-dev.4" +version = "0.5.0-dev.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd8c893bb6777a3fff50a47604e9051ff05abc2eba83bbf6c227084d8f3f5603" +checksum = "9f2c97f85f43c82aa95488bed64f85aa2ac84cc209adf1bfc8f6e3a2f3a8110a" dependencies = [ "getrandom", "hdi", @@ -508,9 +508,9 @@ dependencies = [ [[package]] name = "hdk_derive" -version = "0.5.0-dev.2" +version = "0.5.0-dev.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee069cd3ba1ae4d0677832b43b8307ae022cfd57235509a634114425f42522f5" +checksum = "3477a3b1fa6e302d14144397a7cf669e7806e6b116e6f432411d232d8c3c243d" dependencies = [ "darling 0.14.4", "heck", @@ -536,9 +536,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "holo_hash" -version = "0.5.0-dev.2" +version = "0.5.0-dev.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52b1609ab3426ffbc6b96c0ae917d5281682f6bde22c1799fdc2d2f65d1c716d" +checksum = "e9ef5f1b831a64ab1e1d2a2d6c76b8140c59660cd9b6c745eaf0c4b0d03b9257" dependencies = [ "base64", "blake2b_simd", @@ -549,14 +549,15 @@ dependencies = [ "kitsune_p2p_dht_arc", "serde", "serde_bytes", + "sha2", "thiserror", ] [[package]] name = "holochain_integrity_types" -version = "0.5.0-dev.2" +version = "0.5.0-dev.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad6856a52474f4d99818b3492260e1a53e8d7a766584bce1e8dfd2a3475dfc3" +checksum = "8835be40ef1c0dffbfa111991611169a886506c48d45c91dce9523eae7639a14" dependencies = [ "holo_hash", "holochain_secure_primitive", @@ -658,9 +659,9 @@ dependencies = [ [[package]] name = "holochain_zome_types" -version = "0.5.0-dev.4" +version = "0.5.0-dev.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "992e6f17a7bf5248d9739a92a64f067f3c5a0c47b71bc197c6d637223846212e" +checksum = "0c9a6ecee3de89277f3711c4fa41d9627287b494a2e043b3dd43afd284b328bc" dependencies = [ "derive_more", "holo_hash", @@ -749,9 +750,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "js-sys" @@ -819,9 +820,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.162" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "lock_api" @@ -1063,9 +1064,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "indexmap", "itoa", @@ -1085,6 +1086,17 @@ dependencies = [ "digest", ] +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "shlex" version = "1.3.0" @@ -1285,9 +1297,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "valuable" diff --git a/docs/client.appcallzomerequest.md b/docs/client.appcallzomerequest.md index e34e930e..be64897d 100644 --- a/docs/client.appcallzomerequest.md +++ b/docs/client.appcallzomerequest.md @@ -8,7 +8,7 @@ **Signature:** ```typescript -export type AppCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequestSigned | RoleNameCallZomeRequestSigned; +export type AppCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequest; ``` -**References:** [NonProvenanceCallZomeRequest](./client.nonprovenancecallzomerequest.md), [RoleNameCallZomeRequest](./client.rolenamecallzomerequest.md), [CallZomeRequestSigned](./client.callzomerequestsigned.md), [RoleNameCallZomeRequestSigned](./client.rolenamecallzomerequestsigned.md) +**References:** [NonProvenanceCallZomeRequest](./client.nonprovenancecallzomerequest.md), [RoleNameCallZomeRequest](./client.rolenamecallzomerequest.md), [CallZomeRequest](./client.callzomerequest.md) diff --git a/docs/client.callzomerequest.md b/docs/client.callzomerequest.md index 2e5bdd79..1e8b8ddc 100644 --- a/docs/client.callzomerequest.md +++ b/docs/client.callzomerequest.md @@ -8,7 +8,7 @@ **Signature:** ```typescript -export type CallZomeRequest = CallZomeRequestGeneric; +export type CallZomeRequest = CallZomeRequestGeneric; ``` **References:** [CallZomeRequestGeneric](./client.callzomerequestgeneric.md) diff --git a/docs/client.callzomerequestunsigned.cap_secret.md b/docs/client.callzomerequestparams.cap_secret.md similarity index 53% rename from docs/client.callzomerequestunsigned.cap_secret.md rename to docs/client.callzomerequestparams.cap_secret.md index 63e8a67d..8bc8b6e0 100644 --- a/docs/client.callzomerequestunsigned.cap_secret.md +++ b/docs/client.callzomerequestparams.cap_secret.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestUnsigned](./client.callzomerequestunsigned.md) > [cap\_secret](./client.callzomerequestunsigned.cap_secret.md) +[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestParams](./client.callzomerequestparams.md) > [cap\_secret](./client.callzomerequestparams.cap_secret.md) -## CallZomeRequestUnsigned.cap\_secret property +## CallZomeRequestParams.cap\_secret property **Signature:** diff --git a/docs/client.callzomerequestunsigned.expires_at.md b/docs/client.callzomerequestparams.expires_at.md similarity index 51% rename from docs/client.callzomerequestunsigned.expires_at.md rename to docs/client.callzomerequestparams.expires_at.md index 73d59cd7..8b469cf6 100644 --- a/docs/client.callzomerequestunsigned.expires_at.md +++ b/docs/client.callzomerequestparams.expires_at.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestUnsigned](./client.callzomerequestunsigned.md) > [expires\_at](./client.callzomerequestunsigned.expires_at.md) +[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestParams](./client.callzomerequestparams.md) > [expires\_at](./client.callzomerequestparams.expires_at.md) -## CallZomeRequestUnsigned.expires\_at property +## CallZomeRequestParams.expires\_at property **Signature:** diff --git a/docs/client.callzomerequestunsigned.md b/docs/client.callzomerequestparams.md similarity index 61% rename from docs/client.callzomerequestunsigned.md rename to docs/client.callzomerequestparams.md index 23175fe4..4222eb87 100644 --- a/docs/client.callzomerequestunsigned.md +++ b/docs/client.callzomerequestparams.md @@ -1,14 +1,14 @@ -[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestUnsigned](./client.callzomerequestunsigned.md) +[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestParams](./client.callzomerequestparams.md) -## CallZomeRequestUnsigned interface +## CallZomeRequestParams interface **Signature:** ```typescript -export interface CallZomeRequestUnsigned extends CallZomeRequest +export interface CallZomeRequestParams extends CallZomeRequest ``` **Extends:** [CallZomeRequest](./client.callzomerequest.md) @@ -37,7 +37,7 @@ Description -[cap\_secret](./client.callzomerequestunsigned.cap_secret.md) +[cap\_secret](./client.callzomerequestparams.cap_secret.md) @@ -54,7 +54,7 @@ Description -[expires\_at](./client.callzomerequestunsigned.expires_at.md) +[expires\_at](./client.callzomerequestparams.expires_at.md) @@ -71,7 +71,7 @@ number -[nonce](./client.callzomerequestunsigned.nonce.md) +[nonce](./client.callzomerequestparams.nonce.md) diff --git a/docs/client.callzomerequestunsigned.nonce.md b/docs/client.callzomerequestparams.nonce.md similarity index 54% rename from docs/client.callzomerequestunsigned.nonce.md rename to docs/client.callzomerequestparams.nonce.md index ac1ff7f3..64617cd6 100644 --- a/docs/client.callzomerequestunsigned.nonce.md +++ b/docs/client.callzomerequestparams.nonce.md @@ -1,8 +1,8 @@ -[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestUnsigned](./client.callzomerequestunsigned.md) > [nonce](./client.callzomerequestunsigned.nonce.md) +[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestParams](./client.callzomerequestparams.md) > [nonce](./client.callzomerequestparams.nonce.md) -## CallZomeRequestUnsigned.nonce property +## CallZomeRequestParams.nonce property **Signature:** diff --git a/docs/client.callzomerequestsigned.bytes.md b/docs/client.callzomerequestsigned.bytes.md new file mode 100644 index 00000000..4b25ba0e --- /dev/null +++ b/docs/client.callzomerequestsigned.bytes.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [CallZomeRequestSigned](./client.callzomerequestsigned.md) > [bytes](./client.callzomerequestsigned.bytes.md) + +## CallZomeRequestSigned.bytes property + +**Signature:** + +```typescript +bytes: Uint8Array; +``` diff --git a/docs/client.callzomerequestsigned.md b/docs/client.callzomerequestsigned.md index 05fbabe8..1c4e695c 100644 --- a/docs/client.callzomerequestsigned.md +++ b/docs/client.callzomerequestsigned.md @@ -8,9 +8,8 @@ **Signature:** ```typescript -export interface CallZomeRequestSigned extends CallZomeRequestUnsigned +export interface CallZomeRequestSigned ``` -**Extends:** [CallZomeRequestUnsigned](./client.callzomerequestunsigned.md) ## Properties @@ -37,6 +36,23 @@ Description +[bytes](./client.callzomerequestsigned.bytes.md) + + + + + + + +Uint8Array + + + + + + + + [signature](./client.callzomerequestsigned.signature.md) diff --git a/docs/client.md b/docs/client.md index 90b7e3ce..272053aa 100644 --- a/docs/client.md +++ b/docs/client.md @@ -594,7 +594,7 @@ Description -[CallZomeRequestSigned](./client.callzomerequestsigned.md) +[CallZomeRequestParams](./client.callzomerequestparams.md) @@ -604,7 +604,7 @@ Description -[CallZomeRequestUnsigned](./client.callzomerequestunsigned.md) +[CallZomeRequestSigned](./client.callzomerequestsigned.md) diff --git a/flake.lock b/flake.lock index 6e6d3a54..88869bfd 100644 --- a/flake.lock +++ b/flake.lock @@ -53,11 +53,11 @@ "hc-scaffold": { "flake": false, "locked": { - "lastModified": 1730407032, - "narHash": "sha256-NNnow8Cne1KBJ4WvJ6eT1OzcqyJiii35Q2ElVdI0ozA=", + "lastModified": 1731921057, + "narHash": "sha256-8Qn6yXNVRTAiKCwlZpD9PDW6JQZh7lgOEa9kmnsbXnM=", "owner": "holochain", "repo": "scaffolding", - "rev": "f838294a3c4f45b3e8e41297ea36eb91cfedee80", + "rev": "2c5dc235c2e42b458bbc40cdd8c35bf588a2c40c", "type": "github" }, "original": { @@ -70,16 +70,16 @@ "holochain": { "flake": false, "locked": { - "lastModified": 1730855012, - "narHash": "sha256-oW4d2DRHxktRkkGbilWL8ZufXfA3vGeMXLnLgi12Ewk=", + "lastModified": 1732065228, + "narHash": "sha256-4QBB/HAv6MoVaHVYsbhhvj2UnfIT0bCb0cgcoeNn07A=", "owner": "holochain", "repo": "holochain", - "rev": "525b63fb019eac866e096033ba194c2d8bb45b9a", + "rev": "0069772823ce6f761f793544ca7ec8877cd47a39", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.5.0-dev.4", + "ref": "holochain-0.5.0-dev.6", "repo": "holochain", "type": "github" } @@ -96,11 +96,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1730912125, - "narHash": "sha256-zKdkSsd5d6OtY9YgBh42Pkx0NqyquWy3uktB606FZ/g=", + "lastModified": 1732123243, + "narHash": "sha256-ugJEN44UgCQYPoxV1WN32ybPxij9M8uTnDLCfWi4Rb0=", "owner": "holochain", "repo": "holonix", - "rev": "3919d71452577ccfe094a5ec3ce9581b959bb099", + "rev": "f58fb5e1c490704d90daa1b461701de7c70d685a", "type": "github" }, "original": { diff --git a/package-lock.json b/package-lock.json index 64f06998..c61ef000 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,11 +10,11 @@ "license": "CAL-1.0", "dependencies": { "@bitgo/blake2b": "^3.2.4", - "@holochain/serialization": "^0.1.0-beta-rc.3", "@msgpack/msgpack": "^2.8.0", "emittery": "^1.0.1", "isomorphic-ws": "^5.0.0", "js-base64": "^3.7.5", + "js-sha512": "^0.9.0", "libsodium-wrappers": "^0.7.13", "lodash-es": "^4.17.21", "ws": "^8.14.2" @@ -560,11 +560,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@holochain/serialization": { - "version": "0.1.0-beta-rc.3", - "resolved": "https://registry.npmjs.org/@holochain/serialization/-/serialization-0.1.0-beta-rc.3.tgz", - "integrity": "sha512-DJx4V2KXHVLciyOGjOYKTM/JLBpBEZ3RsPIRCgf7qmwhQdxXvhi2p+oFFRD51yUT5uC1/MzIVeJCl/R60PwFbw==" - }, "node_modules/@humanwhocodes/config-array": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", @@ -879,9 +874,9 @@ } }, "node_modules/@types/node": { - "version": "22.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", - "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", + "version": "22.9.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.1.tgz", + "integrity": "sha512-p8Yy/8sw1caA8CdRIQBG5tiLHmxtQKObCijiAa9Ez+d4+PRffM4054xbju0msf+cvhJpnFEeNjxmVT/0ipktrg==", "dev": true, "dependencies": { "undici-types": "~6.19.8" @@ -1406,9 +1401,9 @@ "dev": true }, "node_modules/cross-spawn": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", - "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -1616,9 +1611,9 @@ } }, "node_modules/es-abstract": { - "version": "1.23.3", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", - "integrity": "sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==", + "version": "1.23.5", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.5.tgz", + "integrity": "sha512-vlmniQ0WNPwXqA0BnmwV3Ng7HxiGlh6r5U6JcTMNx8OilcAGqVJBHJcPjqOMaczU9fRuRK5Px2BdVyPRnKMMVQ==", "dev": true, "dependencies": { "array-buffer-byte-length": "^1.0.1", @@ -1636,7 +1631,7 @@ "function.prototype.name": "^1.1.6", "get-intrinsic": "^1.2.4", "get-symbol-description": "^1.0.2", - "globalthis": "^1.0.3", + "globalthis": "^1.0.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2", "has-proto": "^1.0.3", @@ -1652,10 +1647,10 @@ "is-string": "^1.0.7", "is-typed-array": "^1.1.13", "is-weakref": "^1.0.2", - "object-inspect": "^1.13.1", + "object-inspect": "^1.13.3", "object-keys": "^1.1.1", "object.assign": "^4.1.5", - "regexp.prototype.flags": "^1.5.2", + "regexp.prototype.flags": "^1.5.3", "safe-array-concat": "^1.1.2", "safe-regex-test": "^1.0.3", "string.prototype.trim": "^1.2.9", @@ -2270,9 +2265,9 @@ } }, "node_modules/flatted": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", - "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.2.tgz", + "integrity": "sha512-AiwGJM8YcNOaobumgtng+6NHuOqC3A7MixFeDafM3X9cIUM+xUXoS5Vfgf+OihAYe20fxqNM9yPBXJzRtZ/4eA==", "dev": true }, "node_modules/for-each": { @@ -3056,6 +3051,11 @@ "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.7.tgz", "integrity": "sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==" }, + "node_modules/js-sha512": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/js-sha512/-/js-sha512-0.9.0.tgz", + "integrity": "sha512-mirki9WS/SUahm+1TbAPkqvbCiCfOAAsyXeHxK1UkullnJVVqoJG2pL9ObvT05CN+tM7fxhfYm0NbXn+1hWoZg==" + }, "node_modules/js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", diff --git a/package.json b/package.json index a928192e..0dc5857b 100644 --- a/package.json +++ b/package.json @@ -43,11 +43,11 @@ }, "dependencies": { "@bitgo/blake2b": "^3.2.4", - "@holochain/serialization": "^0.1.0-beta-rc.3", "@msgpack/msgpack": "^2.8.0", "emittery": "^1.0.1", "isomorphic-ws": "^5.0.0", "js-base64": "^3.7.5", + "js-sha512": "^0.9.0", "libsodium-wrappers": "^0.7.13", "lodash-es": "^4.17.21", "ws": "^8.14.2" @@ -72,4 +72,4 @@ "tsx": "^4.7.2", "typescript": "^4.9.5" } -} \ No newline at end of file +} diff --git a/src/api/app/types.ts b/src/api/app/types.ts index 9ca96705..54706fc9 100644 --- a/src/api/app/types.ts +++ b/src/api/app/types.ts @@ -55,8 +55,7 @@ export type RoleNameCallZomeRequestSigned = Omit< export type AppCallZomeRequest = | NonProvenanceCallZomeRequest | RoleNameCallZomeRequest - | CallZomeRequestSigned - | RoleNameCallZomeRequestSigned; + | CallZomeRequest; /** * @public @@ -91,7 +90,7 @@ export interface AppEvents { /** * @public */ -export interface CallZomeRequestUnsigned extends CallZomeRequest { +export interface CallZomeRequestParams extends CallZomeRequest { cap_secret: CapSecret | null; nonce: Nonce256Bit; expires_at: number; @@ -100,7 +99,8 @@ export interface CallZomeRequestUnsigned extends CallZomeRequest { /** * @public */ -export interface CallZomeRequestSigned extends CallZomeRequestUnsigned { +export interface CallZomeRequestSigned { + bytes: Uint8Array; signature: Uint8Array; } diff --git a/src/api/app/websocket.ts b/src/api/app/websocket.ts index 27721e36..eca32319 100644 --- a/src/api/app/websocket.ts +++ b/src/api/app/websocket.ts @@ -30,7 +30,7 @@ import { SignalCb, CallZomeRequest, CallZomeRequestSigned, - CallZomeRequestUnsigned, + CallZomeRequestParams, CallZomeResponse, CallZomeResponseGeneric, CreateCloneCellRequest, @@ -66,9 +66,9 @@ import { randomNonce, } from "../zome-call-signing.js"; import { encodeHashToBase64 } from "../../utils/index.js"; -import { hashZomeCall } from "@holochain/serialization"; import _sodium from "libsodium-wrappers"; import { WsClient } from "../client.js"; +import { sha512 } from "js-sha512"; /** * A class to establish a websocket connection to an App interface, for a @@ -603,7 +603,7 @@ export const signZomeCall = async (request: CallZomeRequest) => { )}, ${encodeHashToBase64(request.cell_id[1])}]` ); } - const unsignedZomeCallPayload: CallZomeRequestUnsigned = { + const unsignedZomeCallPayload: CallZomeRequestParams = { cap_secret: signingCredentialsForCell.capSecret, cell_id: request.cell_id, zome_name: request.zome_name, @@ -613,15 +613,16 @@ export const signZomeCall = async (request: CallZomeRequest) => { nonce: await randomNonce(), expires_at: getNonceExpiration(), }; - const hashedZomeCall = await hashZomeCall(unsignedZomeCallPayload); + const bytes = encode(unsignedZomeCallPayload); + const bytesHash = new Uint8Array(sha512.array(bytes)); await _sodium.ready; const sodium = _sodium; const signature = sodium - .crypto_sign(hashedZomeCall, signingCredentialsForCell.keyPair.privateKey) + .crypto_sign(bytesHash, signingCredentialsForCell.keyPair.privateKey) .subarray(0, sodium.crypto_sign_BYTES); const signedZomeCall: CallZomeRequestSigned = { - ...unsignedZomeCallPayload, + bytes, signature, }; return signedZomeCall; diff --git a/src/api/index.ts b/src/api/index.ts index 8cb359db..4de4bcf7 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,4 +1,3 @@ -export { hashZomeCall } from "@holochain/serialization"; export * from "./admin/index.js"; export * from "./app/index.js"; export { diff --git a/src/environments/launcher.ts b/src/environments/launcher.ts index f5c4b44f..4a3d780c 100644 --- a/src/environments/launcher.ts +++ b/src/environments/launcher.ts @@ -1,8 +1,5 @@ import { AppAuthenticationToken, CallZomeRequest } from "../api/index.js"; -import { - CallZomeRequestSigned, - CallZomeRequestUnsigned, -} from "../api/index.js"; +import { CallZomeRequestSigned, CallZomeRequestParams } from "../api/index.js"; import { InstalledAppId } from "../types.js"; export interface LauncherEnvironment { @@ -61,7 +58,7 @@ interface CallZomeRequestSignedElectron interface CallZomeRequestUnsignedElectron extends Omit< - CallZomeRequestUnsigned, + CallZomeRequestParams, | "cap_secret" | "cell_id" | "provenance"