@premiumsarl/premium-nodejs-library 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +132 -0
- package/dist/auth/index.d.ts +19 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +61 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/db/mysql.d.ts +26 -0
- package/dist/db/mysql.d.ts.map +1 -0
- package/dist/db/mysql.js +64 -0
- package/dist/db/mysql.js.map +1 -0
- package/dist/db/prisma.d.ts +21 -0
- package/dist/db/prisma.d.ts.map +1 -0
- package/dist/db/prisma.js +34 -0
- package/dist/db/prisma.js.map +1 -0
- package/dist/email/index.d.ts +23 -0
- package/dist/email/index.d.ts.map +1 -0
- package/dist/email/index.js +79 -0
- package/dist/email/index.js.map +1 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +193 -0
- package/dist/index.js.map +1 -0
- package/dist/otp/index.d.ts +40 -0
- package/dist/otp/index.d.ts.map +1 -0
- package/dist/otp/index.js +85 -0
- package/dist/otp/index.js.map +1 -0
- package/dist/payments/paytech.d.ts +32 -0
- package/dist/payments/paytech.d.ts.map +1 -0
- package/dist/payments/paytech.js +65 -0
- package/dist/payments/paytech.js.map +1 -0
- package/dist/payments/stripe.d.ts +18 -0
- package/dist/payments/stripe.d.ts.map +1 -0
- package/dist/payments/stripe.js +24 -0
- package/dist/payments/stripe.js.map +1 -0
- package/dist/responses/core.d.ts +23 -0
- package/dist/responses/core.d.ts.map +1 -0
- package/dist/responses/core.js +45 -0
- package/dist/responses/core.js.map +1 -0
- package/dist/responses/express.d.ts +17 -0
- package/dist/responses/express.d.ts.map +1 -0
- package/dist/responses/express.js +67 -0
- package/dist/responses/express.js.map +1 -0
- package/dist/responses/nextjs.d.ts +15 -0
- package/dist/responses/nextjs.d.ts.map +1 -0
- package/dist/responses/nextjs.js +45 -0
- package/dist/responses/nextjs.js.map +1 -0
- package/dist/storage/s3.d.ts +66 -0
- package/dist/storage/s3.d.ts.map +1 -0
- package/dist/storage/s3.js +172 -0
- package/dist/storage/s3.js.map +1 -0
- package/dist/storage/supabase.d.ts +41 -0
- package/dist/storage/supabase.d.ts.map +1 -0
- package/dist/storage/supabase.js +83 -0
- package/dist/storage/supabase.js.map +1 -0
- package/dist/utils/date.d.ts +29 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +79 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/misc.d.ts +25 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +50 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/string.d.ts +29 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +56 -0
- package/dist/utils/string.js.map +1 -0
- package/dist/validation/index.d.ts +46 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +189 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +66 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* premium_nodejs_library v4.0.0
|
|
4
|
+
*
|
|
5
|
+
* Shared Node.js library for Premium SARL projects.
|
|
6
|
+
* Provides auth, email, responses, storage, payments,
|
|
7
|
+
* OTP, validation, DB, and utility modules.
|
|
8
|
+
*
|
|
9
|
+
* BACKWARD COMPATIBLE with base_nodejs_library.
|
|
10
|
+
* All original exports are preserved.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.isValidTime = exports.isValidEmail = exports.checkRequiredValidation = exports.otpValidator = exports.twilioVerifyOTP = exports.twilioSendOTP = exports.isOtpExpired = exports.generateOtpExpiryTime = exports.generateOtp = exports.createPayTechPayment = exports.createStripeClient = exports.deleteFromSupabase = exports.uploadToSupabase = exports.createSupabaseStorageClient = exports.deleteFileFroms3Bucket = exports.uploadFiles3Bucket = exports.deleteFileFromS3 = exports.uploadFilesToS3 = exports.getS3FileUrl = exports.isValidS3Url = exports.extractKeyFromObjectUrl = exports.serverErrorResponse = exports.notFoundResponse = exports.forbiddenResponse = exports.unauthorizedResponse = exports.errorResponse = exports.successResponse = exports.generateSuccessFullResponse = exports.generateServerErrorResponse = exports.generateSuccessResponseWithData = exports.generateSuccessResponse = exports.generateErrorResponse = exports.generateForbiddenErrorResponse = exports.generateBadGatewayResponse = exports.generateUnauthorizedResponse = exports.generateBadRequestResponse = exports.makeBadGateway = exports.makeServerError = exports.makeNotFound = exports.makeForbidden = exports.makeUnauthorized = exports.makeError = exports.makeSuccessMessage = exports.makeSuccess = exports.sendEmailWithName = exports.sendEmail = exports.verifyJWT = exports.generateJWT = exports.compareHashedPassword = exports.hashPassword = void 0;
|
|
14
|
+
exports.getContextFromEnvironment = exports.removeKeysFromJoinData = exports.randomNumberModule = exports.applyPagination = exports.getYearAndWeekNumber = exports.convertDateTimeFormat = exports.validateAndConvertDate = exports.isPastDate = exports.dBDateFormatModule = exports.normalizeString = exports.normalizeDataNFD = exports.removeAccents = exports.removeSpecialCharactersFromURL = exports.removeSpecialCharactersFromNormalString = exports.capitalizeFirstLetter = exports.createPrismaSingleton = exports.selectQueryModule = exports.runAnyQuery = exports.checkVerifiedUserInfo = exports.checkExistingUser = exports.validateEmailAndPhone = exports.checkEmptyString = exports.isValidEndTime = void 0;
|
|
15
|
+
// ─── Auth ───────────────────────────────────────────
|
|
16
|
+
var auth_1 = require("./auth");
|
|
17
|
+
Object.defineProperty(exports, "hashPassword", { enumerable: true, get: function () { return auth_1.hashPassword; } });
|
|
18
|
+
Object.defineProperty(exports, "compareHashedPassword", { enumerable: true, get: function () { return auth_1.compareHashedPassword; } });
|
|
19
|
+
Object.defineProperty(exports, "generateJWT", { enumerable: true, get: function () { return auth_1.generateJWT; } });
|
|
20
|
+
Object.defineProperty(exports, "verifyJWT", { enumerable: true, get: function () { return auth_1.verifyJWT; } });
|
|
21
|
+
// ─── Email ──────────────────────────────────────────
|
|
22
|
+
var email_1 = require("./email");
|
|
23
|
+
Object.defineProperty(exports, "sendEmail", { enumerable: true, get: function () { return email_1.sendEmail; } });
|
|
24
|
+
Object.defineProperty(exports, "sendEmailWithName", { enumerable: true, get: function () { return email_1.sendEmailWithName; } });
|
|
25
|
+
// ─── Responses (framework-agnostic) ─────────────────
|
|
26
|
+
var core_1 = require("./responses/core");
|
|
27
|
+
Object.defineProperty(exports, "makeSuccess", { enumerable: true, get: function () { return core_1.makeSuccess; } });
|
|
28
|
+
Object.defineProperty(exports, "makeSuccessMessage", { enumerable: true, get: function () { return core_1.makeSuccessMessage; } });
|
|
29
|
+
Object.defineProperty(exports, "makeError", { enumerable: true, get: function () { return core_1.makeError; } });
|
|
30
|
+
Object.defineProperty(exports, "makeUnauthorized", { enumerable: true, get: function () { return core_1.makeUnauthorized; } });
|
|
31
|
+
Object.defineProperty(exports, "makeForbidden", { enumerable: true, get: function () { return core_1.makeForbidden; } });
|
|
32
|
+
Object.defineProperty(exports, "makeNotFound", { enumerable: true, get: function () { return core_1.makeNotFound; } });
|
|
33
|
+
Object.defineProperty(exports, "makeServerError", { enumerable: true, get: function () { return core_1.makeServerError; } });
|
|
34
|
+
Object.defineProperty(exports, "makeBadGateway", { enumerable: true, get: function () { return core_1.makeBadGateway; } });
|
|
35
|
+
// ─── Responses (Express adapter) ────────────────────
|
|
36
|
+
var express_1 = require("./responses/express");
|
|
37
|
+
Object.defineProperty(exports, "generateBadRequestResponse", { enumerable: true, get: function () { return express_1.generateBadRequestResponse; } });
|
|
38
|
+
Object.defineProperty(exports, "generateUnauthorizedResponse", { enumerable: true, get: function () { return express_1.generateUnauthorizedResponse; } });
|
|
39
|
+
Object.defineProperty(exports, "generateBadGatewayResponse", { enumerable: true, get: function () { return express_1.generateBadGatewayResponse; } });
|
|
40
|
+
Object.defineProperty(exports, "generateForbiddenErrorResponse", { enumerable: true, get: function () { return express_1.generateForbiddenErrorResponse; } });
|
|
41
|
+
Object.defineProperty(exports, "generateErrorResponse", { enumerable: true, get: function () { return express_1.generateErrorResponse; } });
|
|
42
|
+
Object.defineProperty(exports, "generateSuccessResponse", { enumerable: true, get: function () { return express_1.generateSuccessResponse; } });
|
|
43
|
+
Object.defineProperty(exports, "generateSuccessResponseWithData", { enumerable: true, get: function () { return express_1.generateSuccessResponseWithData; } });
|
|
44
|
+
Object.defineProperty(exports, "generateServerErrorResponse", { enumerable: true, get: function () { return express_1.generateServerErrorResponse; } });
|
|
45
|
+
Object.defineProperty(exports, "generateSuccessFullResponse", { enumerable: true, get: function () { return express_1.generateSuccessFullResponse; } });
|
|
46
|
+
// ─── Responses (Next.js adapter) ────────────────────
|
|
47
|
+
var nextjs_1 = require("./responses/nextjs");
|
|
48
|
+
Object.defineProperty(exports, "successResponse", { enumerable: true, get: function () { return nextjs_1.successResponse; } });
|
|
49
|
+
Object.defineProperty(exports, "errorResponse", { enumerable: true, get: function () { return nextjs_1.errorResponse; } });
|
|
50
|
+
Object.defineProperty(exports, "unauthorizedResponse", { enumerable: true, get: function () { return nextjs_1.unauthorizedResponse; } });
|
|
51
|
+
Object.defineProperty(exports, "forbiddenResponse", { enumerable: true, get: function () { return nextjs_1.forbiddenResponse; } });
|
|
52
|
+
Object.defineProperty(exports, "notFoundResponse", { enumerable: true, get: function () { return nextjs_1.notFoundResponse; } });
|
|
53
|
+
Object.defineProperty(exports, "serverErrorResponse", { enumerable: true, get: function () { return nextjs_1.serverErrorResponse; } });
|
|
54
|
+
// ─── Storage (S3) ───────────────────────────────────
|
|
55
|
+
var s3_1 = require("./storage/s3");
|
|
56
|
+
Object.defineProperty(exports, "extractKeyFromObjectUrl", { enumerable: true, get: function () { return s3_1.extractKeyFromObjectUrl; } });
|
|
57
|
+
Object.defineProperty(exports, "isValidS3Url", { enumerable: true, get: function () { return s3_1.isValidS3Url; } });
|
|
58
|
+
Object.defineProperty(exports, "getS3FileUrl", { enumerable: true, get: function () { return s3_1.getS3FileUrl; } });
|
|
59
|
+
Object.defineProperty(exports, "uploadFilesToS3", { enumerable: true, get: function () { return s3_1.uploadFilesToS3; } });
|
|
60
|
+
Object.defineProperty(exports, "deleteFileFromS3", { enumerable: true, get: function () { return s3_1.deleteFileFromS3; } });
|
|
61
|
+
// Backward-compatible aliases
|
|
62
|
+
Object.defineProperty(exports, "uploadFiles3Bucket", { enumerable: true, get: function () { return s3_1.uploadFiles3Bucket; } });
|
|
63
|
+
Object.defineProperty(exports, "deleteFileFroms3Bucket", { enumerable: true, get: function () { return s3_1.deleteFileFroms3Bucket; } });
|
|
64
|
+
// ─── Storage (Supabase) ─────────────────────────────
|
|
65
|
+
var supabase_1 = require("./storage/supabase");
|
|
66
|
+
Object.defineProperty(exports, "createSupabaseStorageClient", { enumerable: true, get: function () { return supabase_1.createSupabaseStorageClient; } });
|
|
67
|
+
Object.defineProperty(exports, "uploadToSupabase", { enumerable: true, get: function () { return supabase_1.uploadToSupabase; } });
|
|
68
|
+
Object.defineProperty(exports, "deleteFromSupabase", { enumerable: true, get: function () { return supabase_1.deleteFromSupabase; } });
|
|
69
|
+
// ─── Payments (Stripe) ──────────────────────────────
|
|
70
|
+
var stripe_1 = require("./payments/stripe");
|
|
71
|
+
Object.defineProperty(exports, "createStripeClient", { enumerable: true, get: function () { return stripe_1.createStripeClient; } });
|
|
72
|
+
// ─── Payments (PayTech) ─────────────────────────────
|
|
73
|
+
var paytech_1 = require("./payments/paytech");
|
|
74
|
+
Object.defineProperty(exports, "createPayTechPayment", { enumerable: true, get: function () { return paytech_1.createPayTechPayment; } });
|
|
75
|
+
// ─── OTP & Twilio ───────────────────────────────────
|
|
76
|
+
var otp_1 = require("./otp");
|
|
77
|
+
Object.defineProperty(exports, "generateOtp", { enumerable: true, get: function () { return otp_1.generateOtp; } });
|
|
78
|
+
Object.defineProperty(exports, "generateOtpExpiryTime", { enumerable: true, get: function () { return otp_1.generateOtpExpiryTime; } });
|
|
79
|
+
Object.defineProperty(exports, "isOtpExpired", { enumerable: true, get: function () { return otp_1.isOtpExpired; } });
|
|
80
|
+
Object.defineProperty(exports, "twilioSendOTP", { enumerable: true, get: function () { return otp_1.twilioSendOTP; } });
|
|
81
|
+
Object.defineProperty(exports, "twilioVerifyOTP", { enumerable: true, get: function () { return otp_1.twilioVerifyOTP; } });
|
|
82
|
+
Object.defineProperty(exports, "otpValidator", { enumerable: true, get: function () { return otp_1.otpValidator; } });
|
|
83
|
+
// ─── Validation ─────────────────────────────────────
|
|
84
|
+
var validation_1 = require("./validation");
|
|
85
|
+
Object.defineProperty(exports, "checkRequiredValidation", { enumerable: true, get: function () { return validation_1.checkRequiredValidation; } });
|
|
86
|
+
Object.defineProperty(exports, "isValidEmail", { enumerable: true, get: function () { return validation_1.isValidEmail; } });
|
|
87
|
+
Object.defineProperty(exports, "isValidTime", { enumerable: true, get: function () { return validation_1.isValidTime; } });
|
|
88
|
+
Object.defineProperty(exports, "isValidEndTime", { enumerable: true, get: function () { return validation_1.isValidEndTime; } });
|
|
89
|
+
Object.defineProperty(exports, "checkEmptyString", { enumerable: true, get: function () { return validation_1.checkEmptyString; } });
|
|
90
|
+
Object.defineProperty(exports, "validateEmailAndPhone", { enumerable: true, get: function () { return validation_1.validateEmailAndPhone; } });
|
|
91
|
+
Object.defineProperty(exports, "checkExistingUser", { enumerable: true, get: function () { return validation_1.checkExistingUser; } });
|
|
92
|
+
Object.defineProperty(exports, "checkVerifiedUserInfo", { enumerable: true, get: function () { return validation_1.checkVerifiedUserInfo; } });
|
|
93
|
+
// ─── Database (MySQL) ───────────────────────────────
|
|
94
|
+
var mysql_1 = require("./db/mysql");
|
|
95
|
+
Object.defineProperty(exports, "runAnyQuery", { enumerable: true, get: function () { return mysql_1.runAnyQuery; } });
|
|
96
|
+
Object.defineProperty(exports, "selectQueryModule", { enumerable: true, get: function () { return mysql_1.selectQueryModule; } });
|
|
97
|
+
// ─── Database (Prisma) ──────────────────────────────
|
|
98
|
+
var prisma_1 = require("./db/prisma");
|
|
99
|
+
Object.defineProperty(exports, "createPrismaSingleton", { enumerable: true, get: function () { return prisma_1.createPrismaSingleton; } });
|
|
100
|
+
// ─── Utils (String) ─────────────────────────────────
|
|
101
|
+
var string_1 = require("./utils/string");
|
|
102
|
+
Object.defineProperty(exports, "capitalizeFirstLetter", { enumerable: true, get: function () { return string_1.capitalizeFirstLetter; } });
|
|
103
|
+
Object.defineProperty(exports, "removeSpecialCharactersFromNormalString", { enumerable: true, get: function () { return string_1.removeSpecialCharactersFromNormalString; } });
|
|
104
|
+
Object.defineProperty(exports, "removeSpecialCharactersFromURL", { enumerable: true, get: function () { return string_1.removeSpecialCharactersFromURL; } });
|
|
105
|
+
Object.defineProperty(exports, "removeAccents", { enumerable: true, get: function () { return string_1.removeAccents; } });
|
|
106
|
+
Object.defineProperty(exports, "normalizeDataNFD", { enumerable: true, get: function () { return string_1.normalizeDataNFD; } });
|
|
107
|
+
Object.defineProperty(exports, "normalizeString", { enumerable: true, get: function () { return string_1.normalizeString; } });
|
|
108
|
+
// ─── Utils (Date) ───────────────────────────────────
|
|
109
|
+
var date_1 = require("./utils/date");
|
|
110
|
+
Object.defineProperty(exports, "dBDateFormatModule", { enumerable: true, get: function () { return date_1.dBDateFormatModule; } });
|
|
111
|
+
Object.defineProperty(exports, "isPastDate", { enumerable: true, get: function () { return date_1.isPastDate; } });
|
|
112
|
+
Object.defineProperty(exports, "validateAndConvertDate", { enumerable: true, get: function () { return date_1.validateAndConvertDate; } });
|
|
113
|
+
Object.defineProperty(exports, "convertDateTimeFormat", { enumerable: true, get: function () { return date_1.convertDateTimeFormat; } });
|
|
114
|
+
Object.defineProperty(exports, "getYearAndWeekNumber", { enumerable: true, get: function () { return date_1.getYearAndWeekNumber; } });
|
|
115
|
+
// ─── Utils (Misc) ───────────────────────────────────
|
|
116
|
+
var misc_1 = require("./utils/misc");
|
|
117
|
+
Object.defineProperty(exports, "applyPagination", { enumerable: true, get: function () { return misc_1.applyPagination; } });
|
|
118
|
+
Object.defineProperty(exports, "randomNumberModule", { enumerable: true, get: function () { return misc_1.randomNumberModule; } });
|
|
119
|
+
Object.defineProperty(exports, "removeKeysFromJoinData", { enumerable: true, get: function () { return misc_1.removeKeysFromJoinData; } });
|
|
120
|
+
Object.defineProperty(exports, "getContextFromEnvironment", { enumerable: true, get: function () { return misc_1.getContextFromEnvironment; } });
|
|
121
|
+
// ─── Default Export (Babel backward compat) ─────────
|
|
122
|
+
const auth_2 = require("./auth");
|
|
123
|
+
const email_2 = require("./email");
|
|
124
|
+
const express_2 = require("./responses/express");
|
|
125
|
+
const s3_2 = require("./storage/s3");
|
|
126
|
+
const otp_2 = require("./otp");
|
|
127
|
+
const validation_2 = require("./validation");
|
|
128
|
+
const mysql_2 = require("./db/mysql");
|
|
129
|
+
const string_2 = require("./utils/string");
|
|
130
|
+
const date_2 = require("./utils/date");
|
|
131
|
+
const misc_2 = require("./utils/misc");
|
|
132
|
+
exports.default = {
|
|
133
|
+
// Auth
|
|
134
|
+
hashPassword: auth_2.hashPassword,
|
|
135
|
+
compareHashedPassword: auth_2.compareHashedPassword,
|
|
136
|
+
generateJWT: auth_2.generateJWT,
|
|
137
|
+
verifyJWT: auth_2.verifyJWT,
|
|
138
|
+
// Email
|
|
139
|
+
sendEmail: email_2.sendEmail,
|
|
140
|
+
// Responses (Express)
|
|
141
|
+
generateBadRequestResponse: express_2.generateBadRequestResponse,
|
|
142
|
+
generateUnauthorizedResponse: express_2.generateUnauthorizedResponse,
|
|
143
|
+
generateBadGatewayResponse: express_2.generateBadGatewayResponse,
|
|
144
|
+
generateForbiddenErrorResponse: express_2.generateForbiddenErrorResponse,
|
|
145
|
+
generateErrorResponse: express_2.generateErrorResponse,
|
|
146
|
+
generateSuccessResponse: express_2.generateSuccessResponse,
|
|
147
|
+
generateSuccessResponseWithData: express_2.generateSuccessResponseWithData,
|
|
148
|
+
generateServerErrorResponse: express_2.generateServerErrorResponse,
|
|
149
|
+
generateSuccessFullResponse: express_2.generateSuccessFullResponse,
|
|
150
|
+
// Storage
|
|
151
|
+
extractKeyFromObjectUrl: s3_2.extractKeyFromObjectUrl,
|
|
152
|
+
uploadFiles3Bucket: s3_2.uploadFiles3Bucket,
|
|
153
|
+
deleteFileFroms3Bucket: s3_2.deleteFileFroms3Bucket,
|
|
154
|
+
isValidS3Url: s3_2.isValidS3Url,
|
|
155
|
+
// OTP
|
|
156
|
+
twilioSendOTP: otp_2.twilioSendOTP,
|
|
157
|
+
twilioVerifyOTP: otp_2.twilioVerifyOTP,
|
|
158
|
+
generateOtp: otp_2.generateOtp,
|
|
159
|
+
isOtpExpired: otp_2.isOtpExpired,
|
|
160
|
+
generateOtpExpiryTime: otp_2.generateOtpExpiryTime,
|
|
161
|
+
otpValidator: otp_2.otpValidator,
|
|
162
|
+
// Validation
|
|
163
|
+
checkRequiredValidation: validation_2.checkRequiredValidation,
|
|
164
|
+
isValidEmail: validation_2.isValidEmail,
|
|
165
|
+
isValidTime: validation_2.isValidTime,
|
|
166
|
+
isValidEndTime: validation_2.isValidEndTime,
|
|
167
|
+
checkEmptyString: validation_2.checkEmptyString,
|
|
168
|
+
validateEmailAndPhone: validation_2.validateEmailAndPhone,
|
|
169
|
+
checkExistingUser: validation_2.checkExistingUser,
|
|
170
|
+
checkVerifiedUserInfo: validation_2.checkVerifiedUserInfo,
|
|
171
|
+
// DB
|
|
172
|
+
runAnyQuery: mysql_2.runAnyQuery,
|
|
173
|
+
selectQueryModule: mysql_2.selectQueryModule,
|
|
174
|
+
// Strings
|
|
175
|
+
capitalizeFirstLetter: string_2.capitalizeFirstLetter,
|
|
176
|
+
removeSpecialCharactersFromNormalString: string_2.removeSpecialCharactersFromNormalString,
|
|
177
|
+
removeSpecialCharactersFromURL: string_2.removeSpecialCharactersFromURL,
|
|
178
|
+
removeAccents: string_2.removeAccents,
|
|
179
|
+
normalizeDataNFD: string_2.normalizeDataNFD,
|
|
180
|
+
normalizeString: string_2.normalizeString,
|
|
181
|
+
// Dates
|
|
182
|
+
dBDateFormatModule: date_2.dBDateFormatModule,
|
|
183
|
+
isPastDate: date_2.isPastDate,
|
|
184
|
+
validateAndConvertDate: date_2.validateAndConvertDate,
|
|
185
|
+
convertDateTimeFormat: date_2.convertDateTimeFormat,
|
|
186
|
+
getYearAndWeekNumber: date_2.getYearAndWeekNumber,
|
|
187
|
+
// Misc
|
|
188
|
+
applyPagination: misc_2.applyPagination,
|
|
189
|
+
randomNumberModule: misc_2.randomNumberModule,
|
|
190
|
+
removeKeysFromJoinData: misc_2.removeKeysFromJoinData,
|
|
191
|
+
getContextFromEnvironment: misc_2.getContextFromEnvironment,
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;AAEH,uDAAuD;AACvD,+BAKgB;AAJZ,oGAAA,YAAY,OAAA;AACZ,6GAAA,qBAAqB,OAAA;AACrB,mGAAA,WAAW,OAAA;AACX,iGAAA,SAAS,OAAA;AAGb,uDAAuD;AACvD,iCAGiB;AAFb,kGAAA,SAAS,OAAA;AACT,0GAAA,iBAAiB,OAAA;AAGrB,uDAAuD;AACvD,yCAS0B;AARtB,mGAAA,WAAW,OAAA;AACX,0GAAA,kBAAkB,OAAA;AAClB,iGAAA,SAAS,OAAA;AACT,wGAAA,gBAAgB,OAAA;AAChB,qGAAA,aAAa,OAAA;AACb,oGAAA,YAAY,OAAA;AACZ,uGAAA,eAAe,OAAA;AACf,sGAAA,cAAc,OAAA;AAIlB,uDAAuD;AACvD,+CAU6B;AATzB,qHAAA,0BAA0B,OAAA;AAC1B,uHAAA,4BAA4B,OAAA;AAC5B,qHAAA,0BAA0B,OAAA;AAC1B,yHAAA,8BAA8B,OAAA;AAC9B,gHAAA,qBAAqB,OAAA;AACrB,kHAAA,uBAAuB,OAAA;AACvB,0HAAA,+BAA+B,OAAA;AAC/B,sHAAA,2BAA2B,OAAA;AAC3B,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iBAAY;IACZ,MAAM;IACN,aAAa,EAAb,mBAAa;IACb,eAAe,EAAf,qBAAe;IACf,WAAW,EAAX,iBAAW;IACX,YAAY,EAAZ,kBAAY;IACZ,qBAAqB,EAArB,2BAAqB;IACrB,YAAY,EAAZ,kBAAY;IACZ,aAAa;IACb,uBAAuB,EAAvB,oCAAuB;IACvB,YAAY,EAAZ,yBAAY;IACZ,WAAW,EAAX,wBAAW;IACX,cAAc,EAAd,2BAAc;IACd,gBAAgB,EAAhB,6BAAgB;IAChB,qBAAqB,EAArB,kCAAqB;IACrB,iBAAiB,EAAjB,8BAAiB;IACjB,qBAAqB,EAArB,kCAAqB;IACrB,KAAK;IACL,WAAW,EAAX,mBAAW;IACX,iBAAiB,EAAjB,yBAAiB;IACjB,UAAU;IACV,qBAAqB,EAArB,8BAAqB;IACrB,uCAAuC,EAAvC,gDAAuC;IACvC,8BAA8B,EAA9B,uCAA8B;IAC9B,aAAa,EAAb,sBAAa;IACb,gBAAgB,EAAhB,yBAAgB;IAChB,eAAe,EAAf,wBAAe;IACf,QAAQ;IACR,kBAAkB,EAAlB,yBAAkB;IAClB,UAAU,EAAV,iBAAU;IACV,sBAAsB,EAAtB,6BAAsB;IACtB,qBAAqB,EAArB,4BAAqB;IACrB,oBAAoB,EAApB,2BAAoB;IACpB,OAAO;IACP,eAAe,EAAf,sBAAe;IACf,kBAAkB,EAAlB,yBAAkB;IAClB,sBAAsB,EAAtB,6BAAsB;IACtB,yBAAyB,EAAzB,gCAAyB;CAC5B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTP (One-Time Password) generation and validation.
|
|
3
|
+
* Also includes Twilio helpers for SMS-based OTP.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate a 6-digit OTP code.
|
|
7
|
+
*/
|
|
8
|
+
export declare const generateOtp: () => string;
|
|
9
|
+
/**
|
|
10
|
+
* Generate an OTP expiry time (10 minutes from now).
|
|
11
|
+
*/
|
|
12
|
+
export declare const generateOtpExpiryTime: () => Date;
|
|
13
|
+
/**
|
|
14
|
+
* Check if an OTP has expired.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isOtpExpired: (otpExpiresAt: Date) => boolean;
|
|
17
|
+
export interface TwilioConfig {
|
|
18
|
+
baseUrl: string;
|
|
19
|
+
accountSid: string;
|
|
20
|
+
authToken: string;
|
|
21
|
+
templateSid: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Send an OTP via Twilio.
|
|
25
|
+
*/
|
|
26
|
+
export declare const twilioSendOTP: (to: string, mode: string, config: TwilioConfig) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
27
|
+
/**
|
|
28
|
+
* Verify an OTP code via Twilio.
|
|
29
|
+
*/
|
|
30
|
+
export declare const twilioVerifyOTP: (to: string, code: string, config: TwilioConfig) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
31
|
+
/**
|
|
32
|
+
* Validate an OTP code against a user record.
|
|
33
|
+
*/
|
|
34
|
+
export declare const otpValidator: (user: {
|
|
35
|
+
phoneOtpCode?: number;
|
|
36
|
+
emailOtpCode?: number;
|
|
37
|
+
phoneOtpExpiresAt?: Date;
|
|
38
|
+
emailOtpExpiresAt?: Date;
|
|
39
|
+
}, phone: string | null, otpCode: number) => string | undefined;
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/otp/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;GAEG;AACH,eAAO,MAAM,WAAW,QAAO,MAE9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAO,IAIxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,iBACP,IAAI,KACnB,OAEF,CAAC;AAIF,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,OAClB,MAAM,QACJ,MAAM,UACJ,YAAY,qDAcvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,OACpB,MAAM,QACJ,MAAM,UACJ,YAAY,qDAcvB,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,YAAY,SACf;IACF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACzB,iBAAiB,CAAC,EAAE,IAAI,CAAC;CAC5B,SACM,MAAM,GAAG,IAAI,WACX,MAAM,KAChB,MAAM,GAAG,SAkBX,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OTP (One-Time Password) generation and validation.
|
|
4
|
+
* Also includes Twilio helpers for SMS-based OTP.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.otpValidator = exports.twilioVerifyOTP = exports.twilioSendOTP = exports.isOtpExpired = exports.generateOtpExpiryTime = exports.generateOtp = void 0;
|
|
11
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
12
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
|
+
// --- OTP Generation ---
|
|
14
|
+
/**
|
|
15
|
+
* Generate a 6-digit OTP code.
|
|
16
|
+
*/
|
|
17
|
+
const generateOtp = () => {
|
|
18
|
+
return crypto_1.default.randomInt(100000, 999999).toString();
|
|
19
|
+
};
|
|
20
|
+
exports.generateOtp = generateOtp;
|
|
21
|
+
/**
|
|
22
|
+
* Generate an OTP expiry time (10 minutes from now).
|
|
23
|
+
*/
|
|
24
|
+
const generateOtpExpiryTime = () => {
|
|
25
|
+
const expiry = new Date();
|
|
26
|
+
expiry.setMinutes(expiry.getMinutes() + 10);
|
|
27
|
+
return expiry;
|
|
28
|
+
};
|
|
29
|
+
exports.generateOtpExpiryTime = generateOtpExpiryTime;
|
|
30
|
+
/**
|
|
31
|
+
* Check if an OTP has expired.
|
|
32
|
+
*/
|
|
33
|
+
const isOtpExpired = (otpExpiresAt) => {
|
|
34
|
+
return new Date() > otpExpiresAt;
|
|
35
|
+
};
|
|
36
|
+
exports.isOtpExpired = isOtpExpired;
|
|
37
|
+
/**
|
|
38
|
+
* Send an OTP via Twilio.
|
|
39
|
+
*/
|
|
40
|
+
const twilioSendOTP = async (to, mode, config) => {
|
|
41
|
+
const body = {
|
|
42
|
+
accountSid: config.accountSid,
|
|
43
|
+
template: config.templateSid,
|
|
44
|
+
authToken: config.authToken,
|
|
45
|
+
to,
|
|
46
|
+
channel: mode,
|
|
47
|
+
};
|
|
48
|
+
return axios_1.default.post(`${config.baseUrl}/twilio/create`, body);
|
|
49
|
+
};
|
|
50
|
+
exports.twilioSendOTP = twilioSendOTP;
|
|
51
|
+
/**
|
|
52
|
+
* Verify an OTP code via Twilio.
|
|
53
|
+
*/
|
|
54
|
+
const twilioVerifyOTP = async (to, code, config) => {
|
|
55
|
+
const body = {
|
|
56
|
+
accountSid: config.accountSid,
|
|
57
|
+
template: config.templateSid,
|
|
58
|
+
authToken: config.authToken,
|
|
59
|
+
to,
|
|
60
|
+
code,
|
|
61
|
+
};
|
|
62
|
+
return axios_1.default.post(`${config.baseUrl}/twilio/check`, body);
|
|
63
|
+
};
|
|
64
|
+
exports.twilioVerifyOTP = twilioVerifyOTP;
|
|
65
|
+
// --- OTP Validators (used in auth flows) ---
|
|
66
|
+
/**
|
|
67
|
+
* Validate an OTP code against a user record.
|
|
68
|
+
*/
|
|
69
|
+
const otpValidator = (user, phone, otpCode) => {
|
|
70
|
+
const userOtpCode = phone
|
|
71
|
+
? user.phoneOtpCode
|
|
72
|
+
: user.emailOtpCode;
|
|
73
|
+
if (userOtpCode !== otpCode) {
|
|
74
|
+
return "Invalid OTP code";
|
|
75
|
+
}
|
|
76
|
+
const expiresAt = phone
|
|
77
|
+
? user.phoneOtpExpiresAt
|
|
78
|
+
: user.emailOtpExpiresAt;
|
|
79
|
+
if (expiresAt && (0, exports.isOtpExpired)(expiresAt)) {
|
|
80
|
+
return "OTP code has expired";
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
};
|
|
84
|
+
exports.otpValidator = otpValidator;
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/otp/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,oDAA4B;AAC5B,kDAA0B;AAE1B,yBAAyB;AAEzB;;GAEG;AACI,MAAM,WAAW,GAAG,GAAW,EAAE;IACpC,OAAO,gBAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC,CAAC;AAFW,QAAA,WAAW,eAEtB;AAEF;;GAEG;AACI,MAAM,qBAAqB,GAAG,GAAS,EAAE;IAC5C,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;IAC1B,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5C,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAJW,QAAA,qBAAqB,yBAIhC;AAEF;;GAEG;AACI,MAAM,YAAY,GAAG,CACxB,YAAkB,EACX,EAAE;IACT,OAAO,IAAI,IAAI,EAAE,GAAG,YAAY,CAAC;AACrC,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAWF;;GAEG;AACI,MAAM,aAAa,GAAG,KAAK,EAC9B,EAAU,EACV,IAAY,EACZ,MAAoB,EACtB,E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O,SAAS,CAAC;AACrB,CAAC,CAAC;AA3BW,QAAA,YAAY,gBA2BvB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PayTech payment gateway client.
|
|
3
|
+
* Used by GrooMe for mobile money and card payments
|
|
4
|
+
* in West Africa.
|
|
5
|
+
*/
|
|
6
|
+
interface PayTechConfig {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
apiSecret: string;
|
|
9
|
+
isMobile?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface PayTechItem {
|
|
12
|
+
itemName: string;
|
|
13
|
+
itemPrice: number;
|
|
14
|
+
commandName: string;
|
|
15
|
+
}
|
|
16
|
+
interface PayTechUrls {
|
|
17
|
+
ipnUrl: string;
|
|
18
|
+
successUrl: string;
|
|
19
|
+
cancelUrl: string;
|
|
20
|
+
}
|
|
21
|
+
interface PayTechResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
token?: string;
|
|
24
|
+
redirectUrl?: string;
|
|
25
|
+
errors?: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a PayTech payment request.
|
|
29
|
+
*/
|
|
30
|
+
export declare const createPayTechPayment: (config: PayTechConfig, item: PayTechItem, urls: PayTechUrls, refCommand: string, currency?: string, env?: string) => Promise<PayTechResult>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=paytech.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paytech.d.ts","sourceRoot":"","sources":["../../src/payments/paytech.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,UAAU,aAAa;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,WAAW;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,WAAW;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,aAAa;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAKD;;GAEG;AACH,eAAO,MAAM,oBAAoB,WACrB,aAAa,QACf,WAAW,QACX,WAAW,cACL,MAAM,sCAGnB,QAAQ,aAAa,CA4DvB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PayTech payment gateway client.
|
|
4
|
+
* Used by GrooMe for mobile money and card payments
|
|
5
|
+
* in West Africa.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.createPayTechPayment = void 0;
|
|
9
|
+
const PAYTECH_BASE_URL = "https://paytech.sn/api/payment/request-payment";
|
|
10
|
+
/**
|
|
11
|
+
* Create a PayTech payment request.
|
|
12
|
+
*/
|
|
13
|
+
const createPayTechPayment = async (config, item, urls, refCommand, currency = "XOF", env = "prod") => {
|
|
14
|
+
const headers = {
|
|
15
|
+
Accept: "application/json",
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
API_KEY: config.apiKey,
|
|
18
|
+
API_SECRET: config.apiSecret,
|
|
19
|
+
};
|
|
20
|
+
const body = {
|
|
21
|
+
item_name: item.itemName,
|
|
22
|
+
item_price: item.itemPrice.toString(),
|
|
23
|
+
command_name: item.commandName,
|
|
24
|
+
ref_command: refCommand,
|
|
25
|
+
currency,
|
|
26
|
+
env,
|
|
27
|
+
ipn_url: urls.ipnUrl,
|
|
28
|
+
success_url: urls.successUrl,
|
|
29
|
+
cancel_url: urls.cancelUrl,
|
|
30
|
+
custom_field: JSON.stringify({
|
|
31
|
+
custom_field1: config.isMobile
|
|
32
|
+
? "mobile"
|
|
33
|
+
: "web",
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetch(PAYTECH_BASE_URL, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers,
|
|
40
|
+
body: JSON.stringify(body),
|
|
41
|
+
});
|
|
42
|
+
const data = (await response.json());
|
|
43
|
+
if (data.success === 1) {
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
token: data.token,
|
|
47
|
+
redirectUrl: data.redirect_url,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
errors: data.errors || [
|
|
53
|
+
"Payment request failed",
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const msg = error instanceof Error
|
|
59
|
+
? error.message
|
|
60
|
+
: "PayTech request failed";
|
|
61
|
+
return { success: false, errors: [msg] };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.createPayTechPayment = createPayTechPayment;
|
|
65
|
+
//# sourceMappingURL=paytech.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paytech.js","sourceRoot":"","sources":["../../src/payments/paytech.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA2BH,MAAM,gBAAgB,GAClB,gDAAgD,CAAC;AAErD;;GAEG;AACI,MAAM,oBAAoB,GAAG,KAAK,EACrC,MAAqB,EACrB,IAAiB,EACjB,IAAiB,EACjB,UAAkB,EAClB,QAAQ,GAAG,KAAK,EAChB,GAAG,GAAG,MAAM,EACU,EAAE;IACxB,MAAM,OAAO,GAA2B;QACpC,MAAM,EAAE,kBAAkB;QAC1B,cAAc,EAAE,kBAAkB;QAClC,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,UAAU,EAAE,MAAM,CAAC,SAAS;KAC/B,CAAC;IAEF,M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AAE,CAAC;IAC7C,CAAC;AACL,CAAC,CAAC;AAnEW,QAAA,oBAAoB,wBAmE/B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stripe client factory.
|
|
3
|
+
* Used by GrooMe for payment processing.
|
|
4
|
+
*
|
|
5
|
+
* Requires 'stripe' as a peer dependency.
|
|
6
|
+
*/
|
|
7
|
+
interface StripeConfig {
|
|
8
|
+
secretKey: string;
|
|
9
|
+
apiVersion?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a lazy-initialized Stripe client.
|
|
13
|
+
* Returns a function that creates the client on
|
|
14
|
+
* first call.
|
|
15
|
+
*/
|
|
16
|
+
export declare const createStripeClient: (config: StripeConfig) => any;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=stripe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/payments/stripe.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,UAAU,YAAY;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WACnB,YAAY,QAQvB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Stripe client factory.
|
|
4
|
+
* Used by GrooMe for payment processing.
|
|
5
|
+
*
|
|
6
|
+
* Requires 'stripe' as a peer dependency.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createStripeClient = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Create a lazy-initialized Stripe client.
|
|
12
|
+
* Returns a function that creates the client on
|
|
13
|
+
* first call.
|
|
14
|
+
*/
|
|
15
|
+
const createStripeClient = (config) => {
|
|
16
|
+
// Dynamic import to avoid hard dependency
|
|
17
|
+
// eslint-disable-next-line
|
|
18
|
+
const Stripe = require("stripe");
|
|
19
|
+
return new Stripe(config.secretKey, {
|
|
20
|
+
apiVersion: config.apiVersion || "2026-01-28.clover",
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.createStripeClient = createStripeClient;
|
|
24
|
+
//# sourceMappingURL=stripe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.js","sourceRoot":"","sources":["../../src/payments/stripe.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAOH;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAC9B,MAAoB,EACtB,EAAE;IACA,0CAA0C;IAC1C,2BAA2B;IAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;QAChC,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,mBAAmB;KACvD,CAAC,CAAC;AACP,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StatusCodes } from "http-status-codes";
|
|
2
|
+
/**
|
|
3
|
+
* Framework-agnostic API response shape.
|
|
4
|
+
* Adapters (Express, Next.js) convert this to actual
|
|
5
|
+
* HTTP responses.
|
|
6
|
+
*/
|
|
7
|
+
export interface ApiResponse {
|
|
8
|
+
statusCode: number;
|
|
9
|
+
body: {
|
|
10
|
+
status: boolean;
|
|
11
|
+
message?: string;
|
|
12
|
+
data?: unknown;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const makeSuccess: (data: unknown, statusCode?: StatusCodes) => ApiResponse;
|
|
16
|
+
export declare const makeSuccessMessage: (message: string, statusCode?: StatusCodes) => ApiResponse;
|
|
17
|
+
export declare const makeError: (message: string, statusCode?: StatusCodes) => ApiResponse;
|
|
18
|
+
export declare const makeUnauthorized: (message?: string) => ApiResponse;
|
|
19
|
+
export declare const makeForbidden: (message?: string) => ApiResponse;
|
|
20
|
+
export declare const makeNotFound: (message?: string) => ApiResponse;
|
|
21
|
+
export declare const makeServerError: (message?: string) => ApiResponse;
|
|
22
|
+
export declare const makeBadGateway: (message: string) => ApiResponse;
|
|
23
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/responses/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QACF,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;CACL;AAED,eAAO,MAAM,WAAW,SACd,OAAO,+BAEd,WAGD,CAAC;AAEH,eAAO,MAAM,kBAAkB,YAClB,MAAM,+BAEhB,WAGD,CAAC;AAEH,eAAO,MAAM,SAAS,YACT,MAAM,+BAEhB,WAGD,CAAC;AAEH,eAAO,MAAM,gBAAgB,wBAE1B,WAGD,CAAC;AAEH,eAAO,MAAM,aAAa,wBAEvB,WAGD,CAAC;AAEH,eAAO,MAAM,YAAY,wBAEtB,WAGD,CAAC;AAEH,eAAO,MAAM,eAAe,wBAEzB,WAGD,CAAC;AAEH,eAAO,MAAM,cAAc,YACd,MAAM,KAChB,WAGD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeBadGateway = exports.makeServerError = exports.makeNotFound = exports.makeForbidden = exports.makeUnauthorized = exports.makeError = exports.makeSuccessMessage = exports.makeSuccess = void 0;
|
|
4
|
+
const http_status_codes_1 = require("http-status-codes");
|
|
5
|
+
const makeSuccess = (data, statusCode = http_status_codes_1.StatusCodes.OK) => ({
|
|
6
|
+
statusCode,
|
|
7
|
+
body: { status: true, data },
|
|
8
|
+
});
|
|
9
|
+
exports.makeSuccess = makeSuccess;
|
|
10
|
+
const makeSuccessMessage = (message, statusCode = http_status_codes_1.StatusCodes.OK) => ({
|
|
11
|
+
statusCode,
|
|
12
|
+
body: { status: true, message },
|
|
13
|
+
});
|
|
14
|
+
exports.makeSuccessMessage = makeSuccessMessage;
|
|
15
|
+
const makeError = (message, statusCode = http_status_codes_1.StatusCodes.BAD_REQUEST) => ({
|
|
16
|
+
statusCode,
|
|
17
|
+
body: { status: false, message },
|
|
18
|
+
});
|
|
19
|
+
exports.makeError = makeError;
|
|
20
|
+
const makeUnauthorized = (message = "Unauthorized") => ({
|
|
21
|
+
statusCode: http_status_codes_1.StatusCodes.UNAUTHORIZED,
|
|
22
|
+
body: { status: false, message },
|
|
23
|
+
});
|
|
24
|
+
exports.makeUnauthorized = makeUnauthorized;
|
|
25
|
+
const makeForbidden = (message = "Forbidden") => ({
|
|
26
|
+
statusCode: http_status_codes_1.StatusCodes.FORBIDDEN,
|
|
27
|
+
body: { status: false, message },
|
|
28
|
+
});
|
|
29
|
+
exports.makeForbidden = makeForbidden;
|
|
30
|
+
const makeNotFound = (message = "Not found") => ({
|
|
31
|
+
statusCode: http_status_codes_1.StatusCodes.NOT_FOUND,
|
|
32
|
+
body: { status: false, message },
|
|
33
|
+
});
|
|
34
|
+
exports.makeNotFound = makeNotFound;
|
|
35
|
+
const makeServerError = (message = "Internal server error") => ({
|
|
36
|
+
statusCode: http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR,
|
|
37
|
+
body: { status: false, message },
|
|
38
|
+
});
|
|
39
|
+
exports.makeServerError = makeServerError;
|
|
40
|
+
const makeBadGateway = (message) => ({
|
|
41
|
+
statusCode: http_status_codes_1.StatusCodes.BAD_GATEWAY,
|
|
42
|
+
body: { status: false, message },
|
|
43
|
+
});
|
|
44
|
+
exports.makeBadGateway = makeBadGateway;
|
|
45
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/responses/core.ts"],"names":[],"mappings":";;;AAAA,yDAAgD;AAgBzC,MAAM,WAAW,GAAG,CACvB,IAAa,EACb,UAAU,GAAG,+BAAW,CAAC,EAAE,EAChB,EAAE,CAAC,CAAC;IACf,UAAU;IACV,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;CAC/B,CAAC,CAAC;AANU,QAAA,WAAW,eAMrB;AAEI,MAAM,kBAAkB,GAAG,CAC9B,OAAe,EACf,UAAU,GAAG,+BAAW,CAAC,EAAE,EAChB,EAAE,CAAC,CAAC;IACf,UAAU;IACV,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;CAClC,CAAC,CAAC;AANU,QAAA,kBAAkB,sBAM5B;AAEI,MAAM,SAAS,GAAG,CACrB,OAAe,EACf,UAAU,GAAG,+BAAW,CAAC,WAAW,EACzB,EAAE,CAAC,CAAC;IACf,UAAU;IACV,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;CACnC,CAAC,CAAC;AANU,QAAA,SAAS,aAMnB;AAEI,MAAM,gBAAgB,GAAG,CAC5B,OAAO,GAAG,cAAc,EACb,EAAE,CAAC,CAAC;IACf,UAAU,EAAE,+BAAW,CAAC,YAAY;IACpC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;CACnC,CAAC,CAAC;AALU,QAAA,gBAAgB,oBAK1B;AAEI,MAAM,aAAa,GAAG,CACzB,OAAO,GAAG,WAAW,EACV,EAAE,CAAC,CAAC;IACf,UAAU,EAAE,+BAAW,CAAC,SAAS;IACjC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;CACnC,CAAC,CAAC;AALU,QAAA,aAAa,iBAKvB;AAEI,MAAM,YAAY,GAAG,CACxB,OAAO,GAAG,WAAW,EACV,EAAE,CAAC,CAAC;IACf,UAAU,EAAE,+BAAW,CAAC,SAAS;IACjC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;CACnC,CAAC,CAAC;AALU,QAAA,YAAY,gBAKtB;AAEI,MAAM,eAAe,GAAG,CAC3B,OAAO,GAAG,uBAAuB,EACtB,EAAE,CAAC,CAAC;IACf,UAAU,EAAE,+BAAW,CAAC,qBAAqB;IAC7C,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;CACnC,CAAC,CAAC;AALU,QAAA,eAAe,mBAKzB;AAEI,MAAM,cAAc,GAAG,CAC1B,OAAe,EACJ,EAAE,CAAC,CAAC;IACf,UAAU,EAAE,+BAAW,CAAC,WAAW;IACnC,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;CACnC,CAAC,CAAC;AALU,QAAA,cAAc,kBAKxB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Express response adapter functions.
|
|
3
|
+
* Used by babel-lambda-api and other Express projects.
|
|
4
|
+
*
|
|
5
|
+
* These accept Express `res` object directly — backward
|
|
6
|
+
* compatible with the original base_nodejs_library API.
|
|
7
|
+
*/
|
|
8
|
+
export declare const generateBadRequestResponse: (response: any, data: string) => any;
|
|
9
|
+
export declare const generateUnauthorizedResponse: (response: any, data: string) => any;
|
|
10
|
+
export declare const generateBadGatewayResponse: (response: any, data: string) => any;
|
|
11
|
+
export declare const generateForbiddenErrorResponse: (response: any, data: string) => any;
|
|
12
|
+
export declare const generateErrorResponse: (response: any, data: any) => any;
|
|
13
|
+
export declare const generateSuccessResponse: (response: any, data: any) => any;
|
|
14
|
+
export declare const generateSuccessResponseWithData: (response: any, data: any) => any;
|
|
15
|
+
export declare const generateServerErrorResponse: (response: any, data: string, statusCode: number) => any;
|
|
16
|
+
export declare const generateSuccessFullResponse: (response: any, responseData: object) => any;
|
|
17
|
+
//# sourceMappingURL=express.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/responses/express.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAIH,eAAO,MAAM,0BAA0B,aACzB,GAAG,QACP,MAAM,KACb,GAIF,CAAC;AAEF,eAAO,MAAM,4BAA4B,aAC3B,GAAG,QACP,MAAM,KACb,GAIF,CAAC;AAEF,eAAO,MAAM,0BAA0B,aACzB,GAAG,QACP,MAAM,KACb,GAIF,CAAC;AAEF,eAAO,MAAM,8BAA8B,aAC7B,GAAG,QACP,MAAM,KACb,GAIF,CAAC;AAEF,eAAO,MAAM,qBAAqB,aACpB,GAAG,QACP,GAAG,KACV,GAIF,CAAC;AAEF,eAAO,MAAM,uBAAuB,aACtB,GAAG,QACP,GAAG,KACV,GAIF,CAAC;AAEF,eAAO,MAAM,+BAA+B,aAC9B,GAAG,QACP,GAAG,KACV,GAIF,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAC1B,GAAG,QACP,MAAM,cACA,MAAM,KACnB,GAIF,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAC1B,GAAG,gBACC,MAAM,KACrB,GAIF,CAAC"}
|