@lightsparkdev/core 0.3.7 → 0.3.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lightsparkdev/core
2
2
 
3
+ ## 0.3.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 98e2511: Consolidate tsconfigs for apps and stricter rules for packages
8
+
3
9
  ## 0.3.7
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -152,6 +152,9 @@ var getCrypto = () => {
152
152
  if (!nodeCrypto.getRandomValues) {
153
153
  cryptoModule = Object.assign({}, cryptoModule, {
154
154
  getRandomValues: (array) => {
155
+ if (!array) {
156
+ return array;
157
+ }
155
158
  const buffer = Buffer.from(array.buffer);
156
159
  nodeCrypto.randomFillSync(buffer);
157
160
  return array;
@@ -638,6 +641,9 @@ var CONVERSION_MAP = {
638
641
  }
639
642
  };
640
643
  var convertCurrencyAmount = (from, toUnit) => {
644
+ if (from.originalUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || from.originalUnit === "USD" /* USD */ || toUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || toUnit === "USD" /* USD */) {
645
+ throw new LightsparkException_default("CurrencyError", `Unsupported CurrencyUnit.`);
646
+ }
641
647
  const conversionFn = CONVERSION_MAP[from.originalUnit][toUnit];
642
648
  if (!conversionFn) {
643
649
  throw new LightsparkException_default(
package/dist/index.js CHANGED
@@ -100,6 +100,9 @@ var getCrypto = () => {
100
100
  if (!nodeCrypto.getRandomValues) {
101
101
  cryptoModule = Object.assign({}, cryptoModule, {
102
102
  getRandomValues: (array) => {
103
+ if (!array) {
104
+ return array;
105
+ }
103
106
  const buffer = Buffer.from(array.buffer);
104
107
  nodeCrypto.randomFillSync(buffer);
105
108
  return array;
@@ -586,6 +589,9 @@ var CONVERSION_MAP = {
586
589
  }
587
590
  };
588
591
  var convertCurrencyAmount = (from, toUnit) => {
592
+ if (from.originalUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || from.originalUnit === "USD" /* USD */ || toUnit === "FUTURE_VALUE" /* FUTURE_VALUE */ || toUnit === "USD" /* USD */) {
593
+ throw new LightsparkException_default("CurrencyError", `Unsupported CurrencyUnit.`);
594
+ }
589
595
  const conversionFn = CONVERSION_MAP[from.originalUnit][toUnit];
590
596
  if (!conversionFn) {
591
597
  throw new LightsparkException_default(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/core",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -48,7 +48,11 @@ const getCrypto = () => {
48
48
  }
49
49
  if (!nodeCrypto.getRandomValues) {
50
50
  cryptoModule = Object.assign({}, cryptoModule, {
51
- getRandomValues: (array) => {
51
+ getRandomValues: <T extends ArrayBufferView | null>(array: T): T => {
52
+ if (!array) {
53
+ return array;
54
+ }
55
+
52
56
  const buffer = Buffer.from(array.buffer);
53
57
  nodeCrypto.randomFillSync(buffer);
54
58
  return array;
@@ -103,6 +103,15 @@ export const convertCurrencyAmount = (
103
103
  from: CurrencyAmount,
104
104
  toUnit: CurrencyUnit
105
105
  ): CurrencyAmount => {
106
+ if (
107
+ from.originalUnit === CurrencyUnit.FUTURE_VALUE ||
108
+ from.originalUnit === CurrencyUnit.USD ||
109
+ toUnit === CurrencyUnit.FUTURE_VALUE ||
110
+ toUnit === CurrencyUnit.USD
111
+ ) {
112
+ throw new LightsparkException("CurrencyError", `Unsupported CurrencyUnit.`);
113
+ }
114
+
106
115
  const conversionFn = CONVERSION_MAP[from.originalUnit][toUnit];
107
116
  if (!conversionFn) {
108
117
  throw new LightsparkException(