@edge-markets/connect 1.5.1 → 1.6.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 +50 -0
- package/dist/index.d.mts +174 -1
- package/dist/index.d.ts +174 -1
- package/dist/index.js +11 -0
- package/dist/index.mjs +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ import type {
|
|
|
24
24
|
Balance,
|
|
25
25
|
Transfer,
|
|
26
26
|
EdgeTokens,
|
|
27
|
+
EdgeWebhookEvent,
|
|
27
28
|
} from '@edge-markets/connect'
|
|
28
29
|
|
|
29
30
|
// Types are generated from the OpenAPI spec
|
|
@@ -36,6 +37,49 @@ const user: User = {
|
|
|
36
37
|
}
|
|
37
38
|
```
|
|
38
39
|
|
|
40
|
+
### Webhook events
|
|
41
|
+
|
|
42
|
+
`EdgeWebhookEvent` is a discriminated union over `event.type` covering every
|
|
43
|
+
event the producer emits. Switching narrows `event.data` to the matching
|
|
44
|
+
variant — no casts:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import type { EdgeWebhookEvent } from '@edge-markets/connect'
|
|
48
|
+
|
|
49
|
+
function handle(event: EdgeWebhookEvent) {
|
|
50
|
+
switch (event.type) {
|
|
51
|
+
case 'transfer.completed':
|
|
52
|
+
// event.data is { transferId, status: 'completed', type, amount }
|
|
53
|
+
console.log(`completed: ${event.data.transferId} for ${event.data.amount}`)
|
|
54
|
+
break
|
|
55
|
+
case 'transfer.failed':
|
|
56
|
+
// event.data.reason is `string | undefined`
|
|
57
|
+
console.log(`failed: ${event.data.reason ?? 'unknown'}`)
|
|
58
|
+
break
|
|
59
|
+
case 'transfer.expired':
|
|
60
|
+
console.log(`expired: ${event.data.transferId}`)
|
|
61
|
+
break
|
|
62
|
+
case 'transfer.processing':
|
|
63
|
+
// @experimental — reserved for ledger dual-write hand-off
|
|
64
|
+
break
|
|
65
|
+
case 'consent.revoked':
|
|
66
|
+
console.log(`consent revoked: ${event.data.userId}`)
|
|
67
|
+
break
|
|
68
|
+
default: {
|
|
69
|
+
const _exhaustive: never = event
|
|
70
|
+
return _exhaustive
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
> `event.data.amount` is intentionally typed as `string` (e.g. `'100.00'`) to
|
|
77
|
+
> preserve decimal precision. Parse with a decimal-aware library on your side.
|
|
78
|
+
|
|
79
|
+
For HMAC signature verification on the live HTTP delivery channel, use
|
|
80
|
+
`verifyWebhookSignature` from `@edge-markets/connect-node`. For
|
|
81
|
+
reconciliation polling, use `EdgeConnectServer.syncWebhookEvents`.
|
|
82
|
+
|
|
39
83
|
### Configuration
|
|
40
84
|
|
|
41
85
|
Get environment-specific URLs:
|
|
@@ -93,6 +137,12 @@ try {
|
|
|
93
137
|
| `EdgeTokens` | OAuth tokens |
|
|
94
138
|
| `EdgeLinkSuccess` | Successful link result |
|
|
95
139
|
| `EdgeLinkExit` | Link exit metadata |
|
|
140
|
+
| `EdgeWebhookEvent` | Discriminated union over webhook event types |
|
|
141
|
+
| `TransferCompletedEventData` | Payload for `transfer.completed` |
|
|
142
|
+
| `TransferFailedEventData` | Payload for `transfer.failed` (includes optional `reason`) |
|
|
143
|
+
| `TransferExpiredEventData` | Payload for `transfer.expired` |
|
|
144
|
+
| `ConsentRevokedEventData` | Payload for `consent.revoked` |
|
|
145
|
+
| `EDGE_WEBHOOK_EVENT_TYPES` | Runtime tuple of all known event type strings |
|
|
96
146
|
|
|
97
147
|
### Configuration
|
|
98
148
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2536,6 +2536,179 @@ declare const OTP_METHODS: readonly ["sms", "totp", "email"];
|
|
|
2536
2536
|
*/
|
|
2537
2537
|
declare const TRANSFER_CATEGORIES: readonly ["sportsbook", "casino", "dfs", "sweepstakes"];
|
|
2538
2538
|
|
|
2539
|
+
/**
|
|
2540
|
+
* EDGE Connect Webhook Event Types (SDK-002)
|
|
2541
|
+
*
|
|
2542
|
+
* Discriminated union over `event.type` so partners get full type narrowing
|
|
2543
|
+
* inside `switch` blocks. Field shapes mirror the producer's enqueue calls
|
|
2544
|
+
* 1:1; see `edgeboost-api/src/nest/services/connect/`:
|
|
2545
|
+
* - `transfer-execution.service.ts:273` (transfer.completed)
|
|
2546
|
+
* - `verification-session.service.ts:468` (transfer.failed)
|
|
2547
|
+
* - `connect.service.ts:184` (transfer.expired)
|
|
2548
|
+
* - `oauth/consent.service.ts:125` (consent.revoked)
|
|
2549
|
+
*
|
|
2550
|
+
* **Decimal precision:** `data.amount` is intentionally a `string`, not a
|
|
2551
|
+
* `number`. The producer sends `String(transfer.amount)` so partner systems
|
|
2552
|
+
* can parse with arbitrary-precision libraries (e.g., decimal.js, big.js)
|
|
2553
|
+
* without losing the trailing cent.
|
|
2554
|
+
*
|
|
2555
|
+
* **Timestamps:** `created_at` is an ISO 8601 string, not a `Date` — webhook
|
|
2556
|
+
* payloads are JSON, parsing into `Date` is the partner's choice.
|
|
2557
|
+
*/
|
|
2558
|
+
|
|
2559
|
+
/**
|
|
2560
|
+
* All EDGE Connect webhook event type strings.
|
|
2561
|
+
*
|
|
2562
|
+
* Use this with {@link EDGE_WEBHOOK_EVENT_TYPES} for runtime checks
|
|
2563
|
+
* and as the discriminator on {@link EdgeWebhookEvent}.
|
|
2564
|
+
*/
|
|
2565
|
+
type EdgeWebhookEventType = 'transfer.completed' | 'transfer.failed' | 'transfer.expired' | 'transfer.processing' | 'consent.revoked';
|
|
2566
|
+
/**
|
|
2567
|
+
* Runtime tuple of every known event type.
|
|
2568
|
+
*
|
|
2569
|
+
* Use this when you need an array of strings (e.g., to filter incoming
|
|
2570
|
+
* events, validate config, or render a UI dropdown). Kept in sync with
|
|
2571
|
+
* {@link EdgeWebhookEventType} via `satisfies`.
|
|
2572
|
+
*/
|
|
2573
|
+
declare const EDGE_WEBHOOK_EVENT_TYPES: readonly ["transfer.completed", "transfer.failed", "transfer.expired", "transfer.processing", "consent.revoked"];
|
|
2574
|
+
/**
|
|
2575
|
+
* Common envelope shared by every webhook event.
|
|
2576
|
+
*
|
|
2577
|
+
* @template T - The discriminator literal (event type)
|
|
2578
|
+
* @template D - The shape of the `data` payload for this event type
|
|
2579
|
+
*/
|
|
2580
|
+
interface BaseWebhookEvent<T extends EdgeWebhookEventType, D> {
|
|
2581
|
+
/**
|
|
2582
|
+
* Globally unique event identifier (`evt_<base36-time><random>`).
|
|
2583
|
+
*
|
|
2584
|
+
* Use this for idempotency — webhook delivery is at-least-once.
|
|
2585
|
+
*/
|
|
2586
|
+
id: string;
|
|
2587
|
+
/** Event discriminator. */
|
|
2588
|
+
type: T;
|
|
2589
|
+
/**
|
|
2590
|
+
* ISO 8601 timestamp of when EDGE created the event.
|
|
2591
|
+
*
|
|
2592
|
+
* Snake-case key matches the wire format — JSON payloads are not transformed.
|
|
2593
|
+
*/
|
|
2594
|
+
created_at: string;
|
|
2595
|
+
/** Event-specific payload. Type narrows when you `switch` on `type`. */
|
|
2596
|
+
data: D;
|
|
2597
|
+
}
|
|
2598
|
+
/**
|
|
2599
|
+
* Payload for `transfer.completed`.
|
|
2600
|
+
*
|
|
2601
|
+
* Emitted when a transfer is verified and the user balance has been settled.
|
|
2602
|
+
*/
|
|
2603
|
+
interface TransferCompletedEventData {
|
|
2604
|
+
/** UUID v4 of the transfer. */
|
|
2605
|
+
transferId: string;
|
|
2606
|
+
/** Always `'completed'` for this event. */
|
|
2607
|
+
status: 'completed';
|
|
2608
|
+
/** Direction of the transfer (debit = user → partner, credit = partner → user). */
|
|
2609
|
+
type: TransferType;
|
|
2610
|
+
/** Decimal amount as a string (e.g. `'100.00'`). NOT a number. */
|
|
2611
|
+
amount: string;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Payload for `transfer.failed`.
|
|
2615
|
+
*
|
|
2616
|
+
* Emitted when OTP attempts are exhausted, the ledger rejects the transfer,
|
|
2617
|
+
* or a hard failure occurs after authorization.
|
|
2618
|
+
*/
|
|
2619
|
+
interface TransferFailedEventData {
|
|
2620
|
+
transferId: string;
|
|
2621
|
+
status: 'failed';
|
|
2622
|
+
type: TransferType;
|
|
2623
|
+
amount: string;
|
|
2624
|
+
/**
|
|
2625
|
+
* Human-readable failure reason.
|
|
2626
|
+
*
|
|
2627
|
+
* Optional — older failures may not include this field. Always default-safe
|
|
2628
|
+
* with `event.data.reason ?? 'unknown'` rather than asserting.
|
|
2629
|
+
*/
|
|
2630
|
+
reason?: string;
|
|
2631
|
+
}
|
|
2632
|
+
/**
|
|
2633
|
+
* Payload for `transfer.expired`.
|
|
2634
|
+
*
|
|
2635
|
+
* Emitted when the user did not verify their OTP within the 15-minute
|
|
2636
|
+
* verification window.
|
|
2637
|
+
*/
|
|
2638
|
+
interface TransferExpiredEventData {
|
|
2639
|
+
transferId: string;
|
|
2640
|
+
status: 'expired';
|
|
2641
|
+
type: TransferType;
|
|
2642
|
+
amount: string;
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Payload for `transfer.processing`.
|
|
2646
|
+
*
|
|
2647
|
+
* @experimental Reserved for the EDGE-360 ledger dual-write hand-off and not
|
|
2648
|
+
* currently emitted by the production producer. The shape may change before
|
|
2649
|
+
* GA — do not rely on it in production code paths yet.
|
|
2650
|
+
*/
|
|
2651
|
+
interface TransferProcessingEventData {
|
|
2652
|
+
transferId: string;
|
|
2653
|
+
status: 'processing';
|
|
2654
|
+
type: TransferType;
|
|
2655
|
+
amount: string;
|
|
2656
|
+
}
|
|
2657
|
+
/**
|
|
2658
|
+
* Payload for `consent.revoked`.
|
|
2659
|
+
*
|
|
2660
|
+
* Emitted when a user revokes the partner's access to their EDGE account.
|
|
2661
|
+
* The partner should mark the corresponding linked account as inactive and
|
|
2662
|
+
* stop calling user-scoped endpoints with the now-invalid access token.
|
|
2663
|
+
*/
|
|
2664
|
+
interface ConsentRevokedEventData {
|
|
2665
|
+
/** EDGE user ID whose consent was revoked. */
|
|
2666
|
+
userId: string;
|
|
2667
|
+
/** OAuth client ID that lost consent (your partner client ID). */
|
|
2668
|
+
clientId: string;
|
|
2669
|
+
/** ISO 8601 timestamp of the revocation. */
|
|
2670
|
+
revokedAt: string;
|
|
2671
|
+
}
|
|
2672
|
+
/**
|
|
2673
|
+
* A fully-typed EDGE Connect webhook event.
|
|
2674
|
+
*
|
|
2675
|
+
* Switching on `event.type` narrows `event.data` to the matching variant —
|
|
2676
|
+
* no casts needed:
|
|
2677
|
+
*
|
|
2678
|
+
* @example
|
|
2679
|
+
* ```typescript
|
|
2680
|
+
* import type { EdgeWebhookEvent } from '@edge-markets/connect'
|
|
2681
|
+
*
|
|
2682
|
+
* function handle(event: EdgeWebhookEvent) {
|
|
2683
|
+
* switch (event.type) {
|
|
2684
|
+
* case 'transfer.completed':
|
|
2685
|
+
* // event.data is TransferCompletedEventData
|
|
2686
|
+
* creditWallet(event.data.transferId, event.data.amount)
|
|
2687
|
+
* break
|
|
2688
|
+
* case 'transfer.failed':
|
|
2689
|
+
* // event.data.reason is `string | undefined`
|
|
2690
|
+
* logFailure(event.data.transferId, event.data.reason)
|
|
2691
|
+
* break
|
|
2692
|
+
* case 'transfer.expired':
|
|
2693
|
+
* cancelPending(event.data.transferId)
|
|
2694
|
+
* break
|
|
2695
|
+
* case 'transfer.processing':
|
|
2696
|
+
* // experimental — no-op for now
|
|
2697
|
+
* break
|
|
2698
|
+
* case 'consent.revoked':
|
|
2699
|
+
* deactivateLink(event.data.userId, event.data.clientId)
|
|
2700
|
+
* break
|
|
2701
|
+
* default: {
|
|
2702
|
+
* // Compile error if a new event type is added without a handler
|
|
2703
|
+
* const _exhaustive: never = event
|
|
2704
|
+
* return _exhaustive
|
|
2705
|
+
* }
|
|
2706
|
+
* }
|
|
2707
|
+
* }
|
|
2708
|
+
* ```
|
|
2709
|
+
*/
|
|
2710
|
+
type EdgeWebhookEvent = BaseWebhookEvent<'transfer.completed', TransferCompletedEventData> | BaseWebhookEvent<'transfer.failed', TransferFailedEventData> | BaseWebhookEvent<'transfer.expired', TransferExpiredEventData> | BaseWebhookEvent<'transfer.processing', TransferProcessingEventData> | BaseWebhookEvent<'consent.revoked', ConsentRevokedEventData>;
|
|
2711
|
+
|
|
2539
2712
|
/**
|
|
2540
2713
|
* EDGE Connect SDK Types
|
|
2541
2714
|
*
|
|
@@ -3039,4 +3212,4 @@ declare const SDK_VERSION = "1.0.0";
|
|
|
3039
3212
|
*/
|
|
3040
3213
|
declare const SDK_NAME = "@edge-markets/connect";
|
|
3041
3214
|
|
|
3042
|
-
export { ALL_EDGE_SCOPES, type ApiError, type Balance, type ConsentRequiredError, type CreateVerificationSessionRequest, EDGE_ENVIRONMENTS, EDGE_SCOPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, type EdgeEnvironment, type EdgeEnvironmentConfig, EdgeError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, type EdgeLinkConfigBase, type EdgeLinkEvent, type EdgeLinkEventName, type EdgeLinkExit, type EdgeLinkSuccess, EdgeNetworkError, EdgeNotFoundError, EdgePopupBlockedError, EdgePopupClosedError, type EdgeScope, EdgeStateMismatchError, EdgeTokenExchangeError, type EdgeTokens, EdgeValidationError, type InitiateTransferRequest, type ListTransfersParams, OTP_METHODS, type OtpMethod, type PKCEPair, type RevokeConsentResponse, SCOPE_DESCRIPTIONS, SCOPE_ICONS, SDK_NAME, SDK_VERSION, type SdkGeolocation, TRANSFER_CATEGORIES, TRANSFER_STATUSES, TRANSFER_TYPES, type Transfer, type TransferCategory, type TransferList, type TransferListItem, type TransferStatus, type TransferType, type User, type UserAddress, type VerificationSession, type VerificationSessionStatus, type VerificationSessionStatusResponse, type VerifyIdentityAddress, type VerifyIdentityOptions, type VerifyIdentityResult, type VerifyIdentityScores, type components, formatScopeForEnvironment, formatScopesForEnvironment, getAvailableEnvironments, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isIdentityVerificationError, isNetworkError, isProductionEnvironment, isValidScope, type operations, parseScope, type paths };
|
|
3215
|
+
export { ALL_EDGE_SCOPES, type ApiError, type Balance, type BaseWebhookEvent, type ConsentRequiredError, type ConsentRevokedEventData, type CreateVerificationSessionRequest, EDGE_ENVIRONMENTS, EDGE_SCOPES, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, type EdgeEnvironment, type EdgeEnvironmentConfig, EdgeError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, type EdgeLinkConfigBase, type EdgeLinkEvent, type EdgeLinkEventName, type EdgeLinkExit, type EdgeLinkSuccess, EdgeNetworkError, EdgeNotFoundError, EdgePopupBlockedError, EdgePopupClosedError, type EdgeScope, EdgeStateMismatchError, EdgeTokenExchangeError, type EdgeTokens, EdgeValidationError, type EdgeWebhookEvent, type EdgeWebhookEventType, type InitiateTransferRequest, type ListTransfersParams, OTP_METHODS, type OtpMethod, type PKCEPair, type RevokeConsentResponse, SCOPE_DESCRIPTIONS, SCOPE_ICONS, SDK_NAME, SDK_VERSION, type SdkGeolocation, TRANSFER_CATEGORIES, TRANSFER_STATUSES, TRANSFER_TYPES, type Transfer, type TransferCategory, type TransferCompletedEventData, type TransferExpiredEventData, type TransferFailedEventData, type TransferList, type TransferListItem, type TransferProcessingEventData, type TransferStatus, type TransferType, type User, type UserAddress, type VerificationSession, type VerificationSessionStatus, type VerificationSessionStatusResponse, type VerifyIdentityAddress, type VerifyIdentityOptions, type VerifyIdentityResult, type VerifyIdentityScores, type components, formatScopeForEnvironment, formatScopesForEnvironment, getAvailableEnvironments, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isIdentityVerificationError, isNetworkError, isProductionEnvironment, isValidScope, type operations, parseScope, type paths };
|
package/dist/index.d.ts
CHANGED
|
@@ -2536,6 +2536,179 @@ declare const OTP_METHODS: readonly ["sms", "totp", "email"];
|
|
|
2536
2536
|
*/
|
|
2537
2537
|
declare const TRANSFER_CATEGORIES: readonly ["sportsbook", "casino", "dfs", "sweepstakes"];
|
|
2538
2538
|
|
|
2539
|
+
/**
|
|
2540
|
+
* EDGE Connect Webhook Event Types (SDK-002)
|
|
2541
|
+
*
|
|
2542
|
+
* Discriminated union over `event.type` so partners get full type narrowing
|
|
2543
|
+
* inside `switch` blocks. Field shapes mirror the producer's enqueue calls
|
|
2544
|
+
* 1:1; see `edgeboost-api/src/nest/services/connect/`:
|
|
2545
|
+
* - `transfer-execution.service.ts:273` (transfer.completed)
|
|
2546
|
+
* - `verification-session.service.ts:468` (transfer.failed)
|
|
2547
|
+
* - `connect.service.ts:184` (transfer.expired)
|
|
2548
|
+
* - `oauth/consent.service.ts:125` (consent.revoked)
|
|
2549
|
+
*
|
|
2550
|
+
* **Decimal precision:** `data.amount` is intentionally a `string`, not a
|
|
2551
|
+
* `number`. The producer sends `String(transfer.amount)` so partner systems
|
|
2552
|
+
* can parse with arbitrary-precision libraries (e.g., decimal.js, big.js)
|
|
2553
|
+
* without losing the trailing cent.
|
|
2554
|
+
*
|
|
2555
|
+
* **Timestamps:** `created_at` is an ISO 8601 string, not a `Date` — webhook
|
|
2556
|
+
* payloads are JSON, parsing into `Date` is the partner's choice.
|
|
2557
|
+
*/
|
|
2558
|
+
|
|
2559
|
+
/**
|
|
2560
|
+
* All EDGE Connect webhook event type strings.
|
|
2561
|
+
*
|
|
2562
|
+
* Use this with {@link EDGE_WEBHOOK_EVENT_TYPES} for runtime checks
|
|
2563
|
+
* and as the discriminator on {@link EdgeWebhookEvent}.
|
|
2564
|
+
*/
|
|
2565
|
+
type EdgeWebhookEventType = 'transfer.completed' | 'transfer.failed' | 'transfer.expired' | 'transfer.processing' | 'consent.revoked';
|
|
2566
|
+
/**
|
|
2567
|
+
* Runtime tuple of every known event type.
|
|
2568
|
+
*
|
|
2569
|
+
* Use this when you need an array of strings (e.g., to filter incoming
|
|
2570
|
+
* events, validate config, or render a UI dropdown). Kept in sync with
|
|
2571
|
+
* {@link EdgeWebhookEventType} via `satisfies`.
|
|
2572
|
+
*/
|
|
2573
|
+
declare const EDGE_WEBHOOK_EVENT_TYPES: readonly ["transfer.completed", "transfer.failed", "transfer.expired", "transfer.processing", "consent.revoked"];
|
|
2574
|
+
/**
|
|
2575
|
+
* Common envelope shared by every webhook event.
|
|
2576
|
+
*
|
|
2577
|
+
* @template T - The discriminator literal (event type)
|
|
2578
|
+
* @template D - The shape of the `data` payload for this event type
|
|
2579
|
+
*/
|
|
2580
|
+
interface BaseWebhookEvent<T extends EdgeWebhookEventType, D> {
|
|
2581
|
+
/**
|
|
2582
|
+
* Globally unique event identifier (`evt_<base36-time><random>`).
|
|
2583
|
+
*
|
|
2584
|
+
* Use this for idempotency — webhook delivery is at-least-once.
|
|
2585
|
+
*/
|
|
2586
|
+
id: string;
|
|
2587
|
+
/** Event discriminator. */
|
|
2588
|
+
type: T;
|
|
2589
|
+
/**
|
|
2590
|
+
* ISO 8601 timestamp of when EDGE created the event.
|
|
2591
|
+
*
|
|
2592
|
+
* Snake-case key matches the wire format — JSON payloads are not transformed.
|
|
2593
|
+
*/
|
|
2594
|
+
created_at: string;
|
|
2595
|
+
/** Event-specific payload. Type narrows when you `switch` on `type`. */
|
|
2596
|
+
data: D;
|
|
2597
|
+
}
|
|
2598
|
+
/**
|
|
2599
|
+
* Payload for `transfer.completed`.
|
|
2600
|
+
*
|
|
2601
|
+
* Emitted when a transfer is verified and the user balance has been settled.
|
|
2602
|
+
*/
|
|
2603
|
+
interface TransferCompletedEventData {
|
|
2604
|
+
/** UUID v4 of the transfer. */
|
|
2605
|
+
transferId: string;
|
|
2606
|
+
/** Always `'completed'` for this event. */
|
|
2607
|
+
status: 'completed';
|
|
2608
|
+
/** Direction of the transfer (debit = user → partner, credit = partner → user). */
|
|
2609
|
+
type: TransferType;
|
|
2610
|
+
/** Decimal amount as a string (e.g. `'100.00'`). NOT a number. */
|
|
2611
|
+
amount: string;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Payload for `transfer.failed`.
|
|
2615
|
+
*
|
|
2616
|
+
* Emitted when OTP attempts are exhausted, the ledger rejects the transfer,
|
|
2617
|
+
* or a hard failure occurs after authorization.
|
|
2618
|
+
*/
|
|
2619
|
+
interface TransferFailedEventData {
|
|
2620
|
+
transferId: string;
|
|
2621
|
+
status: 'failed';
|
|
2622
|
+
type: TransferType;
|
|
2623
|
+
amount: string;
|
|
2624
|
+
/**
|
|
2625
|
+
* Human-readable failure reason.
|
|
2626
|
+
*
|
|
2627
|
+
* Optional — older failures may not include this field. Always default-safe
|
|
2628
|
+
* with `event.data.reason ?? 'unknown'` rather than asserting.
|
|
2629
|
+
*/
|
|
2630
|
+
reason?: string;
|
|
2631
|
+
}
|
|
2632
|
+
/**
|
|
2633
|
+
* Payload for `transfer.expired`.
|
|
2634
|
+
*
|
|
2635
|
+
* Emitted when the user did not verify their OTP within the 15-minute
|
|
2636
|
+
* verification window.
|
|
2637
|
+
*/
|
|
2638
|
+
interface TransferExpiredEventData {
|
|
2639
|
+
transferId: string;
|
|
2640
|
+
status: 'expired';
|
|
2641
|
+
type: TransferType;
|
|
2642
|
+
amount: string;
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Payload for `transfer.processing`.
|
|
2646
|
+
*
|
|
2647
|
+
* @experimental Reserved for the EDGE-360 ledger dual-write hand-off and not
|
|
2648
|
+
* currently emitted by the production producer. The shape may change before
|
|
2649
|
+
* GA — do not rely on it in production code paths yet.
|
|
2650
|
+
*/
|
|
2651
|
+
interface TransferProcessingEventData {
|
|
2652
|
+
transferId: string;
|
|
2653
|
+
status: 'processing';
|
|
2654
|
+
type: TransferType;
|
|
2655
|
+
amount: string;
|
|
2656
|
+
}
|
|
2657
|
+
/**
|
|
2658
|
+
* Payload for `consent.revoked`.
|
|
2659
|
+
*
|
|
2660
|
+
* Emitted when a user revokes the partner's access to their EDGE account.
|
|
2661
|
+
* The partner should mark the corresponding linked account as inactive and
|
|
2662
|
+
* stop calling user-scoped endpoints with the now-invalid access token.
|
|
2663
|
+
*/
|
|
2664
|
+
interface ConsentRevokedEventData {
|
|
2665
|
+
/** EDGE user ID whose consent was revoked. */
|
|
2666
|
+
userId: string;
|
|
2667
|
+
/** OAuth client ID that lost consent (your partner client ID). */
|
|
2668
|
+
clientId: string;
|
|
2669
|
+
/** ISO 8601 timestamp of the revocation. */
|
|
2670
|
+
revokedAt: string;
|
|
2671
|
+
}
|
|
2672
|
+
/**
|
|
2673
|
+
* A fully-typed EDGE Connect webhook event.
|
|
2674
|
+
*
|
|
2675
|
+
* Switching on `event.type` narrows `event.data` to the matching variant —
|
|
2676
|
+
* no casts needed:
|
|
2677
|
+
*
|
|
2678
|
+
* @example
|
|
2679
|
+
* ```typescript
|
|
2680
|
+
* import type { EdgeWebhookEvent } from '@edge-markets/connect'
|
|
2681
|
+
*
|
|
2682
|
+
* function handle(event: EdgeWebhookEvent) {
|
|
2683
|
+
* switch (event.type) {
|
|
2684
|
+
* case 'transfer.completed':
|
|
2685
|
+
* // event.data is TransferCompletedEventData
|
|
2686
|
+
* creditWallet(event.data.transferId, event.data.amount)
|
|
2687
|
+
* break
|
|
2688
|
+
* case 'transfer.failed':
|
|
2689
|
+
* // event.data.reason is `string | undefined`
|
|
2690
|
+
* logFailure(event.data.transferId, event.data.reason)
|
|
2691
|
+
* break
|
|
2692
|
+
* case 'transfer.expired':
|
|
2693
|
+
* cancelPending(event.data.transferId)
|
|
2694
|
+
* break
|
|
2695
|
+
* case 'transfer.processing':
|
|
2696
|
+
* // experimental — no-op for now
|
|
2697
|
+
* break
|
|
2698
|
+
* case 'consent.revoked':
|
|
2699
|
+
* deactivateLink(event.data.userId, event.data.clientId)
|
|
2700
|
+
* break
|
|
2701
|
+
* default: {
|
|
2702
|
+
* // Compile error if a new event type is added without a handler
|
|
2703
|
+
* const _exhaustive: never = event
|
|
2704
|
+
* return _exhaustive
|
|
2705
|
+
* }
|
|
2706
|
+
* }
|
|
2707
|
+
* }
|
|
2708
|
+
* ```
|
|
2709
|
+
*/
|
|
2710
|
+
type EdgeWebhookEvent = BaseWebhookEvent<'transfer.completed', TransferCompletedEventData> | BaseWebhookEvent<'transfer.failed', TransferFailedEventData> | BaseWebhookEvent<'transfer.expired', TransferExpiredEventData> | BaseWebhookEvent<'transfer.processing', TransferProcessingEventData> | BaseWebhookEvent<'consent.revoked', ConsentRevokedEventData>;
|
|
2711
|
+
|
|
2539
2712
|
/**
|
|
2540
2713
|
* EDGE Connect SDK Types
|
|
2541
2714
|
*
|
|
@@ -3039,4 +3212,4 @@ declare const SDK_VERSION = "1.0.0";
|
|
|
3039
3212
|
*/
|
|
3040
3213
|
declare const SDK_NAME = "@edge-markets/connect";
|
|
3041
3214
|
|
|
3042
|
-
export { ALL_EDGE_SCOPES, type ApiError, type Balance, type ConsentRequiredError, type CreateVerificationSessionRequest, EDGE_ENVIRONMENTS, EDGE_SCOPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, type EdgeEnvironment, type EdgeEnvironmentConfig, EdgeError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, type EdgeLinkConfigBase, type EdgeLinkEvent, type EdgeLinkEventName, type EdgeLinkExit, type EdgeLinkSuccess, EdgeNetworkError, EdgeNotFoundError, EdgePopupBlockedError, EdgePopupClosedError, type EdgeScope, EdgeStateMismatchError, EdgeTokenExchangeError, type EdgeTokens, EdgeValidationError, type InitiateTransferRequest, type ListTransfersParams, OTP_METHODS, type OtpMethod, type PKCEPair, type RevokeConsentResponse, SCOPE_DESCRIPTIONS, SCOPE_ICONS, SDK_NAME, SDK_VERSION, type SdkGeolocation, TRANSFER_CATEGORIES, TRANSFER_STATUSES, TRANSFER_TYPES, type Transfer, type TransferCategory, type TransferList, type TransferListItem, type TransferStatus, type TransferType, type User, type UserAddress, type VerificationSession, type VerificationSessionStatus, type VerificationSessionStatusResponse, type VerifyIdentityAddress, type VerifyIdentityOptions, type VerifyIdentityResult, type VerifyIdentityScores, type components, formatScopeForEnvironment, formatScopesForEnvironment, getAvailableEnvironments, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isIdentityVerificationError, isNetworkError, isProductionEnvironment, isValidScope, type operations, parseScope, type paths };
|
|
3215
|
+
export { ALL_EDGE_SCOPES, type ApiError, type Balance, type BaseWebhookEvent, type ConsentRequiredError, type ConsentRevokedEventData, type CreateVerificationSessionRequest, EDGE_ENVIRONMENTS, EDGE_SCOPES, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, type EdgeEnvironment, type EdgeEnvironmentConfig, EdgeError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, type EdgeLinkConfigBase, type EdgeLinkEvent, type EdgeLinkEventName, type EdgeLinkExit, type EdgeLinkSuccess, EdgeNetworkError, EdgeNotFoundError, EdgePopupBlockedError, EdgePopupClosedError, type EdgeScope, EdgeStateMismatchError, EdgeTokenExchangeError, type EdgeTokens, EdgeValidationError, type EdgeWebhookEvent, type EdgeWebhookEventType, type InitiateTransferRequest, type ListTransfersParams, OTP_METHODS, type OtpMethod, type PKCEPair, type RevokeConsentResponse, SCOPE_DESCRIPTIONS, SCOPE_ICONS, SDK_NAME, SDK_VERSION, type SdkGeolocation, TRANSFER_CATEGORIES, TRANSFER_STATUSES, TRANSFER_TYPES, type Transfer, type TransferCategory, type TransferCompletedEventData, type TransferExpiredEventData, type TransferFailedEventData, type TransferList, type TransferListItem, type TransferProcessingEventData, type TransferStatus, type TransferType, type User, type UserAddress, type VerificationSession, type VerificationSessionStatus, type VerificationSessionStatusResponse, type VerifyIdentityAddress, type VerifyIdentityOptions, type VerifyIdentityResult, type VerifyIdentityScores, type components, formatScopeForEnvironment, formatScopesForEnvironment, getAvailableEnvironments, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isIdentityVerificationError, isNetworkError, isProductionEnvironment, isValidScope, type operations, parseScope, type paths };
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ __export(index_exports, {
|
|
|
23
23
|
ALL_EDGE_SCOPES: () => ALL_EDGE_SCOPES,
|
|
24
24
|
EDGE_ENVIRONMENTS: () => EDGE_ENVIRONMENTS,
|
|
25
25
|
EDGE_SCOPES: () => EDGE_SCOPES,
|
|
26
|
+
EDGE_WEBHOOK_EVENT_TYPES: () => EDGE_WEBHOOK_EVENT_TYPES,
|
|
26
27
|
EdgeApiError: () => EdgeApiError,
|
|
27
28
|
EdgeAuthenticationError: () => EdgeAuthenticationError,
|
|
28
29
|
EdgeConsentRequiredError: () => EdgeConsentRequiredError,
|
|
@@ -77,6 +78,15 @@ var TRANSFER_CATEGORIES = [
|
|
|
77
78
|
"sweepstakes"
|
|
78
79
|
];
|
|
79
80
|
|
|
81
|
+
// src/types/webhooks.ts
|
|
82
|
+
var EDGE_WEBHOOK_EVENT_TYPES = [
|
|
83
|
+
"transfer.completed",
|
|
84
|
+
"transfer.failed",
|
|
85
|
+
"transfer.expired",
|
|
86
|
+
"transfer.processing",
|
|
87
|
+
"consent.revoked"
|
|
88
|
+
];
|
|
89
|
+
|
|
80
90
|
// src/config/environments.ts
|
|
81
91
|
var EDGE_ENVIRONMENTS = {
|
|
82
92
|
production: {
|
|
@@ -333,6 +343,7 @@ var SDK_NAME = "@edge-markets/connect";
|
|
|
333
343
|
ALL_EDGE_SCOPES,
|
|
334
344
|
EDGE_ENVIRONMENTS,
|
|
335
345
|
EDGE_SCOPES,
|
|
346
|
+
EDGE_WEBHOOK_EVENT_TYPES,
|
|
336
347
|
EdgeApiError,
|
|
337
348
|
EdgeAuthenticationError,
|
|
338
349
|
EdgeConsentRequiredError,
|
package/dist/index.mjs
CHANGED
|
@@ -15,6 +15,15 @@ var TRANSFER_CATEGORIES = [
|
|
|
15
15
|
"sweepstakes"
|
|
16
16
|
];
|
|
17
17
|
|
|
18
|
+
// src/types/webhooks.ts
|
|
19
|
+
var EDGE_WEBHOOK_EVENT_TYPES = [
|
|
20
|
+
"transfer.completed",
|
|
21
|
+
"transfer.failed",
|
|
22
|
+
"transfer.expired",
|
|
23
|
+
"transfer.processing",
|
|
24
|
+
"consent.revoked"
|
|
25
|
+
];
|
|
26
|
+
|
|
18
27
|
// src/config/environments.ts
|
|
19
28
|
var EDGE_ENVIRONMENTS = {
|
|
20
29
|
production: {
|
|
@@ -270,6 +279,7 @@ export {
|
|
|
270
279
|
ALL_EDGE_SCOPES,
|
|
271
280
|
EDGE_ENVIRONMENTS,
|
|
272
281
|
EDGE_SCOPES,
|
|
282
|
+
EDGE_WEBHOOK_EVENT_TYPES,
|
|
273
283
|
EdgeApiError,
|
|
274
284
|
EdgeAuthenticationError,
|
|
275
285
|
EdgeConsentRequiredError,
|