@paxosglobal/sdk 0.0.0-stage → 0.1.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/AGENTS.md +268 -0
- package/CHANGELOG.md +35 -0
- package/LICENSE +191 -0
- package/README.md +445 -2
- package/dist/auth.d.ts +60 -0
- package/dist/auth.js +248 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +353 -0
- package/dist/client.js +967 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +16 -0
- package/dist/constants.js +17 -0
- package/dist/constants.js.map +1 -0
- package/dist/decimal-fields.d.ts +16 -0
- package/dist/decimal-fields.js +570 -0
- package/dist/decimal-fields.js.map +1 -0
- package/dist/decimal.d.ts +25 -0
- package/dist/decimal.js +93 -0
- package/dist/decimal.js.map +1 -0
- package/dist/decode.d.ts +34 -0
- package/dist/decode.js +118 -0
- package/dist/decode.js.map +1 -0
- package/dist/enums.d.ts +1080 -0
- package/dist/enums.js +1031 -0
- package/dist/enums.js.map +1 -0
- package/dist/errors.d.ts +142 -0
- package/dist/errors.js +261 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated-types.d.ts +13629 -0
- package/dist/generated-types.js +3 -0
- package/dist/generated-types.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +299 -0
- package/dist/models.js +3 -0
- package/dist/models.js.map +1 -0
- package/dist/paxos-client.d.ts +107 -0
- package/dist/paxos-client.js +157 -0
- package/dist/paxos-client.js.map +1 -0
- package/dist/query-keys.d.ts +1 -0
- package/dist/query-keys.js +31 -0
- package/dist/query-keys.js.map +1 -0
- package/dist/response-defaults.d.ts +2 -0
- package/dist/response-defaults.js +109 -0
- package/dist/response-defaults.js.map +1 -0
- package/dist/services/account-members.d.ts +32 -0
- package/dist/services/account-members.js +46 -0
- package/dist/services/account-members.js.map +1 -0
- package/dist/services/accounts.d.ts +74 -0
- package/dist/services/accounts.js +71 -0
- package/dist/services/accounts.js.map +1 -0
- package/dist/services/address-verification.d.ts +72 -0
- package/dist/services/address-verification.js +64 -0
- package/dist/services/address-verification.js.map +1 -0
- package/dist/services/api-credentials.d.ts +44 -0
- package/dist/services/api-credentials.js +42 -0
- package/dist/services/api-credentials.js.map +1 -0
- package/dist/services/claims.d.ts +68 -0
- package/dist/services/claims.js +67 -0
- package/dist/services/claims.js.map +1 -0
- package/dist/services/cross-chain-transfer.d.ts +71 -0
- package/dist/services/cross-chain-transfer.js +68 -0
- package/dist/services/cross-chain-transfer.js.map +1 -0
- package/dist/services/crypto-deposits.d.ts +30 -0
- package/dist/services/crypto-deposits.js +39 -0
- package/dist/services/crypto-deposits.js.map +1 -0
- package/dist/services/crypto-withdrawals.d.ts +60 -0
- package/dist/services/crypto-withdrawals.js +42 -0
- package/dist/services/crypto-withdrawals.js.map +1 -0
- package/dist/services/deposit-addresses.d.ts +54 -0
- package/dist/services/deposit-addresses.js +36 -0
- package/dist/services/deposit-addresses.js.map +1 -0
- package/dist/services/events.d.ts +53 -0
- package/dist/services/events.js +39 -0
- package/dist/services/events.js.map +1 -0
- package/dist/services/exchange.d.ts +52 -0
- package/dist/services/exchange.js +30 -0
- package/dist/services/exchange.js.map +1 -0
- package/dist/services/fees.d.ts +15 -0
- package/dist/services/fees.js +24 -0
- package/dist/services/fees.js.map +1 -0
- package/dist/services/fiat-transfers.d.ts +133 -0
- package/dist/services/fiat-transfers.js +127 -0
- package/dist/services/fiat-transfers.js.map +1 -0
- package/dist/services/identity-controls.d.ts +43 -0
- package/dist/services/identity-controls.js +42 -0
- package/dist/services/identity-controls.js.map +1 -0
- package/dist/services/identity-documents.d.ts +45 -0
- package/dist/services/identity-documents.js +50 -0
- package/dist/services/identity-documents.js.map +1 -0
- package/dist/services/identity.d.ts +122 -0
- package/dist/services/identity.js +66 -0
- package/dist/services/identity.js.map +1 -0
- package/dist/services/index.d.ts +89 -0
- package/dist/services/index.js +55 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/institution-members.d.ts +30 -0
- package/dist/services/institution-members.js +44 -0
- package/dist/services/institution-members.js.map +1 -0
- package/dist/services/internal-transfers.d.ts +15 -0
- package/dist/services/internal-transfers.js +26 -0
- package/dist/services/internal-transfers.js.map +1 -0
- package/dist/services/issuer-quotes.d.ts +72 -0
- package/dist/services/issuer-quotes.js +66 -0
- package/dist/services/issuer-quotes.js.map +1 -0
- package/dist/services/limits.d.ts +20 -0
- package/dist/services/limits.js +23 -0
- package/dist/services/limits.js.map +1 -0
- package/dist/services/market-data.d.ts +15 -0
- package/dist/services/market-data.js +23 -0
- package/dist/services/market-data.js.map +1 -0
- package/dist/services/monitoring-addresses.d.ts +64 -0
- package/dist/services/monitoring-addresses.js +68 -0
- package/dist/services/monitoring-addresses.js.map +1 -0
- package/dist/services/orchestration-rules.d.ts +53 -0
- package/dist/services/orchestration-rules.js +47 -0
- package/dist/services/orchestration-rules.js.map +1 -0
- package/dist/services/orchestrations.d.ts +70 -0
- package/dist/services/orchestrations.js +45 -0
- package/dist/services/orchestrations.js.map +1 -0
- package/dist/services/orders.d.ts +86 -0
- package/dist/services/orders.js +67 -0
- package/dist/services/orders.js.map +1 -0
- package/dist/services/paxos-transfers.d.ts +24 -0
- package/dist/services/paxos-transfers.js +35 -0
- package/dist/services/paxos-transfers.js.map +1 -0
- package/dist/services/payments.d.ts +46 -0
- package/dist/services/payments.js +35 -0
- package/dist/services/payments.js.map +1 -0
- package/dist/services/payout-groups.d.ts +59 -0
- package/dist/services/payout-groups.js +59 -0
- package/dist/services/payout-groups.js.map +1 -0
- package/dist/services/pricing.d.ts +67 -0
- package/dist/services/pricing.js +42 -0
- package/dist/services/pricing.js.map +1 -0
- package/dist/services/profiles.d.ts +106 -0
- package/dist/services/profiles.js +84 -0
- package/dist/services/profiles.js.map +1 -0
- package/dist/services/quote-executions.d.ts +51 -0
- package/dist/services/quote-executions.js +41 -0
- package/dist/services/quote-executions.js.map +1 -0
- package/dist/services/quotes.d.ts +44 -0
- package/dist/services/quotes.js +48 -0
- package/dist/services/quotes.js.map +1 -0
- package/dist/services/reward-addresses.d.ts +80 -0
- package/dist/services/reward-addresses.js +79 -0
- package/dist/services/reward-addresses.js.map +1 -0
- package/dist/services/rewards-statements.d.ts +35 -0
- package/dist/services/rewards-statements.js +32 -0
- package/dist/services/rewards-statements.js.map +1 -0
- package/dist/services/rewards.d.ts +34 -0
- package/dist/services/rewards.js +37 -0
- package/dist/services/rewards.js.map +1 -0
- package/dist/services/sandbox-deposits.d.ts +15 -0
- package/dist/services/sandbox-deposits.js +22 -0
- package/dist/services/sandbox-deposits.js.map +1 -0
- package/dist/services/sandbox-fiat-transfers.d.ts +15 -0
- package/dist/services/sandbox-fiat-transfers.js +24 -0
- package/dist/services/sandbox-fiat-transfers.js.map +1 -0
- package/dist/services/sandbox-identity.d.ts +39 -0
- package/dist/services/sandbox-identity.js +60 -0
- package/dist/services/sandbox-identity.js.map +1 -0
- package/dist/services/settlement.d.ts +76 -0
- package/dist/services/settlement.js +79 -0
- package/dist/services/settlement.js.map +1 -0
- package/dist/services/stablecoin-conversion.d.ts +70 -0
- package/dist/services/stablecoin-conversion.js +65 -0
- package/dist/services/stablecoin-conversion.js.map +1 -0
- package/dist/services/statements.d.ts +44 -0
- package/dist/services/statements.js +35 -0
- package/dist/services/statements.js.map +1 -0
- package/dist/services/tax-documentation.d.ts +21 -0
- package/dist/services/tax-documentation.js +33 -0
- package/dist/services/tax-documentation.js.map +1 -0
- package/dist/services/tax-forms.d.ts +45 -0
- package/dist/services/tax-forms.js +38 -0
- package/dist/services/tax-forms.js.map +1 -0
- package/dist/services/transfers.d.ts +96 -0
- package/dist/services/transfers.js +37 -0
- package/dist/services/transfers.js.map +1 -0
- package/dist/services/travel-rule.d.ts +32 -0
- package/dist/services/travel-rule.js +30 -0
- package/dist/services/travel-rule.js.map +1 -0
- package/dist/services/user-audit-logs.d.ts +45 -0
- package/dist/services/user-audit-logs.js +27 -0
- package/dist/services/user-audit-logs.js.map +1 -0
- package/dist/services/webhooks.d.ts +58 -0
- package/dist/services/webhooks.js +42 -0
- package/dist/services/webhooks.js.map +1 -0
- package/dist/signing.d.ts +33 -0
- package/dist/signing.js +186 -0
- package/dist/signing.js.map +1 -0
- package/dist/testing/fixtures.d.ts +40 -0
- package/dist/testing/fixtures.js +131 -0
- package/dist/testing/fixtures.js.map +1 -0
- package/dist/testing/index.d.ts +28 -0
- package/dist/testing/index.js +28 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mock-server.d.ts +121 -0
- package/dist/testing/mock-server.js +276 -0
- package/dist/testing/mock-server.js.map +1 -0
- package/dist/timeouts.d.ts +13 -0
- package/dist/timeouts.js +71 -0
- package/dist/timeouts.js.map +1 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +67 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signing.js","sourceRoot":"","sources":["../src/signing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,IAAI,EAAkB,MAAM,aAAa,CAAC;AAEtF;;;GAGG;AACH,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,WAAW,CACzB,aAAqB,EACrB,KAAa,EACb,MAAc,EACd,IAAY,EACZ,IAAgB;IAEhB,MAAM,UAAU,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IAElD,OAAO,kBAAkB,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,aAAqB;IACnD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AAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAEpD,oCAAoC;IACpC,OAAO,GAAG,aAAa,IAAI,cAAc,IAAI,gBAAgB,EAAE,CAAC;AAClE,CAAC;AAED,uDAAuD;AACvD,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC,CAAC;IAC1D,OAAO,gBAAgB,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,wCAAwC;AACxC,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/**\n * JWS (JSON Web Signature) request signing for the Paxos API.\n *\n * When configured, the SDK signs every HTTP request with an Ed25519 (EdDSA) or P-256 (ES256) JWS and\n * sends it in the `Paxos-Signature` header. This is opt-in — users must contact\n * Paxos support to enable request signing on their OAuth client, then configure\n * the SDK with their private key and key ID.\n *\n * The {@link signRequest} function can also be used independently for custom\n * integrations or webhook verification.\n */\n\nimport { createPrivateKey, createPublicKey, sign, type KeyObject } from \"node:crypto\";\n\n/**\n * PKCS8 DER prefix for Ed25519 private keys (RFC 8410).\n * This wraps a raw 32-byte Ed25519 seed into a valid PKCS8 DER structure.\n */\nconst PKCS8_ED25519_PREFIX = Buffer.from(\"302e020100300506032b657004220420\", \"hex\");\n\n/**\n * Create a JWS compact serialization for the given HTTP request parameters.\n *\n * This is a standalone utility function that can be used independently of the\n * PaxosClient, for example in custom integrations or webhook verification.\n *\n * @param signingKeyHex - Ed25519 private key as 128 hex chars (32-byte seed followed by the\n * 32-byte public key), or an unencrypted PKCS#8 PEM (\"BEGIN PRIVATE KEY\", Ed25519 or P-256)\n * or SEC1 PEM (\"BEGIN EC PRIVATE KEY\", P-256).\n * @param keyId - UUID of the registered public key.\n * @param method - HTTP method (GET, POST, PUT, PATCH, DELETE).\n * @param path - Full transmitted request path including query string and base URL prefix\n * (e.g., \"/v2/transfer/crypto-withdrawals\").\n * @param body - Raw HTTP request body bytes. For requests with no body (GET, DELETE),\n * pass an empty Uint8Array.\n * @returns JWS compact serialization: `base64url(header).base64url(payload).base64url(signature)`\n *\n * @remarks\n * Request signing requires contacting Paxos support to enable on the OAuth\n * client before it can be used.\n */\nexport function signRequest(\n signingKeyHex: string,\n keyId: string,\n method: string,\n path: string,\n body: Uint8Array,\n): string {\n const privateKey = parseSigningKey(signingKeyHex);\n\n return signRequestWithKey(privateKey, keyId, method, path, body);\n}\n\n/**\n * Parse a signing key, given as 128 hex characters (Ed25519) or as an unencrypted\n * PKCS#8 or SEC1 PEM (Ed25519 or P-256), and return the KeyObject.\n * Used internally by the client to parse the key once at construction time.\n * @internal\n */\nexport function parseSigningKey(signingKeyHex: string): KeyObject {\n if (signingKeyHex.trim().startsWith(\"-----BEGIN\")) {\n return parsePemSigningKey(signingKeyHex.trim());\n }\n if (/[^0-9a-fA-F]/.test(signingKeyHex)) {\n throw new Error(\"invalid signing key hex: expected ASCII hexadecimal characters\");\n }\n if (signingKeyHex.length !== 128) {\n throw new Error(\"signing key must be 64 bytes (128 hex chars)\");\n }\n const keyBytes = Buffer.from(signingKeyHex, \"hex\");\n const privateKey = createEd25519Key(keyBytes.subarray(0, 32));\n const publicKey = createPublicKey(privateKey).export({ format: \"der\", type: \"spki\" }).subarray(-32);\n if (!publicKey.equals(keyBytes.subarray(32))) {\n throw new Error(\"signing key public half does not match its seed\");\n }\n return privateKey;\n}\n\nfunction parsePemSigningKey(pem: string): KeyObject {\n if (pem.startsWith(\"-----BEGIN ENCRYPTED PRIVATE KEY-----\")) {\n throw new Error(\"encrypted PEM signing keys are not supported; decrypt the key first\");\n }\n if (pem.split(\"-----BEGIN\").length !== 2 || !/-----END [A-Z0-9 ]+-----$/.test(pem)) {\n throw new Error(\"invalid signing key PEM: expected a single PEM block\");\n }\n if (!pem.startsWith(\"-----BEGIN PRIVATE KEY-----\") && !pem.startsWith(\"-----BEGIN EC PRIVATE KEY-----\")) {\n throw new Error(\"unsupported PEM block type; expected an unencrypted PKCS#8 or SEC1 private key\");\n }\n let key: KeyObject;\n try {\n key = createPrivateKey({ key: pem, format: \"pem\" });\n } catch {\n throw new Error(\n \"invalid signing key PEM: not a valid unencrypted PKCS#8 or SEC1 private key; the SDK supports Ed25519 (EdDSA) and P-256 (ES256) keys only\",\n );\n }\n if (!hasExactDerLength(pem)) {\n throw new Error(\n \"invalid signing key PEM: not a valid unencrypted PKCS#8 or SEC1 private key; the SDK supports Ed25519 (EdDSA) and P-256 (ES256) keys only\",\n );\n }\n if (key.asymmetricKeyType !== \"ed25519\" && !isP256(key)) {\n throw new Error(\n \"unsupported signing key type in PEM; the SDK supports Ed25519 (EdDSA) and P-256 (ES256) keys only\",\n );\n }\n if (key.asymmetricKeyType === \"ec\" && !hasValidP256Scalar(pem)) {\n throw new Error(\n \"invalid signing key PEM: not a valid unencrypted PKCS#8 or SEC1 private key; the SDK supports Ed25519 (EdDSA) and P-256 (ES256) keys only\",\n );\n }\n return key;\n}\n\nfunction readTlv(buf: Buffer, offset: number): { start: number; end: number } {\n let length = buf[offset + 1];\n let start = offset + 2;\n if (length & 0x80) {\n const count = length & 0x7f;\n length = 0;\n for (let i = 0; i < count; i++) {\n length = length * 256 + buf[start + i];\n }\n start += count;\n }\n return { start, end: start + length };\n}\n\nconst P256_ORDER = Buffer.from(\"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551\", \"hex\");\n\nfunction pemDer(pem: string): Buffer {\n return Buffer.from(\n pem\n .split(\"\\n\")\n .filter((line) => !line.trim().startsWith(\"-----\"))\n .join(\"\"),\n \"base64\",\n );\n}\n\nfunction hasExactDerLength(pem: string): boolean {\n const der = pemDer(pem);\n return der.length > 1 && readTlv(der, 0).end === der.length;\n}\n\nfunction hasValidP256Scalar(pem: string): boolean {\n try {\n const der = pemDer(pem);\n let position = readTlv(der, 0).start;\n if (pem.startsWith(\"-----BEGIN PRIVATE KEY-----\")) {\n position = readTlv(der, readTlv(der, position).end).end;\n position = readTlv(der, readTlv(der, position).start).start;\n }\n const scalar = readTlv(der, readTlv(der, position).end);\n const bytes = der.subarray(scalar.start, scalar.end);\n return bytes.length === 32 && bytes.some((b) => b !== 0) && Buffer.compare(bytes, P256_ORDER) < 0;\n } catch {\n return false;\n }\n}\n\nconst P256_PKCS8_ALGORITHM = Buffer.from(\"020100301306072a8648ce3d020106082a8648ce3d030107\", \"hex\");\n\nfunction isP256(key: KeyObject): boolean {\n if (key.asymmetricKeyType !== \"ec\") {\n return false;\n }\n try {\n const der = key.export({ format: \"der\", type: \"pkcs8\" });\n const index = der.indexOf(P256_PKCS8_ALGORITHM);\n return index >= 0 && index <= 4;\n } catch {\n return false;\n }\n}\n\n/**\n * Create a JWS using an already-parsed Ed25519 or P-256 private key.\n * @internal\n */\nexport function signRequestWithKey(\n privateKey: KeyObject,\n keyId: string,\n method: string,\n path: string,\n body: Uint8Array,\n timestampOverride?: number,\n): string {\n const isEc = privateKey.asymmetricKeyType === \"ec\";\n const timestamp = timestampOverride !== undefined ? timestampOverride : Math.floor(Date.now() / 1000);\n\n // Build the protected header.\n const header = {\n alg: isEc ? \"ES256\" : \"EdDSA\",\n kid: keyId,\n \"paxos.com/request-method\": method,\n \"paxos.com/request-path\": path,\n \"paxos.com/timestamp\": String(timestamp),\n };\n\n const headerJson = JSON.stringify(header);\n const encodedHeader = base64urlEncode(Buffer.from(headerJson, \"utf-8\"));\n const encodedPayload = base64urlEncode(body instanceof Buffer ? body : Buffer.from(body));\n\n // Sign base64url(header).base64url(payload).\n const signingInput = `${encodedHeader}.${encodedPayload}`;\n const signature = isEc\n ? sign(\"sha256\", Buffer.from(signingInput, \"ascii\"), { key: privateKey, dsaEncoding: \"ieee-p1363\" })\n : sign(null, Buffer.from(signingInput, \"ascii\"), privateKey);\n\n // Base64url encode the signature.\n const encodedSignature = base64urlEncode(signature);\n\n // Return JWS compact serialization.\n return `${encodedHeader}.${encodedPayload}.${encodedSignature}`;\n}\n\n/** Create an Ed25519 KeyObject from a 32-byte seed. */\nfunction createEd25519Key(seed: Buffer): KeyObject {\n const pkcs8 = Buffer.concat([PKCS8_ED25519_PREFIX, seed]);\n return createPrivateKey({ key: pkcs8, format: \"der\", type: \"pkcs8\" });\n}\n\n/** Base64url encode without padding. */\nfunction base64urlEncode(data: Buffer): string {\n return data.toString(\"base64url\");\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-built response fixtures for common Paxos API resources.
|
|
3
|
+
*
|
|
4
|
+
* Each fixture returns a typed model object matching the shape of the API
|
|
5
|
+
* response. Decimal fields are `Decimal` values, which serialize without
|
|
6
|
+
* trailing zeros (for example `"1.5"`). Pass these to {@link MockServer.on} to configure realistic
|
|
7
|
+
* mock responses in tests.
|
|
8
|
+
*/
|
|
9
|
+
import type { Account, DepositAddress, Identity, Order, Profile, Transfer } from "../models.js";
|
|
10
|
+
/** Returns a Transfer-shaped object for use in mock responses. */
|
|
11
|
+
export declare function transferFixture(id: string): Transfer;
|
|
12
|
+
/** Returns a Profile-shaped object for use in mock responses. */
|
|
13
|
+
export declare function profileFixture(id: string): Profile;
|
|
14
|
+
/** Returns an Identity-shaped object for use in mock responses. */
|
|
15
|
+
export declare function identityFixture(id: string): Identity;
|
|
16
|
+
/** Returns an Order-shaped object for use in mock responses. */
|
|
17
|
+
export declare function orderFixture(id: string): Order;
|
|
18
|
+
/** Returns an Account-shaped object for use in mock responses. */
|
|
19
|
+
export declare function accountFixture(id: string): Account;
|
|
20
|
+
/** Returns a DepositAddress-shaped object for use in mock responses. */
|
|
21
|
+
export declare function depositAddressFixture(id: string): DepositAddress;
|
|
22
|
+
/**
|
|
23
|
+
* Wraps items and an optional cursor in a paginated list response.
|
|
24
|
+
*
|
|
25
|
+
* @param items - Array of response objects for the page.
|
|
26
|
+
* @param nextPageCursor - Cursor for the next page. Omit or pass empty string for the last page.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // First page with a next-page cursor.
|
|
31
|
+
* const page1 = listResponse(
|
|
32
|
+
* [transferFixture("txn_1"), transferFixture("txn_2")],
|
|
33
|
+
* "cursor_page2",
|
|
34
|
+
* );
|
|
35
|
+
*
|
|
36
|
+
* // Last page (no cursor).
|
|
37
|
+
* const page2 = listResponse([transferFixture("txn_3")]);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function listResponse(items: Record<string, unknown>[], nextPageCursor?: string): Record<string, unknown>;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-built response fixtures for common Paxos API resources.
|
|
3
|
+
*
|
|
4
|
+
* Each fixture returns a typed model object matching the shape of the API
|
|
5
|
+
* response. Decimal fields are `Decimal` values, which serialize without
|
|
6
|
+
* trailing zeros (for example `"1.5"`). Pass these to {@link MockServer.on} to configure realistic
|
|
7
|
+
* mock responses in tests.
|
|
8
|
+
*/
|
|
9
|
+
import { Decimal } from "../decimal.js";
|
|
10
|
+
import { AccountAccountType, DepositAddressConversionTargetAsset, OrderType, IdentityType, IdentityStatus, Market, OrderStatus, OrderSide, CryptoNetwork, ProfileType, } from "../models.js";
|
|
11
|
+
/** Returns the current time as an RFC 3339 string. */
|
|
12
|
+
function nowRFC3339() {
|
|
13
|
+
return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
14
|
+
}
|
|
15
|
+
/** Returns a Transfer-shaped object for use in mock responses. */
|
|
16
|
+
export function transferFixture(id) {
|
|
17
|
+
return {
|
|
18
|
+
id,
|
|
19
|
+
customer_id: "cust_fixture",
|
|
20
|
+
profile_id: "prof_fixture",
|
|
21
|
+
asset: "BTC",
|
|
22
|
+
amount: new Decimal("1.50000000"),
|
|
23
|
+
fee: new Decimal("0.00010000"),
|
|
24
|
+
total: new Decimal("1.50010000"),
|
|
25
|
+
direction: "DEBIT",
|
|
26
|
+
type: "CRYPTO_WITHDRAWAL",
|
|
27
|
+
status: "COMPLETED",
|
|
28
|
+
metadata: {},
|
|
29
|
+
created_at: nowRFC3339(),
|
|
30
|
+
updated_at: nowRFC3339(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Returns a Profile-shaped object for use in mock responses. */
|
|
34
|
+
export function profileFixture(id) {
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
nickname: "Test Profile",
|
|
38
|
+
type: ProfileType.NORMAL,
|
|
39
|
+
description: "Fixture profile for testing",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Returns an Identity-shaped object for use in mock responses. */
|
|
43
|
+
export function identityFixture(id) {
|
|
44
|
+
return {
|
|
45
|
+
id,
|
|
46
|
+
metadata: {},
|
|
47
|
+
institution_members: [],
|
|
48
|
+
tax_details: [],
|
|
49
|
+
status: IdentityStatus.APPROVED,
|
|
50
|
+
summary_status: IdentityStatus.APPROVED,
|
|
51
|
+
type: IdentityType.PERSON,
|
|
52
|
+
person_details: {
|
|
53
|
+
first_name: "Jane",
|
|
54
|
+
last_name: "Doe",
|
|
55
|
+
date_of_birth: "1990-01-15",
|
|
56
|
+
},
|
|
57
|
+
created_at: nowRFC3339(),
|
|
58
|
+
updated_at: nowRFC3339(),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Returns an Order-shaped object for use in mock responses. */
|
|
62
|
+
export function orderFixture(id) {
|
|
63
|
+
return {
|
|
64
|
+
id,
|
|
65
|
+
metadata: {},
|
|
66
|
+
profile_id: "prof_fixture",
|
|
67
|
+
market: Market.BTCUSD,
|
|
68
|
+
side: OrderSide.BUY,
|
|
69
|
+
type: OrderType.MARKET,
|
|
70
|
+
status: OrderStatus.FILLED,
|
|
71
|
+
base_amount: new Decimal("0.10000000"),
|
|
72
|
+
price: new Decimal("42000.00"),
|
|
73
|
+
amount_filled: new Decimal("0.10000000"),
|
|
74
|
+
created_at: nowRFC3339(),
|
|
75
|
+
modified_at: nowRFC3339(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Returns an Account-shaped object for use in mock responses. */
|
|
79
|
+
export function accountFixture(id) {
|
|
80
|
+
return {
|
|
81
|
+
id,
|
|
82
|
+
identity_id: "id_fixture",
|
|
83
|
+
type: AccountAccountType.BROKERAGE,
|
|
84
|
+
summary_status: IdentityStatus.APPROVED,
|
|
85
|
+
description: "Fixture account for testing",
|
|
86
|
+
created_at: nowRFC3339(),
|
|
87
|
+
updated_at: nowRFC3339(),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Returns a DepositAddress-shaped object for use in mock responses. */
|
|
91
|
+
export function depositAddressFixture(id) {
|
|
92
|
+
return {
|
|
93
|
+
id,
|
|
94
|
+
metadata: {},
|
|
95
|
+
compatible_crypto_networks: [],
|
|
96
|
+
profile_id: "prof_fixture",
|
|
97
|
+
customer_id: "cust_fixture",
|
|
98
|
+
crypto_network: CryptoNetwork.ETHEREUM,
|
|
99
|
+
address: "0x742d35Cc6634C0532925a3b844Bc9e7595f2bD00",
|
|
100
|
+
conversion_target_asset: DepositAddressConversionTargetAsset.NO_CONVERSION,
|
|
101
|
+
identity_id: "id_fixture",
|
|
102
|
+
account_id: "acc_fixture",
|
|
103
|
+
created_at: nowRFC3339(),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Wraps items and an optional cursor in a paginated list response.
|
|
108
|
+
*
|
|
109
|
+
* @param items - Array of response objects for the page.
|
|
110
|
+
* @param nextPageCursor - Cursor for the next page. Omit or pass empty string for the last page.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // First page with a next-page cursor.
|
|
115
|
+
* const page1 = listResponse(
|
|
116
|
+
* [transferFixture("txn_1"), transferFixture("txn_2")],
|
|
117
|
+
* "cursor_page2",
|
|
118
|
+
* );
|
|
119
|
+
*
|
|
120
|
+
* // Last page (no cursor).
|
|
121
|
+
* const page2 = listResponse([transferFixture("txn_3")]);
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export function listResponse(items, nextPageCursor = "") {
|
|
125
|
+
const resp = { items };
|
|
126
|
+
if (nextPageCursor !== "") {
|
|
127
|
+
resp["next_page_cursor"] = nextPageCursor;
|
|
128
|
+
}
|
|
129
|
+
return resp;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/testing/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EACL,kBAAkB,EAClB,mCAAmC,EACnC,SAAS,EACT,YAAY,EACZ,cAAc,EACd,MAAM,EACN,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,GACZ,MAAM,cAAc,CAAC;AAEtB,sDAAsD;AACtD,SAAS,UAAU;IACjB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AAC5D,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,OAAO;QACL,EAAE;QACF,WAAW,EAAE,cAAc;QAC3B,UAAU,EAAE,cAAc;QAC1B,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,IAAI,OAAO,CAAC,YAAY,CAAC;QACjC,GAAG,EAAE,IAAI,OAAO,CAAC,YAAY,CAAC;QAC9B,KAAK,EAAE,IAAI,OAAO,CAAC,YAAY,CAAC;QAChC,SAAS,EAAE,OAAO;QAClB,IAAI,EAAE,mBAAmB;QACzB,MAAM,EAAE,WAAW;QACnB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,UAAU,EAAE;QACxB,UAAU,EAAE,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WAAW,EAAE,YAAY;QACzB,IAAI,EAAE,kBAAkB,CAAC,SAAS;QAClC,cAAc,EAAE,cAAc,CAAC,QAAQ;QACvC,WAAW,EAAE,6BAA6B;QAC1C,UAAU,EAAE,UAAU,EAAE;QACxB,UAAU,EAAE,UAAU,EAAE;KACzB,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,qBAAqB,CAAC,EAAU;IAC9C,OAAO;QACL,EAAE;QACF,QAAQ,EAAE,EAAE;QACZ,0BAA0B,EAAE,EAAE;QAC9B,UAAU,EAAE,cAAc;QAC1B,WAAW,EAAE,cAAc;QAC3B,cAAc,EAAE,aAAa,CAAC,QAAQ;QACtC,OAAO,EAAE,4CAA4C;QACrD,uBAAuB,EAAE,mCAAmC,CAAC,aAAa;QAC1E,WAAW,EAAE,YAAY;QACzB,UAAU,EAAE,aAAa;QACzB,UAAU,EAAE,UAAU,EAAE;KACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAAC,KAAgC,EAAE,cAAc,GAAG,EAAE;IAChF,MAAM,IAAI,GAA4B,EAAE,KAAK,EAAE,CAAC;IAChD,IAAI,cAAc,KAAK,EAAE,EAAE,CAAC;QAC1B,IAAI,CAAC,kBAAkB,CAAC,GAAG,cAAc,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * Pre-built response fixtures for common Paxos API resources.\n *\n * Each fixture returns a typed model object matching the shape of the API\n * response. Decimal fields are `Decimal` values, which serialize without\n * trailing zeros (for example `\"1.5\"`). Pass these to {@link MockServer.on} to configure realistic\n * mock responses in tests.\n */\n\nimport { Decimal } from \"../decimal.js\";\nimport type { Account, DepositAddress, Identity, Order, Profile, Transfer } from \"../models.js\";\nimport {\n AccountAccountType,\n DepositAddressConversionTargetAsset,\n OrderType,\n IdentityType,\n IdentityStatus,\n Market,\n OrderStatus,\n OrderSide,\n CryptoNetwork,\n ProfileType,\n} from \"../models.js\";\n\n/** Returns the current time as an RFC 3339 string. */\nfunction nowRFC3339(): string {\n return new Date().toISOString().replace(/\\.\\d{3}Z$/, \"Z\");\n}\n\n/** Returns a Transfer-shaped object for use in mock responses. */\nexport function transferFixture(id: string): Transfer {\n return {\n id,\n customer_id: \"cust_fixture\",\n profile_id: \"prof_fixture\",\n asset: \"BTC\",\n amount: new Decimal(\"1.50000000\"),\n fee: new Decimal(\"0.00010000\"),\n total: new Decimal(\"1.50010000\"),\n direction: \"DEBIT\",\n type: \"CRYPTO_WITHDRAWAL\",\n status: \"COMPLETED\",\n metadata: {},\n created_at: nowRFC3339(),\n updated_at: nowRFC3339(),\n };\n}\n\n/** Returns a Profile-shaped object for use in mock responses. */\nexport function profileFixture(id: string): Profile {\n return {\n id,\n nickname: \"Test Profile\",\n type: ProfileType.NORMAL,\n description: \"Fixture profile for testing\",\n };\n}\n\n/** Returns an Identity-shaped object for use in mock responses. */\nexport function identityFixture(id: string): Identity {\n return {\n id,\n metadata: {},\n institution_members: [],\n tax_details: [],\n status: IdentityStatus.APPROVED,\n summary_status: IdentityStatus.APPROVED,\n type: IdentityType.PERSON,\n person_details: {\n first_name: \"Jane\",\n last_name: \"Doe\",\n date_of_birth: \"1990-01-15\",\n },\n created_at: nowRFC3339(),\n updated_at: nowRFC3339(),\n };\n}\n\n/** Returns an Order-shaped object for use in mock responses. */\nexport function orderFixture(id: string): Order {\n return {\n id,\n metadata: {},\n profile_id: \"prof_fixture\",\n market: Market.BTCUSD,\n side: OrderSide.BUY,\n type: OrderType.MARKET,\n status: OrderStatus.FILLED,\n base_amount: new Decimal(\"0.10000000\"),\n price: new Decimal(\"42000.00\"),\n amount_filled: new Decimal(\"0.10000000\"),\n created_at: nowRFC3339(),\n modified_at: nowRFC3339(),\n };\n}\n\n/** Returns an Account-shaped object for use in mock responses. */\nexport function accountFixture(id: string): Account {\n return {\n id,\n identity_id: \"id_fixture\",\n type: AccountAccountType.BROKERAGE,\n summary_status: IdentityStatus.APPROVED,\n description: \"Fixture account for testing\",\n created_at: nowRFC3339(),\n updated_at: nowRFC3339(),\n };\n}\n\n/** Returns a DepositAddress-shaped object for use in mock responses. */\nexport function depositAddressFixture(id: string): DepositAddress {\n return {\n id,\n metadata: {},\n compatible_crypto_networks: [],\n profile_id: \"prof_fixture\",\n customer_id: \"cust_fixture\",\n crypto_network: CryptoNetwork.ETHEREUM,\n address: \"0x742d35Cc6634C0532925a3b844Bc9e7595f2bD00\",\n conversion_target_asset: DepositAddressConversionTargetAsset.NO_CONVERSION,\n identity_id: \"id_fixture\",\n account_id: \"acc_fixture\",\n created_at: nowRFC3339(),\n };\n}\n\n/**\n * Wraps items and an optional cursor in a paginated list response.\n *\n * @param items - Array of response objects for the page.\n * @param nextPageCursor - Cursor for the next page. Omit or pass empty string for the last page.\n *\n * @example\n * ```typescript\n * // First page with a next-page cursor.\n * const page1 = listResponse(\n * [transferFixture(\"txn_1\"), transferFixture(\"txn_2\")],\n * \"cursor_page2\",\n * );\n *\n * // Last page (no cursor).\n * const page2 = listResponse([transferFixture(\"txn_3\")]);\n * ```\n */\nexport function listResponse(items: Record<string, unknown>[], nextPageCursor = \"\"): Record<string, unknown> {\n const resp: Record<string, unknown> = { items };\n if (nextPageCursor !== \"\") {\n resp[\"next_page_cursor\"] = nextPageCursor;\n }\n return resp;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paxos SDK test utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides a mock HTTP server and pre-built response fixtures for
|
|
5
|
+
* testing SDK integrations without real API calls.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {
|
|
10
|
+
* MockServer,
|
|
11
|
+
* transferFixture,
|
|
12
|
+
* listResponse,
|
|
13
|
+
* } from "@paxosglobal/sdk/testing";
|
|
14
|
+
*
|
|
15
|
+
* const server = new MockServer();
|
|
16
|
+
* await server.start();
|
|
17
|
+
*
|
|
18
|
+
* server.on("GET", "/transfer/transfers/txn_123")
|
|
19
|
+
* .respond(200, transferFixture("txn_123"));
|
|
20
|
+
*
|
|
21
|
+
* // ... test with new PaxosClient({ ..., ...server.clientOptions() }) ...
|
|
22
|
+
*
|
|
23
|
+
* await server.shutdown();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export { MockServer, Route } from "./mock-server.js";
|
|
27
|
+
export type { RecordedRequest } from "./mock-server.js";
|
|
28
|
+
export { transferFixture, profileFixture, identityFixture, orderFixture, accountFixture, depositAddressFixture, listResponse, } from "./fixtures.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paxos SDK test utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides a mock HTTP server and pre-built response fixtures for
|
|
5
|
+
* testing SDK integrations without real API calls.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {
|
|
10
|
+
* MockServer,
|
|
11
|
+
* transferFixture,
|
|
12
|
+
* listResponse,
|
|
13
|
+
* } from "@paxosglobal/sdk/testing";
|
|
14
|
+
*
|
|
15
|
+
* const server = new MockServer();
|
|
16
|
+
* await server.start();
|
|
17
|
+
*
|
|
18
|
+
* server.on("GET", "/transfer/transfers/txn_123")
|
|
19
|
+
* .respond(200, transferFixture("txn_123"));
|
|
20
|
+
*
|
|
21
|
+
* // ... test with new PaxosClient({ ..., ...server.clientOptions() }) ...
|
|
22
|
+
*
|
|
23
|
+
* await server.shutdown();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export { MockServer, Route } from "./mock-server.js";
|
|
27
|
+
export { transferFixture, profileFixture, identityFixture, orderFixture, accountFixture, depositAddressFixture, listResponse, } from "./fixtures.js";
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EACL,eAAe,EACf,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,YAAY,GACb,MAAM,eAAe,CAAC","sourcesContent":["/**\n * Paxos SDK test utilities.\n *\n * Provides a mock HTTP server and pre-built response fixtures for\n * testing SDK integrations without real API calls.\n *\n * @example\n * ```typescript\n * import {\n * MockServer,\n * transferFixture,\n * listResponse,\n * } from \"@paxosglobal/sdk/testing\";\n *\n * const server = new MockServer();\n * await server.start();\n *\n * server.on(\"GET\", \"/transfer/transfers/txn_123\")\n * .respond(200, transferFixture(\"txn_123\"));\n *\n * // ... test with new PaxosClient({ ..., ...server.clientOptions() }) ...\n *\n * await server.shutdown();\n * ```\n */\n\nexport { MockServer, Route } from \"./mock-server.js\";\nexport type { RecordedRequest } from \"./mock-server.js\";\n\nexport {\n transferFixture,\n profileFixture,\n identityFixture,\n orderFixture,\n accountFixture,\n depositAddressFixture,\n listResponse,\n} from \"./fixtures.js\";\n"]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock HTTP server for testing Paxos SDK integrations.
|
|
3
|
+
*
|
|
4
|
+
* Provides a configurable in-process HTTP server that records incoming
|
|
5
|
+
* requests and returns pre-configured responses. Use it in tests to
|
|
6
|
+
* verify SDK behavior without making real API calls.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { MockServer, transferFixture } from "@paxosglobal/sdk/testing";
|
|
11
|
+
* import { PaxosClient, Scope } from "@paxosglobal/sdk";
|
|
12
|
+
*
|
|
13
|
+
* const server = new MockServer();
|
|
14
|
+
* await server.start();
|
|
15
|
+
*
|
|
16
|
+
* server.on("GET", "/transfer/transfers/txn_123")
|
|
17
|
+
* .respond(200, transferFixture("txn_123"));
|
|
18
|
+
*
|
|
19
|
+
* const client = new PaxosClient({
|
|
20
|
+
* clientId: "id",
|
|
21
|
+
* clientSecret: "secret",
|
|
22
|
+
* scopes: [Scope.TRANSFER_READ_TRANSFER],
|
|
23
|
+
* ...server.clientOptions(),
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // ... run your test ...
|
|
27
|
+
*
|
|
28
|
+
* await server.shutdown();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
/** Details of an HTTP request received by the mock server. */
|
|
32
|
+
export interface RecordedRequest {
|
|
33
|
+
method: string;
|
|
34
|
+
path: string;
|
|
35
|
+
/** Full request target as received, including the query string. */
|
|
36
|
+
url: string;
|
|
37
|
+
/** Parsed query parameters; a repeated parameter has several values. */
|
|
38
|
+
query: Record<string, string[]>;
|
|
39
|
+
headers: Record<string, string>;
|
|
40
|
+
body: Buffer;
|
|
41
|
+
/** Return the value of a header by case-insensitive name, or undefined if absent. */
|
|
42
|
+
header(name: string): string | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Route represents a registered mock route with one or more queued responses.
|
|
46
|
+
* Supports fluent chaining via {@link respond} and {@link respondWithHeaders}.
|
|
47
|
+
*/
|
|
48
|
+
export declare class Route {
|
|
49
|
+
private responses;
|
|
50
|
+
private index;
|
|
51
|
+
/**
|
|
52
|
+
* Queue a response with the given status code and JSON body.
|
|
53
|
+
* If called multiple times, responses are returned in FIFO order.
|
|
54
|
+
* After all queued responses are consumed, the last one repeats.
|
|
55
|
+
*/
|
|
56
|
+
respond(status: number, body?: unknown): Route;
|
|
57
|
+
/**
|
|
58
|
+
* Queue a response with custom HTTP headers.
|
|
59
|
+
*/
|
|
60
|
+
respondWithHeaders(status: number, body: unknown, headers: Record<string, string>): Route;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* In-process HTTP mock server for Paxos SDK tests.
|
|
64
|
+
*
|
|
65
|
+
* Provides route registration, request recording, and convenience
|
|
66
|
+
* helpers for common error responses.
|
|
67
|
+
*/
|
|
68
|
+
export declare class MockServer {
|
|
69
|
+
private server;
|
|
70
|
+
private routes;
|
|
71
|
+
private recorded;
|
|
72
|
+
private recordedTokens;
|
|
73
|
+
/** The base URL of the running server (e.g. "http://127.0.0.1:12345"). */
|
|
74
|
+
get url(): string;
|
|
75
|
+
/** The URL of the mock OAuth token endpoint. */
|
|
76
|
+
get tokenUrl(): string;
|
|
77
|
+
/** Client options pointing a PaxosClient at this server for API and OAuth token requests. */
|
|
78
|
+
clientOptions(): {
|
|
79
|
+
baseUrl: string;
|
|
80
|
+
tokenUrl: string;
|
|
81
|
+
};
|
|
82
|
+
/** Start the mock server on a random available port. */
|
|
83
|
+
start(): Promise<void>;
|
|
84
|
+
/** Shut down the mock server and release the port. */
|
|
85
|
+
shutdown(): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Register a route expectation for the given HTTP method and path.
|
|
88
|
+
* Returns a {@link Route} that can be configured with responses.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* server.on("GET", "/transfer/transfers/txn_123")
|
|
93
|
+
* .respond(200, transferFixture("txn_123"));
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
on(method: string, path: string): Route;
|
|
97
|
+
/** Returns a copy of all recorded requests received by the server. */
|
|
98
|
+
calls(): RecordedRequest[];
|
|
99
|
+
/** Returns a copy of all OAuth token requests received by the server. They are not included in {@link calls}. */
|
|
100
|
+
tokenCalls(): RecordedRequest[];
|
|
101
|
+
/** Clear all registered routes and recorded requests. */
|
|
102
|
+
reset(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Register a 404 Not Found response for the given method and path.
|
|
105
|
+
*/
|
|
106
|
+
returnNotFound(method: string, path: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* Register a 429 Rate Limit response.
|
|
109
|
+
*/
|
|
110
|
+
returnRateLimit(method: string, path: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* Register a 500 Internal Server Error response.
|
|
113
|
+
*/
|
|
114
|
+
returnServerError(method: string, path: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Register a 400 Validation Error response with a custom detail message.
|
|
117
|
+
*/
|
|
118
|
+
returnValidationError(method: string, path: string, detail: string): void;
|
|
119
|
+
/** Internal request handler. */
|
|
120
|
+
private handler;
|
|
121
|
+
}
|