@lightsparkdev/core 1.4.1 → 1.4.3

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.
@@ -1 +1 @@
1
- export { A as AppendUnitsOptions, ab as ById, am as Complete, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, V as CurrencyCodes, T as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, af as DeepPartial, D as DeprecatedCurrencyAmountObj, aa as ExpandRecursively, ae as ExtractByTypename, ag as JSONLiteral, ai as JSONObject, ah as JSONType, a9 as Maybe, aj as NN, ac as OmitTypename, al as PartialBy, an as RequiredKeys, S as SDKCurrencyAmountType, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, O as bytesToHex, $ as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, R as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, _ as deleteLocalStorageItem, e as ensureArray, N as errorToJSON, B as formatCurrencyStr, w as getCurrencyAmount, Q as getCurrentLocale, L as getErrorMsg, Y as getLocalStorageBoolean, X as getLocalStorageConfigItem, P as hexToBytes, G as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, J as isError, M as isErrorMsg, K as isErrorWithMessage, H as isNode, a2 as isNumber, a7 as isObject, a8 as isRecord, v as isSDKCurrencyAmount, I as isTest, ad as isType, a6 as isUint8Array, q as isUmaCurrencyAmount, a0 as linearInterpolate, W as localeToCurrencyCode, F as localeToCurrencySymbol, a5 as lsidToUUID, x as mapCurrencyAmount, ak as notNullUndefined, a3 as pollUntil, a1 as round, E as separateCurrencyStrParts, Z as setLocalStorageBoolean, a4 as sleep, u as urlsafe_b64decode } from '../index-DZbfPQqd.cjs';
1
+ export { A as AppendUnitsOptions, ad as ById, ao as Complete, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, X as CurrencyCodes, W as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ah as DeepPartial, D as DeprecatedCurrencyAmountObj, ac as ExpandRecursively, ag as ExtractByTypename, ai as JSONLiteral, ak as JSONObject, aj as JSONType, ab as Maybe, al as NN, ae as OmitTypename, an as PartialBy, ap as RequiredKeys, S as SDKCurrencyAmountType, aq as StateCode, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, Q as bytesToHex, a1 as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, V as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, a0 as deleteLocalStorageItem, e as ensureArray, P as errorToJSON, B as formatCurrencyStr, G as formatInviteAmount, w as getCurrencyAmount, T as getCurrentLocale, N as getErrorMsg, _ as getLocalStorageBoolean, Z as getLocalStorageConfigItem, R as hexToBytes, K as isBare, H as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, L as isError, O as isErrorMsg, M as isErrorWithMessage, I as isNode, a4 as isNumber, a9 as isObject, aa as isRecord, v as isSDKCurrencyAmount, J as isTest, af as isType, a8 as isUint8Array, q as isUmaCurrencyAmount, a2 as linearInterpolate, Y as localeToCurrencyCode, F as localeToCurrencySymbol, a7 as lsidToUUID, x as mapCurrencyAmount, am as notNullUndefined, a5 as pollUntil, a3 as round, E as separateCurrencyStrParts, $ as setLocalStorageBoolean, a6 as sleep, u as urlsafe_b64decode, as as zipcodeToState, ar as zipcodeToStateCode } from '../index-gUXiTlhb.cjs';
@@ -1 +1 @@
1
- export { A as AppendUnitsOptions, ab as ById, am as Complete, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, V as CurrencyCodes, T as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, af as DeepPartial, D as DeprecatedCurrencyAmountObj, aa as ExpandRecursively, ae as ExtractByTypename, ag as JSONLiteral, ai as JSONObject, ah as JSONType, a9 as Maybe, aj as NN, ac as OmitTypename, al as PartialBy, an as RequiredKeys, S as SDKCurrencyAmountType, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, O as bytesToHex, $ as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, R as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, _ as deleteLocalStorageItem, e as ensureArray, N as errorToJSON, B as formatCurrencyStr, w as getCurrencyAmount, Q as getCurrentLocale, L as getErrorMsg, Y as getLocalStorageBoolean, X as getLocalStorageConfigItem, P as hexToBytes, G as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, J as isError, M as isErrorMsg, K as isErrorWithMessage, H as isNode, a2 as isNumber, a7 as isObject, a8 as isRecord, v as isSDKCurrencyAmount, I as isTest, ad as isType, a6 as isUint8Array, q as isUmaCurrencyAmount, a0 as linearInterpolate, W as localeToCurrencyCode, F as localeToCurrencySymbol, a5 as lsidToUUID, x as mapCurrencyAmount, ak as notNullUndefined, a3 as pollUntil, a1 as round, E as separateCurrencyStrParts, Z as setLocalStorageBoolean, a4 as sleep, u as urlsafe_b64decode } from '../index-DZbfPQqd.js';
1
+ export { A as AppendUnitsOptions, ad as ById, ao as Complete, o as CurrencyAmountArg, k as CurrencyAmountInputObj, m as CurrencyAmountObj, n as CurrencyAmountPreferenceObj, X as CurrencyCodes, W as CurrencyLocales, j as CurrencyMap, f as CurrencyUnit, g as CurrencyUnitType, ah as DeepPartial, D as DeprecatedCurrencyAmountObj, ac as ExpandRecursively, ag as ExtractByTypename, ai as JSONLiteral, ak as JSONObject, aj as JSONType, ab as Maybe, al as NN, ae as OmitTypename, an as PartialBy, ap as RequiredKeys, S as SDKCurrencyAmountType, aq as StateCode, U as UmaCurrency, l as UmaCurrencyAmount, z as abbrCurrencyUnit, b as b64decode, a as b64encode, Q as bytesToHex, a1 as clamp, i as convertCurrencyAmount, h as convertCurrencyAmountValue, V as countryCodesToCurrencyCodes, c as createSha256Hash, d as defaultCurrencyCode, a0 as deleteLocalStorageItem, e as ensureArray, P as errorToJSON, B as formatCurrencyStr, G as formatInviteAmount, w as getCurrencyAmount, T as getCurrentLocale, N as getErrorMsg, _ as getLocalStorageBoolean, Z as getLocalStorageConfigItem, R as hexToBytes, K as isBare, H as isBrowser, p as isCurrencyAmountInputObj, s as isCurrencyAmountObj, t as isCurrencyAmountPreferenceObj, y as isCurrencyMap, r as isDeprecatedCurrencyAmountObj, L as isError, O as isErrorMsg, M as isErrorWithMessage, I as isNode, a4 as isNumber, a9 as isObject, aa as isRecord, v as isSDKCurrencyAmount, J as isTest, af as isType, a8 as isUint8Array, q as isUmaCurrencyAmount, a2 as linearInterpolate, Y as localeToCurrencyCode, F as localeToCurrencySymbol, a7 as lsidToUUID, x as mapCurrencyAmount, am as notNullUndefined, a5 as pollUntil, a3 as round, E as separateCurrencyStrParts, $ as setLocalStorageBoolean, a6 as sleep, u as urlsafe_b64decode, as as zipcodeToState, ar as zipcodeToStateCode } from '../index-gUXiTlhb.js';
@@ -14,12 +14,14 @@ import {
14
14
  ensureArray,
15
15
  errorToJSON,
16
16
  formatCurrencyStr,
17
+ formatInviteAmount,
17
18
  getCurrencyAmount,
18
19
  getCurrentLocale,
19
20
  getErrorMsg,
20
21
  getLocalStorageBoolean,
21
22
  getLocalStorageConfigItem,
22
23
  hexToBytes,
24
+ isBare,
23
25
  isBrowser,
24
26
  isCurrencyAmountInputObj,
25
27
  isCurrencyAmountObj,
@@ -49,8 +51,10 @@ import {
49
51
  separateCurrencyStrParts,
50
52
  setLocalStorageBoolean,
51
53
  sleep,
52
- urlsafe_b64decode
53
- } from "../chunk-NV53XYAS.js";
54
+ urlsafe_b64decode,
55
+ zipcodeToState,
56
+ zipcodeToStateCode
57
+ } from "../chunk-36QHRQJC.js";
54
58
  export {
55
59
  CurrencyUnit,
56
60
  abbrCurrencyUnit,
@@ -67,12 +71,14 @@ export {
67
71
  ensureArray,
68
72
  errorToJSON,
69
73
  formatCurrencyStr,
74
+ formatInviteAmount,
70
75
  getCurrencyAmount,
71
76
  getCurrentLocale,
72
77
  getErrorMsg,
73
78
  getLocalStorageBoolean,
74
79
  getLocalStorageConfigItem,
75
80
  hexToBytes,
81
+ isBare,
76
82
  isBrowser,
77
83
  isCurrencyAmountInputObj,
78
84
  isCurrencyAmountObj,
@@ -102,5 +108,7 @@ export {
102
108
  separateCurrencyStrParts,
103
109
  setLocalStorageBoolean,
104
110
  sleep,
105
- urlsafe_b64decode
111
+ urlsafe_b64decode,
112
+ zipcodeToState,
113
+ zipcodeToStateCode
106
114
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightsparkdev/core",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Lightspark JS SDK",
5
5
  "author": "Lightspark Inc.",
6
6
  "keywords": [
@@ -4,7 +4,6 @@ import autoBind from "auto-bind";
4
4
  import dayjs from "dayjs";
5
5
  import utc from "dayjs/plugin/utc.js";
6
6
  import type { Client as WsClient } from "graphql-ws";
7
- import { createClient } from "graphql-ws";
8
7
  import { Observable } from "zen-observable-ts";
9
8
 
10
9
  import type Query from "./Query.js";
@@ -18,7 +17,7 @@ import type { SigningKey } from "../crypto/SigningKey.js";
18
17
  import LightsparkException from "../LightsparkException.js";
19
18
  import { logger } from "../Logger.js";
20
19
  import { b64encode } from "../utils/base64.js";
21
- import { isNode } from "../utils/environment.js";
20
+ import { isBare, isNode } from "../utils/environment.js";
22
21
 
23
22
  const DEFAULT_BASE_URL = "api.lightspark.com";
24
23
  dayjs.extend(utc);
@@ -32,8 +31,8 @@ type BodyData = {
32
31
  };
33
32
 
34
33
  class Requester {
35
- private wsClient: Promise<WsClient>;
36
- private resolveWsClient: ((value: WsClient) => void) | null = null;
34
+ private wsClient: Promise<WsClient | null>;
35
+ private resolveWsClient: ((value: WsClient | null) => void) | null = null;
37
36
  constructor(
38
37
  private readonly nodeKeyCache: NodeKeyCache,
39
38
  private readonly schemaEndpoint: string,
@@ -44,7 +43,7 @@ class Requester {
44
43
  private readonly signingKey?: SigningKey,
45
44
  private readonly fetchImpl: typeof fetch = fetch,
46
45
  ) {
47
- this.wsClient = new Promise<WsClient>((resolve) => {
46
+ this.wsClient = new Promise<WsClient | null>((resolve) => {
48
47
  this.resolveWsClient = resolve;
49
48
  });
50
49
  void this.initWsClient(baseUrl, authProvider);
@@ -57,6 +56,11 @@ class Requester {
57
56
  return this.wsClient;
58
57
  }
59
58
 
59
+ if (isBare) {
60
+ /* graphql-ws library is currently not supported in Bare environment, see LIG-7942 */
61
+ return null;
62
+ }
63
+
60
64
  let websocketImpl;
61
65
  if (isNode && typeof WebSocket === "undefined") {
62
66
  const wsModule = await import("ws");
@@ -67,6 +71,9 @@ class Requester {
67
71
  websocketProtocol = "ws";
68
72
  }
69
73
 
74
+ const graphqlWsModule = await import("graphql-ws");
75
+ const { createClient } = graphqlWsModule;
76
+
70
77
  const wsClient = createClient({
71
78
  url: `${websocketProtocol}://${this.stripProtocol(this.baseUrl)}/${
72
79
  this.schemaEndpoint
@@ -99,6 +106,7 @@ class Requester {
99
106
  variables: { [key: string]: unknown } = {},
100
107
  ) {
101
108
  logger.trace(`Requester.subscribe variables`, variables);
109
+
102
110
  const operationNameRegex = /^\s*(query|mutation|subscription)\s+(\w+)/i;
103
111
  const operationMatch = queryPayload.match(operationNameRegex);
104
112
  if (!operationMatch || operationMatch.length < 3) {
@@ -134,6 +142,15 @@ class Requester {
134
142
  void (async () => {
135
143
  try {
136
144
  const wsClient = await this.wsClient;
145
+
146
+ if (!wsClient) {
147
+ /* graphql-ws library is currently not supported in Bare environment, see LIG-7942 */
148
+ throw new LightsparkException(
149
+ "WebSocketNotInitialized",
150
+ "WebSocket client is not initialized or is not available in the current environment.",
151
+ );
152
+ }
153
+
137
154
  if (!canceled) {
138
155
  cleanup = wsClient.subscribe(bodyData, {
139
156
  next: (data) => observer.next(data as { data: T }),
@@ -22,6 +22,8 @@ export const CurrencyUnit = {
22
22
  MXN: "MXN",
23
23
  PHP: "PHP",
24
24
  EUR: "EUR",
25
+ GBP: "GBP",
26
+ INR: "INR",
25
27
 
26
28
  Bitcoin: "BITCOIN",
27
29
  Microbitcoin: "MICROBITCOIN",
@@ -32,6 +34,8 @@ export const CurrencyUnit = {
32
34
  Usd: "USD",
33
35
  Mxn: "MXN",
34
36
  Php: "PHP",
37
+ Gbp: "GBP",
38
+ Inr: "INR",
35
39
  } as const;
36
40
 
37
41
  export type CurrencyUnitType = (typeof CurrencyUnit)[keyof typeof CurrencyUnit];
@@ -61,6 +65,8 @@ const standardUnitConversionObj = {
61
65
  [CurrencyUnit.MXN]: (v: number) => v,
62
66
  [CurrencyUnit.PHP]: (v: number) => v,
63
67
  [CurrencyUnit.EUR]: (v: number) => v,
68
+ [CurrencyUnit.GBP]: (v: number) => v,
69
+ [CurrencyUnit.INR]: (v: number) => v,
64
70
  };
65
71
 
66
72
  /* Round without decimals since we're returning cents: */
@@ -89,6 +95,8 @@ const CONVERSION_MAP = {
89
95
  [CurrencyUnit.MXN]: toBitcoinConversion,
90
96
  [CurrencyUnit.PHP]: toBitcoinConversion,
91
97
  [CurrencyUnit.EUR]: toBitcoinConversion,
98
+ [CurrencyUnit.GBP]: toBitcoinConversion,
99
+ [CurrencyUnit.INR]: toBitcoinConversion,
92
100
  },
93
101
  [CurrencyUnit.MICROBITCOIN]: {
94
102
  [CurrencyUnit.BITCOIN]: (v: number) => v / 1_000_000,
@@ -101,6 +109,8 @@ const CONVERSION_MAP = {
101
109
  [CurrencyUnit.MXN]: toMicrobitcoinConversion,
102
110
  [CurrencyUnit.PHP]: toMicrobitcoinConversion,
103
111
  [CurrencyUnit.EUR]: toMicrobitcoinConversion,
112
+ [CurrencyUnit.GBP]: toMicrobitcoinConversion,
113
+ [CurrencyUnit.INR]: toMicrobitcoinConversion,
104
114
  },
105
115
  [CurrencyUnit.MILLIBITCOIN]: {
106
116
  [CurrencyUnit.BITCOIN]: (v: number) => v / 1_000,
@@ -113,6 +123,8 @@ const CONVERSION_MAP = {
113
123
  [CurrencyUnit.MXN]: toMillibitcoinConversion,
114
124
  [CurrencyUnit.PHP]: toMillibitcoinConversion,
115
125
  [CurrencyUnit.EUR]: toMillibitcoinConversion,
126
+ [CurrencyUnit.GBP]: toMillibitcoinConversion,
127
+ [CurrencyUnit.INR]: toMillibitcoinConversion,
116
128
  },
117
129
  [CurrencyUnit.MILLISATOSHI]: {
118
130
  [CurrencyUnit.BITCOIN]: (v: number) => v / 100_000_000_000,
@@ -125,6 +137,8 @@ const CONVERSION_MAP = {
125
137
  [CurrencyUnit.MXN]: toMillisatoshiConversion,
126
138
  [CurrencyUnit.PHP]: toMillisatoshiConversion,
127
139
  [CurrencyUnit.EUR]: toMillisatoshiConversion,
140
+ [CurrencyUnit.GBP]: toMillisatoshiConversion,
141
+ [CurrencyUnit.INR]: toMillisatoshiConversion,
128
142
  },
129
143
  [CurrencyUnit.NANOBITCOIN]: {
130
144
  [CurrencyUnit.BITCOIN]: (v: number) => v / 1_000_000_000,
@@ -137,6 +151,8 @@ const CONVERSION_MAP = {
137
151
  [CurrencyUnit.MXN]: toNanobitcoinConversion,
138
152
  [CurrencyUnit.PHP]: toNanobitcoinConversion,
139
153
  [CurrencyUnit.EUR]: toNanobitcoinConversion,
154
+ [CurrencyUnit.GBP]: toNanobitcoinConversion,
155
+ [CurrencyUnit.INR]: toNanobitcoinConversion,
140
156
  },
141
157
  [CurrencyUnit.SATOSHI]: {
142
158
  [CurrencyUnit.BITCOIN]: (v: number) => v / 100_000_000,
@@ -149,11 +165,15 @@ const CONVERSION_MAP = {
149
165
  [CurrencyUnit.MXN]: toSatoshiConversion,
150
166
  [CurrencyUnit.PHP]: toSatoshiConversion,
151
167
  [CurrencyUnit.EUR]: toSatoshiConversion,
168
+ [CurrencyUnit.GBP]: toSatoshiConversion,
169
+ [CurrencyUnit.INR]: toSatoshiConversion,
152
170
  },
153
171
  [CurrencyUnit.USD]: standardUnitConversionObj,
154
172
  [CurrencyUnit.MXN]: standardUnitConversionObj,
155
173
  [CurrencyUnit.PHP]: standardUnitConversionObj,
156
174
  [CurrencyUnit.EUR]: standardUnitConversionObj,
175
+ [CurrencyUnit.GBP]: standardUnitConversionObj,
176
+ [CurrencyUnit.INR]: standardUnitConversionObj,
157
177
  };
158
178
 
159
179
  export function convertCurrencyAmountValue(
@@ -219,6 +239,8 @@ export type CurrencyMap = {
219
239
  [CurrencyUnit.MXN]: number;
220
240
  [CurrencyUnit.PHP]: number;
221
241
  [CurrencyUnit.EUR]: number;
242
+ [CurrencyUnit.GBP]: number;
243
+ [CurrencyUnit.INR]: number;
222
244
  [CurrencyUnit.FUTURE_VALUE]: number;
223
245
  formatted: {
224
246
  sats: string;
@@ -234,6 +256,8 @@ export type CurrencyMap = {
234
256
  [CurrencyUnit.MXN]: string;
235
257
  [CurrencyUnit.PHP]: string;
236
258
  [CurrencyUnit.EUR]: string;
259
+ [CurrencyUnit.GBP]: string;
260
+ [CurrencyUnit.INR]: string;
237
261
  [CurrencyUnit.FUTURE_VALUE]: string;
238
262
  };
239
263
  isZero: boolean;
@@ -430,6 +454,8 @@ function convertCurrencyAmountValues(
430
454
  mxn: CurrencyUnit.MXN,
431
455
  php: CurrencyUnit.PHP,
432
456
  eur: CurrencyUnit.EUR,
457
+ gbp: CurrencyUnit.GBP,
458
+ inr: CurrencyUnit.INR,
433
459
  mibtc: CurrencyUnit.MICROBITCOIN,
434
460
  mlbtc: CurrencyUnit.MILLIBITCOIN,
435
461
  nbtc: CurrencyUnit.NANOBITCOIN,
@@ -479,7 +505,7 @@ export function mapCurrencyAmount(
479
505
  * preferred_currency_unit on CurrencyAmount types: */
480
506
  const conversionOverride = getPreferredConversionOverride(currencyAmountArg);
481
507
 
482
- const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur } =
508
+ const { sats, msats, btc, usd, mxn, php, mibtc, mlbtc, nbtc, eur, gbp, inr } =
483
509
  convertCurrencyAmountValues(unit, value, unitsPerBtc, conversionOverride);
484
510
 
485
511
  const mapWithCurrencyUnits = {
@@ -490,6 +516,8 @@ export function mapCurrencyAmount(
490
516
  [CurrencyUnit.MXN]: mxn,
491
517
  [CurrencyUnit.PHP]: php,
492
518
  [CurrencyUnit.EUR]: eur,
519
+ [CurrencyUnit.GBP]: gbp,
520
+ [CurrencyUnit.INR]: inr,
493
521
  [CurrencyUnit.MICROBITCOIN]: mibtc,
494
522
  [CurrencyUnit.MILLIBITCOIN]: mlbtc,
495
523
  [CurrencyUnit.NANOBITCOIN]: nbtc,
@@ -535,6 +563,14 @@ export function mapCurrencyAmount(
535
563
  value: eur,
536
564
  unit: CurrencyUnit.EUR,
537
565
  }),
566
+ [CurrencyUnit.GBP]: formatCurrencyStr({
567
+ value: gbp,
568
+ unit: CurrencyUnit.GBP,
569
+ }),
570
+ [CurrencyUnit.INR]: formatCurrencyStr({
571
+ value: inr,
572
+ unit: CurrencyUnit.INR,
573
+ }),
538
574
  [CurrencyUnit.FUTURE_VALUE]: "-",
539
575
  },
540
576
  };
@@ -611,6 +647,10 @@ export const abbrCurrencyUnit = (unit: CurrencyUnitType) => {
611
647
  return "PHP";
612
648
  case CurrencyUnit.EUR:
613
649
  return "EUR";
650
+ case CurrencyUnit.GBP:
651
+ return "GBP";
652
+ case CurrencyUnit.INR:
653
+ return "INR";
614
654
  }
615
655
  return "Unsupported CurrencyUnit";
616
656
  };
@@ -665,6 +705,7 @@ export function formatCurrencyStr(
665
705
  CurrencyUnit.MXN,
666
706
  CurrencyUnit.PHP,
667
707
  CurrencyUnit.EUR,
708
+ CurrencyUnit.GBP,
668
709
  ] as string[];
669
710
  /* centCurrencies are always provided in the smallest unit, e.g. cents for USD. These should be
670
711
  * divided by 100 for proper display format: */
@@ -804,3 +845,24 @@ export function localeToCurrencySymbol(locale: string) {
804
845
  const { symbol } = separateCurrencyStrParts(formatted);
805
846
  return symbol;
806
847
  }
848
+
849
+ /**
850
+ * Formats an amount from the smallest currency unit to a display string
851
+ * @param amount - The amount in the smallest currency unit (No decimals)
852
+ * @param currency - The currency object with code and decimals
853
+ * @returns Formatted string like "12.50 USD" or empty string if invalid
854
+ */
855
+ export function formatInviteAmount(
856
+ amount: number | null | undefined,
857
+ currency: UmaCurrency | null | undefined,
858
+ ): string {
859
+ if (!amount || !currency) {
860
+ return "";
861
+ }
862
+
863
+ const displayAmount = (amount / Math.pow(10, currency.decimals)).toFixed(
864
+ currency.decimals,
865
+ );
866
+
867
+ return `${displayAmount} ${currency.code}`;
868
+ }
@@ -1,3 +1,7 @@
1
+ declare global {
2
+ const Bare: unknown;
3
+ }
4
+
1
5
  export const isBrowser =
2
6
  typeof window !== "undefined" && typeof window.document !== "undefined";
3
7
 
@@ -7,3 +11,6 @@ export const isNode =
7
11
  process.versions.node != null;
8
12
 
9
13
  export const isTest = isNode && process.env.NODE_ENV === "test";
14
+
15
+ /* https://github.com/holepunchto/which-runtime/blob/main/index.js */
16
+ export const isBare = typeof Bare !== "undefined";
@@ -16,3 +16,4 @@ export * from "./sleep.js";
16
16
  export * from "./strings.js";
17
17
  export * from "./typeGuards.js";
18
18
  export * from "./types.js";
19
+ export * from "./zipcodeToState.js";