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