Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: "Build"
description: "Sets up environment and builds the WASM package"

inputs:
github-app-token:
description: "GitHub App token for private git deps"
required: false
default: ""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not need this if all outputs are public.

configure-git-user:
description: "Configure git user for commits"
required: false
default: "false"
node-version:
description: "Node.js version to install"
required: false
default: "24"
setup-npm-registry:
description: "Setup NPM registry URL"
required: false
default: "false"

runs:
using: "composite"
steps:
- name: Configure git for GitHub App auth (private deps and push)
if: ${{ inputs.github-app-token != '' }}
shell: bash
env:
BULLET_APP_TOKEN: ${{ inputs.github-app-token }}
run: |
git config --global --add url."https://x-access-token:${BULLET_APP_TOKEN}@github.com/".insteadOf "ssh://git@github.com/"
git config --global --add url."https://x-access-token:${BULLET_APP_TOKEN}@github.com/".insteadOf "git@github.com:"
git config --global --add url."https://x-access-token:${BULLET_APP_TOKEN}@github.com/".insteadOf "https://github.com/"
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which dependencies are needing these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None, good point, this was copied from the old js sdk

- name: Configure Git user
if: ${{ inputs.configure-git-user == 'true' }}
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.setup-npm-registry == 'true' && 'https://registry.npmjs.org' || '' }}

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Rust cache
uses: Swatinem/rust-cache@v2

- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@main
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unpinned third-party action in release publish pipeline

Medium Severity

cargo-bins/cargo-binstall@main references a mutable branch rather than a commit SHA, unlike the other actions in this pipeline (e.g., actions/checkout and actions/setup-node are SHA-pinned). Since this composite action is used in the npm-publish.yml workflow that has id-token: write permission and publishes to npm with provenance, a compromised main branch in the cargo-binstall repo could inject malicious code into the published package. At minimum, the version input available on this action could be set to pin the installed binary version.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 059ac8f. Configure here.


- name: Install wasm-pack
shell: bash
run: cargo binstall wasm-pack -y

- name: Install just
uses: extractions/setup-just@v2

- name: Install npm dependencies
shell: bash
working-directory: ./wasm
run: npm install

- name: Build WASM
shell: bash
run: just build-wasm
Comment thread
cursor[bot] marked this conversation as resolved.
83 changes: 83 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# NPM publishing uses OIDC Trusted Publishers for authentication (no NPM_TOKEN needed).
# Configure the Trusted Publisher at https://www.npmjs.com/package/@bulletxyz/sdk-wasm/access
# See: https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions

name: NPM Publish

on:
workflow_dispatch:
inputs:
branch:
description: "Branch to build and publish from"
required: true
default: "main"
type: string
level:
description: "Release level"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
- rc

env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: true
CI: 1

concurrency:
group: npm-publish
cancel-in-progress: false

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
persist-credentials: false
fetch-depth: 0

- name: Create GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.BULLET_DEPLOY_APP_ID }}
private-key: ${{ secrets.BULLET_DEPLOY_KEY }}
owner: ${{ github.repository_owner }}

- name: Configure git
env:
GITHUB_APP_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git config user.name "bullet-deploy[bot]"
git config user.email "${{ vars.BULLET_DEPLOY_APP_ID }}+bullet-deploy[bot]@users.noreply.github.com"
git config --global url."https://x-access-token:${GITHUB_APP_TOKEN}@github.com/".insteadOf "https://github.com/"

- name: Build
uses: ./.github/actions/build
with:
github-app-token: ${{ steps.app-token.outputs.token }}
setup-npm-registry: "true"

- name: Install cargo-edit
run: cargo binstall cargo-edit -y

- name: Bump + publish to npm
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot May 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: OIDC trusted publishing will fail with actions/setup-node@v4. When registry-url is set, v4 exports a placeholder NODE_AUTH_TOKEN (XXXXX-XXXXX-XXXXX-XXXXX) that takes precedence over OIDC token negotiation, causing npm publish to fail with a 404. This was fixed in actions/setup-node@v6 (see setup-node#1477). Either upgrade to actions/setup-node@v6 in the composite action, or set NODE_AUTH_TOKEN: "" in the environment of this publish step as a workaround.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/npm-publish.yml, line 75:

<comment>OIDC trusted publishing will fail with `actions/setup-node@v4`. When `registry-url` is set, v4 exports a placeholder `NODE_AUTH_TOKEN` (`XXXXX-XXXXX-XXXXX-XXXXX`) that takes precedence over OIDC token negotiation, causing `npm publish` to fail with a 404. This was fixed in `actions/setup-node@v6` (see [setup-node#1477](https://github.com/actions/setup-node/pull/1477)). Either upgrade to `actions/setup-node@v6` in the composite action, or set `NODE_AUTH_TOKEN: ""` in the environment of this publish step as a workaround.</comment>

<file context>
@@ -0,0 +1,84 @@
+      - name: Install cargo-edit
+        run: cargo binstall cargo-edit -y
+
+      - name: Bump + publish to npm
+        run: just publish-wasm ${{ inputs.level }}
+
</file context>
Fix with Cubic

run: just publish-wasm ${{ inputs.level }}
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated

- name: Commit, tag, and push
run: |
V=$(cargo pkgid -p bullet-rust-sdk-wasm | cut -d@ -f2)
git add Cargo.toml rust/Cargo.toml wasm/Cargo.toml wasm/package.json
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
git commit -m "v${V} [skip ci]"
git tag -m "v${V}" "v${V}"
git push --follow-tags
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
members = ["rust", "wasm"]
resolver = "2"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can upgrade this to 3 now with latest rust versions (we just moved to rust 1.94)


[workspace.package]
version = "0.0.9"
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
edition = "2024"
license = "MIT"
repository = "https://github.com/bulletxyz/bullet-rust-sdk"

[workspace.dependencies]
bon = "3.9.0"

Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
packages = [
rust
pkgs.cargo-nextest
pkgs.cargo-edit
pkgs.just
(makeWasmPack pkgs)
pkgs.pkg-config
Expand Down
24 changes: 24 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,30 @@ ci:

printf '\n\033[1;32m✓ All checks passed\033[0m\n'

# ── Publish ───────────────────────────────────────────────────────────────────

# Bump workspace version, build, and publish to npm (no git ops).
# Level: patch | minor | major | rc
publish-wasm level="patch":
#!/usr/bin/env bash
set -euo pipefail
case "{{ level }}" in
patch|minor|major)
cargo set-version --workspace --bump {{ level }}
;;
rc)
cargo set-version --workspace "$(cargo pkgid -p bullet-rust-sdk-wasm | cut -d@ -f2 | awk -F. '{print $1"."$2"."$3+1"-rc.0"}')"
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
;;
*)
echo "Unknown level: {{ level }}" >&2; exit 1
;;
esac
V=$(cargo pkgid -p bullet-rust-sdk-wasm | cut -d@ -f2)
cd wasm && npm version "$V" --no-git-tag-version --allow-same-version && cd ..
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
just build-wasm
tag=$([ "{{ level }}" = "rc" ] && echo "rc" || echo "latest")
cd wasm && npm publish --tag "$tag" --access public
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated

# ── OpenAPI spec ──────────────────────────────────────────────────────────────

# Fetch and cache the latest OpenAPI spec from mainnet
Expand Down
8 changes: 4 additions & 4 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "bullet-rust-sdk"
version = "0.0.4"
edition = "2024"
license = "MIT"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "Rust SDK for the Bullet trading platform"
repository = "https://github.com/bulletxyz/bullet-rust-sdk"
links = "bullet_rust_codegen"

[lib]
Expand Down
8 changes: 4 additions & 4 deletions wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "bullet-rust-sdk-wasm"
version = "0.0.4"
edition = "2024"
license = "MIT"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "WebAssembly bindings for the Bullet trading SDK"
repository = "https://github.com/bulletxyz/bullet-rust-sdk"

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
8 changes: 5 additions & 3 deletions wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bulletxyz/sdk-wasm",
"version": "0.0.4",
"version": "0.0.9",
"description": "WebAssembly bindings for the Bullet trading SDK — works in Node.js, browsers, and Deno",
"author": "Bullet.xyz",
"license": "MIT",
Expand All @@ -21,7 +21,9 @@
],
"type": "module",
"scripts": {
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
Comment thread
Firaenix marked this conversation as resolved.
"build": "cd .. && just build-wasm",
"prepublishOnly": "[ -n \"$CI\" ] || npm run build"
},
"devDependencies": {
"@jest/globals": "^30.3.0",
Expand Down Expand Up @@ -67,4 +69,4 @@
"sideEffects": [
"./pkg/node.js"
]
}
}