
Research
/Security News
Mini Shai-Hulud Campaign Hits Red Hat Cloud Services npm Packages
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.
@permaweb/aoconnect
Advanced tools
The `aoconnect` library provides an abstraction for spawning, evaluating, and interacting with `ao` Processes.
ao ConnectThe aoconnect library provides an abstraction for spawning, evaluating, and
interacting with ao Processes.
This module will run in a browser or server environment.
ao Message evaluation from a ao Compute Unit cuao Process to an ao Message Unit muao Process, assigning it to an ao Scheduler Unit suThis module can be used on the server, as well as the browser:
moduleimport { message, result, spawn } from "@permaweb/aoconnect";
commonjsconst { spawn, message, result } = require("@permaweb/aoconnect");
The duration of this document will use ESM for examples
resultRead the result of the message evaluation from an ao Compute Unit cu
import { result } from "@permaweb/aoconnect";
let { messages, spawns, output, error } = await result({
message: "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
process: "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg",
});
resultsRead a batch of results from a process, this feature can be used as a polling mechanism looking for new results
import { results } from "@permaweb/aoconnect";
let results = await results({
process: "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg",
from: cursor,
sort: "ASC",
limit: 25,
});
Parameters
| Name | Description | Optional? |
|---|---|---|
| process | the process identifier | false |
| from | cursor starting point | true |
| to | cursor ending point | true |
| sort | list results in decending or ascending order, default will be ASC | true |
| limit | the number of results to return (default: 25) | true |
messagesend a message to an ao Message Unit mu targeting an ao process.
import { createDataItemSigner, message } from "@permaweb/aoconnect";
const messageId = await message({
process,
signer: createDataItemSigner(wallet),
anchor,
tags,
data,
});
You can pass a 32 byte
anchortomessagewhich will be set on the DataItem
spawnSpawn an ao process, assigning the ao Scheduler to schedule its messages
import { createDataItemSigner, spawn } from "@permaweb/aoconnect";
const processId = await spawn({
module,
scheduler,
signer: createDataItemSigner(wallet),
tags,
data,
});
connectIf you would like the connect to use ao components other than the defaults, you
can specify those components by providing their urls to connect. You can
currently specify:
GATEWAY_URL)MU_URL)CU_URL)import { connect } from "@permaweb/aoconnect";
const { spawn, message, result } = connect({
GATEWAY_URL: "...",
MU_URL: "...",
CU_URL: "...",
});
If any url is not provided, a library default will be used. In this sense,
invoking connect() with no parameters or an empty object is functionally
equivalent to using the top-lvl exports of the library:
import {
spawn,
message,
result
connect
} from '@permaweb/aoconnect';
// These are functionally equivalent
connect() == { spawn, message, result }
monitorWhen using cron messages, ao users need a way to start injesting the messages, using this monitor method, ao users can initiate the subscription service for cron messages.
import { createDataItemSigner, monitor } from "@permaweb/aoconnect";
const result = await monitor({
process,
signer: createDataItemSigner(wallet),
});
The library also allows configuring ao components described above, using environment variables.
On NodeJS, you can use process.env to set these values.
In the browser, you can use globalThis to set these values.
In both cases, you should set environment variables prior to importing the module. If this is not possible, consider using
connectand passing in values from the environment that way.
createDataItemSignermessage and spawn both require signing a DataItem with a wallet.
createDataItemSigner is a convenience api that, given a wallet, returns a
function that can be passed to both message and spawn in order to properly
sign DataItems.
The library provides a browser compatible and node compatible version that you can use OOTB.
The browser compatible versions expects an instance of window.arweaveWallet
to be passed to it:
import { createDataItemSigner } from "@permaweb/aoconnect";
const signer = createDataItemSigner(globalThis.arweaveWallet);
The node compatible versions expects a JWK interface to be passed to it:
import fs from "node:fs";
import { createDataItemSigner } from "@permaweb/aoconnect";
const wallet = JSON.parse(fs.readFileSync(process.env.PATH_TO_WALLET));
const signer = createDataItemSigner(wallet);
You can also implement your own createDataItemSigner, as long as it satisfies
the api. Here is what the API looks like in TypeScript:
type CreateDataItemSigner = (wallet: any):
(args: { data: any, tags?: { name: string, value: string}[], target?: string, anchor?: string }):
Promise<{ id: string, raw: ArrayBuffer }>
You can enable verbose debug logging on the library. All logging is scoped under
the name @permaweb/aoconnect*. You can use wildcards to enable a subset of
logs ie. @permaweb/aoconnect/result*
For Node, set the DEBUG environment variable to the logs you're interested in.
For the Browser, set the localStorage.debug variable to the logs you're
interested in.
Run npm test to run the tests.
Run npm run test:integration to run the integration tests.
The aoconnect project loosely implements the
Ports and Adapters
Architecture.
All business logic is in lib where each public api is implemented and tested.
dal.js contains the contracts for the driven adapters aka side-effects.
Implementations for those contracts are injected into, then parsed and invoked
by, the business logic. This is how we inject specific integrations for
providers ie. Warp, Irys, or even platforms specific implementations like
node and the browser while keeping them separated from the business logic --
the business logic simply consumes a black-box API -- easy to stub, and easy to
unit test.
Because the contract wrapping is done by the business logic itself, it also ensures the stubs we use in our unit tests accurately implement the contract API. Thus our unit tests are simoultaneously contract tests.
client contains implementations, of the contracts in dal.js, for various
platforms. The unit tests for the implementations in client also import
contracts from dal.js to help ensure that the implementation properly
satisfies the API.
Finally, the entrypoints (index.js for Node and index.browser.js for the
Browser) orchestrate everything, choosing the appropriate implementations from
client and injecting them into the business logic from lib.
FAQs
The `aoconnect` library provides an abstraction for spawning, evaluating, and interacting with `ao` Processes.
The npm package @permaweb/aoconnect receives a total of 4,492 weekly downloads. As such, @permaweb/aoconnect popularity was classified as popular.
We found that @permaweb/aoconnect demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.

Research
/Security News
The North Korean malware loader hides in a Packagist-listed package and its GitHub branch to fetch and execute remote code in a likely Contagious Interview-style lure.

Security News
The Rust project is moving toward formal rules on LLM use in contributions after months of internal debate over maintainer burden, code quality, and contributor experience.