From 487f58d6afc571b2a937292443f88da27d8a81bf Mon Sep 17 00:00:00 2001 From: Kai Peacock Date: Fri, 6 Sep 2024 09:52:31 -0700 Subject: [PATCH] feat: exports polling utilities from `@dfinity/agent` --- docs/CHANGELOG.md | 3 +++ packages/agent/src/certificate.ts | 2 +- packages/agent/src/index.ts | 1 + packages/agent/src/polling/index.ts | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b50095a8..967913bd 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -14,6 +14,9 @@ - docs: documentation and metadata for use-auth-client - feat: adds optional `rootKey` to `HttpAgentOptions` to allow for a custom root key to be used for verifying signatures from other networks - chore: npm audit bumping micromatch +- feat: exports polling utilities from `@dfinity/agent` for use in other packages + - `pollForResponse` now uses the default strategy by default + - Updated the `bls-verify` jsdoc comment to accurately reflect that the default strategy now uses @noble/curves ### Changed - feat: replaces hdkey and bip32 implementations with `@scure/bip39` and `@scure/bip32` due to vulnerability and lack of maintenance for `elliptic` diff --git a/packages/agent/src/certificate.ts b/packages/agent/src/certificate.ts index a8cdf551..4e7c5eac 100644 --- a/packages/agent/src/certificate.ts +++ b/packages/agent/src/certificate.ts @@ -135,7 +135,7 @@ export interface CreateCertificateOptions { */ canisterId: Principal; /** - * BLS Verification strategy. Default strategy uses wasm for performance, but that may not be available in all contexts. + * BLS Verification strategy. Default strategy uses bls12_381 from @noble/curves */ blsVerify?: VerifyFunc; diff --git a/packages/agent/src/index.ts b/packages/agent/src/index.ts index 98608f63..cf911b7f 100644 --- a/packages/agent/src/index.ts +++ b/packages/agent/src/index.ts @@ -29,6 +29,7 @@ import { Agent, HttpAgent } from './agent'; import { IDL } from '@dfinity/candid'; export * as Cbor from './cbor'; +export * from './polling'; export interface GlobalInternetComputer { ic: { diff --git a/packages/agent/src/polling/index.ts b/packages/agent/src/polling/index.ts index 2a18bc26..ccd399eb 100644 --- a/packages/agent/src/polling/index.ts +++ b/packages/agent/src/polling/index.ts @@ -5,6 +5,7 @@ import { RequestId } from '../request_id'; import { toHex } from '../utils/buffer'; export * as strategy from './strategy'; +import { defaultStrategy } from './strategy'; export { defaultStrategy } from './strategy'; export type PollStrategy = ( canisterId: Principal, @@ -27,7 +28,7 @@ export async function pollForResponse( agent: Agent, canisterId: Principal, requestId: RequestId, - strategy: PollStrategy, + strategy: PollStrategy = defaultStrategy(), // eslint-disable-next-line request?: any, blsVerify?: CreateCertificateOptions['blsVerify'],