@jini-ai/capability-providers 0.6.11 → 0.6.15-rc.1

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,23 @@
1
1
  # @jini-ai/capability-providers
2
2
 
3
+ ## 0.6.13
4
+
5
+ ### Patch Changes
6
+
7
+ - 31819c8: The Stripe `PaymentsProvider` adapter moved unchanged out of `@jini-ai/capability-providers` into the `payments-stripe` provider plugin (move only: commerce's payment contract is canonical, conversion is deferred, and no host selects or activates it). Removed: the `@jini-ai/capability-providers/adapters/stripe` subpath. The hardwiring check treats `provider-plugins/` sources as provider adapters.
8
+ - Updated dependencies [7479159]
9
+ - Updated dependencies [c31264d]
10
+ - Updated dependencies [0728914]
11
+ - Updated dependencies [6ecbdb2]
12
+ - Updated dependencies [63bacc5]
13
+ - @jini-ai/core@0.6.13
14
+
15
+ ## 0.6.12
16
+
17
+ ### Patch Changes
18
+
19
+ - @jini-ai/core@0.6.12
20
+
3
21
  ## 0.6.11
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -3,28 +3,13 @@
3
3
  ## Integration update (2026-10-01)
4
4
 
5
5
  The existing exports and entry runtimes cover all reported subpaths: `.`, `./visitor-auth`,
6
- `./unsafe-reference`, and the five `./adapters/*` entries. No new exports or dependencies are needed.
6
+ `./unsafe-reference`, and the four `./adapters/*` entries. (`./adapters/stripe` moved to the
7
+ `payments-stripe` provider plugin in `@jini-ai/provider-plugins` on 2026-10-25.)
7
8
  The non-DB APIs use required/optional argument objects; the remaining DB conversion belongs to the
8
9
  active DB lane and remains deferred across the port and both implementations together.
9
10
 
10
- ```ts
11
- const stripe = new StripePaymentsProvider(
12
- { secretKey },
13
- { fetchFn, apiBase, now: () => Date.now() },
14
- );
15
- await stripe.getCharge({ id });
16
- await stripe.charge(
17
- { amountCents: 1000, currency: 'usd', customerRef },
18
- { description: 'Order payment' },
19
- );
20
- ```
21
-
22
11
  Provider tokens use core's `token({ id })` factory and retain their existing IDs.
23
- Stripe error metadata includes `stripeType` and `stripeCode` only when supplied by the response.
24
-
25
- The universal Stripe adapter now uses UTF-8 plus native base64 encoding for Basic auth and an
26
- injected clock when a response omits `created`. Successful response timestamps and HTTP payloads
27
- retain their existing meaning. Neutrality guards inspect every production source extension and
12
+ Neutrality guards inspect every production source extension and
28
13
  reject application references in comments as well as imports.
29
14
  Verification is not run (owner directive); see INTEGRATION-REPORT.md.
30
15
 
@@ -81,9 +66,8 @@ you want at composition time; a pack declaring one of these in its `deps` gets i
81
66
  - `./adapters/blob-storage` — `BlobStorageProvider` / `BlobStorageProviderOptions`. Delegates to an
82
67
  injected `@jini-ai/platform` `BlobStorage` (`LocalBlobStorage` or `S3BlobStorage`), scoped to one
83
68
  namespace. `StoragePutOptions.contentType` is echoed back but not durably persisted.
84
- - `./adapters/stripe` — `StripePaymentsProvider` / `StripePaymentsProviderOptions` /
85
- `StripePaymentsProviderError`. Real Stripe REST calls; the secret key is an explicit constructor
86
- argument, never read from an environment variable inside the adapter.
69
+ - Stripe (`StripePaymentsProvider`) is no longer here: it is the `payments-stripe` provider plugin in
70
+ `@jini-ai/provider-plugins` (moved only; commerce's payment contract is canonical).
87
71
  - `./adapters/sqlite` — `SqliteDbProvider`, constructed from a `better-sqlite3` `Database` you own
88
72
  and open. Creates its own `jini_capability_db_records` table.
89
73
  - `./adapters/ws` — `WebSocketRealtimeProvider`, `createWebSocketRealtimeProvider`, and the
@@ -145,7 +129,6 @@ const session = await daemon.services.account.auth.signIn({
145
129
  | `./unsafe-reference` | Non-production in-memory stubs. See the warning above. | none |
146
130
  | `./adapters/jwt-auth` | `JwtAuthProvider` (HS256 sessions, `scrypt` hashing, in-memory users). | none (`node:crypto`) |
147
131
  | `./adapters/blob-storage` | `BlobStorageProvider` over an injected `@jini-ai/platform` `BlobStorage`. | none |
148
- | `./adapters/stripe` | `StripePaymentsProvider` (real Stripe REST). | none (`fetch`) |
149
132
  | `./adapters/sqlite` | `SqliteDbProvider` over a caller-owned `Database` handle. | `better-sqlite3` (native) |
150
133
  | `./adapters/ws` | `WebSocketRealtimeProvider` + `createWebSocketRealtimeProvider`. | `ws` |
151
134
 
@@ -154,7 +137,7 @@ const session = await daemon.services.account.auth.signIn({
154
137
  Everything, by design — that is the package's whole reason to exist. Each of the five interfaces is a
155
138
  port you can implement against any vendor (Supabase, Auth0, S3, Postgres, Pusher) and bind through
156
139
  the matching token with no change at the consumer. Within the shipped adapters, the injectable seams
157
- are real too: `StripePaymentsProvider` takes `fetchFn`/`apiBase`, `JwtAuthProvider` takes `now` and
140
+ are real too: `JwtAuthProvider` takes `now` and
158
141
  `sessionTtlMs`, `BlobStorageProvider` takes the `BlobStorage` instance, `SqliteDbProvider` takes the
159
142
  open database handle, and `WebSocketRealtimeProvider` accepts an injected server object so tests need
160
143
  no real socket. Composition — pairing, say, `JwtAuthProvider` with a durable user store — happens at
@@ -163,7 +146,7 @@ the binding site, deliberately not inside this package.
163
146
  ## Runtime
164
147
 
165
148
  `jini.runtime: "universal"` for the root entry point and `./unsafe-reference`. Per-entry:
166
- `./adapters/stripe` is universal (`fetch` only); `./adapters/ws`, `./adapters/sqlite`,
149
+ `./adapters/ws`, `./adapters/sqlite`,
167
150
  `./adapters/blob-storage`, and `./adapters/jwt-auth` are Node-only.
168
151
  ESM only — ships `"type": "module"` with no CommonJS `require` build.
169
152
 
@@ -155,7 +155,8 @@ export class JwtAuthProvider {
155
155
  sub: user.id,
156
156
  jti: randomBytes(16).toString('hex'),
157
157
  iat: Math.floor(nowMs / 1000),
158
- exp: Math.floor(expiresAt / 1000),
158
+ // JWT seconds must cover the full millisecond lifetime advertised by expiresAt.
159
+ exp: Math.ceil(expiresAt / 1000),
159
160
  }, this.secret);
160
161
  return { token, userId: user.id, expiresAt };
161
162
  }
@@ -3,9 +3,10 @@
3
3
  *
4
4
  * This file defines the port's stable interface/type surface and nothing else —
5
5
  * it has no imports at all, so a consumer implementing `PaymentsProvider`
6
- * themselves installs nothing. The one real, production-quality adapter
7
- * (`StripePaymentsProvider`, against Stripe's Charges/Refunds REST API) lives
8
- * at the separate `@jini-ai/capability-providers/adapters/stripe` entry point;
6
+ * themselves installs nothing. The Stripe adapter (`StripePaymentsProvider`,
7
+ * against Stripe's Charges/Refunds REST API) moved to the `payments-stripe`
8
+ * provider plugin in `@jini-ai/provider-plugins` (2026-10-25, move only: commerce's
9
+ * payment contract is canonical and conversion is deferred);
9
10
  * the non-production in-memory reference stub
10
11
  * (`createInMemoryPaymentsProvider`) lives under `src/unsafe-reference/`,
11
12
  * exported only from `@jini-ai/capability-providers/unsafe-reference`.
package/dist/payments.js CHANGED
@@ -3,9 +3,10 @@
3
3
  *
4
4
  * This file defines the port's stable interface/type surface and nothing else —
5
5
  * it has no imports at all, so a consumer implementing `PaymentsProvider`
6
- * themselves installs nothing. The one real, production-quality adapter
7
- * (`StripePaymentsProvider`, against Stripe's Charges/Refunds REST API) lives
8
- * at the separate `@jini-ai/capability-providers/adapters/stripe` entry point;
6
+ * themselves installs nothing. The Stripe adapter (`StripePaymentsProvider`,
7
+ * against Stripe's Charges/Refunds REST API) moved to the `payments-stripe`
8
+ * provider plugin in `@jini-ai/provider-plugins` (2026-10-25, move only: commerce's
9
+ * payment contract is canonical and conversion is deferred);
9
10
  * the non-production in-memory reference stub
10
11
  * (`createInMemoryPaymentsProvider`) lives under `src/unsafe-reference/`,
11
12
  * exported only from `@jini-ai/capability-providers/unsafe-reference`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jini-ai/capability-providers",
3
- "version": "0.6.11",
3
+ "version": "0.6.15-rc.1",
4
4
  "description": "Swappable capability-provider ports (auth, storage, payments, db, realtime) as interfaces and DI tokens only; concrete adapters live behind ./adapters/* subpaths.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -20,7 +20,6 @@
20
20
  "./adapters/sqlite": "node",
21
21
  "./adapters/blob-storage": "node",
22
22
  "./adapters/jwt-auth": "node",
23
- "./adapters/stripe": "universal",
24
23
  "./comments": "universal"
25
24
  },
26
25
  "isolation": {
@@ -28,8 +27,7 @@
28
27
  "./adapters/ws": "realtime",
29
28
  "./adapters/sqlite": "db",
30
29
  "./adapters/blob-storage": "storage",
31
- "./adapters/jwt-auth": "auth",
32
- "./adapters/stripe": "payments"
30
+ "./adapters/jwt-auth": "auth"
33
31
  }
34
32
  }
35
33
  },
@@ -73,11 +71,6 @@
73
71
  "import": "./dist/adapters/jwt-auth/index.js",
74
72
  "default": "./dist/adapters/jwt-auth/index.js"
75
73
  },
76
- "./adapters/stripe": {
77
- "types": "./dist/adapters/stripe/index.d.ts",
78
- "import": "./dist/adapters/stripe/index.js",
79
- "default": "./dist/adapters/stripe/index.js"
80
- },
81
74
  "./comments": {
82
75
  "types": "./dist/comments/index.d.ts",
83
76
  "import": "./dist/comments/index.js",
@@ -101,12 +94,12 @@
101
94
  "registry": "https://registry.npmjs.org"
102
95
  },
103
96
  "dependencies": {
104
- "@jini-ai/core": "^0.6.11"
97
+ "@jini-ai/core": "^0.6.15-rc.1"
105
98
  },
106
99
  "peerDependencies": {
107
100
  "better-sqlite3": "^13.0.0",
108
101
  "ws": "^8.18.0",
109
- "@jini-ai/platform": "^0.6.10"
102
+ "@jini-ai/platform": "^0.6.15-rc.1"
110
103
  },
111
104
  "peerDependenciesMeta": {
112
105
  "better-sqlite3": {
@@ -125,8 +118,8 @@
125
118
  "@vitest/coverage-v8": "^2.1.9",
126
119
  "better-sqlite3": "^13.0.0",
127
120
  "ws": "^8.18.0",
128
- "@jini-ai/platform": "0.6.11",
129
- "@jini-ai/core": "0.6.11"
121
+ "@jini-ai/core": "0.6.15-rc.1",
122
+ "@jini-ai/platform": "0.6.15-rc.1"
130
123
  },
131
124
  "scripts": {
132
125
  "build": "tsc -p tsconfig.json",
@@ -1,94 +0,0 @@
1
- /**
2
- * `@jini-ai/capability-providers/adapters/stripe` — the one real,
3
- * production-quality `PaymentsProvider` adapter this package ships, against
4
- * Stripe's real, documented Charges/Refunds REST API
5
- * (`https://docs.stripe.com/api/charges`, `https://docs.stripe.com/api/refunds`)
6
- * — verified against Stripe's own docs while building this, not guessed from
7
- * memory (request shape, Basic auth over the secret key, form-encoded body,
8
- * JSON error envelope).
9
- *
10
- * Lives at this separate entry point (not the package's main
11
- * `@jini-ai/capability-providers` barrel) so importing the port
12
- * interface/types/DI tokens never pulls a vendor-specific HTTP client into a
13
- * consumer that only wanted the `PaymentsProvider` interface to implement
14
- * itself against a different processor. Import from here only when you actually
15
- * want this concrete adapter.
16
- *
17
- * The in-memory reference implementation (`createInMemoryPaymentsProvider`) is
18
- * a separate, non-production stub under `src/unsafe-reference/` — see that
19
- * directory's `index.ts` header for the full warning.
20
- */
21
- import type { Charge, ChargeInput, PaymentsProvider } from '../../payments.js';
22
- /** Error thrown by {@link StripePaymentsProvider}, carrying Stripe's own error envelope fields (`https://docs.stripe.com/api/errors`) when the failure came from a Stripe API response. */
23
- export declare class StripePaymentsProviderError extends Error {
24
- /** The HTTP status Stripe (or a local pre-flight check) returned. */
25
- readonly status: number;
26
- /** Stripe's `error.type` — one of `api_error`, `card_error`, `idempotency_error`, `invalid_request_error`. Undefined for a local pre-flight rejection (e.g. a non-positive amount) that never reached Stripe. */
27
- readonly stripeType?: string;
28
- /** Stripe's `error.code`, when present. */
29
- readonly stripeCode?: string;
30
- constructor({ message, status }: {
31
- message: string;
32
- status: number;
33
- }, { stripeType, stripeCode }?: {
34
- stripeType?: string;
35
- stripeCode?: string;
36
- });
37
- }
38
- export interface StripePaymentsProviderOptions {
39
- /** Stripe secret key (`sk_live_...`/`sk_test_...`). Required and explicit — never read from an environment variable inside this adapter. */
40
- readonly secretKey: string;
41
- }
42
- export interface StripePaymentsProviderOptionalArgs {
43
- /** Clock used when a response omits its creation timestamp. */
44
- readonly now?: () => number;
45
- /** Pluggable fetch for tests. Defaults to `globalThis.fetch`, matching `S3BlobStorage`/`netlify.ts`'s precedent in this repo. */
46
- readonly fetchFn?: typeof fetch;
47
- /** Overrides Stripe's API base URL. Tests only — production leaves this unset. */
48
- readonly apiBase?: string;
49
- }
50
- /**
51
- * `PaymentsProvider` adapter against Stripe's real Charges/Refunds REST API. No mock/simulated
52
- * money movement — every `charge`/`getCharge`/`refund` call is a real HTTP request to
53
- * `api.stripe.com` (or `optional.apiBase` in tests), authenticated the way Stripe's own docs
54
- * specify: HTTP Basic auth with the secret key as the username and an empty password
55
- * (`Authorization: Basic base64("sk_...:")`), request bodies form-encoded
56
- * (`application/x-www-form-urlencoded`), not JSON.
57
- *
58
- * `ChargeInput.customerRef` is sent as Stripe's `customer` parameter — this adapter always
59
- * charges an existing Stripe Customer (who must already have a default/attached payment method),
60
- * never a one-off `source`/token; `ChargeInput` has no field for a raw card token, and inventing
61
- * one wasn't part of this port's brief.
62
- */
63
- export declare class StripePaymentsProvider implements PaymentsProvider {
64
- private readonly options;
65
- private readonly fetchFn;
66
- private readonly apiBase;
67
- private readonly now;
68
- constructor(options: StripePaymentsProviderOptions, optional?: StripePaymentsProviderOptionalArgs);
69
- charge(input: ChargeInput, optional?: {
70
- description?: string;
71
- }): Promise<Charge>;
72
- getCharge({ id }: {
73
- id: string;
74
- }): Promise<Charge | null>;
75
- /**
76
- * `PaymentsProvider.refund` returns a completed `Charge`, but a real Stripe `Refund` object's
77
- * own `status` can be `'succeeded'`, `'pending'` (common for bank-sourced refunds that settle
78
- * over days), `'failed'`, or `'canceled'` — a richer state machine than this port's
79
- * `ChargeStatus` has room for. Since `ChargeStatus` has no "refund in flight" state, `'pending'`
80
- * is treated the same as `'succeeded'` here (Stripe accepted the refund; it will settle) and
81
- * only `'failed'`/`'canceled'` reject. A host that needs to distinguish "refund accepted" from
82
- * "refund settled" should track Stripe's own refund object separately — out of scope for this
83
- * port's `Charge`-shaped return value.
84
- */
85
- refund({ id }: {
86
- id: string;
87
- }): Promise<Charge>;
88
- private authHeader;
89
- private request;
90
- private safeJson;
91
- private toError;
92
- private toCharge;
93
- }
94
- //# sourceMappingURL=index.d.ts.map
@@ -1,167 +0,0 @@
1
- const STRIPE_API_BASE = 'https://api.stripe.com/v1';
2
- /** Error thrown by {@link StripePaymentsProvider}, carrying Stripe's own error envelope fields (`https://docs.stripe.com/api/errors`) when the failure came from a Stripe API response. */
3
- export class StripePaymentsProviderError extends Error {
4
- /** The HTTP status Stripe (or a local pre-flight check) returned. */
5
- status;
6
- /** Stripe's `error.type` — one of `api_error`, `card_error`, `idempotency_error`, `invalid_request_error`. Undefined for a local pre-flight rejection (e.g. a non-positive amount) that never reached Stripe. */
7
- stripeType;
8
- /** Stripe's `error.code`, when present. */
9
- stripeCode;
10
- constructor({ message, status }, { stripeType, stripeCode } = {}) {
11
- super(message);
12
- this.name = 'StripePaymentsProviderError';
13
- this.status = status;
14
- if (stripeType !== undefined)
15
- this.stripeType = stripeType;
16
- if (stripeCode !== undefined)
17
- this.stripeCode = stripeCode;
18
- }
19
- }
20
- /**
21
- * Maps a raw Stripe Charge JSON object's `status` (`'succeeded' | 'pending' | 'failed'` per
22
- * Stripe's documented Charge object) plus its separate `refunded` boolean onto this port's
23
- * `ChargeStatus`. `refunded: true` always wins — Stripe leaves `status` at `'succeeded'` even
24
- * after a full refund, but this port's `ChargeStatus` models "refunded" as its own terminal
25
- * state distinct from "succeeded", so a charge this adapter itself refunded (or that was
26
- * refunded directly in Stripe) reports as `'refunded'` here.
27
- */
28
- function mapStripeChargeStatus(raw, refunded) {
29
- if (refunded === true)
30
- return 'refunded';
31
- if (raw === 'succeeded' || raw === 'pending' || raw === 'failed')
32
- return raw;
33
- // Stripe's Charge.status is documented as exactly succeeded | pending | failed — this branch
34
- // has no real reachable path against Stripe's actual contract, but keeps the mapping total
35
- // against `unknown` JSON (an arbitrary HTTP response body) rather than asserting.
36
- return 'pending';
37
- }
38
- /**
39
- * `PaymentsProvider` adapter against Stripe's real Charges/Refunds REST API. No mock/simulated
40
- * money movement — every `charge`/`getCharge`/`refund` call is a real HTTP request to
41
- * `api.stripe.com` (or `optional.apiBase` in tests), authenticated the way Stripe's own docs
42
- * specify: HTTP Basic auth with the secret key as the username and an empty password
43
- * (`Authorization: Basic base64("sk_...:")`), request bodies form-encoded
44
- * (`application/x-www-form-urlencoded`), not JSON.
45
- *
46
- * `ChargeInput.customerRef` is sent as Stripe's `customer` parameter — this adapter always
47
- * charges an existing Stripe Customer (who must already have a default/attached payment method),
48
- * never a one-off `source`/token; `ChargeInput` has no field for a raw card token, and inventing
49
- * one wasn't part of this port's brief.
50
- */
51
- export class StripePaymentsProvider {
52
- options;
53
- fetchFn;
54
- apiBase;
55
- now;
56
- constructor(options, optional = {}) {
57
- this.options = options;
58
- if (!options.secretKey) {
59
- throw new StripePaymentsProviderError({ message: 'StripePaymentsProvider requires a non-empty options.secretKey', status: 401 });
60
- }
61
- const fn = optional.fetchFn ?? globalThis.fetch;
62
- if (!fn) {
63
- throw new StripePaymentsProviderError({ message: 'StripePaymentsProvider requires a fetch implementation', status: 500 });
64
- }
65
- this.fetchFn = fn;
66
- this.now = optional.now ?? Date.now;
67
- this.apiBase = (optional.apiBase ?? STRIPE_API_BASE).replace(/\/+$/, '');
68
- }
69
- async charge(input, optional = {}) {
70
- if (input.amountCents <= 0) {
71
- throw new StripePaymentsProviderError({ message: 'amountCents must be positive', status: 400 });
72
- }
73
- const body = new URLSearchParams({
74
- amount: String(input.amountCents),
75
- currency: input.currency,
76
- customer: input.customerRef,
77
- });
78
- if (optional.description !== undefined)
79
- body.set('description', optional.description);
80
- const json = await this.request('POST', '/charges', body);
81
- return this.toCharge(json);
82
- }
83
- async getCharge({ id }) {
84
- try {
85
- const json = await this.request('GET', `/charges/${encodeURIComponent(id)}`);
86
- return this.toCharge(json);
87
- }
88
- catch (err) {
89
- if (err instanceof StripePaymentsProviderError && err.status === 404)
90
- return null;
91
- throw err;
92
- }
93
- }
94
- /**
95
- * `PaymentsProvider.refund` returns a completed `Charge`, but a real Stripe `Refund` object's
96
- * own `status` can be `'succeeded'`, `'pending'` (common for bank-sourced refunds that settle
97
- * over days), `'failed'`, or `'canceled'` — a richer state machine than this port's
98
- * `ChargeStatus` has room for. Since `ChargeStatus` has no "refund in flight" state, `'pending'`
99
- * is treated the same as `'succeeded'` here (Stripe accepted the refund; it will settle) and
100
- * only `'failed'`/`'canceled'` reject. A host that needs to distinguish "refund accepted" from
101
- * "refund settled" should track Stripe's own refund object separately — out of scope for this
102
- * port's `Charge`-shaped return value.
103
- */
104
- async refund({ id }) {
105
- const existing = await this.getCharge({ id });
106
- if (!existing) {
107
- throw new StripePaymentsProviderError({ message: `unknown charge: ${id}`, status: 404 });
108
- }
109
- if (existing.status !== 'succeeded') {
110
- throw new StripePaymentsProviderError({ message: `charge ${id} is not refundable from status "${existing.status}"`, status: 400 });
111
- }
112
- const json = await this.request('POST', '/refunds', new URLSearchParams({ charge: id }));
113
- const refundStatus = json.status;
114
- if (refundStatus === 'failed' || refundStatus === 'canceled') {
115
- throw new StripePaymentsProviderError({ message: `Stripe refund ${String(refundStatus)} for charge ${id}`, status: 402 }, { stripeType: 'api_error' });
116
- }
117
- return { ...existing, status: 'refunded' };
118
- }
119
- authHeader() {
120
- const bytes = new TextEncoder().encode(`${this.options.secretKey}:`);
121
- return `Basic ${btoa(Array.from(bytes, (byte) => String.fromCharCode(byte)).join(''))}`;
122
- }
123
- async request(method, path, formBody) {
124
- const headers = { Authorization: this.authHeader() };
125
- const init = { method, headers };
126
- if (formBody) {
127
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
128
- init.body = formBody.toString();
129
- }
130
- const res = await this.fetchFn(`${this.apiBase}${path}`, init);
131
- const json = await this.safeJson(res);
132
- if (!res.ok)
133
- throw this.toError(res.status, json);
134
- return json;
135
- }
136
- async safeJson(res) {
137
- try {
138
- const parsed = await res.json();
139
- return parsed && typeof parsed === 'object' ? parsed : {};
140
- }
141
- catch {
142
- return {};
143
- }
144
- }
145
- toError(status, json) {
146
- const errorObj = json.error && typeof json.error === 'object' ? json.error : {};
147
- const message = typeof errorObj.message === 'string' && errorObj.message ? errorObj.message : `Stripe request failed (${status}).`;
148
- const stripeType = typeof errorObj.type === 'string' ? errorObj.type : undefined;
149
- const stripeCode = typeof errorObj.code === 'string' ? errorObj.code : undefined;
150
- return new StripePaymentsProviderError({ message, status }, {
151
- ...(stripeType === undefined ? {} : { stripeType }),
152
- ...(stripeCode === undefined ? {} : { stripeCode }),
153
- });
154
- }
155
- toCharge(json) {
156
- return {
157
- id: typeof json.id === 'string' ? json.id : '',
158
- status: mapStripeChargeStatus(json.status, json.refunded),
159
- amountCents: typeof json.amount === 'number' ? json.amount : 0,
160
- currency: typeof json.currency === 'string' ? json.currency : '',
161
- customerRef: typeof json.customer === 'string' ? json.customer : '',
162
- // Stripe's `created` is Unix seconds; this port's `createdAt` is epoch milliseconds.
163
- createdAt: typeof json.created === 'number' ? json.created * 1000 : this.now(),
164
- };
165
- }
166
- }
167
- //# sourceMappingURL=index.js.map