
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@dfinity/utils
Advanced tools
A collection of utilities and constants for NNS/SNS projects.
You can use utils-js by installing it in your project.
npm i @dfinity/utils
The bundle needs peer dependencies, be sure that following resources are available in your project as well.
npm i @dfinity/agent @dfinity/candid @dfinity/principal
utils-js implements following features:
Get a default agent that connects to mainnet with the anonymous identity.
| Function | Type |
|---|---|
defaultAgent | () => Agent |
Create an agent for a given identity
| Function | Type |
|---|---|
createAgent | ({ identity, host, fetchRootKey, }: { identity: Identity; host?: string; fetchRootKey?: boolean; }) => Promise<HttpAgent> |
Parameters:
identity: A mandatory identity to use for the agenthost: An optional host to connect tofetchRootKey: Fetch root key for certificate validation during local development or on testnet| Function | Type |
|---|---|
createServices | <T>({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, }, idlFactory, certifiedIdlFactory, }: { options: RequiredCanisterOptions<T>; idlFactory: InterfaceFactory; certifiedIdlFactory: InterfaceFactory; }) => { ...; } |
| Function | Type |
|---|---|
uint8ArrayToBigInt | (array: Uint8Array) => bigint |
| Function | Type |
|---|---|
arrayBufferToUint8Array | (buffer: ArrayBuffer) => Uint8Array |
| Function | Type |
|---|---|
uint8ArrayToArrayOfNumber | (array: Uint8Array) => number[] |
| Function | Type |
|---|---|
arrayOfNumberToUint8Array | (numbers: number[]) => Uint8Array |
| Function | Type |
|---|---|
asciiStringToByteArray | (text: string) => number[] |
| Function | Type |
|---|---|
assertNonNullish | <T>(value: T, message?: string) => asserts value is NonNullable<T> |
| Function | Type |
|---|---|
toNullable | <T>(value?: T) => [] or [T] |
| Function | Type |
|---|---|
fromNullable | <T>(value: [] or [T]) => T |
| Function | Type |
|---|---|
fromDefinedNullable | <T>(value: [] or [T]) => T |
Convert a principal to a Uint8Array 32 length. e.g. Useful to convert a canister ID when topping up cycles with the Cmc canister
| Function | Type |
|---|---|
principalToSubAccount | (principal: Principal) => Uint8Array |
Parameters:
principal: The principal that needs to be converted to Subaccountpublic
Parameters:
messageFAQs
A collection of utilities and constants for NNS/SNS projects.
The npm package @dfinity/utils receives a total of 18,521 weekly downloads. As such, @dfinity/utils popularity was classified as popular.
We found that @dfinity/utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.