@vesant-sdk/fraud 0.1.3 → 0.2.0-dev.0520b46

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/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var core = require('@vesant-sdk/core');
5
5
  // src/client.ts
6
6
 
7
7
  // src/types/enums.ts
8
- var SiftTransactionTypeValues = [
8
+ var TransactionTypeValues = [
9
9
  "$sale",
10
10
  "$authorize",
11
11
  "$capture",
@@ -33,7 +33,7 @@ var TransactionType = {
33
33
  Send: "$send",
34
34
  Receive: "$receive"
35
35
  };
36
- var SiftChargebackStateValues = [
36
+ var ChargebackStateValues = [
37
37
  "$received",
38
38
  "$accepted",
39
39
  "$disputed",
@@ -47,7 +47,7 @@ var ChargebackState = {
47
47
  Won: "$won",
48
48
  Lost: "$lost"
49
49
  };
50
- var SiftChargebackReasonValues = [
50
+ var ChargebackReasonValues = [
51
51
  "$fraud",
52
52
  "$duplicate",
53
53
  "$product_not_received",
@@ -75,28 +75,28 @@ var ChargebackReason = {
75
75
  AchReversal: "$ach_reversal",
76
76
  Other: "$other"
77
77
  };
78
- var SiftLoginStatusValues = ["$success", "$failure"];
78
+ var LoginStatusValues = ["$success", "$failure"];
79
79
  var LoginStatus = {
80
80
  Success: "$success",
81
81
  Failure: "$failure"
82
82
  };
83
- var SiftLoginFailureReasonValues = [
83
+ var LoginFailureReasonValues = [
84
84
  "$account_unknown",
85
85
  "$account_suspended",
86
86
  "$account_disabled",
87
87
  "$wrong_password"
88
88
  ];
89
- var SiftPasswordUpdateReasonValues = [
89
+ var PasswordUpdateReasonValues = [
90
90
  "$user_update",
91
91
  "$forgot_password",
92
92
  "$forced_reset"
93
93
  ];
94
94
  var PasswordUpdateReason = {
95
- UserUpdate: SiftPasswordUpdateReasonValues[0],
96
- ForgotPassword: SiftPasswordUpdateReasonValues[1],
97
- ForcedReset: SiftPasswordUpdateReasonValues[2]
95
+ UserUpdate: PasswordUpdateReasonValues[0],
96
+ ForgotPassword: PasswordUpdateReasonValues[1],
97
+ ForcedReset: PasswordUpdateReasonValues[2]
98
98
  };
99
- var SiftPasswordUpdateStatusValues = [
99
+ var PasswordUpdateStatusValues = [
100
100
  "$pending",
101
101
  "$success",
102
102
  "$failure"
@@ -106,12 +106,12 @@ var PasswordUpdateStatus = {
106
106
  Success: "$success",
107
107
  Failure: "$failure"
108
108
  };
109
- var SiftWagerStatusValues = ["$accept", "$cancel"];
109
+ var WagerStatusValues = ["$accept", "$cancel"];
110
110
  var WagerStatus = {
111
111
  Accept: "$accept",
112
112
  Cancel: "$cancel"
113
113
  };
114
- var SiftTransactionStatusValues = [
114
+ var TransactionStatusValues = [
115
115
  "$success",
116
116
  "$failure",
117
117
  "$pending"
@@ -121,7 +121,7 @@ var TransactionStatus = {
121
121
  Failure: "$failure",
122
122
  Pending: "$pending"
123
123
  };
124
- var SiftPaymentTypeValues = [
124
+ var PaymentTypeValues = [
125
125
  "$cash",
126
126
  "$check",
127
127
  "$credit_card",
@@ -173,7 +173,7 @@ var PaymentType = {
173
173
  WireCredit: "$wire_credit",
174
174
  WireDebit: "$wire_debit"
175
175
  };
176
- var SiftWalletTypeValues = ["$crypto", "$digital", "$fiat"];
176
+ var WalletTypeValues = ["$crypto", "$digital", "$fiat"];
177
177
  var WalletType = {
178
178
  Crypto: "$crypto",
179
179
  Digital: "$digital",
@@ -230,7 +230,7 @@ var PAYMENT_TYPE_ALIASES = {
230
230
  wire_credit: "$wire_credit",
231
231
  wire_debit: "$wire_debit"
232
232
  };
233
- var SIFT_PAYMENT_METHOD_WHITELIST = /* @__PURE__ */ new Set([
233
+ var PAYMENT_METHOD_FIELD_WHITELIST = /* @__PURE__ */ new Set([
234
234
  "payment_type",
235
235
  "payment_gateway",
236
236
  "card_bin",
@@ -267,18 +267,18 @@ function isDevEnvironment() {
267
267
  function warnDeprecatedKey(key) {
268
268
  if (!isDevEnvironment()) return;
269
269
  const messages = {
270
- account_number_last4: "[vesant-sdk/fraud] account_number_last4 is not a Sift field; use account_number_last5",
271
- account_id: "[vesant-sdk/fraud] account_id is not a Sift field; moved to metadata",
272
- wallet_address_last4: "[vesant-sdk/fraud] wallet_address_last4 is not a Sift field; moved to metadata",
273
- crypto_currency: "[vesant-sdk/fraud] crypto_currency is not a Sift field on payment_method; moved to metadata",
274
- network: "[vesant-sdk/fraud] network is not a Sift field on payment_method; moved to metadata"
270
+ account_number_last4: "[vesant-sdk/fraud] account_number_last4 is not a recognized field; use account_number_last5",
271
+ account_id: "[vesant-sdk/fraud] account_id is not a recognized field; moved to metadata",
272
+ wallet_address_last4: "[vesant-sdk/fraud] wallet_address_last4 is not a recognized field; moved to metadata",
273
+ crypto_currency: "[vesant-sdk/fraud] crypto_currency is not a recognized field on payment_method; moved to metadata",
274
+ network: "[vesant-sdk/fraud] network is not a recognized field on payment_method; moved to metadata"
275
275
  };
276
276
  const message = messages[key];
277
277
  if (message) {
278
278
  console.warn(message);
279
279
  }
280
280
  }
281
- function normalizeSiftPaymentType(value) {
281
+ function normalizePaymentType(value) {
282
282
  if (value === void 0 || value === null) return void 0;
283
283
  const trimmed = String(value).trim();
284
284
  if (trimmed === "") return void 0;
@@ -286,12 +286,12 @@ function normalizeSiftPaymentType(value) {
286
286
  const alias = PAYMENT_TYPE_ALIASES[normalized.toLowerCase()];
287
287
  if (alias) return alias;
288
288
  const withPrefix = `$${normalized}`;
289
- if (SiftPaymentTypeValues.includes(withPrefix)) {
289
+ if (PaymentTypeValues.includes(withPrefix)) {
290
290
  return withPrefix;
291
291
  }
292
292
  return void 0;
293
293
  }
294
- function toSiftAccountNumberLast5(value) {
294
+ function toAccountNumberLast5(value) {
295
295
  if (value === void 0 || value === null) return void 0;
296
296
  const digits = String(value).replace(/\D/g, "");
297
297
  if (digits.length === 0) return void 0;
@@ -302,11 +302,11 @@ function collectMetadataExtra(metadataExtras, key, value) {
302
302
  if (value === void 0) return;
303
303
  metadataExtras[key] = value;
304
304
  }
305
- function normalizeSiftPaymentMethod(raw) {
305
+ function normalizePaymentMethod(raw) {
306
306
  const metadataExtras = {};
307
307
  const method = {};
308
308
  const rawPaymentType = raw.payment_type !== void 0 ? String(raw.payment_type) : raw.$payment_type !== void 0 ? String(raw.$payment_type) : void 0;
309
- const normalizedType = normalizeSiftPaymentType(rawPaymentType);
309
+ const normalizedType = normalizePaymentType(rawPaymentType);
310
310
  if (rawPaymentType !== void 0 && normalizedType === void 0) {
311
311
  return null;
312
312
  }
@@ -318,7 +318,7 @@ function normalizeSiftPaymentMethod(raw) {
318
318
  }
319
319
  const accountLast4 = raw.account_number_last4 ?? raw.$account_number_last4;
320
320
  const accountLast5 = raw.account_number_last5 ?? raw.$account_number_last5;
321
- const resolvedLast5 = toSiftAccountNumberLast5(accountLast5 ?? accountLast4);
321
+ const resolvedLast5 = toAccountNumberLast5(accountLast5 ?? accountLast4);
322
322
  if (resolvedLast5 !== void 0) {
323
323
  method.account_number_last5 = resolvedLast5;
324
324
  }
@@ -329,13 +329,13 @@ function normalizeSiftPaymentMethod(raw) {
329
329
  const plainKey = key.startsWith("$") ? key.slice(1) : key;
330
330
  if (METADATA_STRIP_KEYS.has(plainKey)) {
331
331
  if (plainKey === "account_id") {
332
- collectMetadataExtra(metadataExtras, "linkmoney_account_id", String(value));
332
+ collectMetadataExtra(metadataExtras, "payment_method_account_id", String(value));
333
333
  } else {
334
334
  collectMetadataExtra(metadataExtras, plainKey, value);
335
335
  }
336
336
  continue;
337
337
  }
338
- if (!SIFT_PAYMENT_METHOD_WHITELIST.has(plainKey)) {
338
+ if (!PAYMENT_METHOD_FIELD_WHITELIST.has(plainKey)) {
339
339
  collectMetadataExtra(metadataExtras, `payment_method_${plainKey}`, value);
340
340
  continue;
341
341
  }
@@ -351,29 +351,29 @@ function normalizeSiftPaymentMethod(raw) {
351
351
  };
352
352
  }
353
353
  function mergeAccountIds(target, accountId) {
354
- const existing = target.linkmoney_account_ids;
354
+ const existing = target.payment_method_account_ids;
355
355
  if (Array.isArray(existing)) {
356
356
  existing.push(accountId);
357
357
  return;
358
358
  }
359
- if (typeof target.linkmoney_account_id === "string") {
360
- target.linkmoney_account_ids = [target.linkmoney_account_id, accountId];
361
- delete target.linkmoney_account_id;
359
+ if (typeof target.payment_method_account_id === "string") {
360
+ target.payment_method_account_ids = [target.payment_method_account_id, accountId];
361
+ delete target.payment_method_account_id;
362
362
  return;
363
363
  }
364
- target.linkmoney_account_id = accountId;
364
+ target.payment_method_account_id = accountId;
365
365
  }
366
- function normalizeSiftPaymentMethods(methods) {
366
+ function normalizePaymentMethods(methods) {
367
367
  if (methods === void 0) return {};
368
368
  const normalized = [];
369
369
  const metadata = {};
370
370
  for (const raw of methods) {
371
- const result = normalizeSiftPaymentMethod(raw);
371
+ const result = normalizePaymentMethod(raw);
372
372
  if (result === null) continue;
373
373
  normalized.push(result.method);
374
374
  if (result.metadataExtras) {
375
375
  for (const [key, value] of Object.entries(result.metadataExtras)) {
376
- if (key === "linkmoney_account_id" && typeof value === "string") {
376
+ if (key === "payment_method_account_id" && typeof value === "string") {
377
377
  mergeAccountIds(metadata, value);
378
378
  } else if (key in metadata && Array.isArray(metadata[key]) && Array.isArray(value)) {
379
379
  metadata[key] = [...metadata[key], ...value];
@@ -390,21 +390,21 @@ function normalizeSiftPaymentMethods(methods) {
390
390
  };
391
391
  }
392
392
 
393
- // src/normalization/sift-keys.ts
394
- function siftKey(key) {
393
+ // src/normalization/reserved-keys.ts
394
+ function reservedKey(key) {
395
395
  return key.startsWith("$") ? key : `$${key}`;
396
396
  }
397
- function toSiftKeyedObject(value) {
397
+ function toReservedKeyedObject(value) {
398
398
  if (value === null || value === void 0) {
399
399
  return value;
400
400
  }
401
401
  if (Array.isArray(value)) {
402
- return value.map((item) => toSiftKeyedObject(item));
402
+ return value.map((item) => toReservedKeyedObject(item));
403
403
  }
404
404
  if (typeof value === "object") {
405
405
  const out = {};
406
406
  for (const [key, nested] of Object.entries(value)) {
407
- out[siftKey(key)] = toSiftKeyedObject(nested);
407
+ out[reservedKey(key)] = toReservedKeyedObject(nested);
408
408
  }
409
409
  return out;
410
410
  }
@@ -412,12 +412,13 @@ function toSiftKeyedObject(value) {
412
412
  }
413
413
 
414
414
  // src/normalization/normalize.ts
415
- var BASE_SIFT_FIELD_KEYS = [
415
+ var WIRE_USER_REFERENCE_KEY = "sift_user_id";
416
+ var BASE_RESERVED_FIELD_KEYS = [
416
417
  "session_id",
417
418
  "user_email",
418
419
  "name",
419
420
  "phone",
420
- "sift_payment_method",
421
+ "payment_method_details",
421
422
  "payment_methods",
422
423
  "billing_address",
423
424
  "shipping_address",
@@ -452,9 +453,9 @@ function createStrippedBody(rest, metadata, stripKeys) {
452
453
  stripKeys
453
454
  );
454
455
  }
455
- function applySiftMetadata(body, metadata, siftMetadata, onlyWhenNonEmpty = false) {
456
- if (!onlyWhenNonEmpty || Object.keys(siftMetadata).length > 0) {
457
- body.metadata = mergeMetadata(metadata, siftMetadata);
456
+ function applyReservedMetadata(body, metadata, reservedMetadata, onlyWhenNonEmpty = false) {
457
+ if (!onlyWhenNonEmpty || Object.keys(reservedMetadata).length > 0) {
458
+ body.metadata = mergeMetadata(metadata, reservedMetadata);
458
459
  }
459
460
  return body;
460
461
  }
@@ -468,14 +469,14 @@ function collectRuleSignals(request, keys) {
468
469
  }
469
470
  return signals;
470
471
  }
471
- function buildBaseSiftMetadata(body) {
472
+ function buildBaseReservedMetadata(body) {
472
473
  const {
473
474
  event_type,
474
475
  session_id,
475
476
  user_email,
476
477
  name,
477
478
  phone,
478
- sift_payment_method,
479
+ payment_method_details,
479
480
  payment_methods,
480
481
  billing_address,
481
482
  shipping_address,
@@ -497,83 +498,87 @@ function buildBaseSiftMetadata(body) {
497
498
  metadata,
498
499
  skip_payment_method_normalization
499
500
  } = body;
500
- const siftMetadata = {
501
+ const reservedMetadata = {
501
502
  ...metadata ?? {}
502
503
  };
503
- if (session_id !== void 0) siftMetadata.$session_id = session_id;
504
- if (user_email !== void 0) siftMetadata.$user_email = user_email;
505
- if (name !== void 0) siftMetadata.$name = name;
506
- if (phone !== void 0) siftMetadata.$phone = phone;
507
- if (sift_payment_method !== void 0) {
504
+ if (session_id !== void 0) reservedMetadata.$session_id = session_id;
505
+ if (user_email !== void 0) reservedMetadata.$user_email = user_email;
506
+ if (name !== void 0) reservedMetadata.$name = name;
507
+ if (phone !== void 0) reservedMetadata.$phone = phone;
508
+ if (payment_method_details !== void 0) {
508
509
  if (skip_payment_method_normalization) {
509
- siftMetadata.$payment_method = toSiftKeyedObject(sift_payment_method);
510
+ reservedMetadata.$payment_method = toReservedKeyedObject(payment_method_details);
510
511
  } else {
511
- const result = normalizeSiftPaymentMethod(
512
- sift_payment_method
512
+ const result = normalizePaymentMethod(
513
+ payment_method_details
513
514
  );
514
515
  if (result !== null) {
515
- siftMetadata.$payment_method = toSiftKeyedObject(result.method);
516
+ reservedMetadata.$payment_method = toReservedKeyedObject(result.method);
516
517
  if (result.metadataExtras) {
517
- Object.assign(siftMetadata, result.metadataExtras);
518
+ Object.assign(reservedMetadata, result.metadataExtras);
518
519
  }
519
520
  }
520
521
  }
521
522
  }
522
523
  if (payment_methods !== void 0) {
523
524
  if (skip_payment_method_normalization) {
524
- siftMetadata.$payment_methods = toSiftKeyedObject(payment_methods);
525
+ reservedMetadata.$payment_methods = toReservedKeyedObject(payment_methods);
525
526
  } else {
526
- const { payment_methods: normalized, metadata: pmMetadata } = normalizeSiftPaymentMethods(
527
+ const { payment_methods: normalized, metadata: pmMetadata } = normalizePaymentMethods(
527
528
  payment_methods
528
529
  );
529
530
  if (normalized !== void 0) {
530
- siftMetadata.$payment_methods = toSiftKeyedObject(normalized);
531
+ reservedMetadata.$payment_methods = toReservedKeyedObject(normalized);
531
532
  }
532
533
  if (pmMetadata) {
533
- Object.assign(siftMetadata, pmMetadata);
534
+ Object.assign(reservedMetadata, pmMetadata);
534
535
  }
535
536
  }
536
537
  }
537
538
  if (billing_address !== void 0) {
538
- siftMetadata.$billing_address = toSiftKeyedObject(billing_address);
539
+ reservedMetadata.$billing_address = toReservedKeyedObject(billing_address);
539
540
  }
540
541
  if (shipping_address !== void 0) {
541
- siftMetadata.$shipping_address = toSiftKeyedObject(shipping_address);
542
+ reservedMetadata.$shipping_address = toReservedKeyedObject(shipping_address);
542
543
  }
543
- if (app !== void 0) siftMetadata.$app = toSiftKeyedObject(app);
544
+ if (app !== void 0) reservedMetadata.$app = toReservedKeyedObject(app);
544
545
  if (browser !== void 0) {
545
- siftMetadata.$browser = toSiftKeyedObject(browser);
546
+ reservedMetadata.$browser = toReservedKeyedObject(browser);
546
547
  }
547
548
  if (event_type === "$create_order" || event_type === "$update_account") {
548
549
  if (verification_phone_number !== void 0) {
549
- siftMetadata.$verification_phone_number = verification_phone_number;
550
+ reservedMetadata.$verification_phone_number = verification_phone_number;
550
551
  }
551
552
  }
552
553
  if (event_type === "$create_order") {
553
- if (order_id !== void 0) siftMetadata.$order_id = order_id;
554
- if (amount !== void 0) siftMetadata.$amount = amount;
555
- if (currency_code !== void 0) siftMetadata.$currency_code = currency_code;
554
+ if (order_id !== void 0) reservedMetadata.$order_id = order_id;
555
+ if (amount !== void 0) reservedMetadata.$amount = amount;
556
+ if (currency_code !== void 0) reservedMetadata.$currency_code = currency_code;
556
557
  if (exchange_rate !== void 0) {
557
- siftMetadata.$exchange_rate = toSiftKeyedObject(exchange_rate);
558
+ reservedMetadata.$exchange_rate = toReservedKeyedObject(exchange_rate);
558
559
  }
559
- if (expedited_shipping !== void 0) siftMetadata.$expedited_shipping = expedited_shipping;
560
- if (shipping_method !== void 0) siftMetadata.$shipping_method = shipping_method;
561
- if (shipping_carrier !== void 0) siftMetadata.$shipping_carrier = shipping_carrier;
560
+ if (expedited_shipping !== void 0) reservedMetadata.$expedited_shipping = expedited_shipping;
561
+ if (shipping_method !== void 0) reservedMetadata.$shipping_method = shipping_method;
562
+ if (shipping_carrier !== void 0) reservedMetadata.$shipping_carrier = shipping_carrier;
562
563
  if (shipping_tracking_numbers !== void 0) {
563
- siftMetadata.$shipping_tracking_numbers = shipping_tracking_numbers;
564
+ reservedMetadata.$shipping_tracking_numbers = shipping_tracking_numbers;
564
565
  }
565
- if (brand_name !== void 0) siftMetadata.$brand_name = brand_name;
566
- if (site_country !== void 0) siftMetadata.$site_country = site_country;
567
- if (site_domain !== void 0) siftMetadata.$site_domain = site_domain;
568
- if (ip !== void 0) siftMetadata.$ip = ip;
566
+ if (brand_name !== void 0) reservedMetadata.$brand_name = brand_name;
567
+ if (site_country !== void 0) reservedMetadata.$site_country = site_country;
568
+ if (site_domain !== void 0) reservedMetadata.$site_domain = site_domain;
569
+ if (ip !== void 0) reservedMetadata.$ip = ip;
569
570
  }
570
- return siftMetadata;
571
+ return reservedMetadata;
571
572
  }
572
- function normalizeBaseSiftFields(body) {
573
- const siftMetadata = buildBaseSiftMetadata(body);
574
- const stripped = stripSdkOnlyFields(body, [...BASE_SIFT_FIELD_KEYS]);
575
- if (Object.keys(siftMetadata).length > 0) {
576
- stripped.metadata = siftMetadata;
573
+ function normalizeBaseReservedFields(body) {
574
+ const reservedMetadata = buildBaseReservedMetadata(body);
575
+ const stripped = stripSdkOnlyFields(body, [...BASE_RESERVED_FIELD_KEYS]);
576
+ if ("user_reference" in stripped) {
577
+ stripped[WIRE_USER_REFERENCE_KEY] = stripped.user_reference;
578
+ delete stripped.user_reference;
579
+ }
580
+ if (Object.keys(reservedMetadata).length > 0) {
581
+ stripped.metadata = reservedMetadata;
577
582
  }
578
583
  return stripped;
579
584
  }
@@ -594,12 +599,12 @@ function normalizeUpdatePassword(request) {
594
599
  "password_reason",
595
600
  "password_status"
596
601
  ]);
597
- const siftMetadata = {
602
+ const reservedMetadata = {
598
603
  $reason: password_reason ?? PasswordUpdateReason.UserUpdate,
599
604
  $status: password_status ?? PasswordUpdateStatus.Success
600
605
  };
601
- body = applySiftMetadata(body, metadata, siftMetadata);
602
- return normalizeBaseSiftFields(body);
606
+ body = applyReservedMetadata(body, metadata, reservedMetadata);
607
+ return normalizeBaseReservedFields(body);
603
608
  }
604
609
  function normalizeWager(request) {
605
610
  const { wager_type, wager_status, wager_event_type, wager_event_name, wager_event_id, metadata, ...rest } = request;
@@ -610,15 +615,15 @@ function normalizeWager(request) {
610
615
  "wager_event_name",
611
616
  "wager_event_id"
612
617
  ]);
613
- const siftMetadata = {
618
+ const reservedMetadata = {
614
619
  $wager_type: wager_type,
615
620
  $wager_status: wager_status
616
621
  };
617
- if (wager_event_type) siftMetadata.$wager_event_type = wager_event_type;
618
- if (wager_event_name) siftMetadata.$wager_event_name = wager_event_name;
619
- if (wager_event_id) siftMetadata.$wager_event_id = wager_event_id;
620
- body = applySiftMetadata(body, metadata, siftMetadata);
621
- return normalizeBaseSiftFields(body);
622
+ if (wager_event_type) reservedMetadata.$wager_event_type = wager_event_type;
623
+ if (wager_event_name) reservedMetadata.$wager_event_name = wager_event_name;
624
+ if (wager_event_id) reservedMetadata.$wager_event_id = wager_event_id;
625
+ body = applyReservedMetadata(body, metadata, reservedMetadata);
626
+ return normalizeBaseReservedFields(body);
622
627
  }
623
628
  function normalizeLogin(request) {
624
629
  const { login_status, login_failure_reason, metadata, ...rest } = request;
@@ -628,20 +633,20 @@ function normalizeLogin(request) {
628
633
  "login_failure_reason",
629
634
  ...LOGIN_RULE_SIGNAL_KEYS
630
635
  ]);
631
- const siftMetadata = {
636
+ const reservedMetadata = {
632
637
  $login_status: effectiveStatus
633
638
  };
634
639
  if (effectiveStatus === LoginStatus.Failure && login_failure_reason) {
635
- siftMetadata.$failure_reason = login_failure_reason;
640
+ reservedMetadata.$failure_reason = login_failure_reason;
636
641
  }
637
- body = applySiftMetadata(body, metadata, siftMetadata);
642
+ body = applyReservedMetadata(body, metadata, reservedMetadata);
638
643
  body = applyRuleSignals(
639
644
  body,
640
645
  request,
641
646
  LOGIN_RULE_SIGNAL_KEYS,
642
647
  []
643
648
  );
644
- return normalizeBaseSiftFields(body);
649
+ return normalizeBaseReservedFields(body);
645
650
  }
646
651
  function normalizeTransaction(request) {
647
652
  const { transaction_status, decline_category, transfer_recipient_user_id, metadata, ...rest } = request;
@@ -651,20 +656,20 @@ function normalizeTransaction(request) {
651
656
  "transfer_recipient_user_id",
652
657
  ...TRANSACTION_RULE_SIGNAL_KEYS
653
658
  ]);
654
- const siftMetadata = {};
655
- if (transaction_status) siftMetadata.$transaction_status = transaction_status;
656
- if (decline_category) siftMetadata.$decline_category = decline_category;
659
+ const reservedMetadata = {};
660
+ if (transaction_status) reservedMetadata.$transaction_status = transaction_status;
661
+ if (decline_category) reservedMetadata.$decline_category = decline_category;
657
662
  if (transfer_recipient_user_id) {
658
- siftMetadata.$transfer_recipient_user_id = transfer_recipient_user_id;
663
+ reservedMetadata.$transfer_recipient_user_id = transfer_recipient_user_id;
659
664
  }
660
- body = applySiftMetadata(body, metadata, siftMetadata, true);
665
+ body = applyReservedMetadata(body, metadata, reservedMetadata, true);
661
666
  body = applyRuleSignals(
662
667
  body,
663
668
  request,
664
669
  TRANSACTION_RULE_SIGNAL_KEYS,
665
670
  []
666
671
  );
667
- return normalizeBaseSiftFields(body);
672
+ return normalizeBaseReservedFields(body);
668
673
  }
669
674
  function normalizeUpdateAccount(request) {
670
675
  const { metadata, ...rest } = request;
@@ -677,7 +682,7 @@ function normalizeUpdateAccount(request) {
677
682
  UPDATE_ACCOUNT_RULE_SIGNAL_KEYS,
678
683
  []
679
684
  );
680
- return normalizeBaseSiftFields(body);
685
+ return normalizeBaseReservedFields(body);
681
686
  }
682
687
  function normalizeCreateOrder(request) {
683
688
  const { amount, currency_code, metadata, ...rest } = request;
@@ -685,15 +690,15 @@ function normalizeCreateOrder(request) {
685
690
  "amount",
686
691
  "currency_code"
687
692
  ]);
688
- const siftMetadata = {
693
+ const reservedMetadata = {
689
694
  $amount: amount,
690
695
  $currency_code: currency_code
691
696
  };
692
- body = applySiftMetadata(body, metadata, siftMetadata);
693
- return normalizeBaseSiftFields(body);
697
+ body = applyReservedMetadata(body, metadata, reservedMetadata);
698
+ return normalizeBaseReservedFields(body);
694
699
  }
695
700
  function normalizeDefault(request) {
696
- return normalizeBaseSiftFields({ ...request });
701
+ return normalizeBaseReservedFields({ ...request });
697
702
  }
698
703
  function normalizeScoreRequestForApi(request) {
699
704
  switch (request.event_type) {
@@ -751,12 +756,12 @@ function isSupportedFraudEventType(eventType) {
751
756
  }
752
757
 
753
758
  // src/types/metadata.ts
754
- var TYPED_SIFT_METADATA_KEYS = {
759
+ var TYPED_METADATA_KEYS = {
755
760
  session_id: "$session_id",
756
761
  user_email: "$user_email",
757
762
  name: "$name",
758
763
  phone: "$phone",
759
- sift_payment_method: "$payment_method",
764
+ payment_method_details: "$payment_method",
760
765
  billing_address: "$billing_address",
761
766
  payment_methods: "$payment_methods",
762
767
  app: "$app",
@@ -775,7 +780,7 @@ var TYPED_SIFT_METADATA_KEYS = {
775
780
  ip: "$ip"
776
781
  };
777
782
  function findMetadataConflictWithTypedFields(metadata, request) {
778
- for (const [field, metaKey] of Object.entries(TYPED_SIFT_METADATA_KEYS)) {
783
+ for (const [field, metaKey] of Object.entries(TYPED_METADATA_KEYS)) {
779
784
  if (request[field] !== void 0 && metadata[metaKey] !== void 0) {
780
785
  return metaKey;
781
786
  }
@@ -830,26 +835,26 @@ function validatePaymentMethods(request, errors, prefix) {
830
835
  if (skipNormalization) {
831
836
  for (const key of Object.keys(raw)) {
832
837
  const plainKey = key.startsWith("$") ? key.slice(1) : key;
833
- if (!SIFT_PAYMENT_METHOD_WHITELIST.has(plainKey)) {
838
+ if (!PAYMENT_METHOD_FIELD_WHITELIST.has(plainKey)) {
834
839
  errors.push(
835
- `${prefix}payment_methods[${index}].${plainKey} is not a valid Sift payment method field`
840
+ `${prefix}payment_methods[${index}].${plainKey} is not a recognized payment method field`
836
841
  );
837
842
  }
838
843
  }
839
844
  const rawType2 = raw.payment_type !== void 0 ? String(raw.payment_type) : void 0;
840
- if (rawType2 !== void 0 && normalizeSiftPaymentType(rawType2) === void 0) {
845
+ if (rawType2 !== void 0 && normalizePaymentType(rawType2) === void 0) {
841
846
  errors.push(
842
- `${prefix}payment_methods[${index}].payment_type is not a valid Sift payment type`
847
+ `${prefix}payment_methods[${index}].payment_type is not a recognized payment type`
843
848
  );
844
849
  }
845
850
  return;
846
851
  }
847
852
  const rawType = raw.payment_type !== void 0 ? String(raw.payment_type) : raw.$payment_type !== void 0 ? String(raw.$payment_type) : void 0;
848
853
  if (rawType !== void 0) {
849
- const result = normalizeSiftPaymentMethod(raw);
854
+ const result = normalizePaymentMethod(raw);
850
855
  if (result === null) {
851
856
  errors.push(
852
- `${prefix}payment_methods[${index}].payment_type is not a valid Sift payment type`
857
+ `${prefix}payment_methods[${index}].payment_type is not a recognized payment type`
853
858
  );
854
859
  }
855
860
  }
@@ -857,17 +862,17 @@ function validatePaymentMethods(request, errors, prefix) {
857
862
  }
858
863
  function validateBase(request, errors, prefix) {
859
864
  assertNonEmpty(request.customer_id, "customer_id", errors, prefix);
860
- assertNonEmpty(request.sift_user_id, "sift_user_id", errors, prefix);
865
+ assertNonEmpty(request.user_reference, "user_reference", errors, prefix);
861
866
  assertNonEmpty(request.event_type, "event_type", errors, prefix);
862
867
  validateMetadata(request.metadata, request, errors, prefix);
863
868
  }
864
869
  function validateLogin(request, errors, prefix) {
865
- assertEnum(request.login_status, SiftLoginStatusValues, "login_status", errors, prefix);
870
+ assertEnum(request.login_status, LoginStatusValues, "login_status", errors, prefix);
866
871
  if (request.login_failure_reason !== void 0) {
867
872
  if (request.login_status === "$failure") {
868
873
  assertEnum(
869
874
  request.login_failure_reason,
870
- SiftLoginFailureReasonValues,
875
+ LoginFailureReasonValues,
871
876
  "login_failure_reason",
872
877
  errors,
873
878
  prefix
@@ -880,14 +885,14 @@ function validateLogin(request, errors, prefix) {
880
885
  function validateUpdatePassword(request, errors, prefix) {
881
886
  assertEnum(
882
887
  request.password_reason,
883
- SiftPasswordUpdateReasonValues,
888
+ PasswordUpdateReasonValues,
884
889
  "password_reason",
885
890
  errors,
886
891
  prefix
887
892
  );
888
893
  assertEnum(
889
894
  request.password_status,
890
- SiftPasswordUpdateStatusValues,
895
+ PasswordUpdateStatusValues,
891
896
  "password_status",
892
897
  errors,
893
898
  prefix
@@ -896,10 +901,10 @@ function validateUpdatePassword(request, errors, prefix) {
896
901
  function validateTransaction(request, errors, prefix) {
897
902
  assertPositiveAmount(request.amount, "amount", errors, prefix);
898
903
  assertNonEmpty(request.currency, "currency", errors, prefix);
899
- assertEnum(request.transaction_type, SiftTransactionTypeValues, "transaction_type", errors, prefix);
904
+ assertEnum(request.transaction_type, TransactionTypeValues, "transaction_type", errors, prefix);
900
905
  assertEnum(
901
906
  request.transaction_status,
902
- SiftTransactionStatusValues,
907
+ TransactionStatusValues,
903
908
  "transaction_status",
904
909
  errors,
905
910
  prefix
@@ -918,7 +923,7 @@ function validateTransaction(request, errors, prefix) {
918
923
  function validateWager(request, errors, prefix) {
919
924
  assertNonEmpty(request.transaction_id, "transaction_id", errors, prefix);
920
925
  assertNonEmpty(request.wager_type, "wager_type", errors, prefix);
921
- assertEnum(request.wager_status, SiftWagerStatusValues, "wager_status", errors, prefix);
926
+ assertEnum(request.wager_status, WagerStatusValues, "wager_status", errors, prefix);
922
927
  if (!request.wager_status) {
923
928
  errors.push(`${prefix}wager_status is required`);
924
929
  }
@@ -953,10 +958,10 @@ function validateChargeback(request, errors, prefix) {
953
958
  if (!hasTransactionId && !hasOrderId) {
954
959
  errors.push(`${prefix}transaction_id or order_id is required`);
955
960
  }
956
- assertEnum(request.chargeback_state, SiftChargebackStateValues, "chargeback_state", errors, prefix);
961
+ assertEnum(request.chargeback_state, ChargebackStateValues, "chargeback_state", errors, prefix);
957
962
  assertEnum(
958
963
  request.chargeback_reason,
959
- SiftChargebackReasonValues,
964
+ ChargebackReasonValues,
960
965
  "chargeback_reason",
961
966
  errors,
962
967
  prefix
@@ -1064,44 +1069,44 @@ function isFraudAlertCallbackEvent(value) {
1064
1069
 
1065
1070
  exports.CHARGEBACK_FRAUD_EVENT_TYPE = CHARGEBACK_FRAUD_EVENT_TYPE;
1066
1071
  exports.ChargebackReason = ChargebackReason;
1072
+ exports.ChargebackReasonValues = ChargebackReasonValues;
1067
1073
  exports.ChargebackState = ChargebackState;
1074
+ exports.ChargebackStateValues = ChargebackStateValues;
1068
1075
  exports.FraudClient = FraudClient;
1069
1076
  exports.LOGIN_RULE_SIGNAL_KEYS = LOGIN_RULE_SIGNAL_KEYS;
1077
+ exports.LoginFailureReasonValues = LoginFailureReasonValues;
1070
1078
  exports.LoginStatus = LoginStatus;
1079
+ exports.LoginStatusValues = LoginStatusValues;
1071
1080
  exports.PLANNED_FRAUD_EVENT_TYPES = PLANNED_FRAUD_EVENT_TYPES;
1072
1081
  exports.PasswordUpdateReason = PasswordUpdateReason;
1082
+ exports.PasswordUpdateReasonValues = PasswordUpdateReasonValues;
1073
1083
  exports.PasswordUpdateStatus = PasswordUpdateStatus;
1084
+ exports.PasswordUpdateStatusValues = PasswordUpdateStatusValues;
1074
1085
  exports.PaymentType = PaymentType;
1086
+ exports.PaymentTypeValues = PaymentTypeValues;
1075
1087
  exports.SCORED_FRAUD_EVENT_TYPES = SCORED_FRAUD_EVENT_TYPES;
1076
1088
  exports.SUPPORTED_FRAUD_EVENT_TYPES = SUPPORTED_FRAUD_EVENT_TYPES;
1077
- exports.SiftChargebackReasonValues = SiftChargebackReasonValues;
1078
- exports.SiftChargebackStateValues = SiftChargebackStateValues;
1079
- exports.SiftLoginFailureReasonValues = SiftLoginFailureReasonValues;
1080
- exports.SiftLoginStatusValues = SiftLoginStatusValues;
1081
- exports.SiftPasswordUpdateReasonValues = SiftPasswordUpdateReasonValues;
1082
- exports.SiftPasswordUpdateStatusValues = SiftPasswordUpdateStatusValues;
1083
- exports.SiftPaymentTypeValues = SiftPaymentTypeValues;
1084
- exports.SiftTransactionStatusValues = SiftTransactionStatusValues;
1085
- exports.SiftTransactionTypeValues = SiftTransactionTypeValues;
1086
- exports.SiftWagerStatusValues = SiftWagerStatusValues;
1087
- exports.SiftWalletTypeValues = SiftWalletTypeValues;
1088
1089
  exports.TRANSACTION_RULE_SIGNAL_KEYS = TRANSACTION_RULE_SIGNAL_KEYS;
1089
- exports.TYPED_SIFT_METADATA_KEYS = TYPED_SIFT_METADATA_KEYS;
1090
+ exports.TYPED_METADATA_KEYS = TYPED_METADATA_KEYS;
1090
1091
  exports.TransactionStatus = TransactionStatus;
1092
+ exports.TransactionStatusValues = TransactionStatusValues;
1091
1093
  exports.TransactionType = TransactionType;
1094
+ exports.TransactionTypeValues = TransactionTypeValues;
1092
1095
  exports.UPDATE_ACCOUNT_RULE_SIGNAL_KEYS = UPDATE_ACCOUNT_RULE_SIGNAL_KEYS;
1093
1096
  exports.WagerStatus = WagerStatus;
1097
+ exports.WagerStatusValues = WagerStatusValues;
1094
1098
  exports.WalletType = WalletType;
1099
+ exports.WalletTypeValues = WalletTypeValues;
1095
1100
  exports.buildScoreRequestPreview = buildScoreRequestPreview;
1096
1101
  exports.findMetadataConflictWithTypedFields = findMetadataConflictWithTypedFields;
1097
1102
  exports.isFraudAlertCallbackEvent = isFraudAlertCallbackEvent;
1098
1103
  exports.isPlannedFraudEventType = isPlannedFraudEventType;
1099
1104
  exports.isSupportedFraudEventType = isSupportedFraudEventType;
1105
+ exports.normalizePaymentMethod = normalizePaymentMethod;
1106
+ exports.normalizePaymentMethods = normalizePaymentMethods;
1107
+ exports.normalizePaymentType = normalizePaymentType;
1100
1108
  exports.normalizeScoreRequestForApi = normalizeScoreRequestForApi;
1101
- exports.normalizeSiftPaymentMethod = normalizeSiftPaymentMethod;
1102
- exports.normalizeSiftPaymentMethods = normalizeSiftPaymentMethods;
1103
- exports.normalizeSiftPaymentType = normalizeSiftPaymentType;
1104
- exports.toSiftAccountNumberLast5 = toSiftAccountNumberLast5;
1109
+ exports.toAccountNumberLast5 = toAccountNumberLast5;
1105
1110
  exports.validateScoreRequest = validateScoreRequest;
1106
1111
  //# sourceMappingURL=index.js.map
1107
1112
  //# sourceMappingURL=index.js.map