@edge-markets/connect-node 1.6.0 → 1.6.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/README.md CHANGED
@@ -175,7 +175,7 @@ const balance = await client.getBalance()
175
175
  ### Transfers
176
176
 
177
177
  ```typescript
178
- // Initiate transfer (requires OTP verification)
178
+ // 1. Initiate the transfer — returns a pending transfer that requires verification.
179
179
  const transfer = await client.initiateTransfer({
180
180
  type: 'debit', // 'debit' = pull from user, 'credit' = push to user
181
181
  amount: '100.00',
@@ -183,12 +183,22 @@ const transfer = await client.initiateTransfer({
183
183
  })
184
184
  // Returns: { transferId, status: 'pending_verification', otpMethod }
185
185
 
186
- // Verify with OTP
187
- const result = await client.verifyTransfer(transfer.transferId, userOtp)
188
- // Returns: { transferId, status: 'completed' | 'failed' }
186
+ // 2. Create an EDGE-hosted verification session. The returned `verificationUrl`
187
+ // is a single-use, short-lived URL you embed in an iframe or popup on your
188
+ // frontend. The user enters their OTP inside the EDGE-hosted UI — OTP secrets
189
+ // never touch your infrastructure.
190
+ const session = await client.createVerificationSession(transfer.transferId, {
191
+ origin: 'https://your-site.example.com',
192
+ })
193
+ // Returns: { sessionId, verificationUrl, expiresAt }
194
+
195
+ // 3. Listen for the postMessage event from the iframe (or poll
196
+ // getVerificationSessionStatus) to learn when verification completes.
197
+ // A `transfer.completed` webhook will be delivered to your configured
198
+ // webhook URL once the transfer settles.
189
199
 
190
200
  // Get transfer status
191
- const status = await client.getTransfer(transferId)
201
+ const status = await client.getTransfer(transfer.transferId)
192
202
 
193
203
  // List transfers
194
204
  const { transfers, total } = await client.listTransfers({
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as node_https from 'node:https';
2
- import { EdgeEnvironment, TransferCategory, SdkGeolocation, User, VerifyIdentityOptions, VerifyIdentityResult, Balance, Transfer, ListTransfersParams, TransferList, CreateVerificationSessionRequest, VerificationSession, VerificationSessionStatusResponse, EdgeTokens } from '@edge-markets/connect';
2
+ import { EdgeEnvironment, TransferCategory, User, VerifyIdentityOptions, VerifyIdentityResult, Balance, Transfer, ListTransfersParams, TransferList, CreateVerificationSessionRequest, VerificationSession, VerificationSessionStatusResponse, EdgeTokens } from '@edge-markets/connect';
3
3
  export { Balance, CreateVerificationSessionRequest, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, ListTransfersParams, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferList, TransferListItem, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
4
4
 
5
5
  interface RequestInfo {
@@ -56,13 +56,6 @@ interface TransferOptions {
56
56
  /** Optional transaction category for settlement window determination */
57
57
  category?: TransferCategory;
58
58
  }
59
- /**
60
- * Options for verifying a transfer with OTP.
61
- */
62
- interface VerifyTransferOptions {
63
- /** SDK-reported geolocation for cross-referencing against IP-based geo */
64
- sdkGeo?: SdkGeolocation;
65
- }
66
59
 
67
60
  /**
68
61
  * A lightweight, user-scoped API client created via {@link EdgeConnectServer.forUser}.
@@ -78,7 +71,6 @@ declare class EdgeUserClient {
78
71
  verifyIdentity(options: VerifyIdentityOptions): Promise<VerifyIdentityResult>;
79
72
  getBalance(): Promise<Balance>;
80
73
  initiateTransfer(options: TransferOptions): Promise<Transfer>;
81
- verifyTransfer(transferId: string, otp: string, options?: VerifyTransferOptions): Promise<Transfer>;
82
74
  getTransfer(transferId: string): Promise<Transfer>;
83
75
  listTransfers(params?: ListTransfersParams): Promise<TransferList>;
84
76
  revokeConsent(): Promise<{
@@ -132,4 +124,4 @@ declare class EdgeConnectServer {
132
124
  private handleApiErrorFromBody;
133
125
  }
134
126
 
135
- export { EdgeConnectServer, type EdgeConnectServerConfig, EdgeUserClient, type MtlsConfig, type RequestInfo, type ResponseInfo, type RetryConfig, type TransferOptions, type VerifyTransferOptions };
127
+ export { EdgeConnectServer, type EdgeConnectServerConfig, EdgeUserClient, type MtlsConfig, type RequestInfo, type ResponseInfo, type RetryConfig, type TransferOptions };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as node_https from 'node:https';
2
- import { EdgeEnvironment, TransferCategory, SdkGeolocation, User, VerifyIdentityOptions, VerifyIdentityResult, Balance, Transfer, ListTransfersParams, TransferList, CreateVerificationSessionRequest, VerificationSession, VerificationSessionStatusResponse, EdgeTokens } from '@edge-markets/connect';
2
+ import { EdgeEnvironment, TransferCategory, User, VerifyIdentityOptions, VerifyIdentityResult, Balance, Transfer, ListTransfersParams, TransferList, CreateVerificationSessionRequest, VerificationSession, VerificationSessionStatusResponse, EdgeTokens } from '@edge-markets/connect';
3
3
  export { Balance, CreateVerificationSessionRequest, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, ListTransfersParams, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferList, TransferListItem, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
4
4
 
5
5
  interface RequestInfo {
@@ -56,13 +56,6 @@ interface TransferOptions {
56
56
  /** Optional transaction category for settlement window determination */
57
57
  category?: TransferCategory;
58
58
  }
59
- /**
60
- * Options for verifying a transfer with OTP.
61
- */
62
- interface VerifyTransferOptions {
63
- /** SDK-reported geolocation for cross-referencing against IP-based geo */
64
- sdkGeo?: SdkGeolocation;
65
- }
66
59
 
67
60
  /**
68
61
  * A lightweight, user-scoped API client created via {@link EdgeConnectServer.forUser}.
@@ -78,7 +71,6 @@ declare class EdgeUserClient {
78
71
  verifyIdentity(options: VerifyIdentityOptions): Promise<VerifyIdentityResult>;
79
72
  getBalance(): Promise<Balance>;
80
73
  initiateTransfer(options: TransferOptions): Promise<Transfer>;
81
- verifyTransfer(transferId: string, otp: string, options?: VerifyTransferOptions): Promise<Transfer>;
82
74
  getTransfer(transferId: string): Promise<Transfer>;
83
75
  listTransfers(params?: ListTransfersParams): Promise<TransferList>;
84
76
  revokeConsent(): Promise<{
@@ -132,4 +124,4 @@ declare class EdgeConnectServer {
132
124
  private handleApiErrorFromBody;
133
125
  }
134
126
 
135
- export { EdgeConnectServer, type EdgeConnectServerConfig, EdgeUserClient, type MtlsConfig, type RequestInfo, type ResponseInfo, type RetryConfig, type TransferOptions, type VerifyTransferOptions };
127
+ export { EdgeConnectServer, type EdgeConnectServerConfig, EdgeUserClient, type MtlsConfig, type RequestInfo, type ResponseInfo, type RetryConfig, type TransferOptions };
package/dist/index.js CHANGED
@@ -134,18 +134,6 @@ var EdgeUserClient = class {
134
134
  }
135
135
  return this.server._apiRequest("POST", "/transfer", this.accessToken, body);
136
136
  }
137
- async verifyTransfer(transferId, otp, options) {
138
- const body = { otp };
139
- if (options?.sdkGeo) {
140
- body.sdkGeo = options.sdkGeo;
141
- }
142
- return this.server._apiRequest(
143
- "POST",
144
- `/transfer/${encodeURIComponent(transferId)}/verify`,
145
- this.accessToken,
146
- body
147
- );
148
- }
149
137
  async getTransfer(transferId) {
150
138
  return this.server._apiRequest("GET", `/transfer/${encodeURIComponent(transferId)}`, this.accessToken);
151
139
  }
@@ -308,6 +296,28 @@ var instances = /* @__PURE__ */ new Map();
308
296
  function getInstanceKey(config) {
309
297
  return `${config.clientId}:${config.environment}`;
310
298
  }
299
+ var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set(["connect-staging.edgeboost.io", "api.edgeboost.com"]);
300
+ function isMtlsEnforcedHost(host) {
301
+ if (MTLS_ENFORCED_HOSTS.has(host)) {
302
+ return true;
303
+ }
304
+ for (const enforced of MTLS_ENFORCED_HOSTS) {
305
+ if (host.endsWith("." + enforced)) {
306
+ return true;
307
+ }
308
+ }
309
+ return false;
310
+ }
311
+ function environmentRequiresMtls(environment, apiBaseUrl) {
312
+ if (environment === "staging" || environment === "production") {
313
+ return true;
314
+ }
315
+ try {
316
+ return isMtlsEnforcedHost(new URL(apiBaseUrl).host);
317
+ } catch {
318
+ return false;
319
+ }
320
+ }
311
321
  var EdgeConnectServer = class _EdgeConnectServer {
312
322
  static getInstance(config) {
313
323
  const key = getInstanceKey(config);
@@ -343,6 +353,10 @@ var EdgeConnectServer = class _EdgeConnectServer {
343
353
  validateMtlsConfig(config.mtls);
344
354
  this.httpsAgent = createHttpsAgent(config.mtls);
345
355
  this.dispatcher = createUndiciDispatcher(config.mtls);
356
+ } else if (environmentRequiresMtls(config.environment, this.apiBaseUrl)) {
357
+ console.warn(
358
+ `[EdgeConnectServer] environment='${config.environment}' is served from an mTLS-enforced host (${this.apiBaseUrl}) but no mtls config was provided. Requests will fail at the TLS handshake with a connection reset. Pass mtls: { enabled: true, cert, key, ca? } to EdgeConnectServer or coordinate with EDGE DevRel to issue a partner client certificate.`
359
+ );
346
360
  }
347
361
  }
348
362
  /**
package/dist/index.mjs CHANGED
@@ -97,18 +97,6 @@ var EdgeUserClient = class {
97
97
  }
98
98
  return this.server._apiRequest("POST", "/transfer", this.accessToken, body);
99
99
  }
100
- async verifyTransfer(transferId, otp, options) {
101
- const body = { otp };
102
- if (options?.sdkGeo) {
103
- body.sdkGeo = options.sdkGeo;
104
- }
105
- return this.server._apiRequest(
106
- "POST",
107
- `/transfer/${encodeURIComponent(transferId)}/verify`,
108
- this.accessToken,
109
- body
110
- );
111
- }
112
100
  async getTransfer(transferId) {
113
101
  return this.server._apiRequest("GET", `/transfer/${encodeURIComponent(transferId)}`, this.accessToken);
114
102
  }
@@ -271,6 +259,28 @@ var instances = /* @__PURE__ */ new Map();
271
259
  function getInstanceKey(config) {
272
260
  return `${config.clientId}:${config.environment}`;
273
261
  }
262
+ var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set(["connect-staging.edgeboost.io", "api.edgeboost.com"]);
263
+ function isMtlsEnforcedHost(host) {
264
+ if (MTLS_ENFORCED_HOSTS.has(host)) {
265
+ return true;
266
+ }
267
+ for (const enforced of MTLS_ENFORCED_HOSTS) {
268
+ if (host.endsWith("." + enforced)) {
269
+ return true;
270
+ }
271
+ }
272
+ return false;
273
+ }
274
+ function environmentRequiresMtls(environment, apiBaseUrl) {
275
+ if (environment === "staging" || environment === "production") {
276
+ return true;
277
+ }
278
+ try {
279
+ return isMtlsEnforcedHost(new URL(apiBaseUrl).host);
280
+ } catch {
281
+ return false;
282
+ }
283
+ }
274
284
  var EdgeConnectServer = class _EdgeConnectServer {
275
285
  static getInstance(config) {
276
286
  const key = getInstanceKey(config);
@@ -306,6 +316,10 @@ var EdgeConnectServer = class _EdgeConnectServer {
306
316
  validateMtlsConfig(config.mtls);
307
317
  this.httpsAgent = createHttpsAgent(config.mtls);
308
318
  this.dispatcher = createUndiciDispatcher(config.mtls);
319
+ } else if (environmentRequiresMtls(config.environment, this.apiBaseUrl)) {
320
+ console.warn(
321
+ `[EdgeConnectServer] environment='${config.environment}' is served from an mTLS-enforced host (${this.apiBaseUrl}) but no mtls config was provided. Requests will fail at the TLS handshake with a connection reset. Pass mtls: { enabled: true, cert, key, ca? } to EdgeConnectServer or coordinate with EDGE DevRel to issue a partner client certificate.`
322
+ );
309
323
  }
310
324
  }
311
325
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edge-markets/connect-node",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Server SDK for EDGE Connect token exchange and API calls",
5
5
  "author": "Edge Markets",
6
6
  "license": "MIT",
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@edge-markets/connect": "^1.5.0"
24
+ "@edge-markets/connect": "^1.5.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsup": "^8.0.0",