@xyo-network/rebilly-payment-card-authorization-plugin 2.99.6 → 3.0.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.
Files changed (210) hide show
  1. package/dist/neutral/index.d.ts +39 -5
  2. package/package.json +18 -37
  3. package/xy.config.ts +4 -5
  4. package/dist/browser/Api/PaymentCardToken/Request.d.cts +0 -38
  5. package/dist/browser/Api/PaymentCardToken/Request.d.cts.map +0 -1
  6. package/dist/browser/Api/PaymentCardToken/Request.d.mts +0 -38
  7. package/dist/browser/Api/PaymentCardToken/Request.d.mts.map +0 -1
  8. package/dist/browser/Api/PaymentCardToken/Request.d.ts +0 -38
  9. package/dist/browser/Api/PaymentCardToken/Request.d.ts.map +0 -1
  10. package/dist/browser/Api/PaymentCardToken/Response.d.cts +0 -36
  11. package/dist/browser/Api/PaymentCardToken/Response.d.cts.map +0 -1
  12. package/dist/browser/Api/PaymentCardToken/Response.d.mts +0 -36
  13. package/dist/browser/Api/PaymentCardToken/Response.d.mts.map +0 -1
  14. package/dist/browser/Api/PaymentCardToken/Response.d.ts +0 -36
  15. package/dist/browser/Api/PaymentCardToken/Response.d.ts.map +0 -1
  16. package/dist/browser/Api/PaymentCardToken/index.d.cts +0 -3
  17. package/dist/browser/Api/PaymentCardToken/index.d.cts.map +0 -1
  18. package/dist/browser/Api/PaymentCardToken/index.d.mts +0 -3
  19. package/dist/browser/Api/PaymentCardToken/index.d.mts.map +0 -1
  20. package/dist/browser/Api/PaymentCardToken/index.d.ts +0 -3
  21. package/dist/browser/Api/PaymentCardToken/index.d.ts.map +0 -1
  22. package/dist/browser/Api/index.d.cts +0 -2
  23. package/dist/browser/Api/index.d.cts.map +0 -1
  24. package/dist/browser/Api/index.d.mts +0 -2
  25. package/dist/browser/Api/index.d.mts.map +0 -1
  26. package/dist/browser/Api/index.d.ts +0 -2
  27. package/dist/browser/Api/index.d.ts.map +0 -1
  28. package/dist/browser/Config.d.cts +0 -8
  29. package/dist/browser/Config.d.cts.map +0 -1
  30. package/dist/browser/Config.d.mts +0 -8
  31. package/dist/browser/Config.d.mts.map +0 -1
  32. package/dist/browser/Config.d.ts +0 -8
  33. package/dist/browser/Config.d.ts.map +0 -1
  34. package/dist/browser/Params.d.cts +0 -7
  35. package/dist/browser/Params.d.cts.map +0 -1
  36. package/dist/browser/Params.d.mts +0 -7
  37. package/dist/browser/Params.d.mts.map +0 -1
  38. package/dist/browser/Params.d.ts +0 -7
  39. package/dist/browser/Params.d.ts.map +0 -1
  40. package/dist/browser/Schema.d.cts +0 -3
  41. package/dist/browser/Schema.d.cts.map +0 -1
  42. package/dist/browser/Schema.d.mts +0 -3
  43. package/dist/browser/Schema.d.mts.map +0 -1
  44. package/dist/browser/Schema.d.ts +0 -3
  45. package/dist/browser/Schema.d.ts.map +0 -1
  46. package/dist/browser/Sentinel.d.cts +0 -24
  47. package/dist/browser/Sentinel.d.cts.map +0 -1
  48. package/dist/browser/Sentinel.d.mts +0 -24
  49. package/dist/browser/Sentinel.d.mts.map +0 -1
  50. package/dist/browser/Sentinel.d.ts +0 -24
  51. package/dist/browser/Sentinel.d.ts.map +0 -1
  52. package/dist/browser/index.cjs +0 -145
  53. package/dist/browser/index.cjs.map +0 -1
  54. package/dist/browser/index.d.cts +0 -5
  55. package/dist/browser/index.d.cts.map +0 -1
  56. package/dist/browser/index.d.mts +0 -5
  57. package/dist/browser/index.d.mts.map +0 -1
  58. package/dist/browser/index.d.ts +0 -5
  59. package/dist/browser/index.d.ts.map +0 -1
  60. package/dist/browser/index.mjs +0 -122
  61. package/dist/browser/index.mjs.map +0 -1
  62. package/dist/browser/util/index.d.cts +0 -2
  63. package/dist/browser/util/index.d.cts.map +0 -1
  64. package/dist/browser/util/index.d.mts +0 -2
  65. package/dist/browser/util/index.d.mts.map +0 -1
  66. package/dist/browser/util/index.d.ts +0 -2
  67. package/dist/browser/util/index.d.ts.map +0 -1
  68. package/dist/browser/util/toTokenRequest.d.cts +0 -4
  69. package/dist/browser/util/toTokenRequest.d.cts.map +0 -1
  70. package/dist/browser/util/toTokenRequest.d.mts +0 -4
  71. package/dist/browser/util/toTokenRequest.d.mts.map +0 -1
  72. package/dist/browser/util/toTokenRequest.d.ts +0 -4
  73. package/dist/browser/util/toTokenRequest.d.ts.map +0 -1
  74. package/dist/neutral/Api/PaymentCardToken/Request.d.cts +0 -38
  75. package/dist/neutral/Api/PaymentCardToken/Request.d.cts.map +0 -1
  76. package/dist/neutral/Api/PaymentCardToken/Request.d.mts +0 -38
  77. package/dist/neutral/Api/PaymentCardToken/Request.d.mts.map +0 -1
  78. package/dist/neutral/Api/PaymentCardToken/Request.d.ts +0 -38
  79. package/dist/neutral/Api/PaymentCardToken/Request.d.ts.map +0 -1
  80. package/dist/neutral/Api/PaymentCardToken/Response.d.cts +0 -36
  81. package/dist/neutral/Api/PaymentCardToken/Response.d.cts.map +0 -1
  82. package/dist/neutral/Api/PaymentCardToken/Response.d.mts +0 -36
  83. package/dist/neutral/Api/PaymentCardToken/Response.d.mts.map +0 -1
  84. package/dist/neutral/Api/PaymentCardToken/Response.d.ts +0 -36
  85. package/dist/neutral/Api/PaymentCardToken/Response.d.ts.map +0 -1
  86. package/dist/neutral/Api/PaymentCardToken/index.d.cts +0 -3
  87. package/dist/neutral/Api/PaymentCardToken/index.d.cts.map +0 -1
  88. package/dist/neutral/Api/PaymentCardToken/index.d.mts +0 -3
  89. package/dist/neutral/Api/PaymentCardToken/index.d.mts.map +0 -1
  90. package/dist/neutral/Api/PaymentCardToken/index.d.ts +0 -3
  91. package/dist/neutral/Api/PaymentCardToken/index.d.ts.map +0 -1
  92. package/dist/neutral/Api/index.d.cts +0 -2
  93. package/dist/neutral/Api/index.d.cts.map +0 -1
  94. package/dist/neutral/Api/index.d.mts +0 -2
  95. package/dist/neutral/Api/index.d.mts.map +0 -1
  96. package/dist/neutral/Api/index.d.ts +0 -2
  97. package/dist/neutral/Api/index.d.ts.map +0 -1
  98. package/dist/neutral/Config.d.cts +0 -8
  99. package/dist/neutral/Config.d.cts.map +0 -1
  100. package/dist/neutral/Config.d.mts +0 -8
  101. package/dist/neutral/Config.d.mts.map +0 -1
  102. package/dist/neutral/Config.d.ts +0 -8
  103. package/dist/neutral/Config.d.ts.map +0 -1
  104. package/dist/neutral/Params.d.cts +0 -7
  105. package/dist/neutral/Params.d.cts.map +0 -1
  106. package/dist/neutral/Params.d.mts +0 -7
  107. package/dist/neutral/Params.d.mts.map +0 -1
  108. package/dist/neutral/Params.d.ts +0 -7
  109. package/dist/neutral/Params.d.ts.map +0 -1
  110. package/dist/neutral/Schema.d.cts +0 -3
  111. package/dist/neutral/Schema.d.cts.map +0 -1
  112. package/dist/neutral/Schema.d.mts +0 -3
  113. package/dist/neutral/Schema.d.mts.map +0 -1
  114. package/dist/neutral/Schema.d.ts +0 -3
  115. package/dist/neutral/Schema.d.ts.map +0 -1
  116. package/dist/neutral/Sentinel.d.cts +0 -24
  117. package/dist/neutral/Sentinel.d.cts.map +0 -1
  118. package/dist/neutral/Sentinel.d.mts +0 -24
  119. package/dist/neutral/Sentinel.d.mts.map +0 -1
  120. package/dist/neutral/Sentinel.d.ts +0 -24
  121. package/dist/neutral/Sentinel.d.ts.map +0 -1
  122. package/dist/neutral/index.cjs +0 -145
  123. package/dist/neutral/index.cjs.map +0 -1
  124. package/dist/neutral/index.d.cts +0 -5
  125. package/dist/neutral/index.d.cts.map +0 -1
  126. package/dist/neutral/index.d.mts +0 -5
  127. package/dist/neutral/index.d.mts.map +0 -1
  128. package/dist/neutral/index.d.ts.map +0 -1
  129. package/dist/neutral/util/index.d.cts +0 -2
  130. package/dist/neutral/util/index.d.cts.map +0 -1
  131. package/dist/neutral/util/index.d.mts +0 -2
  132. package/dist/neutral/util/index.d.mts.map +0 -1
  133. package/dist/neutral/util/index.d.ts +0 -2
  134. package/dist/neutral/util/index.d.ts.map +0 -1
  135. package/dist/neutral/util/toTokenRequest.d.cts +0 -4
  136. package/dist/neutral/util/toTokenRequest.d.cts.map +0 -1
  137. package/dist/neutral/util/toTokenRequest.d.mts +0 -4
  138. package/dist/neutral/util/toTokenRequest.d.mts.map +0 -1
  139. package/dist/neutral/util/toTokenRequest.d.ts +0 -4
  140. package/dist/neutral/util/toTokenRequest.d.ts.map +0 -1
  141. package/dist/node/Api/PaymentCardToken/Request.d.cts +0 -38
  142. package/dist/node/Api/PaymentCardToken/Request.d.cts.map +0 -1
  143. package/dist/node/Api/PaymentCardToken/Request.d.mts +0 -38
  144. package/dist/node/Api/PaymentCardToken/Request.d.mts.map +0 -1
  145. package/dist/node/Api/PaymentCardToken/Request.d.ts +0 -38
  146. package/dist/node/Api/PaymentCardToken/Request.d.ts.map +0 -1
  147. package/dist/node/Api/PaymentCardToken/Response.d.cts +0 -36
  148. package/dist/node/Api/PaymentCardToken/Response.d.cts.map +0 -1
  149. package/dist/node/Api/PaymentCardToken/Response.d.mts +0 -36
  150. package/dist/node/Api/PaymentCardToken/Response.d.mts.map +0 -1
  151. package/dist/node/Api/PaymentCardToken/Response.d.ts +0 -36
  152. package/dist/node/Api/PaymentCardToken/Response.d.ts.map +0 -1
  153. package/dist/node/Api/PaymentCardToken/index.d.cts +0 -3
  154. package/dist/node/Api/PaymentCardToken/index.d.cts.map +0 -1
  155. package/dist/node/Api/PaymentCardToken/index.d.mts +0 -3
  156. package/dist/node/Api/PaymentCardToken/index.d.mts.map +0 -1
  157. package/dist/node/Api/PaymentCardToken/index.d.ts +0 -3
  158. package/dist/node/Api/PaymentCardToken/index.d.ts.map +0 -1
  159. package/dist/node/Api/index.d.cts +0 -2
  160. package/dist/node/Api/index.d.cts.map +0 -1
  161. package/dist/node/Api/index.d.mts +0 -2
  162. package/dist/node/Api/index.d.mts.map +0 -1
  163. package/dist/node/Api/index.d.ts +0 -2
  164. package/dist/node/Api/index.d.ts.map +0 -1
  165. package/dist/node/Config.d.cts +0 -8
  166. package/dist/node/Config.d.cts.map +0 -1
  167. package/dist/node/Config.d.mts +0 -8
  168. package/dist/node/Config.d.mts.map +0 -1
  169. package/dist/node/Config.d.ts +0 -8
  170. package/dist/node/Config.d.ts.map +0 -1
  171. package/dist/node/Params.d.cts +0 -7
  172. package/dist/node/Params.d.cts.map +0 -1
  173. package/dist/node/Params.d.mts +0 -7
  174. package/dist/node/Params.d.mts.map +0 -1
  175. package/dist/node/Params.d.ts +0 -7
  176. package/dist/node/Params.d.ts.map +0 -1
  177. package/dist/node/Schema.d.cts +0 -3
  178. package/dist/node/Schema.d.cts.map +0 -1
  179. package/dist/node/Schema.d.mts +0 -3
  180. package/dist/node/Schema.d.mts.map +0 -1
  181. package/dist/node/Schema.d.ts +0 -3
  182. package/dist/node/Schema.d.ts.map +0 -1
  183. package/dist/node/Sentinel.d.cts +0 -24
  184. package/dist/node/Sentinel.d.cts.map +0 -1
  185. package/dist/node/Sentinel.d.mts +0 -24
  186. package/dist/node/Sentinel.d.mts.map +0 -1
  187. package/dist/node/Sentinel.d.ts +0 -24
  188. package/dist/node/Sentinel.d.ts.map +0 -1
  189. package/dist/node/index.cjs +0 -152
  190. package/dist/node/index.cjs.map +0 -1
  191. package/dist/node/index.d.cts +0 -5
  192. package/dist/node/index.d.cts.map +0 -1
  193. package/dist/node/index.d.mts +0 -5
  194. package/dist/node/index.d.mts.map +0 -1
  195. package/dist/node/index.d.ts +0 -5
  196. package/dist/node/index.d.ts.map +0 -1
  197. package/dist/node/index.mjs +0 -123
  198. package/dist/node/index.mjs.map +0 -1
  199. package/dist/node/util/index.d.cts +0 -2
  200. package/dist/node/util/index.d.cts.map +0 -1
  201. package/dist/node/util/index.d.mts +0 -2
  202. package/dist/node/util/index.d.mts.map +0 -1
  203. package/dist/node/util/index.d.ts +0 -2
  204. package/dist/node/util/index.d.ts.map +0 -1
  205. package/dist/node/util/toTokenRequest.d.cts +0 -4
  206. package/dist/node/util/toTokenRequest.d.cts.map +0 -1
  207. package/dist/node/util/toTokenRequest.d.mts +0 -4
  208. package/dist/node/util/toTokenRequest.d.mts.map +0 -1
  209. package/dist/node/util/toTokenRequest.d.ts +0 -4
  210. package/dist/node/util/toTokenRequest.d.ts.map +0 -1
@@ -1,152 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- RebillyPaymentCardAuthorizationSentinel: () => RebillyPaymentCardAuthorizationSentinel,
24
- RebillyPaymentCardAuthorizationSentinelConfigSchema: () => RebillyPaymentCardAuthorizationSentinelConfigSchema,
25
- RebillyPaymentCardAuthorizationSentinelSchema: () => RebillyPaymentCardAuthorizationSentinelSchema
26
- });
27
- module.exports = __toCommonJS(src_exports);
28
-
29
- // src/Schema.ts
30
- var RebillyPaymentCardAuthorizationSentinelSchema = "network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly";
31
-
32
- // src/Config.ts
33
- var RebillyPaymentCardAuthorizationSentinelConfigSchema = `${RebillyPaymentCardAuthorizationSentinelSchema}.config`;
34
-
35
- // src/Sentinel.ts
36
- var import_assert = require("@xylabs/assert");
37
- var import_axios = require("@xylabs/axios");
38
- var import_payload_builder = require("@xyo-network/payload-builder");
39
- var import_payment_payload_plugins = require("@xyo-network/payment-payload-plugins");
40
- var import_rebilly_payment_payload_plugin = require("@xyo-network/rebilly-payment-payload-plugin");
41
- var import_sentinel_abstract = require("@xyo-network/sentinel-abstract");
42
- var import_axios2 = require("axios");
43
-
44
- // src/util/toTokenRequest.ts
45
- var toTokenRequest = (paymentCard, billingAddress) => {
46
- const { cvv, expMonth, expYear, cardNumber } = paymentCard;
47
- const { schema: _, ...fields } = billingAddress;
48
- return {
49
- billingAddress: { ...fields },
50
- method: "payment-card",
51
- paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber }
52
- };
53
- };
54
-
55
- // src/Sentinel.ts
56
- var removePrefix = (str, prefix) => {
57
- const regex = new RegExp(`^${prefix}`);
58
- return str.replace(regex, "");
59
- };
60
- var moduleName = "RebillyPaymentCardAuthorizationSentinel";
61
- var RebillyPaymentCardAuthorizationSentinel = class extends import_sentinel_abstract.AbstractSentinel {
62
- static configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema];
63
- static defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema;
64
- _apiRoot = void 0;
65
- _domain = void 0;
66
- _headers = void 0;
67
- _organizationId = void 0;
68
- _publishableApiKey = void 0;
69
- _tokenEndpoint = void 0;
70
- /**
71
- * The Rebilly Organization API root endpoint
72
- */
73
- get apiRoot() {
74
- if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`;
75
- return this._apiRoot;
76
- }
77
- /**
78
- * The Rebilly domain
79
- */
80
- get domain() {
81
- if (!this._domain) this._domain = (0, import_assert.assertEx)(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`);
82
- return this._domain;
83
- }
84
- /**
85
- * The headers to be included in the request for each request
86
- */
87
- get headers() {
88
- if (!this._headers) this._headers = { Authorization: this.publishableApiKey };
89
- return this._headers;
90
- }
91
- /**
92
- * True if the environment is sandbox (testing), false otherwise
93
- */
94
- get isSandboxEnvironment() {
95
- return this.domain.includes("sandbox");
96
- }
97
- /**
98
- * The Rebilly organization ID
99
- */
100
- get organizationId() {
101
- if (!this._organizationId)
102
- this._organizationId = removePrefix(
103
- (0, import_assert.assertEx)(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),
104
- "org_"
105
- );
106
- return this._organizationId;
107
- }
108
- /**
109
- * The Rebilly Publishable API key
110
- */
111
- get publishableApiKey() {
112
- if (!this._publishableApiKey)
113
- this._publishableApiKey = (0, import_assert.assertEx)(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
114
- return this._publishableApiKey;
115
- }
116
- /**
117
- * The Rebilly Organization token creation endpoint
118
- */
119
- get tokenEndpoint() {
120
- if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`;
121
- return this._tokenEndpoint;
122
- }
123
- async reportHandler(payloads) {
124
- var _a, _b;
125
- await this.started("throw");
126
- const results = [];
127
- if (!payloads || payloads.length === 0) return results;
128
- const paymentCard = payloads == null ? void 0 : payloads.find(import_payment_payload_plugins.isPaymentCard);
129
- if (!paymentCard) return results;
130
- const billingAddress = payloads == null ? void 0 : payloads.find(import_payment_payload_plugins.isBillingAddress);
131
- if (!billingAddress) return results;
132
- const axios = new import_axios.AxiosJson({ headers: this.headers });
133
- try {
134
- const data = toTokenRequest(paymentCard, billingAddress);
135
- const response = await axios.post(this.tokenEndpoint, data);
136
- (0, import_assert.assertEx)(response.status === import_axios2.HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`);
137
- const { id } = response.data;
138
- const sources = await import_payload_builder.PayloadBuilder.dataHashes([paymentCard, billingAddress]);
139
- results.push({ id, schema: import_rebilly_payment_payload_plugin.RebillyPaymentAuthorizationTokenSchema, sources });
140
- } catch (error) {
141
- (_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `${moduleName}: Error creating payment token: ${error}`);
142
- }
143
- return results;
144
- }
145
- };
146
- // Annotate the CommonJS export names for ESM import in node:
147
- 0 && (module.exports = {
148
- RebillyPaymentCardAuthorizationSentinel,
149
- RebillyPaymentCardAuthorizationSentinelConfigSchema,
150
- RebillyPaymentCardAuthorizationSentinelSchema
151
- });
152
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Schema.ts","../../src/Config.ts","../../src/Sentinel.ts","../../src/util/toTokenRequest.ts"],"sourcesContent":["export * from './Config.ts'\nexport * from './Params.ts'\nexport * from './Schema.ts'\nexport * from './Sentinel.ts'\n","export const RebillyPaymentCardAuthorizationSentinelSchema = 'network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly'\nexport type RebillyPaymentCardAuthorizationSentinelSchema = typeof RebillyPaymentCardAuthorizationSentinelSchema\n","import { RebillyApiDomainSettings } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { SentinelConfig } from '@xyo-network/sentinel-model'\n\nimport { RebillyPaymentCardAuthorizationSentinelSchema } from './Schema.ts'\n\nexport const RebillyPaymentCardAuthorizationSentinelConfigSchema = `${RebillyPaymentCardAuthorizationSentinelSchema}.config`\nexport type RebillyPaymentCardAuthorizationSentinelConfigSchema = typeof RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n/*\n * The Rebilly Payment Card Authorization Sentinel Config\n */\nexport type RebillyPaymentCardAuthorizationSentinelConfig = SentinelConfig<{\n /**\n * The config schema\n */\n schema: RebillyPaymentCardAuthorizationSentinelConfigSchema\n}> &\nPartial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson } from '@xylabs/axios'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, WithSources } from '@xyo-network/payload-model'\nimport { isBillingAddress, isPaymentCard } from '@xyo-network/payment-payload-plugins'\nimport { RebillyPaymentAuthorizationToken, RebillyPaymentAuthorizationTokenSchema } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { AbstractSentinel } from '@xyo-network/sentinel-abstract'\nimport { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model'\nimport { AxiosRequestConfig, HttpStatusCode } from 'axios'\n\nimport { CreateTokenResponse } from './Api/index.ts'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config.ts'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts'\nimport { toTokenRequest } from './util/index.ts'\n\nconst removePrefix = (str: string, prefix: string) => {\n const regex = new RegExp(`^${prefix}`)\n return str.replace(regex, '')\n}\n\nconst moduleName = 'RebillyPaymentCardAuthorizationSentinel'\nexport class RebillyPaymentCardAuthorizationSentinel<\n TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams,\n TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>,\n> extends AbstractSentinel<TParams, TEventData> {\n static override configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema]\n static override defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n protected _apiRoot: string | undefined = undefined\n protected _domain: string | undefined = undefined\n protected _headers: AxiosRequestConfig['headers'] | undefined = undefined\n protected _organizationId: string | undefined = undefined\n protected _publishableApiKey: string | undefined = undefined\n protected _tokenEndpoint: string | undefined = undefined\n\n /**\n * The Rebilly Organization API root endpoint\n */\n protected get apiRoot() {\n if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`\n return this._apiRoot\n }\n\n /**\n * The Rebilly domain\n */\n protected get domain() {\n if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`)\n return this._domain\n }\n\n /**\n * The headers to be included in the request for each request\n */\n protected get headers(): AxiosRequestConfig['headers'] {\n if (!this._headers) this._headers = { Authorization: this.publishableApiKey }\n return this._headers\n }\n\n /**\n * True if the environment is sandbox (testing), false otherwise\n */\n protected get isSandboxEnvironment(): boolean {\n return this.domain.includes('sandbox')\n }\n\n /**\n * The Rebilly organization ID\n */\n protected get organizationId() {\n if (!this._organizationId)\n this._organizationId = removePrefix(\n assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),\n 'org_',\n )\n return this._organizationId\n }\n\n /**\n * The Rebilly Publishable API key\n */\n protected get publishableApiKey(): string {\n if (!this._publishableApiKey)\n this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`)\n return this._publishableApiKey\n }\n\n /**\n * The Rebilly Organization token creation endpoint\n */\n protected get tokenEndpoint() {\n if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`\n return this._tokenEndpoint\n }\n\n override async reportHandler(payloads?: Payload[]): Promise<Payload[]> {\n await this.started('throw')\n const results: WithSources<RebillyPaymentAuthorizationToken>[] = []\n // Verify necessary inputs and if nothing meets our criteria, bail early\n if (!payloads || payloads.length === 0) return results\n const paymentCard = payloads?.find(isPaymentCard)\n if (!paymentCard) return results\n const billingAddress = payloads?.find(isBillingAddress)\n if (!billingAddress) return results\n const axios = new AxiosJson({ headers: this.headers })\n try {\n const data = toTokenRequest(paymentCard, billingAddress)\n const response = await axios.post<CreateTokenResponse>(this.tokenEndpoint, data)\n assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`)\n const { id } = response.data\n const sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress])\n results.push({ id, schema: RebillyPaymentAuthorizationTokenSchema, sources })\n } catch (error) {\n this.logger?.error?.(`${moduleName}: Error creating payment token: ${error}`)\n }\n return results\n }\n}\n","import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'\n\nimport { CreatePaymentTokenRequest } from '../Api/index.ts'\n\n/**\n * Converts a payment card and billing address to a token request\n * @param paymentCard The payment card\n * @param billingAddress The billing address\n * @returns The token request\n */\nexport const toTokenRequest = (paymentCard: PaymentCard, billingAddress: BillingAddress): CreatePaymentTokenRequest => {\n const { cvv, expMonth, expYear, cardNumber } = paymentCard\n // NOTE: We are destructuring all but the schema and passing it along to the billingAddress. This\n // is to allow for missing fields to be omitted rather than set to undefined and for any new fields\n // that might be added later to be automatically picked up on. It is fine to pass this along since\n // the user is supplying this data about themselves.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { schema: _, ...fields } = billingAddress\n return {\n billingAddress: { ...fields },\n method: 'payment-card',\n paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber },\n }\n}\n"],"mappings":"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","names":["import_axios"]}
@@ -1,5 +0,0 @@
1
- export * from './Config.ts';
2
- export * from './Params.ts';
3
- export * from './Schema.ts';
4
- export * from './Sentinel.ts';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
@@ -1,5 +0,0 @@
1
- export * from './Config.ts';
2
- export * from './Params.ts';
3
- export * from './Schema.ts';
4
- export * from './Sentinel.ts';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
@@ -1,5 +0,0 @@
1
- export * from './Config.ts';
2
- export * from './Params.ts';
3
- export * from './Schema.ts';
4
- export * from './Sentinel.ts';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
@@ -1,123 +0,0 @@
1
- // src/Schema.ts
2
- var RebillyPaymentCardAuthorizationSentinelSchema = "network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly";
3
-
4
- // src/Config.ts
5
- var RebillyPaymentCardAuthorizationSentinelConfigSchema = `${RebillyPaymentCardAuthorizationSentinelSchema}.config`;
6
-
7
- // src/Sentinel.ts
8
- import { assertEx } from "@xylabs/assert";
9
- import { AxiosJson } from "@xylabs/axios";
10
- import { PayloadBuilder } from "@xyo-network/payload-builder";
11
- import { isBillingAddress, isPaymentCard } from "@xyo-network/payment-payload-plugins";
12
- import { RebillyPaymentAuthorizationTokenSchema } from "@xyo-network/rebilly-payment-payload-plugin";
13
- import { AbstractSentinel } from "@xyo-network/sentinel-abstract";
14
- import { HttpStatusCode } from "axios";
15
-
16
- // src/util/toTokenRequest.ts
17
- var toTokenRequest = (paymentCard, billingAddress) => {
18
- const { cvv, expMonth, expYear, cardNumber } = paymentCard;
19
- const { schema: _, ...fields } = billingAddress;
20
- return {
21
- billingAddress: { ...fields },
22
- method: "payment-card",
23
- paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber }
24
- };
25
- };
26
-
27
- // src/Sentinel.ts
28
- var removePrefix = (str, prefix) => {
29
- const regex = new RegExp(`^${prefix}`);
30
- return str.replace(regex, "");
31
- };
32
- var moduleName = "RebillyPaymentCardAuthorizationSentinel";
33
- var RebillyPaymentCardAuthorizationSentinel = class extends AbstractSentinel {
34
- static configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema];
35
- static defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema;
36
- _apiRoot = void 0;
37
- _domain = void 0;
38
- _headers = void 0;
39
- _organizationId = void 0;
40
- _publishableApiKey = void 0;
41
- _tokenEndpoint = void 0;
42
- /**
43
- * The Rebilly Organization API root endpoint
44
- */
45
- get apiRoot() {
46
- if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`;
47
- return this._apiRoot;
48
- }
49
- /**
50
- * The Rebilly domain
51
- */
52
- get domain() {
53
- if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`);
54
- return this._domain;
55
- }
56
- /**
57
- * The headers to be included in the request for each request
58
- */
59
- get headers() {
60
- if (!this._headers) this._headers = { Authorization: this.publishableApiKey };
61
- return this._headers;
62
- }
63
- /**
64
- * True if the environment is sandbox (testing), false otherwise
65
- */
66
- get isSandboxEnvironment() {
67
- return this.domain.includes("sandbox");
68
- }
69
- /**
70
- * The Rebilly organization ID
71
- */
72
- get organizationId() {
73
- if (!this._organizationId)
74
- this._organizationId = removePrefix(
75
- assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),
76
- "org_"
77
- );
78
- return this._organizationId;
79
- }
80
- /**
81
- * The Rebilly Publishable API key
82
- */
83
- get publishableApiKey() {
84
- if (!this._publishableApiKey)
85
- this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
86
- return this._publishableApiKey;
87
- }
88
- /**
89
- * The Rebilly Organization token creation endpoint
90
- */
91
- get tokenEndpoint() {
92
- if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`;
93
- return this._tokenEndpoint;
94
- }
95
- async reportHandler(payloads) {
96
- var _a, _b;
97
- await this.started("throw");
98
- const results = [];
99
- if (!payloads || payloads.length === 0) return results;
100
- const paymentCard = payloads == null ? void 0 : payloads.find(isPaymentCard);
101
- if (!paymentCard) return results;
102
- const billingAddress = payloads == null ? void 0 : payloads.find(isBillingAddress);
103
- if (!billingAddress) return results;
104
- const axios = new AxiosJson({ headers: this.headers });
105
- try {
106
- const data = toTokenRequest(paymentCard, billingAddress);
107
- const response = await axios.post(this.tokenEndpoint, data);
108
- assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`);
109
- const { id } = response.data;
110
- const sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress]);
111
- results.push({ id, schema: RebillyPaymentAuthorizationTokenSchema, sources });
112
- } catch (error) {
113
- (_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `${moduleName}: Error creating payment token: ${error}`);
114
- }
115
- return results;
116
- }
117
- };
118
- export {
119
- RebillyPaymentCardAuthorizationSentinel,
120
- RebillyPaymentCardAuthorizationSentinelConfigSchema,
121
- RebillyPaymentCardAuthorizationSentinelSchema
122
- };
123
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/Schema.ts","../../src/Config.ts","../../src/Sentinel.ts","../../src/util/toTokenRequest.ts"],"sourcesContent":["export const RebillyPaymentCardAuthorizationSentinelSchema = 'network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly'\nexport type RebillyPaymentCardAuthorizationSentinelSchema = typeof RebillyPaymentCardAuthorizationSentinelSchema\n","import { RebillyApiDomainSettings } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { SentinelConfig } from '@xyo-network/sentinel-model'\n\nimport { RebillyPaymentCardAuthorizationSentinelSchema } from './Schema.ts'\n\nexport const RebillyPaymentCardAuthorizationSentinelConfigSchema = `${RebillyPaymentCardAuthorizationSentinelSchema}.config`\nexport type RebillyPaymentCardAuthorizationSentinelConfigSchema = typeof RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n/*\n * The Rebilly Payment Card Authorization Sentinel Config\n */\nexport type RebillyPaymentCardAuthorizationSentinelConfig = SentinelConfig<{\n /**\n * The config schema\n */\n schema: RebillyPaymentCardAuthorizationSentinelConfigSchema\n}> &\nPartial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson } from '@xylabs/axios'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport { Payload, WithSources } from '@xyo-network/payload-model'\nimport { isBillingAddress, isPaymentCard } from '@xyo-network/payment-payload-plugins'\nimport { RebillyPaymentAuthorizationToken, RebillyPaymentAuthorizationTokenSchema } from '@xyo-network/rebilly-payment-payload-plugin'\nimport { AbstractSentinel } from '@xyo-network/sentinel-abstract'\nimport { SentinelInstance, SentinelModuleEventData } from '@xyo-network/sentinel-model'\nimport { AxiosRequestConfig, HttpStatusCode } from 'axios'\n\nimport { CreateTokenResponse } from './Api/index.ts'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config.ts'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params.ts'\nimport { toTokenRequest } from './util/index.ts'\n\nconst removePrefix = (str: string, prefix: string) => {\n const regex = new RegExp(`^${prefix}`)\n return str.replace(regex, '')\n}\n\nconst moduleName = 'RebillyPaymentCardAuthorizationSentinel'\nexport class RebillyPaymentCardAuthorizationSentinel<\n TParams extends RebillyPaymentCardAuthorizationSentinelParams = RebillyPaymentCardAuthorizationSentinelParams,\n TEventData extends SentinelModuleEventData<SentinelInstance<TParams>> = SentinelModuleEventData<SentinelInstance<TParams>>,\n> extends AbstractSentinel<TParams, TEventData> {\n static override configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema]\n static override defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema\n\n protected _apiRoot: string | undefined = undefined\n protected _domain: string | undefined = undefined\n protected _headers: AxiosRequestConfig['headers'] | undefined = undefined\n protected _organizationId: string | undefined = undefined\n protected _publishableApiKey: string | undefined = undefined\n protected _tokenEndpoint: string | undefined = undefined\n\n /**\n * The Rebilly Organization API root endpoint\n */\n protected get apiRoot() {\n if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`\n return this._apiRoot\n }\n\n /**\n * The Rebilly domain\n */\n protected get domain() {\n if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`)\n return this._domain\n }\n\n /**\n * The headers to be included in the request for each request\n */\n protected get headers(): AxiosRequestConfig['headers'] {\n if (!this._headers) this._headers = { Authorization: this.publishableApiKey }\n return this._headers\n }\n\n /**\n * True if the environment is sandbox (testing), false otherwise\n */\n protected get isSandboxEnvironment(): boolean {\n return this.domain.includes('sandbox')\n }\n\n /**\n * The Rebilly organization ID\n */\n protected get organizationId() {\n if (!this._organizationId)\n this._organizationId = removePrefix(\n assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),\n 'org_',\n )\n return this._organizationId\n }\n\n /**\n * The Rebilly Publishable API key\n */\n protected get publishableApiKey(): string {\n if (!this._publishableApiKey)\n this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`)\n return this._publishableApiKey\n }\n\n /**\n * The Rebilly Organization token creation endpoint\n */\n protected get tokenEndpoint() {\n if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`\n return this._tokenEndpoint\n }\n\n override async reportHandler(payloads?: Payload[]): Promise<Payload[]> {\n await this.started('throw')\n const results: WithSources<RebillyPaymentAuthorizationToken>[] = []\n // Verify necessary inputs and if nothing meets our criteria, bail early\n if (!payloads || payloads.length === 0) return results\n const paymentCard = payloads?.find(isPaymentCard)\n if (!paymentCard) return results\n const billingAddress = payloads?.find(isBillingAddress)\n if (!billingAddress) return results\n const axios = new AxiosJson({ headers: this.headers })\n try {\n const data = toTokenRequest(paymentCard, billingAddress)\n const response = await axios.post<CreateTokenResponse>(this.tokenEndpoint, data)\n assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`)\n const { id } = response.data\n const sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress])\n results.push({ id, schema: RebillyPaymentAuthorizationTokenSchema, sources })\n } catch (error) {\n this.logger?.error?.(`${moduleName}: Error creating payment token: ${error}`)\n }\n return results\n }\n}\n","import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins'\n\nimport { CreatePaymentTokenRequest } from '../Api/index.ts'\n\n/**\n * Converts a payment card and billing address to a token request\n * @param paymentCard The payment card\n * @param billingAddress The billing address\n * @returns The token request\n */\nexport const toTokenRequest = (paymentCard: PaymentCard, billingAddress: BillingAddress): CreatePaymentTokenRequest => {\n const { cvv, expMonth, expYear, cardNumber } = paymentCard\n // NOTE: We are destructuring all but the schema and passing it along to the billingAddress. This\n // is to allow for missing fields to be omitted rather than set to undefined and for any new fields\n // that might be added later to be automatically picked up on. It is fine to pass this along since\n // the user is supplying this data about themselves.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { schema: _, ...fields } = billingAddress\n return {\n billingAddress: { ...fields },\n method: 'payment-card',\n paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber },\n }\n}\n"],"mappings":";AAAO,IAAM,gDAAgD;;;ACKtD,IAAM,sDAAsD,GAAG,6CAA6C;;;ACLnH,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAE/B,SAAS,kBAAkB,qBAAqB;AAChD,SAA2C,8CAA8C;AACzF,SAAS,wBAAwB;AAEjC,SAA6B,sBAAsB;;;ACE5C,IAAM,iBAAiB,CAAC,aAA0B,mBAA8D;AACrH,QAAM,EAAE,KAAK,UAAU,SAAS,WAAW,IAAI;AAM/C,QAAM,EAAE,QAAQ,GAAG,GAAG,OAAO,IAAI;AACjC,SAAO;AAAA,IACL,gBAAgB,EAAE,GAAG,OAAO;AAAA,IAC5B,QAAQ;AAAA,IACR,mBAAmB,EAAE,KAAK,UAAU,SAAS,KAAK,WAAW;AAAA,EAC/D;AACF;;;ADRA,IAAM,eAAe,CAAC,KAAa,WAAmB;AACpD,QAAM,QAAQ,IAAI,OAAO,IAAI,MAAM,EAAE;AACrC,SAAO,IAAI,QAAQ,OAAO,EAAE;AAC9B;AAEA,IAAM,aAAa;AACZ,IAAM,0CAAN,cAGG,iBAAsC;AAAA,EAC9C,OAAgB,gBAAgB,CAAC,mDAAmD;AAAA,EACpF,OAAgB,sBAAsB;AAAA,EAE5B,WAA+B;AAAA,EAC/B,UAA8B;AAAA,EAC9B,WAAsD;AAAA,EACtD,kBAAsC;AAAA,EACtC,qBAAyC;AAAA,EACzC,iBAAqC;AAAA;AAAA;AAAA;AAAA,EAK/C,IAAc,UAAU;AACtB,QAAI,CAAC,KAAK,SAAU,MAAK,WAAW,GAAG,KAAK,MAAM,kBAAkB,KAAK,cAAc;AACvF,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAc,SAAS;AACrB,QAAI,CAAC,KAAK,QAAS,MAAK,UAAU,SAAS,KAAK,OAAO,UAAU,KAAK,OAAO,QAAQ,MAAM,GAAG,UAAU,mCAAmC;AAC3I,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAc,UAAyC;AACrD,QAAI,CAAC,KAAK,SAAU,MAAK,WAAW,EAAE,eAAe,KAAK,kBAAkB;AAC5E,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAc,uBAAgC;AAC5C,WAAO,KAAK,OAAO,SAAS,SAAS;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,IAAc,iBAAiB;AAC7B,QAAI,CAAC,KAAK;AACR,WAAK,kBAAkB;AAAA,QACrB,SAAS,KAAK,OAAO,gBAAgB,MAAM,GAAG,UAAU,oCAAoC;AAAA,QAC5F;AAAA,MACF;AACF,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAc,oBAA4B;AACxC,QAAI,CAAC,KAAK;AACR,WAAK,qBAAqB,SAAS,KAAK,OAAO,mBAAmB,MAAM,GAAG,UAAU,uCAAuC;AAC9H,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,IAAc,gBAAgB;AAC5B,QAAI,CAAC,KAAK,eAAgB,MAAK,iBAAiB,GAAG,KAAK,OAAO;AAC/D,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAe,cAAc,UAA0C;AA/FzE;AAgGI,UAAM,KAAK,QAAQ,OAAO;AAC1B,UAAM,UAA2D,CAAC;AAElE,QAAI,CAAC,YAAY,SAAS,WAAW,EAAG,QAAO;AAC/C,UAAM,cAAc,qCAAU,KAAK;AACnC,QAAI,CAAC,YAAa,QAAO;AACzB,UAAM,iBAAiB,qCAAU,KAAK;AACtC,QAAI,CAAC,eAAgB,QAAO;AAC5B,UAAM,QAAQ,IAAI,UAAU,EAAE,SAAS,KAAK,QAAQ,CAAC;AACrD,QAAI;AACF,YAAM,OAAO,eAAe,aAAa,cAAc;AACvD,YAAM,WAAW,MAAM,MAAM,KAA0B,KAAK,eAAe,IAAI;AAC/E,eAAS,SAAS,WAAW,eAAe,SAAS,MAAM,oCAAoC,SAAS,MAAM,EAAE;AAChH,YAAM,EAAE,GAAG,IAAI,SAAS;AACxB,YAAM,UAAU,MAAM,eAAe,WAAW,CAAC,aAAa,cAAc,CAAC;AAC7E,cAAQ,KAAK,EAAE,IAAI,QAAQ,wCAAwC,QAAQ,CAAC;AAAA,IAC9E,SAAS,OAAO;AACd,uBAAK,WAAL,mBAAa,UAAb,4BAAqB,GAAG,UAAU,mCAAmC,KAAK;AAAA,IAC5E;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1,2 +0,0 @@
1
- export * from './toTokenRequest.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './toTokenRequest.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './toTokenRequest.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -1,4 +0,0 @@
1
- import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
2
- import { CreatePaymentTokenRequest } from '../Api/index.ts';
3
- export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
4
- //# sourceMappingURL=toTokenRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toTokenRequest.d.ts","sourceRoot":"","sources":["../../../src/util/toTokenRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAElF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAQ3D,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}
@@ -1,4 +0,0 @@
1
- import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
2
- import { CreatePaymentTokenRequest } from '../Api/index.ts';
3
- export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
4
- //# sourceMappingURL=toTokenRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toTokenRequest.d.ts","sourceRoot":"","sources":["../../../src/util/toTokenRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAElF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAQ3D,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}
@@ -1,4 +0,0 @@
1
- import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
2
- import { CreatePaymentTokenRequest } from '../Api/index.ts';
3
- export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
4
- //# sourceMappingURL=toTokenRequest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toTokenRequest.d.ts","sourceRoot":"","sources":["../../../src/util/toTokenRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAA;AAElF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAA;AAQ3D,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}