@xyo-network/rebilly-payment-card-authorization-plugin 2.96.0 → 2.96.2

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 (103) hide show
  1. package/dist/browser/Api/PaymentCardToken/Request.d.cts +0 -50
  2. package/dist/browser/Api/PaymentCardToken/Request.d.cts.map +1 -1
  3. package/dist/browser/Api/PaymentCardToken/Request.d.mts +0 -50
  4. package/dist/browser/Api/PaymentCardToken/Request.d.mts.map +1 -1
  5. package/dist/browser/Api/PaymentCardToken/Request.d.ts +0 -50
  6. package/dist/browser/Api/PaymentCardToken/Request.d.ts.map +1 -1
  7. package/dist/browser/Api/PaymentCardToken/Response.d.cts +0 -34
  8. package/dist/browser/Api/PaymentCardToken/Response.d.cts.map +1 -1
  9. package/dist/browser/Api/PaymentCardToken/Response.d.mts +0 -34
  10. package/dist/browser/Api/PaymentCardToken/Response.d.mts.map +1 -1
  11. package/dist/browser/Api/PaymentCardToken/Response.d.ts +0 -34
  12. package/dist/browser/Api/PaymentCardToken/Response.d.ts.map +1 -1
  13. package/dist/browser/Config.d.cts +0 -3
  14. package/dist/browser/Config.d.cts.map +1 -1
  15. package/dist/browser/Config.d.mts +0 -3
  16. package/dist/browser/Config.d.mts.map +1 -1
  17. package/dist/browser/Config.d.ts +0 -3
  18. package/dist/browser/Config.d.ts.map +1 -1
  19. package/dist/browser/Sentinel.d.cts +0 -21
  20. package/dist/browser/Sentinel.d.cts.map +1 -1
  21. package/dist/browser/Sentinel.d.mts +0 -21
  22. package/dist/browser/Sentinel.d.mts.map +1 -1
  23. package/dist/browser/Sentinel.d.ts +0 -21
  24. package/dist/browser/Sentinel.d.ts.map +1 -1
  25. package/dist/browser/index.cjs +1 -143
  26. package/dist/browser/index.cjs.map +1 -1
  27. package/dist/browser/index.js +1 -120
  28. package/dist/browser/index.js.map +1 -1
  29. package/dist/browser/util/toTokenRequest.d.cts +0 -6
  30. package/dist/browser/util/toTokenRequest.d.cts.map +1 -1
  31. package/dist/browser/util/toTokenRequest.d.mts +0 -6
  32. package/dist/browser/util/toTokenRequest.d.mts.map +1 -1
  33. package/dist/browser/util/toTokenRequest.d.ts +0 -6
  34. package/dist/browser/util/toTokenRequest.d.ts.map +1 -1
  35. package/dist/neutral/Api/PaymentCardToken/Request.d.cts +0 -50
  36. package/dist/neutral/Api/PaymentCardToken/Request.d.cts.map +1 -1
  37. package/dist/neutral/Api/PaymentCardToken/Request.d.mts +0 -50
  38. package/dist/neutral/Api/PaymentCardToken/Request.d.mts.map +1 -1
  39. package/dist/neutral/Api/PaymentCardToken/Request.d.ts +0 -50
  40. package/dist/neutral/Api/PaymentCardToken/Request.d.ts.map +1 -1
  41. package/dist/neutral/Api/PaymentCardToken/Response.d.cts +0 -34
  42. package/dist/neutral/Api/PaymentCardToken/Response.d.cts.map +1 -1
  43. package/dist/neutral/Api/PaymentCardToken/Response.d.mts +0 -34
  44. package/dist/neutral/Api/PaymentCardToken/Response.d.mts.map +1 -1
  45. package/dist/neutral/Api/PaymentCardToken/Response.d.ts +0 -34
  46. package/dist/neutral/Api/PaymentCardToken/Response.d.ts.map +1 -1
  47. package/dist/neutral/Config.d.cts +0 -3
  48. package/dist/neutral/Config.d.cts.map +1 -1
  49. package/dist/neutral/Config.d.mts +0 -3
  50. package/dist/neutral/Config.d.mts.map +1 -1
  51. package/dist/neutral/Config.d.ts +0 -3
  52. package/dist/neutral/Config.d.ts.map +1 -1
  53. package/dist/neutral/Sentinel.d.cts +0 -21
  54. package/dist/neutral/Sentinel.d.cts.map +1 -1
  55. package/dist/neutral/Sentinel.d.mts +0 -21
  56. package/dist/neutral/Sentinel.d.mts.map +1 -1
  57. package/dist/neutral/Sentinel.d.ts +0 -21
  58. package/dist/neutral/Sentinel.d.ts.map +1 -1
  59. package/dist/neutral/index.cjs +1 -143
  60. package/dist/neutral/index.cjs.map +1 -1
  61. package/dist/neutral/index.js +1 -120
  62. package/dist/neutral/index.js.map +1 -1
  63. package/dist/neutral/util/toTokenRequest.d.cts +0 -6
  64. package/dist/neutral/util/toTokenRequest.d.cts.map +1 -1
  65. package/dist/neutral/util/toTokenRequest.d.mts +0 -6
  66. package/dist/neutral/util/toTokenRequest.d.mts.map +1 -1
  67. package/dist/neutral/util/toTokenRequest.d.ts +0 -6
  68. package/dist/neutral/util/toTokenRequest.d.ts.map +1 -1
  69. package/dist/node/Api/PaymentCardToken/Request.d.cts +0 -50
  70. package/dist/node/Api/PaymentCardToken/Request.d.cts.map +1 -1
  71. package/dist/node/Api/PaymentCardToken/Request.d.mts +0 -50
  72. package/dist/node/Api/PaymentCardToken/Request.d.mts.map +1 -1
  73. package/dist/node/Api/PaymentCardToken/Request.d.ts +0 -50
  74. package/dist/node/Api/PaymentCardToken/Request.d.ts.map +1 -1
  75. package/dist/node/Api/PaymentCardToken/Response.d.cts +0 -34
  76. package/dist/node/Api/PaymentCardToken/Response.d.cts.map +1 -1
  77. package/dist/node/Api/PaymentCardToken/Response.d.mts +0 -34
  78. package/dist/node/Api/PaymentCardToken/Response.d.mts.map +1 -1
  79. package/dist/node/Api/PaymentCardToken/Response.d.ts +0 -34
  80. package/dist/node/Api/PaymentCardToken/Response.d.ts.map +1 -1
  81. package/dist/node/Config.d.cts +0 -3
  82. package/dist/node/Config.d.cts.map +1 -1
  83. package/dist/node/Config.d.mts +0 -3
  84. package/dist/node/Config.d.mts.map +1 -1
  85. package/dist/node/Config.d.ts +0 -3
  86. package/dist/node/Config.d.ts.map +1 -1
  87. package/dist/node/Sentinel.d.cts +0 -21
  88. package/dist/node/Sentinel.d.cts.map +1 -1
  89. package/dist/node/Sentinel.d.mts +0 -21
  90. package/dist/node/Sentinel.d.mts.map +1 -1
  91. package/dist/node/Sentinel.d.ts +0 -21
  92. package/dist/node/Sentinel.d.ts.map +1 -1
  93. package/dist/node/index.cjs +1 -150
  94. package/dist/node/index.cjs.map +1 -1
  95. package/dist/node/index.js +1 -121
  96. package/dist/node/index.js.map +1 -1
  97. package/dist/node/util/toTokenRequest.d.cts +0 -6
  98. package/dist/node/util/toTokenRequest.d.cts.map +1 -1
  99. package/dist/node/util/toTokenRequest.d.mts +0 -6
  100. package/dist/node/util/toTokenRequest.d.mts.map +1 -1
  101. package/dist/node/util/toTokenRequest.d.ts +0 -6
  102. package/dist/node/util/toTokenRequest.d.ts.map +1 -1
  103. package/package.json +12 -12
@@ -1,151 +1,2 @@
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
-
43
- // src/util/toTokenRequest.ts
44
- var toTokenRequest = (paymentCard, billingAddress) => {
45
- const { cvv, expMonth, expYear, cardNumber } = paymentCard;
46
- const { schema: _, ...fields } = billingAddress;
47
- return {
48
- billingAddress: { ...fields },
49
- method: "payment-card",
50
- paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber }
51
- };
52
- };
53
-
54
- // src/Sentinel.ts
55
- var removePrefix = (str, prefix) => {
56
- const regex = new RegExp(`^${prefix}`);
57
- return str.replace(regex, "");
58
- };
59
- var moduleName = "RebillyPaymentCardAuthorizationSentinel";
60
- var RebillyPaymentCardAuthorizationSentinel = class extends import_sentinel_abstract.AbstractSentinel {
61
- static configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema];
62
- static defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema;
63
- _apiRoot = void 0;
64
- _domain = void 0;
65
- _headers = void 0;
66
- _organizationId = void 0;
67
- _publishableApiKey = void 0;
68
- _tokenEndpoint = void 0;
69
- /**
70
- * The Rebilly Organization API root endpoint
71
- */
72
- get apiRoot() {
73
- if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`;
74
- return this._apiRoot;
75
- }
76
- /**
77
- * The Rebilly domain
78
- */
79
- get domain() {
80
- if (!this._domain) this._domain = (0, import_assert.assertEx)(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`);
81
- return this._domain;
82
- }
83
- /**
84
- * The headers to be included in the request for each request
85
- */
86
- get headers() {
87
- if (!this._headers) this._headers = { Authorization: this.publishableApiKey };
88
- return this._headers;
89
- }
90
- /**
91
- * True if the environment is sandbox (testing), false otherwise
92
- */
93
- get isSandboxEnvironment() {
94
- return this.domain.includes("sandbox");
95
- }
96
- /**
97
- * The Rebilly organization ID
98
- */
99
- get organizationId() {
100
- if (!this._organizationId)
101
- this._organizationId = removePrefix(
102
- (0, import_assert.assertEx)(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),
103
- "org_"
104
- );
105
- return this._organizationId;
106
- }
107
- /**
108
- * The Rebilly Publishable API key
109
- */
110
- get publishableApiKey() {
111
- if (!this._publishableApiKey)
112
- this._publishableApiKey = (0, import_assert.assertEx)(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
113
- return this._publishableApiKey;
114
- }
115
- /**
116
- * The Rebilly Organization token creation endpoint
117
- */
118
- get tokenEndpoint() {
119
- if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`;
120
- return this._tokenEndpoint;
121
- }
122
- async reportHandler(payloads) {
123
- var _a, _b;
124
- await this.started("throw");
125
- const results = [];
126
- if (!payloads || payloads.length === 0) return results;
127
- const paymentCard = payloads == null ? void 0 : payloads.find(import_payment_payload_plugins.isPaymentCard);
128
- if (!paymentCard) return results;
129
- const billingAddress = payloads == null ? void 0 : payloads.find(import_payment_payload_plugins.isBillingAddress);
130
- if (!billingAddress) return results;
131
- const axios = new import_axios.AxiosJson({ headers: this.headers });
132
- try {
133
- const data = toTokenRequest(paymentCard, billingAddress);
134
- const response = await axios.post(this.tokenEndpoint, data);
135
- (0, import_assert.assertEx)(response.status === import_axios.HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`);
136
- const { id } = response.data;
137
- const sources = await import_payload_builder.PayloadBuilder.dataHashes([paymentCard, billingAddress]);
138
- results.push({ id, schema: import_rebilly_payment_payload_plugin.RebillyPaymentAuthorizationTokenSchema, sources });
139
- } catch (error) {
140
- (_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `${moduleName}: Error creating payment token: ${error}`);
141
- }
142
- return results;
143
- }
144
- };
145
- // Annotate the CommonJS export names for ESM import in node:
146
- 0 && (module.exports = {
147
- RebillyPaymentCardAuthorizationSentinel,
148
- RebillyPaymentCardAuthorizationSentinelConfigSchema,
149
- RebillyPaymentCardAuthorizationSentinelSchema
150
- });
1
+ "use strict";var f=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var k=(i,e)=>{for(var t in e)f(i,t,{get:e[t],enumerable:!0})},E=(i,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of z(e))!_.call(i,n)&&n!==t&&f(i,n,{get:()=>e[n],enumerable:!(o=x(e,n))||o.enumerable});return i};var T=i=>E(f({},"__esModule",{value:!0}),i);var I={};k(I,{RebillyPaymentCardAuthorizationSentinel:()=>y,RebillyPaymentCardAuthorizationSentinelConfigSchema:()=>d,RebillyPaymentCardAuthorizationSentinelSchema:()=>g});module.exports=T(I);var g="network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly";var d=`${g}.config`;var a=require("@xylabs/assert"),l=require("@xylabs/axios"),S=require("@xyo-network/payload-builder"),h=require("@xyo-network/payment-payload-plugins"),A=require("@xyo-network/rebilly-payment-payload-plugin"),C=require("@xyo-network/sentinel-abstract");var b=(i,e)=>{let{cvv:t,expMonth:o,expYear:n,cardNumber:p}=i,{schema:r,...s}=e;return{billingAddress:{...s},method:"payment-card",paymentInstrument:{cvv:t,expMonth:o,expYear:n,pan:p}}};var v=(i,e)=>{let t=new RegExp(`^${e}`);return i.replace(t,"")},m="RebillyPaymentCardAuthorizationSentinel",y=class extends C.AbstractSentinel{static configSchemas=[d];static defaultConfigSchema=d;_apiRoot=void 0;_domain=void 0;_headers=void 0;_organizationId=void 0;_publishableApiKey=void 0;_tokenEndpoint=void 0;get apiRoot(){return this._apiRoot||(this._apiRoot=`${this.domain}/organizations/${this.organizationId}`),this._apiRoot}get domain(){return this._domain||(this._domain=(0,a.assertEx)(this.params.domain??this.config.domain,()=>`${m}: Missing domain in params/config`)),this._domain}get headers(){return this._headers||(this._headers={Authorization:this.publishableApiKey}),this._headers}get isSandboxEnvironment(){return this.domain.includes("sandbox")}get organizationId(){return this._organizationId||(this._organizationId=v((0,a.assertEx)(this.params.organizationId,()=>`${m}: Missing organizationId in params`),"org_")),this._organizationId}get publishableApiKey(){return this._publishableApiKey||(this._publishableApiKey=(0,a.assertEx)(this.params.publishableApiKey,()=>`${m}: Missing publishableApiKey in params`)),this._publishableApiKey}get tokenEndpoint(){return this._tokenEndpoint||(this._tokenEndpoint=`${this.apiRoot}/tokens`),this._tokenEndpoint}async reportHandler(e){var r,s;await this.started("throw");let t=[];if(!e||e.length===0)return t;let o=e==null?void 0:e.find(h.isPaymentCard);if(!o)return t;let n=e==null?void 0:e.find(h.isBillingAddress);if(!n)return t;let p=new l.AxiosJson({headers:this.headers});try{let u=b(o,n),c=await p.post(this.tokenEndpoint,u);(0,a.assertEx)(c.status===l.HttpStatusCode.Created,()=>`Failed to tokenize payment card: ${c.status}`);let{id:P}=c.data,R=await S.PayloadBuilder.dataHashes([o,n]);t.push({id:P,schema:A.RebillyPaymentAuthorizationTokenSchema,sources:R})}catch(u){(s=(r=this.logger)==null?void 0:r.error)==null||s.call(r,`${m}: Error creating payment token: ${u}`)}return t}};0&&(module.exports={RebillyPaymentCardAuthorizationSentinel,RebillyPaymentCardAuthorizationSentinelConfigSchema,RebillyPaymentCardAuthorizationSentinelSchema});
151
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/Schema.ts","../../src/Config.ts","../../src/Sentinel.ts","../../src/util/toTokenRequest.ts"],"sourcesContent":["export * from './Config'\nexport * from './Params'\nexport * from './Schema'\nexport * from './Sentinel'\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'\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}> &\n Partial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson, AxiosRequestConfig, HttpStatusCode } 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'\n\nimport { CreateTokenResponse } from './Api'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params'\nimport { toTokenRequest } from './util'\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'\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,gDAAgD;;;ACKtD,IAAM,sDAAsD,GAAG,6CAA6C;;;ACLnH,oBAAyB;AACzB,mBAA8D;AAC9D,6BAA+B;AAE/B,qCAAgD;AAChD,4CAAyF;AACzF,+BAAiC;;;ACI1B,IAAM,iBAAiB,CAAC,aAA0B,mBAA8D;AACrH,QAAM,EAAE,KA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AC5E;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/Schema.ts","../../src/Config.ts","../../src/Sentinel.ts","../../src/util/toTokenRequest.ts"],"sourcesContent":["export * from './Config'\nexport * from './Params'\nexport * from './Schema'\nexport * from './Sentinel'\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'\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}> &\n Partial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson, AxiosRequestConfig, HttpStatusCode } 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'\n\nimport { CreateTokenResponse } from './Api'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params'\nimport { toTokenRequest } from './util'\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'\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: { 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AAQ,yCAAwC,QAAAC,CAAQ,CAAC,CAC9E,OAASC,EAAO,EACdV,GAAAD,EAAA,KAAK,SAAL,YAAAA,EAAa,QAAb,MAAAC,EAAA,KAAAD,EAAqB,GAAGJ,CAAU,mCAAmCe,CAAK,GAC5E,CACA,OAAOT,CACT,CACF","names":["src_exports","__export","RebillyPaymentCardAuthorizationSentinel","RebillyPaymentCardAuthorizationSentinelConfigSchema","RebillyPaymentCardAuthorizationSentinelSchema","__toCommonJS","RebillyPaymentCardAuthorizationSentinelSchema","RebillyPaymentCardAuthorizationSentinelConfigSchema","RebillyPaymentCardAuthorizationSentinelSchema","import_assert","import_axios","import_payload_builder","import_payment_payload_plugins","import_rebilly_payment_payload_plugin","import_sentinel_abstract","toTokenRequest","paymentCard","billingAddress","cvv","expMonth","expYear","cardNumber","_","fields","removePrefix","str","prefix","regex","moduleName","RebillyPaymentCardAuthorizationSentinel","RebillyPaymentCardAuthorizationSentinelConfigSchema","payloads","_a","_b","results","paymentCard","billingAddress","axios","data","toTokenRequest","response","id","sources","error"]}
@@ -1,122 +1,2 @@
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, HttpStatusCode } 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
-
15
- // src/util/toTokenRequest.ts
16
- var toTokenRequest = (paymentCard, billingAddress) => {
17
- const { cvv, expMonth, expYear, cardNumber } = paymentCard;
18
- const { schema: _, ...fields } = billingAddress;
19
- return {
20
- billingAddress: { ...fields },
21
- method: "payment-card",
22
- paymentInstrument: { cvv, expMonth, expYear, pan: cardNumber }
23
- };
24
- };
25
-
26
- // src/Sentinel.ts
27
- var removePrefix = (str, prefix) => {
28
- const regex = new RegExp(`^${prefix}`);
29
- return str.replace(regex, "");
30
- };
31
- var moduleName = "RebillyPaymentCardAuthorizationSentinel";
32
- var RebillyPaymentCardAuthorizationSentinel = class extends AbstractSentinel {
33
- static configSchemas = [RebillyPaymentCardAuthorizationSentinelConfigSchema];
34
- static defaultConfigSchema = RebillyPaymentCardAuthorizationSentinelConfigSchema;
35
- _apiRoot = void 0;
36
- _domain = void 0;
37
- _headers = void 0;
38
- _organizationId = void 0;
39
- _publishableApiKey = void 0;
40
- _tokenEndpoint = void 0;
41
- /**
42
- * The Rebilly Organization API root endpoint
43
- */
44
- get apiRoot() {
45
- if (!this._apiRoot) this._apiRoot = `${this.domain}/organizations/${this.organizationId}`;
46
- return this._apiRoot;
47
- }
48
- /**
49
- * The Rebilly domain
50
- */
51
- get domain() {
52
- if (!this._domain) this._domain = assertEx(this.params.domain ?? this.config.domain, () => `${moduleName}: Missing domain in params/config`);
53
- return this._domain;
54
- }
55
- /**
56
- * The headers to be included in the request for each request
57
- */
58
- get headers() {
59
- if (!this._headers) this._headers = { Authorization: this.publishableApiKey };
60
- return this._headers;
61
- }
62
- /**
63
- * True if the environment is sandbox (testing), false otherwise
64
- */
65
- get isSandboxEnvironment() {
66
- return this.domain.includes("sandbox");
67
- }
68
- /**
69
- * The Rebilly organization ID
70
- */
71
- get organizationId() {
72
- if (!this._organizationId)
73
- this._organizationId = removePrefix(
74
- assertEx(this.params.organizationId, () => `${moduleName}: Missing organizationId in params`),
75
- "org_"
76
- );
77
- return this._organizationId;
78
- }
79
- /**
80
- * The Rebilly Publishable API key
81
- */
82
- get publishableApiKey() {
83
- if (!this._publishableApiKey)
84
- this._publishableApiKey = assertEx(this.params.publishableApiKey, () => `${moduleName}: Missing publishableApiKey in params`);
85
- return this._publishableApiKey;
86
- }
87
- /**
88
- * The Rebilly Organization token creation endpoint
89
- */
90
- get tokenEndpoint() {
91
- if (!this._tokenEndpoint) this._tokenEndpoint = `${this.apiRoot}/tokens`;
92
- return this._tokenEndpoint;
93
- }
94
- async reportHandler(payloads) {
95
- var _a, _b;
96
- await this.started("throw");
97
- const results = [];
98
- if (!payloads || payloads.length === 0) return results;
99
- const paymentCard = payloads == null ? void 0 : payloads.find(isPaymentCard);
100
- if (!paymentCard) return results;
101
- const billingAddress = payloads == null ? void 0 : payloads.find(isBillingAddress);
102
- if (!billingAddress) return results;
103
- const axios = new AxiosJson({ headers: this.headers });
104
- try {
105
- const data = toTokenRequest(paymentCard, billingAddress);
106
- const response = await axios.post(this.tokenEndpoint, data);
107
- assertEx(response.status === HttpStatusCode.Created, () => `Failed to tokenize payment card: ${response.status}`);
108
- const { id } = response.data;
109
- const sources = await PayloadBuilder.dataHashes([paymentCard, billingAddress]);
110
- results.push({ id, schema: RebillyPaymentAuthorizationTokenSchema, sources });
111
- } catch (error) {
112
- (_b = (_a = this.logger) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, `${moduleName}: Error creating payment token: ${error}`);
113
- }
114
- return results;
115
- }
116
- };
117
- export {
118
- RebillyPaymentCardAuthorizationSentinel,
119
- RebillyPaymentCardAuthorizationSentinelConfigSchema,
120
- RebillyPaymentCardAuthorizationSentinelSchema
121
- };
1
+ var u="network.xyo.sentinel.payments.payment.instrument.card.authorization.rebilly";var p=`${u}.config`;import{assertEx as s}from"@xylabs/assert";import{AxiosJson as b,HttpStatusCode as S}from"@xylabs/axios";import{PayloadBuilder as A}from"@xyo-network/payload-builder";import{isBillingAddress as C,isPaymentCard as P}from"@xyo-network/payment-payload-plugins";import{RebillyPaymentAuthorizationTokenSchema as R}from"@xyo-network/rebilly-payment-payload-plugin";import{AbstractSentinel as x}from"@xyo-network/sentinel-abstract";var c=(r,e)=>{let{cvv:t,expMonth:i,expYear:n,cardNumber:m}=r,{schema:o,...a}=e;return{billingAddress:{...a},method:"payment-card",paymentInstrument:{cvv:t,expMonth:i,expYear:n,pan:m}}};var z=(r,e)=>{let t=new RegExp(`^${e}`);return r.replace(t,"")},d="RebillyPaymentCardAuthorizationSentinel",f=class extends x{static configSchemas=[p];static defaultConfigSchema=p;_apiRoot=void 0;_domain=void 0;_headers=void 0;_organizationId=void 0;_publishableApiKey=void 0;_tokenEndpoint=void 0;get apiRoot(){return this._apiRoot||(this._apiRoot=`${this.domain}/organizations/${this.organizationId}`),this._apiRoot}get domain(){return this._domain||(this._domain=s(this.params.domain??this.config.domain,()=>`${d}: Missing domain in params/config`)),this._domain}get headers(){return this._headers||(this._headers={Authorization:this.publishableApiKey}),this._headers}get isSandboxEnvironment(){return this.domain.includes("sandbox")}get organizationId(){return this._organizationId||(this._organizationId=z(s(this.params.organizationId,()=>`${d}: Missing organizationId in params`),"org_")),this._organizationId}get publishableApiKey(){return this._publishableApiKey||(this._publishableApiKey=s(this.params.publishableApiKey,()=>`${d}: Missing publishableApiKey in params`)),this._publishableApiKey}get tokenEndpoint(){return this._tokenEndpoint||(this._tokenEndpoint=`${this.apiRoot}/tokens`),this._tokenEndpoint}async reportHandler(e){var o,a;await this.started("throw");let t=[];if(!e||e.length===0)return t;let i=e==null?void 0:e.find(P);if(!i)return t;let n=e==null?void 0:e.find(C);if(!n)return t;let m=new b({headers:this.headers});try{let l=c(i,n),h=await m.post(this.tokenEndpoint,l);s(h.status===S.Created,()=>`Failed to tokenize payment card: ${h.status}`);let{id:g}=h.data,y=await A.dataHashes([i,n]);t.push({id:g,schema:R,sources:y})}catch(l){(a=(o=this.logger)==null?void 0:o.error)==null||a.call(o,`${d}: Error creating payment token: ${l}`)}return t}};export{f as RebillyPaymentCardAuthorizationSentinel,p as RebillyPaymentCardAuthorizationSentinelConfigSchema,u as RebillyPaymentCardAuthorizationSentinelSchema};
122
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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'\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}> &\n Partial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson, AxiosRequestConfig, HttpStatusCode } 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'\n\nimport { CreateTokenResponse } from './Api'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params'\nimport { toTokenRequest } from './util'\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'\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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,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
+ {"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'\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}> &\n Partial<RebillyApiDomainSettings>\n","import { assertEx } from '@xylabs/assert'\nimport { AxiosJson, AxiosRequestConfig, HttpStatusCode } 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'\n\nimport { CreateTokenResponse } from './Api'\nimport { RebillyPaymentCardAuthorizationSentinelConfigSchema } from './Config'\nimport { RebillyPaymentCardAuthorizationSentinelParams } from './Params'\nimport { toTokenRequest } from './util'\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'\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,IAAMA,EAAgD,8ECKtD,IAAMC,EAAsD,GAAGC,CAA6C,UCLnH,OAAS,YAAAC,MAAgB,iBACzB,OAAS,aAAAC,EAA+B,kBAAAC,MAAsB,gBAC9D,OAAS,kBAAAC,MAAsB,+BAE/B,OAAS,oBAAAC,EAAkB,iBAAAC,MAAqB,uCAChD,OAA2C,0CAAAC,MAA8C,8CACzF,OAAS,oBAAAC,MAAwB,iCCI1B,IAAMC,EAAiB,CAACC,EAA0BC,IAA8D,CACrH,GAAM,CAAE,IAAAC,EAAK,SAAAC,EAAU,QAAAC,EAAS,WAAAC,CAAW,EAAIL,EAMzC,CAAE,OAAQM,EAAG,GAAGC,CAAO,EAAIN,EACjC,MAAO,CACL,eAAgB,CAAE,GAAGM,CAAO,EAC5B,OAAQ,eACR,kBAAmB,CAAE,IAAAL,EAAK,SAAAC,EAAU,QAAAC,EAAS,IAAKC,CAAW,CAC/D,CACF,EDTA,IAAMG,EAAe,CAACC,EAAaC,IAAmB,CACpD,IAAMC,EAAQ,IAAI,OAAO,IAAID,CAAM,EAAE,EACrC,OAAOD,EAAI,QAAQE,EAAO,EAAE,CAC9B,EAEMC,EAAa,0CACNC,EAAN,cAGGC,CAAsC,CAC9C,OAAgB,cAAgB,CAACC,CAAmD,EACpF,OAAgB,oBAAsBA,EAE5B,SAA+B,OAC/B,QAA8B,OAC9B,SAAsD,OACtD,gBAAsC,OACtC,mBAAyC,OACzC,eAAqC,OAK/C,IAAc,SAAU,CACtB,OAAK,KAAK,WAAU,KAAK,SAAW,GAAG,KAAK,MAAM,kBAAkB,KAAK,cA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Ae,QAAS,IAAM,oCAAoCD,EAAS,MAAM,EAAE,EAChH,GAAM,CAAE,GAAAE,CAAG,EAAIF,EAAS,KAClBG,EAAU,MAAMC,EAAe,WAAW,CAACZ,EAAaE,CAAc,CAAC,EAC7EH,EAAQ,KAAK,CAAE,GAAAW,EAAI,OAAQG,EAAwC,QAAAF,CAAQ,CAAC,CAC9E,OAASG,EAAO,EACdhB,GAAAD,EAAA,KAAK,SAAL,YAAAA,EAAa,QAAb,MAAAC,EAAA,KAAAD,EAAqB,GAAGN,CAAU,mCAAmCuB,CAAK,GAC5E,CACA,OAAOf,CACT,CACF","names":["RebillyPaymentCardAuthorizationSentinelSchema","RebillyPaymentCardAuthorizationSentinelConfigSchema","RebillyPaymentCardAuthorizationSentinelSchema","assertEx","AxiosJson","HttpStatusCode","PayloadBuilder","isBillingAddress","isPaymentCard","RebillyPaymentAuthorizationTokenSchema","AbstractSentinel","toTokenRequest","paymentCard","billingAddress","cvv","expMonth","expYear","cardNumber","_","fields","removePrefix","str","prefix","regex","moduleName","RebillyPaymentCardAuthorizationSentinel","AbstractSentinel","RebillyPaymentCardAuthorizationSentinelConfigSchema","assertEx","payloads","_a","_b","results","paymentCard","isPaymentCard","billingAddress","isBillingAddress","axios","AxiosJson","data","toTokenRequest","response","HttpStatusCode","id","sources","PayloadBuilder","RebillyPaymentAuthorizationTokenSchema","error"]}
@@ -1,10 +1,4 @@
1
1
  import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
2
2
  import { CreatePaymentTokenRequest } from '../Api';
3
- /**
4
- * Converts a payment card and billing address to a token request
5
- * @param paymentCard The payment card
6
- * @param billingAddress The billing address
7
- * @returns The token request
8
- */
9
3
  export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
10
4
  //# sourceMappingURL=toTokenRequest.d.ts.map
@@ -1 +1 @@
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,QAAQ,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}
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,QAAQ,CAAA;AAQlD,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}
@@ -1,10 +1,4 @@
1
1
  import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
2
2
  import { CreatePaymentTokenRequest } from '../Api';
3
- /**
4
- * Converts a payment card and billing address to a token request
5
- * @param paymentCard The payment card
6
- * @param billingAddress The billing address
7
- * @returns The token request
8
- */
9
3
  export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
10
4
  //# sourceMappingURL=toTokenRequest.d.ts.map
@@ -1 +1 @@
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,QAAQ,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}
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,QAAQ,CAAA;AAQlD,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}
@@ -1,10 +1,4 @@
1
1
  import { BillingAddress, PaymentCard } from '@xyo-network/payment-payload-plugins';
2
2
  import { CreatePaymentTokenRequest } from '../Api';
3
- /**
4
- * Converts a payment card and billing address to a token request
5
- * @param paymentCard The payment card
6
- * @param billingAddress The billing address
7
- * @returns The token request
8
- */
9
3
  export declare const toTokenRequest: (paymentCard: PaymentCard, billingAddress: BillingAddress) => CreatePaymentTokenRequest;
10
4
  //# sourceMappingURL=toTokenRequest.d.ts.map
@@ -1 +1 @@
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,QAAQ,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}
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,QAAQ,CAAA;AAQlD,eAAO,MAAM,cAAc,gBAAiB,WAAW,kBAAkB,cAAc,KAAG,yBAazF,CAAA"}
package/package.json CHANGED
@@ -12,21 +12,21 @@
12
12
  "dependencies": {
13
13
  "@xylabs/assert": "^3.5.1",
14
14
  "@xylabs/axios": "^3.5.1",
15
- "@xyo-network/module-model": "^2.105.0",
16
- "@xyo-network/payload-builder": "^2.105.0",
17
- "@xyo-network/payload-model": "^2.105.0",
18
- "@xyo-network/payment-payload-plugins": "~2.96.0",
19
- "@xyo-network/rebilly-payment-payload-plugin": "~2.96.0",
20
- "@xyo-network/sentinel-abstract": "^2.105.0",
21
- "@xyo-network/sentinel-model": "^2.105.0"
15
+ "@xyo-network/module-model": "^2.106.0",
16
+ "@xyo-network/payload-builder": "^2.106.0",
17
+ "@xyo-network/payload-model": "^2.106.0",
18
+ "@xyo-network/payment-payload-plugins": "~2.96.2",
19
+ "@xyo-network/rebilly-payment-payload-plugin": "~2.96.2",
20
+ "@xyo-network/sentinel-abstract": "^2.106.0",
21
+ "@xyo-network/sentinel-model": "^2.106.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@xylabs/jest-helpers": "^3.5.1",
25
- "@xylabs/ts-scripts-yarn3": "^3.10.4",
26
- "@xylabs/tsconfig": "^3.10.4",
27
- "@xyo-network/boundwitness-model": "^2.105.0",
25
+ "@xylabs/ts-scripts-yarn3": "^3.11.7",
26
+ "@xylabs/tsconfig": "^3.11.7",
27
+ "@xyo-network/boundwitness-model": "^2.106.0",
28
28
  "jest": "^29.7.0",
29
- "typescript": "^5.4.5"
29
+ "typescript": "^5.5.2"
30
30
  },
31
31
  "description": "Typescript/Javascript Plugins for XYO Platform",
32
32
  "types": "dist/node/index.d.ts",
@@ -67,6 +67,6 @@
67
67
  "url": "https://github.com/XYOracleNetwork/plugins.git"
68
68
  },
69
69
  "sideEffects": false,
70
- "version": "2.96.0",
70
+ "version": "2.96.2",
71
71
  "type": "module"
72
72
  }