@kivel.io/sdk 0.6.1 → 0.8.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/CHANGELOG.md +12 -0
- package/README.md +11 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +65 -0
- package/dist/types.d.ts +155 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @kivel.io/sdk
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7290344: Add test wallets, x402 paywalls and mock checkouts with approval-aware payments, ledgers and test outcome controls.
|
|
8
|
+
|
|
9
|
+
## 0.7.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 7cbd3fc: Add workspace credential storage, password generation and approved reveals.
|
|
14
|
+
|
|
3
15
|
## 0.6.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -85,3 +85,14 @@ await kivel.deleteOAuthProvider(provider.id);
|
|
|
85
85
|
`oauthProviders()` lists workspace providers; `updateOAuthProvider(id, config)` replaces
|
|
86
86
|
the users, claims and test scenario. Endpoint use is public; management stays private.
|
|
87
87
|
See the [OAuth guide](https://kivel.io/docs/mock-oauth/) for token flows and failure scenarios.
|
|
88
|
+
|
|
89
|
+
## Workspace vault
|
|
90
|
+
|
|
91
|
+
Use `saveCredential({ name, url, username })` to generate and store a password, or
|
|
92
|
+
include `password` to save one you already have. The generated value is returned
|
|
93
|
+
once. `credentials()` and `credential(id)` return metadata.
|
|
94
|
+
`revealCredential(id)` requests human approval by default. Wait with
|
|
95
|
+
`waitForApproval(approvalId)`, then repeat the reveal with that approval ID.
|
|
96
|
+
Each approval permits one reveal by the same caller. Only signed-in owners and
|
|
97
|
+
admins can change `agentMayRead`. Use `generatePassword(length)` for a standalone
|
|
98
|
+
password, `updateCredential(id, changes)` to edit, and `deleteCredential(id)` to remove it.
|
package/dist/index.d.ts
CHANGED
|
@@ -123,6 +123,57 @@ export declare class Kivel {
|
|
|
123
123
|
deleteAuthenticator(id: string): Promise<void>;
|
|
124
124
|
getEmailAttachment(id: string, messageId: string, attachmentId: string): Promise<EmailAttachmentLink>;
|
|
125
125
|
downloadEmailAttachment(id: string, messageId: string, attachmentId: string): Promise<Uint8Array>;
|
|
126
|
+
createTestWallet(input: import('./types.js').TestWalletInput): Promise<import("./types.js").TestPaymentResource>;
|
|
127
|
+
createTestPaywall(input: import('./types.js').TestPaywallInput): Promise<import("./types.js").TestPaymentResource>;
|
|
128
|
+
createTestCheckout(input: import('./types.js').TestCheckoutInput): Promise<import("./types.js").TestPaymentResource & {
|
|
129
|
+
webhookSecret: string;
|
|
130
|
+
}>;
|
|
131
|
+
testPayments(kind: 'wallets' | 'paywalls' | 'checkouts'): Promise<{
|
|
132
|
+
testMode: true;
|
|
133
|
+
resources: import('./types.js').TestPaymentResource[];
|
|
134
|
+
}>;
|
|
135
|
+
testPayment(kind: 'wallets' | 'paywalls' | 'checkouts', id: string): Promise<import("./types.js").TestPaymentResource>;
|
|
136
|
+
updateTestPayment(kind: 'wallets' | 'paywalls' | 'checkouts', id: string, input: Partial<import('./types.js').TestWalletInput | import('./types.js').TestPaywallInput | import('./types.js').TestCheckoutInput>): Promise<import("./types.js").TestPaymentResource>;
|
|
137
|
+
deleteTestPayment(kind: 'wallets' | 'paywalls' | 'checkouts', id: string): Promise<void>;
|
|
138
|
+
walletBalance(id: string): Promise<import("./types.js").TestPaymentResource>;
|
|
139
|
+
topUpTestWallet(id: string, amount: number): Promise<{
|
|
140
|
+
testMode: true;
|
|
141
|
+
balance: number;
|
|
142
|
+
transaction: import('./types.js').TestTransaction;
|
|
143
|
+
}>;
|
|
144
|
+
walletPay(id: string, input: import('./types.js').TestPaymentInput): Promise<import("./types.js").TestPaymentResult>;
|
|
145
|
+
listWalletTransactions(id: string, options?: {
|
|
146
|
+
cursor?: string;
|
|
147
|
+
limit?: number;
|
|
148
|
+
}): Promise<{
|
|
149
|
+
testMode: true;
|
|
150
|
+
transactions: import('./types.js').TestTransaction[];
|
|
151
|
+
nextCursor?: string;
|
|
152
|
+
}>;
|
|
153
|
+
completeTestCheckout(id: string, input: {
|
|
154
|
+
idempotencyKey: string;
|
|
155
|
+
card: {
|
|
156
|
+
number: string;
|
|
157
|
+
expiry?: string;
|
|
158
|
+
cvc?: string;
|
|
159
|
+
};
|
|
160
|
+
}): Promise<import("./types.js").TestCheckoutAttempt>;
|
|
161
|
+
confirmTestCheckout(id: string, confirmationToken: string): Promise<import("./types.js").TestCheckoutAttempt>;
|
|
162
|
+
saveCredential(input: import('./types.js').CredentialInput): Promise<{
|
|
163
|
+
credential: import('./types.js').Credential;
|
|
164
|
+
password?: string;
|
|
165
|
+
}>;
|
|
166
|
+
credentials(): Promise<{
|
|
167
|
+
credentials: import('./types.js').Credential[];
|
|
168
|
+
limit: number;
|
|
169
|
+
}>;
|
|
170
|
+
credential(id: string): Promise<import("./types.js").Credential>;
|
|
171
|
+
updateCredential(id: string, input: Partial<import('./types.js').CredentialInput>): Promise<import("./types.js").Credential>;
|
|
172
|
+
deleteCredential(id: string): Promise<void>;
|
|
173
|
+
revealCredential(id: string, approvalId?: string): Promise<import("./types.js").CredentialReveal>;
|
|
174
|
+
generatePassword(length?: number): Promise<{
|
|
175
|
+
password: string;
|
|
176
|
+
}>;
|
|
126
177
|
createEmailInbox(settings?: import('./types.js').EmailInboxSettings): Promise<EmailInbox>;
|
|
127
178
|
emailInboxes(): Promise<{
|
|
128
179
|
inboxes: EmailInbox[];
|
package/dist/index.js
CHANGED
|
@@ -170,6 +170,71 @@ export class Kivel {
|
|
|
170
170
|
throw new KivelError('Attachment link expired or unavailable.', response.status, response.headers.get('x-request-id') ?? undefined);
|
|
171
171
|
return new Uint8Array(await response.arrayBuffer());
|
|
172
172
|
}
|
|
173
|
+
createTestWallet(input) {
|
|
174
|
+
return this.request('POST', '/api/test-wallets', input);
|
|
175
|
+
}
|
|
176
|
+
createTestPaywall(input) {
|
|
177
|
+
return this.request('POST', '/api/test-paywalls', input);
|
|
178
|
+
}
|
|
179
|
+
createTestCheckout(input) {
|
|
180
|
+
return this.request('POST', '/api/test-checkouts', input);
|
|
181
|
+
}
|
|
182
|
+
testPayments(kind) {
|
|
183
|
+
return this.request('GET', `/api/test-${kind}`);
|
|
184
|
+
}
|
|
185
|
+
testPayment(kind, id) {
|
|
186
|
+
return this.request('GET', `/api/test-${kind}/${encodeURIComponent(id)}`);
|
|
187
|
+
}
|
|
188
|
+
updateTestPayment(kind, id, input) {
|
|
189
|
+
return this.request('PATCH', `/api/test-${kind}/${encodeURIComponent(id)}`, input);
|
|
190
|
+
}
|
|
191
|
+
deleteTestPayment(kind, id) {
|
|
192
|
+
return this.request('DELETE', `/api/test-${kind}/${encodeURIComponent(id)}`);
|
|
193
|
+
}
|
|
194
|
+
walletBalance(id) {
|
|
195
|
+
return this.testPayment('wallets', id);
|
|
196
|
+
}
|
|
197
|
+
topUpTestWallet(id, amount) {
|
|
198
|
+
return this.request('POST', `/api/test-wallets/${encodeURIComponent(id)}/top-up`, { amount });
|
|
199
|
+
}
|
|
200
|
+
walletPay(id, input) {
|
|
201
|
+
return this.request('POST', `/api/test-wallets/${encodeURIComponent(id)}/pay`, input);
|
|
202
|
+
}
|
|
203
|
+
listWalletTransactions(id, options = {}) {
|
|
204
|
+
const query = new URLSearchParams();
|
|
205
|
+
if (options.cursor)
|
|
206
|
+
query.set('cursor', options.cursor);
|
|
207
|
+
if (options.limit !== undefined)
|
|
208
|
+
query.set('limit', String(options.limit));
|
|
209
|
+
return this.request('GET', `/api/test-wallets/${encodeURIComponent(id)}/transactions?${query}`);
|
|
210
|
+
}
|
|
211
|
+
completeTestCheckout(id, input) {
|
|
212
|
+
return this.request('POST', `/api/test-checkouts/${encodeURIComponent(id)}/complete`, input);
|
|
213
|
+
}
|
|
214
|
+
confirmTestCheckout(id, confirmationToken) {
|
|
215
|
+
return this.request('POST', `/api/test-checkouts/${encodeURIComponent(id)}/confirm`, { confirmationToken });
|
|
216
|
+
}
|
|
217
|
+
saveCredential(input) {
|
|
218
|
+
return this.request('POST', '/api/credentials', input);
|
|
219
|
+
}
|
|
220
|
+
credentials() {
|
|
221
|
+
return this.request('GET', '/api/credentials');
|
|
222
|
+
}
|
|
223
|
+
credential(id) {
|
|
224
|
+
return this.request('GET', `/api/credentials/${encodeURIComponent(id)}`);
|
|
225
|
+
}
|
|
226
|
+
updateCredential(id, input) {
|
|
227
|
+
return this.request('PATCH', `/api/credentials/${encodeURIComponent(id)}`, input);
|
|
228
|
+
}
|
|
229
|
+
deleteCredential(id) {
|
|
230
|
+
return this.request('DELETE', `/api/credentials/${encodeURIComponent(id)}`);
|
|
231
|
+
}
|
|
232
|
+
revealCredential(id, approvalId) {
|
|
233
|
+
return this.request('POST', `/api/credentials/${encodeURIComponent(id)}/reveal`, approvalId ? { approvalId } : {});
|
|
234
|
+
}
|
|
235
|
+
generatePassword(length = 24) {
|
|
236
|
+
return this.request('POST', '/api/passwords/generate', { length });
|
|
237
|
+
}
|
|
173
238
|
createEmailInbox(settings = {}) {
|
|
174
239
|
return this.request('POST', '/api/email-inboxes', settings);
|
|
175
240
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -274,3 +274,158 @@ export interface OAuthProvider {
|
|
|
274
274
|
export interface CreatedOAuthProvider extends OAuthProvider {
|
|
275
275
|
client_secret: string;
|
|
276
276
|
}
|
|
277
|
+
export interface Credential {
|
|
278
|
+
id: string;
|
|
279
|
+
name: string;
|
|
280
|
+
url: string;
|
|
281
|
+
username: string;
|
|
282
|
+
agentMayRead: boolean;
|
|
283
|
+
authenticatorId?: string;
|
|
284
|
+
inboxId?: string;
|
|
285
|
+
createdAt: string;
|
|
286
|
+
updatedAt: string;
|
|
287
|
+
}
|
|
288
|
+
export interface CredentialInput {
|
|
289
|
+
name: string;
|
|
290
|
+
url: string;
|
|
291
|
+
username: string;
|
|
292
|
+
password?: string;
|
|
293
|
+
passwordLength?: number;
|
|
294
|
+
notes?: string;
|
|
295
|
+
agentMayRead?: boolean;
|
|
296
|
+
authenticatorId?: string | null;
|
|
297
|
+
inboxId?: string | null;
|
|
298
|
+
}
|
|
299
|
+
export type CredentialReveal = {
|
|
300
|
+
status: 'awaitingApproval';
|
|
301
|
+
approvalId: string;
|
|
302
|
+
answerUrl: string;
|
|
303
|
+
} | {
|
|
304
|
+
status: 'revealed';
|
|
305
|
+
id: string;
|
|
306
|
+
password: string;
|
|
307
|
+
notes: string;
|
|
308
|
+
};
|
|
309
|
+
export type TestPaymentKind = 'wallet' | 'paywall' | 'checkout';
|
|
310
|
+
export type CheckoutOutcome = 'succeeded' | 'declined' | 'insufficient_funds' | 'requires_verification' | 'expired';
|
|
311
|
+
export interface TestTransaction {
|
|
312
|
+
id: string;
|
|
313
|
+
at: string;
|
|
314
|
+
kind: 'payment' | 'topup';
|
|
315
|
+
amount: number;
|
|
316
|
+
payee: string;
|
|
317
|
+
memo: string;
|
|
318
|
+
status: 'awaitingApproval' | 'authorized' | 'succeeded' | 'refused' | 'expired';
|
|
319
|
+
reason?: string;
|
|
320
|
+
approvalId?: string;
|
|
321
|
+
events: {
|
|
322
|
+
at: string;
|
|
323
|
+
status: string;
|
|
324
|
+
reason?: string;
|
|
325
|
+
}[];
|
|
326
|
+
}
|
|
327
|
+
export interface TestPaymentResource {
|
|
328
|
+
id: string;
|
|
329
|
+
kind: TestPaymentKind;
|
|
330
|
+
testMode: true;
|
|
331
|
+
name: string;
|
|
332
|
+
expiresAt: string;
|
|
333
|
+
endpointUrl?: string;
|
|
334
|
+
balance?: number;
|
|
335
|
+
availableBalance?: number;
|
|
336
|
+
reservedBalance?: number;
|
|
337
|
+
perPaymentLimit?: number;
|
|
338
|
+
dailyLimit?: number;
|
|
339
|
+
approvalThreshold?: number;
|
|
340
|
+
amount?: number;
|
|
341
|
+
currency?: string;
|
|
342
|
+
item?: string;
|
|
343
|
+
description?: string;
|
|
344
|
+
modes?: ('wallet' | 'permissive')[];
|
|
345
|
+
response?: {
|
|
346
|
+
status: number;
|
|
347
|
+
body: unknown;
|
|
348
|
+
};
|
|
349
|
+
successUrl?: string;
|
|
350
|
+
cancelUrl?: string;
|
|
351
|
+
webhookUrl?: string;
|
|
352
|
+
attempts?: {
|
|
353
|
+
id: string;
|
|
354
|
+
at: string;
|
|
355
|
+
outcome: CheckoutOutcome;
|
|
356
|
+
last4?: string;
|
|
357
|
+
verified?: boolean;
|
|
358
|
+
}[];
|
|
359
|
+
deliveries?: {
|
|
360
|
+
requestId: string;
|
|
361
|
+
at: string;
|
|
362
|
+
attempts: number;
|
|
363
|
+
status?: number;
|
|
364
|
+
error?: string;
|
|
365
|
+
}[];
|
|
366
|
+
}
|
|
367
|
+
export interface TestWalletInput {
|
|
368
|
+
name: string;
|
|
369
|
+
balance?: number;
|
|
370
|
+
availableBalance?: number;
|
|
371
|
+
reservedBalance?: number;
|
|
372
|
+
ttlSeconds?: number;
|
|
373
|
+
persistent?: boolean;
|
|
374
|
+
/** Only an owner/admin browser session can set spending controls. Agent keys omit them. */
|
|
375
|
+
perPaymentLimit?: number;
|
|
376
|
+
dailyLimit?: number;
|
|
377
|
+
approvalThreshold?: number;
|
|
378
|
+
}
|
|
379
|
+
export interface TestPaywallInput {
|
|
380
|
+
name: string;
|
|
381
|
+
amount: number;
|
|
382
|
+
description?: string;
|
|
383
|
+
modes?: ('wallet' | 'permissive')[];
|
|
384
|
+
response?: {
|
|
385
|
+
status: number;
|
|
386
|
+
body: unknown;
|
|
387
|
+
};
|
|
388
|
+
ttlSeconds?: number;
|
|
389
|
+
persistent?: boolean;
|
|
390
|
+
}
|
|
391
|
+
export interface TestCheckoutInput {
|
|
392
|
+
name: string;
|
|
393
|
+
item: string;
|
|
394
|
+
description?: string;
|
|
395
|
+
amount: number;
|
|
396
|
+
currency?: 'USD' | 'EUR' | 'GBP' | 'CAD' | 'AUD';
|
|
397
|
+
successUrl?: string;
|
|
398
|
+
cancelUrl?: string;
|
|
399
|
+
webhookUrl?: string;
|
|
400
|
+
ttlSeconds?: number;
|
|
401
|
+
persistent?: boolean;
|
|
402
|
+
}
|
|
403
|
+
export interface TestPaymentInput {
|
|
404
|
+
payee: string;
|
|
405
|
+
amount?: number;
|
|
406
|
+
memo?: string;
|
|
407
|
+
idempotencyKey: string;
|
|
408
|
+
authorizeOnly?: boolean;
|
|
409
|
+
}
|
|
410
|
+
export interface TestPaymentResult {
|
|
411
|
+
testMode: true;
|
|
412
|
+
status: 'awaitingApproval' | 'authorized' | 'succeeded';
|
|
413
|
+
transaction?: TestTransaction;
|
|
414
|
+
transactionId?: string;
|
|
415
|
+
approvalId?: string;
|
|
416
|
+
answerUrl?: string;
|
|
417
|
+
paymentHeader?: string;
|
|
418
|
+
headerName?: 'X-PAYMENT';
|
|
419
|
+
expiresAt?: string;
|
|
420
|
+
content?: unknown;
|
|
421
|
+
checkout?: TestCheckoutAttempt;
|
|
422
|
+
}
|
|
423
|
+
export interface TestCheckoutAttempt {
|
|
424
|
+
testMode: true;
|
|
425
|
+
id: string;
|
|
426
|
+
at: string;
|
|
427
|
+
outcome: CheckoutOutcome;
|
|
428
|
+
last4?: string;
|
|
429
|
+
verified?: boolean;
|
|
430
|
+
confirmationToken?: string;
|
|
431
|
+
}
|