Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
dd700c0
feat: add typed environment configuration and @SandboxOnly decorator
fahmidareem3 Feb 5, 2026
0b774d6
Merge origin/main into SDK-20
fahmidareem3 Feb 5, 2026
a2705b9
Merge pull request #16 from oak-network/main
fahmidareem3 Feb 5, 2026
68aaf84
fix: update integration tests for Result pattern
fahmidareem3 Feb 5, 2026
ec1f4ef
fix: add environment variables to CI workflow
fahmidareem3 Feb 5, 2026
61edf44
fix: async error handling in SandboxOnly and lazy env URL resolution
fahmidareem3 Feb 5, 2026
8de703c
fix: restore tsconfig rootDir to ./src for valid package exports
fahmidareem3 Feb 5, 2026
02537c4
fix: preserve method contracts in SandboxOnly and fix tsconfig for IDE
fahmidareem3 Feb 5, 2026
35c1ac5
refactor: hardcode environment URLs as SDK constants
fahmidareem3 Feb 5, 2026
8e5af5b
fix: add the oak environment field to the sample env
fahmidareem3 Feb 5, 2026
e9337cf
chore: enhance httpClient to include Oak-Version in headers (#18)
lucasvinhas Feb 5, 2026
90a385c
Merge pull request #12 from oak-network/SDK-20
fahmidareem3 Feb 6, 2026
3d46b6f
refactor(api): centralize Result-based errors in httpClient
Fahad-CCP Feb 6, 2026
2fa79dc
chore: add changeset for Result-based httpClient errors
Fahad-CCP Feb 6, 2026
8d9d5a9
fix(api): stop retries after abort signal in httpClient
Fahad-CCP Feb 6, 2026
3a857c7
refactor: refactored req res types
tahseen-ccprotocol Feb 6, 2026
0e71e56
Merge pull request #19 from oak-network/feature/http-client
Fahad-CCP Feb 9, 2026
edac706
feat: updated typescript types according to API
tahseen-ccprotocol Feb 9, 2026
7b504bb
fix: fixed webhook delete function type
tahseen-ccprotocol Feb 9, 2026
537cf6d
merged with develop
tahseen-ccprotocol Feb 9, 2026
13965ac
added changeset
tahseen-ccprotocol Feb 9, 2026
8227b20
feat: added refund service
tahseen-ccprotocol Feb 10, 2026
97ae029
Merge pull request #20 from oak-network/sdk-34
tahseen-ccprotocol Feb 10, 2026
e3d3946
feat: updated unit test for refund service
tahseen-ccprotocol Feb 10, 2026
c244dad
Merge pull request #21 from oak-network/sdk-34
tahseen-ccprotocol Feb 10, 2026
9802723
fix: handle non-JSON error responses in httpClient
fahmidareem3 Feb 13, 2026
c1f1d5e
fix: increase timeout for customerService integration tests
fahmidareem3 Feb 13, 2026
3315c34
chore: add changeset for httpClient fix and test timeout improvements
fahmidareem3 Feb 13, 2026
9efbb07
fix(http): normalize null JSON body before building ApiError
fahmidareem3 Feb 13, 2026
cb6dd8e
feat: update the stage url
fahmidareem3 Feb 13, 2026
604c530
refactor: centralize environment URLs in single exported constant
fahmidareem3 Feb 16, 2026
312bb7a
Merge pull request #22 from oak-network/SDK-62
fahmidareem3 Feb 16, 2026
7584f11
test: updated integration test of customer for us clients
tahseen-ccprotocol Feb 17, 2026
4b360a9
test: added stripe manual payout integration test
tahseen-ccprotocol Feb 17, 2026
96805ef
feat: add integration tests for webhook service
fahmidareem3 Feb 17, 2026
ea7bc0c
chore: added changeset
tahseen-ccprotocol Feb 17, 2026
2e02fcf
fix: rename transaction_list to notification_list in webhook types
fahmidareem3 Feb 18, 2026
e254cc6
chore: added guard if no customer found
tahseen-ccprotocol Feb 18, 2026
be92489
Merge pull request #24 from oak-network/sdk-51
tahseen-ccprotocol Feb 18, 2026
696c07e
Merge pull request #23 from oak-network/SDK-56
fahmidareem3 Feb 18, 2026
94bb175
feat: add integration tests for payment method service
fahmidareem3 Feb 19, 2026
f2f31cd
feat: add TSDoc to core types and client factory
fahmidareem3 Feb 20, 2026
9782f56
Merge pull request #25 from oak-network/SDK-53
fahmidareem3 Feb 20, 2026
1504f77
feat: added sync API in customer service
tahseen-ccprotocol Feb 20, 2026
3a02619
docs: add TSDoc to error classes and SandboxOnly decorator
fahmidareem3 Feb 20, 2026
e08a0f7
docs: add TSDoc to HTTP client and retry utilities
fahmidareem3 Feb 20, 2026
19c41a0
docs: add TSDoc to service factory functions
fahmidareem3 Feb 20, 2026
b6bd00f
docs: complete TSDoc coverage for remaining functions
fahmidareem3 Feb 20, 2026
8b5e9f8
chore: add changeset for TSDoc documentation
fahmidareem3 Feb 20, 2026
3d3993c
Merge pull request #26 from oak-network/SDK-70
fahmidareem3 Feb 20, 2026
c86a0b8
feat: integrated sync and balance api in customer service
tahseen-ccprotocol Feb 20, 2026
44cee69
added change set
tahseen-ccprotocol Feb 20, 2026
d498a7a
Sdk 52
lucasvinhas Feb 20, 2026
855ab0b
Refactor code structure for improved readability and maintainability
0xrafasec Feb 20, 2026
6d6a082
chore: update pnpm engine requirement to version 10.0.0
0xrafasec Feb 20, 2026
cc6ab4f
fix: update CI and release workflows to exclude contracts from build …
0xrafasec Feb 20, 2026
48ecfc2
refactor: remove unused authService and config types; delete test-sdk…
0xrafasec Feb 20, 2026
fc0912b
fix: update devDependencies for dotenv and nock; remove unused depend…
0xrafasec Feb 20, 2026
b90c470
fix: add comment for clarity on experimentalDecorators in tsconfig
0xrafasec Feb 20, 2026
b01513e
fix: improve error handling in payment method tests for missing prere…
0xrafasec Feb 20, 2026
0b62d2b
fix: improve error handling in transfer service tests for missing cus…
0xrafasec Feb 20, 2026
58d7314
fix: improve error handling in webhook service tests for missing crea…
0xrafasec Feb 20, 2026
f25d7b4
test: add unit tests for buildUrl utility function
0xrafasec Feb 20, 2026
37b0a78
test: add unit tests for webhook verification and payload parsing
0xrafasec Feb 20, 2026
9ec4570
test: add unit tests for withAuth utility function
0xrafasec Feb 20, 2026
99f82c3
fix: convert token expiration from seconds to milliseconds in AuthMan…
0xrafasec Feb 20, 2026
74c22b3
fix: update createOakClient to return public config without clientSec…
0xrafasec Feb 20, 2026
8eaa745
refactor: simplify create method in BuyService by using withAuth and …
0xrafasec Feb 20, 2026
5eb9b28
refactor: streamline customer service methods by utilizing withAuth a…
0xrafasec Feb 20, 2026
8b589f2
refactor: replace token retrieval with withAuth in PaymentMethodServi…
0xrafasec Feb 20, 2026
d7f6c2a
refactor: replace manual token retrieval with withAuth in PaymentServ…
0xrafasec Feb 20, 2026
9e0e509
refactor: replace manual token handling with withAuth in PlanService …
0xrafasec Feb 20, 2026
238816c
refactor: replace manual token handling with withAuth in ProviderServ…
0xrafasec Feb 20, 2026
e7fa817
refactor: replace manual token handling with withAuth in RefundServic…
0xrafasec Feb 20, 2026
f6971c9
refactor: replace manual token handling with withAuth in SellService …
0xrafasec Feb 20, 2026
465f691
refactor: replace manual token handling with withAuth in TransactionS…
0xrafasec Feb 20, 2026
df6e7d8
refactor: replace manual token handling with withAuth in TransferServ…
0xrafasec Feb 20, 2026
6138703
refactor: replace manual token handling with withAuth in WebhookServi…
0xrafasec Feb 20, 2026
1dea0b9
refactor: update CrowdsplitProduct interface to use service types and…
0xrafasec Feb 20, 2026
89909d0
refactor: remove unused getErrorBodyMessage function from helpers
0xrafasec Feb 20, 2026
a204aea
refactor: remove authService exports from services index
0xrafasec Feb 20, 2026
c049cab
refactor: update OakClient config to use PublicOakClientConfig for se…
0xrafasec Feb 20, 2026
a58d228
refactor: add customer identifier fields with documentation in Data i…
0xrafasec Feb 20, 2026
18cf349
refactor: remove unused config export from types index
0xrafasec Feb 20, 2026
42705ba
refactor: update Transaction interface to include provider, source, c…
0xrafasec Feb 20, 2026
e9e9ea7
refactor: restructure TransferData type for clarity and consistency
0xrafasec Feb 20, 2026
35fb74d
feat: add buildUrl function for consistent URL construction with trai…
0xrafasec Feb 20, 2026
68eff3c
refactor: change data type from any to unknown in post, put, and patc…
0xrafasec Feb 20, 2026
744dd5d
refactor: add missing exports for withAuth, buildUrl, and webhookVeri…
0xrafasec Feb 20, 2026
4da6885
refactor: improve error handling in withRetry function for better typ…
0xrafasec Feb 20, 2026
5a44430
feat: implement webhook signature verification and payload parsing fu…
0xrafasec Feb 20, 2026
bdba8ca
feat: add withAuth function for authenticated HTTP operations
0xrafasec Feb 20, 2026
b34dead
docs: update README with comprehensive SDK usage examples and securit…
0xrafasec Feb 20, 2026
a4ce548
docs: add comprehensive AI development guidelines for Oak SDK
0xrafasec Feb 20, 2026
fc90e26
chore: add comprehensive changelog documenting notable changes, featu…
0xrafasec Feb 20, 2026
5ce3d18
refactor: clean type safety
tahseen-ccprotocol Feb 20, 2026
da8727b
test: added test coverage
tahseen-ccprotocol Feb 20, 2026
a76f558
feat: add PAYMENT_CUSTOMER_ID to environment configuration and update…
0xrafasec Feb 20, 2026
c762d2b
fix: refactor customer creation tests to use timestamp for unique ema…
0xrafasec Feb 20, 2026
2780285
fix: enhance test customer setup to prioritize environment configuration
0xrafasec Feb 20, 2026
e865e03
fix: remove unused getErrorBodyMessage test from service helpers
0xrafasec Feb 20, 2026
f066016
fix: add optional id field to Customer Data interface
0xrafasec Feb 20, 2026
4859d07
fix: update config preservation test to ensure clientSecret is not ex…
0xrafasec Feb 20, 2026
cee1c98
fix: remove clientSecret from client configuration and auth service d…
0xrafasec Feb 20, 2026
6ba7f8d
fix: update error handling in webhook verification tests to streamlin…
0xrafasec Feb 20, 2026
9ec70d8
fix: simplify error handling in withAuth tests by removing unnecessar…
0xrafasec Feb 20, 2026
d24f960
feat: add example .env file for API credentials and configuration
0xrafasec Feb 20, 2026
039792f
feat: add comprehensive examples and documentation for Oak SDK usage
0xrafasec Feb 20, 2026
17d510a
feat: add authentication example demonstrating OAuth 2.0 client crede…
0xrafasec Feb 20, 2026
0240fc5
feat: add shared configuration helper for Oak SDK examples
0xrafasec Feb 20, 2026
6f284a4
feat: add simple logging utility for consistent console output in exa…
0xrafasec Feb 20, 2026
66d1cab
feat: add create customer example with error handling and logging
0xrafasec Feb 20, 2026
ee193bc
feat: add get customer example with error handling and logging
0xrafasec Feb 20, 2026
20b1283
feat: add list customers example with pagination and email filtering
0xrafasec Feb 20, 2026
39f5ba3
feat: add update customer example with error handling and logging
0xrafasec Feb 20, 2026
9346bc5
feat: add example for adding bank account payment method with error h…
0xrafasec Feb 20, 2026
91cfd09
feat: add example for adding PIX payment method with error handling a…
0xrafasec Feb 20, 2026
caa3afc
feat: add example for deleting a payment method with error handling a…
0xrafasec Feb 20, 2026
90fb42f
feat: add example for listing payment methods with filtering and erro…
0xrafasec Feb 20, 2026
22d6b1f
feat: add example for managing webhooks with listing, updating, toggl…
0xrafasec Feb 20, 2026
006f9db
feat: add example for registering a webhook with configuration and er…
0xrafasec Feb 20, 2026
e1bfa84
feat: add example for verifying webhook signatures with detailed logg…
0xrafasec Feb 20, 2026
38238a5
feat: add complete payment flow workflow example with customer setup,…
0xrafasec Feb 20, 2026
252de4f
feat: add complete customer onboarding workflow example with payment …
0xrafasec Feb 20, 2026
1c0f2e4
fix: update error handling in webhook verification and parsing functions
0xrafasec Feb 20, 2026
b06a488
feat: add Quick Start Guide for Oak SDK examples with setup and usage…
0xrafasec Feb 20, 2026
b976f0b
fix: improve type safety and documentation in Crowdsplit facade and H…
0xrafasec Feb 20, 2026
783fa47
fix: lower coverage thresholds in Jest configuration to 90%
0xrafasec Feb 20, 2026
0e6595b
fix: update pnpm workspace configuration and add minimatch override
0xrafasec Feb 20, 2026
a765195
fix: update pnpm overrides for minimatch and test-exclude to address …
0xrafasec Feb 20, 2026
c2d9565
Merge pull request #28 from oak-network/sdk-87
tahseen-ccprotocol Feb 23, 2026
d06db3f
feat(tests): add integration tests for TransactionService (#30)
lucasvinhas Feb 23, 2026
c20c0a7
Sdk 55 (#32)
lucasvinhas Feb 24, 2026
7c55753
fix: update customer creation tests to remove unnecessary fields and …
0xrafasec Feb 24, 2026
5b2a554
test: enhance CustomerService integration tests with create, get, upd…
0xrafasec Feb 24, 2026
63e0351
fix: remove coverage flag from integration tests in package.json for …
0xrafasec Feb 24, 2026
1e88823
test: refactor PaymentMethodService integration tests for improved cu…
0xrafasec Feb 24, 2026
a67e693
test: update DEFAULT_RETRY_OPTIONS onRetry test to reflect its undefi…
0xrafasec Feb 24, 2026
c874a6a
fix: enhance AuthManager to handle token refresh more efficiently and…
0xrafasec Feb 24, 2026
2146f15
refactor: remove default onRetry logging from DEFAULT_RETRY_OPTIONS, …
0xrafasec Feb 24, 2026
a927abc
docs: update QUICK_START.md to specify Stripe for payment methods and…
0xrafasec Feb 24, 2026
912f72d
docs: update README.md to specify Stripe for payment methods and rena…
0xrafasec Feb 24, 2026
38f5ac3
refactor: enhance customer ID resolution logic by adding functions to…
0xrafasec Feb 24, 2026
23f4a87
refactor: simplify customer creation example to focus on email-only i…
0xrafasec Feb 24, 2026
04eb312
refactor: streamline customer retrieval example by resolving customer…
0xrafasec Feb 24, 2026
c3936a4
refactor: update customer example to focus on email updates, streamli…
0xrafasec Feb 24, 2026
9ebd42e
refactor: update add-bank-account example to specify Stripe, enhance …
0xrafasec Feb 24, 2026
e8a5029
refactor: update add-pix example to clarify that only Stripe is suppo…
0xrafasec Feb 24, 2026
b2c67fd
refactor: improve delete payment method example by enhancing customer…
0xrafasec Feb 24, 2026
31a9659
refactor: enhance list payment methods example by specifying Stripe, …
0xrafasec Feb 24, 2026
1d88399
refactor: update complete payment flow example to specify Stripe, enh…
0xrafasec Feb 24, 2026
b3fdfe0
refactor: simplify customer onboarding workflow to focus on email-onl…
0xrafasec Feb 24, 2026
f402a51
chore: add backlog for API improvements and bug fixes, prioritizing c…
0xrafasec Feb 24, 2026
8423fa0
feat: add common types export to API type definitions for improved mo…
0xrafasec Feb 24, 2026
249dcc5
fix: add missing 'err' import in customerService for error handling
0xrafasec Feb 24, 2026
ece327f
chore: remove completed tasks from API backlog to maintain clarity an…
0xrafasec Feb 24, 2026
50beb12
Merge pull request #31 from oak-network/fix/enhance-codebase
0xrafasec Feb 24, 2026
df2bf32
Merge origin/main into develop
fahmidareem3 Feb 25, 2026
f68d65a
Merge pull request #35 from oak-network/sync/main-into-develop
fahmidareem3 Feb 25, 2026
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
5 changes: 5 additions & 0 deletions .changeset/flat-teams-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@oaknetwork/api": patch
---

chore: enhance httpClient to include Oak-Version in headers#18
5 changes: 5 additions & 0 deletions .changeset/fruity-clouds-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@oaknetwork/api': minor
---

Add typed environment configuration and @SandboxOnly decorator
5 changes: 5 additions & 0 deletions .changeset/heavy-eggs-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@oaknetwork/api': patch
---

Add TSDoc documentation to SDK public API
5 changes: 5 additions & 0 deletions .changeset/hot-lions-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@oaknetwork/api': minor
---

Add integration tests for WebhookService covering CRUD operations, toggle, and notifications endpoints
5 changes: 5 additions & 0 deletions .changeset/quick-eyes-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@oaknetwork/api': minor
---

Fix httpClient to return ApiError for non-JSON API error responses
5 changes: 5 additions & 0 deletions .changeset/seven-hornets-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@oaknetwork/api": minor
---

added sync and balance API
5 changes: 5 additions & 0 deletions .changeset/soft-plums-say.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@oaknetwork/api": major
---

Updated types of all request response
5 changes: 5 additions & 0 deletions .changeset/solid-rules-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@oaknetwork/api": major
---

updated customer test for US clients, added test for transfer
5 changes: 5 additions & 0 deletions .changeset/some-bottles-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@oaknetwork/api': minor
---

Add Payment Method Service Integration Tests
5 changes: 5 additions & 0 deletions .changeset/yellow-snails-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@oaknetwork/api": major
---

Refactor httpClient to return Result<T, OakError> and centralize error handling (breaking change).
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ jobs:
run: pnpm changeset:status

- name: Build all packages
run: pnpm -r --workspace-concurrency=Infinity build
run: pnpm -r --workspace-concurrency=Infinity --filter=!@oaknetwork/contracts build

- name: Run tests with coverage (enforces 100% threshold)
run: pnpm -r --workspace-concurrency=Infinity test --coverage
run: pnpm -r --workspace-concurrency=Infinity --filter=!@oaknetwork/contracts test --coverage
env:
CI: true
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
BASE_URL: ${{ secrets.BASE_URL }}
OAK_ENVIRONMENT: sandbox

- name: Upload coverage reports
uses: actions/upload-artifact@v4
Expand All @@ -58,5 +58,4 @@ jobs:
retention-days: 30

- name: Run lint
run: pnpm -r --workspace-concurrency=Infinity lint
continue-on-error: true
run: pnpm -r --workspace-concurrency=Infinity --filter=!@oaknetwork/contracts lint
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ jobs:

- name: Build packages
if: steps.changesets.outputs.hasChangesets == 'false'
run: pnpm build
run: pnpm --filter=!@oaknetwork/contracts build

- name: Update npm for OIDC support
if: steps.changesets.outputs.hasChangesets == 'false'
run: |
npm install -g npm@latest
npm install -g npm@10.9.2
npm --version

- name: Publish packages
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ coverage/
.yarn-cache/
.yarn-integrity

### Wrong package manager lockfiles (use pnpm)
package-lock.json
**/package-lock.json

### Lint/test caches
.eslintcache
.jest-cache/
Expand All @@ -101,5 +105,9 @@ coverage/
storage/
init-queues.sh

### Test and scratch files
test-sdk.ts
**/test-sdk.ts

.specstory
.specstory/** */
17 changes: 16 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,20 @@
"**/.trunk/*plugins/": true,
"**/.git/**": true,
"**/.vscode/**": true
}
},
"jest.runMode": "on-demand",
"jest.virtualFolders": [
{
"name": "api",
"rootPath": "packages/api",
"jestCommandLine": "node packages/api/scripts/jest-run-exact.js --",
"pathToConfig": "jest.config.js"
},
{
"name": "contracts",
"rootPath": "packages/contracts",
"jestCommandLine": "pnpm --filter @oaknetwork/contracts test --",
"pathToConfig": "jest.config.js"
}
]
}
232 changes: 232 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# Changelog

All notable changes to the Oak SDK will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- **Webhook Verification Utilities**: New `verifyWebhookSignature()` and `parseWebhookPayload()` functions for secure webhook handling using HMAC-SHA256 with timing-safe comparison
- **RefundService**: Added to Crowdsplit product facade, exposing refund functionality that was previously available but not exposed
- **Helper Utilities**:
- `withAuth()`: Higher-order function for wrapping HTTP operations with authentication (eliminates 35+ duplications)
- `buildUrl()`: Centralized URL construction with consistent trailing slash handling (standardizes 36+ URL constructions)
- **Comprehensive Unit Tests**: Added test coverage for all new utility functions
- **AI Development Guidelines**: Created `CLAUDE.md` with comprehensive coding standards and best practices

### Fixed

- **Critical Token Expiration Bug**: Fixed OAuth token expiration calculation - `expires_in` is in seconds but `Date.now()` returns milliseconds. Now correctly multiplies by 1000
- **Integration Test Silent Skips**: Replaced 20+ silent test skips (console.warn + return) with explicit error throws for accurate test reporting
- **Payment URL Inconsistency**: Removed inconsistent trailing slash from payment service URL construction

### Changed

- **BREAKING**: `client.config.clientSecret` is no longer accessible for security reasons. Store credentials separately and only pass to `createOakClient()`
- **BREAKING**: Removed `createAuthService()` wrapper - use `client.getAccessToken()` and `client.grantToken()` directly
- **Type System Improvements**:
- Replaced `any` with `unknown` in httpClient methods (`post`, `put`, `patch`) and retryHandler for better type safety
- Converted `ReturnType<typeof>` to direct interface imports in Crowdsplit facade
- Converted intersection types to standalone interfaces in Payment and Transfer types
- **Dependency Updates**:
- Moved `nock` and `dotenv` from dependencies to devDependencies (reduces production bundle size)
- Updated `ts-jest` from `^29.4.1` to `^29.4.6`
- Engine requirement updated: `pnpm >= 10.0.0` (was `>= 8.0.0`)
- **CI/CD Improvements**:
- Removed `continue-on-error` from lint step - lint failures now block PRs
- Excluded `@oaknetwork/contracts` placeholder package from CI builds
- Pinned npm version in release workflow to `10.9.2` for deterministic builds
- Added `package-lock.json` to .gitignore (enforces pnpm as canonical package manager)

### Removed

- **Dead Code**: Deleted unused `getErrorBodyMessage()` function (14 lines)
- **Unused Types**: Deleted unused `SDKConfig` type and `src/types/config.ts`
- **Scratch Files**: Deleted `test-sdk.ts` (200+ lines with hardcoded UUIDs) and added to .gitignore
- **Lockfiles**: Removed npm lockfiles from root and api package

### Internal

- **Service Refactoring**: All 11 service files refactored to use new `withAuth` and `buildUrl` helpers
- Net reduction: 75 lines of code
- Eliminated ~300 lines of duplicated token-fetch code
- Standardized URL construction across all services
- **TypeScript Config**: Added comment explaining `experimentalDecorators` requirement for `@SandboxOnly` decorator

## Migration Guide

### Breaking Changes in v0.2.0

#### 1. `clientSecret` No Longer Accessible

**Before:**

```typescript
const client = createOakClient({
environment: "sandbox",
clientId: "your-client-id",
clientSecret: "your-client-secret",
});

// This no longer works:
console.log(client.config.clientSecret); // ❌ undefined
```

**After:**

```typescript
// Store secret separately if needed for logging/debugging
const clientSecret = process.env.CLIENT_SECRET;

const client = createOakClient({
environment: "sandbox",
clientId: process.env.CLIENT_ID,
clientSecret, // Pass it in, but don't access it later
});

// Secret is NOT exposed on client.config for security
```

**Why**: Prevents accidental secret exposure through logging, serialization, or error messages.

#### 2. `createAuthService()` Removed

**Before:**

```typescript
import { createAuthService } from "@oaknetwork/api";

const auth = createAuthService(client);
const token = await auth.getAccessToken();
```

**After:**

```typescript
// Use client methods directly
const token = await client.getAccessToken();
const tokenResponse = await client.grantToken();
```

**Why**: Zero-value wrapper that added no functionality.

#### 3. Stricter Type Checking

**Before:**

```typescript
// Any type accepted
httpClient.post(url, anyData, config);
```

**After:**

```typescript
// Unknown type requires explicit typing
httpClient.post<ResponseType>(url, requestData as RequestType, config);
```

**Why**: Better type safety prevents runtime errors.

### New Features

#### Webhook Verification

```typescript
import { verifyWebhookSignature, parseWebhookPayload } from "@oaknetwork/api";

// Option 1: Verify signature only
app.post("/webhook", (req, res) => {
const isValid = verifyWebhookSignature(
JSON.stringify(req.body),
req.headers["x-oak-signature"] as string,
process.env.WEBHOOK_SECRET,
);

if (!isValid) {
return res.status(401).send("Invalid signature");
}

// Process webhook...
});

// Option 2: Verify and parse in one step
app.post("/webhook", (req, res) => {
const result = parseWebhookPayload<PaymentEvent>(
JSON.stringify(req.body),
req.headers["x-oak-signature"] as string,
process.env.WEBHOOK_SECRET,
);

if (!result.ok) {
return res.status(401).send(result.error.message);
}

const event = result.value;
// Handle event...
});
```

#### RefundService Now Available

```typescript
import { Crowdsplit } from "@oaknetwork/api/products/crowdsplit";

const crowdsplit = Crowdsplit(client);

// Refund service is now exposed
const result = await crowdsplit.refunds.create({
transaction_id: "txn_123",
amount: 1000,
});
```

### Upgrade Steps

1. **Update Package**:

```bash
pnpm update @oaknetwork/api@latest
```

2. **Remove `clientSecret` Access**:

- Search codebase for `client.config.clientSecret`
- Store separately if needed for non-SDK purposes
- Update to use environment variables

3. **Replace `createAuthService()`**:

- Search for `createAuthService`
- Replace with direct `client.getAccessToken()` or `client.grantToken()` calls
- Remove import

4. **Add Type Assertions** (if needed):

- TypeScript may require type assertions for HTTP client methods
- Add `as RequestType` where compiler indicates `unknown` cannot be assigned

5. **Test Thoroughly**:
- Run full test suite
- Verify authentication still works
- Check webhook handling if applicable

## [0.1.0] - 2026-02-XX

### Added

- Initial release of Oak SDK
- Support for Crowdsplit API
- Customer, Payment, PaymentMethod, Transaction services
- Transfer, Webhook, Plan, Buy, Sell services
- OAuth 2.0 client credentials flow
- TypeScript type definitions
- Comprehensive test suite
- Result type pattern for error handling

---

For more details, see the [GitHub Releases](https://github.com/oak-network/sdk/releases) page.
Loading