@edge-markets/connect-node 1.10.1 → 1.11.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 +9 -9
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +31 -8
- package/dist/index.mjs +31 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ Supported environment variables:
|
|
|
84
84
|
|----------|-------------|
|
|
85
85
|
| `EDGE_CLIENT_ID` | User-facing OAuth client ID |
|
|
86
86
|
| `EDGE_CLIENT_SECRET` | User-facing OAuth client secret |
|
|
87
|
-
| `EDGE_ENVIRONMENT` | `production
|
|
87
|
+
| `EDGE_ENVIRONMENT` | `production` or `sandbox` |
|
|
88
88
|
| `EDGE_API_BASE_URL` | Optional Connect API override |
|
|
89
89
|
| `EDGE_OAUTH_BASE_URL` | Optional OAuth/token URL override |
|
|
90
90
|
| `EDGE_PARTNER_API_BASE_URL` | Optional partner dashboard API override |
|
|
@@ -106,7 +106,7 @@ the inline value wins and the helper returns a warning.
|
|
|
106
106
|
interface EdgeConnectServerConfig {
|
|
107
107
|
clientId: string // Your user-facing OAuth client ID
|
|
108
108
|
clientSecret: string // Your user-facing OAuth client secret (keep secret!)
|
|
109
|
-
environment: EdgeEnvironment // 'production' | '
|
|
109
|
+
environment: EdgeEnvironment // 'production' | 'sandbox'
|
|
110
110
|
|
|
111
111
|
// Optional
|
|
112
112
|
apiBaseUrl?: string // Custom API URL (dev only)
|
|
@@ -126,8 +126,8 @@ interface EdgeConnectServerConfig {
|
|
|
126
126
|
|
|
127
127
|
// By default the SDK derives partnerApiBaseUrl from apiBaseUrl by replacing
|
|
128
128
|
// /connect/v1 with /v1. For example:
|
|
129
|
-
// https://connect
|
|
130
|
-
// -> https://connect
|
|
129
|
+
// https://sandbox.connect.staging.edgeboost.io/connect/v1
|
|
130
|
+
// -> https://sandbox.connect.staging.edgeboost.io/v1
|
|
131
131
|
|
|
132
132
|
// Optional: Message Level Encryption (Connect endpoints only)
|
|
133
133
|
mle?: {
|
|
@@ -155,7 +155,7 @@ interface EdgeConnectServerConfig {
|
|
|
155
155
|
const edge = new EdgeConnectServer({
|
|
156
156
|
clientId: process.env.EDGE_CLIENT_ID!,
|
|
157
157
|
clientSecret: process.env.EDGE_CLIENT_SECRET!,
|
|
158
|
-
environment: '
|
|
158
|
+
environment: 'sandbox',
|
|
159
159
|
mle: {
|
|
160
160
|
enabled: true,
|
|
161
161
|
edgePublicKey: process.env.EDGE_MLE_EDGE_PUBLIC_KEY!,
|
|
@@ -176,7 +176,7 @@ Use `mtls` when EDGE has issued your partner backend a client certificate and ke
|
|
|
176
176
|
const edge = new EdgeConnectServer({
|
|
177
177
|
clientId: process.env.EDGE_CLIENT_ID!,
|
|
178
178
|
clientSecret: process.env.EDGE_CLIENT_SECRET!,
|
|
179
|
-
environment: '
|
|
179
|
+
environment: 'sandbox',
|
|
180
180
|
mtls: {
|
|
181
181
|
enabled: true,
|
|
182
182
|
cert: process.env.EDGE_MTLS_CERT!,
|
|
@@ -189,7 +189,7 @@ const edge = new EdgeConnectServer({
|
|
|
189
189
|
authentication material and must stay on your server.
|
|
190
190
|
|
|
191
191
|
`ca` is optional server trust material. Public EDGE Connect gateways such as
|
|
192
|
-
`https://connect.edgeboost.io` and `https://connect
|
|
192
|
+
`https://connect.edgeboost.io` and `https://sandbox.connect.staging.edgeboost.io` use
|
|
193
193
|
public certificates, so most partners should omit `ca`. If EDGE provides a
|
|
194
194
|
private server CA for a non-public endpoint, pass it as `ca`; the SDK appends it
|
|
195
195
|
to Node's default public trust roots instead of replacing them.
|
|
@@ -748,7 +748,7 @@ export class EdgeService {
|
|
|
748
748
|
this.edge = new EdgeConnectServer({
|
|
749
749
|
clientId: this.config.getOrThrow('EDGE_CLIENT_ID'),
|
|
750
750
|
clientSecret: this.config.getOrThrow('EDGE_CLIENT_SECRET'),
|
|
751
|
-
environment: this.config.get('EDGE_ENVIRONMENT', '
|
|
751
|
+
environment: this.config.get('EDGE_ENVIRONMENT', 'sandbox'),
|
|
752
752
|
})
|
|
753
753
|
}
|
|
754
754
|
|
|
@@ -781,7 +781,7 @@ import { EdgeConnectServer, isEdgeError } from '@edge-markets/connect-node'
|
|
|
781
781
|
const edge = new EdgeConnectServer({
|
|
782
782
|
clientId: process.env.EDGE_CLIENT_ID!,
|
|
783
783
|
clientSecret: process.env.EDGE_CLIENT_SECRET!,
|
|
784
|
-
environment: '
|
|
784
|
+
environment: 'sandbox',
|
|
785
785
|
})
|
|
786
786
|
|
|
787
787
|
const app = express()
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as node_https from 'node:https';
|
|
2
2
|
import { EdgeEnvironment, TransferCategory, Transfer, VerificationSession, TransferType, TransferStatus, User, VerifyIdentityOptions, VerifyIdentityResult, Balance, ListTransfersParams, TransferList, CreateVerificationSessionRequest, VerificationSessionStatusResponse, EdgeTokens, EdgeWebhookEvent, EdgeWebhookEventType } from '@edge-markets/connect';
|
|
3
|
-
export { ACTIVE_EDGE_SCOPES, Balance, BaseWebhookEvent, ConsentRevokedEventData, CreateVerificationSessionRequest, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, EdgeValidationError, EdgeWebhookEvent, EdgeWebhookEventType, ListTransfersParams, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferCompletedEventData, TransferExpiredEventData, TransferFailedEventData, TransferList, TransferListItem, TransferProcessingEventData, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isFeatureUnavailableError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
|
|
3
|
+
export { ACTIVE_EDGE_SCOPES, ALL_EDGE_SCOPES, Balance, BaseWebhookEvent, ConsentRevokedEventData, CreateVerificationSessionRequest, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_SCOPES, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, EdgeValidationError, EdgeWebhookEvent, EdgeWebhookEventType, ListTransfersParams, RESERVED_EDGE_SCOPES, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferCompletedEventData, TransferExpiredEventData, TransferFailedEventData, TransferList, TransferListItem, TransferProcessingEventData, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isFeatureUnavailableError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
|
|
4
4
|
|
|
5
5
|
type RequestEndpoint = 'connect_api' | 'oauth_token' | 'partner_webhook_sync';
|
|
6
6
|
interface RequestInfo {
|
|
@@ -37,8 +37,8 @@ interface EdgeConnectServerConfig {
|
|
|
37
37
|
* from `apiBaseUrl` by replacing `/connect/v1` with `/v1`, matching the
|
|
38
38
|
* EDGE Connect gateway layout:
|
|
39
39
|
*
|
|
40
|
-
* - user-scoped API: `https://connect
|
|
41
|
-
* - partner dashboard API: `https://connect
|
|
40
|
+
* - user-scoped API: `https://connect.edgeboost.io/connect/v1`
|
|
41
|
+
* - partner dashboard API: `https://connect.edgeboost.io/v1`
|
|
42
42
|
*/
|
|
43
43
|
partnerApiBaseUrl?: string;
|
|
44
44
|
oauthBaseUrl?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as node_https from 'node:https';
|
|
2
2
|
import { EdgeEnvironment, TransferCategory, Transfer, VerificationSession, TransferType, TransferStatus, User, VerifyIdentityOptions, VerifyIdentityResult, Balance, ListTransfersParams, TransferList, CreateVerificationSessionRequest, VerificationSessionStatusResponse, EdgeTokens, EdgeWebhookEvent, EdgeWebhookEventType } from '@edge-markets/connect';
|
|
3
|
-
export { ACTIVE_EDGE_SCOPES, Balance, BaseWebhookEvent, ConsentRevokedEventData, CreateVerificationSessionRequest, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, EdgeValidationError, EdgeWebhookEvent, EdgeWebhookEventType, ListTransfersParams, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferCompletedEventData, TransferExpiredEventData, TransferFailedEventData, TransferList, TransferListItem, TransferProcessingEventData, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isFeatureUnavailableError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
|
|
3
|
+
export { ACTIVE_EDGE_SCOPES, ALL_EDGE_SCOPES, Balance, BaseWebhookEvent, ConsentRevokedEventData, CreateVerificationSessionRequest, EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE, EDGE_SCOPES, EDGE_WEBHOOK_EVENT_TYPES, EdgeApiError, EdgeAuthenticationError, EdgeConsentRequiredError, EdgeEnvironment, EdgeError, EdgeFeatureUnavailableError, EdgeIdentityVerificationError, EdgeInsufficientScopeError, EdgeNetworkError, EdgeNotFoundError, EdgeTokenExchangeError, EdgeTokens, EdgeValidationError, EdgeWebhookEvent, EdgeWebhookEventType, ListTransfersParams, RESERVED_EDGE_SCOPES, SdkGeolocation, TRANSFER_CATEGORIES, Transfer, TransferCategory, TransferCompletedEventData, TransferExpiredEventData, TransferFailedEventData, TransferList, TransferListItem, TransferProcessingEventData, TransferStatus, TransferType, User, UserAddress, VerificationSession, VerificationSessionStatus, VerificationSessionStatusResponse, VerifyIdentityAddress, VerifyIdentityOptions, VerifyIdentityResult, VerifyIdentityScores, getEnvironmentConfig, isApiError, isAuthenticationError, isConsentRequiredError, isEdgeError, isFeatureUnavailableError, isIdentityVerificationError, isNetworkError, isProductionEnvironment } from '@edge-markets/connect';
|
|
4
4
|
|
|
5
5
|
type RequestEndpoint = 'connect_api' | 'oauth_token' | 'partner_webhook_sync';
|
|
6
6
|
interface RequestInfo {
|
|
@@ -37,8 +37,8 @@ interface EdgeConnectServerConfig {
|
|
|
37
37
|
* from `apiBaseUrl` by replacing `/connect/v1` with `/v1`, matching the
|
|
38
38
|
* EDGE Connect gateway layout:
|
|
39
39
|
*
|
|
40
|
-
* - user-scoped API: `https://connect
|
|
41
|
-
* - partner dashboard API: `https://connect
|
|
40
|
+
* - user-scoped API: `https://connect.edgeboost.io/connect/v1`
|
|
41
|
+
* - partner dashboard API: `https://connect.edgeboost.io/v1`
|
|
42
42
|
*/
|
|
43
43
|
partnerApiBaseUrl?: string;
|
|
44
44
|
oauthBaseUrl?: string;
|
package/dist/index.js
CHANGED
|
@@ -31,8 +31,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ACTIVE_EDGE_SCOPES: () => import_connect16.ACTIVE_EDGE_SCOPES,
|
|
34
|
+
ALL_EDGE_SCOPES: () => import_connect16.ALL_EDGE_SCOPES,
|
|
34
35
|
CONNECT_TRANSFER_DIRECTIONS: () => CONNECT_TRANSFER_DIRECTIONS,
|
|
35
36
|
EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE: () => import_connect15.EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
|
|
37
|
+
EDGE_SCOPES: () => import_connect16.EDGE_SCOPES,
|
|
36
38
|
EDGE_WEBHOOK_EVENT_TYPES: () => import_connect16.EDGE_WEBHOOK_EVENT_TYPES,
|
|
37
39
|
EdgeApiError: () => import_connect15.EdgeApiError,
|
|
38
40
|
EdgeAuthenticationError: () => import_connect15.EdgeAuthenticationError,
|
|
@@ -51,6 +53,7 @@ __export(index_exports, {
|
|
|
51
53
|
EdgeValidationError: () => import_connect15.EdgeValidationError,
|
|
52
54
|
EdgeWebhookInbox: () => EdgeWebhookInbox,
|
|
53
55
|
EdgeWebhookReconciler: () => EdgeWebhookReconciler,
|
|
56
|
+
RESERVED_EDGE_SCOPES: () => import_connect16.RESERVED_EDGE_SCOPES,
|
|
54
57
|
TRANSFER_CATEGORIES: () => import_connect16.TRANSFER_CATEGORIES,
|
|
55
58
|
assertSameTransferIntent: () => assertSameTransferIntent,
|
|
56
59
|
assertTransferEventMatchesIntent: () => assertTransferEventMatchesIntent,
|
|
@@ -856,7 +859,11 @@ function getInstanceKey(config) {
|
|
|
856
859
|
config.partnerClientId || ""
|
|
857
860
|
]);
|
|
858
861
|
}
|
|
859
|
-
var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set(["connect
|
|
862
|
+
var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set(["sandbox.connect.staging.edgeboost.io", "connect.edgeboost.io"]);
|
|
863
|
+
var CONNECT_INGRESS_REQUIRED_MESSAGE = "Edge Connect API requests must go through the mTLS Connect gateway. Set EDGE_API_BASE_URL and EDGE_OAUTH_BASE_URL to the Connect gateway for this environment and configure EDGE_MTLS_CERT and EDGE_MTLS_KEY.";
|
|
864
|
+
var MTLS_REQUIRED_MESSAGE = "Edge Connect rejected this request because no trusted partner mTLS client certificate was presented. Configure the issued EDGE_MTLS_CERT and EDGE_MTLS_KEY and retry through the Connect gateway.";
|
|
865
|
+
var MTLS_CLIENT_UNREGISTERED_MESSAGE = "Edge Connect accepted the client certificate at the gateway, but the certificate is not registered for this partner. Contact EDGE DevRel to bind the certificate fingerprint to your OAuth client ID.";
|
|
866
|
+
var MTLS_CLIENT_MISMATCH_MESSAGE = "Edge Connect accepted the client certificate at the gateway, but it is not bound to the OAuth client ID used by this request. Use the certificate issued for this client ID or contact EDGE DevRel.";
|
|
860
867
|
function isMtlsEnforcedHost(host) {
|
|
861
868
|
if (MTLS_ENFORCED_HOSTS.has(host)) {
|
|
862
869
|
return true;
|
|
@@ -869,7 +876,7 @@ function isMtlsEnforcedHost(host) {
|
|
|
869
876
|
return false;
|
|
870
877
|
}
|
|
871
878
|
function environmentRequiresMtls(environment, apiBaseUrl) {
|
|
872
|
-
if (environment === "
|
|
879
|
+
if (environment === "sandbox" || environment === "production") {
|
|
873
880
|
return true;
|
|
874
881
|
}
|
|
875
882
|
try {
|
|
@@ -1487,18 +1494,31 @@ var EdgeConnectServer = class _EdgeConnectServer {
|
|
|
1487
1494
|
});
|
|
1488
1495
|
}
|
|
1489
1496
|
async handleApiErrorFromBody(error, status, path) {
|
|
1497
|
+
const errorCode = error.error || error.code;
|
|
1490
1498
|
if (status === 401) {
|
|
1491
1499
|
return new import_connect5.EdgeAuthenticationError(error.message || "Access token is invalid or expired", error);
|
|
1492
1500
|
}
|
|
1493
1501
|
if (status === 403) {
|
|
1494
|
-
if (
|
|
1502
|
+
if (errorCode === "connect_ingress_required") {
|
|
1503
|
+
return new import_connect5.EdgeApiError("connect_ingress_required", CONNECT_INGRESS_REQUIRED_MESSAGE, status, error);
|
|
1504
|
+
}
|
|
1505
|
+
if (errorCode === "mtls_required") {
|
|
1506
|
+
return new import_connect5.EdgeApiError("mtls_required", MTLS_REQUIRED_MESSAGE, status, error);
|
|
1507
|
+
}
|
|
1508
|
+
if (errorCode === "mtls_client_unregistered") {
|
|
1509
|
+
return new import_connect5.EdgeApiError("mtls_client_unregistered", MTLS_CLIENT_UNREGISTERED_MESSAGE, status, error);
|
|
1510
|
+
}
|
|
1511
|
+
if (errorCode === "mtls_client_mismatch") {
|
|
1512
|
+
return new import_connect5.EdgeApiError("mtls_client_mismatch", MTLS_CLIENT_MISMATCH_MESSAGE, status, error);
|
|
1513
|
+
}
|
|
1514
|
+
if (errorCode === "consent_required") {
|
|
1495
1515
|
return new import_connect5.EdgeConsentRequiredError(
|
|
1496
1516
|
this.config.clientId,
|
|
1497
1517
|
error.consentUrl,
|
|
1498
1518
|
error.message
|
|
1499
1519
|
);
|
|
1500
1520
|
}
|
|
1501
|
-
if (
|
|
1521
|
+
if (errorCode === "insufficient_scope" || errorCode === "insufficient_consent") {
|
|
1502
1522
|
return new import_connect5.EdgeInsufficientScopeError(
|
|
1503
1523
|
error.missing_scopes || error.missingScopes || [],
|
|
1504
1524
|
error.message
|
|
@@ -1580,7 +1600,7 @@ function readPemValue(env, valueName, pathName, warnings) {
|
|
|
1580
1600
|
}
|
|
1581
1601
|
}
|
|
1582
1602
|
function readEnvironment(env) {
|
|
1583
|
-
const value = readEnv(env, "EDGE_ENVIRONMENT") || "
|
|
1603
|
+
const value = readEnv(env, "EDGE_ENVIRONMENT") || "sandbox";
|
|
1584
1604
|
if (!ENVIRONMENT_NAMES.has(value)) {
|
|
1585
1605
|
throw new import_connect6.EdgeValidationError("Invalid EDGE_ENVIRONMENT", {
|
|
1586
1606
|
EDGE_ENVIRONMENT: [`Must be one of: ${Array.from(ENVIRONMENT_NAMES).join(", ")}`]
|
|
@@ -1642,11 +1662,11 @@ function buildMtlsConfig(env, requireMtls, warnings) {
|
|
|
1642
1662
|
};
|
|
1643
1663
|
}
|
|
1644
1664
|
function inferMtlsRequirement(environment, apiBaseUrl) {
|
|
1645
|
-
if (environment === "
|
|
1665
|
+
if (environment === "sandbox" || environment === "production") return true;
|
|
1646
1666
|
const resolvedApiBaseUrl = apiBaseUrl || (0, import_connect6.getEnvironmentConfig)(environment).apiBaseUrl;
|
|
1647
1667
|
try {
|
|
1648
1668
|
const host = new URL(resolvedApiBaseUrl).host;
|
|
1649
|
-
return host === "connect
|
|
1669
|
+
return host === "sandbox.connect.staging.edgeboost.io" || host === "connect.edgeboost.io";
|
|
1650
1670
|
} catch {
|
|
1651
1671
|
return false;
|
|
1652
1672
|
}
|
|
@@ -1657,7 +1677,7 @@ function createEdgeConnectServerFromEnv(options = {}) {
|
|
|
1657
1677
|
const environment = readEnvironment(env);
|
|
1658
1678
|
const apiBaseUrl = readEnv(env, "EDGE_API_BASE_URL");
|
|
1659
1679
|
const mtlsRequiredByTarget = inferMtlsRequirement(environment, apiBaseUrl);
|
|
1660
|
-
const requireMtls = options.requireMtls ?? readBooleanEnv(env, "EDGE_REQUIRE_MTLS") ??
|
|
1680
|
+
const requireMtls = options.requireMtls ?? readBooleanEnv(env, "EDGE_REQUIRE_MTLS") ?? mtlsRequiredByTarget;
|
|
1661
1681
|
const mtls = buildMtlsConfig(env, requireMtls, warnings);
|
|
1662
1682
|
const timeout = readTimeout(env, options.timeout);
|
|
1663
1683
|
const clientId = readFirstEnv(env, ["EDGE_CLIENT_ID", "EDGE_CONNECT_CLIENT_ID"]) || "";
|
|
@@ -2658,8 +2678,10 @@ var import_connect16 = require("@edge-markets/connect");
|
|
|
2658
2678
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2659
2679
|
0 && (module.exports = {
|
|
2660
2680
|
ACTIVE_EDGE_SCOPES,
|
|
2681
|
+
ALL_EDGE_SCOPES,
|
|
2661
2682
|
CONNECT_TRANSFER_DIRECTIONS,
|
|
2662
2683
|
EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
|
|
2684
|
+
EDGE_SCOPES,
|
|
2663
2685
|
EDGE_WEBHOOK_EVENT_TYPES,
|
|
2664
2686
|
EdgeApiError,
|
|
2665
2687
|
EdgeAuthenticationError,
|
|
@@ -2678,6 +2700,7 @@ var import_connect16 = require("@edge-markets/connect");
|
|
|
2678
2700
|
EdgeValidationError,
|
|
2679
2701
|
EdgeWebhookInbox,
|
|
2680
2702
|
EdgeWebhookReconciler,
|
|
2703
|
+
RESERVED_EDGE_SCOPES,
|
|
2681
2704
|
TRANSFER_CATEGORIES,
|
|
2682
2705
|
assertSameTransferIntent,
|
|
2683
2706
|
assertTransferEventMatchesIntent,
|
package/dist/index.mjs
CHANGED
|
@@ -769,7 +769,11 @@ function getInstanceKey(config) {
|
|
|
769
769
|
config.partnerClientId || ""
|
|
770
770
|
]);
|
|
771
771
|
}
|
|
772
|
-
var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set(["connect
|
|
772
|
+
var MTLS_ENFORCED_HOSTS = /* @__PURE__ */ new Set(["sandbox.connect.staging.edgeboost.io", "connect.edgeboost.io"]);
|
|
773
|
+
var CONNECT_INGRESS_REQUIRED_MESSAGE = "Edge Connect API requests must go through the mTLS Connect gateway. Set EDGE_API_BASE_URL and EDGE_OAUTH_BASE_URL to the Connect gateway for this environment and configure EDGE_MTLS_CERT and EDGE_MTLS_KEY.";
|
|
774
|
+
var MTLS_REQUIRED_MESSAGE = "Edge Connect rejected this request because no trusted partner mTLS client certificate was presented. Configure the issued EDGE_MTLS_CERT and EDGE_MTLS_KEY and retry through the Connect gateway.";
|
|
775
|
+
var MTLS_CLIENT_UNREGISTERED_MESSAGE = "Edge Connect accepted the client certificate at the gateway, but the certificate is not registered for this partner. Contact EDGE DevRel to bind the certificate fingerprint to your OAuth client ID.";
|
|
776
|
+
var MTLS_CLIENT_MISMATCH_MESSAGE = "Edge Connect accepted the client certificate at the gateway, but it is not bound to the OAuth client ID used by this request. Use the certificate issued for this client ID or contact EDGE DevRel.";
|
|
773
777
|
function isMtlsEnforcedHost(host) {
|
|
774
778
|
if (MTLS_ENFORCED_HOSTS.has(host)) {
|
|
775
779
|
return true;
|
|
@@ -782,7 +786,7 @@ function isMtlsEnforcedHost(host) {
|
|
|
782
786
|
return false;
|
|
783
787
|
}
|
|
784
788
|
function environmentRequiresMtls(environment, apiBaseUrl) {
|
|
785
|
-
if (environment === "
|
|
789
|
+
if (environment === "sandbox" || environment === "production") {
|
|
786
790
|
return true;
|
|
787
791
|
}
|
|
788
792
|
try {
|
|
@@ -1400,18 +1404,31 @@ var EdgeConnectServer = class _EdgeConnectServer {
|
|
|
1400
1404
|
});
|
|
1401
1405
|
}
|
|
1402
1406
|
async handleApiErrorFromBody(error, status, path) {
|
|
1407
|
+
const errorCode = error.error || error.code;
|
|
1403
1408
|
if (status === 401) {
|
|
1404
1409
|
return new EdgeAuthenticationError2(error.message || "Access token is invalid or expired", error);
|
|
1405
1410
|
}
|
|
1406
1411
|
if (status === 403) {
|
|
1407
|
-
if (
|
|
1412
|
+
if (errorCode === "connect_ingress_required") {
|
|
1413
|
+
return new EdgeApiError("connect_ingress_required", CONNECT_INGRESS_REQUIRED_MESSAGE, status, error);
|
|
1414
|
+
}
|
|
1415
|
+
if (errorCode === "mtls_required") {
|
|
1416
|
+
return new EdgeApiError("mtls_required", MTLS_REQUIRED_MESSAGE, status, error);
|
|
1417
|
+
}
|
|
1418
|
+
if (errorCode === "mtls_client_unregistered") {
|
|
1419
|
+
return new EdgeApiError("mtls_client_unregistered", MTLS_CLIENT_UNREGISTERED_MESSAGE, status, error);
|
|
1420
|
+
}
|
|
1421
|
+
if (errorCode === "mtls_client_mismatch") {
|
|
1422
|
+
return new EdgeApiError("mtls_client_mismatch", MTLS_CLIENT_MISMATCH_MESSAGE, status, error);
|
|
1423
|
+
}
|
|
1424
|
+
if (errorCode === "consent_required") {
|
|
1408
1425
|
return new EdgeConsentRequiredError(
|
|
1409
1426
|
this.config.clientId,
|
|
1410
1427
|
error.consentUrl,
|
|
1411
1428
|
error.message
|
|
1412
1429
|
);
|
|
1413
1430
|
}
|
|
1414
|
-
if (
|
|
1431
|
+
if (errorCode === "insufficient_scope" || errorCode === "insufficient_consent") {
|
|
1415
1432
|
return new EdgeInsufficientScopeError(
|
|
1416
1433
|
error.missing_scopes || error.missingScopes || [],
|
|
1417
1434
|
error.message
|
|
@@ -1493,7 +1510,7 @@ function readPemValue(env, valueName, pathName, warnings) {
|
|
|
1493
1510
|
}
|
|
1494
1511
|
}
|
|
1495
1512
|
function readEnvironment(env) {
|
|
1496
|
-
const value = readEnv(env, "EDGE_ENVIRONMENT") || "
|
|
1513
|
+
const value = readEnv(env, "EDGE_ENVIRONMENT") || "sandbox";
|
|
1497
1514
|
if (!ENVIRONMENT_NAMES.has(value)) {
|
|
1498
1515
|
throw new EdgeValidationError4("Invalid EDGE_ENVIRONMENT", {
|
|
1499
1516
|
EDGE_ENVIRONMENT: [`Must be one of: ${Array.from(ENVIRONMENT_NAMES).join(", ")}`]
|
|
@@ -1555,11 +1572,11 @@ function buildMtlsConfig(env, requireMtls, warnings) {
|
|
|
1555
1572
|
};
|
|
1556
1573
|
}
|
|
1557
1574
|
function inferMtlsRequirement(environment, apiBaseUrl) {
|
|
1558
|
-
if (environment === "
|
|
1575
|
+
if (environment === "sandbox" || environment === "production") return true;
|
|
1559
1576
|
const resolvedApiBaseUrl = apiBaseUrl || getEnvironmentConfig2(environment).apiBaseUrl;
|
|
1560
1577
|
try {
|
|
1561
1578
|
const host = new URL(resolvedApiBaseUrl).host;
|
|
1562
|
-
return host === "connect
|
|
1579
|
+
return host === "sandbox.connect.staging.edgeboost.io" || host === "connect.edgeboost.io";
|
|
1563
1580
|
} catch {
|
|
1564
1581
|
return false;
|
|
1565
1582
|
}
|
|
@@ -1570,7 +1587,7 @@ function createEdgeConnectServerFromEnv(options = {}) {
|
|
|
1570
1587
|
const environment = readEnvironment(env);
|
|
1571
1588
|
const apiBaseUrl = readEnv(env, "EDGE_API_BASE_URL");
|
|
1572
1589
|
const mtlsRequiredByTarget = inferMtlsRequirement(environment, apiBaseUrl);
|
|
1573
|
-
const requireMtls = options.requireMtls ?? readBooleanEnv(env, "EDGE_REQUIRE_MTLS") ??
|
|
1590
|
+
const requireMtls = options.requireMtls ?? readBooleanEnv(env, "EDGE_REQUIRE_MTLS") ?? mtlsRequiredByTarget;
|
|
1574
1591
|
const mtls = buildMtlsConfig(env, requireMtls, warnings);
|
|
1575
1592
|
const timeout = readTimeout(env, options.timeout);
|
|
1576
1593
|
const clientId = readFirstEnv(env, ["EDGE_CLIENT_ID", "EDGE_CONNECT_CLIENT_ID"]) || "";
|
|
@@ -2600,6 +2617,9 @@ import {
|
|
|
2600
2617
|
} from "@edge-markets/connect";
|
|
2601
2618
|
import {
|
|
2602
2619
|
ACTIVE_EDGE_SCOPES,
|
|
2620
|
+
ALL_EDGE_SCOPES,
|
|
2621
|
+
EDGE_SCOPES,
|
|
2622
|
+
RESERVED_EDGE_SCOPES,
|
|
2603
2623
|
EDGE_WEBHOOK_EVENT_TYPES as EDGE_WEBHOOK_EVENT_TYPES2,
|
|
2604
2624
|
TRANSFER_CATEGORIES,
|
|
2605
2625
|
getEnvironmentConfig as getEnvironmentConfig3,
|
|
@@ -2607,8 +2627,10 @@ import {
|
|
|
2607
2627
|
} from "@edge-markets/connect";
|
|
2608
2628
|
export {
|
|
2609
2629
|
ACTIVE_EDGE_SCOPES,
|
|
2630
|
+
ALL_EDGE_SCOPES,
|
|
2610
2631
|
CONNECT_TRANSFER_DIRECTIONS,
|
|
2611
2632
|
EDGE_CONNECT_FEATURE_UNAVAILABLE_MESSAGE,
|
|
2633
|
+
EDGE_SCOPES,
|
|
2612
2634
|
EDGE_WEBHOOK_EVENT_TYPES2 as EDGE_WEBHOOK_EVENT_TYPES,
|
|
2613
2635
|
EdgeApiError2 as EdgeApiError,
|
|
2614
2636
|
EdgeAuthenticationError4 as EdgeAuthenticationError,
|
|
@@ -2627,6 +2649,7 @@ export {
|
|
|
2627
2649
|
EdgeValidationError13 as EdgeValidationError,
|
|
2628
2650
|
EdgeWebhookInbox,
|
|
2629
2651
|
EdgeWebhookReconciler,
|
|
2652
|
+
RESERVED_EDGE_SCOPES,
|
|
2630
2653
|
TRANSFER_CATEGORIES,
|
|
2631
2654
|
assertSameTransferIntent,
|
|
2632
2655
|
assertTransferEventMatchesIntent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edge-markets/connect-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "Server SDK for EDGE Connect token exchange and API calls",
|
|
5
5
|
"author": "Edge Markets",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"undici": "^5.29.0",
|
|
25
|
-
"@edge-markets/connect": "^1.
|
|
25
|
+
"@edge-markets/connect": "^1.9.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "^8.0.0",
|