@edge-markets/connect 1.0.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 ADDED
@@ -0,0 +1,134 @@
1
+ # @edgeboost/edge-connect-sdk
2
+
3
+ Core types, configuration, and utilities for EDGE Connect SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @edgeboost/edge-connect-sdk
9
+ # or
10
+ pnpm add @edgeboost/edge-connect-sdk
11
+ # or
12
+ yarn add @edgeboost/edge-connect-sdk
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Types
18
+
19
+ Import types for API responses and requests:
20
+
21
+ ```typescript
22
+ import type {
23
+ User,
24
+ Balance,
25
+ Transfer,
26
+ EdgeTokens,
27
+ } from '@edgeboost/edge-connect-sdk'
28
+
29
+ // Types are generated from the OpenAPI spec
30
+ const user: User = {
31
+ id: '507f1f77bcf86cd799439011',
32
+ email: 'user@example.com',
33
+ firstName: 'John',
34
+ lastName: 'Doe',
35
+ createdAt: '2024-01-15T10:30:00.000Z',
36
+ }
37
+ ```
38
+
39
+ ### Configuration
40
+
41
+ Get environment-specific URLs:
42
+
43
+ ```typescript
44
+ import {
45
+ getEnvironmentConfig,
46
+ EDGE_SCOPES,
47
+ formatScopeForEnvironment,
48
+ } from '@edgeboost/edge-connect-sdk'
49
+
50
+ const config = getEnvironmentConfig('staging')
51
+ console.log(config.apiBaseUrl) // https://...
52
+
53
+ // Format scopes for your environment
54
+ const scopes = formatScopeForEnvironment(EDGE_SCOPES.BALANCE_READ, 'staging')
55
+ // Returns: 'edge-connect-staging/balance.read'
56
+ ```
57
+
58
+ ### Error Handling
59
+
60
+ Typed error classes for specific scenarios:
61
+
62
+ ```typescript
63
+ import {
64
+ EdgeError,
65
+ EdgeConsentRequiredError,
66
+ isConsentRequiredError,
67
+ } from '@edgeboost/edge-connect-sdk'
68
+
69
+ try {
70
+ const balance = await edge.getBalance(accessToken)
71
+ } catch (error) {
72
+ if (isConsentRequiredError(error)) {
73
+ // User needs to grant consent - redirect to EdgeLink
74
+ console.log(`Consent required for client: ${error.clientId}`)
75
+ } else if (error instanceof EdgeError) {
76
+ // Handle other SDK errors
77
+ console.error(`Error [${error.code}]: ${error.message}`)
78
+ }
79
+ }
80
+ ```
81
+
82
+ ## Exports
83
+
84
+ ### Types
85
+
86
+ | Type | Description |
87
+ |------|-------------|
88
+ | `User` | User profile information |
89
+ | `Balance` | Account balance |
90
+ | `Transfer` | Transfer response |
91
+ | `TransferListItem` | Transfer in list |
92
+ | `EdgeTokens` | OAuth tokens |
93
+ | `EdgeLinkSuccess` | Successful link result |
94
+ | `EdgeLinkExit` | Link exit metadata |
95
+
96
+ ### Configuration
97
+
98
+ | Export | Description |
99
+ |--------|-------------|
100
+ | `EDGE_ENVIRONMENTS` | All environment configs |
101
+ | `getEnvironmentConfig(env)` | Get config for environment |
102
+ | `EDGE_SCOPES` | Available OAuth scopes |
103
+ | `ALL_EDGE_SCOPES` | All scopes as array |
104
+ | `formatScopeForEnvironment(scope, env)` | Format scope for Cognito |
105
+
106
+ ### Errors
107
+
108
+ | Error | When thrown |
109
+ |-------|-------------|
110
+ | `EdgeError` | Base error class |
111
+ | `EdgeAuthenticationError` | Invalid/expired token |
112
+ | `EdgeConsentRequiredError` | User hasn't granted consent |
113
+ | `EdgeApiError` | API request failed |
114
+ | `EdgePopupBlockedError` | Popup was blocked |
115
+
116
+ ### Type Guards
117
+
118
+ ```typescript
119
+ isEdgeError(error) // Any SDK error
120
+ isConsentRequiredError(error) // Consent needed
121
+ isAuthenticationError(error) // Auth failed
122
+ isApiError(error) // API error
123
+ ```
124
+
125
+ ## Related Packages
126
+
127
+ - `@edgeboost/edge-connect-link` - Browser SDK for popup authentication
128
+ - `@edgeboost/edge-connect-server` - Server SDK for token exchange and API calls
129
+
130
+ ## License
131
+
132
+ MIT
133
+
134
+