@vellumai/credential-executor 0.11.1 → 0.11.2-dev.202608042257.9e99b1d

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/Dockerfile CHANGED
@@ -19,9 +19,7 @@ ENV PATH="/root/.bun/bin:${PATH}"
19
19
  # Note that we don't need source code to resolve cross-workspace dependencies.
20
20
  COPY package.json bun.lock ./
21
21
  COPY patches ./patches
22
- COPY clients/docs/package.json ./clients/docs/
23
- COPY clients/macos/package.json ./clients/macos/
24
- COPY clients/web/package.json ./clients/web/
22
+ COPY --parents clients/*/package.json ./
25
23
  COPY cli/package.json ./cli/
26
24
  COPY gateway/package.json ./gateway/
27
25
  COPY credential-executor/package.json ./credential-executor/
@@ -19,6 +19,7 @@
19
19
  "./attachment-naming": "./src/attachment-naming.ts",
20
20
  "./redacted-credential": "./src/redacted-credential.ts",
21
21
  "./secret-detection": "./src/secret-detection.ts",
22
+ "./stripe-currency": "./src/stripe-currency.ts",
22
23
  "./error": "./src/error.ts"
23
24
  },
24
25
  "scripts": {
@@ -0,0 +1,37 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import {
4
+ STRIPE_THREE_DECIMAL_CURRENCIES,
5
+ STRIPE_ZERO_DECIMAL_CURRENCIES,
6
+ stripeScaleDigits,
7
+ } from "../stripe-currency.js";
8
+
9
+ describe("stripeScaleDigits", () => {
10
+ test("zero-decimal currencies scale to 0 digits", () => {
11
+ expect(stripeScaleDigits("JPY")).toBe(0);
12
+ expect(stripeScaleDigits("KRW")).toBe(0);
13
+ });
14
+
15
+ test("three-decimal currencies scale to 3 digits", () => {
16
+ expect(stripeScaleDigits("BHD")).toBe(3);
17
+ expect(stripeScaleDigits("KWD")).toBe(3);
18
+ });
19
+
20
+ test("everything else scales to 2 digits", () => {
21
+ expect(stripeScaleDigits("USD")).toBe(2);
22
+ expect(stripeScaleDigits("EUR")).toBe(2);
23
+ expect(stripeScaleDigits("XYZ")).toBe(2);
24
+ });
25
+
26
+ test("Stripe's charge-side two-decimal special cases stay at 2 digits", () => {
27
+ for (const code of ["ISK", "HUF", "TWD", "UGX"]) {
28
+ expect(stripeScaleDigits(code)).toBe(2);
29
+ }
30
+ });
31
+
32
+ test("the currency sets do not overlap", () => {
33
+ for (const code of STRIPE_ZERO_DECIMAL_CURRENCIES) {
34
+ expect(STRIPE_THREE_DECIMAL_CURRENCIES.has(code)).toBe(false);
35
+ }
36
+ });
37
+ });
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Stripe amount scaling rules for charges and invoices.
3
+ *
4
+ * These sets follow Stripe's amount scaling rules
5
+ * (https://docs.stripe.com/currencies), not ISO 4217 metadata: divide the
6
+ * minor-unit integer by 100 for most currencies, by 1 for the zero-decimal
7
+ * set (e.g. JPY, KRW), and by 1000 for the three-decimal set (e.g. BHD).
8
+ * ISK, HUF, TWD, and UGX are deliberately absent from the zero-decimal set:
9
+ * Stripe charges and invoices them as two-decimal amounts and treats them
10
+ * as zero-decimal only for payouts, per Stripe's currency docs.
11
+ *
12
+ * Only the scaling data and digit selection live here; presentation (locale,
13
+ * symbol vs code display, fallbacks for unknown codes) belongs to each
14
+ * consumer.
15
+ */
16
+ export const STRIPE_ZERO_DECIMAL_CURRENCIES: ReadonlySet<string> = new Set([
17
+ "BIF",
18
+ "CLP",
19
+ "DJF",
20
+ "GNF",
21
+ "JPY",
22
+ "KMF",
23
+ "KRW",
24
+ "MGA",
25
+ "PYG",
26
+ "RWF",
27
+ "VND",
28
+ "VUV",
29
+ "XAF",
30
+ "XOF",
31
+ "XPF",
32
+ ]);
33
+
34
+ export const STRIPE_THREE_DECIMAL_CURRENCIES: ReadonlySet<string> = new Set([
35
+ "BHD",
36
+ "JOD",
37
+ "KWD",
38
+ "OMR",
39
+ "TND",
40
+ ]);
41
+
42
+ /**
43
+ * Fraction digits Stripe uses when charging or invoicing in the given
44
+ * currency. Expects an uppercase ISO 4217 code; unknown codes get the
45
+ * two-decimal default.
46
+ */
47
+ export function stripeScaleDigits(currencyCode: string): number {
48
+ if (STRIPE_ZERO_DECIMAL_CURRENCIES.has(currencyCode)) {
49
+ return 0;
50
+ }
51
+ if (STRIPE_THREE_DECIMAL_CURRENCIES.has(currencyCode)) {
52
+ return 3;
53
+ }
54
+ return 2;
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/credential-executor",
3
- "version": "0.11.1",
3
+ "version": "0.11.2-dev.202608042257.9e99b1d",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {