better-auth-flutterwave 0.2.2 → 0.3.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/README.md +13 -17
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/{index-XrxY-MVF.d.mts → index-D4uWNxiw.d.mts} +38 -37
- package/dist/index-D4uWNxiw.d.mts.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +52 -14
- package/dist/index.mjs.map +1 -1
- package/dist/{version-UDe8miQm.mjs → version-C3pJ_ZLK.mjs} +2 -2
- package/dist/{version-UDe8miQm.mjs.map → version-C3pJ_ZLK.mjs.map} +1 -1
- package/package.json +12 -29
- package/skills/better-auth-flutterwave-setup/SKILL.md +1 -1
- package/skills/flutterwave-billing-flows/SKILL.md +1 -1
- package/skills/flutterwave-catalog-limits/SKILL.md +1 -1
- package/skills/flutterwave-client-api/SKILL.md +1 -1
- package/skills/flutterwave-local-subscriptions/SKILL.md +1 -1
- package/skills/flutterwave-organization-billing/SKILL.md +1 -1
- package/skills/flutterwave-schema-migrations/SKILL.md +1 -1
- package/skills/flutterwave-tanstack-start/SKILL.md +1 -1
- package/skills/flutterwave-testing-fixtures/SKILL.md +1 -1
- package/skills/flutterwave-webhooks-events/SKILL.md +1 -1
- package/dist/index-XrxY-MVF.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ webhooks, refunds, and reconciliation.
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npm install better-auth better-auth-flutterwave
|
|
11
|
+
npm install better-auth better-auth-flutterwave
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Node.js 22 or newer is required.
|
|
14
|
+
Node.js 22.22.2 or newer is required. Development and CI use Node 22.23.3, pinned in `.node-version`, and pnpm 12.10.1. The current jsdom test environment sets the minimum Node 22 patch level.
|
|
15
15
|
|
|
16
16
|
## Configure
|
|
17
17
|
|
|
@@ -62,9 +62,9 @@ export const auth = betterAuth({
|
|
|
62
62
|
});
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
The plugin calls Flutterwave's v3 API with Node's built-in `fetch`; you do not need a separate
|
|
66
|
+
Flutterwave SDK dependency. Inject `flutterwaveClient` for a custom provider boundary or `fetch` for
|
|
67
|
+
tests and controlled transports.
|
|
68
68
|
|
|
69
69
|
Configure the client plugin:
|
|
70
70
|
|
|
@@ -228,7 +228,7 @@ the same seat price as checkout and rejects canceled or provider-managed subscri
|
|
|
228
228
|
Release Please opens the version/change-log PR after reviewed changes reach `main`. Merging that
|
|
229
229
|
release PR creates the version tag and triggers the tag-pinned npm trusted-publishing workflow.
|
|
230
230
|
The npm trusted publisher must reference this repository and `.github/workflows/release-please.yml`.
|
|
231
|
-
The workflow requires Node
|
|
231
|
+
The workflow requires Node 22.23.3, the locked pnpm version, library tests, a package build, package/type
|
|
232
232
|
lint, and the downstream example/schema checks. A branch push or ordinary application build does
|
|
233
233
|
not publish this package.
|
|
234
234
|
|
|
@@ -320,21 +320,17 @@ provider exposes the other's customer or subscription identifiers.
|
|
|
320
320
|
Public identifiers use Flutterwave-native names: `txRef`, `transactionId`, `flwRef`,
|
|
321
321
|
`paymentPlanId`, `subscriptionId`, `secretHash`, and `subaccountId`.
|
|
322
322
|
|
|
323
|
-
##
|
|
323
|
+
## Provider transport
|
|
324
324
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
The SDK performs always-on telemetry and may write telemetry data through an operating-system
|
|
330
|
-
temporary file. This behavior comes from the upstream SDK, not Better Auth or this plugin. Review
|
|
331
|
-
the SDK and your deployment environment’s privacy, filesystem, and serverless constraints before
|
|
332
|
-
adopting it. Injecting a compatible client helps with tests but does not change upstream behavior
|
|
333
|
-
when the official SDK is used.
|
|
325
|
+
Provider requests use Flutterwave's v3 HTTP API with bearer authentication and validate response
|
|
326
|
+
envelopes before returning data to the plugin. The adapter accepts injected `fetch` and
|
|
327
|
+
`flutterwaveClient` implementations for tests and custom transports.
|
|
334
328
|
|
|
335
329
|
## Development
|
|
336
330
|
|
|
337
|
-
This repository uses [Vite+](https://viteplus.dev)
|
|
331
|
+
This repository uses [Vite+](https://viteplus.dev). `vp check` uses its native TypeScript checker. Declaration builds still require the compiler API provided by the maintained `@typescript/typescript6` compatibility package; Vite+ 1.1.0 explicitly rejects the TypeScript 7 compiler API for this mode.
|
|
332
|
+
|
|
333
|
+
Commands:
|
|
338
334
|
|
|
339
335
|
```bash
|
|
340
336
|
vp install
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as FlutterwaveInitializeResult, M as FlutterwavePlan, N as FlutterwaveProduct, R as FlutterwaveTransaction, p as FlutterwaveMetadata, q as Subscription, t as flutterwave, x as parseFlutterwaveMetadata, z as FlutterwaveTransactionResponse } from "./index-
|
|
1
|
+
import { A as FlutterwaveInitializeResult, M as FlutterwavePlan, N as FlutterwaveProduct, R as FlutterwaveTransaction, p as FlutterwaveMetadata, q as Subscription, t as flutterwave, x as parseFlutterwaveMetadata, z as FlutterwaveTransactionResponse } from "./index-D4uWNxiw.mjs";
|
|
2
2
|
import { BetterFetch, BetterFetchOption, BetterFetchResponse } from "@better-fetch/fetch";
|
|
3
3
|
import { BetterAuthClientPlugin } from "better-auth/client";
|
|
4
4
|
//#region src/client.d.ts
|
package/dist/client.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as parseFlutterwaveMetadata, t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { l as parseFlutterwaveMetadata, t as PACKAGE_VERSION } from "./version-C3pJ_ZLK.mjs";
|
|
2
2
|
//#region src/client.ts
|
|
3
3
|
const flutterwaveClient = (_options) => ({
|
|
4
4
|
id: "flutterwave-client",
|
|
@@ -116,8 +116,8 @@ type FlutterwaveRefundData = z.infer<typeof refundSchema>;
|
|
|
116
116
|
//#endregion
|
|
117
117
|
//#region src/flutterwave-sdk.d.ts
|
|
118
118
|
type SdkResult = Promise<unknown>;
|
|
119
|
-
/** The deliberately small
|
|
120
|
-
interface
|
|
119
|
+
/** The deliberately small provider boundary used by this package. */
|
|
120
|
+
interface FlutterwaveClient {
|
|
121
121
|
Transaction: {
|
|
122
122
|
verify(input: {
|
|
123
123
|
id: number;
|
|
@@ -146,10 +146,12 @@ interface FlutterwaveSdkClient {
|
|
|
146
146
|
charge(input: FlutterwaveTokenChargeInput): SdkResult;
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
+
/** @deprecated Use FlutterwaveClient. */
|
|
150
|
+
type FlutterwaveSdkClient = FlutterwaveClient;
|
|
149
151
|
interface FlutterwaveAdapterOptions {
|
|
150
152
|
publicKey: string;
|
|
151
153
|
secretKey: string;
|
|
152
|
-
flutterwaveClient?:
|
|
154
|
+
flutterwaveClient?: FlutterwaveClient;
|
|
153
155
|
fetch?: typeof globalThis.fetch;
|
|
154
156
|
apiBaseUrl?: string;
|
|
155
157
|
}
|
|
@@ -186,10 +188,9 @@ declare class FlutterwaveAdapterError extends Error {
|
|
|
186
188
|
/**
|
|
187
189
|
* Creates the provider boundary used by the plugin.
|
|
188
190
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* required. This adapter intentionally uses only the SDK's Promise API.
|
|
191
|
+
* Uses Flutterwave's v3 HTTP API directly so applications do not need a separate
|
|
192
|
+
* SDK dependency. Inject `flutterwaveClient` for a custom provider boundary or
|
|
193
|
+
* `fetch` for controlled transport and tests.
|
|
193
194
|
*/
|
|
194
195
|
declare function createFlutterwaveAdapter(options: FlutterwaveAdapterOptions): FlutterwaveAdapter;
|
|
195
196
|
//#endregion
|
|
@@ -440,7 +441,7 @@ interface ChargeRecurringSubscriptionResult {
|
|
|
440
441
|
}
|
|
441
442
|
//#endregion
|
|
442
443
|
//#region src/routes.d.ts
|
|
443
|
-
declare const initializeTransaction: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
444
|
+
declare const initializeTransaction: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
444
445
|
method: "POST";
|
|
445
446
|
body: z.ZodObject<{
|
|
446
447
|
amount: z.ZodOptional<z.ZodNumber>;
|
|
@@ -464,7 +465,7 @@ declare const initializeTransaction: <P extends string>(options: AnyFlutterwaveO
|
|
|
464
465
|
transactionCharge: z.ZodOptional<z.ZodNumber>;
|
|
465
466
|
}, z.core.$strip>>>;
|
|
466
467
|
}, z.core.$strip>;
|
|
467
|
-
use: (((inputContext: import("better-
|
|
468
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
468
469
|
session: {
|
|
469
470
|
session: Record<string, any> & {
|
|
470
471
|
id: string;
|
|
@@ -486,21 +487,21 @@ declare const initializeTransaction: <P extends string>(options: AnyFlutterwaveO
|
|
|
486
487
|
image?: string | null | undefined;
|
|
487
488
|
};
|
|
488
489
|
};
|
|
489
|
-
}
|
|
490
|
+
}>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>)[];
|
|
490
491
|
}, {
|
|
491
492
|
kind: "checkout";
|
|
492
493
|
url: string;
|
|
493
494
|
txRef: string;
|
|
494
495
|
redirect: true;
|
|
495
496
|
}>;
|
|
496
|
-
declare const verifyTransaction: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
497
|
+
declare const verifyTransaction: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
497
498
|
method: "POST";
|
|
498
499
|
body: z.ZodObject<{
|
|
499
500
|
transactionId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
500
501
|
txRef: z.ZodOptional<z.ZodString>;
|
|
501
502
|
referenceId: z.ZodOptional<z.ZodString>;
|
|
502
503
|
}, z.core.$strip>;
|
|
503
|
-
use: (((inputContext: import("better-
|
|
504
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
504
505
|
session: {
|
|
505
506
|
session: Record<string, any> & {
|
|
506
507
|
id: string;
|
|
@@ -522,18 +523,18 @@ declare const verifyTransaction: <P extends string>(options: AnyFlutterwaveOptio
|
|
|
522
523
|
image?: string | null | undefined;
|
|
523
524
|
};
|
|
524
525
|
};
|
|
525
|
-
}
|
|
526
|
+
}>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>)[];
|
|
526
527
|
}, {
|
|
527
528
|
status: string;
|
|
528
529
|
txRef: string;
|
|
529
530
|
data: FlutterwaveTransactionResponse;
|
|
530
531
|
}>;
|
|
531
|
-
declare const listTransactions: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
532
|
+
declare const listTransactions: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
532
533
|
method: "GET";
|
|
533
534
|
query: z.ZodObject<{
|
|
534
535
|
referenceId: z.ZodOptional<z.ZodString>;
|
|
535
536
|
}, z.core.$strip>;
|
|
536
|
-
use: ((inputContext: import("better-
|
|
537
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
537
538
|
session: {
|
|
538
539
|
session: Record<string, any> & {
|
|
539
540
|
id: string;
|
|
@@ -555,16 +556,16 @@ declare const listTransactions: <P extends string>(options: AnyFlutterwaveOption
|
|
|
555
556
|
image?: string | null | undefined;
|
|
556
557
|
};
|
|
557
558
|
};
|
|
558
|
-
}
|
|
559
|
+
}>>[];
|
|
559
560
|
}, {
|
|
560
561
|
transactions: FlutterwaveTransaction[];
|
|
561
562
|
}>;
|
|
562
|
-
declare const listSubscriptions: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
563
|
+
declare const listSubscriptions: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
563
564
|
method: "GET";
|
|
564
565
|
query: z.ZodObject<{
|
|
565
566
|
referenceId: z.ZodOptional<z.ZodString>;
|
|
566
567
|
}, z.core.$strip>;
|
|
567
|
-
use: ((inputContext: import("better-
|
|
568
|
+
use: import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
568
569
|
session: {
|
|
569
570
|
session: Record<string, any> & {
|
|
570
571
|
id: string;
|
|
@@ -586,17 +587,17 @@ declare const listSubscriptions: <P extends string>(options: AnyFlutterwaveOptio
|
|
|
586
587
|
image?: string | null | undefined;
|
|
587
588
|
};
|
|
588
589
|
};
|
|
589
|
-
}
|
|
590
|
+
}>>[];
|
|
590
591
|
}, {
|
|
591
592
|
subscriptions: Subscription[];
|
|
592
593
|
}>;
|
|
593
|
-
declare const cancelSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
594
|
+
declare const cancelSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
594
595
|
method: "POST";
|
|
595
596
|
body: z.ZodObject<{
|
|
596
597
|
subscriptionId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
597
598
|
atPeriodEnd: z.ZodOptional<z.ZodBoolean>;
|
|
598
599
|
}, z.core.$strip>;
|
|
599
|
-
use: (((inputContext: import("better-
|
|
600
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
600
601
|
session: {
|
|
601
602
|
session: Record<string, any> & {
|
|
602
603
|
id: string;
|
|
@@ -618,16 +619,16 @@ declare const cancelSubscription: <P extends string>(options: AnyFlutterwaveOpti
|
|
|
618
619
|
image?: string | null | undefined;
|
|
619
620
|
};
|
|
620
621
|
};
|
|
621
|
-
}
|
|
622
|
+
}>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>)[];
|
|
622
623
|
}, {
|
|
623
624
|
status: string;
|
|
624
625
|
}>;
|
|
625
|
-
declare const restoreSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
626
|
+
declare const restoreSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
626
627
|
method: "POST";
|
|
627
628
|
body: z.ZodObject<{
|
|
628
629
|
subscriptionId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
629
630
|
}, z.core.$strip>;
|
|
630
|
-
use: (((inputContext: import("better-
|
|
631
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
631
632
|
session: {
|
|
632
633
|
session: Record<string, any> & {
|
|
633
634
|
id: string;
|
|
@@ -649,11 +650,11 @@ declare const restoreSubscription: <P extends string>(options: AnyFlutterwaveOpt
|
|
|
649
650
|
image?: string | null | undefined;
|
|
650
651
|
};
|
|
651
652
|
};
|
|
652
|
-
}
|
|
653
|
+
}>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>)[];
|
|
653
654
|
}, {
|
|
654
655
|
status: string;
|
|
655
656
|
}>;
|
|
656
|
-
declare const createSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
657
|
+
declare const createSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
657
658
|
method: "POST";
|
|
658
659
|
body: z.ZodObject<{
|
|
659
660
|
amount: z.ZodOptional<z.ZodNumber>;
|
|
@@ -677,7 +678,7 @@ declare const createSubscription: <P extends string>(options: AnyFlutterwaveOpti
|
|
|
677
678
|
transactionCharge: z.ZodOptional<z.ZodNumber>;
|
|
678
679
|
}, z.core.$strip>>>;
|
|
679
680
|
}, z.core.$strip>;
|
|
680
|
-
use: (((inputContext: import("better-
|
|
681
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
681
682
|
session: {
|
|
682
683
|
session: Record<string, any> & {
|
|
683
684
|
id: string;
|
|
@@ -699,14 +700,14 @@ declare const createSubscription: <P extends string>(options: AnyFlutterwaveOpti
|
|
|
699
700
|
image?: string | null | undefined;
|
|
700
701
|
};
|
|
701
702
|
};
|
|
702
|
-
}
|
|
703
|
+
}>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>)[];
|
|
703
704
|
}, {
|
|
704
705
|
kind: "checkout";
|
|
705
706
|
url: string;
|
|
706
707
|
txRef: string;
|
|
707
708
|
redirect: true;
|
|
708
709
|
}>;
|
|
709
|
-
declare const upgradeSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
710
|
+
declare const upgradeSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
710
711
|
method: "POST";
|
|
711
712
|
body: z.ZodObject<{
|
|
712
713
|
amount: z.ZodOptional<z.ZodNumber>;
|
|
@@ -730,7 +731,7 @@ declare const upgradeSubscription: <P extends string>(options: AnyFlutterwaveOpt
|
|
|
730
731
|
transactionCharge: z.ZodOptional<z.ZodNumber>;
|
|
731
732
|
}, z.core.$strip>>>;
|
|
732
733
|
}, z.core.$strip>;
|
|
733
|
-
use: (((inputContext: import("better-
|
|
734
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
734
735
|
session: {
|
|
735
736
|
session: Record<string, any> & {
|
|
736
737
|
id: string;
|
|
@@ -752,24 +753,24 @@ declare const upgradeSubscription: <P extends string>(options: AnyFlutterwaveOpt
|
|
|
752
753
|
image?: string | null | undefined;
|
|
753
754
|
};
|
|
754
755
|
};
|
|
755
|
-
}
|
|
756
|
+
}>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>)[];
|
|
756
757
|
}, {
|
|
757
758
|
kind: "checkout";
|
|
758
759
|
url: string;
|
|
759
760
|
txRef: string;
|
|
760
761
|
redirect: true;
|
|
761
762
|
}>;
|
|
762
|
-
declare const listProducts: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
763
|
+
declare const listProducts: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
763
764
|
method: "GET";
|
|
764
765
|
}, {
|
|
765
766
|
products: FlutterwaveProduct[];
|
|
766
767
|
}>;
|
|
767
|
-
declare const listPlans: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
768
|
+
declare const listPlans: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
768
769
|
method: "GET";
|
|
769
770
|
}, {
|
|
770
771
|
plans: FlutterwavePlan[];
|
|
771
772
|
}>;
|
|
772
|
-
declare const getConfig: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
773
|
+
declare const getConfig: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
773
774
|
method: "GET";
|
|
774
775
|
}, {
|
|
775
776
|
plans: FlutterwavePlan[];
|
|
@@ -777,7 +778,7 @@ declare const getConfig: <P extends string>(options: AnyFlutterwaveOptions, path
|
|
|
777
778
|
subscriptions: boolean;
|
|
778
779
|
marketplace: boolean;
|
|
779
780
|
}>;
|
|
780
|
-
declare const flutterwaveWebhook: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-
|
|
781
|
+
declare const flutterwaveWebhook: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
781
782
|
method: "POST";
|
|
782
783
|
metadata: {
|
|
783
784
|
openapi: {
|
|
@@ -792,7 +793,7 @@ declare const flutterwaveWebhook: <P extends string>(options: AnyFlutterwaveOpti
|
|
|
792
793
|
}>;
|
|
793
794
|
//#endregion
|
|
794
795
|
//#region src/version.d.ts
|
|
795
|
-
declare const PACKAGE_VERSION = "0.
|
|
796
|
+
declare const PACKAGE_VERSION = "0.3.1";
|
|
796
797
|
//#endregion
|
|
797
798
|
//#region src/metadata.d.ts
|
|
798
799
|
type FlutterwaveMetadata = Record<string, unknown>;
|
|
@@ -940,4 +941,4 @@ type FlutterwavePluginInstance<O extends AnyFlutterwaveOptions> = Omit<BetterAut
|
|
|
940
941
|
declare const flutterwave: <TFlutterwaveClient extends FlutterwaveClientLike = FlutterwaveClientLike, O extends FlutterwaveOptions<TFlutterwaveClient> = FlutterwaveOptions<TFlutterwaveClient>>(options: O) => FlutterwavePluginInstance<O>;
|
|
941
942
|
//#endregion
|
|
942
943
|
export { FlutterwaveSdkClient as $, FlutterwaveInitializeResult as A, FlutterwaveWebhookEvent as B, AnyFlutterwaveOptions as C, FlutterwaveClientLike as D, FlutterwaveCheckoutChannel as E, FlutterwaveSubaccountSplit as F, Organization as G, FlutterwaveWebhookPayload as H, FlutterwaveSubscription as I, SubscriptionOptions as J, Session as K, FlutterwaveSyncResult as L, FlutterwavePlan as M, FlutterwaveProduct as N, FlutterwaveCurrency as O, FlutterwaveRefund as P, FlutterwaveAdapterOptions as Q, FlutterwaveTransaction as R, stringifyFlutterwaveMetadata as S, ChargeRecurringSubscriptionResult as T, InputFlutterwaveProduct as U, FlutterwaveWebhookEventRecord as V, Member as W, FlutterwaveAdapter as X, User as Y, FlutterwaveAdapterError as Z, getMetadataBoolean as _, processScheduledFlutterwaveCancellations as a, hasFlutterwaveMetadata as b, checkSeatLimit as c, decryptPaymentToken as d, createFlutterwaveAdapter as et, encryptPaymentToken as f, createRenewalMetadata as g, createProrationMetadata as h, chargeSubscriptionRenewal as i, FlutterwaveOptions as j, FlutterwaveCustomer as k, checkTeamLimit as l, createCheckoutMetadata as m, reconcileFlutterwaveRefunds as n, refundFlutterwaveTransaction as o, FlutterwaveMetadata as p, Subscription as q, reconcileFlutterwaveTransaction as r, syncFlutterwavePlans as s, flutterwave as t, FlutterwaveTokenChargeInput as tt, getOrganizationEntitlements as u, getMetadataNumber as v, ChargeRecurringSubscriptionInput as w, parseFlutterwaveMetadata as x, getMetadataString as y, FlutterwaveTransactionResponse as z };
|
|
943
|
-
//# sourceMappingURL=index-
|
|
944
|
+
//# sourceMappingURL=index-D4uWNxiw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D4uWNxiw.d.mts","names":["_$__types_ts0.FlutterwaveTransaction","_$__types_ts0.Subscription","_$__types_ts0.FlutterwavePlan","_$__types_ts0.FlutterwaveRefund"],"sources":["../src/schema.ts","../src/flutterwave-contracts.ts","../src/flutterwave-sdk.ts","../src/types.d.ts","../src/routes.ts","../src/version.ts","../src/metadata.ts","../src/token-crypto.ts","../src/limits.ts","../src/billing-store.ts","../src/operations.ts","../src/reconciliation.ts","../src/index.ts"],"mappings":";;;;;KAIK,kBAAkB,0BAA0B,4BAA4B,OAC3E;EAEE,QAAQ,OAAO,WAAW;EAC1B;EACA;;KAIC,qBAAqB;KAuBrB,sBAAsB;KA4BtB,iBAAiB;KAcjB,cAAc;KAed,sBAAsB;KAatB,gBAAgB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O,8BAA8B,QAAQ;EACzD,kBAAkB,uBAAuB,kBAAkB,QAAQ;;cAGxD,gCAAgC;WAClC;WACA;WACA;EAEG,YAAA,mBAAmB,iBAAiB;IAAY;IAAiB;;;;;;;;;;iBAmI/D,yBAAyB,SAAS,4BAA4B;;;KChNlE;KACA;UACK;EACb;EACA;EACA;;UAEa;EACb;EACA;EACA;EACA;;UAEa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb,eAAe;EACf,WAAW;EACX,WAAW;;UAEE;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;EACZ,YAAY;;UAEC;EACb;EACA;EACA;EACA;;UAEa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACI;IACA,gBAAgB,cAAc,iBAAiB;IAC/C,cAAc,cAAc,iBAAiB;IAC7C,kBAAkB,cAAc,iBAAiB;;EAErD,SAAS;EACT;EACA;EACA,YAAY;EACZ,YAAY;;UAEC;EACb;EACA,MAAM;IACF;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;MACI;;;;KAIA,4BAA4B;UACvB;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA,OAAO;;UAEM;EACb;EACA;EACA;EACA;;UAEa;EACb;EACA,OAAO,2BAA2B,QAAQ;EAC1C;EACA;EACA;EACA,yBAAyB;EACzB,sBAAsB;IAClB,MAAM;IACN,SAAS;IACT;IACA;KACD,KAAK,2BAA2B;EACnC,0BAA0B;IACtB,OAAO;IACP,cAAc;IACd,MAAM;KACP,KAAK,2BAA2B;EACnC,yBAAyB;IACrB,OAAO;IACP,cAAc;IACd,MAAM;KACP,KAAK,2BAA2B;EACnC,wBAAwB;IACpB,OAAO;IACP,cAAc;IACd,MAAM;KACP,KAAK,2BAA2B;EACnC,wBAAwB;IACpB,OAAO;IACP,cAAc;KACf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
|
1
|
-
import { $ as FlutterwaveSdkClient, A as FlutterwaveInitializeResult, B as FlutterwaveWebhookEvent, C as AnyFlutterwaveOptions, D as FlutterwaveClientLike, E as FlutterwaveCheckoutChannel, F as FlutterwaveSubaccountSplit, G as Organization, H as FlutterwaveWebhookPayload, I as FlutterwaveSubscription, J as SubscriptionOptions, K as Session, L as FlutterwaveSyncResult, M as FlutterwavePlan, N as FlutterwaveProduct, O as FlutterwaveCurrency, P as FlutterwaveRefund, Q as FlutterwaveAdapterOptions, R as FlutterwaveTransaction, S as stringifyFlutterwaveMetadata, T as ChargeRecurringSubscriptionResult, U as InputFlutterwaveProduct, V as FlutterwaveWebhookEventRecord, W as Member, X as FlutterwaveAdapter, Y as User, Z as FlutterwaveAdapterError, _ as getMetadataBoolean, a as processScheduledFlutterwaveCancellations, b as hasFlutterwaveMetadata, c as checkSeatLimit, d as decryptPaymentToken, et as createFlutterwaveAdapter, f as encryptPaymentToken, g as createRenewalMetadata, h as createProrationMetadata, i as chargeSubscriptionRenewal, j as FlutterwaveOptions, k as FlutterwaveCustomer, l as checkTeamLimit, m as createCheckoutMetadata, n as reconcileFlutterwaveRefunds, o as refundFlutterwaveTransaction, p as FlutterwaveMetadata, q as Subscription, r as reconcileFlutterwaveTransaction, s as syncFlutterwavePlans, t as flutterwave, tt as FlutterwaveTokenChargeInput, u as getOrganizationEntitlements, v as getMetadataNumber, w as ChargeRecurringSubscriptionInput, x as parseFlutterwaveMetadata, y as getMetadataString, z as FlutterwaveTransactionResponse } from "./index-
|
|
1
|
+
import { $ as FlutterwaveSdkClient, A as FlutterwaveInitializeResult, B as FlutterwaveWebhookEvent, C as AnyFlutterwaveOptions, D as FlutterwaveClientLike, E as FlutterwaveCheckoutChannel, F as FlutterwaveSubaccountSplit, G as Organization, H as FlutterwaveWebhookPayload, I as FlutterwaveSubscription, J as SubscriptionOptions, K as Session, L as FlutterwaveSyncResult, M as FlutterwavePlan, N as FlutterwaveProduct, O as FlutterwaveCurrency, P as FlutterwaveRefund, Q as FlutterwaveAdapterOptions, R as FlutterwaveTransaction, S as stringifyFlutterwaveMetadata, T as ChargeRecurringSubscriptionResult, U as InputFlutterwaveProduct, V as FlutterwaveWebhookEventRecord, W as Member, X as FlutterwaveAdapter, Y as User, Z as FlutterwaveAdapterError, _ as getMetadataBoolean, a as processScheduledFlutterwaveCancellations, b as hasFlutterwaveMetadata, c as checkSeatLimit, d as decryptPaymentToken, et as createFlutterwaveAdapter, f as encryptPaymentToken, g as createRenewalMetadata, h as createProrationMetadata, i as chargeSubscriptionRenewal, j as FlutterwaveOptions, k as FlutterwaveCustomer, l as checkTeamLimit, m as createCheckoutMetadata, n as reconcileFlutterwaveRefunds, o as refundFlutterwaveTransaction, p as FlutterwaveMetadata, q as Subscription, r as reconcileFlutterwaveTransaction, s as syncFlutterwavePlans, t as flutterwave, tt as FlutterwaveTokenChargeInput, u as getOrganizationEntitlements, v as getMetadataNumber, w as ChargeRecurringSubscriptionInput, x as parseFlutterwaveMetadata, y as getMetadataString, z as FlutterwaveTransactionResponse } from "./index-D4uWNxiw.mjs";
|
|
2
2
|
export { type AnyFlutterwaveOptions, type ChargeRecurringSubscriptionInput, type ChargeRecurringSubscriptionResult, type FlutterwaveAdapter, FlutterwaveAdapterError, type FlutterwaveAdapterOptions, type FlutterwaveCheckoutChannel, type FlutterwaveClientLike, type FlutterwaveCurrency, type FlutterwaveCustomer, type FlutterwaveInitializeResult, type FlutterwaveMetadata, type FlutterwaveOptions, type FlutterwavePlan, type FlutterwaveProduct, type FlutterwaveRefund, type FlutterwaveSdkClient, type FlutterwaveSubaccountSplit, type FlutterwaveSubscription, type FlutterwaveSyncResult, type FlutterwaveTokenChargeInput, type FlutterwaveTransaction, type FlutterwaveTransactionResponse, type FlutterwaveWebhookEvent, type FlutterwaveWebhookEventRecord, type FlutterwaveWebhookPayload, type InputFlutterwaveProduct, type Member, type Organization, type Session, type Subscription, type SubscriptionOptions, type User, chargeSubscriptionRenewal, checkSeatLimit, checkTeamLimit, createCheckoutMetadata, createFlutterwaveAdapter, createProrationMetadata, createRenewalMetadata, decryptPaymentToken, encryptPaymentToken, flutterwave, getMetadataBoolean, getMetadataNumber, getMetadataString, getOrganizationEntitlements, hasFlutterwaveMetadata, parseFlutterwaveMetadata, processScheduledFlutterwaveCancellations, reconcileFlutterwaveRefunds, reconcileFlutterwaveTransaction, refundFlutterwaveTransaction, stringifyFlutterwaveMetadata, syncFlutterwavePlans };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { a as getMetadataBoolean, c as hasFlutterwaveMetadata, i as createRenewalMetadata, l as parseFlutterwaveMetadata, n as createCheckoutMetadata, o as getMetadataNumber, r as createProrationMetadata, s as getMetadataString, t as PACKAGE_VERSION, u as stringifyFlutterwaveMetadata } from "./version-
|
|
2
|
-
import { createRequire } from "node:module";
|
|
1
|
+
import { a as getMetadataBoolean, c as hasFlutterwaveMetadata, i as createRenewalMetadata, l as parseFlutterwaveMetadata, n as createCheckoutMetadata, o as getMetadataNumber, r as createProrationMetadata, s as getMetadataString, t as PACKAGE_VERSION, u as stringifyFlutterwaveMetadata } from "./version-C3pJ_ZLK.mjs";
|
|
3
2
|
import { HIDE_METADATA, defineErrorCodes } from "better-auth";
|
|
4
3
|
import { createHash, timingSafeEqual } from "node:crypto";
|
|
5
|
-
import { APIError, createAuthEndpoint, getSessionFromCtx,
|
|
4
|
+
import { APIError, createAuthEndpoint, getSessionFromCtx, originCheckMiddleware, sessionMiddleware } from "better-auth/api";
|
|
6
5
|
import * as z from "zod";
|
|
7
6
|
import { Buffer } from "node:buffer";
|
|
8
7
|
import { mergeSchema } from "better-auth/db";
|
|
@@ -434,8 +433,48 @@ var FlutterwaveAdapterError = class extends Error {
|
|
|
434
433
|
this.cause = options?.cause;
|
|
435
434
|
}
|
|
436
435
|
};
|
|
437
|
-
function
|
|
438
|
-
|
|
436
|
+
function queryString(input) {
|
|
437
|
+
const query = new URLSearchParams();
|
|
438
|
+
for (const [key, value] of Object.entries(input)) if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") query.set(key, String(value));
|
|
439
|
+
const serialized = query.toString();
|
|
440
|
+
return serialized.length === 0 ? "" : `?${serialized}`;
|
|
441
|
+
}
|
|
442
|
+
function createHttpClient(fetchImpl, apiBaseUrl, secretKey) {
|
|
443
|
+
const request = async (path, method = "GET", body) => {
|
|
444
|
+
if (typeof fetchImpl !== "function") throw new Error("Fetch is not available");
|
|
445
|
+
const response = await fetchImpl(`${apiBaseUrl}${path}`, {
|
|
446
|
+
method,
|
|
447
|
+
headers: {
|
|
448
|
+
accept: "application/json",
|
|
449
|
+
authorization: `Bearer ${secretKey}`,
|
|
450
|
+
"content-type": "application/json"
|
|
451
|
+
},
|
|
452
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
453
|
+
});
|
|
454
|
+
let raw;
|
|
455
|
+
try {
|
|
456
|
+
raw = await response.json();
|
|
457
|
+
} catch {
|
|
458
|
+
throw new Error(`Flutterwave returned a non-JSON response (HTTP ${response.status})`);
|
|
459
|
+
}
|
|
460
|
+
if (!response.ok) throw new Error(messageFromUnknown(raw) ?? `Flutterwave request failed with HTTP ${response.status}`);
|
|
461
|
+
return raw;
|
|
462
|
+
};
|
|
463
|
+
const post = (path, body) => request(path, "POST", body);
|
|
464
|
+
return {
|
|
465
|
+
Transaction: {
|
|
466
|
+
verify: ({ id }) => request(`/v3/transactions/${id}/verify`),
|
|
467
|
+
verify_by_tx: ({ tx_ref }) => request(`/v3/transactions/verify_by_reference${queryString({ tx_ref })}`),
|
|
468
|
+
refund: ({ id, amount }) => post(`/v3/transactions/${id}/refund`, amount === void 0 ? {} : { amount })
|
|
469
|
+
},
|
|
470
|
+
PaymentPlan: { get_all: (query) => request(`/v3/payment-plans${queryString(query)}`) },
|
|
471
|
+
Subscription: {
|
|
472
|
+
fetch_all: (query) => request(`/v3/subscriptions${queryString(query)}`),
|
|
473
|
+
cancel: ({ id }) => request(`/v3/subscriptions/${id}/cancel`, "PUT"),
|
|
474
|
+
activate: ({ id }) => request(`/v3/subscriptions/${id}/activate`, "PUT")
|
|
475
|
+
},
|
|
476
|
+
Tokenized: { charge: (input) => post("/v3/tokenized-charges", input) }
|
|
477
|
+
};
|
|
439
478
|
}
|
|
440
479
|
function messageFromUnknown(value) {
|
|
441
480
|
if (typeof value === "string") return value;
|
|
@@ -462,20 +501,19 @@ const optionalPositiveAmountSchema = z.number().positive().optional();
|
|
|
462
501
|
/**
|
|
463
502
|
* Creates the provider boundary used by the plugin.
|
|
464
503
|
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
* required. This adapter intentionally uses only the SDK's Promise API.
|
|
504
|
+
* Uses Flutterwave's v3 HTTP API directly so applications do not need a separate
|
|
505
|
+
* SDK dependency. Inject `flutterwaveClient` for a custom provider boundary or
|
|
506
|
+
* `fetch` for controlled transport and tests.
|
|
469
507
|
*/
|
|
470
508
|
function createFlutterwaveAdapter(options) {
|
|
471
509
|
if (!options.publicKey) throw new FlutterwaveAdapterError("configuration", "publicKey is required");
|
|
472
510
|
if (!options.secretKey) throw new FlutterwaveAdapterError("configuration", "secretKey is required");
|
|
473
|
-
const client = options.flutterwaveClient ?? createSdkClient(options.publicKey, options.secretKey);
|
|
474
511
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
475
512
|
const configuredApiBaseUrl = options.apiBaseUrl ?? "https://api.flutterwave.com";
|
|
476
513
|
let end = configuredApiBaseUrl.length;
|
|
477
514
|
while (end > 0 && configuredApiBaseUrl.charCodeAt(end - 1) === 47) end--;
|
|
478
515
|
const apiBaseUrl = configuredApiBaseUrl.slice(0, end);
|
|
516
|
+
const client = options.flutterwaveClient ?? createHttpClient(fetchImpl, apiBaseUrl, options.secretKey);
|
|
479
517
|
return {
|
|
480
518
|
async initializePayment(input) {
|
|
481
519
|
const body = standardCheckoutInputSchema.parse(input);
|
|
@@ -902,7 +940,7 @@ async function configuredProducts(options) {
|
|
|
902
940
|
const initializeTransaction = (options, path) => createAuthEndpoint(path, {
|
|
903
941
|
method: "POST",
|
|
904
942
|
body: initializeBodySchema,
|
|
905
|
-
use: [sessionMiddleware,
|
|
943
|
+
use: [sessionMiddleware, originCheckMiddleware]
|
|
906
944
|
}, async (ctx) => {
|
|
907
945
|
const { user, referenceId } = await authenticatedReference(ctx, options, "initialize-transaction", ctx.body.referenceId);
|
|
908
946
|
if (options.subscription?.requireEmailVerification === true && ctx.body.plan && user.emailVerified !== true) throw new APIError("BAD_REQUEST", FLUTTERWAVE_ERROR_CODES.EMAIL_VERIFICATION_REQUIRED);
|
|
@@ -999,7 +1037,7 @@ const initializeTransaction = (options, path) => createAuthEndpoint(path, {
|
|
|
999
1037
|
const verifyTransaction = (options, path) => createAuthEndpoint(path, {
|
|
1000
1038
|
method: "POST",
|
|
1001
1039
|
body: verifyBodySchema,
|
|
1002
|
-
use: [sessionMiddleware,
|
|
1040
|
+
use: [sessionMiddleware, originCheckMiddleware]
|
|
1003
1041
|
}, async (ctx) => {
|
|
1004
1042
|
const store = createBillingStore(ctx);
|
|
1005
1043
|
const verified = await adapter$1(options).verifyTransaction({
|
|
@@ -1065,7 +1103,7 @@ async function findSubscription(ctx, id) {
|
|
|
1065
1103
|
const cancelSubscription = (options, path) => createAuthEndpoint(path, {
|
|
1066
1104
|
method: "POST",
|
|
1067
1105
|
body: subscriptionBodySchema,
|
|
1068
|
-
use: [sessionMiddleware,
|
|
1106
|
+
use: [sessionMiddleware, originCheckMiddleware]
|
|
1069
1107
|
}, async (ctx) => {
|
|
1070
1108
|
const store = createBillingStore(ctx);
|
|
1071
1109
|
const local = await findSubscription(ctx, ctx.body.subscriptionId);
|
|
@@ -1098,7 +1136,7 @@ const cancelSubscription = (options, path) => createAuthEndpoint(path, {
|
|
|
1098
1136
|
const restoreSubscription = (options, path) => createAuthEndpoint(path, {
|
|
1099
1137
|
method: "POST",
|
|
1100
1138
|
body: subscriptionBodySchema.omit({ atPeriodEnd: true }),
|
|
1101
|
-
use: [sessionMiddleware,
|
|
1139
|
+
use: [sessionMiddleware, originCheckMiddleware]
|
|
1102
1140
|
}, async (ctx) => {
|
|
1103
1141
|
const store = createBillingStore(ctx);
|
|
1104
1142
|
const local = await findSubscription(ctx, ctx.body.subscriptionId);
|