@ozura/elements 0.1.0-beta.7 → 1.0.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.
Files changed (50) hide show
  1. package/README.md +906 -663
  2. package/dist/frame/element-frame.js +77 -57
  3. package/dist/frame/element-frame.js.map +1 -1
  4. package/dist/frame/tokenizer-frame.html +1 -1
  5. package/dist/frame/tokenizer-frame.js +211 -94
  6. package/dist/frame/tokenizer-frame.js.map +1 -1
  7. package/dist/oz-elements.esm.js +817 -230
  8. package/dist/oz-elements.esm.js.map +1 -1
  9. package/dist/oz-elements.umd.js +817 -229
  10. package/dist/oz-elements.umd.js.map +1 -1
  11. package/dist/react/frame/tokenizerFrame.d.ts +32 -0
  12. package/dist/react/index.cjs.js +968 -218
  13. package/dist/react/index.cjs.js.map +1 -1
  14. package/dist/react/index.esm.js +965 -219
  15. package/dist/react/index.esm.js.map +1 -1
  16. package/dist/react/react/index.d.ts +148 -6
  17. package/dist/react/sdk/OzElement.d.ts +34 -3
  18. package/dist/react/sdk/OzVault.d.ts +68 -4
  19. package/dist/react/sdk/errors.d.ts +9 -0
  20. package/dist/react/sdk/index.d.ts +29 -0
  21. package/dist/react/server/index.d.ts +181 -17
  22. package/dist/react/types/index.d.ts +69 -19
  23. package/dist/react/utils/appearance.d.ts +9 -0
  24. package/dist/react/utils/cardUtils.d.ts +14 -0
  25. package/dist/react/utils/uuid.d.ts +12 -0
  26. package/dist/server/frame/tokenizerFrame.d.ts +32 -0
  27. package/dist/server/index.cjs.js +608 -71
  28. package/dist/server/index.cjs.js.map +1 -1
  29. package/dist/server/index.esm.js +606 -72
  30. package/dist/server/index.esm.js.map +1 -1
  31. package/dist/server/sdk/OzElement.d.ts +34 -3
  32. package/dist/server/sdk/OzVault.d.ts +68 -4
  33. package/dist/server/sdk/errors.d.ts +9 -0
  34. package/dist/server/sdk/index.d.ts +29 -0
  35. package/dist/server/server/index.d.ts +181 -17
  36. package/dist/server/types/index.d.ts +69 -19
  37. package/dist/server/utils/appearance.d.ts +9 -0
  38. package/dist/server/utils/cardUtils.d.ts +14 -0
  39. package/dist/server/utils/uuid.d.ts +12 -0
  40. package/dist/types/frame/tokenizerFrame.d.ts +32 -0
  41. package/dist/types/sdk/OzElement.d.ts +34 -3
  42. package/dist/types/sdk/OzVault.d.ts +68 -4
  43. package/dist/types/sdk/errors.d.ts +9 -0
  44. package/dist/types/sdk/index.d.ts +29 -0
  45. package/dist/types/server/index.d.ts +181 -17
  46. package/dist/types/types/index.d.ts +69 -19
  47. package/dist/types/utils/appearance.d.ts +9 -0
  48. package/dist/types/utils/cardUtils.d.ts +14 -0
  49. package/dist/types/utils/uuid.d.ts +12 -0
  50. package/package.json +7 -4
@@ -1,5 +1,269 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * errors.ts — error types and normalisation for OzElements.
5
+ *
6
+ * Three normalisation functions:
7
+ * - normalizeVaultError — maps raw vault /tokenize errors to user-facing messages (card flows)
8
+ * - normalizeBankVaultError — maps raw vault /tokenize errors to user-facing messages (bank/ACH flows)
9
+ * - normalizeCardSaleError — maps raw cardSale API errors to user-facing messages
10
+ *
11
+ * Error keys in normalizeCardSaleError are taken directly from checkout's
12
+ * errorMapping.ts so the same error strings produce the same user-facing copy.
13
+ */
14
+ // ─── cardSale error map (mirrors checkout/src/utils/errorMapping.ts exactly) ─
15
+ const CARD_SALE_ERROR_MAP = [
16
+ ['Insufficient Funds', 'Your card has insufficient funds. Please use a different payment method.'],
17
+ ['Invalid card number', 'The card number you entered is invalid. Please check and try again.'],
18
+ ['Card expired', 'Your card has expired. Please use a different card.'],
19
+ ['CVV Verification Failed', 'The CVV code you entered is incorrect. Please check and try again.'],
20
+ ['Address Verification Failed', 'The billing address does not match your card. Please verify your address.'],
21
+ ['Do Not Honor', 'Your card was declined. Please contact your bank or use a different payment method.'],
22
+ ['Declined', 'Your card was declined. Please contact your bank or use a different payment method.'],
23
+ ['Surcharge is currently not supported', 'Surcharge fees are not supported at this time.'],
24
+ ['Surcharge percent must be between', 'Surcharge fees are not supported at this time.'],
25
+ ['Forbidden - API key', 'Authentication failed. Please refresh the page.'],
26
+ ['Api Key is invalid', 'Authentication failed. Please refresh the page.'],
27
+ ['API key not found', 'Authentication failed. Please refresh the page.'],
28
+ ['Access token expired', 'Your session has expired. Please refresh the page.'],
29
+ ['Access token is invalid', 'Authentication failed. Please refresh the page.'],
30
+ ['Unauthorized', 'Authentication failed. Please refresh the page.'],
31
+ ['Too Many Requests', 'Too many requests. Please wait a moment and try again.'],
32
+ ['Rate limit exceeded', 'System is busy. Please wait a moment and try again.'],
33
+ ['No processor integrations found', 'Payment processing is not configured for this merchant. Please contact the merchant for assistance.'],
34
+ ['processor integration', 'Payment processing is temporarily unavailable. Please try again later or contact the merchant.'],
35
+ ['Invalid zipcode', 'The ZIP code you entered is invalid. Please check and try again.'],
36
+ ['failed to save to database', 'Your payment was processed but we encountered an issue. Please contact support.'],
37
+ ['CASHBACK UNAVAIL', 'This transaction type is not supported. Please try again or use a different payment method.'],
38
+ ];
39
+ /**
40
+ * Maps a raw Ozura Pay API cardSale error string to a user-facing message.
41
+ *
42
+ * Uses the exact same error key table as checkout's `getUserFriendlyError()` in
43
+ * errorMapping.ts so both surfaces produce identical copy for the same errors.
44
+ *
45
+ * Falls back to the original string when it's under 100 characters, or to a
46
+ * generic message for long/opaque server errors — matching checkout's fallback
47
+ * behaviour exactly.
48
+ *
49
+ * **Trade-off:** Short unrecognised strings (e.g. processor codes like
50
+ * `"PROC_TIMEOUT"`) are passed through verbatim. This intentionally mirrors
51
+ * checkout so the same raw Pay API errors produce the same user-facing text on
52
+ * both surfaces. If the Pay API ever returns internal codes that should never
53
+ * reach the UI, the fix belongs in the Pay API error normalisation layer rather
54
+ * than here.
55
+ */
56
+ function normalizeCardSaleError(raw) {
57
+ if (!raw)
58
+ return 'Payment processing failed. Please try again.';
59
+ for (const [key, message] of CARD_SALE_ERROR_MAP) {
60
+ if (raw.toLowerCase().includes(key.toLowerCase())) {
61
+ return message;
62
+ }
63
+ }
64
+ // Checkout fallback: pass through short errors, genericise long ones
65
+ if (raw.length < 100)
66
+ return raw;
67
+ return 'Payment processing failed. Please try again or contact support.';
68
+ }
69
+
70
+ /**
71
+ * billingUtils.ts — billing detail validation and normalization.
72
+ *
73
+ * Mirrors the validation in checkout/page.tsx (pre-flight checks before cardSale)
74
+ * so that billing data passed to createToken() is guaranteed schema-compliant and
75
+ * ready to forward directly to the Ozura Pay API cardSale endpoint.
76
+ *
77
+ * All string fields enforced to 1–50 characters (cardSale schema constraint).
78
+ * State is normalized to 2-letter abbreviation for US and CA.
79
+ * Phone must be E.164 format (matches checkout's formatPhoneForAPI output).
80
+ */
81
+ // ─── Email ────────────────────────────────────────────────────────────────────
82
+ const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
83
+ /** Returns true when the email is syntactically valid and ≤50 characters. */
84
+ function validateEmail(email) {
85
+ return EMAIL_RE.test(email) && email.length <= 50;
86
+ }
87
+ // ─── Phone ───────────────────────────────────────────────────────────────────
88
+ /**
89
+ * Validates E.164 phone format: starts with +, 1–3 digit country code,
90
+ * followed by 7–12 digits, total ≤50 characters.
91
+ *
92
+ * Matches the output of checkout's formatPhoneForAPI() function.
93
+ * Examples: "+15551234567", "+447911123456", "+61412345678"
94
+ */
95
+ function validateE164Phone(phone) {
96
+ return /^\+[1-9]\d{6,49}$/.test(phone) && phone.length <= 50;
97
+ }
98
+ // ─── Field length ─────────────────────────────────────────────────────────────
99
+ /** Returns true when the string is non-empty and ≤50 characters (cardSale schema). */
100
+ function isValidBillingField(value) {
101
+ return value.length > 0 && value.length <= 50;
102
+ }
103
+ // ─── US state normalization ───────────────────────────────────────────────────
104
+ // Mirrors checkout's convertStateToAbbreviation() so the same input variants work.
105
+ const US_STATES = {
106
+ alabama: 'AL', alaska: 'AK', arizona: 'AZ', arkansas: 'AR',
107
+ california: 'CA', colorado: 'CO', connecticut: 'CT', delaware: 'DE',
108
+ 'district of columbia': 'DC', florida: 'FL', georgia: 'GA', hawaii: 'HI',
109
+ idaho: 'ID', illinois: 'IL', indiana: 'IN', iowa: 'IA', kansas: 'KS',
110
+ kentucky: 'KY', louisiana: 'LA', maine: 'ME', maryland: 'MD',
111
+ massachusetts: 'MA', michigan: 'MI', minnesota: 'MN', mississippi: 'MS',
112
+ missouri: 'MO', montana: 'MT', nebraska: 'NE', nevada: 'NV',
113
+ 'new hampshire': 'NH', 'new jersey': 'NJ', 'new mexico': 'NM', 'new york': 'NY',
114
+ 'north carolina': 'NC', 'north dakota': 'ND', ohio: 'OH', oklahoma: 'OK',
115
+ oregon: 'OR', pennsylvania: 'PA', 'rhode island': 'RI', 'south carolina': 'SC',
116
+ 'south dakota': 'SD', tennessee: 'TN', texas: 'TX', utah: 'UT',
117
+ vermont: 'VT', virginia: 'VA', washington: 'WA', 'west virginia': 'WV',
118
+ wisconsin: 'WI', wyoming: 'WY',
119
+ // US territories
120
+ 'puerto rico': 'PR', guam: 'GU', 'virgin islands': 'VI',
121
+ 'us virgin islands': 'VI', 'u.s. virgin islands': 'VI',
122
+ 'american samoa': 'AS', 'northern mariana islands': 'MP',
123
+ 'commonwealth of the northern mariana islands': 'MP',
124
+ // Military / diplomatic addresses
125
+ 'armed forces europe': 'AE', 'armed forces pacific': 'AP',
126
+ 'armed forces americas': 'AA',
127
+ };
128
+ const US_ABBREVS = new Set(Object.values(US_STATES));
129
+ const CA_PROVINCES = {
130
+ alberta: 'AB', 'british columbia': 'BC', manitoba: 'MB', 'new brunswick': 'NB',
131
+ 'newfoundland and labrador': 'NL', 'nova scotia': 'NS', ontario: 'ON',
132
+ 'prince edward island': 'PE', quebec: 'QC', saskatchewan: 'SK',
133
+ 'northwest territories': 'NT', nunavut: 'NU', yukon: 'YT',
134
+ };
135
+ const CA_ABBREVS = new Set(Object.values(CA_PROVINCES));
136
+ /**
137
+ * Converts a full US state or Canadian province name to its 2-letter abbreviation.
138
+ * If already a valid abbreviation (case-insensitive), returns it uppercased.
139
+ * For non-US/CA countries, returns the input uppercased unchanged.
140
+ *
141
+ * Matches checkout's convertStateToAbbreviation() behaviour exactly.
142
+ */
143
+ function normalizeState(state, country) {
144
+ var _a, _b;
145
+ const upper = state.trim().toUpperCase();
146
+ const lower = state.trim().toLowerCase();
147
+ if (country === 'US') {
148
+ if (US_ABBREVS.has(upper))
149
+ return upper;
150
+ return (_a = US_STATES[lower]) !== null && _a !== void 0 ? _a : upper;
151
+ }
152
+ if (country === 'CA') {
153
+ if (CA_ABBREVS.has(upper))
154
+ return upper;
155
+ return (_b = CA_PROVINCES[lower]) !== null && _b !== void 0 ? _b : upper;
156
+ }
157
+ return upper;
158
+ }
159
+ // ─── Postal code validation ───────────────────────────────────────────────────
160
+ const POSTAL_PATTERNS = {
161
+ US: /^\d{5}(-?\d{4})?$/, // 5-digit or ZIP+4 (with or without hyphen)
162
+ CA: /^[A-Za-z]\d[A-Za-z]\s?\d[A-Za-z]\d$/, // A1A 1A1
163
+ GB: /^[A-Za-z]{1,2}\d[A-Za-z\d]?\s?\d[A-Za-z]{2}$/,
164
+ DE: /^\d{5}$/,
165
+ FR: /^\d{5}$/,
166
+ ES: /^\d{5}$/,
167
+ IT: /^\d{5}$/,
168
+ AU: /^\d{4}$/,
169
+ NL: /^\d{4}\s?[A-Za-z]{2}$/,
170
+ BR: /^\d{5}-?\d{3}$/,
171
+ JP: /^\d{3}-?\d{4}$/,
172
+ IN: /^\d{6}$/,
173
+ };
174
+ /**
175
+ * Validates a postal/ZIP code against country-specific format rules.
176
+ * For countries without a specific pattern, falls back to generic 1–50 char check.
177
+ */
178
+ function validatePostalCode(zip, country) {
179
+ if (!zip || zip.length === 0)
180
+ return { valid: false, error: 'Postal code is required' };
181
+ if (zip.length > 50)
182
+ return { valid: false, error: 'Postal code must be 50 characters or fewer' };
183
+ const pattern = POSTAL_PATTERNS[country.toUpperCase()];
184
+ if (pattern && !pattern.test(zip)) {
185
+ return { valid: false, error: `Invalid postal code format for ${country.toUpperCase()}` };
186
+ }
187
+ return { valid: true };
188
+ }
189
+ /**
190
+ * Validates and normalizes billing details against the Ozura cardSale API schema.
191
+ *
192
+ * Rules applied (same as checkout's pre-flight validation in page.tsx):
193
+ * - firstName, lastName: required, 1–50 chars
194
+ * - email: optional; if provided, must be valid format and ≤50 chars
195
+ * - phone: optional; if provided, must be E.164 and ≤50 chars
196
+ * - address fields: if address is provided, line1/city/state/zip/country are
197
+ * required (1–50 chars each); line2 is optional and omitted from normalized
198
+ * output if blank (cardSale schema: minLength 1 if present)
199
+ * - state: normalized to 2-letter abbreviation for US and CA
200
+ */
201
+ function validateBilling(billing) {
202
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
203
+ const errors = [];
204
+ const firstName = (_b = (_a = billing.firstName) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
205
+ const lastName = (_d = (_c = billing.lastName) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : '';
206
+ const email = (_f = (_e = billing.email) === null || _e === void 0 ? void 0 : _e.trim()) !== null && _f !== void 0 ? _f : '';
207
+ const phone = (_h = (_g = billing.phone) === null || _g === void 0 ? void 0 : _g.trim()) !== null && _h !== void 0 ? _h : '';
208
+ if (!isValidBillingField(firstName)) {
209
+ errors.push('billing.firstName must be 1–50 characters');
210
+ }
211
+ if (!isValidBillingField(lastName)) {
212
+ errors.push('billing.lastName must be 1–50 characters');
213
+ }
214
+ if (email && !validateEmail(email)) {
215
+ errors.push('billing.email must be a valid address (max 50 characters)');
216
+ }
217
+ if (phone && !validateE164Phone(phone)) {
218
+ errors.push('billing.phone must be E.164 format, e.g. "+15551234567" (max 50 characters)');
219
+ }
220
+ let normalizedAddress;
221
+ if (billing.address) {
222
+ const a = billing.address;
223
+ const country = (_k = (_j = a.country) === null || _j === void 0 ? void 0 : _j.trim().toUpperCase()) !== null && _k !== void 0 ? _k : '';
224
+ const line1 = (_m = (_l = a.line1) === null || _l === void 0 ? void 0 : _l.trim()) !== null && _m !== void 0 ? _m : '';
225
+ const line2 = (_p = (_o = a.line2) === null || _o === void 0 ? void 0 : _o.trim()) !== null && _p !== void 0 ? _p : '';
226
+ const city = (_r = (_q = a.city) === null || _q === void 0 ? void 0 : _q.trim()) !== null && _r !== void 0 ? _r : '';
227
+ const zip = (_t = (_s = a.zip) === null || _s === void 0 ? void 0 : _s.trim()) !== null && _t !== void 0 ? _t : '';
228
+ const state = normalizeState((_v = (_u = a.state) === null || _u === void 0 ? void 0 : _u.trim()) !== null && _v !== void 0 ? _v : '', country);
229
+ if (!isValidBillingField(line1))
230
+ errors.push('billing.address.line1 must be 1–50 characters');
231
+ if (line2 && !isValidBillingField(line2))
232
+ errors.push('billing.address.line2 must be 1–50 characters if provided');
233
+ if (!isValidBillingField(city))
234
+ errors.push('billing.address.city must be 1–50 characters');
235
+ if (!isValidBillingField(state)) {
236
+ errors.push('billing.address.state must be 1–50 characters');
237
+ }
238
+ else if (country === 'US' && !US_ABBREVS.has(state)) {
239
+ errors.push(`billing.address.state "${state}" is not a recognized US state or territory abbreviation (e.g. "CA", "NY", "PR")`);
240
+ }
241
+ else if (country === 'CA' && !CA_ABBREVS.has(state)) {
242
+ errors.push(`billing.address.state "${state}" is not a recognized Canadian province or territory abbreviation (e.g. "ON", "BC", "QC")`);
243
+ }
244
+ // cardSale backend uses strict enum validation on country — must be exactly 2 uppercase letters
245
+ if (!/^[A-Z]{2}$/.test(country)) {
246
+ errors.push('billing.address.country must be a 2-letter ISO 3166-1 alpha-2 code (e.g. "US", "CA", "GB")');
247
+ }
248
+ if (!isValidBillingField(zip)) {
249
+ errors.push('billing.address.zip must be 1–50 characters');
250
+ }
251
+ else if (/^[A-Z]{2}$/.test(country)) {
252
+ const postalResult = validatePostalCode(zip, country);
253
+ if (!postalResult.valid) {
254
+ errors.push(`billing.address.zip: ${postalResult.error}`);
255
+ }
256
+ }
257
+ normalizedAddress = Object.assign(Object.assign({ line1 }, (line2 ? { line2 } : {})), { city,
258
+ state,
259
+ zip,
260
+ country });
261
+ }
262
+ const normalized = Object.assign(Object.assign(Object.assign({ firstName,
263
+ lastName }, (email ? { email } : {})), (phone ? { phone } : {})), (normalizedAddress ? { address: normalizedAddress } : {}));
264
+ return { valid: errors.length === 0, errors, normalized };
265
+ }
266
+
3
267
  /**
4
268
  * @ozura/server — Server-side SDK for the Ozura Pay API.
5
269
  *
@@ -8,7 +272,7 @@
8
272
  *
9
273
  * @example
10
274
  * ```ts
11
- * import { Ozura } from 'oz-elements/server';
275
+ * import { Ozura } from '@ozura/elements/server';
12
276
  *
13
277
  * const ozura = new Ozura({
14
278
  * merchantId: process.env.MERCHANT_ID!,
@@ -29,8 +293,8 @@
29
293
  * ```
30
294
  */
31
295
  // ─── Configuration ───────────────────────────────────────────────────────────
32
- const DEFAULT_API_URL = "https://ozurapay-pay-api-v2-staging-c8abbdfhfbd3c5em.eastus-01.azurewebsites.net";
33
- const DEFAULT_VAULT_URL = "https://pci-vault-staging-drc0duhcakf4g4fr.eastus-01.azurewebsites.net";
296
+ const DEFAULT_API_URL = "https://payapi.v2.ozurapay.com";
297
+ const DEFAULT_VAULT_URL = "https://api.ozuravault.com";
34
298
  const DEFAULT_TIMEOUT = 30000;
35
299
  // ─── Error ───────────────────────────────────────────────────────────────────
36
300
  class OzuraError extends Error {
@@ -50,14 +314,27 @@ function isRetryable(status) {
50
314
  async function sleep(ms) {
51
315
  return new Promise(resolve => setTimeout(resolve, ms));
52
316
  }
317
+ /**
318
+ * Returns an AbortSignal that aborts after `ms` milliseconds.
319
+ *
320
+ * Uses `AbortSignal.timeout()` when available (Node 17.3+ / 18.0+) and
321
+ * falls back to a manual `AbortController` + `setTimeout` for Node 16 and
322
+ * other older runtimes. Both paths produce an `AbortError`-family signal;
323
+ * the catch sites in this file only use `err.message` so the difference in
324
+ * `err.name` (`'AbortError'` vs `'TimeoutError'`) is inconsequential.
325
+ */
326
+ function timeoutSignal(ms) {
327
+ if (typeof AbortSignal.timeout === 'function') {
328
+ return AbortSignal.timeout(ms);
329
+ }
330
+ const controller = new AbortController();
331
+ setTimeout(() => controller.abort(), ms);
332
+ return controller.signal;
333
+ }
53
334
  // ─── Main class ──────────────────────────────────────────────────────────────
54
335
  class Ozura {
55
336
  constructor(config) {
56
337
  var _a, _b;
57
- if (!config.merchantId)
58
- throw new OzuraError('merchantId is required', 0);
59
- if (!config.apiKey)
60
- throw new OzuraError('apiKey is required', 0);
61
338
  if (!config.vaultKey)
62
339
  throw new OzuraError('vaultKey is required', 0);
63
340
  this.merchantId = config.merchantId;
@@ -76,6 +353,10 @@ class Ozura {
76
353
  */
77
354
  async cardSale(input) {
78
355
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
356
+ if (!this.merchantId)
357
+ throw new OzuraError('merchantId is required for cardSale(). Add it to the Ozura constructor config.', 0);
358
+ if (!this.apiKey)
359
+ throw new OzuraError('apiKey is required for cardSale(). Add it to the Ozura constructor config.', 0);
79
360
  const billing = input.billing;
80
361
  const body = {
81
362
  merchantId: this.merchantId,
@@ -111,6 +392,10 @@ class Ozura {
111
392
  * Rate limit: 200 requests/minute per merchant.
112
393
  */
113
394
  async listTransactions(input = {}) {
395
+ if (!this.merchantId)
396
+ throw new OzuraError('merchantId is required for listTransactions(). Add it to the Ozura constructor config.', 0);
397
+ if (!this.apiKey)
398
+ throw new OzuraError('apiKey is required for listTransactions(). Add it to the Ozura constructor config.', 0);
114
399
  const params = { merchantId: this.merchantId };
115
400
  if (input.transactionId)
116
401
  params.transactionId = input.transactionId;
@@ -136,56 +421,62 @@ class Ozura {
136
421
  }
137
422
  // ─── Wax key helpers ─────────────────────────────────────────────────────
138
423
  /**
139
- * Mint a short-lived wax key from the vault.
424
+ * Mint a short-lived, use-limited wax key from the vault.
140
425
  *
141
426
  * Call this server-side to implement the `fetchWaxKey` callback required by
142
427
  * `OzVault.create()` on the frontend. The wax key replaces the vault secret
143
428
  * on every browser tokenize call — the secret never leaves your server.
144
429
  *
145
- * The `tokenizationSessionId` passed to `fetchWaxKey` by the SDK should be
146
- * forwarded here for correlation; it is stored by the vault alongside the
147
- * wax key but is not used for authentication.
430
+ * **Use limits:** by default each wax key accepts up to 3 tokenize calls
431
+ * (`maxTokenizeCalls: 3`). After that the vault marks the key as consumed and
432
+ * the client SDK transparently re-mints. Keep `maxTokenizeCalls` in sync with
433
+ * `VaultOptions.maxTokenizeCalls` so the SDK can proactively refresh before
434
+ * hitting the limit rather than waiting for a rejection.
435
+ *
436
+ * **Session correlation:** the `tokenizationSessionId` forwarded from the SDK's
437
+ * `fetchWaxKey` callback should be passed here so the vault can correlate the
438
+ * key with the checkout session in its audit log.
148
439
  *
149
440
  * @example
150
441
  * // Next.js API route
151
442
  * export async function POST(req: Request) {
152
443
  * const { sessionId } = await req.json();
153
- * const { waxKey } = await ozura.mintWaxKey({ tokenizationSessionId: sessionId });
444
+ * const { waxKey } = await ozura.mintWaxKey({
445
+ * tokenizationSessionId: sessionId,
446
+ * maxTokenizeCalls: 3,
447
+ * });
154
448
  * return Response.json({ waxKey });
155
449
  * }
156
450
  */
157
451
  async mintWaxKey(options) {
158
- var _a, _b;
452
+ var _a, _b, _c;
159
453
  const body = {};
160
454
  if (options === null || options === void 0 ? void 0 : options.tokenizationSessionId) {
161
455
  body.checkout_session_id = options.tokenizationSessionId;
162
456
  }
163
- let res;
164
- try {
165
- res = await fetch(`${this.vaultUrl}/internal/wax-session`, {
166
- method: 'POST',
167
- headers: {
168
- 'Content-Type': 'application/json',
169
- 'X-API-Key': this.vaultKey,
170
- },
171
- body: JSON.stringify(body),
172
- signal: AbortSignal.timeout(this.timeoutMs),
173
- });
174
- }
175
- catch (err) {
176
- const msg = err instanceof Error ? err.message : 'Network error';
177
- throw new OzuraError(`Wax key mint failed: ${msg}`, 0, msg);
457
+ // Always send max_tokenize_calls — default 3 if not overridden.
458
+ body.max_tokenize_calls = (_a = options === null || options === void 0 ? void 0 : options.maxTokenizeCalls) !== null && _a !== void 0 ? _a : 3;
459
+ if ((options === null || options === void 0 ? void 0 : options.maxProxyCalls) !== undefined) {
460
+ body.max_proxy_calls = options.maxProxyCalls;
178
461
  }
462
+ const res = await this.fetchWithRetry(`${this.vaultUrl}/internal/wax-session`, {
463
+ method: 'POST',
464
+ headers: {
465
+ 'Content-Type': 'application/json',
466
+ 'X-API-Key': this.vaultKey,
467
+ },
468
+ body: JSON.stringify(body),
469
+ });
179
470
  const json = await res.json().catch(() => ({}));
180
471
  if (res.status === 201) {
181
472
  const data = json.data;
182
- const waxKey = String((_a = data === null || data === void 0 ? void 0 : data.wax_key) !== null && _a !== void 0 ? _a : '');
473
+ const waxKey = String((_b = data === null || data === void 0 ? void 0 : data.wax_key) !== null && _b !== void 0 ? _b : '');
183
474
  if (!waxKey) {
184
475
  throw new OzuraError('Vault mint response missing data.wax_key', res.status, JSON.stringify(json));
185
476
  }
186
477
  return {
187
478
  waxKey,
188
- expiresInSeconds: Number((_b = data === null || data === void 0 ? void 0 : data.expires_in_seconds) !== null && _b !== void 0 ? _b : 1800),
479
+ expiresInSeconds: Number((_c = data === null || data === void 0 ? void 0 : data.expires_in_seconds) !== null && _c !== void 0 ? _c : 1800),
189
480
  };
190
481
  }
191
482
  const errorCode = json.error_code || '';
@@ -219,7 +510,7 @@ class Ozura {
219
510
  'X-API-Key': this.vaultKey,
220
511
  },
221
512
  body: JSON.stringify({ wax_key: waxKey }),
222
- signal: AbortSignal.timeout(3000),
513
+ signal: timeoutSignal(3000),
223
514
  });
224
515
  if (res.status === 200 || res.status === 404)
225
516
  return;
@@ -235,12 +526,12 @@ class Ozura {
235
526
  * Execute a fetch with retry on 5xx / network errors.
236
527
  * 4xx errors (including 429) are never retried — they require caller action.
237
528
  */
238
- async fetchWithRetry(url, init) {
529
+ async fetchWithRetry(url, init, maxRetries = this.retries) {
239
530
  let lastError;
240
- for (let attempt = 0; attempt <= this.retries; attempt++) {
531
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
241
532
  try {
242
- const res = await fetch(url, Object.assign(Object.assign({}, init), { signal: AbortSignal.timeout(this.timeoutMs) }));
243
- if (isRetryable(res.status) && attempt < this.retries) {
533
+ const res = await fetch(url, Object.assign(Object.assign({}, init), { signal: timeoutSignal(this.timeoutMs) }));
534
+ if (isRetryable(res.status) && attempt < maxRetries) {
244
535
  // Consume/cancel body so the connection is released (undici holds socket until body is drained)
245
536
  if (res.body) {
246
537
  try {
@@ -258,7 +549,7 @@ class Ozura {
258
549
  }
259
550
  catch (err) {
260
551
  lastError = err;
261
- if (attempt < this.retries) {
552
+ if (attempt < maxRetries) {
262
553
  const backoff = Math.min(1000 * 2 ** attempt, 8000);
263
554
  await sleep(backoff);
264
555
  continue;
@@ -274,7 +565,7 @@ class Ozura {
274
565
  }
275
566
  throw new OzuraError('Network error', 0);
276
567
  }
277
- async post(path, body, includeVaultKey) {
568
+ async post(path, body, includeVaultKey, maxRetries) {
278
569
  // Enforce: the server SDK sends x-api-key on every request, so it must
279
570
  // never be used to call the vault tokenize endpoint. Tokenization is
280
571
  // client-side only (OzVault + tokenizerFrame). Surface misuse immediately.
@@ -284,6 +575,7 @@ class Ozura {
284
575
  }
285
576
  const headers = {
286
577
  'Content-Type': 'application/json',
578
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
287
579
  'x-api-key': this.apiKey,
288
580
  };
289
581
  if (includeVaultKey) {
@@ -293,7 +585,7 @@ class Ozura {
293
585
  method: 'POST',
294
586
  headers,
295
587
  body: JSON.stringify(body),
296
- });
588
+ }, maxRetries);
297
589
  return this.handleResponse(res);
298
590
  }
299
591
  async getRaw(path) {
@@ -304,33 +596,33 @@ class Ozura {
304
596
  }
305
597
  const res = await this.fetchWithRetry(`${this.apiUrl}${path}`, {
306
598
  method: 'GET',
599
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
307
600
  headers: { 'x-api-key': this.apiKey },
308
601
  });
309
- const json = await res.json().catch(() => ({ error: res.statusText }));
310
- if (!res.ok) {
311
- const retryAfter = res.status === 429
312
- ? Number(res.headers.get('retry-after') || json.retryAfter) || undefined
313
- : undefined;
314
- throw new OzuraError(json.error || `HTTP ${res.status}`, res.status, json.error, retryAfter);
315
- }
316
- if (json.success === false) {
317
- throw new OzuraError(json.error || 'Request was not successful', res.status, json.error);
318
- }
319
- return json;
602
+ return (await this.parseApiJson(res));
320
603
  }
321
604
  async handleResponse(res) {
322
605
  var _a;
606
+ const json = await this.parseApiJson(res);
607
+ return ((_a = json.data) !== null && _a !== void 0 ? _a : json);
608
+ }
609
+ /**
610
+ * Parses a Pay API response JSON and throws `OzuraError` on HTTP errors or
611
+ * `success: false` payloads. Used by both `getRaw` and `handleResponse` to
612
+ * avoid duplicating the error-mapping logic.
613
+ */
614
+ async parseApiJson(res) {
323
615
  const json = await res.json().catch(() => ({ error: res.statusText }));
324
616
  if (!res.ok) {
325
617
  const retryAfter = res.status === 429
326
618
  ? Number(res.headers.get('retry-after') || json.retryAfter) || undefined
327
619
  : undefined;
328
- throw new OzuraError(json.error || `HTTP ${res.status}`, res.status, json.error, retryAfter);
620
+ throw new OzuraError(json.error || `HTTP ${res.status}`, res.status, typeof json.error === 'string' ? json.error : undefined, retryAfter);
329
621
  }
330
622
  if (json.success === false) {
331
- throw new OzuraError(json.error || 'Request was not successful', res.status, json.error);
623
+ throw new OzuraError(json.error || 'Request was not successful', res.status, typeof json.error === 'string' ? json.error : undefined);
332
624
  }
333
- return ((_a = json.data) !== null && _a !== void 0 ? _a : json);
625
+ return json;
334
626
  }
335
627
  }
336
628
  /**
@@ -357,17 +649,22 @@ class Ozura {
357
649
  */
358
650
  function createMintWaxHandler(ozura) {
359
651
  return async (req) => {
360
- var _a;
361
- let sessionId;
362
- try {
363
- const body = await req.json().catch(() => ({}));
364
- const raw = (_a = body.sessionId) !== null && _a !== void 0 ? _a : body.tokenizationSessionId;
365
- if (typeof raw === 'string' && raw)
366
- sessionId = raw;
652
+ var _a, _b;
653
+ if (req.method !== 'POST') {
654
+ return Response.json({ error: 'Method Not Allowed' }, { status: 405 });
367
655
  }
368
- catch (_b) {
369
- // unreadable body proceed without sessionId
656
+ // Reject non-JSON bodies — blocks simple-form CSRF requests which send
657
+ // application/x-www-form-urlencoded and cannot set Content-Type to
658
+ // application/json without triggering a CORS preflight.
659
+ const contentType = (_a = req.headers.get('content-type')) !== null && _a !== void 0 ? _a : '';
660
+ if (!contentType.includes('application/json')) {
661
+ return Response.json({ error: 'Content-Type must be application/json' }, { status: 415 });
370
662
  }
663
+ let sessionId;
664
+ const body = await req.json().catch(() => ({}));
665
+ const raw = (_b = body.sessionId) !== null && _b !== void 0 ? _b : body.tokenizationSessionId;
666
+ if (typeof raw === 'string' && raw)
667
+ sessionId = raw;
371
668
  try {
372
669
  const { waxKey } = await ozura.mintWaxKey({ tokenizationSessionId: sessionId });
373
670
  return Response.json({ waxKey });
@@ -406,9 +703,22 @@ function createMintWaxHandler(ozura) {
406
703
  */
407
704
  function createMintWaxMiddleware(ozura) {
408
705
  return async (req, res) => {
409
- var _a, _b;
410
- const body = ((_a = req.body) !== null && _a !== void 0 ? _a : {});
411
- const raw = (_b = body.sessionId) !== null && _b !== void 0 ? _b : body.tokenizationSessionId;
706
+ var _a, _b, _c;
707
+ const method = req.method;
708
+ if (method && method !== 'POST') {
709
+ res.status(405).json({ error: 'Method Not Allowed' });
710
+ return;
711
+ }
712
+ // Reject non-JSON content types — blocks simple-form CSRF requests.
713
+ // Express sets req.headers as a plain object; check it directly.
714
+ const headers = req.headers;
715
+ const ct = (_a = (typeof (headers === null || headers === void 0 ? void 0 : headers['content-type']) === 'string' ? headers['content-type'] : '')) !== null && _a !== void 0 ? _a : '';
716
+ if (!ct.includes('application/json')) {
717
+ res.status(415).json({ error: 'Content-Type must be application/json' });
718
+ return;
719
+ }
720
+ const body = ((_b = req.body) !== null && _b !== void 0 ? _b : {});
721
+ const raw = (_c = body.sessionId) !== null && _c !== void 0 ? _c : body.tokenizationSessionId;
412
722
  const sessionId = typeof raw === 'string' && raw ? raw : undefined;
413
723
  try {
414
724
  const { waxKey } = await ozura.mintWaxKey({ tokenizationSessionId: sessionId });
@@ -431,8 +741,27 @@ function createMintWaxMiddleware(ozura) {
431
741
  * (Cloudflare) → `x-forwarded-for` (reverse proxy) → `x-real-ip` →
432
742
  * `socket.remoteAddress` → `"0.0.0.0"`.
433
743
  *
744
+ * **Proxy trust requirements — read before deploying:**
745
+ *
746
+ * - **`x-forwarded-for` / `x-real-ip`** are HTTP headers that any client can
747
+ * set arbitrarily. They are only trustworthy when your server sits behind a
748
+ * reverse proxy (nginx, AWS ALB, Cloudflare, etc.) that strips and rewrites
749
+ * those headers. If your Node.js process is directly internet-accessible,
750
+ * an attacker can spoof any IP value and bypass payment-processor
751
+ * IP-based fraud checks.
752
+ * - **Express `req.ip`** resolves through `X-Forwarded-For` only when
753
+ * `app.set('trust proxy', true)` (or a specific proxy count/subnet) is
754
+ * configured. Without `trust proxy`, `req.ip` returns the direct socket
755
+ * address (your load-balancer's IP, not the client's).
756
+ * - **`cf-connecting-ip`** is only trustworthy when Cloudflare is genuinely
757
+ * in front of your server. Without Cloudflare, any client can send this
758
+ * header with a fabricated value.
759
+ *
760
+ * In all cases, ensure your infrastructure strips untrusted forwarding headers
761
+ * before they reach your application.
762
+ *
434
763
  * @example
435
- * // Express / Fastify
764
+ * // Express requires app.set('trust proxy', true) behind a proxy
436
765
  * clientIpAddress: getClientIp(req)
437
766
  *
438
767
  * // Next.js App Router
@@ -450,8 +779,11 @@ function getClientIp(req) {
450
779
  if (cfIp)
451
780
  return cfIp;
452
781
  const xff = get('x-forwarded-for');
453
- if (xff)
454
- return xff.split(',')[0].trim();
782
+ if (xff) {
783
+ const candidate = xff.split(',')[0].trim();
784
+ if (candidate)
785
+ return candidate;
786
+ }
455
787
  const realIp = get('x-real-ip');
456
788
  if (realIp)
457
789
  return realIp;
@@ -463,10 +795,16 @@ function getClientIp(req) {
463
795
  if (typeof cfIp === 'string' && cfIp)
464
796
  return cfIp;
465
797
  const xff = h['x-forwarded-for'];
466
- if (typeof xff === 'string' && xff)
467
- return xff.split(',')[0].trim();
468
- if (Array.isArray(xff) && xff[0])
469
- return xff[0].split(',')[0].trim();
798
+ if (typeof xff === 'string' && xff) {
799
+ const candidate = xff.split(',')[0].trim();
800
+ if (candidate)
801
+ return candidate;
802
+ }
803
+ if (Array.isArray(xff) && xff[0]) {
804
+ const candidate = xff[0].split(',')[0].trim();
805
+ if (candidate)
806
+ return candidate;
807
+ }
470
808
  const realIp = h['x-real-ip'];
471
809
  if (typeof realIp === 'string' && realIp)
472
810
  return realIp;
@@ -477,10 +815,209 @@ function getClientIp(req) {
477
815
  return socket.remoteAddress;
478
816
  return '0.0.0.0';
479
817
  }
818
+ /**
819
+ * Validates the token/cvcSession/billing fields from a parsed request body.
820
+ * Returns the normalized billing or a 400 error descriptor.
821
+ */
822
+ function parseCardSaleBody(body) {
823
+ const { token, cvcSession, billing } = body;
824
+ if (typeof token !== 'string' || !token) {
825
+ return { ok: false, error: 'token is required' };
826
+ }
827
+ if (typeof cvcSession !== 'string' || !cvcSession) {
828
+ return { ok: false, error: 'cvcSession is required' };
829
+ }
830
+ if (!billing || typeof billing.firstName !== 'string' || typeof billing.lastName !== 'string') {
831
+ return { ok: false, error: 'billing with firstName and lastName is required' };
832
+ }
833
+ const billingValidation = validateBilling(billing);
834
+ if (!billingValidation.valid) {
835
+ return { ok: false, error: `Invalid billing details: ${billingValidation.errors.join('; ')}` };
836
+ }
837
+ return { ok: true, token, cvcSession, billing: billingValidation.normalized };
838
+ }
839
+ /**
840
+ * Runs the card sale after body validation: resolves amount + currency,
841
+ * calls ozura.cardSale(), and returns a typed outcome. Both handler and
842
+ * middleware factories delegate to this shared implementation.
843
+ */
844
+ async function executeCardSale(ozura, options, token, cvcSession, billing, rawBody, clientIpAddress) {
845
+ let amount;
846
+ try {
847
+ amount = await options.getAmount(rawBody);
848
+ }
849
+ catch (err) {
850
+ return { ok: false, error: err instanceof Error ? err.message : 'Failed to resolve amount', status: 500 };
851
+ }
852
+ if (typeof amount !== 'string' || !amount.trim()) {
853
+ return { ok: false, error: 'getAmount must return a non-empty decimal string', status: 500 };
854
+ }
855
+ if (!/^\d+(\.\d{1,2})?$/.test(amount.trim())) {
856
+ return {
857
+ ok: false,
858
+ error: `getAmount returned an invalid amount: "${amount}". Expected a positive decimal string, e.g. "49.00".`,
859
+ status: 500,
860
+ };
861
+ }
862
+ amount = amount.trim();
863
+ let currency = 'USD';
864
+ if (options.getCurrency) {
865
+ try {
866
+ currency = await options.getCurrency(rawBody);
867
+ }
868
+ catch (err) {
869
+ return { ok: false, error: err instanceof Error ? err.message : 'Failed to resolve currency', status: 500 };
870
+ }
871
+ }
872
+ try {
873
+ const result = await ozura.cardSale({ token, cvcSession, amount, currency, billing, clientIpAddress });
874
+ return {
875
+ ok: true,
876
+ data: {
877
+ transactionId: result.transactionId,
878
+ amount: result.amount,
879
+ cardLastFour: result.cardLastFour,
880
+ cardBrand: result.cardBrand,
881
+ },
882
+ };
883
+ }
884
+ catch (err) {
885
+ if (err instanceof OzuraError) {
886
+ if (err.statusCode === 429) {
887
+ return { ok: false, error: normalizeCardSaleError(err.message), status: 429, retryAfter: err.retryAfter };
888
+ }
889
+ const status = err.statusCode >= 400 && err.statusCode < 600 ? err.statusCode : 502;
890
+ return { ok: false, error: normalizeCardSaleError(err.message), status };
891
+ }
892
+ return { ok: false, error: 'Payment failed', status: 500 };
893
+ }
894
+ }
895
+ // ─── Public factories ─────────────────────────────────────────────────────────
896
+ /**
897
+ * Creates a ready-to-use Fetch API route handler for charging a tokenized card.
898
+ *
899
+ * Drop-in for Next.js App Router, Cloudflare Workers, Vercel Edge, and any
900
+ * runtime built on the standard Web API `Request` / `Response`.
901
+ *
902
+ * The handler reads `{ token, cvcSession, billing }` from the JSON request body,
903
+ * resolves the amount via `options.getAmount()`, calls `ozura.cardSale()`, and
904
+ * returns `{ transactionId, amount, cardLastFour, cardBrand }` on success.
905
+ * On error it returns `{ error }` with a normalized, user-facing message and
906
+ * an appropriate HTTP status.
907
+ *
908
+ * `clientIpAddress` is extracted automatically from the request headers.
909
+ *
910
+ * @example
911
+ * // app/api/charge/route.ts (Next.js App Router)
912
+ * import { Ozura, createCardSaleHandler } from '@ozura/elements/server';
913
+ *
914
+ * const ozura = new Ozura({ merchantId: '...', apiKey: '...', vaultKey: '...' });
915
+ *
916
+ * export const POST = createCardSaleHandler(ozura, {
917
+ * getAmount: async (body) => {
918
+ * const order = await db.orders.findById(body.orderId as string);
919
+ * return order.total;
920
+ * },
921
+ * });
922
+ */
923
+ function createCardSaleHandler(ozura, options) {
924
+ return async (req) => {
925
+ var _a;
926
+ if (req.method !== 'POST') {
927
+ return Response.json({ error: 'Method Not Allowed' }, { status: 405 });
928
+ }
929
+ const contentType = (_a = req.headers.get('content-type')) !== null && _a !== void 0 ? _a : '';
930
+ if (!contentType.includes('application/json')) {
931
+ return Response.json({ error: 'Content-Type must be application/json' }, { status: 415 });
932
+ }
933
+ let body;
934
+ try {
935
+ body = await req.json();
936
+ }
937
+ catch (_b) {
938
+ return Response.json({ error: 'Invalid JSON body' }, { status: 400 });
939
+ }
940
+ const parsed = parseCardSaleBody(body);
941
+ if (!parsed.ok) {
942
+ return Response.json({ error: parsed.error }, { status: 400 });
943
+ }
944
+ const outcome = await executeCardSale(ozura, options, parsed.token, parsed.cvcSession, parsed.billing, body, getClientIp(req));
945
+ if (!outcome.ok) {
946
+ const headers = outcome.retryAfter
947
+ ? { 'Retry-After': String(outcome.retryAfter) }
948
+ : {};
949
+ return Response.json({ error: outcome.error }, Object.assign({ status: outcome.status }, (Object.keys(headers).length > 0 ? { headers } : {})));
950
+ }
951
+ return Response.json(outcome.data);
952
+ };
953
+ }
954
+ /**
955
+ * Creates a ready-to-use Express / Connect middleware for charging a tokenized card.
956
+ *
957
+ * Requires `express.json()` (or equivalent body-parser) to be registered before
958
+ * this middleware so `req.body` is available.
959
+ *
960
+ * The middleware reads `{ token, cvcSession, billing }` from `req.body`, resolves
961
+ * the amount via `options.getAmount()`, calls `ozura.cardSale()`, and sends
962
+ * `{ transactionId, amount, cardLastFour, cardBrand }` on success.
963
+ * On error it sends `{ error }` with a normalized, user-facing message and an
964
+ * appropriate HTTP status.
965
+ *
966
+ * `clientIpAddress` is extracted automatically from the request object.
967
+ *
968
+ * @example
969
+ * // Express
970
+ * import express from 'express';
971
+ * import { Ozura, createCardSaleMiddleware } from '@ozura/elements/server';
972
+ *
973
+ * const app = express();
974
+ * const ozura = new Ozura({ merchantId: '...', apiKey: '...', vaultKey: '...' });
975
+ *
976
+ * app.use(express.json());
977
+ * app.post('/api/charge', createCardSaleMiddleware(ozura, {
978
+ * getAmount: async (body) => {
979
+ * const order = await db.orders.findById(body.orderId as string);
980
+ * return order.total;
981
+ * },
982
+ * }));
983
+ */
984
+ function createCardSaleMiddleware(ozura, options) {
985
+ return async (req, res) => {
986
+ var _a, _b, _c;
987
+ const method = req.method;
988
+ if (method && method !== 'POST') {
989
+ res.status(405).json({ error: 'Method Not Allowed' });
990
+ return;
991
+ }
992
+ const headers = req.headers;
993
+ const ct = (_a = (typeof (headers === null || headers === void 0 ? void 0 : headers['content-type']) === 'string' ? headers['content-type'] : '')) !== null && _a !== void 0 ? _a : '';
994
+ if (!ct.includes('application/json')) {
995
+ res.status(415).json({ error: 'Content-Type must be application/json' });
996
+ return;
997
+ }
998
+ const body = ((_b = req.body) !== null && _b !== void 0 ? _b : {});
999
+ const parsed = parseCardSaleBody(body);
1000
+ if (!parsed.ok) {
1001
+ res.status(400).json({ error: parsed.error });
1002
+ return;
1003
+ }
1004
+ const outcome = await executeCardSale(ozura, options, parsed.token, parsed.cvcSession, parsed.billing, body, getClientIp(req));
1005
+ if (!outcome.ok) {
1006
+ if (outcome.retryAfter)
1007
+ (_c = res.setHeader) === null || _c === void 0 ? void 0 : _c.call(res, 'Retry-After', String(outcome.retryAfter));
1008
+ res.status(outcome.status).json({ error: outcome.error });
1009
+ return;
1010
+ }
1011
+ res.json(outcome.data);
1012
+ };
1013
+ }
480
1014
 
481
1015
  exports.Ozura = Ozura;
482
1016
  exports.OzuraError = OzuraError;
1017
+ exports.createCardSaleHandler = createCardSaleHandler;
1018
+ exports.createCardSaleMiddleware = createCardSaleMiddleware;
483
1019
  exports.createMintWaxHandler = createMintWaxHandler;
484
1020
  exports.createMintWaxMiddleware = createMintWaxMiddleware;
485
1021
  exports.getClientIp = getClientIp;
1022
+ exports.normalizeCardSaleError = normalizeCardSaleError;
486
1023
  //# sourceMappingURL=index.cjs.js.map