@edge-protocol/sdk 0.5.0 → 0.5.1
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/DOCS.md +71 -1
- package/README.md +3 -3
- package/package.json +1 -1
package/DOCS.md
CHANGED
|
@@ -280,6 +280,67 @@ if (!sdk.isValid(pass)) {
|
|
|
280
280
|
|
|
281
281
|
---
|
|
282
282
|
|
|
283
|
+
### `sdk.on(event, listener)` → `this`
|
|
284
|
+
|
|
285
|
+
Subscribe to transaction outcomes. Fires automatically after every `sdk.execute()` call. Returns the SDK instance for chaining.
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
sdk
|
|
289
|
+
.on('approved', ({ outcome, pass, request }) => {
|
|
290
|
+
console.log('executed:', outcome.digest);
|
|
291
|
+
updateBudgetUI(pass);
|
|
292
|
+
})
|
|
293
|
+
.on('escalated', ({ outcome, request }) => {
|
|
294
|
+
notifyUser(`Approve $${request.amount} at ${request.merchant}?`);
|
|
295
|
+
})
|
|
296
|
+
.on('blocked', ({ outcome, request }) => {
|
|
297
|
+
logger.warn(`blocked: ${outcome.reason}`);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
// events fire automatically on execute
|
|
301
|
+
await sdk.execute(pass, request, signer);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Event payload:**
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
// approved
|
|
308
|
+
{ type: 'approved', outcome: { status: 'approved', digest: string, auto: true }, pass, request }
|
|
309
|
+
|
|
310
|
+
// escalated
|
|
311
|
+
{ type: 'escalated', outcome: { status: 'escalated', reason: string, auto: false }, pass, request }
|
|
312
|
+
|
|
313
|
+
// blocked
|
|
314
|
+
{ type: 'blocked', outcome: { status: 'blocked', reason: string, auto: false }, pass, request }
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
### `sdk.off(event, listener)` → `this`
|
|
320
|
+
|
|
321
|
+
Remove a specific listener.
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
const onApproved = ({ outcome }) => console.log(outcome.digest);
|
|
325
|
+
|
|
326
|
+
sdk.on('approved', onApproved);
|
|
327
|
+
// later...
|
|
328
|
+
sdk.off('approved', onApproved);
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
### `sdk.removeAllListeners(event?)` → `this`
|
|
334
|
+
|
|
335
|
+
Remove all listeners for an event, or all events if none specified.
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
sdk.removeAllListeners('approved'); // remove all approved listeners
|
|
339
|
+
sdk.removeAllListeners(); // remove all listeners
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
283
344
|
## Templates
|
|
284
345
|
|
|
285
346
|
Pre-configured trust boundaries for common use cases. Every template is a starting point — override any field.
|
|
@@ -758,7 +819,16 @@ cd packages/sdk && pnpm test
|
|
|
758
819
|
✓ all templates have autoThreshold < escalateThreshold
|
|
759
820
|
✓ all templates have escalateThreshold < budget
|
|
760
821
|
|
|
761
|
-
|
|
822
|
+
📋 Events system
|
|
823
|
+
✓ on() returns sdk instance for chaining
|
|
824
|
+
✓ fires approved event on auto-approve
|
|
825
|
+
✓ fires blocked event on policy rejection
|
|
826
|
+
✓ fires escalated event above threshold
|
|
827
|
+
✓ off() removes listener
|
|
828
|
+
✓ removeAllListeners() clears all events
|
|
829
|
+
✓ multiple listeners fire for same event
|
|
830
|
+
|
|
831
|
+
34 passed · 0 failed ✅
|
|
762
832
|
```
|
|
763
833
|
|
|
764
834
|
---
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
**Give agents your rules, not your keys.**
|
|
14
14
|
|
|
15
|
-
[Live Demo](https://edge-web-
|
|
15
|
+
[Live Demo](https://edge-web-git-main-fluturecodes-projects.vercel.app) · [Full Docs](https://github.com/fluturecode/edge/blob/main/packages/sdk/DOCS.md) · [GitHub](https://github.com/fluturecode/edge)
|
|
16
16
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -213,7 +213,7 @@ Festival Mode: Claude autonomously manages purchases within an EdgePass.
|
|
|
213
213
|
3 transactions · $54.50 spent · 0 wallet popups
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
-
[See it live →](https://edge-web-
|
|
216
|
+
[See it live →](https://edge-web-git-main-fluturecodes-projects.vercel.app)
|
|
217
217
|
|
|
218
218
|
---
|
|
219
219
|
|
|
@@ -230,7 +230,7 @@ pnpm test
|
|
|
230
230
|
✓ blocks when budget exceeded
|
|
231
231
|
✓ blocks when expired
|
|
232
232
|
✓ blocks when inactive
|
|
233
|
-
|
|
233
|
+
34/34 passing ✅
|
|
234
234
|
```
|
|
235
235
|
|
|
236
236
|
---
|
package/package.json
CHANGED