@brninpay/core 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/core@0.1.0 build /home/runner/work/brninpay/brninpay/packages/core
3
- > tsc
4
-
1
+
2
+ > @brninpay/core@1.1.0 build /home/bernieweb3/Downloads/runtimee/packages/core
3
+ > tsc
4
+
@@ -0,0 +1,4 @@
1
+
2
+ > @brninpay/core@0.1.0 typecheck /home/bernieweb3/Downloads/runtimee/packages/core
3
+ > tsc --noEmit
4
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @brninpay/core
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ea45d4c: Minor fixes
8
+
9
+ ## 1.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 5fc7f42: Brninpay is here! From BernieWeb3 a.k.a NxBern with love :3
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,7 +1,109 @@
1
- # @runtimee/core
1
+ # @brninpay/core
2
2
 
3
- Pure TypeScript authorization kernel for Runtimee.
3
+ Pure TypeScript authorization kernel for Brninpay. Zero blockchain dependencies. Zero I/O. Zero network calls.
4
4
 
5
- Zero blockchain dependencies. Zero I/O. Zero network calls.
5
+ ## Install
6
6
 
7
- Provides the PolicyEngine, DecisionResolver, and built-in policies that form the core authorization pipeline.
7
+ ```bash
8
+ npm install @brninpay/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Policy Engine
14
+
15
+ Evaluate spending requests against composable policies:
16
+
17
+ ```ts
18
+ import { PolicyEngine, createBudgetCheckPolicy, createAllowlistPolicy } from '@brninpay/core'
19
+
20
+ const engine = new PolicyEngine()
21
+
22
+ engine.addPolicy(createBudgetCheckPolicy({
23
+ maxAmount: '1000',
24
+ currency: 'USDC',
25
+ period: 'monthly',
26
+ }))
27
+
28
+ engine.addPolicy(createAllowlistPolicy({
29
+ allowedTargets: ['0x1234...'],
30
+ }))
31
+
32
+ const decision = await engine.evaluate({
33
+ target: '0x1234...',
34
+ amount: '500000000', // 500 USDC (6 decimals)
35
+ purpose: { type: 'payment', id: 'inv_001' },
36
+ budget: { used: '100000000', total: '1000000000' },
37
+ })
38
+ ```
39
+
40
+ ### Built-in Policies
41
+
42
+ | Policy | Import | Purpose |
43
+ |--------|--------|---------|
44
+ | Budget Check | `createBudgetCheckPolicy` | Enforce monthly/total spending caps |
45
+ | Allowlist | `createAllowlistPolicy` | Restrict to approved target addresses |
46
+ | Max Per Call | `createMaxPerCallPolicy` | Cap individual payment amounts |
47
+ | Rate Limit | `createRateLimitPolicy` | Limit payments per time window |
48
+
49
+ ### Decision Resolver
50
+
51
+ Combine multiple policy evaluators with configurable logic:
52
+
53
+ ```ts
54
+ import { DecisionResolver } from '@brninpay/core'
55
+
56
+ const resolver = new DecisionResolver({
57
+ mode: 'all', // 'all' | 'any' | 'weighted'
58
+ allowUndecided: false,
59
+ })
60
+
61
+ const result = await resolver.resolve(evaluators, context)
62
+ ```
63
+
64
+ ### Cryptographic Helpers
65
+
66
+ ```ts
67
+ import { sha256Hex, signHmacSha256, verifyHmacSha256, generateNonce } from '@brninpay/core'
68
+
69
+ const signature = await signHmacSha256('my-secret', 'message')
70
+ const isValid = await verifyHmacSha256('my-secret', 'message', signature)
71
+ const nonce = generateNonce()
72
+ ```
73
+
74
+ ### Type-Safe Parsing (Zod)
75
+
76
+ Parse and validate untrusted input:
77
+
78
+ ```ts
79
+ import { parsePaymentIntent, parsePolicyDefinition, parseUserOperation } from '@brninpay/core'
80
+
81
+ const intent = parsePaymentIntent(untrustedData)
82
+ const policy = parsePolicyDefinition(userInput)
83
+ ```
84
+
85
+ ## API
86
+
87
+ ### PolicyEngine
88
+
89
+ - `engine.addPolicy(middleware)` — Register a policy middleware
90
+ - `engine.removePolicy(name)` — Remove by name
91
+ - `engine.evaluate(context)` → `AggregatedPolicyDecision`
92
+ - `engine.getPolicies()` → `PolicyMiddleware[]`
93
+
94
+ ### DecisionResolver
95
+
96
+ - `new DecisionResolver(config)` — `mode`: `'all'` (default, require all approve), `'any'`, `'weighted`
97
+ - `resolver.resolve(evaluators, context)` → `AuthorizationDecision`
98
+
99
+ ### Type Exports
100
+
101
+ `Actor`, `Intent`, `Policy`, `Budget`, `Authorization`, `ExecutionPlan`, `PaymentIntent`, `UserOperation`, `SmartWallet`, `PolicyDefinition`, `PolicyEvaluationResult`, and more — see `src/types.ts`.
102
+
103
+ ### Error Classes
104
+
105
+ `BrninpayError`, `ValidationError`, `AuthorizationError`, `BudgetExhaustedError`, `AllowlistDeniedError`, `RateLimitExceededError`, `ExecutionError`, `NetworkError`, `HmacVerificationError`
106
+
107
+ ### Validation Schemas (Zod)
108
+
109
+ `PaymentIntentSchema`, `PolicyDefinitionSchema`, `UserOperationSchema`, `AddressSchema`, `HexSchema`, and more — see `src/validation/schemas.ts`.
package/dist/errors.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { ErrorCode, RuntimeeError, ValidationError, AuthorizationError, BudgetExhaustedError, AllowlistDeniedError, RateLimitExceededError, AuthorizationExpiredError, ExecutionError, NetworkError, GasEstimationError, BroadcastError, ReorgDetectedError, HmacVerificationError, isRuntimeeError, serializeError, } from './types/errors.js';
1
+ export { ErrorCode, BrninpayError, ValidationError, AuthorizationError, BudgetExhaustedError, AllowlistDeniedError, RateLimitExceededError, AuthorizationExpiredError, ExecutionError, NetworkError, GasEstimationError, BroadcastError, ReorgDetectedError, HmacVerificationError, isBrninpayError, serializeError, } from './types/errors.js';
2
2
  export type { ErrorCodeMessage, SerializedError } from './types/errors.js';
3
3
  //# sourceMappingURL=errors.d.ts.map
package/dist/errors.js CHANGED
@@ -1,2 +1,2 @@
1
- export { ErrorCode, RuntimeeError, ValidationError, AuthorizationError, BudgetExhaustedError, AllowlistDeniedError, RateLimitExceededError, AuthorizationExpiredError, ExecutionError, NetworkError, GasEstimationError, BroadcastError, ReorgDetectedError, HmacVerificationError, isRuntimeeError, serializeError, } from './types/errors.js';
1
+ export { ErrorCode, BrninpayError, ValidationError, AuthorizationError, BudgetExhaustedError, AllowlistDeniedError, RateLimitExceededError, AuthorizationExpiredError, ExecutionError, NetworkError, GasEstimationError, BroadcastError, ReorgDetectedError, HmacVerificationError, isBrninpayError, serializeError, } from './types/errors.js';
2
2
  //# sourceMappingURL=errors.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { Actor, Budget, Policy, SettlementDescriptor, Target, Purpose, Intent, BudgetState, PolicyResult, AuthorizationDecision, Authorization, SettlementHint, ExecutionPlan, PolicyContext, PolicyMiddleware, PolicyEvaluator, SimulationResult, SignedTransaction, Receipt, PaymentIntentStatus, PaymentAmount, PaymentRecipient, PaymentIntentFailure, PaymentMetadataValue, PaymentIntent, SerializedBigInt, PolicyDecision, PolicyReason, BasePolicy, BudgetPolicy, AllowlistPolicy, RateLimitPolicy, PolicyDefinition, PolicyEvaluationContext, PolicyEvaluationResult, AggregatedPolicyDecision, Hex, Address, SmartWalletProvider, EntryPointVersion, SmartWallet, UserOperationCall, GasEstimate, UserOperationV06, UserOperationV07, UserOperation, } from './types.js';
2
- export { AuthorizationError, BudgetExhaustedError, AllowlistDeniedError, RateLimitExceededError, AuthorizationExpiredError, RuntimeeError, ValidationError, ExecutionError, NetworkError, GasEstimationError, BroadcastError, ReorgDetectedError, HmacVerificationError, isRuntimeeError, serializeError, ErrorCode, } from './errors.js';
2
+ export { AuthorizationError, BudgetExhaustedError, AllowlistDeniedError, RateLimitExceededError, AuthorizationExpiredError, BrninpayError, ValidationError, ExecutionError, NetworkError, GasEstimationError, BroadcastError, ReorgDetectedError, HmacVerificationError, isBrninpayError, serializeError, ErrorCode, } from './errors.js';
3
3
  export type { ErrorCodeMessage, SerializedError } from './errors.js';
4
4
  export { PAYMENT_INTENT_STATUSES, PAYMENT_INTENT_TERMINAL_STATUSES, PAYMENT_INTENT_TRANSITIONS, validatePaymentAmount, isPaymentIntentTerminalStatus, canTransitionPaymentIntentStatus, assertValidPaymentIntentTransition, assertPaymentIntent, serializeBigInts, deserializeBigInts, serializePaymentIntent, deserializePaymentIntent, POLICY_DECISIONS, evaluatePolicy, aggregatePolicyDecisions, evaluatePolicies, isUserOperationV06, isUserOperationV07, getUserOperationSender, getUserOperationNonce, } from './types.js';
5
5
  export { DecisionResolver } from './decision-resolver.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { AuthorizationError, BudgetExhaustedError, AllowlistDeniedError, RateLimitExceededError, AuthorizationExpiredError, RuntimeeError, ValidationError, ExecutionError, NetworkError, GasEstimationError, BroadcastError, ReorgDetectedError, HmacVerificationError, isRuntimeeError, serializeError, ErrorCode, } from './errors.js';
1
+ export { AuthorizationError, BudgetExhaustedError, AllowlistDeniedError, RateLimitExceededError, AuthorizationExpiredError, BrninpayError, ValidationError, ExecutionError, NetworkError, GasEstimationError, BroadcastError, ReorgDetectedError, HmacVerificationError, isBrninpayError, serializeError, ErrorCode, } from './errors.js';
2
2
  export { PAYMENT_INTENT_STATUSES, PAYMENT_INTENT_TERMINAL_STATUSES, PAYMENT_INTENT_TRANSITIONS, validatePaymentAmount, isPaymentIntentTerminalStatus, canTransitionPaymentIntentStatus, assertValidPaymentIntentTransition, assertPaymentIntent, serializeBigInts, deserializeBigInts, serializePaymentIntent, deserializePaymentIntent, POLICY_DECISIONS, evaluatePolicy, aggregatePolicyDecisions, evaluatePolicies, isUserOperationV06, isUserOperationV07, getUserOperationSender, getUserOperationNonce, } from './types.js';
3
3
  export { DecisionResolver } from './decision-resolver.js';
4
4
  export { PolicyEngine } from './policy-engine.js';
@@ -23,17 +23,17 @@ export interface SerializedError {
23
23
  statusCode: number;
24
24
  details?: unknown;
25
25
  }
26
- export declare class RuntimeeError extends Error {
26
+ export declare class BrninpayError extends Error {
27
27
  readonly code: string;
28
28
  readonly statusCode: number;
29
29
  readonly details?: unknown;
30
30
  constructor(code: string, message: string, statusCode?: number, details?: unknown, options?: ErrorOptions);
31
31
  toJSON(): SerializedError;
32
32
  }
33
- export declare class ValidationError extends RuntimeeError {
33
+ export declare class ValidationError extends BrninpayError {
34
34
  constructor(message: string, details?: unknown, options?: ErrorOptions);
35
35
  }
36
- export declare class AuthorizationError extends RuntimeeError {
36
+ export declare class AuthorizationError extends BrninpayError {
37
37
  constructor(code: string, message: string, details?: unknown, options?: ErrorOptions);
38
38
  }
39
39
  export declare class BudgetExhaustedError extends AuthorizationError {
@@ -56,7 +56,7 @@ export declare class RateLimitExceededError extends AuthorizationError {
56
56
  export declare class AuthorizationExpiredError extends AuthorizationError {
57
57
  constructor(options?: ErrorOptions);
58
58
  }
59
- export declare class ExecutionError extends RuntimeeError {
59
+ export declare class ExecutionError extends BrninpayError {
60
60
  constructor(code: string, message: string, details?: unknown, options?: ErrorOptions);
61
61
  }
62
62
  export declare class NetworkError extends ExecutionError {
@@ -72,9 +72,9 @@ export declare class ReorgDetectedError extends ExecutionError {
72
72
  readonly depth: number;
73
73
  constructor(depth: number, options?: ErrorOptions);
74
74
  }
75
- export declare class HmacVerificationError extends RuntimeeError {
75
+ export declare class HmacVerificationError extends BrninpayError {
76
76
  constructor(message: string, details?: unknown, options?: ErrorOptions);
77
77
  }
78
- export declare function isRuntimeeError(error: unknown): error is RuntimeeError;
78
+ export declare function isBrninpayError(error: unknown): error is BrninpayError;
79
79
  export declare function serializeError(error: unknown): SerializedError;
80
80
  //# sourceMappingURL=errors.d.ts.map
@@ -13,7 +13,7 @@ export var ErrorCode;
13
13
  ErrorCode["REORG_DETECTED"] = "reorg_detected";
14
14
  ErrorCode["HMAC_VERIFICATION_FAILED"] = "hmac_verification_failed";
15
15
  })(ErrorCode || (ErrorCode = {}));
16
- export class RuntimeeError extends Error {
16
+ export class BrninpayError extends Error {
17
17
  code;
18
18
  statusCode;
19
19
  details;
@@ -29,12 +29,12 @@ export class RuntimeeError extends Error {
29
29
  return serializeError(this);
30
30
  }
31
31
  }
32
- export class ValidationError extends RuntimeeError {
32
+ export class ValidationError extends BrninpayError {
33
33
  constructor(message, details, options) {
34
34
  super(ErrorCode.VALIDATION_ERROR, message, 400, details, options);
35
35
  }
36
36
  }
37
- export class AuthorizationError extends RuntimeeError {
37
+ export class AuthorizationError extends BrninpayError {
38
38
  constructor(code, message, details, options) {
39
39
  super(code, message, 403, details, options);
40
40
  }
@@ -86,7 +86,7 @@ export class AuthorizationExpiredError extends AuthorizationError {
86
86
  super(ErrorCode.AUTHORIZATION_EXPIRED, 'Authorization preview has expired. Re-simulate.', undefined, options);
87
87
  }
88
88
  }
89
- export class ExecutionError extends RuntimeeError {
89
+ export class ExecutionError extends BrninpayError {
90
90
  constructor(code, message, details, options) {
91
91
  super(code, message, 502, details, options);
92
92
  }
@@ -113,16 +113,16 @@ export class ReorgDetectedError extends ExecutionError {
113
113
  this.depth = depth;
114
114
  }
115
115
  }
116
- export class HmacVerificationError extends RuntimeeError {
116
+ export class HmacVerificationError extends BrninpayError {
117
117
  constructor(message, details, options) {
118
118
  super(ErrorCode.HMAC_VERIFICATION_FAILED, message, 401, details, options);
119
119
  }
120
120
  }
121
- export function isRuntimeeError(error) {
122
- return error instanceof RuntimeeError;
121
+ export function isBrninpayError(error) {
122
+ return error instanceof BrninpayError;
123
123
  }
124
124
  export function serializeError(error) {
125
- if (error instanceof RuntimeeError) {
125
+ if (error instanceof BrninpayError) {
126
126
  return {
127
127
  name: error.name,
128
128
  code: error.code,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brninpay/core",
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",
package/src/errors.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export {
2
2
  ErrorCode,
3
- RuntimeeError,
3
+ BrninpayError,
4
4
  ValidationError,
5
5
  AuthorizationError,
6
6
  BudgetExhaustedError,
@@ -13,7 +13,7 @@ export {
13
13
  BroadcastError,
14
14
  ReorgDetectedError,
15
15
  HmacVerificationError,
16
- isRuntimeeError,
16
+ isBrninpayError,
17
17
  serializeError,
18
18
  } from './types/errors.js'
19
19
 
package/src/index.ts CHANGED
@@ -53,7 +53,7 @@ export {
53
53
  AllowlistDeniedError,
54
54
  RateLimitExceededError,
55
55
  AuthorizationExpiredError,
56
- RuntimeeError,
56
+ BrninpayError,
57
57
  ValidationError,
58
58
  ExecutionError,
59
59
  NetworkError,
@@ -61,7 +61,7 @@ export {
61
61
  BroadcastError,
62
62
  ReorgDetectedError,
63
63
  HmacVerificationError,
64
- isRuntimeeError,
64
+ isBrninpayError,
65
65
  serializeError,
66
66
  ErrorCode,
67
67
  } from './errors.js'
@@ -26,7 +26,7 @@ export interface SerializedError {
26
26
  details?: unknown
27
27
  }
28
28
 
29
- export class RuntimeeError extends Error {
29
+ export class BrninpayError extends Error {
30
30
  public readonly code: string
31
31
  public readonly statusCode: number
32
32
  public readonly details?: unknown
@@ -51,13 +51,13 @@ export class RuntimeeError extends Error {
51
51
  }
52
52
  }
53
53
 
54
- export class ValidationError extends RuntimeeError {
54
+ export class ValidationError extends BrninpayError {
55
55
  constructor(message: string, details?: unknown, options?: ErrorOptions) {
56
56
  super(ErrorCode.VALIDATION_ERROR, message, 400, details, options)
57
57
  }
58
58
  }
59
59
 
60
- export class AuthorizationError extends RuntimeeError {
60
+ export class AuthorizationError extends BrninpayError {
61
61
  constructor(code: string, message: string, details?: unknown, options?: ErrorOptions) {
62
62
  super(code, message, 403, details, options)
63
63
  }
@@ -137,7 +137,7 @@ export class AuthorizationExpiredError extends AuthorizationError {
137
137
  }
138
138
  }
139
139
 
140
- export class ExecutionError extends RuntimeeError {
140
+ export class ExecutionError extends BrninpayError {
141
141
  constructor(code: string, message: string, details?: unknown, options?: ErrorOptions) {
142
142
  super(code, message, 502, details, options)
143
143
  }
@@ -175,18 +175,18 @@ export class ReorgDetectedError extends ExecutionError {
175
175
  }
176
176
  }
177
177
 
178
- export class HmacVerificationError extends RuntimeeError {
178
+ export class HmacVerificationError extends BrninpayError {
179
179
  constructor(message: string, details?: unknown, options?: ErrorOptions) {
180
180
  super(ErrorCode.HMAC_VERIFICATION_FAILED, message, 401, details, options)
181
181
  }
182
182
  }
183
183
 
184
- export function isRuntimeeError(error: unknown): error is RuntimeeError {
185
- return error instanceof RuntimeeError
184
+ export function isBrninpayError(error: unknown): error is BrninpayError {
185
+ return error instanceof BrninpayError
186
186
  }
187
187
 
188
188
  export function serializeError(error: unknown): SerializedError {
189
- if (error instanceof RuntimeeError) {
189
+ if (error instanceof BrninpayError) {
190
190
  return {
191
191
  name: error.name,
192
192
  code: error.code,