better-auth-flutterwave 0.4.3 → 1.0.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.es-ES.md +73 -346
- package/README.fr-FR.md +76 -346
- package/README.md +93 -344
- package/dist/client.d.mts +5 -6
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +2 -3
- package/dist/client.mjs.map +1 -1
- package/dist/{index-BqoHQ7eU.d.mts → index-CWQ-yaXU.d.mts} +17 -151
- package/dist/index-CWQ-yaXU.d.mts.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +33 -46
- package/dist/index.mjs.map +1 -1
- package/dist/{version-eSGk9I11.mjs → version-CvBysHjX.mjs} +4 -6
- package/dist/{version-eSGk9I11.mjs.map → version-CvBysHjX.mjs.map} +1 -1
- package/package.json +15 -17
- package/skills/better-auth-flutterwave-setup/SKILL.md +15 -14
- package/skills/better-auth-flutterwave-setup/agents/openai.yaml +1 -1
- package/skills/flutterwave-billing-flows/SKILL.md +19 -12
- package/skills/flutterwave-billing-flows/agents/openai.yaml +1 -1
- package/skills/flutterwave-catalog-limits/SKILL.md +15 -9
- package/skills/flutterwave-catalog-limits/agents/openai.yaml +1 -1
- package/skills/flutterwave-client-api/SKILL.md +16 -12
- package/skills/flutterwave-client-api/agents/openai.yaml +1 -1
- package/skills/flutterwave-local-subscriptions/SKILL.md +16 -17
- package/skills/flutterwave-local-subscriptions/agents/openai.yaml +1 -1
- package/skills/flutterwave-organization-billing/SKILL.md +14 -9
- package/skills/flutterwave-organization-billing/agents/openai.yaml +1 -1
- package/skills/flutterwave-schema-migrations/SKILL.md +16 -16
- package/skills/flutterwave-schema-migrations/agents/openai.yaml +1 -1
- package/skills/flutterwave-tanstack-start/SKILL.md +15 -17
- package/skills/flutterwave-tanstack-start/agents/openai.yaml +1 -1
- package/skills/flutterwave-testing-fixtures/SKILL.md +17 -11
- package/skills/flutterwave-testing-fixtures/agents/openai.yaml +1 -1
- package/skills/flutterwave-webhooks-events/SKILL.md +17 -13
- package/skills/flutterwave-webhooks-events/agents/openai.yaml +1 -1
- package/dist/index-BqoHQ7eU.d.mts.map +0 -1
|
@@ -2,7 +2,6 @@ import { AuthContext, BetterAuthPlugin, GenericEndpointContext, InferOptionSchem
|
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import { BetterAuthPluginDBSchema, DBFieldAttribute } from "better-auth/db";
|
|
4
4
|
import { Member, Organization } from "better-auth/plugins/organization";
|
|
5
|
-
//#region src/schema.d.ts
|
|
6
5
|
type PluginSchemaTable<TableName extends string, FieldName extends string> = Record<TableName, {
|
|
7
6
|
fields: Record<FieldName, DBFieldAttribute>;
|
|
8
7
|
disableMigration?: boolean;
|
|
@@ -16,8 +15,6 @@ type WebhookEventsSchema = PluginSchemaTable<"flutterwaveWebhookEvent", "eventId
|
|
|
16
15
|
type RefundsSchema = PluginSchemaTable<"flutterwaveRefund", "refundId" | "transactionId" | "txRef" | "referenceId" | "amount" | "currency" | "status" | "reason" | "metadata" | "reconciledAt" | "createdAt" | "updatedAt">;
|
|
17
16
|
type FlutterwavePluginSchema = TransactionsSchema & SubscriptionsSchema & ProductsSchema & PlansSchema & WebhookEventsSchema & RefundsSchema;
|
|
18
17
|
declare const getSchema: (options: FlutterwaveOptions) => BetterAuthPluginDBSchema;
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/flutterwave-contracts.d.ts
|
|
21
18
|
declare const standardCheckoutInputSchema: z.ZodObject<{
|
|
22
19
|
tx_ref: z.ZodString;
|
|
23
20
|
amount: z.ZodCoercedNumber<unknown>;
|
|
@@ -113,8 +110,6 @@ type FlutterwavePaymentPlanData = z.infer<typeof paymentPlanSchema>;
|
|
|
113
110
|
type FlutterwaveSubscriptionData = z.infer<typeof subscriptionSchema>;
|
|
114
111
|
type FlutterwaveTokenChargeInput = z.infer<typeof tokenChargeInputSchema>;
|
|
115
112
|
type FlutterwaveRefundData = z.infer<typeof refundSchema>;
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/flutterwave-sdk.d.ts
|
|
118
113
|
type SdkResult = Promise<unknown>;
|
|
119
114
|
/** The deliberately small provider boundary used by this package. */
|
|
120
115
|
interface FlutterwaveClient {
|
|
@@ -194,8 +189,6 @@ declare class FlutterwaveAdapterError extends Error {
|
|
|
194
189
|
* `fetch` for controlled transport and tests.
|
|
195
190
|
*/
|
|
196
191
|
declare function createFlutterwaveAdapter(options: FlutterwaveAdapterOptions): FlutterwaveAdapter;
|
|
197
|
-
//#endregion
|
|
198
|
-
//#region src/types.d.ts
|
|
199
192
|
type FlutterwaveCurrency = string;
|
|
200
193
|
type FlutterwaveCheckoutChannel = "card" | "account" | "banktransfer" | "ussd" | "mobilemoney" | "mpesa" | "fawry" | "enaira" | "opay" | "applepay" | "googlepay";
|
|
201
194
|
interface FlutterwaveCustomer {
|
|
@@ -463,8 +456,6 @@ interface ChargeRecurringSubscriptionResult {
|
|
|
463
456
|
status: "success" | "pending" | "failed";
|
|
464
457
|
data: FlutterwaveTransactionResponse | FlutterwaveInitializeResult;
|
|
465
458
|
}
|
|
466
|
-
//#endregion
|
|
467
|
-
//#region src/routes.d.ts
|
|
468
459
|
declare const initializeTransaction: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
469
460
|
method: "POST";
|
|
470
461
|
body: z.ZodObject<{
|
|
@@ -483,13 +474,13 @@ declare const initializeTransaction: <P extends string>(options: AnyFlutterwaveO
|
|
|
483
474
|
transactionSplitRatio: z.ZodOptional<z.ZodNumber>;
|
|
484
475
|
transactionChargeType: z.ZodOptional<z.ZodEnum<{
|
|
485
476
|
flat: "flat";
|
|
486
|
-
percentage: "percentage";
|
|
487
477
|
flat_subaccount: "flat_subaccount";
|
|
478
|
+
percentage: "percentage";
|
|
488
479
|
}>>;
|
|
489
480
|
transactionCharge: z.ZodOptional<z.ZodNumber>;
|
|
490
481
|
}, z.core.$strip>>>;
|
|
491
482
|
}, z.core.$strip>;
|
|
492
|
-
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
483
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
493
484
|
session: {
|
|
494
485
|
session: Record<string, any> & {
|
|
495
486
|
id: string;
|
|
@@ -511,7 +502,7 @@ declare const initializeTransaction: <P extends string>(options: AnyFlutterwaveO
|
|
|
511
502
|
image?: string | null | undefined;
|
|
512
503
|
};
|
|
513
504
|
};
|
|
514
|
-
}>>
|
|
505
|
+
}>>)[];
|
|
515
506
|
}, {
|
|
516
507
|
kind: "checkout";
|
|
517
508
|
url: string;
|
|
@@ -525,7 +516,7 @@ declare const verifyTransaction: <P extends string>(options: AnyFlutterwaveOptio
|
|
|
525
516
|
txRef: z.ZodOptional<z.ZodString>;
|
|
526
517
|
referenceId: z.ZodOptional<z.ZodString>;
|
|
527
518
|
}, z.core.$strip>;
|
|
528
|
-
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
519
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
529
520
|
session: {
|
|
530
521
|
session: Record<string, any> & {
|
|
531
522
|
id: string;
|
|
@@ -547,7 +538,7 @@ declare const verifyTransaction: <P extends string>(options: AnyFlutterwaveOptio
|
|
|
547
538
|
image?: string | null | undefined;
|
|
548
539
|
};
|
|
549
540
|
};
|
|
550
|
-
}>>
|
|
541
|
+
}>>)[];
|
|
551
542
|
}, {
|
|
552
543
|
status: string;
|
|
553
544
|
txRef: string;
|
|
@@ -621,7 +612,7 @@ declare const cancelSubscription: <P extends string>(options: AnyFlutterwaveOpti
|
|
|
621
612
|
subscriptionId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
622
613
|
atPeriodEnd: z.ZodOptional<z.ZodBoolean>;
|
|
623
614
|
}, z.core.$strip>;
|
|
624
|
-
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
615
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
625
616
|
session: {
|
|
626
617
|
session: Record<string, any> & {
|
|
627
618
|
id: string;
|
|
@@ -643,7 +634,7 @@ declare const cancelSubscription: <P extends string>(options: AnyFlutterwaveOpti
|
|
|
643
634
|
image?: string | null | undefined;
|
|
644
635
|
};
|
|
645
636
|
};
|
|
646
|
-
}>>
|
|
637
|
+
}>>)[];
|
|
647
638
|
}, {
|
|
648
639
|
status: string;
|
|
649
640
|
}>;
|
|
@@ -652,7 +643,7 @@ declare const restoreSubscription: <P extends string>(options: AnyFlutterwaveOpt
|
|
|
652
643
|
body: z.ZodObject<{
|
|
653
644
|
subscriptionId: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
654
645
|
}, z.core.$strip>;
|
|
655
|
-
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
646
|
+
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
656
647
|
session: {
|
|
657
648
|
session: Record<string, any> & {
|
|
658
649
|
id: string;
|
|
@@ -674,116 +665,12 @@ declare const restoreSubscription: <P extends string>(options: AnyFlutterwaveOpt
|
|
|
674
665
|
image?: string | null | undefined;
|
|
675
666
|
};
|
|
676
667
|
};
|
|
677
|
-
}>>
|
|
668
|
+
}>>)[];
|
|
678
669
|
}, {
|
|
679
670
|
status: string;
|
|
680
671
|
}>;
|
|
681
|
-
declare const createSubscription:
|
|
682
|
-
|
|
683
|
-
body: z.ZodObject<{
|
|
684
|
-
amount: z.ZodOptional<z.ZodNumber>;
|
|
685
|
-
currency: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
686
|
-
redirectUrl: z.ZodString;
|
|
687
|
-
txRef: z.ZodOptional<z.ZodString>;
|
|
688
|
-
referenceId: z.ZodOptional<z.ZodString>;
|
|
689
|
-
plan: z.ZodOptional<z.ZodString>;
|
|
690
|
-
product: z.ZodOptional<z.ZodString>;
|
|
691
|
-
quantity: z.ZodDefault<z.ZodNumber>;
|
|
692
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
693
|
-
paymentOptions: z.ZodOptional<z.ZodString>;
|
|
694
|
-
subaccounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
695
|
-
id: z.ZodString;
|
|
696
|
-
transactionSplitRatio: z.ZodOptional<z.ZodNumber>;
|
|
697
|
-
transactionChargeType: z.ZodOptional<z.ZodEnum<{
|
|
698
|
-
flat: "flat";
|
|
699
|
-
percentage: "percentage";
|
|
700
|
-
flat_subaccount: "flat_subaccount";
|
|
701
|
-
}>>;
|
|
702
|
-
transactionCharge: z.ZodOptional<z.ZodNumber>;
|
|
703
|
-
}, z.core.$strip>>>;
|
|
704
|
-
}, z.core.$strip>;
|
|
705
|
-
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
706
|
-
session: {
|
|
707
|
-
session: Record<string, any> & {
|
|
708
|
-
id: string;
|
|
709
|
-
createdAt: Date;
|
|
710
|
-
updatedAt: Date;
|
|
711
|
-
userId: string;
|
|
712
|
-
expiresAt: Date;
|
|
713
|
-
token: string;
|
|
714
|
-
ipAddress?: string | null | undefined;
|
|
715
|
-
userAgent?: string | null | undefined;
|
|
716
|
-
};
|
|
717
|
-
user: Record<string, any> & {
|
|
718
|
-
id: string;
|
|
719
|
-
createdAt: Date;
|
|
720
|
-
updatedAt: Date;
|
|
721
|
-
email: string;
|
|
722
|
-
emailVerified: boolean;
|
|
723
|
-
name: string;
|
|
724
|
-
image?: string | null | undefined;
|
|
725
|
-
};
|
|
726
|
-
};
|
|
727
|
-
}>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>)[];
|
|
728
|
-
}, {
|
|
729
|
-
kind: "checkout";
|
|
730
|
-
url: string;
|
|
731
|
-
txRef: string;
|
|
732
|
-
redirect: true;
|
|
733
|
-
}>;
|
|
734
|
-
declare const upgradeSubscription: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
735
|
-
method: "POST";
|
|
736
|
-
body: z.ZodObject<{
|
|
737
|
-
amount: z.ZodOptional<z.ZodNumber>;
|
|
738
|
-
currency: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
|
|
739
|
-
redirectUrl: z.ZodString;
|
|
740
|
-
txRef: z.ZodOptional<z.ZodString>;
|
|
741
|
-
referenceId: z.ZodOptional<z.ZodString>;
|
|
742
|
-
plan: z.ZodOptional<z.ZodString>;
|
|
743
|
-
product: z.ZodOptional<z.ZodString>;
|
|
744
|
-
quantity: z.ZodDefault<z.ZodNumber>;
|
|
745
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
746
|
-
paymentOptions: z.ZodOptional<z.ZodString>;
|
|
747
|
-
subaccounts: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
748
|
-
id: z.ZodString;
|
|
749
|
-
transactionSplitRatio: z.ZodOptional<z.ZodNumber>;
|
|
750
|
-
transactionChargeType: z.ZodOptional<z.ZodEnum<{
|
|
751
|
-
flat: "flat";
|
|
752
|
-
percentage: "percentage";
|
|
753
|
-
flat_subaccount: "flat_subaccount";
|
|
754
|
-
}>>;
|
|
755
|
-
transactionCharge: z.ZodOptional<z.ZodNumber>;
|
|
756
|
-
}, z.core.$strip>>>;
|
|
757
|
-
}, z.core.$strip>;
|
|
758
|
-
use: (import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<{
|
|
759
|
-
session: {
|
|
760
|
-
session: Record<string, any> & {
|
|
761
|
-
id: string;
|
|
762
|
-
createdAt: Date;
|
|
763
|
-
updatedAt: Date;
|
|
764
|
-
userId: string;
|
|
765
|
-
expiresAt: Date;
|
|
766
|
-
token: string;
|
|
767
|
-
ipAddress?: string | null | undefined;
|
|
768
|
-
userAgent?: string | null | undefined;
|
|
769
|
-
};
|
|
770
|
-
user: Record<string, any> & {
|
|
771
|
-
id: string;
|
|
772
|
-
createdAt: Date;
|
|
773
|
-
updatedAt: Date;
|
|
774
|
-
email: string;
|
|
775
|
-
emailVerified: boolean;
|
|
776
|
-
name: string;
|
|
777
|
-
image?: string | null | undefined;
|
|
778
|
-
};
|
|
779
|
-
};
|
|
780
|
-
}>> | import("better-auth").Middleware<import("better-auth").MiddlewareOptions, (inputContext: import("better-auth").MiddlewareInputContext<import("better-auth").MiddlewareOptions>) => Promise<void>>)[];
|
|
781
|
-
}, {
|
|
782
|
-
kind: "checkout";
|
|
783
|
-
url: string;
|
|
784
|
-
txRef: string;
|
|
785
|
-
redirect: true;
|
|
786
|
-
}>;
|
|
672
|
+
declare const createSubscription: typeof initializeTransaction;
|
|
673
|
+
declare const upgradeSubscription: typeof initializeTransaction;
|
|
787
674
|
declare const listProducts: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
788
675
|
method: "GET";
|
|
789
676
|
}, {
|
|
@@ -805,21 +692,17 @@ declare const getConfig: <P extends string>(options: AnyFlutterwaveOptions, path
|
|
|
805
692
|
declare const flutterwaveWebhook: <P extends string>(options: AnyFlutterwaveOptions, path: P) => import("better-auth").StrictEndpoint<P, {
|
|
806
693
|
method: "POST";
|
|
807
694
|
metadata: {
|
|
695
|
+
scope: "server";
|
|
808
696
|
openapi: {
|
|
809
697
|
operationId: string;
|
|
810
698
|
};
|
|
811
|
-
scope: "server";
|
|
812
699
|
};
|
|
813
700
|
cloneRequest: true;
|
|
814
701
|
disableBody: true;
|
|
815
702
|
}, {
|
|
816
703
|
received: boolean;
|
|
817
704
|
}>;
|
|
818
|
-
|
|
819
|
-
//#region src/version.d.ts
|
|
820
|
-
declare const PACKAGE_VERSION = "0.4.3";
|
|
821
|
-
//#endregion
|
|
822
|
-
//#region src/metadata.d.ts
|
|
705
|
+
declare const PACKAGE_VERSION = "1.0.1";
|
|
823
706
|
type FlutterwaveMetadata = Record<string, unknown>;
|
|
824
707
|
interface CheckoutMetadataInput {
|
|
825
708
|
referenceId: string;
|
|
@@ -857,8 +740,6 @@ declare function getMetadataBoolean(metadata: FlutterwaveMetadata, key: string):
|
|
|
857
740
|
declare function createCheckoutMetadata(input: CheckoutMetadataInput): FlutterwaveMetadata;
|
|
858
741
|
declare function createProrationMetadata(input: ProrationMetadataInput): FlutterwaveMetadata;
|
|
859
742
|
declare function createRenewalMetadata(input: RenewalMetadataInput): FlutterwaveMetadata;
|
|
860
|
-
//#endregion
|
|
861
|
-
//#region src/flutterwave-v4.d.ts
|
|
862
743
|
interface FlutterwaveV4Options {
|
|
863
744
|
clientId: string;
|
|
864
745
|
clientSecret: string;
|
|
@@ -954,23 +835,15 @@ interface FlutterwaveV4Adapter {
|
|
|
954
835
|
* fields only; raw PAN/CVV handling belongs in a PCI-compliant client flow.
|
|
955
836
|
*/
|
|
956
837
|
declare function createFlutterwaveV4Adapter(options: FlutterwaveV4Options): FlutterwaveV4Adapter;
|
|
957
|
-
//#endregion
|
|
958
|
-
//#region src/token-crypto.d.ts
|
|
959
838
|
declare function encryptPaymentToken(token: string, secret: string): Promise<string>;
|
|
960
839
|
declare function decryptPaymentToken(value: string, secret: string): Promise<string>;
|
|
961
|
-
//#endregion
|
|
962
|
-
//#region src/limits.d.ts
|
|
963
840
|
declare const checkSeatLimit: (ctx: GenericEndpointContext, organizationId: string, seatsToAdd?: number) => Promise<boolean>;
|
|
964
841
|
declare function getOrganizationEntitlements(ctx: GenericEndpointContext, organizationId: string, options: AnyFlutterwaveOptions): Promise<{
|
|
965
842
|
limits: Record<string, number>;
|
|
966
843
|
features: string[];
|
|
967
844
|
}>;
|
|
968
845
|
declare const checkTeamLimit: (ctx: GenericEndpointContext, organizationId: string, maxTeams: number) => Promise<boolean>;
|
|
969
|
-
//#endregion
|
|
970
|
-
//#region src/billing-store.d.ts
|
|
971
846
|
type BillingStoreAdapter = Pick<GenericEndpointContext["context"]["adapter"], "create" | "findOne" | "findMany" | "update" | "updateMany">;
|
|
972
|
-
//#endregion
|
|
973
|
-
//#region src/operations.d.ts
|
|
974
847
|
declare function syncFlutterwavePlans(ctx: GenericEndpointContext, options: AnyFlutterwaveOptions): Promise<FlutterwaveSyncResult>;
|
|
975
848
|
declare function chargeSubscriptionRenewal(ctx: GenericEndpointContext, options: AnyFlutterwaveOptions, input: ChargeRecurringSubscriptionInput): Promise<ChargeRecurringSubscriptionResult>;
|
|
976
849
|
/** Call from an independently authorized scheduled job; no browser endpoint is exposed. */
|
|
@@ -991,8 +864,6 @@ declare function refundFlutterwaveTransaction(ctx: GenericEndpointContext, optio
|
|
|
991
864
|
amount?: number;
|
|
992
865
|
reason?: string;
|
|
993
866
|
}): Promise<FlutterwaveRefund>;
|
|
994
|
-
//#endregion
|
|
995
|
-
//#region src/reconciliation.d.ts
|
|
996
867
|
type FlutterwaveReconciliationSource = "webhook" | "queue" | "admin" | "server" | "browser";
|
|
997
868
|
interface ReconcileFlutterwaveTransactionInput {
|
|
998
869
|
txRef?: string;
|
|
@@ -1011,19 +882,17 @@ declare function reconcileFlutterwaveTransaction(ctx: GenericEndpointContext, op
|
|
|
1011
882
|
status?: undefined;
|
|
1012
883
|
data?: undefined;
|
|
1013
884
|
} | {
|
|
885
|
+
error?: undefined;
|
|
1014
886
|
ok: true;
|
|
1015
887
|
source: FlutterwaveReconciliationSource;
|
|
1016
888
|
txRef: string;
|
|
1017
889
|
status: string;
|
|
1018
890
|
data: FlutterwaveTransactionResponse;
|
|
1019
|
-
error?: undefined;
|
|
1020
891
|
}>;
|
|
1021
892
|
declare function reconcileFlutterwaveRefunds(ctx: GenericEndpointContext, options: AnyFlutterwaveOptions): Promise<{
|
|
1022
893
|
status: "success";
|
|
1023
894
|
count: number;
|
|
1024
895
|
}>;
|
|
1025
|
-
//#endregion
|
|
1026
|
-
//#region src/index.d.ts
|
|
1027
896
|
declare module "better-auth" {
|
|
1028
897
|
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
1029
898
|
flutterwave: {
|
|
@@ -1031,9 +900,7 @@ declare module "better-auth" {
|
|
|
1031
900
|
};
|
|
1032
901
|
}
|
|
1033
902
|
}
|
|
1034
|
-
declare const INTERNAL_ERROR_CODES:
|
|
1035
|
-
[x: string]: import("better-auth").RawError<string>;
|
|
1036
|
-
};
|
|
903
|
+
declare const INTERNAL_ERROR_CODES: NonNullable<BetterAuthPlugin["$ERROR_CODES"]>;
|
|
1037
904
|
type FlutterwavePluginEndpoints = {
|
|
1038
905
|
initializeFlutterwaveTransaction: ReturnType<typeof initializeTransaction>;
|
|
1039
906
|
verifyFlutterwaveTransaction: ReturnType<typeof verifyTransaction>;
|
|
@@ -1060,6 +927,5 @@ type FlutterwavePluginInstance<O extends AnyFlutterwaveOptions> = Omit<BetterAut
|
|
|
1060
927
|
};
|
|
1061
928
|
};
|
|
1062
929
|
declare const flutterwave: <TFlutterwaveClient extends FlutterwaveClientLike = FlutterwaveClientLike, O extends FlutterwaveOptions<TFlutterwaveClient> = FlutterwaveOptions<TFlutterwaveClient>>(options: O) => FlutterwavePluginInstance<O>;
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
//# sourceMappingURL=index-BqoHQ7eU.d.mts.map
|
|
930
|
+
export { FlutterwaveWebhookEventRecord as $, hasFlutterwaveMetadata as A, FlutterwaveCustomer as B, FlutterwaveMetadata as C, getMetadataBoolean as D, createRenewalMetadata as E, ChargeRecurringSubscriptionInput as F, FlutterwaveRefund as G, FlutterwaveOptions as H, ChargeRecurringSubscriptionResult as I, FlutterwaveSyncResult as J, FlutterwaveSubaccountSplit as K, FlutterwaveCheckoutChannel as L, stringifyFlutterwaveMetadata as M, PACKAGE_VERSION as N, getMetadataNumber as O, AnyFlutterwaveOptions as P, FlutterwaveWebhookEvent as Q, FlutterwaveClientLike as R, createFlutterwaveV4Adapter as S, createProrationMetadata as T, FlutterwavePlan as U, FlutterwaveInitializeResult as V, FlutterwaveProduct as W, FlutterwaveTransactionResponse as X, FlutterwaveTransaction as Y, FlutterwaveV4WebhookEvent as Z, FlutterwaveV4CustomerInput as _, processScheduledFlutterwaveCancellations as a, Subscription as at, FlutterwaveV4RefundReason as b, checkSeatLimit as c, FlutterwaveAdapter as ct, decryptPaymentToken as d, FlutterwaveSdkClient as dt, FlutterwaveWebhookPayload as et, encryptPaymentToken as f, createFlutterwaveAdapter as ft, FlutterwaveV4ChargeInput as g, FlutterwaveV4ChargeAuthorization as h, chargeSubscriptionRenewal as i, Session as it, parseFlutterwaveMetadata as j, getMetadataString as k, checkTeamLimit as l, FlutterwaveAdapterError as lt, FlutterwaveV4CardPaymentMethodInput as m, reconcileFlutterwaveRefunds as n, Member as nt, refundFlutterwaveTransaction as o, SubscriptionOptions as ot, FlutterwaveV4Adapter as p, FlutterwaveTokenChargeInput as pt, FlutterwaveSubscription as q, reconcileFlutterwaveTransaction as r, Organization as rt, syncFlutterwavePlans as s, User as st, flutterwave as t, InputFlutterwaveProduct as tt, getOrganizationEntitlements as u, FlutterwaveAdapterOptions as ut, FlutterwaveV4Options as v, createCheckoutMetadata as w, FlutterwaveV4Resource as x, FlutterwaveV4RefundInput as y, FlutterwaveCurrency as z };
|
|
931
|
+
//# sourceMappingURL=index-CWQ-yaXU.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CWQ-yaXU.d.mts","names":["_$__types_ts0.FlutterwavePlan","_$__types_ts0.FlutterwaveRefund"],"sources":["../src/schema.ts","../src/flutterwave-contracts.ts","../src/flutterwave-sdk.ts","../src/types.ts","../src/routes.ts","../src/version.ts","../src/metadata.ts","../src/flutterwave-v4.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;KAgBT,0BAA0B,qBACpC,sBACA,iBACA,cACA,sBACA;cA0IW,YAAS,SAAa,uBAAqB;cCzP3C,6BAA2B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCxB,EAAA,KAAA;cAEH,oBAAkB,EAAA;;GAIf,EAAA,KAAA;cAEH,mBAAiB,EAAA;;;;;;;;;;;;;;;;;;GA2Bd,EAAA,KAAA;cAEH,mBAAiB,EAAA;;;;;;;;;GAc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;EACjB,qBAAqB;EACrB,OAAO,KAAK;IAAkB,SAAS;;;cAG5B,cACX,2BAA2B,wBAAwB,uBACnD,UAAU,mBAAmB,sBAAsB,mBAAmB,qBAAmB,SAEhF,MACR,0BAA0B"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as FlutterwaveWebhookEventRecord, A as hasFlutterwaveMetadata, B as FlutterwaveCustomer, C as FlutterwaveMetadata, D as getMetadataBoolean, E as createRenewalMetadata, F as ChargeRecurringSubscriptionInput, G as FlutterwaveRefund, H as FlutterwaveOptions, I as ChargeRecurringSubscriptionResult, J as FlutterwaveSyncResult, K as FlutterwaveSubaccountSplit, L as FlutterwaveCheckoutChannel, M as stringifyFlutterwaveMetadata, O as getMetadataNumber, P as AnyFlutterwaveOptions, Q as FlutterwaveWebhookEvent, R as FlutterwaveClientLike, S as createFlutterwaveV4Adapter, T as createProrationMetadata, U as FlutterwavePlan, V as FlutterwaveInitializeResult, W as FlutterwaveProduct, X as FlutterwaveTransactionResponse, Y as FlutterwaveTransaction, Z as FlutterwaveV4WebhookEvent, _ as FlutterwaveV4CustomerInput, a as processScheduledFlutterwaveCancellations, at as Subscription, b as FlutterwaveV4RefundReason, c as checkSeatLimit, ct as FlutterwaveAdapter, d as decryptPaymentToken, dt as FlutterwaveSdkClient, et as FlutterwaveWebhookPayload, f as encryptPaymentToken, ft as createFlutterwaveAdapter, g as FlutterwaveV4ChargeInput, h as FlutterwaveV4ChargeAuthorization, i as chargeSubscriptionRenewal, it as Session, j as parseFlutterwaveMetadata, k as getMetadataString, l as checkTeamLimit, lt as FlutterwaveAdapterError, m as FlutterwaveV4CardPaymentMethodInput, n as reconcileFlutterwaveRefunds, nt as Member, o as refundFlutterwaveTransaction, ot as SubscriptionOptions, p as FlutterwaveV4Adapter, pt as FlutterwaveTokenChargeInput, q as FlutterwaveSubscription, r as reconcileFlutterwaveTransaction, rt as Organization, s as syncFlutterwavePlans, st as User, t as flutterwave, tt as InputFlutterwaveProduct, u as getOrganizationEntitlements, ut as FlutterwaveAdapterOptions, v as FlutterwaveV4Options, w as createCheckoutMetadata, x as FlutterwaveV4Resource, y as FlutterwaveV4RefundInput, z as FlutterwaveCurrency } from "./index-CWQ-yaXU.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 FlutterwaveV4Adapter, type FlutterwaveV4CardPaymentMethodInput, type FlutterwaveV4ChargeAuthorization, type FlutterwaveV4ChargeInput, type FlutterwaveV4CustomerInput, type FlutterwaveV4Options, type FlutterwaveV4RefundInput, type FlutterwaveV4RefundReason, type FlutterwaveV4Resource, type FlutterwaveV4WebhookEvent, 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, createFlutterwaveV4Adapter, createProrationMetadata, createRenewalMetadata, decryptPaymentToken, encryptPaymentToken, flutterwave, getMetadataBoolean, getMetadataNumber, getMetadataString, getOrganizationEntitlements, hasFlutterwaveMetadata, parseFlutterwaveMetadata, processScheduledFlutterwaveCancellations, reconcileFlutterwaveRefunds, reconcileFlutterwaveTransaction, refundFlutterwaveTransaction, stringifyFlutterwaveMetadata, syncFlutterwavePlans };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
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-CvBysHjX.mjs";
|
|
2
2
|
import { HIDE_METADATA, defineErrorCodes } from "better-auth";
|
|
3
3
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
4
4
|
import { APIError, createAuthEndpoint, getSessionFromCtx, originCheckMiddleware, sessionMiddleware } from "better-auth/api";
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import { Buffer } from "node:buffer";
|
|
7
7
|
import { mergeSchema } from "better-auth/db";
|
|
8
|
-
|
|
8
|
+
// src/billing-store.ts
|
|
9
9
|
function sortSubscriptionsForCurrent(subscriptions) {
|
|
10
10
|
const statusRank = /* @__PURE__ */ new Map([
|
|
11
11
|
["active", 0],
|
|
@@ -364,8 +364,7 @@ function createBillingStoreFromAdapter(adapter) {
|
|
|
364
364
|
}])
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
|
|
368
|
-
//#region src/flutterwave-contracts.ts
|
|
367
|
+
// src/flutterwave-contracts.ts
|
|
369
368
|
const currencySchema = z.string().regex(/^[A-Z]{3}$/, "Currency must be a three-letter ISO code");
|
|
370
369
|
const positiveAmountSchema = z.coerce.number().positive();
|
|
371
370
|
const optionalDateSchema = z.string().nullable().optional();
|
|
@@ -455,8 +454,7 @@ const refundSchema = z.object({
|
|
|
455
454
|
status: z.string().min(1),
|
|
456
455
|
created_at: optionalDateSchema
|
|
457
456
|
}).passthrough();
|
|
458
|
-
|
|
459
|
-
//#region src/flutterwave-sdk.ts
|
|
457
|
+
// src/flutterwave-sdk.ts
|
|
460
458
|
var FlutterwaveAdapterError = class extends Error {
|
|
461
459
|
operation;
|
|
462
460
|
status;
|
|
@@ -610,8 +608,7 @@ function createFlutterwaveAdapter(options) {
|
|
|
610
608
|
}), refundSchema)
|
|
611
609
|
};
|
|
612
610
|
}
|
|
613
|
-
|
|
614
|
-
//#region src/operation-ledger.ts
|
|
611
|
+
// src/operation-ledger.ts
|
|
615
612
|
const LEASE_MS = 3e5;
|
|
616
613
|
function busy() {
|
|
617
614
|
return new APIError("SERVICE_UNAVAILABLE", { message: "Billing operation is in progress; retry later" });
|
|
@@ -659,8 +656,7 @@ async function failOperation(store, operation) {
|
|
|
659
656
|
updatedAt: /* @__PURE__ */ new Date()
|
|
660
657
|
});
|
|
661
658
|
}
|
|
662
|
-
|
|
663
|
-
//#region src/token-crypto.ts
|
|
659
|
+
// src/token-crypto.ts
|
|
664
660
|
const encoder = new TextEncoder();
|
|
665
661
|
const decoder = new TextDecoder();
|
|
666
662
|
function toBase64(value) {
|
|
@@ -692,8 +688,7 @@ async function decryptPaymentToken(value, secret) {
|
|
|
692
688
|
}, await deriveKey(secret), ciphertext);
|
|
693
689
|
return decoder.decode(decrypted);
|
|
694
690
|
}
|
|
695
|
-
|
|
696
|
-
//#region src/utils.ts
|
|
691
|
+
// src/utils.ts
|
|
697
692
|
function getPlanSeatAmount(plan) {
|
|
698
693
|
if (plan.seatAmount !== void 0) {
|
|
699
694
|
if (typeof plan.seatAmount === "number" && Number.isFinite(plan.seatAmount) && plan.seatAmount >= 0) return plan.seatAmount;
|
|
@@ -772,8 +767,7 @@ function getNextPeriodEnd(startDate, interval) {
|
|
|
772
767
|
}
|
|
773
768
|
return date;
|
|
774
769
|
}
|
|
775
|
-
|
|
776
|
-
//#region src/billing-lifecycle.ts
|
|
770
|
+
// src/billing-lifecycle.ts
|
|
777
771
|
const fulfillmentSchema = z.object({
|
|
778
772
|
initialCompletion: z.boolean(),
|
|
779
773
|
completed: z.array(z.enum([
|
|
@@ -917,8 +911,7 @@ async function recordVerifiedPayment(ctx, options, expected, verified, webhookEv
|
|
|
917
911
|
}
|
|
918
912
|
}
|
|
919
913
|
}
|
|
920
|
-
|
|
921
|
-
//#region src/reference-access.ts
|
|
914
|
+
// src/reference-access.ts
|
|
922
915
|
const DEFAULT_BILLING_ORG_ROLES = ["owner", "admin"];
|
|
923
916
|
function normalizeBillingRoles(roles) {
|
|
924
917
|
return new Set(roles.map((value) => value.trim()).filter((value) => value !== ""));
|
|
@@ -964,17 +957,15 @@ async function authorizeBillingReference(ctx, options, data) {
|
|
|
964
957
|
}
|
|
965
958
|
throw new APIError("UNAUTHORIZED");
|
|
966
959
|
}
|
|
967
|
-
|
|
968
|
-
//#region src/route-modules/webhook.ts
|
|
960
|
+
// src/route-modules/webhook.ts
|
|
969
961
|
function getWebhookRequest(ctx) {
|
|
970
962
|
return ctx.requestClone ?? ctx.request;
|
|
971
963
|
}
|
|
972
964
|
function getWebhookHeaders(ctx) {
|
|
973
965
|
return ctx.headers ?? ctx.request?.headers;
|
|
974
966
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
const FLUTTERWAVE_ERROR_CODES = defineErrorCodes({
|
|
967
|
+
// src/route-modules/shared.ts
|
|
968
|
+
const FLUTTERWAVE_ERROR_MESSAGES = {
|
|
978
969
|
SUBSCRIPTION_NOT_FOUND: "Subscription not found",
|
|
979
970
|
SUBSCRIPTION_PLAN_NOT_FOUND: "Subscription plan not found",
|
|
980
971
|
FAILED_TO_INITIALIZE_TRANSACTION: "Failed to initialize transaction",
|
|
@@ -983,11 +974,11 @@ const FLUTTERWAVE_ERROR_CODES = defineErrorCodes({
|
|
|
983
974
|
FAILED_TO_ENABLE_SUBSCRIPTION: "Failed to enable subscription",
|
|
984
975
|
EMAIL_VERIFICATION_REQUIRED: "Email verification is required before you can subscribe to a plan",
|
|
985
976
|
SUBSCRIPTION_PAYMENT_CHANNEL_NOT_ALLOWED: "This subscription only supports specific payment channels"
|
|
986
|
-
}
|
|
977
|
+
};
|
|
987
978
|
async function hmacSha256Base64(secret, message) {
|
|
988
979
|
const encoder = new TextEncoder();
|
|
989
980
|
const keyData = encoder.encode(secret);
|
|
990
|
-
const
|
|
981
|
+
const body = typeof message === "string" ? encoder.encode(message) : message;
|
|
991
982
|
const crypto = globalThis.crypto;
|
|
992
983
|
if (crypto !== void 0 && crypto !== null && "subtle" in crypto) {
|
|
993
984
|
const subtle = crypto.subtle;
|
|
@@ -995,11 +986,11 @@ async function hmacSha256Base64(secret, message) {
|
|
|
995
986
|
name: "HMAC",
|
|
996
987
|
hash: "SHA-256"
|
|
997
988
|
}, false, ["sign"]);
|
|
998
|
-
const signature = await subtle.sign("HMAC", key,
|
|
989
|
+
const signature = await subtle.sign("HMAC", key, body);
|
|
999
990
|
return Buffer.from(signature).toString("base64");
|
|
1000
991
|
}
|
|
1001
992
|
const { createHmac } = await import("node:crypto");
|
|
1002
|
-
return createHmac("sha256", secret).update(
|
|
993
|
+
return createHmac("sha256", secret).update(body).digest("base64");
|
|
1003
994
|
}
|
|
1004
995
|
function timingSafeEqualString(left, right) {
|
|
1005
996
|
const leftBytes = Buffer.from(left);
|
|
@@ -1007,8 +998,7 @@ function timingSafeEqualString(left, right) {
|
|
|
1007
998
|
if (leftBytes.length !== rightBytes.length) return false;
|
|
1008
999
|
return timingSafeEqual(leftBytes, rightBytes);
|
|
1009
1000
|
}
|
|
1010
|
-
|
|
1011
|
-
//#region src/routes.ts
|
|
1001
|
+
// src/routes.ts
|
|
1012
1002
|
const subaccountSchema = z.object({
|
|
1013
1003
|
id: z.string().min(1),
|
|
1014
1004
|
transactionSplitRatio: z.number().positive().optional(),
|
|
@@ -1132,7 +1122,10 @@ const initializeTransaction = (options, path) => createAuthEndpoint(path, {
|
|
|
1132
1122
|
use: [sessionMiddleware, originCheckMiddleware]
|
|
1133
1123
|
}, async (ctx) => {
|
|
1134
1124
|
const { user, referenceId } = await authenticatedReference(ctx, options, "initialize-transaction", ctx.body.referenceId);
|
|
1135
|
-
if (options.subscription?.requireEmailVerification === true && ctx.body.plan && user.emailVerified !== true) throw new APIError("BAD_REQUEST",
|
|
1125
|
+
if (options.subscription?.requireEmailVerification === true && ctx.body.plan && user.emailVerified !== true) throw new APIError("BAD_REQUEST", {
|
|
1126
|
+
code: "EMAIL_VERIFICATION_REQUIRED",
|
|
1127
|
+
message: FLUTTERWAVE_ERROR_MESSAGES.EMAIL_VERIFICATION_REQUIRED
|
|
1128
|
+
});
|
|
1136
1129
|
const billingEmail = await resolveBillingEmail(ctx, options, referenceId, user);
|
|
1137
1130
|
const plans = await getPlans(options.subscription);
|
|
1138
1131
|
const plan = ctx.body.plan ? plans.find((candidate) => candidate.name.toLowerCase() === ctx.body.plan?.toLowerCase()) : void 0;
|
|
@@ -1396,15 +1389,16 @@ const flutterwaveWebhook = (options, path) => createAuthEndpoint(path, {
|
|
|
1396
1389
|
}, async (ctx) => {
|
|
1397
1390
|
const request = getWebhookRequest(ctx);
|
|
1398
1391
|
if (!request) throw new APIError("BAD_REQUEST", { message: "Request is missing" });
|
|
1399
|
-
const
|
|
1392
|
+
const rawBytes = new Uint8Array(await request.arrayBuffer());
|
|
1393
|
+
const rawBody = new TextDecoder().decode(rawBytes);
|
|
1400
1394
|
const headers = getWebhookHeaders(ctx);
|
|
1401
1395
|
const signature = headers?.get("flutterwave-signature");
|
|
1402
1396
|
const legacyHash = headers?.get("verif-hash");
|
|
1403
1397
|
const secretHash = options.webhook?.secretHash ?? options.secretHash;
|
|
1404
1398
|
if (typeof signature !== "string" && typeof legacyHash !== "string") throw new APIError("UNAUTHORIZED", { message: "Missing signature" });
|
|
1405
|
-
const validV4Signature = typeof signature === "string" && timingSafeEqualString(signature, await hmacSha256Base64(secretHash,
|
|
1399
|
+
const validV4Signature = typeof signature === "string" && timingSafeEqualString(signature, await hmacSha256Base64(secretHash, rawBytes));
|
|
1406
1400
|
const validV3Hash = typeof legacyHash === "string" && timingSafeEqualString(legacyHash, secretHash);
|
|
1407
|
-
if (!validV4Signature
|
|
1401
|
+
if (typeof signature === "string" ? !validV4Signature : !validV3Hash) throw new APIError("UNAUTHORIZED", { message: "Invalid signature" });
|
|
1408
1402
|
let webhookJson;
|
|
1409
1403
|
try {
|
|
1410
1404
|
webhookJson = JSON.parse(rawBody);
|
|
@@ -1518,8 +1512,7 @@ const flutterwaveWebhook = (options, path) => createAuthEndpoint(path, {
|
|
|
1518
1512
|
}
|
|
1519
1513
|
return ctx.json({ received: true });
|
|
1520
1514
|
});
|
|
1521
|
-
|
|
1522
|
-
//#region src/schema.ts
|
|
1515
|
+
// src/schema.ts
|
|
1523
1516
|
const transactions = { flutterwaveTransaction: { fields: {
|
|
1524
1517
|
txRef: {
|
|
1525
1518
|
type: "string",
|
|
@@ -1925,8 +1918,7 @@ const getSchema = (options) => {
|
|
|
1925
1918
|
}
|
|
1926
1919
|
return mergeSchema(baseSchema, optionSchema);
|
|
1927
1920
|
};
|
|
1928
|
-
|
|
1929
|
-
//#region src/flutterwave-v4.ts
|
|
1921
|
+
// src/flutterwave-v4.ts
|
|
1930
1922
|
const DEFAULT_IDENTITY_URL = "https://idp.flutterwave.com/realms/flutterwave/protocol/openid-connect/token";
|
|
1931
1923
|
const DEFAULT_API_URL = "https://f4bexperience.flutterwave.com";
|
|
1932
1924
|
/**
|
|
@@ -2101,8 +2093,7 @@ function v4Error(operation, status, raw) {
|
|
|
2101
2093
|
});
|
|
2102
2094
|
return error;
|
|
2103
2095
|
}
|
|
2104
|
-
|
|
2105
|
-
//#region src/limits.ts
|
|
2096
|
+
// src/limits.ts
|
|
2106
2097
|
const checkSeatLimit = async (ctx, organizationId, seatsToAdd = 1) => {
|
|
2107
2098
|
const store = createBillingStore(ctx);
|
|
2108
2099
|
const seatLimit = (await store.findSubscriptionsByReference(organizationId)).filter((subscription) => subscription.status === "active" || subscription.status === "trialing").reduce((maximum, subscription) => typeof subscription.seats === "number" ? Math.max(maximum ?? subscription.seats, subscription.seats) : maximum, void 0);
|
|
@@ -2129,8 +2120,7 @@ const checkTeamLimit = async (ctx, organizationId, maxTeams) => {
|
|
|
2129
2120
|
if ((await createBillingStore(ctx).listTeams(organizationId)).length >= maxTeams) throw new APIError("FORBIDDEN", { message: `Organization team limit reached. Max teams: ${maxTeams}` });
|
|
2130
2121
|
return true;
|
|
2131
2122
|
};
|
|
2132
|
-
|
|
2133
|
-
//#region src/operations.ts
|
|
2123
|
+
// src/operations.ts
|
|
2134
2124
|
function adapter(options) {
|
|
2135
2125
|
return createFlutterwaveAdapter({
|
|
2136
2126
|
publicKey: options.publicKey,
|
|
@@ -2384,8 +2374,7 @@ async function refundFlutterwaveTransaction(ctx, options, input) {
|
|
|
2384
2374
|
updatedAt: now
|
|
2385
2375
|
});
|
|
2386
2376
|
}
|
|
2387
|
-
|
|
2388
|
-
//#region src/reconciliation.ts
|
|
2377
|
+
// src/reconciliation.ts
|
|
2389
2378
|
async function reconcileFlutterwaveTransaction(ctx, options, input) {
|
|
2390
2379
|
const store = createBillingStore(ctx);
|
|
2391
2380
|
const local = input.txRef ? await store.findTransactionByTxRef(input.txRef) : input.transactionId ? await store.findTransactionById(input.transactionId) : null;
|
|
@@ -2464,9 +2453,8 @@ async function reconcileFlutterwaveRefunds(ctx, options) {
|
|
|
2464
2453
|
count: updated
|
|
2465
2454
|
};
|
|
2466
2455
|
}
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
const INTERNAL_ERROR_CODES = defineErrorCodes(Object.fromEntries(Object.entries(FLUTTERWAVE_ERROR_CODES).map(([key, value]) => [key, typeof value === "string" ? value : value.message])));
|
|
2456
|
+
// src/index.ts
|
|
2457
|
+
const INTERNAL_ERROR_CODES = defineErrorCodes(FLUTTERWAVE_ERROR_MESSAGES);
|
|
2470
2458
|
const flutterwave = (options) => {
|
|
2471
2459
|
const routeOptions = options;
|
|
2472
2460
|
return {
|
|
@@ -2488,14 +2476,13 @@ const flutterwave = (options) => {
|
|
|
2488
2476
|
},
|
|
2489
2477
|
schema: getSchema(routeOptions),
|
|
2490
2478
|
init: (ctx) => {
|
|
2491
|
-
if (options.organization?.enabled === true &&
|
|
2479
|
+
if (options.organization?.enabled === true && ctx.options.plugins?.some((plugin) => plugin.id === "organization") !== true) ctx.logger.error("Flutterwave organization billing requires the Better Auth organization plugin.");
|
|
2492
2480
|
return { options: {} };
|
|
2493
2481
|
},
|
|
2494
2482
|
$ERROR_CODES: INTERNAL_ERROR_CODES,
|
|
2495
2483
|
options
|
|
2496
2484
|
};
|
|
2497
2485
|
};
|
|
2498
|
-
//#endregion
|
|
2499
2486
|
export { FlutterwaveAdapterError, chargeSubscriptionRenewal, checkSeatLimit, checkTeamLimit, createCheckoutMetadata, createFlutterwaveAdapter, createFlutterwaveV4Adapter, createProrationMetadata, createRenewalMetadata, decryptPaymentToken, encryptPaymentToken, flutterwave, getMetadataBoolean, getMetadataNumber, getMetadataString, getOrganizationEntitlements, hasFlutterwaveMetadata, parseFlutterwaveMetadata, processScheduledFlutterwaveCancellations, reconcileFlutterwaveRefunds, reconcileFlutterwaveTransaction, refundFlutterwaveTransaction, stringifyFlutterwaveMetadata, syncFlutterwavePlans };
|
|
2500
2487
|
|
|
2501
2488
|
//# sourceMappingURL=index.mjs.map
|