@venturekit/billing 0.0.0-dev.20260825184900
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/README.md +218 -0
- package/dist/client.d.ts +109 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +139 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +102 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +133 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +170 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +47 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.d.ts +178 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +93 -0
- package/dist/provider.js.map +1 -0
- package/dist/providers/index.d.ts +15 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +15 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/mock.d.ts +79 -0
- package/dist/providers/mock.d.ts.map +1 -0
- package/dist/providers/mock.js +536 -0
- package/dist/providers/mock.js.map +1 -0
- package/dist/providers/zazu/adapter.d.ts +39 -0
- package/dist/providers/zazu/adapter.d.ts.map +1 -0
- package/dist/providers/zazu/adapter.js +233 -0
- package/dist/providers/zazu/adapter.js.map +1 -0
- package/dist/providers/zazu/client.d.ts +76 -0
- package/dist/providers/zazu/client.d.ts.map +1 -0
- package/dist/providers/zazu/client.js +163 -0
- package/dist/providers/zazu/client.js.map +1 -0
- package/dist/providers/zazu/config.d.ts +54 -0
- package/dist/providers/zazu/config.d.ts.map +1 -0
- package/dist/providers/zazu/config.js +55 -0
- package/dist/providers/zazu/config.js.map +1 -0
- package/dist/providers/zazu/correlation.d.ts +65 -0
- package/dist/providers/zazu/correlation.d.ts.map +1 -0
- package/dist/providers/zazu/correlation.js +178 -0
- package/dist/providers/zazu/correlation.js.map +1 -0
- package/dist/providers/zazu/index.d.ts +18 -0
- package/dist/providers/zazu/index.d.ts.map +1 -0
- package/dist/providers/zazu/index.js +21 -0
- package/dist/providers/zazu/index.js.map +1 -0
- package/dist/providers/zazu/maps.d.ts +36 -0
- package/dist/providers/zazu/maps.d.ts.map +1 -0
- package/dist/providers/zazu/maps.js +450 -0
- package/dist/providers/zazu/maps.js.map +1 -0
- package/dist/providers/zazu/types.d.ts +365 -0
- package/dist/providers/zazu/types.d.ts.map +1 -0
- package/dist/providers/zazu/types.js +13 -0
- package/dist/providers/zazu/types.js.map +1 -0
- package/dist/providers/zazu/webhooks.d.ts +73 -0
- package/dist/providers/zazu/webhooks.d.ts.map +1 -0
- package/dist/providers/zazu/webhooks.js +259 -0
- package/dist/providers/zazu/webhooks.js.map +1 -0
- package/dist/types.d.ts +512 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +16 -0
- package/dist/types.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,QAAQ,EACR,OAAO,EACP,6BAA6B,EAC7B,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,0BAA0B,EAC1B,WAAW,EACX,yBAAyB,EACzB,QAAQ,EACR,mBAAmB,EACnB,0BAA0B,EAC1B,eAAe,EACf,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEh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CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,eAAe,CAElF;AAED,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,cAAc,CAEhF;AAED,4EAA4E;AAC5E,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EACvD,CAAC,EAAE,CAAC,GACH,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAEjC;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAC/C,gBAAgB,GAChB,eAAe,GACf,cAAc,GACd,sBAAsB,CAAC;AAMzB;;;GAGG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,eAAe,CAAC;AAI3E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,CAEzF;AAED,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAEhE;AAED,mDAAmD;AACnD,wBAAgB,mBAAmB,IAAI,YAAY,EAAE,CAEpD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,eAAe,CAMpF"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @venturekit/billing — payment provider interface, capabilities & registry
|
|
3
|
+
*
|
|
4
|
+
* ## Interface segregation
|
|
5
|
+
*
|
|
6
|
+
* {@link PaymentProvider} holds only what EVERY card-payment provider can
|
|
7
|
+
* do: hosted checkout, shareable payment links, and inbound webhook
|
|
8
|
+
* normalization. Everything else is an **optional capability** — a
|
|
9
|
+
* separate interface an adapter opts into:
|
|
10
|
+
*
|
|
11
|
+
* | Capability | Operations |
|
|
12
|
+
* | ------------------------------ | ------------------------------------------- |
|
|
13
|
+
* | {@link InvoicingCapable} | invoices + customers |
|
|
14
|
+
* | {@link TransferCapable} | outgoing transfers |
|
|
15
|
+
* | {@link AccountCapable} | funding accounts + their ledger entries |
|
|
16
|
+
* | {@link WebhookEndpointCapable} | webhook endpoint provisioning |
|
|
17
|
+
*
|
|
18
|
+
* This keeps a future Stripe or PayPal adapter from stubbing methods it
|
|
19
|
+
* has no equivalent for (e.g. Zazu's bank accounts). Consumers narrow
|
|
20
|
+
* with the `supports*` type guards before calling.
|
|
21
|
+
*
|
|
22
|
+
* ## Extensibility
|
|
23
|
+
*
|
|
24
|
+
* Providers self-register into a {@link registerProvider registry} so
|
|
25
|
+
* adding a provider NEVER requires editing this file — implement the
|
|
26
|
+
* interface(s), call `registerProvider('name', factory)` in the provider's
|
|
27
|
+
* module, and it's usable by name. Applications can also construct
|
|
28
|
+
* adapters directly and pass instances to `createBillingClient`.
|
|
29
|
+
*/
|
|
30
|
+
import { UnknownProviderError } from './errors.js';
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Capability type guards
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
function hasAll(obj, methods) {
|
|
35
|
+
return methods.every((m) => typeof obj[m] === 'function');
|
|
36
|
+
}
|
|
37
|
+
/** Narrow a provider to one that supports invoicing + customers. */
|
|
38
|
+
export function supportsInvoicing(p) {
|
|
39
|
+
return hasAll(p, ['createInvoice', 'getInvoice', 'listInvoices', 'createCustomer']);
|
|
40
|
+
}
|
|
41
|
+
/** Narrow a provider to one that supports outgoing transfers. */
|
|
42
|
+
export function supportsTransfers(p) {
|
|
43
|
+
return hasAll(p, ['createTransfer', 'getTransfer', 'listTransfers']);
|
|
44
|
+
}
|
|
45
|
+
/** Narrow a provider to one that exposes funding accounts. */
|
|
46
|
+
export function supportsAccounts(p) {
|
|
47
|
+
return hasAll(p, ['listAccounts', 'getAccount', 'listAccountTransactions']);
|
|
48
|
+
}
|
|
49
|
+
/** Narrow a provider to one that supports webhook endpoint provisioning. */
|
|
50
|
+
export function supportsWebhookEndpoints(p) {
|
|
51
|
+
return hasAll(p, ['listWebhookEndpoints', 'createWebhookEndpoint', 'deleteWebhookEndpoint']);
|
|
52
|
+
}
|
|
53
|
+
const registry = new Map();
|
|
54
|
+
/**
|
|
55
|
+
* Register a provider factory under a name. Providers typically call
|
|
56
|
+
* this at the top level of their barrel module so that importing the
|
|
57
|
+
* provider makes it available by name:
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* // providers/stripe/index.ts
|
|
61
|
+
* registerProvider('stripe', (cfg?: Partial<StripeConfig>) => createStripeAdapter(cfg));
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* Registering the same name twice replaces the previous factory
|
|
65
|
+
* (last write wins) — useful for overriding a built-in provider in
|
|
66
|
+
* tests.
|
|
67
|
+
*/
|
|
68
|
+
export function registerProvider(name, factory) {
|
|
69
|
+
registry.set(name, factory);
|
|
70
|
+
}
|
|
71
|
+
/** True if a provider with this name has been registered. */
|
|
72
|
+
export function isProviderRegistered(name) {
|
|
73
|
+
return registry.has(name);
|
|
74
|
+
}
|
|
75
|
+
/** Names of all currently registered providers. */
|
|
76
|
+
export function registeredProviders() {
|
|
77
|
+
return Array.from(registry.keys());
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Build a registered provider by name. Throws {@link UnknownProviderError}
|
|
81
|
+
* if the name hasn't been registered (i.e. the provider module was never
|
|
82
|
+
* imported). Prefer constructing adapters directly and passing them to
|
|
83
|
+
* `createBillingClient` for full tree-shaking control; this string-based
|
|
84
|
+
* path exists for config-driven selection.
|
|
85
|
+
*/
|
|
86
|
+
export function createProvider(name, config) {
|
|
87
|
+
const factory = registry.get(name);
|
|
88
|
+
if (!factory) {
|
|
89
|
+
throw new UnknownProviderError(name);
|
|
90
|
+
}
|
|
91
|
+
return factory(config);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAgCH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AA6InD,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE9E,SAAS,MAAM,CAAC,GAAW,EAAE,OAAiB;IAC5C,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAQ,GAA+B,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;AACzF,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,iBAAiB,CAAmB,CAAI;IACtD,OAAO,MAAM,CAAC,CAAC,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,iBAAiB,CAAmB,CAAI;IACtD,OAAO,MAAM,CAAC,CAAC,EAAE,CAAC,gBAAgB,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,gBAAgB,CAAmB,CAAI;IACrD,OAAO,MAAM,CAAC,CAAC,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,yBAAyB,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CACtC,CAAI;IAEJ,OAAO,MAAM,CAAC,CAAC,EAAE,CAAC,sBAAsB,EAAE,uBAAuB,EAAE,uBAAuB,CAAC,CAAC,CAAC;AAC/F,CAAC;AAsBD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0C,CAAC;AAEnE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,gBAAgB,CAAI,IAAkB,EAAE,OAA2B;IACjF,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAmC,CAAC,CAAC;AAC1D,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,oBAAoB,CAAC,IAAkB;IACrD,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,mBAAmB;IACjC,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAAkB,EAAE,MAAgB;IACjE,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @venturekit/billing — providers barrel
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the real provider factories so consumers can import either
|
|
5
|
+
* via the package barrel or a provider subpath for tree-shaking.
|
|
6
|
+
*
|
|
7
|
+
* The **mock provider is intentionally absent**. It accepts webhooks
|
|
8
|
+
* without verifying signatures and fabricates successful payments, so it
|
|
9
|
+
* must not be reachable from a production bundle. Import it explicitly
|
|
10
|
+
* when you want it:
|
|
11
|
+
*
|
|
12
|
+
* import { createMockProvider } from '@venturekit/billing/providers/mock';
|
|
13
|
+
*/
|
|
14
|
+
export { createZazuAdapter, type ZazuAdapter, createZazuHttpClient, type ZazuHttpClient, resolveZazuConfig, type ZazuConfig, verifyZazuSignature, parseZazuWebhook, handleZazuWebhook, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, type HandleZazuWebhookOptions, } from './zazu/index.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,oBAAoB,EACpB,KAAK,cAAc,EACnB,iBAAiB,EACjB,KAAK,UAAU,EACf,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,iCAAiC,EACjC,KAAK,wBAAwB,GAC9B,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @venturekit/billing — providers barrel
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the real provider factories so consumers can import either
|
|
5
|
+
* via the package barrel or a provider subpath for tree-shaking.
|
|
6
|
+
*
|
|
7
|
+
* The **mock provider is intentionally absent**. It accepts webhooks
|
|
8
|
+
* without verifying signatures and fabricates successful payments, so it
|
|
9
|
+
* must not be reachable from a production bundle. Import it explicitly
|
|
10
|
+
* when you want it:
|
|
11
|
+
*
|
|
12
|
+
* import { createMockProvider } from '@venturekit/billing/providers/mock';
|
|
13
|
+
*/
|
|
14
|
+
export { createZazuAdapter, createZazuHttpClient, resolveZazuConfig, verifyZazuSignature, parseZazuWebhook, handleZazuWebhook, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, } from './zazu/index.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,iBAAiB,EAEjB,oBAAoB,EAEpB,iBAAiB,EAEjB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,iCAAiC,GAElC,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @venturekit/billing — mock provider
|
|
3
|
+
*
|
|
4
|
+
* An in-memory provider implementing the core {@link PaymentProvider}
|
|
5
|
+
* contract plus every optional capability, for tests and local
|
|
6
|
+
* development. It records every call, returns deterministic domain
|
|
7
|
+
* objects, and can be configured to throw — so application business
|
|
8
|
+
* logic can be validated without hitting a real provider.
|
|
9
|
+
*
|
|
10
|
+
* The mock does NOT verify signatures (it has no secret); it parses the
|
|
11
|
+
* raw body as a `PaymentEvent`-shaped object so tests can simulate any
|
|
12
|
+
* event by posting JSON.
|
|
13
|
+
*
|
|
14
|
+
* ## Never in a deployed environment
|
|
15
|
+
*
|
|
16
|
+
* Because it skips signature verification and fabricates successful
|
|
17
|
+
* payments, this module is deliberately kept out of the package barrel
|
|
18
|
+
* and does NOT self-register. Import it by subpath
|
|
19
|
+
* (`@venturekit/billing/providers/mock`) and, if you need name-based
|
|
20
|
+
* lookup, call {@link registerMockProvider} yourself. Construction is
|
|
21
|
+
* additionally gated by {@link assertMockAllowed}.
|
|
22
|
+
*/
|
|
23
|
+
import { type FullPaymentProvider } from '../provider.js';
|
|
24
|
+
import type { Account, AccountTransaction, CheckoutSession, Customer, Invoice, PaymentLink, Transfer, WebhookEndpoint } from '../types.js';
|
|
25
|
+
export interface MockProviderOptions {
|
|
26
|
+
/** Throw on the next N calls of any method before succeeding. */
|
|
27
|
+
failNext?: number;
|
|
28
|
+
/** If set, every call throws this error instead of returning a value. */
|
|
29
|
+
error?: Error;
|
|
30
|
+
/** Seed accounts so `listAccounts` returns something deterministic. */
|
|
31
|
+
accounts?: Account[];
|
|
32
|
+
}
|
|
33
|
+
interface MockState {
|
|
34
|
+
checkoutSessions: Map<string, CheckoutSession>;
|
|
35
|
+
paymentLinks: Map<string, PaymentLink>;
|
|
36
|
+
invoices: Map<string, Invoice>;
|
|
37
|
+
customers: Map<string, Customer>;
|
|
38
|
+
transfers: Map<string, Transfer>;
|
|
39
|
+
accounts: Map<string, Account>;
|
|
40
|
+
accountTransactions: Map<string, AccountTransaction[]>;
|
|
41
|
+
webhookEndpoints: Map<string, WebhookEndpoint>;
|
|
42
|
+
calls: Array<{
|
|
43
|
+
method: string;
|
|
44
|
+
args: unknown[];
|
|
45
|
+
}>;
|
|
46
|
+
failNext: number;
|
|
47
|
+
error?: Error;
|
|
48
|
+
}
|
|
49
|
+
export interface MockProvider extends FullPaymentProvider {
|
|
50
|
+
readonly name: 'mock';
|
|
51
|
+
/** Recorded calls per method, in call order. */
|
|
52
|
+
calls: MockState['calls'];
|
|
53
|
+
/** Direct access to stored objects (for assertions). */
|
|
54
|
+
state: MockState;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a mock provider. Useful in tests:
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* const provider = createMockProvider();
|
|
61
|
+
* const session = await provider.createCheckoutSession({ ... });
|
|
62
|
+
* expect(provider.calls.some(c => c.method === 'createCheckoutSession')).toBe(true);
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Throws {@link MockProviderNotAllowedError} outside `vk dev` and tests.
|
|
66
|
+
*/
|
|
67
|
+
export declare function createMockProvider(options?: MockProviderOptions): MockProvider;
|
|
68
|
+
/**
|
|
69
|
+
* Opt into name-based lookup (`createProvider('mock')`) for this module.
|
|
70
|
+
*
|
|
71
|
+
* Deliberately NOT called at module scope. Self-registering would make
|
|
72
|
+
* the mock reachable by name from anywhere that merely imports the
|
|
73
|
+
* package, and would mark this module as having side effects — so
|
|
74
|
+
* bundlers could not tree-shake it out of a production build. Call it
|
|
75
|
+
* explicitly from test setup or local-dev wiring.
|
|
76
|
+
*/
|
|
77
|
+
export declare function registerMockProvider(): void;
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/providers/mock.ts"],"names":[],"mappings":"AA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