Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .changeset/two-turtles-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@armory-sh/middleware-express-v4": patch
"@armory-sh/middleware-express": patch
---

Fix Dist path
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ jobs:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Bun
uses: oven-sh/setup-bun@v2
Expand All @@ -62,10 +64,36 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Check for changesets
id: check_changesets
run: |
if [ $(find .changeset -name "*.md" -type f | wc -l) -gt 0 ]; then
echo "has_changesets=true" >> $GITHUB_OUTPUT
else
echo "has_changesets=false" >> $GITHUB_OUTPUT
fi

- name: Bump versions
if: steps.check_changesets.outputs.has_changesets == 'true'
run: bun run ci:version

- name: Commit version changes
if: steps.check_changesets.outputs.has_changesets == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add "packages/*/package.json"
git add "package.json"
git add "bun.lock"
git add ".changeset/*.md"
git commit -m "chore: version packages [skip ci]"
git push --no-verify

- name: Build
run: bun run build

- name: Publish to npm
if: steps.check_changesets.outputs.has_changesets == 'true'
run: bun run ci:publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
38 changes: 26 additions & 12 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"changeset": "changeset",
"ci:version": "changeset version && bun update",
"ci:resolve-workspaces": "node scripts/resolve-workspaces.mjs",
"ci:publish": "bun run ci:resolve-workspaces && npm publish --provenance --access public --workspaces && changeset tag",
"ci:publish:beta": "bun run ci:resolve-workspaces && npm publish --provenance --access public --tag beta --workspaces && changeset tag",
"ci:publish:alpha": "bun run ci:resolve-workspaces && npm publish --provenance --access public --tag alpha --workspaces",
"ci:publish": "bun run ci:resolve-workspaces && node scripts/publish-changed.mjs && changeset tag",
"ci:publish:beta": "bun run ci:resolve-workspaces && node scripts/publish-changed.mjs beta && changeset tag",
"ci:publish:alpha": "bun run ci:resolve-workspaces && node scripts/publish-changed.mjs alpha",
"ci:release": "bun run ci:version && bun run ci:publish",
"ci:release:beta": "bun run ci:version && bun run ci:publish:beta",
"ci:release:alpha": "bun run ci:version && bun run ci:publish:alpha"
Expand Down
4 changes: 2 additions & 2 deletions packages/base/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@armory-sh/base",
"version": "0.2.25",
"version": "0.2.26",
"license": "MIT",
"author": "Sawyer Cutler <sawyer@dirtroad.dev>",
"keywords": [
Expand All @@ -25,7 +25,7 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"bun": "./src/index.ts",
"bun": "./dist/index.js",
"default": "./dist/index.js"
},
"./dist/*": "./dist/*.js"
Expand Down
Empty file removed packages/base/src/types/arktype.ts
Empty file.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "armory-cli",
"version": "0.3.5",
"version": "0.3.6",
"description": "Scaffold x402 payment-enabled apps",
"type": "module",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/client-ethers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@armory-sh/client-ethers",
"version": "0.2.24",
"version": "0.2.25",
"license": "MIT",
"author": "Sawyer Cutler <sawyer@dirtroad.dev>",
"keywords": [
Expand Down Expand Up @@ -29,7 +29,7 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"bun": "./src/index.ts",
"bun": "./dist/index.js",
"default": "./dist/index.js"
},
"./dist/*": "./dist/*.js"
Expand Down
65 changes: 65 additions & 0 deletions packages/client-ethers/src/bytes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const textEncoder = new TextEncoder();
const textDecoder = new TextDecoder();
type BufferLike = {
from(data: Uint8Array): { toString(encoding: "base64"): string };
from(data: string, encoding: "base64"): Uint8Array;
};

function getNodeBuffer(): BufferLike | undefined {
if ("Buffer" in globalThis) {
return (globalThis as { Buffer?: BufferLike }).Buffer;
}
return undefined;
}

function toBase64(bytes: Uint8Array): string {
if (typeof btoa === "function") {
let binary = "";
for (let index = 0; index < bytes.length; index += 1) {
binary += String.fromCharCode(bytes[index]);
}
return btoa(binary);
}

const nodeBuffer = getNodeBuffer();
if (nodeBuffer) {
return nodeBuffer.from(bytes).toString("base64");
}

throw new Error("No base64 encoder available in this runtime");
}

function fromBase64(base64: string): Uint8Array {
if (typeof atob === "function") {
const binary = atob(base64);
const bytes = new Uint8Array(binary.length);
for (let index = 0; index < binary.length; index += 1) {
bytes[index] = binary.charCodeAt(index);
}
return bytes;
}

const nodeBuffer = getNodeBuffer();
if (nodeBuffer) {
return Uint8Array.from(nodeBuffer.from(base64, "base64"));
}

throw new Error("No base64 decoder available in this runtime");
}

export function encodeUtf8ToBase64(value: string): string {
const bytes = textEncoder.encode(value);
return toBase64(bytes);
}

export function decodeBase64ToUtf8(value: string): string {
const bytes = fromBase64(value);
return textDecoder.decode(bytes);
}

export function normalizeBase64Url(value: string): string {
return value
.replace(/-/g, "+")
.replace(/_/g, "/")
.padEnd(Math.ceil(value.length / 4) * 4, "=");
}
10 changes: 4 additions & 6 deletions packages/client-ethers/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import type { TransferWithAuthorizationParams, EIP712Domain } from "./types";
import { signEIP3009 } from "./eip3009";
import { PaymentError } from "./errors";
import { decodeBase64ToUtf8, encodeUtf8ToBase64, normalizeBase64Url } from "./bytes";

// ============================================================================
// Version Detection (V2 Only)
Expand Down Expand Up @@ -61,11 +62,8 @@ function parseJsonOrBase64(value: string): unknown {
} catch {
}

const normalized = value
.replace(/-/g, "+")
.replace(/_/g, "/")
.padEnd(Math.ceil(value.length / 4) * 4, "=");
return JSON.parse(Buffer.from(normalized, "base64").toString("utf-8"));
const normalized = normalizeBase64Url(value);
return JSON.parse(decodeBase64ToUtf8(normalized));
}

/**
Expand Down Expand Up @@ -235,5 +233,5 @@ export async function createX402Payment(
* Encode x402 payment payload to Base64 for transport
*/
export function encodeX402Payment(payload: PaymentPayloadV2): string {
return Buffer.from(JSON.stringify(payload)).toString("base64");
return encodeUtf8ToBase64(JSON.stringify(payload));
}
6 changes: 3 additions & 3 deletions packages/client-viem/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@armory-sh/client-viem",
"version": "0.2.24",
"version": "0.2.25",
"license": "MIT",
"author": "Sawyer Cutler <sawyer@dirtroad.dev>",
"keywords": [
Expand Down Expand Up @@ -28,12 +28,12 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"bun": "./src/index.ts",
"bun": "./dist/index.js",
"default": "./dist/index.js"
},
"./extensions": {
"types": "./dist/extensions.d.ts",
"bun": "./src/extensions.ts",
"bun": "./dist/extensions.js",
"default": "./dist/extensions.js"
},
"./dist/*": "./dist/*.js"
Expand Down
Loading