@brninpay/sdk 0.1.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
-
2
- > @brninpay/sdk@0.1.0 build /home/runner/work/brninpay/brninpay/packages/sdk
3
- > tsc
4
-
1
+
2
+ > @brninpay/sdk@1.1.0 build /home/bernieweb3/Downloads/runtimee/packages/sdk
3
+ > tsc
4
+
@@ -0,0 +1,4 @@
1
+
2
+ > @brninpay/sdk@0.1.0 typecheck /home/bernieweb3/Downloads/runtimee/packages/sdk
3
+ > tsc --noEmit
4
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ # @brninpay/sdk
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ea45d4c: Minor fixes
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ea45d4c]
12
+ - @brninpay/core@1.1.0
13
+
14
+ ## 1.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - 5fc7f42: Brninpay is here! From BernieWeb3 a.k.a NxBern with love :3
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [5fc7f42]
23
+ - @brninpay/core@1.0.0
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2026 Runtimee Authors
1
+ Copyright 2026 Brninpay Authors
2
2
 
3
3
  Apache License
4
4
  Version 2.0, January 2004
package/README.md CHANGED
@@ -1,5 +1,238 @@
1
- # @runtimee/sdk
1
+ # @brninpay/sdk
2
2
 
3
- Developer-facing API for Runtimee.
3
+ Developer-facing API for Brninpay. Create financial actors, define spending policies, and let autonomous systems spend USDC within constraints.
4
4
 
5
- Create financial actors, define spending policies, and let autonomous systems spend USDC within constraints.
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @brninpay/sdk
9
+ ```
10
+
11
+ Requires `@brninpay/core` as a peer dependency.
12
+
13
+ ## Usage
14
+
15
+ ### Quick Start
16
+
17
+ ```ts
18
+ import { Brninpay } from '@brninpay/sdk'
19
+
20
+ const bp = new Brninpay({
21
+ apiKey: 'bp_key_...',
22
+ baseUrl: 'https://api.brninpay.dev',
23
+ })
24
+
25
+ // Create an actor with a monthly budget
26
+ const actor = await bp.actors.create({
27
+ name: 'my-agent',
28
+ budget: { amount: '1000', currency: 'USDC', period: 'monthly' },
29
+ policies: [{ type: 'allowlist' }],
30
+ })
31
+
32
+ // Pay USDC within policy constraints
33
+ const receipt = await bp.actors.pay(actor.id, {
34
+ target: '0xrecipient...',
35
+ amount: '50',
36
+ purpose: { type: 'service', id: 'job_001', description: 'API call' },
37
+ })
38
+ ```
39
+
40
+ ### Actors
41
+
42
+ ```ts
43
+ const actor = await bp.actors.create({ name, budget, policies })
44
+ const status = await bp.actors.status(actorId)
45
+ const preview = await bp.actors.previewPay(actorId, { target, amount, purpose })
46
+ const receipt = await bp.actors.pay(actorId, { target, amount, purpose })
47
+ ```
48
+
49
+ ### Payment Intents
50
+
51
+ Full payment lifecycle with idempotency:
52
+
53
+ ```ts
54
+ const pi = await bp.paymentIntents.create({
55
+ workspaceId: 'ws_...',
56
+ actorId: 'act_...',
57
+ amount: { currency: 'USDC', value: '500' },
58
+ recipient: { address: '0x...', chainId: 8453 },
59
+ idempotencyKey: 'unique-key',
60
+ })
61
+
62
+ // Poll until terminal
63
+ const confirmed = await bp.paymentIntents.get(pi.id, { waitForTerminalState: true })
64
+
65
+ // Preview without creating
66
+ const preview = await bp.paymentIntents.preview({
67
+ workspaceId: 'ws_...',
68
+ actorId: 'act_...',
69
+ amount: { currency: 'USDC', value: '500' },
70
+ recipient: { address: '0x...', chainId: 8453 },
71
+ })
72
+ ```
73
+
74
+ ### Policies
75
+
76
+ ```ts
77
+ const policy = await bp.policies.create({
78
+ workspaceId: 'ws_...',
79
+ policy: { kind: 'budget-check', config: { maxAmount: '1000' } },
80
+ })
81
+
82
+ const list = await bp.policies.list({ workspaceId: 'ws_...' })
83
+ await bp.policies.update({ id: policy.id, patch: { enabled: false } })
84
+ await bp.policies.remove(policy.id)
85
+ ```
86
+
87
+ ### Bundler Client
88
+
89
+ Send and track ERC-4337 user operations with fallback providers:
90
+
91
+ ```ts
92
+ const bundler = new BundlerClient({
93
+ entryPointAddress: '0x...',
94
+ entryPointVersion: 'v0.7',
95
+ primary: { name: 'pimlico', url: 'https://api.pimlico.io/v2/...' },
96
+ secondary: { name: 'alchemy', url: 'https://base.g.alchemy.com/...' },
97
+ })
98
+
99
+ const userOpHash = await bundler.sendUserOperation(userOperation)
100
+ const receipt = await bundler.getUserOperationReceipt(userOpHash, { timeoutMs: 30_000 })
101
+ ```
102
+
103
+ ### Paymaster Client
104
+
105
+ Request gas sponsorship for user operations:
106
+
107
+ ```ts
108
+ const paymaster = new PaymasterClient({
109
+ url: 'https://paymaster.brninpay.dev',
110
+ apiKey: 'pm_key_...',
111
+ })
112
+
113
+ const sponsorship = await paymaster.requestSponsorship(userOperation, {
114
+ workspaceId: 'ws_...',
115
+ actorId: 'act_...',
116
+ })
117
+ ```
118
+
119
+ ### Smart Wallets (ERC-4337)
120
+
121
+ Build and send user operations from Safe or Kernel smart accounts:
122
+
123
+ ```ts
124
+ import { SmartWallet, UserOperationBuilder, SafeAccountProvider, parseUsdc } from '@brninpay/sdk'
125
+ import { createWalletClient, http } from 'viem'
126
+ import { base } from 'viem/chains'
127
+
128
+ const client = createWalletClient({ chain: base, transport: http() })
129
+ const owner = { address: '0x...', signMessage: async ({ message }) => client.signMessage({ message }) }
130
+
131
+ const provider = new SafeAccountProvider({
132
+ publicClient: client,
133
+ owner,
134
+ entryPointAddress: '0x...',
135
+ factoryAddress: '0x...',
136
+ chainId: 8453,
137
+ })
138
+
139
+ const builder = new UserOperationBuilder({
140
+ chainId: 8453,
141
+ entryPointAddress: '0x...',
142
+ entryPointVersion: 'v0.7',
143
+ usdcAddress: '0x...',
144
+ })
145
+
146
+ const wallet = new SmartWallet({
147
+ chainId: 8453,
148
+ usdcAddress: '0x...',
149
+ provider,
150
+ bundlerClient: bundler,
151
+ builder,
152
+ })
153
+
154
+ const result = await wallet.sendUSDC({
155
+ recipient: '0x...',
156
+ amount: parseUsdc('100'),
157
+ })
158
+ ```
159
+
160
+ ### Conversion Utilities
161
+
162
+ ```ts
163
+ import { parseUsdc, formatUsdc } from '@brninpay/sdk'
164
+
165
+ parseUsdc('100') // → 100000000n (6 decimals)
166
+ formatUsdc(100000000n) // → '100'
167
+ ```
168
+
169
+ ## API
170
+
171
+ ### `Brinpay` / `BrinpayClient`
172
+
173
+ Main client. Configure with API key, base URL, retry policy, interceptors.
174
+
175
+ | Method | Description |
176
+ |--------|-------------|
177
+ | `bp.actors.*` | Actor operations |
178
+ | `bp.paymentIntents.*` | Payment intent CRUD |
179
+ | `bp.policies.*` | Policy CRUD |
180
+ | `bp.bundler.*` | ERC-4337 bundler client |
181
+ | `bp.paymaster.*` | Paymaster sponsorship client |
182
+
183
+ ### `ActorClient`
184
+
185
+ - `create(params)` → `ActorSummary`
186
+ - `pay(actorId, params)` → `ExecutionReceipt`
187
+ - `previewPay(actorId, params)` → `{ decision, policyResults }`
188
+ - `status(actorId)` → `ActorStatus`
189
+
190
+ ### `PaymentIntentClient`
191
+
192
+ - `create(params)` → `PaymentIntent`
193
+ - `get(id, options?)` → `PaymentIntent`
194
+ - `list(params)` → `PaginatedResult<PaymentIntent>`
195
+ - `cancel(id, params?)` → `PaymentIntent`
196
+ - `preview(params)` → `PaymentIntentPreview`
197
+
198
+ ### `PolicyClient`
199
+
200
+ - `create(params)` → `PolicyDefinition`
201
+ - `list(params)` → `PaginatedResult<PolicyDefinition>`
202
+ - `get(id)` → `PolicyDefinition`
203
+ - `update(params)` → `PolicyDefinition`
204
+ - `remove(id)` → `void`
205
+
206
+ ### `BundlerClient`
207
+
208
+ - `estimateUserOperationGas(userOp)` → `GasEstimate`
209
+ - `sendUserOperation(userOp)` → `Hex` (userOpHash)
210
+ - `getUserOperationReceipt(hash, options?)` → `UserOperationReceipt`
211
+ - `getUserOperationByHash(hash)` → `UserOperationByHash`
212
+
213
+ ### `PaymasterClient`
214
+
215
+ - `requestSponsorship(userOp, context?)` → `SponsorshipData`
216
+
217
+ ### `SmartWallet`
218
+
219
+ - `getAddress()` → `Address`
220
+ - `sendUSDC({ recipient, amount })` → `SmartWalletSendResult`
221
+ - `sendUserOperation(calls, options?)` → `SmartWalletSendResult`
222
+ - `isDeployed()` → `boolean`
223
+ - `getBalance()` → `bigint`
224
+
225
+ ### `UserOperationBuilder`
226
+
227
+ - `buildUSDCTransfer({ recipient, amount })` → `UserOperationCall`
228
+ - `prepareUserOperation(provider, context)` → `UserOperation`
229
+
230
+ ### Providers
231
+
232
+ - `SafeAccountProvider` — Safe (formerly Gnosis Safe) smart account
233
+ - `KernelAccountProvider` — ZeroDev Kernel smart account
234
+
235
+ ### Bundler Providers
236
+
237
+ - `createPimlicoBundlerProvider({ chainId, apiKey })`
238
+ - `createAlchemyBundlerProvider({ apiKey, network? })`
@@ -0,0 +1,4 @@
1
+ import { BrninpayClient } from './client.js';
2
+ export declare class Brninpay extends BrninpayClient {
3
+ }
4
+ //# sourceMappingURL=brninpay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brninpay.d.ts","sourceRoot":"","sources":["../src/brninpay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,qBAAa,QAAS,SAAQ,cAAc;CAAG"}
@@ -0,0 +1,4 @@
1
+ import { BrninpayClient } from './client.js';
2
+ export class Brninpay extends BrninpayClient {
3
+ }
4
+ //# sourceMappingURL=brninpay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brninpay.js","sourceRoot":"","sources":["../src/brninpay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,MAAM,OAAO,QAAS,SAAQ,cAAc;CAAG"}
package/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ActorClient } from './actor-client.js';
2
2
  import { PaymentIntentClient } from './modules/payment-intents.js';
3
3
  import { PolicyClient } from './modules/policies.js';
4
- import type { ClientRequestOptions, ClientTransport, RequestInterceptor, ResponseInterceptor, RetryPolicy, RuntimeeConfig, SdkLogger } from './types.js';
4
+ import type { ClientRequestOptions, ClientTransport, RequestInterceptor, ResponseInterceptor, RetryPolicy, BrninpayConfig, SdkLogger } from './types.js';
5
5
  export declare class BrninpayClient implements ClientTransport {
6
6
  readonly actors: ActorClient;
7
7
  readonly paymentIntents: PaymentIntentClient;
@@ -16,7 +16,7 @@ export declare class BrninpayClient implements ClientTransport {
16
16
  protected readonly retryPolicy: RetryPolicy;
17
17
  protected readonly requestInterceptors: RequestInterceptor[];
18
18
  protected readonly responseInterceptors: ResponseInterceptor[];
19
- constructor(config: RuntimeeConfig);
19
+ constructor(config: BrninpayConfig);
20
20
  request<T>(options: ClientRequestOptions): Promise<T>;
21
21
  private executeRequest;
22
22
  private applyAuthentication;
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@ import { AllowlistDeniedError, AuthorizationError, BudgetExhaustedError, ErrorCo
2
2
  import { ActorClient } from './actor-client.js';
3
3
  import { PaymentIntentClient } from './modules/payment-intents.js';
4
4
  import { PolicyClient } from './modules/policies.js';
5
- const DEFAULT_BASE_URL = 'https://api.runtimee.dev';
5
+ const DEFAULT_BASE_URL = 'https://api.brninpay.dev';
6
6
  const DEFAULT_TIMEOUT_MS = 15_000;
7
7
  const DEFAULT_RETRY_POLICY = {
8
8
  retries: 2,
@@ -190,7 +190,7 @@ export class BrninpayClient {
190
190
  responseInterceptors;
191
191
  constructor(config) {
192
192
  if (!config.apiKey?.trim()) {
193
- throw new ValidationError('Runtimee SDK requires a non-empty apiKey');
193
+ throw new ValidationError('Brninpay SDK requires a non-empty apiKey');
194
194
  }
195
195
  this.baseUrl = validateBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL);
196
196
  this.apiKey = config.apiKey;
@@ -203,7 +203,7 @@ export class BrninpayClient {
203
203
  this.requestInterceptors = config.requestInterceptors ?? [];
204
204
  this.responseInterceptors = config.responseInterceptors ?? [];
205
205
  if (!Number.isInteger(this.timeoutMs) || this.timeoutMs <= 0) {
206
- throw new ValidationError('Runtimee SDK timeoutMs must be a positive integer', {
206
+ throw new ValidationError('Brninpay SDK timeoutMs must be a positive integer', {
207
207
  timeoutMs: config.timeoutMs,
208
208
  });
209
209
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { BrninpayClient } from './client.js';
2
- export { Runtimee } from './runtimee.js';
2
+ export { Brninpay } from './brninpay.js';
3
3
  export { ActorClient } from './actor-client.js';
4
4
  export { PaymentIntentClient } from './modules/payment-intents.js';
5
5
  export { PolicyClient } from './modules/policies.js';
@@ -12,5 +12,5 @@ export { SmartWallet } from './erc4337/smart-wallet.js';
12
12
  export { SafeAccountProvider } from './erc4337/providers/safe.js';
13
13
  export { KernelAccountProvider } from './erc4337/providers/kernel.js';
14
14
  export { parseUsdc, formatUsdc } from './conversion.js';
15
- export type { Address, ApiErrorPayload, BatchOperationOptions, BundlerClientConfig, BundlerProviderConfig, CancelPaymentIntentParams, ClientRequestOptions, ClientTransport, CreateActorParams, CreatePaymentIntentParams, CreatePolicyParams, PayParams, PaginatedResult, PaymentIntentPreview, PaymentIntentPreviewParams, PimlicoBundlerProviderParams, PreviewPayParams, PublicClientLike, RequestContext, ResponseContext, RetryPolicy, SmartAccountOwner, SmartWalletConfig, SmartWalletInstance, SmartWalletSendResult, SponsorshipContext, SponsorshipData, ActorStatus, ActorSummary, ExecutionReceipt, AlchemyBundlerProviderParams, GetPaymentIntentOptions, ListPaymentIntentsParams, ListPoliciesParams, PaymasterClientConfig, PolicyDecisionExplanation, PreparedUserOperationContext, SmartWalletAccountProvider, SdkLogger, UpdatePolicyParams, UserOperationBuilderConfig, UserOperationByHash, UserOperationReceipt, RuntimeeConfig, } from './types.js';
15
+ export type { Address, ApiErrorPayload, BatchOperationOptions, BundlerClientConfig, BundlerProviderConfig, CancelPaymentIntentParams, ClientRequestOptions, ClientTransport, CreateActorParams, CreatePaymentIntentParams, CreatePolicyParams, PayParams, PaginatedResult, PaymentIntentPreview, PaymentIntentPreviewParams, PimlicoBundlerProviderParams, PreviewPayParams, PublicClientLike, RequestContext, ResponseContext, RetryPolicy, SmartAccountOwner, SmartWalletConfig, SmartWalletInstance, SmartWalletSendResult, SponsorshipContext, SponsorshipData, ActorStatus, ActorSummary, ExecutionReceipt, AlchemyBundlerProviderParams, GetPaymentIntentOptions, ListPaymentIntentsParams, ListPoliciesParams, PaymasterClientConfig, PolicyDecisionExplanation, PreparedUserOperationContext, SmartWalletAccountProvider, SdkLogger, UpdatePolicyParams, UserOperationBuilderConfig, UserOperationByHash, UserOperationReceipt, BrninpayConfig, } from './types.js';
16
16
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { BrninpayClient } from './client.js';
2
- export { Runtimee } from './runtimee.js';
2
+ export { Brninpay } from './brninpay.js';
3
3
  export { ActorClient } from './actor-client.js';
4
4
  export { PaymentIntentClient } from './modules/payment-intents.js';
5
5
  export { PolicyClient } from './modules/policies.js';
package/dist/types.d.ts CHANGED
@@ -81,7 +81,7 @@ export interface RetryPolicy {
81
81
  maxDelayMs: number;
82
82
  retryMethods: readonly HttpMethod[];
83
83
  }
84
- export interface RuntimeeConfig {
84
+ export interface BrninpayConfig {
85
85
  apiKey: string;
86
86
  apiSecret?: string;
87
87
  baseUrl?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brninpay/sdk",
3
- "version": "0.1.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "viem": "^2.21.0",
15
- "@brninpay/core": "0.1.0"
15
+ "@brninpay/core": "1.1.0"
16
16
  },
17
17
  "devDependencies": {
18
18
  "rimraf": "^6.0.0",
@@ -0,0 +1,3 @@
1
+ import { BrninpayClient } from './client.js'
2
+
3
+ export class Brninpay extends BrninpayClient {}
package/src/client.ts CHANGED
@@ -25,11 +25,11 @@ import type {
25
25
  ResponseContext,
26
26
  ResponseInterceptor,
27
27
  RetryPolicy,
28
- RuntimeeConfig,
28
+ BrninpayConfig,
29
29
  SdkLogger,
30
30
  } from './types.js'
31
31
 
32
- const DEFAULT_BASE_URL = 'https://api.runtimee.dev'
32
+ const DEFAULT_BASE_URL = 'https://api.brninpay.dev'
33
33
  const DEFAULT_TIMEOUT_MS = 15_000
34
34
  const DEFAULT_RETRY_POLICY: RetryPolicy = {
35
35
  retries: 2,
@@ -278,9 +278,9 @@ export class BrninpayClient implements ClientTransport {
278
278
  protected readonly requestInterceptors: RequestInterceptor[]
279
279
  protected readonly responseInterceptors: ResponseInterceptor[]
280
280
 
281
- constructor(config: RuntimeeConfig) {
281
+ constructor(config: BrninpayConfig) {
282
282
  if (!config.apiKey?.trim()) {
283
- throw new ValidationError('Runtimee SDK requires a non-empty apiKey')
283
+ throw new ValidationError('Brninpay SDK requires a non-empty apiKey')
284
284
  }
285
285
 
286
286
  this.baseUrl = validateBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL)
@@ -295,7 +295,7 @@ export class BrninpayClient implements ClientTransport {
295
295
  this.responseInterceptors = config.responseInterceptors ?? []
296
296
 
297
297
  if (!Number.isInteger(this.timeoutMs) || this.timeoutMs <= 0) {
298
- throw new ValidationError('Runtimee SDK timeoutMs must be a positive integer', {
298
+ throw new ValidationError('Brninpay SDK timeoutMs must be a positive integer', {
299
299
  timeoutMs: config.timeoutMs,
300
300
  })
301
301
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { BrninpayClient } from './client.js'
2
- export { Runtimee } from './runtimee.js'
2
+ export { Brninpay } from './brninpay.js'
3
3
  export { ActorClient } from './actor-client.js'
4
4
  export { PaymentIntentClient } from './modules/payment-intents.js'
5
5
  export { PolicyClient } from './modules/policies.js'
@@ -56,5 +56,5 @@ export type {
56
56
  UserOperationBuilderConfig,
57
57
  UserOperationByHash,
58
58
  UserOperationReceipt,
59
- RuntimeeConfig,
59
+ BrninpayConfig,
60
60
  } from './types.js'
package/src/types.ts CHANGED
@@ -128,7 +128,7 @@ export interface RetryPolicy {
128
128
  retryMethods: readonly HttpMethod[]
129
129
  }
130
130
 
131
- export interface RuntimeeConfig {
131
+ export interface BrninpayConfig {
132
132
  apiKey: string
133
133
  apiSecret?: string
134
134
  baseUrl?: string
@@ -1,24 +1,24 @@
1
1
  import { describe, expect, it, vi } from 'vitest'
2
- import { Runtimee } from '../src/runtimee.js'
3
- import type { RuntimeeConfig } from '../src/types.js'
2
+ import { Brninpay } from '../src/brninpay.js'
3
+ import type { BrninpayConfig } from '../src/types.js'
4
4
 
5
- describe('Runtimee', () => {
6
- const config: RuntimeeConfig = {
5
+ describe('Brninpay', () => {
6
+ const config: BrninpayConfig = {
7
7
  apiKey: 're_test_key',
8
8
  baseUrl: 'http://localhost:3000',
9
9
  }
10
10
 
11
11
  it('creates instance with config', () => {
12
- const rt = new Runtimee(config)
12
+ const rt = new Brninpay(config)
13
13
  expect(rt).toBeDefined()
14
14
  })
15
15
 
16
16
  it('throws without apiKey', () => {
17
- expect(() => new Runtimee({} as RuntimeeConfig)).toThrow('apiKey')
17
+ expect(() => new Brninpay({} as BrninpayConfig)).toThrow('apiKey')
18
18
  })
19
19
 
20
20
  it('exposes actors namespace', () => {
21
- const rt = new Runtimee(config)
21
+ const rt = new Brninpay(config)
22
22
  expect(rt.actors).toBeDefined()
23
23
  expect(rt.paymentIntents).toBeDefined()
24
24
  expect(rt.policies).toBeDefined()
package/src/runtimee.ts DELETED
@@ -1,3 +0,0 @@
1
- import { BrninpayClient } from './client.js'
2
-
3
- export class Runtimee extends BrninpayClient {}