diff --git a/e2e/node/basic/mainnet.test.ts b/e2e/node/basic/mainnet.test.ts index bc1ee723..b3a530ad 100644 --- a/e2e/node/basic/mainnet.test.ts +++ b/e2e/node/basic/mainnet.test.ts @@ -7,7 +7,6 @@ import { fromHex, polling, requestIdOf, - ReplicaTimeError, } from '@dfinity/agent'; import { IDL } from '@dfinity/candid'; import { Ed25519KeyIdentity } from '@dfinity/identity'; @@ -22,7 +21,7 @@ const createWhoamiActor = async (identity: Identity) => { const idlFactory = () => { return IDL.Service({ whoami: IDL.Func([], [IDL.Principal], ['query']), - // eslint-disable-next-line @typescript-eslint/no-explicit-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any }) as unknown as any; }; vi.useFakeTimers(); @@ -143,6 +142,7 @@ describe('call forwarding', () => { }, 15_000); }); + test('it should allow you to set an incorrect root key', async () => { const agent = HttpAgent.createSync({ rootKey: new Uint8Array(31), @@ -159,79 +159,3 @@ test('it should allow you to set an incorrect root key', async () => { expect(actor.whoami).rejects.toThrowError(`Invalid certificate:`); }); - -test('it should throw an error when the clock is out of sync during a query', async () => { - const canisterId = 'ivcos-eqaaa-aaaab-qablq-cai'; - const idlFactory = () => { - return IDL.Service({ - whoami: IDL.Func([], [IDL.Principal], ['query']), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - }) as unknown as any; - }; - vi.useRealTimers(); - - // set date to long ago - vi.spyOn(Date, 'now').mockImplementation(() => { - return new Date('2021-01-01T00:00:00Z').getTime(); - }); - // vi.setSystemTime(new Date('2021-01-01T00:00:00Z')); - - const agent = await HttpAgent.create({ host: 'https://icp-api.io', fetch: globalThis.fetch }); - - const actor = Actor.createActor(idlFactory, { - agent, - canisterId, - }); - try { - // should throw an error - await actor.whoami(); - } catch (err) { - // handle the replica time error - if (err.name === 'ReplicaTimeError') { - const error = err as ReplicaTimeError; - // use the replica time to sync the agent - error.agent.replicaTime = error.replicaTime; - } - } - // retry the call - const result = await actor.whoami(); - expect(Principal.from(result)).toBeInstanceOf(Principal); -}); - -test('it should throw an error when the clock is out of sync during an update', async () => { - const canisterId = 'ivcos-eqaaa-aaaab-qablq-cai'; - const idlFactory = () => { - return IDL.Service({ - whoami: IDL.Func([], [IDL.Principal], []), - // eslint-disable-next-line @typescript-eslint/no-explicit-any - }) as unknown as any; - }; - vi.useRealTimers(); - - // set date to long ago - vi.spyOn(Date, 'now').mockImplementation(() => { - return new Date('2021-01-01T00:00:00Z').getTime(); - }); - // vi.setSystemTime(new Date('2021-01-01T00:00:00Z')); - - const agent = await HttpAgent.create({ host: 'https://icp-api.io', fetch: globalThis.fetch }); - - const actor = Actor.createActor(idlFactory, { - agent, - canisterId, - }); - try { - // should throw an error - await actor.whoami(); - } catch (err) { - // handle the replica time error - if (err.name === 'ReplicaTimeError') { - const error = err as ReplicaTimeError; - // use the replica time to sync the agent - error.agent.replicaTime = error.replicaTime; - // retry the call - const result = await actor.whoami(); - expect(Principal.from(result)).toBeInstanceOf(Principal); - } - } -}); diff --git a/e2e/node/package.json b/e2e/node/package.json index 07e25187..085c5e98 100644 --- a/e2e/node/package.json +++ b/e2e/node/package.json @@ -47,7 +47,7 @@ }, "overrides": { "vite": { - "rollup": "npm:@rollup/wasm-node" + "rollup": "^4.22.5" } } } diff --git a/package-lock.json b/package-lock.json index 1a4cb8ac..bf53d215 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "Apache-2.0", "devDependencies": { "@jest/types": "^29.6.3", - "@rollup/wasm-node": "^4.20.0", "@size-limit/esbuild": "^11.0.2", "@size-limit/preset-small-lib": "^9.0.0", "@types/jest": "^29.5.5", @@ -3479,9 +3478,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.20.0.tgz", - "integrity": "sha512-TSpWzflCc4VGAUJZlPpgAJE1+V60MePDQnBd7PPkpuEmOy8i87aL6tinFGKBFKuEDikYpig72QzdT3QPYIi+oA==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.22.5.tgz", + "integrity": "sha512-SU5cvamg0Eyu/F+kLeMXS7GoahL+OoizlclVFX3l5Ql6yNlywJJ0OuqTzUx0v+aHhPHEB/56CT06GQrRrGNYww==", "cpu": [ "arm" ], @@ -3493,9 +3492,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.20.0.tgz", - "integrity": "sha512-u00Ro/nok7oGzVuh/FMYfNoGqxU5CPWz1mxV85S2w9LxHR8OoMQBuSk+3BKVIDYgkpeOET5yXkx90OYFc+ytpQ==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.22.5.tgz", + "integrity": "sha512-S4pit5BP6E5R5C8S6tgU/drvgjtYW76FBuG6+ibG3tMvlD1h9LHVF9KmlmaUBQ8Obou7hEyS+0w+IR/VtxwNMQ==", "cpu": [ "arm64" ], @@ -3507,7 +3506,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.20.0", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.5.tgz", + "integrity": "sha512-250ZGg4ipTL0TGvLlfACkIxS9+KLtIbn7BCZjsZj88zSg2Lvu3Xdw6dhAhfe/FjjXPVNCtcSp+WZjVsD3a/Zlw==", "cpu": [ "arm64" ], @@ -3519,9 +3520,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.20.0.tgz", - "integrity": "sha512-xbrMDdlev53vNXexEa6l0LffojxhqDTBeL+VUxuuIXys4x6xyvbKq5XqTXBCEUA8ty8iEJblHvFaWRJTk/icAQ==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.22.5.tgz", + "integrity": "sha512-D8brJEFg5D+QxFcW6jYANu+Rr9SlKtTenmsX5hOSzNYVrK5oLAEMTUgKWYJP+wdKyCdeSwnapLsn+OVRFycuQg==", "cpu": [ "x64" ], @@ -3533,9 +3534,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.20.0.tgz", - "integrity": "sha512-jMYvxZwGmoHFBTbr12Xc6wOdc2xA5tF5F2q6t7Rcfab68TT0n+r7dgawD4qhPEvasDsVpQi+MgDzj2faOLsZjA==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.22.5.tgz", + "integrity": "sha512-PNqXYmdNFyWNg0ma5LdY8wP+eQfdvyaBAojAXgO7/gs0Q/6TQJVXAXe8gwW9URjbS0YAammur0fynYGiWsKlXw==", "cpu": [ "arm" ], @@ -3547,9 +3548,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.20.0.tgz", - "integrity": "sha512-1asSTl4HKuIHIB1GcdFHNNZhxAYEdqML/MW4QmPS4G0ivbEcBr1JKlFLKsIRqjSwOBkdItn3/ZDlyvZ/N6KPlw==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.22.5.tgz", + "integrity": "sha512-kSSCZOKz3HqlrEuwKd9TYv7vxPYD77vHSUvM2y0YaTGnFc8AdI5TTQRrM1yIp3tXCKrSL9A7JLoILjtad5t8pQ==", "cpu": [ "arm" ], @@ -3561,9 +3562,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.20.0.tgz", - "integrity": "sha512-COBb8Bkx56KldOYJfMf6wKeYJrtJ9vEgBRAOkfw6Ens0tnmzPqvlpjZiLgkhg6cA3DGzCmLmmd319pmHvKWWlQ==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.22.5.tgz", + "integrity": "sha512-oTXQeJHRbOnwRnRffb6bmqmUugz0glXaPyspp4gbQOPVApdpRrY/j7KP3lr7M8kTfQTyrBUzFjj5EuHAhqH4/w==", "cpu": [ "arm64" ], @@ -3575,9 +3576,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.20.0.tgz", - "integrity": "sha512-+it+mBSyMslVQa8wSPvBx53fYuZK/oLTu5RJoXogjk6x7Q7sz1GNRsXWjn6SwyJm8E/oMjNVwPhmNdIjwP135Q==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.22.5.tgz", + "integrity": "sha512-qnOTIIs6tIGFKCHdhYitgC2XQ2X25InIbZFor5wh+mALH84qnFHvc+vmWUpyX97B0hNvwNUL4B+MB8vJvH65Fw==", "cpu": [ "arm64" ], @@ -3589,9 +3590,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.20.0.tgz", - "integrity": "sha512-yAMvqhPfGKsAxHN8I4+jE0CpLWD8cv4z7CK7BMmhjDuz606Q2tFKkWRY8bHR9JQXYcoLfopo5TTqzxgPUjUMfw==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.22.5.tgz", + "integrity": "sha512-TMYu+DUdNlgBXING13rHSfUc3Ky5nLPbWs4bFnT+R6Vu3OvXkTkixvvBKk8uO4MT5Ab6lC3U7x8S8El2q5o56w==", "cpu": [ "ppc64" ], @@ -3603,9 +3604,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.20.0.tgz", - "integrity": "sha512-qmuxFpfmi/2SUkAw95TtNq/w/I7Gpjurx609OOOV7U4vhvUhBcftcmXwl3rqAek+ADBwSjIC4IVNLiszoj3dPA==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.22.5.tgz", + "integrity": "sha512-PTQq1Kz22ZRvuhr3uURH+U/Q/a0pbxJoICGSprNLAoBEkyD3Sh9qP5I0Asn0y0wejXQBbsVMRZRxlbGFD9OK4A==", "cpu": [ "riscv64" ], @@ -3617,9 +3618,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.20.0.tgz", - "integrity": "sha512-I0BtGXddHSHjV1mqTNkgUZLnS3WtsqebAXv11D5BZE/gfw5KoyXSAXVqyJximQXNvNzUo4GKlCK/dIwXlz+jlg==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.22.5.tgz", + "integrity": "sha512-bR5nCojtpuMss6TDEmf/jnBnzlo+6n1UhgwqUvRoe4VIotC7FG1IKkyJbwsT7JDsF2jxR+NTnuOwiGv0hLyDoQ==", "cpu": [ "s390x" ], @@ -3644,9 +3645,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.20.0.tgz", - "integrity": "sha512-hM3nhW40kBNYUkZb/r9k2FKK+/MnKglX7UYd4ZUy5DJs8/sMsIbqWK2piZtVGE3kcXVNj3B2IrUYROJMMCikNg==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.22.5.tgz", + "integrity": "sha512-uBa2e28ohzNNwjr6Uxm4XyaA1M/8aTgfF2T7UIlElLaeXkgpmIJ2EitVNQxjO9xLLLy60YqAgKn/AqSpCUkE9g==", "cpu": [ "x64" ], @@ -3658,9 +3659,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.20.0.tgz", - "integrity": "sha512-psegMvP+Ik/Bg7QRJbv8w8PAytPA7Uo8fpFjXyCRHWm6Nt42L+JtoqH8eDQ5hRP7/XW2UiIriy1Z46jf0Oa1kA==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.22.5.tgz", + "integrity": "sha512-RXT8S1HP8AFN/Kr3tg4fuYrNxZ/pZf1HemC5Tsddc6HzgGnJm0+Lh5rAHJkDuW3StI0ynNXukidROMXYl6ew8w==", "cpu": [ "arm64" ], @@ -3672,9 +3673,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.20.0.tgz", - "integrity": "sha512-GabekH3w4lgAJpVxkk7hUzUf2hICSQO0a/BLFA11/RMxQT92MabKAqyubzDZmMOC/hcJNlc+rrypzNzYl4Dx7A==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.22.5.tgz", + "integrity": "sha512-ElTYOh50InL8kzyUD6XsnPit7jYCKrphmddKAe1/Ytt74apOxDq5YEcbsiKs0fR3vff3jEneMM+3I7jbqaMyBg==", "cpu": [ "ia32" ], @@ -3686,9 +3687,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.20.0.tgz", - "integrity": "sha512-aJ1EJSuTdGnM6qbVC4B5DSmozPTqIag9fSzXRNNo+humQLG89XpPgdt16Ia56ORD7s+H8Pmyx44uczDQ0yDzpg==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.22.5.tgz", + "integrity": "sha512-+lvL/4mQxSV8MukpkKyyvfwhH266COcWlXE/1qxwN08ajovta3459zrjLghYMgDerlzNwLAcFpvU+WWE5y6nAQ==", "cpu": [ "x64" ], @@ -3699,26 +3700,6 @@ "win32" ] }, - "node_modules/@rollup/wasm-node": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/wasm-node/-/wasm-node-4.20.0.tgz", - "integrity": "sha512-NxIRJDju9ZzXwpCZ+TMYEflT/KJPgcamVrkInPwB/jSzEIEhckHGgbC9C8Fkzt77nEZZpfF/H2BedwKfjxO9qQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/estree": "1.0.5" - }, - "bin": { - "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=18.0.0", - "npm": ">=8.0.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, "node_modules/@scure/base": { "version": "1.1.7", "license": "MIT", @@ -4263,7 +4244,9 @@ } }, "node_modules/@types/estree": { - "version": "1.0.5", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", "dev": true, "license": "MIT" }, @@ -13154,7 +13137,9 @@ } }, "node_modules/picocolors": { - "version": "1.0.1", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", + "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", "dev": true, "license": "ISC" }, @@ -13268,7 +13253,9 @@ } }, "node_modules/postcss": { - "version": "8.4.40", + "version": "8.4.47", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.47.tgz", + "integrity": "sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==", "dev": true, "funding": [ { @@ -13287,8 +13274,8 @@ "license": "MIT", "dependencies": { "nanoid": "^3.3.7", - "picocolors": "^1.0.1", - "source-map-js": "^1.2.0" + "picocolors": "^1.1.0", + "source-map-js": "^1.2.1" }, "engines": { "node": "^10 || ^12 || >=14" @@ -13296,6 +13283,8 @@ }, "node_modules/postcss/node_modules/nanoid": { "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", "dev": true, "funding": [ { @@ -14903,11 +14892,13 @@ } }, "node_modules/rollup": { - "version": "4.20.0", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.5.tgz", + "integrity": "sha512-WoinX7GeQOFMGznEcWA1WrTQCd/tpEbMkc3nuMs9BT0CPjMdSjPMTVClwWd4pgSQwJdP65SK9mTCNvItlr5o7w==", "dev": true, "license": "MIT", "dependencies": { - "@types/estree": "1.0.5" + "@types/estree": "1.0.6" }, "bin": { "rollup": "dist/bin/rollup" @@ -14917,29 +14908,29 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.20.0", - "@rollup/rollup-android-arm64": "4.20.0", - "@rollup/rollup-darwin-arm64": "4.20.0", - "@rollup/rollup-darwin-x64": "4.20.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.20.0", - "@rollup/rollup-linux-arm-musleabihf": "4.20.0", - "@rollup/rollup-linux-arm64-gnu": "4.20.0", - "@rollup/rollup-linux-arm64-musl": "4.20.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.20.0", - "@rollup/rollup-linux-riscv64-gnu": "4.20.0", - "@rollup/rollup-linux-s390x-gnu": "4.20.0", - "@rollup/rollup-linux-x64-gnu": "4.20.0", - "@rollup/rollup-linux-x64-musl": "4.20.0", - "@rollup/rollup-win32-arm64-msvc": "4.20.0", - "@rollup/rollup-win32-ia32-msvc": "4.20.0", - "@rollup/rollup-win32-x64-msvc": "4.20.0", + "@rollup/rollup-android-arm-eabi": "4.22.5", + "@rollup/rollup-android-arm64": "4.22.5", + "@rollup/rollup-darwin-arm64": "4.22.5", + "@rollup/rollup-darwin-x64": "4.22.5", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.5", + "@rollup/rollup-linux-arm-musleabihf": "4.22.5", + "@rollup/rollup-linux-arm64-gnu": "4.22.5", + "@rollup/rollup-linux-arm64-musl": "4.22.5", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.5", + "@rollup/rollup-linux-riscv64-gnu": "4.22.5", + "@rollup/rollup-linux-s390x-gnu": "4.22.5", + "@rollup/rollup-linux-x64-gnu": "4.22.5", + "@rollup/rollup-linux-x64-musl": "4.22.5", + "@rollup/rollup-win32-arm64-msvc": "4.22.5", + "@rollup/rollup-win32-ia32-msvc": "4.22.5", + "@rollup/rollup-win32-x64-msvc": "4.22.5", "fsevents": "~2.3.2" } }, "node_modules/rollup/node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.20.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.20.0.tgz", - "integrity": "sha512-y+eoL2I3iphUg9tN9GB6ku1FA8kOfmF4oUEWhztDJ4KXJy1agk/9+pejOuZkNFhRwHAOxMsBPLbXPd6mJiCwew==", + "version": "4.22.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.22.5.tgz", + "integrity": "sha512-N0jPPhHjGShcB9/XXZQWuWBKZQnC1F36Ce3sDqWpujsGjDz/CQtOL9LgTrJ+rJC8MJeesMWrMWVLKKNR/tMOCA==", "cpu": [ "x64" ], @@ -15431,7 +15422,9 @@ } }, "node_modules/source-map-js": { - "version": "1.2.0", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "dev": true, "license": "BSD-3-Clause", "engines": { @@ -16697,13 +16690,15 @@ } }, "node_modules/vite": { - "version": "5.3.5", + "version": "5.4.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.8.tgz", + "integrity": "sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ==", "dev": true, "license": "MIT", "dependencies": { "esbuild": "^0.21.3", - "postcss": "^8.4.39", - "rollup": "^4.13.0" + "postcss": "^8.4.43", + "rollup": "^4.20.0" }, "bin": { "vite": "bin/vite.js" @@ -16722,6 +16717,7 @@ "less": "*", "lightningcss": "^1.21.0", "sass": "*", + "sass-embedded": "*", "stylus": "*", "sugarss": "*", "terser": "^5.4.0" @@ -16739,6 +16735,9 @@ "sass": { "optional": true }, + "sass-embedded": { + "optional": true + }, "stylus": { "optional": true }, diff --git a/package.json b/package.json index 701fa4c0..9f95b013 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ }, "devDependencies": { "@jest/types": "^29.6.3", - "@rollup/wasm-node": "^4.20.0", "@size-limit/esbuild": "^11.0.2", "@size-limit/preset-small-lib": "^9.0.0", "@types/jest": "^29.5.5", @@ -159,7 +158,7 @@ }, "overrides": { "vite": { - "rollup": "npm:@rollup/wasm-node" + "rollup": "^4.22.5" } } } diff --git a/packages/agent/src/actor.ts b/packages/agent/src/actor.ts index f447da3e..f347f6fa 100644 --- a/packages/agent/src/actor.ts +++ b/packages/agent/src/actor.ts @@ -2,7 +2,6 @@ import { Buffer } from 'buffer/'; import { Agent, getDefaultAgent, - HttpAgent, HttpDetailsResponse, QueryResponseRejected, QueryResponseStatus, @@ -536,19 +535,13 @@ function _createActorMethod( }); let reply: ArrayBuffer | undefined; let certificate: Certificate | undefined; - const certTime = (agent as HttpAgent).replicaTime - ? (agent as HttpAgent).replicaTime - : undefined; - - certTime; - if (response.body && response.body.certificate) { const cert = response.body.certificate; certificate = await Certificate.create({ certificate: bufFromBufLike(cert), rootKey: agent.rootKey, canisterId: Principal.from(canisterId), - certTime, + blsVerify, }); const path = [new TextEncoder().encode('request_status'), requestId]; const status = new TextDecoder().decode( diff --git a/packages/agent/src/agent/api.ts b/packages/agent/src/agent/api.ts index d4b6283a..b11bd1e4 100644 --- a/packages/agent/src/agent/api.ts +++ b/packages/agent/src/agent/api.ts @@ -119,7 +119,6 @@ export interface CallOptions { export interface ReadStateResponse { certificate: ArrayBuffer; - replicaTime?: Date; } export interface SubmitResponse { diff --git a/packages/agent/src/agent/http/__snapshots__/calculateReplicaTime.test.ts.snap b/packages/agent/src/agent/http/__snapshots__/calculateReplicaTime.test.ts.snap deleted file mode 100644 index 6f7dd4b3..00000000 --- a/packages/agent/src/agent/http/__snapshots__/calculateReplicaTime.test.ts.snap +++ /dev/null @@ -1,3 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`calculateReplicaTime 1`] = `2024-08-13T22:49:30.148Z`; diff --git a/packages/agent/src/agent/http/calculateReplicaTime.test.ts b/packages/agent/src/agent/http/calculateReplicaTime.test.ts deleted file mode 100644 index ba770587..00000000 --- a/packages/agent/src/agent/http/calculateReplicaTime.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { calculateReplicaTime } from './calculateReplicaTime'; -const exampleMessage = `Specified ingress_expiry not within expected range: Minimum allowed expiry: 2024-08-13 22:49:30.148075776 UTC, Maximum allowed expiry: 2024-08-13 22:55:00.148075776 UTC, Provided expiry: 2021-01-01 00:04:00 UTC`; - -test('calculateReplicaTime', () => { - const parsedTime = calculateReplicaTime(exampleMessage); - expect(parsedTime).toMatchSnapshot(); -}); diff --git a/packages/agent/src/agent/http/calculateReplicaTime.ts b/packages/agent/src/agent/http/calculateReplicaTime.ts deleted file mode 100644 index 6983506d..00000000 --- a/packages/agent/src/agent/http/calculateReplicaTime.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Parse the expiry from the message - * @param message an error message - * @returns diff in milliseconds - */ -export const calculateReplicaTime = (message: string): Date => { - const [min, max] = message.split('UTC'); - - const minsplit = min.trim().split(' ').reverse(); - - const minDateString = `${minsplit[1]} ${minsplit[0]} UTC`; - - const maxsplit = max.trim().split(' ').reverse(); - - const maxDateString = `${maxsplit[1]} ${maxsplit[0]} UTC`; - - return new Date(minDateString); -}; - -function midwayBetweenDates(date1: Date, date2: Date) { - return new Date((date1.getTime() + date2.getTime()) / 2); -} diff --git a/packages/agent/src/agent/http/errors.ts b/packages/agent/src/agent/http/errors.ts index 4f701379..8874e14d 100644 --- a/packages/agent/src/agent/http/errors.ts +++ b/packages/agent/src/agent/http/errors.ts @@ -1,27 +1,10 @@ -import { HttpAgent } from '.'; import { AgentError } from '../../errors'; import { HttpDetailsResponse } from '../api'; export class AgentHTTPResponseError extends AgentError { - constructor( - message: string, - public readonly response: HttpDetailsResponse, - ) { + constructor(message: string, public readonly response: HttpDetailsResponse) { super(message); this.name = this.constructor.name; Object.setPrototypeOf(this, new.target.prototype); } } - -export class ReplicaTimeError extends AgentError { - public readonly replicaTime: Date; - public readonly agent: HttpAgent; - - constructor(message: string, replicaTime: Date, agent: HttpAgent) { - super(message); - this.name = 'ReplicaTimeError'; - this.replicaTime = replicaTime; - this.agent = agent; - Object.setPrototypeOf(this, new.target.prototype); - } -} diff --git a/packages/agent/src/agent/http/http.test.ts b/packages/agent/src/agent/http/http.test.ts index 0cf25bc9..386b6bda 100644 --- a/packages/agent/src/agent/http/http.test.ts +++ b/packages/agent/src/agent/http/http.test.ts @@ -16,8 +16,7 @@ import { JSDOM } from 'jsdom'; import { Actor, AnonymousIdentity, SignIdentity, toHex } from '../..'; import { Ed25519KeyIdentity } from '@dfinity/identity'; import { AgentError } from '../../errors'; -import { AgentHTTPResponseError, ReplicaTimeError } from './errors'; -import { IDL } from '@dfinity/candid'; +import { AgentHTTPResponseError } from './errors'; const { window } = new JSDOM(`

Hello world

`); window.fetch = global.fetch; (global as any).window = window; @@ -814,4 +813,3 @@ test('it should log errors to console if the option is set', async () => { await agent.syncTime(); }); -jest.setTimeout(5000); diff --git a/packages/agent/src/agent/http/index.ts b/packages/agent/src/agent/http/index.ts index 07c0b956..067cbe9e 100644 --- a/packages/agent/src/agent/http/index.ts +++ b/packages/agent/src/agent/http/index.ts @@ -27,7 +27,7 @@ import { ReadRequestType, SubmitRequestType, } from './types'; -import { AgentHTTPResponseError, ReplicaTimeError } from './errors'; +import { AgentHTTPResponseError } from './errors'; import { SubnetStatus, request } from '../../canisterStatus'; import { CertificateVerificationError, @@ -41,7 +41,6 @@ import { Ed25519PublicKey } from '../../public_key'; import { decodeTime } from '../../utils/leb'; import { ObservableLog } from '../../observable'; import { BackoffStrategy, BackoffStrategyFactory, ExponentialBackoff } from '../../polling/backoff'; -import { calculateReplicaTime } from './calculateReplicaTime'; export * from './transforms'; export { Nonce, makeNonce } from './types'; @@ -139,10 +138,6 @@ export interface HttpAgentOptions { * Whether to log to the console. Defaults to false. */ logToConsole?: boolean; - /** - * Provide an expected replica time. This can be used to set the baseline for the time to use when making requests against the replica. - */ - replicaTime?: Date; /** * Alternate root key to use for verifying certificates. If not provided, the default IC root key will be used. @@ -248,6 +243,7 @@ export class HttpAgent implements Agent { readonly #fetch: typeof fetch; readonly #fetchOptions?: Record; readonly #callOptions?: Record; + #timeDiffMsecs = 0; readonly host: URL; readonly #credentials: string | undefined; #rootKeyFetched = false; @@ -261,19 +257,6 @@ export class HttpAgent implements Agent { // The UTC time in milliseconds when the latest request was made #waterMark = 0; - // Manage the time offset between the client and the replica - #initialClientTime: Date = new Date(Date.now()); - #initialReplicaTime: Date = new Date(Date.now()); - get replicaTime(): Date { - const offset = Date.now() - this.#initialClientTime.getTime(); - return new Date(this.#initialReplicaTime.getTime() + offset); - } - - set replicaTime(replicaTime: Date) { - this.#initialClientTime = new Date(Date.now()); - this.#initialReplicaTime = replicaTime; - } - get waterMark(): number { return this.#waterMark; } @@ -448,9 +431,8 @@ export class HttpAgent implements Agent { let ingress_expiry = new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS); // If the value is off by more than 30 seconds, reconcile system time with the network - const timeDiffMsecs = this.replicaTime && this.replicaTime.getTime() - Date.now(); - if (Math.abs(timeDiffMsecs) > 1_000 * 30) { - ingress_expiry = new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS + timeDiffMsecs); + if (Math.abs(this.#timeDiffMsecs) > 1_000 * 30) { + ingress_expiry = new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS + this.#timeDiffMsecs); } const submit: CallRequest = { @@ -517,6 +499,7 @@ export class HttpAgent implements Agent { }); }; + const request = this.#requestAndRetry({ request: callSync ? requestSync : requestAsync, backoff, @@ -639,8 +622,6 @@ export class HttpAgent implements Agent { ); } } catch (error) { - this.log.error('Caught exception while attempting to read state', error as AgentError); - this.#handleReplicaTimeError(error as AgentError); if (tries < this.#retryTimes) { this.log.warn( `Caught exception while attempting to make query:\n` + @@ -736,11 +717,6 @@ export class HttpAgent implements Agent { } const responseText = await response.clone().text(); - - if (response.status === 400 && responseText.includes('ingress_expiry')) { - this.#handleReplicaTimeError(new AgentError(responseText)); - } - const errorMessage = `Server returned an error:\n` + ` Code: ${response.status} (${response.statusText})\n` + @@ -789,21 +765,13 @@ export class HttpAgent implements Agent { const canister = Principal.from(canisterId); const sender = id?.getPrincipal() || Principal.anonymous(); - let ingress_expiry = new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS); - - // If the value is off by more than 30 seconds, reconcile system time with the network - const timeDiffMsecs = this.replicaTime && this.replicaTime.getTime() - Date.now(); - if (Math.abs(timeDiffMsecs) > 1_000 * 30) { - ingress_expiry = new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS + timeDiffMsecs); - } - const request: QueryRequest = { request_type: ReadRequestType.Query, canister_id: canister, method_name: fields.methodName, arg: fields.arg, sender, - ingress_expiry, + ingress_expiry: new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS), }; const requestId = await requestIdOf(request); @@ -975,15 +943,9 @@ export class HttpAgent implements Agent { } const sender = id?.getPrincipal() || Principal.anonymous(); - let ingress_expiry = new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS); - - // If the value is off by more than 30 seconds, reconcile system time with the network - const timeDiffMsecs = this.replicaTime && this.replicaTime.getTime() - Date.now(); - if (Math.abs(timeDiffMsecs) > 1_000 * 30) { - ingress_expiry = new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS + timeDiffMsecs); - } - - const transformedRequest = await this._transform({ + // TODO: remove this any. This can be a Signed or UnSigned request. + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const transformedRequest: any = await this._transform({ request: { method: 'POST', headers: { @@ -996,7 +958,7 @@ export class HttpAgent implements Agent { request_type: ReadRequestType.ReadState, paths: fields.paths, sender, - ingress_expiry, + ingress_expiry: new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS), }, }); @@ -1009,7 +971,7 @@ export class HttpAgent implements Agent { fields: ReadStateOptions, identity?: Identity | Promise, // eslint-disable-next-line - request?: Request, + request?: any, ): Promise { const canister = typeof canisterId === 'string' ? Principal.fromText(canisterId) : canisterId; @@ -1022,7 +984,6 @@ export class HttpAgent implements Agent { ); // TODO - https://dfinity.atlassian.net/browse/SDK-1092 const backoff = this.#backoffStrategy(); - try { const response = await this.#requestAndRetry({ request: () => @@ -1053,24 +1014,15 @@ export class HttpAgent implements Agent { this.log.print('Read state response time:', parsedTime); this.#waterMark = parsedTime; } + return decodedResponse; } catch (error) { - this.#handleReplicaTimeError(error as AgentError); + this.log.error('Caught exception while attempting to read state', error as AgentError); + throw error; } - throw new AgentError('Failed to read state'); } - #handleReplicaTimeError = (error: AgentError): void => { - const message = error.message; - if (message?.includes('ingress_expiry')) { - { - const replicaTime = calculateReplicaTime(message); - throw new ReplicaTimeError(message, replicaTime, this); - } - } - }; - - public async parseTimeFromResponse(response: ReadStateResponse): Promise { + public async parseTimeFromResponse(response: { certificate: ArrayBuffer }): Promise { let tree: HashTree; if (response.certificate) { const decoded: { tree: HashTree } | undefined = cbor.decode(response.certificate); @@ -1100,10 +1052,10 @@ export class HttpAgent implements Agent { /** * Allows agent to sync its time with the network. Can be called during intialization or mid-lifecycle if the device's clock has drifted away from the network time. This is necessary to set the Expiry for a request * @param {Principal} canisterId - Pass a canister ID if you need to sync the time with a particular replica. Uses the management canister by default - * @throws {ReplicaTimeError} - this method is not guaranteed to work if the device's clock is off by more than 30 seconds. In such cases, the agent will throw an error. */ public async syncTime(canisterId?: Principal): Promise { const CanisterStatus = await import('../../canisterStatus'); + const callTime = Date.now(); try { if (!canisterId) { this.log.print( @@ -1119,7 +1071,7 @@ export class HttpAgent implements Agent { const replicaTime = status.get('time'); if (replicaTime) { - this.replicaTime = new Date(Number(replicaTime as bigint)); + this.#timeDiffMsecs = Number(replicaTime as bigint) - Number(callTime); } } catch (error) { this.log.error('Caught exception while attempting to sync time', error as AgentError); diff --git a/packages/agent/src/canisterStatus/index.test.ts b/packages/agent/src/canisterStatus/index.test.ts index cac1fe0a..34096676 100644 --- a/packages/agent/src/canisterStatus/index.test.ts +++ b/packages/agent/src/canisterStatus/index.test.ts @@ -63,6 +63,7 @@ const getRealStatus = async () => { const agent = new HttpAgent({ host: 'http://127.0.0.1:4943', fetch, identity }); await agent.fetchRootKey(); const canisterBuffer = new DataView(testPrincipal.toUint8Array().buffer).buffer; + canisterBuffer; const response = await agent.readState( testPrincipal, // Note: subnet is not currently working due to a bug diff --git a/packages/agent/src/canisterStatus/index.ts b/packages/agent/src/canisterStatus/index.ts index a0f9b5fe..c46ba2ca 100644 --- a/packages/agent/src/canisterStatus/index.ts +++ b/packages/agent/src/canisterStatus/index.ts @@ -145,12 +145,10 @@ export const request = async (options: { const response = await agent.readState(canisterId, { paths: [encodedPaths[index]], }); - const certTime = agent.replicaTime ? agent.replicaTime : undefined; const cert = await Certificate.create({ certificate: response.certificate, rootKey: agent.rootKey, canisterId: canisterId, - certTime, }); const lookup = (cert: Certificate, path: Path) => { diff --git a/packages/agent/src/certificate.ts b/packages/agent/src/certificate.ts index d941c0e4..8ddac8ca 100644 --- a/packages/agent/src/certificate.ts +++ b/packages/agent/src/certificate.ts @@ -40,7 +40,7 @@ export type HashTree = /** * Make a human readable string out of a hash tree. - * @param tree - the tree to stringify + * @param tree */ export function hashTreeToString(tree: HashTree): string { const indent = (s: string) => @@ -52,7 +52,7 @@ export function hashTreeToString(tree: HashTree): string { const decoder = new TextDecoder(undefined, { fatal: true }); try { return JSON.stringify(decoder.decode(label)); - } catch { + } catch (e) { return `data(...${label.byteLength} bytes)`; } } @@ -146,16 +146,10 @@ export interface CreateCertificateOptions { * older than the specified age, it will fail verification. */ maxAgeInMinutes?: number; - - /** - * For comparing the time of the certificate to an expected date instead of the result of Date.now. - */ - certTime?: Date; } export class Certificate { public cert: Cert; - #certTime?: Date; /** * Create a new instance of a certificate, automatically verifying it. Throws a @@ -170,6 +164,7 @@ export class Certificate { */ public static async create(options: CreateCertificateOptions): Promise { const cert = Certificate.createUnverified(options); + await cert.verify(); return cert; } @@ -185,7 +180,6 @@ export class Certificate { options.canisterId, blsVerify, options.maxAgeInMinutes, - options.certTime, ); } @@ -196,10 +190,8 @@ export class Certificate { private _blsVerify: VerifyFunc, // Default to 5 minutes private _maxAgeInMinutes: number = 5, - certTime?: Date, ) { this.cert = cbor.decode(new Uint8Array(certificate)); - this.#certTime = certTime; } public lookup(path: Array): LookupResult { @@ -228,10 +220,8 @@ export class Certificate { const FIVE_MINUTES_IN_MSEC = 5 * 60 * 1000; const MAX_AGE_IN_MSEC = this._maxAgeInMinutes * 60 * 1000; const now = Date.now(); - // Use a provided time in case `Date.now()` is inaccurate - const compareTime = this.#certTime || new Date(now); - const earliestCertificateTime = compareTime.getTime() - MAX_AGE_IN_MSEC; - const fiveMinutesFromNow = compareTime.getTime() + FIVE_MINUTES_IN_MSEC; + const earliestCertificateTime = now - MAX_AGE_IN_MSEC; + const fiveMinutesFromNow = now + FIVE_MINUTES_IN_MSEC; const certTime = decodeTime(lookupTime); @@ -240,20 +230,20 @@ export class Certificate { `Certificate is signed more than ${this._maxAgeInMinutes} minutes in the past. Certificate time: ` + certTime.toISOString() + ' Current time: ' + - compareTime.toISOString(), + new Date(now).toISOString(), ); } else if (certTime.getTime() > fiveMinutesFromNow) { throw new CertificateVerificationError( 'Certificate is signed more than 5 minutes in the future. Certificate time: ' + certTime.toISOString() + ' Current time: ' + - compareTime.toISOString(), + new Date(now).toISOString(), ); } try { sigVer = await this._blsVerify(new Uint8Array(key), new Uint8Array(sig), new Uint8Array(msg)); - } catch { + } catch (err) { sigVer = false; } if (!sigVer) { @@ -271,7 +261,6 @@ export class Certificate { rootKey: this._rootKey, canisterId: this._canisterId, blsVerify: this._blsVerify, - certTime: this.#certTime, // Do not check max age for delegation certificates maxAgeInMinutes: Infinity, }); @@ -346,7 +335,7 @@ export function lookupResultToBuffer(result: LookupResult): ArrayBuffer | undefi } /** - * @param t - the tree to reconstruct + * @param t */ export async function reconstruct(t: HashTree): Promise { switch (t[0]) { @@ -419,12 +408,6 @@ interface LookupResultLess { type LabelLookupResult = LookupResult | LookupResultGreater | LookupResultLess; -/** - * Lookup a path in a tree - * @param path - the path to look up - * @param tree - the tree to search - * @returns LookupResult - */ export function lookup_path(path: Array, tree: HashTree): LookupResult { if (path.length === 0) { switch (tree[0]) { @@ -499,12 +482,6 @@ export function flatten_forks(t: HashTree): HashTree[] { } } -/** - * Find a label in a tree - * @param label - the label to find - * @param tree - the tree to search - * @returns LabelLookupResult - */ export function find_label(label: ArrayBuffer, tree: HashTree): LabelLookupResult { switch (tree[0]) { // if we have a labelled node, compare the node's label to the one we are @@ -537,7 +514,6 @@ export function find_label(label: ArrayBuffer, tree: HashTree): LabelLookupResul // if we have a fork node, we need to search both sides, starting with the left case NodeType.Fork: // search in the left node - // eslint-disable-next-line no-case-declarations const leftLookupResult = find_label(label, tree[1]); switch (leftLookupResult.status) { @@ -562,7 +538,7 @@ export function find_label(label: ArrayBuffer, tree: HashTree): LabelLookupResul // if the left node returns an uncertain result, we need to search the // right node case LookupStatus.Unknown: { - const rightLookupResult = find_label(label, tree[2]); + let rightLookupResult = find_label(label, tree[2]); // if the label we're searching for is less than the right node lookup, // then we also need to return an uncertain result @@ -604,11 +580,9 @@ export function find_label(label: ArrayBuffer, tree: HashTree): LabelLookupResul /** * Check if a canister falls within a range of canisters - * @param params - the parameters to check - * @param params.canisterId Principal - * @param params.subnetId Principal - * @param params.tree HashTree - * @returns boolean + * @param canisterId Principal + * @param ranges [Principal, Principal][] + * @returns */ export function check_canister_ranges(params: { canisterId: Principal; diff --git a/packages/agent/src/polling/index.ts b/packages/agent/src/polling/index.ts index baebbc7a..ccd399eb 100644 --- a/packages/agent/src/polling/index.ts +++ b/packages/agent/src/polling/index.ts @@ -1,5 +1,5 @@ import { Principal } from '@dfinity/principal'; -import { Agent, HttpAgent, RequestStatusResponseStatus } from '../agent'; +import { Agent, RequestStatusResponseStatus } from '../agent'; import { Certificate, CreateCertificateOptions, lookupResultToBuffer } from '../certificate'; import { RequestId } from '../request_id'; import { toHex } from '../utils/buffer'; @@ -40,17 +40,10 @@ export async function pollForResponse( const currentRequest = request ?? (await agent.createReadStateRequest?.({ paths: [path] })); const state = await agent.readState(canisterId, { paths: [path] }, undefined, currentRequest); if (agent.rootKey == null) throw new Error('Agent root key not initialized before polling'); - - // if agent has replicaTime, otherwise omit - const certTime = (agent as HttpAgent)?.replicaTime - ? (agent as HttpAgent)?.replicaTime - : undefined; - const cert = await Certificate.create({ certificate: state.certificate, rootKey: agent.rootKey, canisterId: canisterId, - certTime: certTime, blsVerify, }); diff --git a/packages/assets/src/index.ts b/packages/assets/src/index.ts index a2a2579d..a5b416e6 100644 --- a/packages/assets/src/index.ts +++ b/packages/assets/src/index.ts @@ -7,7 +7,6 @@ import { compare, getDefaultAgent, HashTree, - HttpAgent, lookup_path, lookupResultToBuffer, LookupStatus, @@ -537,15 +536,10 @@ class Asset { return false; } - const replicaTime = (agent as HttpAgent).replicaTime - ? (agent as HttpAgent).replicaTime - : undefined; - const cert = await Certificate.create({ certificate: new Uint8Array(certificate), rootKey: agent.rootKey, canisterId, - certTime: replicaTime, }).catch(() => Promise.resolve()); if (!cert) { diff --git a/packages/use-auth-client/package.json b/packages/use-auth-client/package.json index f1cef0f5..22d1e39f 100644 --- a/packages/use-auth-client/package.json +++ b/packages/use-auth-client/package.json @@ -68,7 +68,7 @@ }, "overrides": { "vite": { - "rollup": "npm:@rollup/wasm-node" + "rollup": "^4.22.5" } } }