Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
@dfinity/utils
Advanced tools
A collection of utilities and constants for NNS/SNS projects.
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 testnetFunction | 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:
message
FAQs
A collection of utilities and constants for NNS/SNS projects.
The npm package @dfinity/utils receives a total of 7,892 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 11 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
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.