@soledgic/sdk 0.2.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.
- package/README.md +212 -0
- package/dist/index.d.mts +1636 -0
- package/dist/index.d.ts +1636 -0
- package/dist/index.js +2227 -0
- package/dist/index.mjs +2183 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# Soledgic TypeScript SDK
|
|
2
|
+
|
|
3
|
+
TypeScript client for Soledgic's public resource-first treasury API.
|
|
4
|
+
|
|
5
|
+
This package targets the supported API-key surface:
|
|
6
|
+
|
|
7
|
+
- `participants`
|
|
8
|
+
- `wallets`
|
|
9
|
+
- `transfers`
|
|
10
|
+
- `holds`
|
|
11
|
+
- `checkout-sessions`
|
|
12
|
+
- `payouts`
|
|
13
|
+
- `refunds`
|
|
14
|
+
- `reconciliations`
|
|
15
|
+
- `fraud`
|
|
16
|
+
- `compliance`
|
|
17
|
+
- `tax`
|
|
18
|
+
- webhook endpoint management and signature verification
|
|
19
|
+
|
|
20
|
+
It does not wrap the dashboard/operator control-plane routes such as `/api/identity/*` or `/api/ecosystems/*`.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @soledgic/sdk
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import Soledgic from '@soledgic/sdk'
|
|
32
|
+
|
|
33
|
+
const soledgic = new Soledgic({
|
|
34
|
+
apiKey: process.env.SOLEDGIC_API_KEY!,
|
|
35
|
+
apiVersion: '2026-03-01',
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const participant = await soledgic.createParticipant({
|
|
39
|
+
participantId: 'creator_456',
|
|
40
|
+
userId: '9f9b62d2-2f32-4b20-bc24-1f86b16cb9eb',
|
|
41
|
+
displayName: 'Jane Creator',
|
|
42
|
+
email: 'jane@example.com',
|
|
43
|
+
defaultSplitPercent: 80,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const checkout = await soledgic.createCheckoutSession({
|
|
47
|
+
participantId: participant.participant.id,
|
|
48
|
+
amount: 2999,
|
|
49
|
+
currency: 'USD',
|
|
50
|
+
productName: 'Premium asset pack',
|
|
51
|
+
successUrl: 'https://example.com/success',
|
|
52
|
+
cancelUrl: 'https://example.com/cancel',
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const wallets = await soledgic.listWallets({
|
|
56
|
+
ownerId: participant.participant.id,
|
|
57
|
+
walletType: 'creator_earnings',
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const payout = await soledgic.createPayout({
|
|
61
|
+
participantId: participant.participant.id,
|
|
62
|
+
referenceId: 'payout_2026_03_13_001',
|
|
63
|
+
amount: 1500,
|
|
64
|
+
payoutMethod: 'bank',
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
console.log({
|
|
68
|
+
checkoutUrl: checkout.checkoutSession.checkoutUrl,
|
|
69
|
+
linkedUserId: participant.participant.linkedUserId,
|
|
70
|
+
availableBalance: wallets.wallets[0]?.availableBalance,
|
|
71
|
+
payoutTransactionId: payout.payout.transactionId,
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The wallet API is uniform across integrations, but balances remain scoped.
|
|
76
|
+
Every wallet object belongs to one ledger, one owner, and one wallet type.
|
|
77
|
+
Soledgic does not expose a shared universal wallet balance.
|
|
78
|
+
|
|
79
|
+
## Public Treasury Methods
|
|
80
|
+
|
|
81
|
+
### Participants
|
|
82
|
+
|
|
83
|
+
| Method | Description |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `createParticipant(req)` | Create or provision a participant-backed treasury account |
|
|
86
|
+
| `listParticipants()` | List participant balances and linked-user state |
|
|
87
|
+
| `getParticipant(participantId)` | Get one participant with active hold detail |
|
|
88
|
+
| `getParticipantPayoutEligibility(participantId)` | Check payout readiness |
|
|
89
|
+
|
|
90
|
+
`createParticipant` accepts an optional `userId` so a public participant can be linked to a shared identity record without exposing the operator APIs directly.
|
|
91
|
+
|
|
92
|
+
### Wallets, Transfers, and Holds
|
|
93
|
+
|
|
94
|
+
| Method | Description |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `listWallets(filters?)` | List wallet objects by owner or wallet type |
|
|
97
|
+
| `createWallet(req)` | Create a consumer credit wallet |
|
|
98
|
+
| `getWallet(walletId)` | Fetch a wallet object by wallet id |
|
|
99
|
+
| `getWalletEntries(walletId, opts?)` | List entries for a wallet object |
|
|
100
|
+
| `topUpWallet(req)` | Top up a wallet object |
|
|
101
|
+
| `withdrawFromWallet(req)` | Withdraw from a wallet object |
|
|
102
|
+
| `createTransfer(req)` | Move funds between wallets when transfer is permitted |
|
|
103
|
+
| `listHolds(opts?)` | List held funds |
|
|
104
|
+
| `getHoldSummary()` | Get aggregate held-funds totals |
|
|
105
|
+
| `releaseHold(req)` | Release a hold and optionally execute the transfer |
|
|
106
|
+
|
|
107
|
+
Supported wallet types:
|
|
108
|
+
|
|
109
|
+
- `consumer_credit`: closed-loop platform credits
|
|
110
|
+
- `creator_earnings`: payout-eligible seller or creator proceeds
|
|
111
|
+
|
|
112
|
+
`createWallet` currently provisions scoped consumer-credit wallets. Creator
|
|
113
|
+
earnings wallets are provisioned through participant and treasury flows.
|
|
114
|
+
|
|
115
|
+
### Checkout, Payouts, and Refunds
|
|
116
|
+
|
|
117
|
+
| Method | Description |
|
|
118
|
+
| --- | --- |
|
|
119
|
+
| `createCheckoutSession(req)` | Create hosted or direct checkout flows |
|
|
120
|
+
| `createPayout(req)` | Create a payout resource |
|
|
121
|
+
| `createRefund(req)` | Create a refund resource |
|
|
122
|
+
| `listRefunds(req?)` | Query refunds, including by `saleReference` |
|
|
123
|
+
|
|
124
|
+
### Reconciliations
|
|
125
|
+
|
|
126
|
+
| Method | Description |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| `listUnmatchedTransactions()` | List ledger transactions that still need reconciliation |
|
|
129
|
+
| `matchTransaction(req)` | Create a reconciliation match |
|
|
130
|
+
| `unmatchTransaction(transactionId)` | Remove a reconciliation match |
|
|
131
|
+
| `createReconciliationSnapshot(req)` | Freeze a reconciliation snapshot for a period or as-of date |
|
|
132
|
+
| `getReconciliationSnapshot(periodId)` | Read the latest snapshot for a period |
|
|
133
|
+
| `autoMatchBankTransaction(bankAggregatorTransactionId)` | Attempt an automatic bank-to-ledger match |
|
|
134
|
+
|
|
135
|
+
### Fraud, Compliance, and Tax
|
|
136
|
+
|
|
137
|
+
| Method | Description |
|
|
138
|
+
| --- | --- |
|
|
139
|
+
| `evaluateFraud(req)` | Create a fraud evaluation for a proposed transaction |
|
|
140
|
+
| `listFraudPolicies()` | List active fraud policies |
|
|
141
|
+
| `createFraudPolicy(req)` | Create a fraud policy |
|
|
142
|
+
| `deleteFraudPolicy(policyId)` | Delete a fraud policy |
|
|
143
|
+
| `getComplianceOverview(opts?)` | Summarize ledger-scoped compliance signals |
|
|
144
|
+
| `listComplianceAccessPatterns(opts?)` | Inspect suspicious or high-volume access patterns |
|
|
145
|
+
| `listComplianceFinancialActivity(opts?)` | Summarize payout, sale, refund, and dispute activity |
|
|
146
|
+
| `listComplianceSecuritySummary(opts?)` | Summarize risk-scored security and audit events |
|
|
147
|
+
| `calculateTaxForParticipant(participantId, taxYear?)` | Calculate participant tax totals and shared-profile status |
|
|
148
|
+
| `generateAllTaxDocuments(taxYear?)` | Generate tax documents for the year |
|
|
149
|
+
| `listTaxDocuments(taxYear?)` | List generated tax documents |
|
|
150
|
+
| `getTaxDocument(documentId)` | Read one tax document |
|
|
151
|
+
| `exportTaxDocuments(taxYear?, format?)` | Export tax documents as CSV or JSON |
|
|
152
|
+
| `markTaxDocumentFiled(documentId)` | Mark a document as filed |
|
|
153
|
+
| `generateTaxSummary(taxYear, participantId?)` | Generate tax summary totals for the year |
|
|
154
|
+
|
|
155
|
+
### Webhooks
|
|
156
|
+
|
|
157
|
+
| Method | Description |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `listWebhookEndpoints()` | List configured webhook endpoints |
|
|
160
|
+
| `getWebhookDeliveries(endpointId?, limit?)` | Inspect recent deliveries |
|
|
161
|
+
| `rotateWebhookSecret(endpointId)` | Rotate an endpoint secret |
|
|
162
|
+
| `verifyWebhookSignature(...)` | Verify `X-Soledgic-Signature` |
|
|
163
|
+
| `parseWebhookEvent(payload)` | Parse a webhook payload into an event object |
|
|
164
|
+
|
|
165
|
+
## Replay Safety
|
|
166
|
+
|
|
167
|
+
Replay protection is endpoint-specific:
|
|
168
|
+
|
|
169
|
+
- direct checkout mode supports `idempotencyKey`
|
|
170
|
+
- refunds support `idempotencyKey`
|
|
171
|
+
- wallet writes, transfers, and payouts rely on stable `referenceId`
|
|
172
|
+
|
|
173
|
+
If your integration retries requests or replays processor events, treat `referenceId` as mandatory for treasury writes even when the type allows it.
|
|
174
|
+
|
|
175
|
+
## Error Handling
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
import Soledgic, { SoledgicError } from '@soledgic/sdk'
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
await soledgic.createPayout({
|
|
182
|
+
participantId: 'creator_456',
|
|
183
|
+
referenceId: 'payout_retry_safe_001',
|
|
184
|
+
amount: 999999,
|
|
185
|
+
payoutMethod: 'bank',
|
|
186
|
+
})
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (error instanceof SoledgicError) {
|
|
189
|
+
console.log(error.message)
|
|
190
|
+
console.log(error.status)
|
|
191
|
+
console.log(error.code)
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The SDK surfaces structured `error_code` values from the API when they are present. Use those codes for client logic instead of matching on human-readable messages.
|
|
197
|
+
|
|
198
|
+
## Security Boundary
|
|
199
|
+
|
|
200
|
+
This SDK is intentionally limited to the public integration contract:
|
|
201
|
+
|
|
202
|
+
- API-key treasury resources under `/v1/*`
|
|
203
|
+
- webhook verification helpers
|
|
204
|
+
|
|
205
|
+
It does not authenticate end-user dashboard sessions, and it does not expose the internal operator routes used for:
|
|
206
|
+
|
|
207
|
+
- shared identity profiles
|
|
208
|
+
- participant identity linking and unlinking
|
|
209
|
+
- ecosystem management
|
|
210
|
+
- internal fixture cleanup
|
|
211
|
+
|
|
212
|
+
Those flows are documented in [docs/OPERATOR_CONTROL_PLANE.md](../../docs/OPERATOR_CONTROL_PLANE.md).
|