@lacagnottedesproches/lcdp-js-lite 1.9.1 → 1.11.0
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/.claude/settings.local.json +7 -0
- package/CLAUDE.md +56 -0
- package/__tests__/api.test.ts +46 -0
- package/__tests__/index.test.ts +34 -0
- package/dist/api.d.ts +8 -2
- package/dist/index.js +303 -58
- package/dist/index.min.js +2 -2
- package/dist/index.mjs +303 -58
- package/dist/index.umd.js +303 -58
- package/dist/index.umd.min.js +1 -1
- package/dist/types.d.ts +120 -1
- package/package.json +1 -1
- package/src/api.ts +25 -1
- package/src/index.ts +4 -1
- package/src/types.ts +35 -1
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project
|
|
6
|
+
|
|
7
|
+
`@lacagnottedesproches/lcdp-js-lite` — a thin TypeScript SDK published to npm. It is a wrapper around the upstream **afina-sdk** (which lives behind `https://api.lacagnottedesproches.fr` and is served as a script bundle at `${api_url}/js`). This repo does not implement the SDK logic itself; it only loads it and exposes typed entry points.
|
|
8
|
+
|
|
9
|
+
Peer dependency: `@stripe/stripe-js` (the loaded `LCDP` instance exposes a `stripe` field).
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
- `npm run build` — clean `dist/` and bundle via rollup. Outputs CJS, ESM, IIFE, UMD, and minified UMD (see `rollup.config.cjs`).
|
|
14
|
+
- `npm run dev` — rollup watch mode.
|
|
15
|
+
- `npm test` — Jest in verbose mode.
|
|
16
|
+
- `npm run test:unit` / `npm run test:integration` — filter by path pattern.
|
|
17
|
+
- `npm run test:types` — `tsd` type-level tests against `__tests__/types.test-d.ts` (these files are excluded from Jest via `testPathIgnorePatterns`, so `npm test` won't run them).
|
|
18
|
+
- `npm run test:coverage` — coverage report. CI (`.github/workflows/test.js.yml`, `node.js.yml`) runs this across Node 18/20/22.
|
|
19
|
+
- Run a single test: `npx jest __tests__/api.test.ts -t "createAccount"`.
|
|
20
|
+
|
|
21
|
+
There is no lint script. Prettier (`.prettierrc.json`) and a minimal ESLint config (`extends: ["prettier"]`) are present but not wired into npm scripts.
|
|
22
|
+
|
|
23
|
+
## Architecture
|
|
24
|
+
|
|
25
|
+
The public surface is two functions exported from `src/index.ts`, intended for two opposite runtimes:
|
|
26
|
+
|
|
27
|
+
### `loadLCDP(pubKey, opts?)` — browser only
|
|
28
|
+
Defined in `src/index.ts`. Lazily injects a `<script src="${api_url}/js">` tag, waits for `window.lcdp.Afina` (the upstream constructor) to appear, then `new`s it with the user's args and awaits `init()`. Behavior notes that are easy to miss:
|
|
29
|
+
- The promise (`lcdpPromise`) and `loadCalled` flag are **module-level singletons** — repeated calls reuse the in-flight/resolved promise. Tests must `jest.resetModules()` to reset this.
|
|
30
|
+
- If `window`/`document` are undefined (SSR), it resolves `null` rather than throwing.
|
|
31
|
+
- If a matching script tag already exists in the DOM, it is reused (with a `console.warn`) rather than re-injected.
|
|
32
|
+
- Also injects a `<div id="lcdp-modal-root">` into the body — the upstream SDK renders its modal there.
|
|
33
|
+
- `opts.api_url` overrides the default `https://api.lacagnottedesproches.fr`.
|
|
34
|
+
- `opts.stripe: false` skips the Stripe.js load inside `init()` (origin verification / CSRF bootstrap still runs). For read-only pages: avoids the Stripe.js network/parse cost, the TBT hit, and the need for Stripe domains in the partner's CSP. Token-creating methods will fail in this mode because `lcdp.stripe` stays `null`. The actual skip happens in `afina-sdk` (`src/core.ts:init`).
|
|
35
|
+
|
|
36
|
+
### `requestLCDP(secret, apiUrl?)` — server only
|
|
37
|
+
Returns a `LCDPRequest` (from `src/api.ts`). The constructor and every method throw `"Must be used server side"` if `typeof window !== "undefined"`. This is a hard guard to keep the API token off the client. Methods (`createAccount`, `createPot`, `createAccountAndPot`, `updatePot`, `getAccount`, `updateAccount`, `updateAccountIdentity`, `updateAccountBank`) wrap `fetch` with `Authorization: Bearer ${secret}`. Error contract: HTTP ≥ 400 rejects with the response body's `detail` string; 204 resolves `undefined`; otherwise resolves the JSON body. The promise wrappers around each method are slightly redundant (the inner `requestLCDPApi` already returns a promise) — preserve this shape when editing unless intentionally refactoring.
|
|
38
|
+
|
|
39
|
+
### Types (`src/types.ts`)
|
|
40
|
+
All public types are re-exported via `export * from "./types"` in `index.ts`. Notable shapes:
|
|
41
|
+
- `LCDP` — the browser-side instance interface (token creation, donations, pots, stats, associations).
|
|
42
|
+
- `LCDPApi` — the server-side `LCDPRequest` interface.
|
|
43
|
+
- `LCDPConstructor` / `LoadLCDP` — entry-point signatures.
|
|
44
|
+
- `window.lcdp.Afina` is declared via `declare global` augmentation.
|
|
45
|
+
|
|
46
|
+
When changing public types, update both `__tests__/types.test-d.ts` (compile-time `tsd` assertions) and `__tests__/types.runtime.test.ts` (runtime smoke).
|
|
47
|
+
|
|
48
|
+
## Testing setup
|
|
49
|
+
|
|
50
|
+
- `jest.setup.ts` enables `jest-fetch-mock` and stubs `window`/`document` globally. Individual tests in `__tests__/index.test.ts` rebuild these mocks per case and call `jest.resetModules()` to reset the module-level `lcdpPromise` singleton.
|
|
51
|
+
- `api.test.ts` tests delete `global.window` before constructing `LCDPRequest` (since its constructor throws when `window` is defined).
|
|
52
|
+
- `testEnvironment` is `"node"`, not `"jsdom"` — the DOM is mocked manually.
|
|
53
|
+
|
|
54
|
+
## Publishing
|
|
55
|
+
|
|
56
|
+
`package.json` defines `main`/`module`/`browser`/`browser:min`/`types` pointing into `dist/`. `docs/` is generated by TypeDoc and gitignored. Version bumps live in commit messages (`chore(version): Bump to X.Y.Z`) and `package.json`; there's no automated release script in this repo.
|
package/__tests__/api.test.ts
CHANGED
|
@@ -168,4 +168,50 @@ describe("LCDPRequest (with jest-fetch-mock)", () => {
|
|
|
168
168
|
}),
|
|
169
169
|
);
|
|
170
170
|
});
|
|
171
|
+
|
|
172
|
+
test("createPayout() posts plain JSON to /pots/{id}/payout", async () => {
|
|
173
|
+
fetchMock.mockResponseOnce(
|
|
174
|
+
JSON.stringify({
|
|
175
|
+
payout_id: "payout_1",
|
|
176
|
+
amount_to_owner: 137043,
|
|
177
|
+
pot_closed: true,
|
|
178
|
+
status: "pending",
|
|
179
|
+
}),
|
|
180
|
+
{ status: 201 },
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
const api = new LCDPRequest(SECRET, API_URL);
|
|
184
|
+
const res = await api.createPayout("pot_1", {
|
|
185
|
+
acct_id: "acc_1",
|
|
186
|
+
close_pot: true,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
expect(res.payout_id).toBe("payout_1");
|
|
190
|
+
expect(res.amount_to_owner).toBe(137043);
|
|
191
|
+
expect(res.pot_closed).toBe(true);
|
|
192
|
+
expect(res.status).toBe("pending");
|
|
193
|
+
|
|
194
|
+
expect(fetchMock).toHaveBeenCalledWith(
|
|
195
|
+
`${API_URL}/pots/pot_1/payout`,
|
|
196
|
+
expect.objectContaining({
|
|
197
|
+
method: "POST",
|
|
198
|
+
headers: expect.objectContaining({
|
|
199
|
+
Authorization: `Bearer ${SECRET}`,
|
|
200
|
+
}),
|
|
201
|
+
body: JSON.stringify({ acct_id: "acc_1", close_pot: true }),
|
|
202
|
+
}),
|
|
203
|
+
);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
test("createPayout() rejects on 409 ineligible", async () => {
|
|
207
|
+
fetchMock.mockResponseOnce(JSON.stringify({ detail: "below_minimum" }), {
|
|
208
|
+
status: 409,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const api = new LCDPRequest(SECRET, API_URL);
|
|
212
|
+
|
|
213
|
+
await expect(
|
|
214
|
+
api.createPayout("pot_1", { acct_id: "acc_1", close_pot: false }),
|
|
215
|
+
).rejects.toBe("below_minimum");
|
|
216
|
+
});
|
|
171
217
|
});
|
package/__tests__/index.test.ts
CHANGED
|
@@ -44,6 +44,40 @@ describe("index.ts in node env", () => {
|
|
|
44
44
|
expect(result).toEqual({ ready: true });
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
+
it("forwards { stripe: false } from opts to init", async () => {
|
|
48
|
+
jest.resetModules();
|
|
49
|
+
|
|
50
|
+
const initMock = jest.fn().mockResolvedValue({ ready: true });
|
|
51
|
+
|
|
52
|
+
(globalThis as any).window.lcdp = {
|
|
53
|
+
Afina: function () {
|
|
54
|
+
(this as any).init = initMock;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const { loadLCDP } = await import("../src");
|
|
59
|
+
await loadLCDP("key", { stripe: false });
|
|
60
|
+
|
|
61
|
+
expect(initMock).toHaveBeenCalledWith({ stripe: false });
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("calls init with no args when stripe opt is omitted", async () => {
|
|
65
|
+
jest.resetModules();
|
|
66
|
+
|
|
67
|
+
const initMock = jest.fn().mockResolvedValue({ ready: true });
|
|
68
|
+
|
|
69
|
+
(globalThis as any).window.lcdp = {
|
|
70
|
+
Afina: function () {
|
|
71
|
+
(this as any).init = initMock;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const { loadLCDP } = await import("../src");
|
|
76
|
+
await loadLCDP("key");
|
|
77
|
+
|
|
78
|
+
expect(initMock).toHaveBeenCalledWith(undefined);
|
|
79
|
+
});
|
|
80
|
+
|
|
47
81
|
it("injects script if not present", async () => {
|
|
48
82
|
jest.resetModules(); // reset module-level state
|
|
49
83
|
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountCreated, LCDPApi, PotCreated, TokenObject
|
|
1
|
+
import { Account, AccountAndPotCreated, AccountCreated, ExternalTokenObject, LCDPApi, PayloadPayout, PayoutResult, PotCreated, TokenObject } from "./types";
|
|
2
2
|
interface LCDPApiResponse {
|
|
3
3
|
[key: string]: string | LCDPApiResponse;
|
|
4
4
|
}
|
|
@@ -6,10 +6,16 @@ export declare class LCDPRequest implements LCDPApi {
|
|
|
6
6
|
_apiToken: string;
|
|
7
7
|
_apiUrl: string;
|
|
8
8
|
constructor(secret: string, apiUrl: string);
|
|
9
|
-
requestLCDPApi: (endpoint: string, payload: TokenObject, authToken: string, customMethod?: "POST" | "PATCH") => Promise<LCDPApiResponse | void>;
|
|
9
|
+
requestLCDPApi: (endpoint: string, payload: TokenObject | ExternalTokenObject | PayloadPayout, authToken: string, customMethod?: "POST" | "PATCH") => Promise<LCDPApiResponse | void>;
|
|
10
|
+
requestGetLCDPApi: (endpoint: string, authToken: string) => Promise<LCDPApiResponse | void>;
|
|
10
11
|
createAccount: (payload: TokenObject) => Promise<AccountCreated>;
|
|
11
12
|
createPot: (payload: TokenObject) => Promise<PotCreated>;
|
|
12
13
|
createAccountAndPot: (payload: TokenObject) => Promise<AccountAndPotCreated>;
|
|
13
14
|
updatePot: (payload: TokenObject) => Promise<void>;
|
|
15
|
+
createPayout: (potId: string, payload: PayloadPayout) => Promise<PayoutResult>;
|
|
16
|
+
getAccount: (accountId: string) => Promise<Account>;
|
|
17
|
+
updateAccount: (accountId: string, payload: ExternalTokenObject) => Promise<void>;
|
|
18
|
+
updateAccountIdentity: (accountId: string, payload: ExternalTokenObject) => Promise<void>;
|
|
19
|
+
updateAccountBank: (accountId: string, payload: ExternalTokenObject) => Promise<void>;
|
|
14
20
|
}
|
|
15
21
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -277,19 +277,86 @@ var LCDPRequest = /*#__PURE__*/_createClass(function LCDPRequest(secret, apiUrl)
|
|
|
277
277
|
};
|
|
278
278
|
}());
|
|
279
279
|
});
|
|
280
|
+
_defineProperty(this, "requestGetLCDPApi", function (endpoint, authToken) {
|
|
281
|
+
if (typeof window !== "undefined") {
|
|
282
|
+
throw new Error("Must be used server side");
|
|
283
|
+
}
|
|
284
|
+
return new Promise(/*#__PURE__*/function () {
|
|
285
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(resolve, reject) {
|
|
286
|
+
var url, response, status, _yield$response$json2, detail, data, _t2;
|
|
287
|
+
return _regenerator().w(function (_context2) {
|
|
288
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
289
|
+
case 0:
|
|
290
|
+
url = "".concat(_this._apiUrl, "/").concat(endpoint);
|
|
291
|
+
_context2.p = 1;
|
|
292
|
+
_context2.n = 2;
|
|
293
|
+
return fetch(url, {
|
|
294
|
+
method: "GET",
|
|
295
|
+
headers: {
|
|
296
|
+
"Content-Type": "application/json",
|
|
297
|
+
"User-Agent": "lcdp/v1",
|
|
298
|
+
Authorization: "Bearer ".concat(authToken)
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
case 2:
|
|
302
|
+
response = _context2.v;
|
|
303
|
+
status = response.status;
|
|
304
|
+
if (!(status >= 400)) {
|
|
305
|
+
_context2.n = 4;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
_context2.n = 3;
|
|
309
|
+
return response.json();
|
|
310
|
+
case 3:
|
|
311
|
+
_yield$response$json2 = _context2.v;
|
|
312
|
+
detail = _yield$response$json2.detail;
|
|
313
|
+
reject(detail);
|
|
314
|
+
_context2.n = 7;
|
|
315
|
+
break;
|
|
316
|
+
case 4:
|
|
317
|
+
if (!(status === 204)) {
|
|
318
|
+
_context2.n = 5;
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
resolve();
|
|
322
|
+
_context2.n = 7;
|
|
323
|
+
break;
|
|
324
|
+
case 5:
|
|
325
|
+
_context2.n = 6;
|
|
326
|
+
return response.json();
|
|
327
|
+
case 6:
|
|
328
|
+
data = _context2.v;
|
|
329
|
+
resolve(data);
|
|
330
|
+
case 7:
|
|
331
|
+
_context2.n = 9;
|
|
332
|
+
break;
|
|
333
|
+
case 8:
|
|
334
|
+
_context2.p = 8;
|
|
335
|
+
_t2 = _context2.v;
|
|
336
|
+
reject(_t2);
|
|
337
|
+
case 9:
|
|
338
|
+
return _context2.a(2);
|
|
339
|
+
}
|
|
340
|
+
}, _callee2, null, [[1, 8]]);
|
|
341
|
+
}));
|
|
342
|
+
return function (_x3, _x4) {
|
|
343
|
+
return _ref2.apply(this, arguments);
|
|
344
|
+
};
|
|
345
|
+
}());
|
|
346
|
+
});
|
|
280
347
|
_defineProperty(this, "createAccount", /*#__PURE__*/function () {
|
|
281
|
-
var
|
|
282
|
-
return _regenerator().w(function (
|
|
283
|
-
while (1) switch (
|
|
348
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(payload) {
|
|
349
|
+
return _regenerator().w(function (_context4) {
|
|
350
|
+
while (1) switch (_context4.n) {
|
|
284
351
|
case 0:
|
|
285
|
-
return
|
|
286
|
-
var
|
|
352
|
+
return _context4.a(2, new Promise(/*#__PURE__*/function () {
|
|
353
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(resolve, reject) {
|
|
287
354
|
var responsePromise;
|
|
288
|
-
return _regenerator().w(function (
|
|
289
|
-
while (1) switch (
|
|
355
|
+
return _regenerator().w(function (_context3) {
|
|
356
|
+
while (1) switch (_context3.n) {
|
|
290
357
|
case 0:
|
|
291
358
|
responsePromise = _this.requestLCDPApi("accounts", payload, _this._apiToken);
|
|
292
|
-
return
|
|
359
|
+
return _context3.a(2, responsePromise.then(function (data) {
|
|
293
360
|
try {
|
|
294
361
|
// TODO: may be improved
|
|
295
362
|
resolve(data);
|
|
@@ -300,32 +367,32 @@ var LCDPRequest = /*#__PURE__*/_createClass(function LCDPRequest(secret, apiUrl)
|
|
|
300
367
|
return reject(reason);
|
|
301
368
|
}));
|
|
302
369
|
}
|
|
303
|
-
},
|
|
370
|
+
}, _callee3);
|
|
304
371
|
}));
|
|
305
|
-
return function (
|
|
306
|
-
return
|
|
372
|
+
return function (_x6, _x7) {
|
|
373
|
+
return _ref4.apply(this, arguments);
|
|
307
374
|
};
|
|
308
375
|
}()));
|
|
309
376
|
}
|
|
310
|
-
},
|
|
377
|
+
}, _callee4);
|
|
311
378
|
}));
|
|
312
|
-
return function (
|
|
313
|
-
return
|
|
379
|
+
return function (_x5) {
|
|
380
|
+
return _ref3.apply(this, arguments);
|
|
314
381
|
};
|
|
315
382
|
}());
|
|
316
383
|
_defineProperty(this, "createPot", /*#__PURE__*/function () {
|
|
317
|
-
var
|
|
318
|
-
return _regenerator().w(function (
|
|
319
|
-
while (1) switch (
|
|
384
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(payload) {
|
|
385
|
+
return _regenerator().w(function (_context6) {
|
|
386
|
+
while (1) switch (_context6.n) {
|
|
320
387
|
case 0:
|
|
321
|
-
return
|
|
322
|
-
var
|
|
388
|
+
return _context6.a(2, new Promise(/*#__PURE__*/function () {
|
|
389
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(resolve, reject) {
|
|
323
390
|
var responsePromise;
|
|
324
|
-
return _regenerator().w(function (
|
|
325
|
-
while (1) switch (
|
|
391
|
+
return _regenerator().w(function (_context5) {
|
|
392
|
+
while (1) switch (_context5.n) {
|
|
326
393
|
case 0:
|
|
327
394
|
responsePromise = _this.requestLCDPApi("pots", payload, _this._apiToken);
|
|
328
|
-
return
|
|
395
|
+
return _context5.a(2, responsePromise.then(function (data) {
|
|
329
396
|
try {
|
|
330
397
|
// TODO: may be improved
|
|
331
398
|
resolve(data);
|
|
@@ -336,32 +403,32 @@ var LCDPRequest = /*#__PURE__*/_createClass(function LCDPRequest(secret, apiUrl)
|
|
|
336
403
|
return reject(reason);
|
|
337
404
|
}));
|
|
338
405
|
}
|
|
339
|
-
},
|
|
406
|
+
}, _callee5);
|
|
340
407
|
}));
|
|
341
|
-
return function (
|
|
342
|
-
return
|
|
408
|
+
return function (_x9, _x0) {
|
|
409
|
+
return _ref6.apply(this, arguments);
|
|
343
410
|
};
|
|
344
411
|
}()));
|
|
345
412
|
}
|
|
346
|
-
},
|
|
413
|
+
}, _callee6);
|
|
347
414
|
}));
|
|
348
|
-
return function (
|
|
349
|
-
return
|
|
415
|
+
return function (_x8) {
|
|
416
|
+
return _ref5.apply(this, arguments);
|
|
350
417
|
};
|
|
351
418
|
}());
|
|
352
419
|
_defineProperty(this, "createAccountAndPot", /*#__PURE__*/function () {
|
|
353
|
-
var
|
|
354
|
-
return _regenerator().w(function (
|
|
355
|
-
while (1) switch (
|
|
420
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(payload) {
|
|
421
|
+
return _regenerator().w(function (_context8) {
|
|
422
|
+
while (1) switch (_context8.n) {
|
|
356
423
|
case 0:
|
|
357
|
-
return
|
|
358
|
-
var
|
|
424
|
+
return _context8.a(2, new Promise(/*#__PURE__*/function () {
|
|
425
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(resolve, reject) {
|
|
359
426
|
var responsePromise;
|
|
360
|
-
return _regenerator().w(function (
|
|
361
|
-
while (1) switch (
|
|
427
|
+
return _regenerator().w(function (_context7) {
|
|
428
|
+
while (1) switch (_context7.n) {
|
|
362
429
|
case 0:
|
|
363
430
|
responsePromise = _this.requestLCDPApi("wizards", payload, _this._apiToken);
|
|
364
|
-
return
|
|
431
|
+
return _context7.a(2, responsePromise.then(function (data) {
|
|
365
432
|
try {
|
|
366
433
|
// TODO: may be improved
|
|
367
434
|
resolve(data);
|
|
@@ -372,32 +439,207 @@ var LCDPRequest = /*#__PURE__*/_createClass(function LCDPRequest(secret, apiUrl)
|
|
|
372
439
|
return reject(reason);
|
|
373
440
|
}));
|
|
374
441
|
}
|
|
375
|
-
},
|
|
442
|
+
}, _callee7);
|
|
376
443
|
}));
|
|
377
|
-
return function (
|
|
378
|
-
return
|
|
444
|
+
return function (_x10, _x11) {
|
|
445
|
+
return _ref8.apply(this, arguments);
|
|
379
446
|
};
|
|
380
447
|
}()));
|
|
381
448
|
}
|
|
382
|
-
},
|
|
449
|
+
}, _callee8);
|
|
383
450
|
}));
|
|
384
|
-
return function (
|
|
385
|
-
return
|
|
451
|
+
return function (_x1) {
|
|
452
|
+
return _ref7.apply(this, arguments);
|
|
386
453
|
};
|
|
387
454
|
}());
|
|
388
455
|
_defineProperty(this, "updatePot", /*#__PURE__*/function () {
|
|
389
|
-
var
|
|
390
|
-
return _regenerator().w(function (
|
|
391
|
-
while (1) switch (
|
|
456
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(payload) {
|
|
457
|
+
return _regenerator().w(function (_context0) {
|
|
458
|
+
while (1) switch (_context0.n) {
|
|
392
459
|
case 0:
|
|
393
|
-
return
|
|
394
|
-
var
|
|
460
|
+
return _context0.a(2, new Promise(/*#__PURE__*/function () {
|
|
461
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(resolve, reject) {
|
|
395
462
|
var responsePromise;
|
|
396
|
-
return _regenerator().w(function (
|
|
397
|
-
while (1) switch (
|
|
463
|
+
return _regenerator().w(function (_context9) {
|
|
464
|
+
while (1) switch (_context9.n) {
|
|
398
465
|
case 0:
|
|
399
466
|
responsePromise = _this.requestLCDPApi("pots", payload, _this._apiToken, "PATCH");
|
|
400
|
-
return
|
|
467
|
+
return _context9.a(2, responsePromise.then(function (_) {
|
|
468
|
+
try {
|
|
469
|
+
resolve();
|
|
470
|
+
} catch (error) {
|
|
471
|
+
reject(error);
|
|
472
|
+
}
|
|
473
|
+
})["catch"](function (reason) {
|
|
474
|
+
return reject(reason);
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
477
|
+
}, _callee9);
|
|
478
|
+
}));
|
|
479
|
+
return function (_x13, _x14) {
|
|
480
|
+
return _ref0.apply(this, arguments);
|
|
481
|
+
};
|
|
482
|
+
}()));
|
|
483
|
+
}
|
|
484
|
+
}, _callee0);
|
|
485
|
+
}));
|
|
486
|
+
return function (_x12) {
|
|
487
|
+
return _ref9.apply(this, arguments);
|
|
488
|
+
};
|
|
489
|
+
}());
|
|
490
|
+
_defineProperty(this, "createPayout", /*#__PURE__*/function () {
|
|
491
|
+
var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(potId, payload) {
|
|
492
|
+
return _regenerator().w(function (_context10) {
|
|
493
|
+
while (1) switch (_context10.n) {
|
|
494
|
+
case 0:
|
|
495
|
+
return _context10.a(2, new Promise(/*#__PURE__*/function () {
|
|
496
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(resolve, reject) {
|
|
497
|
+
var responsePromise;
|
|
498
|
+
return _regenerator().w(function (_context1) {
|
|
499
|
+
while (1) switch (_context1.n) {
|
|
500
|
+
case 0:
|
|
501
|
+
responsePromise = _this.requestLCDPApi("pots/".concat(potId, "/payout"), payload, _this._apiToken);
|
|
502
|
+
return _context1.a(2, responsePromise.then(function (data) {
|
|
503
|
+
try {
|
|
504
|
+
resolve(data);
|
|
505
|
+
} catch (error) {
|
|
506
|
+
reject(error);
|
|
507
|
+
}
|
|
508
|
+
})["catch"](function (reason) {
|
|
509
|
+
return reject(reason);
|
|
510
|
+
}));
|
|
511
|
+
}
|
|
512
|
+
}, _callee1);
|
|
513
|
+
}));
|
|
514
|
+
return function (_x17, _x18) {
|
|
515
|
+
return _ref10.apply(this, arguments);
|
|
516
|
+
};
|
|
517
|
+
}()));
|
|
518
|
+
}
|
|
519
|
+
}, _callee10);
|
|
520
|
+
}));
|
|
521
|
+
return function (_x15, _x16) {
|
|
522
|
+
return _ref1.apply(this, arguments);
|
|
523
|
+
};
|
|
524
|
+
}());
|
|
525
|
+
_defineProperty(this, "getAccount", /*#__PURE__*/function () {
|
|
526
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(accountId) {
|
|
527
|
+
return _regenerator().w(function (_context12) {
|
|
528
|
+
while (1) switch (_context12.n) {
|
|
529
|
+
case 0:
|
|
530
|
+
return _context12.a(2, new Promise(/*#__PURE__*/function () {
|
|
531
|
+
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(resolve, reject) {
|
|
532
|
+
var responsePromise;
|
|
533
|
+
return _regenerator().w(function (_context11) {
|
|
534
|
+
while (1) switch (_context11.n) {
|
|
535
|
+
case 0:
|
|
536
|
+
responsePromise = _this.requestGetLCDPApi("accounts/".concat(accountId), _this._apiToken);
|
|
537
|
+
return _context11.a(2, responsePromise.then(function (data) {
|
|
538
|
+
try {
|
|
539
|
+
resolve(data);
|
|
540
|
+
} catch (error) {
|
|
541
|
+
reject(error);
|
|
542
|
+
}
|
|
543
|
+
})["catch"](function (reason) {
|
|
544
|
+
return reject(reason);
|
|
545
|
+
}));
|
|
546
|
+
}
|
|
547
|
+
}, _callee11);
|
|
548
|
+
}));
|
|
549
|
+
return function (_x20, _x21) {
|
|
550
|
+
return _ref12.apply(this, arguments);
|
|
551
|
+
};
|
|
552
|
+
}()));
|
|
553
|
+
}
|
|
554
|
+
}, _callee12);
|
|
555
|
+
}));
|
|
556
|
+
return function (_x19) {
|
|
557
|
+
return _ref11.apply(this, arguments);
|
|
558
|
+
};
|
|
559
|
+
}());
|
|
560
|
+
_defineProperty(this, "updateAccount", /*#__PURE__*/function () {
|
|
561
|
+
var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(accountId, payload) {
|
|
562
|
+
return _regenerator().w(function (_context14) {
|
|
563
|
+
while (1) switch (_context14.n) {
|
|
564
|
+
case 0:
|
|
565
|
+
return _context14.a(2, new Promise(/*#__PURE__*/function () {
|
|
566
|
+
var _ref14 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(resolve, reject) {
|
|
567
|
+
var responsePromise;
|
|
568
|
+
return _regenerator().w(function (_context13) {
|
|
569
|
+
while (1) switch (_context13.n) {
|
|
570
|
+
case 0:
|
|
571
|
+
responsePromise = _this.requestLCDPApi("accounts/".concat(accountId), payload, _this._apiToken, "PATCH");
|
|
572
|
+
return _context13.a(2, responsePromise.then(function (_) {
|
|
573
|
+
try {
|
|
574
|
+
resolve();
|
|
575
|
+
} catch (error) {
|
|
576
|
+
reject(error);
|
|
577
|
+
}
|
|
578
|
+
})["catch"](function (reason) {
|
|
579
|
+
return reject(reason);
|
|
580
|
+
}));
|
|
581
|
+
}
|
|
582
|
+
}, _callee13);
|
|
583
|
+
}));
|
|
584
|
+
return function (_x24, _x25) {
|
|
585
|
+
return _ref14.apply(this, arguments);
|
|
586
|
+
};
|
|
587
|
+
}()));
|
|
588
|
+
}
|
|
589
|
+
}, _callee14);
|
|
590
|
+
}));
|
|
591
|
+
return function (_x22, _x23) {
|
|
592
|
+
return _ref13.apply(this, arguments);
|
|
593
|
+
};
|
|
594
|
+
}());
|
|
595
|
+
_defineProperty(this, "updateAccountIdentity", /*#__PURE__*/function () {
|
|
596
|
+
var _ref15 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(accountId, payload) {
|
|
597
|
+
return _regenerator().w(function (_context16) {
|
|
598
|
+
while (1) switch (_context16.n) {
|
|
599
|
+
case 0:
|
|
600
|
+
return _context16.a(2, new Promise(/*#__PURE__*/function () {
|
|
601
|
+
var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(resolve, reject) {
|
|
602
|
+
var responsePromise;
|
|
603
|
+
return _regenerator().w(function (_context15) {
|
|
604
|
+
while (1) switch (_context15.n) {
|
|
605
|
+
case 0:
|
|
606
|
+
responsePromise = _this.requestLCDPApi("accounts/".concat(accountId, "/identity"), payload, _this._apiToken, "POST");
|
|
607
|
+
return _context15.a(2, responsePromise.then(function (_) {
|
|
608
|
+
try {
|
|
609
|
+
resolve();
|
|
610
|
+
} catch (error) {
|
|
611
|
+
reject(error);
|
|
612
|
+
}
|
|
613
|
+
})["catch"](function (reason) {
|
|
614
|
+
return reject(reason);
|
|
615
|
+
}));
|
|
616
|
+
}
|
|
617
|
+
}, _callee15);
|
|
618
|
+
}));
|
|
619
|
+
return function (_x28, _x29) {
|
|
620
|
+
return _ref16.apply(this, arguments);
|
|
621
|
+
};
|
|
622
|
+
}()));
|
|
623
|
+
}
|
|
624
|
+
}, _callee16);
|
|
625
|
+
}));
|
|
626
|
+
return function (_x26, _x27) {
|
|
627
|
+
return _ref15.apply(this, arguments);
|
|
628
|
+
};
|
|
629
|
+
}());
|
|
630
|
+
_defineProperty(this, "updateAccountBank", /*#__PURE__*/function () {
|
|
631
|
+
var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(accountId, payload) {
|
|
632
|
+
return _regenerator().w(function (_context18) {
|
|
633
|
+
while (1) switch (_context18.n) {
|
|
634
|
+
case 0:
|
|
635
|
+
return _context18.a(2, new Promise(/*#__PURE__*/function () {
|
|
636
|
+
var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(resolve, reject) {
|
|
637
|
+
var responsePromise;
|
|
638
|
+
return _regenerator().w(function (_context17) {
|
|
639
|
+
while (1) switch (_context17.n) {
|
|
640
|
+
case 0:
|
|
641
|
+
responsePromise = _this.requestLCDPApi("accounts/".concat(accountId, "/bank"), payload, _this._apiToken, "POST");
|
|
642
|
+
return _context17.a(2, responsePromise.then(function (_) {
|
|
401
643
|
try {
|
|
402
644
|
resolve();
|
|
403
645
|
} catch (error) {
|
|
@@ -407,17 +649,17 @@ var LCDPRequest = /*#__PURE__*/_createClass(function LCDPRequest(secret, apiUrl)
|
|
|
407
649
|
return reject(reason);
|
|
408
650
|
}));
|
|
409
651
|
}
|
|
410
|
-
},
|
|
652
|
+
}, _callee17);
|
|
411
653
|
}));
|
|
412
|
-
return function (
|
|
413
|
-
return
|
|
654
|
+
return function (_x32, _x33) {
|
|
655
|
+
return _ref18.apply(this, arguments);
|
|
414
656
|
};
|
|
415
657
|
}()));
|
|
416
658
|
}
|
|
417
|
-
},
|
|
659
|
+
}, _callee18);
|
|
418
660
|
}));
|
|
419
|
-
return function (
|
|
420
|
-
return
|
|
661
|
+
return function (_x30, _x31) {
|
|
662
|
+
return _ref17.apply(this, arguments);
|
|
421
663
|
};
|
|
422
664
|
}());
|
|
423
665
|
if (typeof window !== "undefined") {
|
|
@@ -539,7 +781,7 @@ var getLCDPPromise = function getLCDPPromise(args) {
|
|
|
539
781
|
};
|
|
540
782
|
var initLCDP = /*#__PURE__*/function () {
|
|
541
783
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(maybeLCDP, args) {
|
|
542
|
-
var lcdp;
|
|
784
|
+
var lcdp, opts;
|
|
543
785
|
return _regenerator().w(function (_context) {
|
|
544
786
|
while (1) switch (_context.n) {
|
|
545
787
|
case 0:
|
|
@@ -550,7 +792,10 @@ var initLCDP = /*#__PURE__*/function () {
|
|
|
550
792
|
return _context.a(2, Promise.resolve(null));
|
|
551
793
|
case 1:
|
|
552
794
|
lcdp = _construct(maybeLCDP, _toConsumableArray(args));
|
|
553
|
-
|
|
795
|
+
opts = args[1];
|
|
796
|
+
return _context.a(2, lcdp.init((opts === null || opts === void 0 ? void 0 : opts.stripe) === false ? {
|
|
797
|
+
stripe: false
|
|
798
|
+
} : undefined).then(function (lcdpReady) {
|
|
554
799
|
return lcdpReady;
|
|
555
800
|
}));
|
|
556
801
|
}
|