@ztimson/momentum 0.52.3 → 0.52.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.d.ts CHANGED
@@ -27,6 +27,7 @@ export type Notification = {
27
27
  /** Link to on activation */
28
28
  link?: string;
29
29
  };
30
+ export type Optional<T, O> = Omit<T, keyof O> & Pick<Partial<O>, keyof O>;
30
31
  /** Recursive type for defining tree data */
31
32
  export type TreeNode<T> = T & {
32
33
  /** Name of node */
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,qBAAqB;AACrB,MAAM,MAAM,IAAI,GAAG;IAClB,kBAAkB;IAClB,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,YAAY,EAAE,IAAI,CAAC;IACnB,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,YAAY,EAAE,IAAI,CAAC;CACnB,CAAA;AAED,8BAA8B;AAC9B,MAAM,MAAM,kBAAkB,GAAI,OAAO,GAAG,cAAc,GAAG,KAAK,GAAG,OAAO,CAAC;AAE7E,yBAAyB;AACzB,MAAM,MAAM,YAAY,GAAG;IAC1B,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,CAAC;IAClE,2BAA2B;IAC3B,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,GAAG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,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1E,4CAA4C;AAC5C,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG;IAC7B,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;CACxB,CAAC"}
package/dist/email.d.ts CHANGED
@@ -15,6 +15,11 @@ export type Mail = {
15
15
  template: string;
16
16
  data?: any;
17
17
  };
18
+ /** Email attachments */
19
+ attachments?: {
20
+ filename: string;
21
+ content: Buffer;
22
+ }[];
18
23
  };
19
24
  /** Send Emails */
20
25
  export declare class Email extends PathEventEmitter {
@@ -1 +1 @@
1
- {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,kBAAkB;AAClB,MAAM,MAAM,IAAI,GAAG;IAClB,2BAA2B;IAC3B,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,uBAAuB;IACvB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,uBAAuB;IACvB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,GAAG;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAC,CAAC;CAC/C,CAAA;AAED,kBAAkB;AAClB,qBAAa,KAAM,SAAQ,gBAAgB;IAC1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,IAAI;CAOhB"}
1
+ {"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../src/email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,kBAAkB;AAClB,MAAM,MAAM,IAAI,GAAG;IAClB,2BAA2B;IAC3B,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtB,uBAAuB;IACvB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACd,uBAAuB;IACvB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,GAAG;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAC,CAAC;IAC/C,wBAAwB;IACxB,WAAW,CAAC,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,EAAE,CAAA;CACnD,CAAA;AAED,kBAAkB;AAClB,qBAAa,KAAM,SAAQ,gBAAgB;IAC1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,IAAI;CAOhB"}
package/dist/index.cjs CHANGED
@@ -575,6 +575,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
575
575
  }
576
576
  }
577
577
  __publicField2(GatewayTimeoutError, "code", 504);
578
+ class HttpResponse extends Response {
579
+ constructor(resp, stream) {
580
+ super(stream, { headers: resp.headers, status: resp.status, statusText: resp.statusText });
581
+ __publicField2(this, "data");
582
+ __publicField2(this, "ok");
583
+ __publicField2(this, "redirected");
584
+ __publicField2(this, "type");
585
+ __publicField2(this, "url");
586
+ this.ok = resp.ok;
587
+ this.redirected = resp.redirected;
588
+ this.type = resp.type;
589
+ this.url = resp.url;
590
+ }
591
+ }
578
592
  const _Http = class _Http2 {
579
593
  constructor(defaults = {}) {
580
594
  __publicField2(this, "interceptors", {});
@@ -646,13 +660,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
646
660
  push();
647
661
  }
648
662
  });
649
- resp.data = new Response(stream);
650
- if (opts.decode == null || opts.decode) {
663
+ resp = new HttpResponse(resp, stream);
664
+ if (opts.decode !== false) {
651
665
  const content = (_b = resp.headers.get("Content-Type")) == null ? void 0 : _b.toLowerCase();
652
- if (content == null ? void 0 : content.includes("form")) resp.data = await resp.data.formData();
653
- else if (content == null ? void 0 : content.includes("json")) resp.data = await resp.data.json();
654
- else if (content == null ? void 0 : content.includes("text")) resp.data = await resp.data.text();
655
- else if (content == null ? void 0 : content.includes("application")) resp.data = await resp.data.blob();
666
+ if (content == null ? void 0 : content.includes("form")) resp.data = await resp.formData();
667
+ else if (content == null ? void 0 : content.includes("json")) resp.data = await resp.json();
668
+ else if (content == null ? void 0 : content.includes("text")) resp.data = await resp.text();
669
+ else if (content == null ? void 0 : content.includes("application")) resp.data = await resp.blob();
656
670
  }
657
671
  if (resp.ok) res(resp);
658
672
  else rej(resp);
@@ -1007,7 +1021,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1007
1021
  if (this.pending[key] != null) return this.pending[key];
1008
1022
  this.pending[key] = super.request(options).then((response) => {
1009
1023
  this.emit(PES`api/response:${method}`, { request: options, response });
1010
- return response.data;
1024
+ return options.decode === false ? response : response.data;
1011
1025
  }).catch((err) => {
1012
1026
  const e = (err == null ? void 0 : err.data) || err;
1013
1027
  this.emit(PES`api/error:${method}`, { request: options, error: e });
@@ -2017,8 +2031,9 @@ ${log}`;
2017
2031
  constructor(api, opts = {}) {
2018
2032
  super();
2019
2033
  __publicField(this, "api");
2020
- __publicField(this, "loaded", false);
2034
+ /** Stripe object */
2021
2035
  __publicField(this, "stripe");
2036
+ /** Public stripe token */
2022
2037
  __publicField(this, "token");
2023
2038
  this.opts = opts;
2024
2039
  this.api = typeof api == "string" ? new Api(api) : api;
@@ -2027,43 +2042,86 @@ ${log}`;
2027
2042
  ...this.opts
2028
2043
  };
2029
2044
  }
2030
- async checkout(cart, opts = {}) {
2031
- if (!(cart == null ? void 0 : cart.length)) throw new Error("Please add items to cart`");
2032
- const request = await this.api.request({ url: "/api/payments", body: {
2033
- cart,
2034
- recipient: opts == null ? void 0 : opts.recipient,
2035
- invoice: opts == null ? void 0 : opts.invoice,
2036
- extra: opts == null ? void 0 : opts.extra
2037
- } });
2038
- this.emit(PES`payments:c`, request.token);
2039
- return request.token;
2040
- }
2045
+ /**
2046
+ * Initialize stripe API
2047
+ * @return {Promise<any>} Returns stripe API
2048
+ * @private
2049
+ */
2041
2050
  async init() {
2042
- if (!this.stripe) this.stripe = await new Promise((res) => {
2043
- if (this.loaded || this.stripe) return res(window["Stripe"]);
2044
- const script = document.createElement("script");
2045
- script.src = "https://js.stripe.com/v3/";
2046
- script.setAttribute("crossorigin", "anonymous");
2047
- script.onload = () => res(window["Stripe"]);
2048
- document.head.appendChild(script);
2049
- });
2051
+ await new Promise((res) => {
2052
+ if (this.stripe) return res(window["Stripe"]);
2053
+ const stripeScript = document.createElement("script");
2054
+ stripeScript.src = "https://js.stripe.com/v3/";
2055
+ stripeScript.setAttribute("crossorigin", "anonymous");
2056
+ stripeScript.onload = () => res();
2057
+ document.head.appendChild(stripeScript);
2058
+ }).then(() => this.stripe = window["Stripe"]);
2050
2059
  return this.stripe(this.token);
2051
2060
  }
2061
+ /**
2062
+ * Create a stripe client secret to complete transaction
2063
+ * @param {string} id Transaction ID
2064
+ * @return {Promise<string>} Client secret
2065
+ * @private
2066
+ */
2067
+ createSecret(id) {
2068
+ return this.api.request({ url: `/api/payments/init/${id || ""}`, method: "POST" }).then((resp) => resp.token);
2069
+ }
2070
+ /**
2071
+ * Create/Update a transaction
2072
+ * @param {Optional<Transaction, "subtotal" | "total">} transaction Transaction information
2073
+ * @return {Promise<string>} Completed translation information
2074
+ */
2075
+ checkout(transaction) {
2076
+ return this.api.request({
2077
+ url: `/api/payments/transactions/${transaction._id || ""}`,
2078
+ method: transaction._id ? "PATCH" : "POST",
2079
+ body: transaction
2080
+ }).then((resp) => {
2081
+ this.emit(PES`payments:c`, resp);
2082
+ return resp;
2083
+ });
2084
+ }
2085
+ /**
2086
+ * Get translation history
2087
+ * @param {string} username Limit history to user
2088
+ * @return {Promise<Transaction[]>} List of translations
2089
+ */
2052
2090
  async history(username) {
2053
- const history = await this.api.request({ url: `/api/payments/${username || ""}` });
2054
- this.emit(PES`payments/${username}:r`, history);
2055
- return history;
2091
+ return this.api.request({ url: `/api/payments/transactions/${username || ""}` }).then((resp) => {
2092
+ this.emit(PES`payments/${username}:r`, resp);
2093
+ return resp;
2094
+ });
2095
+ }
2096
+ /**
2097
+ * Send recipient transaction receipt or invoice
2098
+ * @param {string} id Translation ID
2099
+ * @return {Promise<void>} Returns once complete
2100
+ */
2101
+ notify(id) {
2102
+ return this.api.request({ url: `/api/payments/notify/${id || ""}`, method: "POST" });
2056
2103
  }
2057
- async products(id) {
2104
+ /**
2105
+ * Retrieve a list of available products
2106
+ * @param {string | number} id Limit to specific product
2107
+ * @return {Promise<any>} List of products or single product if ID is used
2108
+ */
2109
+ products(id) {
2058
2110
  return this.api.request({ url: `/api/payments/products/${id || ""}` }).then((resp) => {
2059
- this.emit(PES`products/${id}:r`, resp);
2111
+ this.emit(PES`products/${id ?? ""}:r`, resp);
2060
2112
  return resp;
2061
2113
  });
2062
2114
  }
2063
- async payment(card, token) {
2064
- const client = await this.init();
2115
+ /**
2116
+ * Process payment programmatically
2117
+ * @param {string} id Transaction ID
2118
+ * @param {Card} card Credit card information
2119
+ * @return {Promise<any>} Stripe confirmation
2120
+ */
2121
+ async payment(id, card) {
2122
+ const [client, secret] = await Promise.all([this.init(), this.createSecret(id)]);
2065
2123
  return client.confirmPayment({
2066
- clientSecret: token,
2124
+ clientSecret: secret,
2067
2125
  confirmParams: {
2068
2126
  payment_method: {
2069
2127
  card: { ...card, details: void 0 },
@@ -2072,9 +2130,15 @@ ${log}`;
2072
2130
  }
2073
2131
  });
2074
2132
  }
2075
- async paymentForm(element, token) {
2076
- const client = await this.init();
2077
- const form = client.elements({ clientSecret: token });
2133
+ /**
2134
+ * Process payment using Stripe form
2135
+ * @param {string} id Transaction ID
2136
+ * @param {string} element DOM element to inject form into
2137
+ * @return {Promise<() => Promise<any>>} Callback to submit form
2138
+ */
2139
+ async paymentForm(id, element) {
2140
+ const [client, secret] = await Promise.all([this.init(), this.createSecret(id)]);
2141
+ const form = client.elements({ clientSecret: secret });
2078
2142
  form.create("payment").mount(element);
2079
2143
  return (redirect = location.href) => client.confirmPayment({
2080
2144
  elements: form,
@@ -2084,11 +2148,11 @@ ${log}`;
2084
2148
  }
2085
2149
  /**
2086
2150
  * Complete payment via Momentum's payment page
2087
- * @param {string} token Stripe payment intent secret
2151
+ * @param {string} id Transaction ID
2088
2152
  * @param {string} host Host origin attempting to login
2089
- * @return {Promise<string>} Token on success
2153
+ * @return {Promise<string>} Translation ID on success
2090
2154
  */
2091
- paymentRedirect(token, host = location.origin) {
2155
+ paymentRedirect(id, host = location.origin) {
2092
2156
  return new Promise(async (res, rej) => {
2093
2157
  var _a;
2094
2158
  let origin = new URL(this.opts.paymentUrl).origin, done = false, listener, win;
@@ -2101,7 +2165,7 @@ ${log}`;
2101
2165
  win.close();
2102
2166
  res(data.response);
2103
2167
  });
2104
- win = window.open(encodeURI(`${(_a = this.opts) == null ? void 0 : _a.paymentUrl}?token=${token}&host=${host}`), "_blank");
2168
+ win = window.open(encodeURI(`${(_a = this.opts) == null ? void 0 : _a.paymentUrl}?token=${id}&host=${host}`), "_blank");
2105
2169
  if (!win) {
2106
2170
  window.removeEventListener("message", listener);
2107
2171
  return rej("Unable to open payment page");
@@ -2119,17 +2183,14 @@ ${log}`;
2119
2183
  this.api = typeof api == "string" ? new Api(api) : api;
2120
2184
  }
2121
2185
  createPdf(body, options) {
2122
- return this.api.request({ url: `/api/` + PES`pdf`, body: { ...body, options }, decode: false }).then(async (resp) => {
2123
- const blob = await resp.blob();
2186
+ return this.api.request({ url: `/api/` + PES`pdf`, body: { ...body, options } }).then(async (resp) => {
2124
2187
  if (options == null ? void 0 : options.download) {
2125
2188
  let filename = (options == null ? void 0 : options.filename) || timestampFilename();
2126
2189
  if (!filename.endsWith(".pdf")) filename += ".pdf";
2127
- const url = URL.createObjectURL(blob);
2128
- downloadUrl(url, filename);
2129
- URL.revokeObjectURL(url);
2190
+ downloadFile(resp, filename);
2130
2191
  }
2131
- this.emit(PES`pdf:c`, blob);
2132
- return blob;
2192
+ this.emit(PES`pdf:c`, resp);
2193
+ return resp;
2133
2194
  });
2134
2195
  }
2135
2196
  fromHtml(html, options = {}) {
package/dist/index.mjs CHANGED
@@ -571,6 +571,20 @@ class GatewayTimeoutError extends CustomError {
571
571
  }
572
572
  }
573
573
  __publicField2(GatewayTimeoutError, "code", 504);
574
+ class HttpResponse extends Response {
575
+ constructor(resp, stream) {
576
+ super(stream, { headers: resp.headers, status: resp.status, statusText: resp.statusText });
577
+ __publicField2(this, "data");
578
+ __publicField2(this, "ok");
579
+ __publicField2(this, "redirected");
580
+ __publicField2(this, "type");
581
+ __publicField2(this, "url");
582
+ this.ok = resp.ok;
583
+ this.redirected = resp.redirected;
584
+ this.type = resp.type;
585
+ this.url = resp.url;
586
+ }
587
+ }
574
588
  const _Http = class _Http2 {
575
589
  constructor(defaults = {}) {
576
590
  __publicField2(this, "interceptors", {});
@@ -642,13 +656,13 @@ const _Http = class _Http2 {
642
656
  push();
643
657
  }
644
658
  });
645
- resp.data = new Response(stream);
646
- if (opts.decode == null || opts.decode) {
659
+ resp = new HttpResponse(resp, stream);
660
+ if (opts.decode !== false) {
647
661
  const content = (_b = resp.headers.get("Content-Type")) == null ? void 0 : _b.toLowerCase();
648
- if (content == null ? void 0 : content.includes("form")) resp.data = await resp.data.formData();
649
- else if (content == null ? void 0 : content.includes("json")) resp.data = await resp.data.json();
650
- else if (content == null ? void 0 : content.includes("text")) resp.data = await resp.data.text();
651
- else if (content == null ? void 0 : content.includes("application")) resp.data = await resp.data.blob();
662
+ if (content == null ? void 0 : content.includes("form")) resp.data = await resp.formData();
663
+ else if (content == null ? void 0 : content.includes("json")) resp.data = await resp.json();
664
+ else if (content == null ? void 0 : content.includes("text")) resp.data = await resp.text();
665
+ else if (content == null ? void 0 : content.includes("application")) resp.data = await resp.blob();
652
666
  }
653
667
  if (resp.ok) res(resp);
654
668
  else rej(resp);
@@ -1003,7 +1017,7 @@ class Api extends Http {
1003
1017
  if (this.pending[key] != null) return this.pending[key];
1004
1018
  this.pending[key] = super.request(options).then((response) => {
1005
1019
  this.emit(PES`api/response:${method}`, { request: options, response });
1006
- return response.data;
1020
+ return options.decode === false ? response : response.data;
1007
1021
  }).catch((err) => {
1008
1022
  const e = (err == null ? void 0 : err.data) || err;
1009
1023
  this.emit(PES`api/error:${method}`, { request: options, error: e });
@@ -2013,8 +2027,9 @@ class Payments extends PathEventEmitter {
2013
2027
  constructor(api, opts = {}) {
2014
2028
  super();
2015
2029
  __publicField(this, "api");
2016
- __publicField(this, "loaded", false);
2030
+ /** Stripe object */
2017
2031
  __publicField(this, "stripe");
2032
+ /** Public stripe token */
2018
2033
  __publicField(this, "token");
2019
2034
  this.opts = opts;
2020
2035
  this.api = typeof api == "string" ? new Api(api) : api;
@@ -2023,43 +2038,86 @@ class Payments extends PathEventEmitter {
2023
2038
  ...this.opts
2024
2039
  };
2025
2040
  }
2026
- async checkout(cart, opts = {}) {
2027
- if (!(cart == null ? void 0 : cart.length)) throw new Error("Please add items to cart`");
2028
- const request = await this.api.request({ url: "/api/payments", body: {
2029
- cart,
2030
- recipient: opts == null ? void 0 : opts.recipient,
2031
- invoice: opts == null ? void 0 : opts.invoice,
2032
- extra: opts == null ? void 0 : opts.extra
2033
- } });
2034
- this.emit(PES`payments:c`, request.token);
2035
- return request.token;
2036
- }
2041
+ /**
2042
+ * Initialize stripe API
2043
+ * @return {Promise<any>} Returns stripe API
2044
+ * @private
2045
+ */
2037
2046
  async init() {
2038
- if (!this.stripe) this.stripe = await new Promise((res) => {
2039
- if (this.loaded || this.stripe) return res(window["Stripe"]);
2040
- const script = document.createElement("script");
2041
- script.src = "https://js.stripe.com/v3/";
2042
- script.setAttribute("crossorigin", "anonymous");
2043
- script.onload = () => res(window["Stripe"]);
2044
- document.head.appendChild(script);
2045
- });
2047
+ await new Promise((res) => {
2048
+ if (this.stripe) return res(window["Stripe"]);
2049
+ const stripeScript = document.createElement("script");
2050
+ stripeScript.src = "https://js.stripe.com/v3/";
2051
+ stripeScript.setAttribute("crossorigin", "anonymous");
2052
+ stripeScript.onload = () => res();
2053
+ document.head.appendChild(stripeScript);
2054
+ }).then(() => this.stripe = window["Stripe"]);
2046
2055
  return this.stripe(this.token);
2047
2056
  }
2057
+ /**
2058
+ * Create a stripe client secret to complete transaction
2059
+ * @param {string} id Transaction ID
2060
+ * @return {Promise<string>} Client secret
2061
+ * @private
2062
+ */
2063
+ createSecret(id) {
2064
+ return this.api.request({ url: `/api/payments/init/${id || ""}`, method: "POST" }).then((resp) => resp.token);
2065
+ }
2066
+ /**
2067
+ * Create/Update a transaction
2068
+ * @param {Optional<Transaction, "subtotal" | "total">} transaction Transaction information
2069
+ * @return {Promise<string>} Completed translation information
2070
+ */
2071
+ checkout(transaction) {
2072
+ return this.api.request({
2073
+ url: `/api/payments/transactions/${transaction._id || ""}`,
2074
+ method: transaction._id ? "PATCH" : "POST",
2075
+ body: transaction
2076
+ }).then((resp) => {
2077
+ this.emit(PES`payments:c`, resp);
2078
+ return resp;
2079
+ });
2080
+ }
2081
+ /**
2082
+ * Get translation history
2083
+ * @param {string} username Limit history to user
2084
+ * @return {Promise<Transaction[]>} List of translations
2085
+ */
2048
2086
  async history(username) {
2049
- const history = await this.api.request({ url: `/api/payments/${username || ""}` });
2050
- this.emit(PES`payments/${username}:r`, history);
2051
- return history;
2087
+ return this.api.request({ url: `/api/payments/transactions/${username || ""}` }).then((resp) => {
2088
+ this.emit(PES`payments/${username}:r`, resp);
2089
+ return resp;
2090
+ });
2091
+ }
2092
+ /**
2093
+ * Send recipient transaction receipt or invoice
2094
+ * @param {string} id Translation ID
2095
+ * @return {Promise<void>} Returns once complete
2096
+ */
2097
+ notify(id) {
2098
+ return this.api.request({ url: `/api/payments/notify/${id || ""}`, method: "POST" });
2052
2099
  }
2053
- async products(id) {
2100
+ /**
2101
+ * Retrieve a list of available products
2102
+ * @param {string | number} id Limit to specific product
2103
+ * @return {Promise<any>} List of products or single product if ID is used
2104
+ */
2105
+ products(id) {
2054
2106
  return this.api.request({ url: `/api/payments/products/${id || ""}` }).then((resp) => {
2055
- this.emit(PES`products/${id}:r`, resp);
2107
+ this.emit(PES`products/${id ?? ""}:r`, resp);
2056
2108
  return resp;
2057
2109
  });
2058
2110
  }
2059
- async payment(card, token) {
2060
- const client = await this.init();
2111
+ /**
2112
+ * Process payment programmatically
2113
+ * @param {string} id Transaction ID
2114
+ * @param {Card} card Credit card information
2115
+ * @return {Promise<any>} Stripe confirmation
2116
+ */
2117
+ async payment(id, card) {
2118
+ const [client, secret] = await Promise.all([this.init(), this.createSecret(id)]);
2061
2119
  return client.confirmPayment({
2062
- clientSecret: token,
2120
+ clientSecret: secret,
2063
2121
  confirmParams: {
2064
2122
  payment_method: {
2065
2123
  card: { ...card, details: void 0 },
@@ -2068,9 +2126,15 @@ class Payments extends PathEventEmitter {
2068
2126
  }
2069
2127
  });
2070
2128
  }
2071
- async paymentForm(element, token) {
2072
- const client = await this.init();
2073
- const form = client.elements({ clientSecret: token });
2129
+ /**
2130
+ * Process payment using Stripe form
2131
+ * @param {string} id Transaction ID
2132
+ * @param {string} element DOM element to inject form into
2133
+ * @return {Promise<() => Promise<any>>} Callback to submit form
2134
+ */
2135
+ async paymentForm(id, element) {
2136
+ const [client, secret] = await Promise.all([this.init(), this.createSecret(id)]);
2137
+ const form = client.elements({ clientSecret: secret });
2074
2138
  form.create("payment").mount(element);
2075
2139
  return (redirect = location.href) => client.confirmPayment({
2076
2140
  elements: form,
@@ -2080,11 +2144,11 @@ class Payments extends PathEventEmitter {
2080
2144
  }
2081
2145
  /**
2082
2146
  * Complete payment via Momentum's payment page
2083
- * @param {string} token Stripe payment intent secret
2147
+ * @param {string} id Transaction ID
2084
2148
  * @param {string} host Host origin attempting to login
2085
- * @return {Promise<string>} Token on success
2149
+ * @return {Promise<string>} Translation ID on success
2086
2150
  */
2087
- paymentRedirect(token, host = location.origin) {
2151
+ paymentRedirect(id, host = location.origin) {
2088
2152
  return new Promise(async (res, rej) => {
2089
2153
  var _a;
2090
2154
  let origin = new URL(this.opts.paymentUrl).origin, done = false, listener, win;
@@ -2097,7 +2161,7 @@ class Payments extends PathEventEmitter {
2097
2161
  win.close();
2098
2162
  res(data.response);
2099
2163
  });
2100
- win = window.open(encodeURI(`${(_a = this.opts) == null ? void 0 : _a.paymentUrl}?token=${token}&host=${host}`), "_blank");
2164
+ win = window.open(encodeURI(`${(_a = this.opts) == null ? void 0 : _a.paymentUrl}?token=${id}&host=${host}`), "_blank");
2101
2165
  if (!win) {
2102
2166
  window.removeEventListener("message", listener);
2103
2167
  return rej("Unable to open payment page");
@@ -2115,17 +2179,14 @@ class Pdf extends PathEventEmitter {
2115
2179
  this.api = typeof api == "string" ? new Api(api) : api;
2116
2180
  }
2117
2181
  createPdf(body, options) {
2118
- return this.api.request({ url: `/api/` + PES`pdf`, body: { ...body, options }, decode: false }).then(async (resp) => {
2119
- const blob = await resp.blob();
2182
+ return this.api.request({ url: `/api/` + PES`pdf`, body: { ...body, options } }).then(async (resp) => {
2120
2183
  if (options == null ? void 0 : options.download) {
2121
2184
  let filename = (options == null ? void 0 : options.filename) || timestampFilename();
2122
2185
  if (!filename.endsWith(".pdf")) filename += ".pdf";
2123
- const url = URL.createObjectURL(blob);
2124
- downloadUrl(url, filename);
2125
- URL.revokeObjectURL(url);
2186
+ downloadFile(resp, filename);
2126
2187
  }
2127
- this.emit(PES`pdf:c`, blob);
2128
- return blob;
2188
+ this.emit(PES`pdf:c`, resp);
2189
+ return resp;
2129
2190
  });
2130
2191
  }
2131
2192
  fromHtml(html, options = {}) {
@@ -1,72 +1,178 @@
1
1
  import { PathEventEmitter } from '@ztimson/utils';
2
2
  import { Api } from './api';
3
3
  import { Meta } from './core';
4
+ /** Creditcard information for payments */
4
5
  export type Card = {
6
+ /** Creditcard number */
5
7
  number: number | string;
8
+ /** Year card expires */
6
9
  expYear: number | string;
10
+ /** Month card expires */
7
11
  expMonth: number | string;
12
+ /** 3 digit security code */
8
13
  csv: number | string;
14
+ /** Additional details for anti-fraud */
9
15
  details?: {
16
+ /** Cardholder name */
10
17
  name?: string;
18
+ /** Billing address */
11
19
  address?: {
12
20
  postal_code?: string;
13
21
  };
14
22
  };
15
23
  };
16
- export type PaymentAccount = {
24
+ /** Payment discounts */
25
+ export type Discount = Meta & {
26
+ /** Public discount code */
27
+ code: string;
28
+ /** Discount information */
29
+ description?: string;
30
+ /** Invalidate discount code */
31
+ expire?: Date;
32
+ /** Discount by fixed amount */
33
+ fixed?: number;
34
+ /** Limit the numer of uses */
35
+ limit?: number;
36
+ /** Discount by percentage */
37
+ percent?: number;
38
+ };
39
+ /** User financial status */
40
+ export type Finances = {
41
+ /** Username */
17
42
  _id?: string;
18
- username: string;
43
+ /** Account balance */
19
44
  balance: number;
45
+ /** Account subscriptions */
20
46
  subscriptions: {
47
+ /** Product ID */
21
48
  _id: string;
49
+ /** Date subscription started */
22
50
  created: Date;
51
+ /** Number of days the subscription lasts */
23
52
  interval: number;
24
53
  }[];
25
54
  };
55
+ /** Payment API options */
26
56
  export type PaymentOptions = {
27
57
  /** Path to payment page */
28
58
  paymentUrl?: string;
29
59
  };
30
- export type PaymentTransaction = Meta & {
31
- /** Deliver to user/email */
32
- recipient: string;
60
+ /** Returned products */
61
+ export type Product = any & {
62
+ _id: number;
63
+ name: string;
64
+ cost: number;
65
+ subscription?: number;
66
+ socked: boolean;
67
+ };
68
+ /** Purchase options */
69
+ export type Transaction = Meta & {
33
70
  /** Purchased items */
34
- receipt: {
35
- _id: number | string;
71
+ cart: {
72
+ /** Product ID number, 'balance' for credit or null if custom */
73
+ _id?: number | 'balance';
74
+ /** Product name or description */
36
75
  name: string;
76
+ /** Number of units to purchase */
37
77
  quantity: number;
38
- price: number;
78
+ /** Individual unit cost */
79
+ cost: number;
39
80
  }[];
81
+ /** Apply credit (Infinity to use all credit) */
82
+ credit: number;
83
+ /** Apply discount */
84
+ discount?: Partial<Omit<Discount, keyof Meta | 'description' | 'expire' | 'limit'>>;
85
+ /** Completion method, null to send invoice (creditcard, cash, transfer, etc) */
86
+ method?: string | null;
87
+ /** Transaction notes */
88
+ notes?: string | null;
89
+ /** Recipient username or information */
90
+ recipient?: {
91
+ /** Billing address */
92
+ address?: string;
93
+ /** Delivery email */
94
+ email?: string;
95
+ /** Receipt name */
96
+ name?: string;
97
+ /** Account name */
98
+ username?: string;
99
+ };
40
100
  /** Transaction total */
101
+ subtotal: number;
102
+ /** Tax percentage as float */
103
+ tax: number;
104
+ /** Transaction total (subtotal - discount - credit + tax) */
41
105
  total: number;
42
- /** Completion method (card, cash, etc) */
43
- method?: string;
44
106
  /** Stripe transaction */
45
107
  tx?: any;
46
108
  };
47
- export type Purchase = {
48
- target: 'balance' | string | number;
49
- amount?: number;
50
- };
51
109
  export declare class Payments extends PathEventEmitter {
52
110
  readonly opts: PaymentOptions;
53
111
  private readonly api;
54
- private loaded;
112
+ /** Stripe object */
55
113
  stripe?: any;
114
+ /** Public stripe token */
56
115
  token?: string;
57
116
  constructor(api: Api | string, opts?: PaymentOptions);
58
- private checkout;
117
+ /**
118
+ * Initialize stripe API
119
+ * @return {Promise<any>} Returns stripe API
120
+ * @private
121
+ */
59
122
  private init;
60
- history(username?: string): Promise<any[]>;
61
- products(id?: string | number): Promise<any[]>;
62
- payment(card: Card, token: string): Promise<any>;
63
- paymentForm(element: string, token: string): Promise<() => Promise<any>>;
123
+ /**
124
+ * Create a stripe client secret to complete transaction
125
+ * @param {string} id Transaction ID
126
+ * @return {Promise<string>} Client secret
127
+ * @private
128
+ */
129
+ private createSecret;
130
+ /**
131
+ * Create/Update a transaction
132
+ * @param {Optional<Transaction, "subtotal" | "total">} transaction Transaction information
133
+ * @return {Promise<string>} Completed translation information
134
+ */
135
+ checkout(transaction: Partial<Transaction> & {
136
+ recipient: string;
137
+ }): Promise<Transaction>;
138
+ /**
139
+ * Get translation history
140
+ * @param {string} username Limit history to user
141
+ * @return {Promise<Transaction[]>} List of translations
142
+ */
143
+ history(username?: string): Promise<Transaction[]>;
144
+ /**
145
+ * Send recipient transaction receipt or invoice
146
+ * @param {string} id Translation ID
147
+ * @return {Promise<void>} Returns once complete
148
+ */
149
+ notify(id: string): Promise<void>;
150
+ /**
151
+ * Retrieve a list of available products
152
+ * @param {string | number} id Limit to specific product
153
+ * @return {Promise<any>} List of products or single product if ID is used
154
+ */
155
+ products<T = any>(id?: string): Promise<T[]>;
156
+ /**
157
+ * Process payment programmatically
158
+ * @param {string} id Transaction ID
159
+ * @param {Card} card Credit card information
160
+ * @return {Promise<any>} Stripe confirmation
161
+ */
162
+ payment(id: string, card: Card): Promise<any>;
163
+ /**
164
+ * Process payment using Stripe form
165
+ * @param {string} id Transaction ID
166
+ * @param {string} element DOM element to inject form into
167
+ * @return {Promise<() => Promise<any>>} Callback to submit form
168
+ */
169
+ paymentForm(id: string, element: string): Promise<() => Promise<any>>;
64
170
  /**
65
171
  * Complete payment via Momentum's payment page
66
- * @param {string} token Stripe payment intent secret
172
+ * @param {string} id Transaction ID
67
173
  * @param {string} host Host origin attempting to login
68
- * @return {Promise<string>} Token on success
174
+ * @return {Promise<string>} Translation ID on success
69
175
  */
70
- paymentRedirect(token: string, host?: string): Promise<string>;
176
+ paymentRedirect(id: string, host?: string): Promise<string>;
71
177
  }
72
178
  //# sourceMappingURL=payments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../src/payments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAM,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAE5B,MAAM,MAAM,IAAI,GAAG;IAClB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE;YACT,WAAW,CAAC,EAAE,MAAM,CAAC;SACrB,CAAA;KACD,CAAA;CACD,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,OAAO,EAAE,IAAI,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;CACJ,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC5B,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG;IACvC,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,OAAO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ACpB,uBAAuB;IACvB,MAAM,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KAChB,CAAA;IACD,gCAAgC;IAChC,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC/B,+BAA+B;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAA;AAED,qBAAa,GAAI,SAAQ,gBAAgB;IACxC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAO;gBAEf,GAAG,EAAE,GAAG,GAAG,MAAM;IAK7B,OAAO,CAAC,SAAS;IAYjB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe;IAK/C,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe;IAKrE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe;CAI7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ztimson/momentum",
3
- "version": "0.52.3",
3
+ "version": "0.52.4",
4
4
  "description": "Client library for momentum",
5
5
  "keywords": ["Momentum"],
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
@@ -24,7 +24,7 @@
24
24
  "postbuild": "node -e \"const fs=require('fs');fs.cpSync('dist/index.mjs','../server/public/momentum.mjs');fs.cpSync('dist/index.cjs','../server/public/momentum.js');fs.cpSync('dist/momentum.worker.js','../server/public/momentum.worker.js')\""
25
25
  },
26
26
  "dependencies": {
27
- "@ztimson/utils": "0.23.11",
27
+ "@ztimson/utils": "0.23.12",
28
28
  "var-persist": "^1.0.1"
29
29
  },
30
30
  "devDependencies": {