servcraft 0.1.0 → 0.1.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/.claude/settings.local.json +29 -0
- package/.github/CODEOWNERS +18 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +46 -0
- package/.github/dependabot.yml +59 -0
- package/.github/workflows/ci.yml +188 -0
- package/.github/workflows/release.yml +195 -0
- package/AUDIT.md +602 -0
- package/README.md +1070 -1
- package/dist/cli/index.cjs +2026 -2168
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +2026 -2168
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +595 -616
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +114 -52
- package/dist/index.d.ts +114 -52
- package/dist/index.js +595 -616
- package/dist/index.js.map +1 -1
- package/docs/CLI-001_MULTI_DB_PLAN.md +546 -0
- package/docs/DATABASE_MULTI_ORM.md +399 -0
- package/docs/PHASE1_BREAKDOWN.md +346 -0
- package/docs/PROGRESS.md +550 -0
- package/docs/modules/ANALYTICS.md +226 -0
- package/docs/modules/API-VERSIONING.md +252 -0
- package/docs/modules/AUDIT.md +192 -0
- package/docs/modules/AUTH.md +431 -0
- package/docs/modules/CACHE.md +346 -0
- package/docs/modules/EMAIL.md +254 -0
- package/docs/modules/FEATURE-FLAG.md +291 -0
- package/docs/modules/I18N.md +294 -0
- package/docs/modules/MEDIA-PROCESSING.md +281 -0
- package/docs/modules/MFA.md +266 -0
- package/docs/modules/NOTIFICATION.md +311 -0
- package/docs/modules/OAUTH.md +237 -0
- package/docs/modules/PAYMENT.md +804 -0
- package/docs/modules/QUEUE.md +540 -0
- package/docs/modules/RATE-LIMIT.md +339 -0
- package/docs/modules/SEARCH.md +288 -0
- package/docs/modules/SECURITY.md +327 -0
- package/docs/modules/SESSION.md +382 -0
- package/docs/modules/SWAGGER.md +305 -0
- package/docs/modules/UPLOAD.md +296 -0
- package/docs/modules/USER.md +505 -0
- package/docs/modules/VALIDATION.md +294 -0
- package/docs/modules/WEBHOOK.md +270 -0
- package/docs/modules/WEBSOCKET.md +691 -0
- package/package.json +53 -38
- package/prisma/schema.prisma +395 -1
- package/src/cli/commands/add-module.ts +520 -87
- package/src/cli/commands/db.ts +3 -4
- package/src/cli/commands/docs.ts +256 -6
- package/src/cli/commands/generate.ts +12 -19
- package/src/cli/commands/init.ts +384 -214
- package/src/cli/index.ts +0 -4
- package/src/cli/templates/repository.ts +6 -1
- package/src/cli/templates/routes.ts +6 -21
- package/src/cli/utils/docs-generator.ts +6 -7
- package/src/cli/utils/env-manager.ts +717 -0
- package/src/cli/utils/field-parser.ts +16 -7
- package/src/cli/utils/interactive-prompt.ts +223 -0
- package/src/cli/utils/template-manager.ts +346 -0
- package/src/config/database.config.ts +183 -0
- package/src/config/env.ts +0 -10
- package/src/config/index.ts +0 -14
- package/src/core/server.ts +1 -1
- package/src/database/adapters/mongoose.adapter.ts +132 -0
- package/src/database/adapters/prisma.adapter.ts +118 -0
- package/src/database/connection.ts +190 -0
- package/src/database/interfaces/database.interface.ts +85 -0
- package/src/database/interfaces/index.ts +7 -0
- package/src/database/interfaces/repository.interface.ts +129 -0
- package/src/database/models/mongoose/index.ts +7 -0
- package/src/database/models/mongoose/payment.schema.ts +347 -0
- package/src/database/models/mongoose/user.schema.ts +154 -0
- package/src/database/prisma.ts +1 -4
- package/src/database/redis.ts +101 -0
- package/src/database/repositories/mongoose/index.ts +7 -0
- package/src/database/repositories/mongoose/payment.repository.ts +380 -0
- package/src/database/repositories/mongoose/user.repository.ts +255 -0
- package/src/database/seed.ts +6 -1
- package/src/index.ts +9 -20
- package/src/middleware/security.ts +2 -6
- package/src/modules/analytics/analytics.routes.ts +80 -0
- package/src/modules/analytics/analytics.service.ts +364 -0
- package/src/modules/analytics/index.ts +18 -0
- package/src/modules/analytics/types.ts +180 -0
- package/src/modules/api-versioning/index.ts +15 -0
- package/src/modules/api-versioning/types.ts +86 -0
- package/src/modules/api-versioning/versioning.middleware.ts +120 -0
- package/src/modules/api-versioning/versioning.routes.ts +54 -0
- package/src/modules/api-versioning/versioning.service.ts +189 -0
- package/src/modules/audit/audit.repository.ts +206 -0
- package/src/modules/audit/audit.service.ts +27 -59
- package/src/modules/auth/auth.controller.ts +2 -2
- package/src/modules/auth/auth.middleware.ts +3 -9
- package/src/modules/auth/auth.routes.ts +10 -107
- package/src/modules/auth/auth.service.ts +126 -23
- package/src/modules/auth/index.ts +3 -4
- package/src/modules/cache/cache.service.ts +367 -0
- package/src/modules/cache/index.ts +10 -0
- package/src/modules/cache/types.ts +44 -0
- package/src/modules/email/email.service.ts +3 -10
- package/src/modules/email/templates.ts +2 -8
- package/src/modules/feature-flag/feature-flag.repository.ts +303 -0
- package/src/modules/feature-flag/feature-flag.routes.ts +247 -0
- package/src/modules/feature-flag/feature-flag.service.ts +566 -0
- package/src/modules/feature-flag/index.ts +20 -0
- package/src/modules/feature-flag/types.ts +192 -0
- package/src/modules/i18n/i18n.middleware.ts +186 -0
- package/src/modules/i18n/i18n.routes.ts +191 -0
- package/src/modules/i18n/i18n.service.ts +456 -0
- package/src/modules/i18n/index.ts +18 -0
- package/src/modules/i18n/types.ts +118 -0
- package/src/modules/media-processing/index.ts +17 -0
- package/src/modules/media-processing/media-processing.routes.ts +111 -0
- package/src/modules/media-processing/media-processing.service.ts +245 -0
- package/src/modules/media-processing/types.ts +156 -0
- package/src/modules/mfa/index.ts +20 -0
- package/src/modules/mfa/mfa.repository.ts +206 -0
- package/src/modules/mfa/mfa.routes.ts +595 -0
- package/src/modules/mfa/mfa.service.ts +572 -0
- package/src/modules/mfa/totp.ts +150 -0
- package/src/modules/mfa/types.ts +57 -0
- package/src/modules/notification/index.ts +20 -0
- package/src/modules/notification/notification.repository.ts +356 -0
- package/src/modules/notification/notification.service.ts +483 -0
- package/src/modules/notification/types.ts +119 -0
- package/src/modules/oauth/index.ts +20 -0
- package/src/modules/oauth/oauth.repository.ts +219 -0
- package/src/modules/oauth/oauth.routes.ts +446 -0
- package/src/modules/oauth/oauth.service.ts +293 -0
- package/src/modules/oauth/providers/apple.provider.ts +250 -0
- package/src/modules/oauth/providers/facebook.provider.ts +181 -0
- package/src/modules/oauth/providers/github.provider.ts +248 -0
- package/src/modules/oauth/providers/google.provider.ts +189 -0
- package/src/modules/oauth/providers/twitter.provider.ts +214 -0
- package/src/modules/oauth/types.ts +94 -0
- package/src/modules/payment/index.ts +19 -0
- package/src/modules/payment/payment.repository.ts +733 -0
- package/src/modules/payment/payment.routes.ts +390 -0
- package/src/modules/payment/payment.service.ts +354 -0
- package/src/modules/payment/providers/mobile-money.provider.ts +274 -0
- package/src/modules/payment/providers/paypal.provider.ts +190 -0
- package/src/modules/payment/providers/stripe.provider.ts +215 -0
- package/src/modules/payment/types.ts +140 -0
- package/src/modules/queue/cron.ts +438 -0
- package/src/modules/queue/index.ts +87 -0
- package/src/modules/queue/queue.routes.ts +600 -0
- package/src/modules/queue/queue.service.ts +842 -0
- package/src/modules/queue/types.ts +222 -0
- package/src/modules/queue/workers.ts +366 -0
- package/src/modules/rate-limit/index.ts +59 -0
- package/src/modules/rate-limit/rate-limit.middleware.ts +134 -0
- package/src/modules/rate-limit/rate-limit.routes.ts +269 -0
- package/src/modules/rate-limit/rate-limit.service.ts +348 -0
- package/src/modules/rate-limit/stores/memory.store.ts +165 -0
- package/src/modules/rate-limit/stores/redis.store.ts +322 -0
- package/src/modules/rate-limit/types.ts +153 -0
- package/src/modules/search/adapters/elasticsearch.adapter.ts +326 -0
- package/src/modules/search/adapters/meilisearch.adapter.ts +261 -0
- package/src/modules/search/adapters/memory.adapter.ts +278 -0
- package/src/modules/search/index.ts +21 -0
- package/src/modules/search/search.service.ts +234 -0
- package/src/modules/search/types.ts +214 -0
- package/src/modules/security/index.ts +40 -0
- package/src/modules/security/sanitize.ts +223 -0
- package/src/modules/security/security-audit.service.ts +388 -0
- package/src/modules/security/security.middleware.ts +398 -0
- package/src/modules/session/index.ts +3 -0
- package/src/modules/session/session.repository.ts +159 -0
- package/src/modules/session/session.service.ts +340 -0
- package/src/modules/session/types.ts +38 -0
- package/src/modules/swagger/index.ts +7 -1
- package/src/modules/swagger/schema-builder.ts +16 -4
- package/src/modules/swagger/swagger.service.ts +9 -10
- package/src/modules/swagger/types.ts +0 -2
- package/src/modules/upload/index.ts +14 -0
- package/src/modules/upload/types.ts +83 -0
- package/src/modules/upload/upload.repository.ts +199 -0
- package/src/modules/upload/upload.routes.ts +311 -0
- package/src/modules/upload/upload.service.ts +448 -0
- package/src/modules/user/index.ts +3 -3
- package/src/modules/user/user.controller.ts +15 -9
- package/src/modules/user/user.repository.ts +237 -113
- package/src/modules/user/user.routes.ts +39 -164
- package/src/modules/user/user.service.ts +4 -3
- package/src/modules/validation/validator.ts +12 -17
- package/src/modules/webhook/index.ts +91 -0
- package/src/modules/webhook/retry.ts +196 -0
- package/src/modules/webhook/signature.ts +135 -0
- package/src/modules/webhook/types.ts +181 -0
- package/src/modules/webhook/webhook.repository.ts +358 -0
- package/src/modules/webhook/webhook.routes.ts +442 -0
- package/src/modules/webhook/webhook.service.ts +457 -0
- package/src/modules/websocket/features.ts +504 -0
- package/src/modules/websocket/index.ts +106 -0
- package/src/modules/websocket/middlewares.ts +298 -0
- package/src/modules/websocket/types.ts +181 -0
- package/src/modules/websocket/websocket.service.ts +692 -0
- package/src/utils/errors.ts +7 -0
- package/src/utils/pagination.ts +4 -1
- package/tests/helpers/db-check.ts +79 -0
- package/tests/integration/auth-redis.test.ts +94 -0
- package/tests/integration/cache-redis.test.ts +387 -0
- package/tests/integration/mongoose-repositories.test.ts +410 -0
- package/tests/integration/payment-prisma.test.ts +637 -0
- package/tests/integration/queue-bullmq.test.ts +417 -0
- package/tests/integration/user-prisma.test.ts +441 -0
- package/tests/integration/websocket-socketio.test.ts +552 -0
- package/tests/setup.ts +11 -9
- package/vitest.config.ts +3 -8
- package/npm-cache/_cacache/content-v2/sha512/1c/d0/03440d500a0487621aad1d6402978340698976602046db8e24fa03c01ee6c022c69b0582f969042d9442ee876ac35c038e960dd427d1e622fa24b8eb7dba +0 -0
- package/npm-cache/_cacache/content-v2/sha512/42/55/28b493ca491833e5aab0e9c3108d29ab3f36c248ca88f45d4630674fce9130959e56ae308797ac2b6328fa7f09a610b9550ed09cb971d039876d293fc69d +0 -0
- package/npm-cache/_cacache/content-v2/sha512/e0/12/f360dc9315ee5f17844a0c8c233ee6bf7c30837c4a02ea0d56c61c7f7ab21c0e958e50ed2c57c59f983c762b93056778c9009b2398ffc26def0183999b13 +0 -0
- package/npm-cache/_cacache/content-v2/sha512/ed/b0/fae1161902898f4c913c67d7f6cdf6be0665aec3b389b9c4f4f0a101ca1da59badf1b59c4e0030f5223023b8d63cfe501c46a32c20c895d4fb3f11ca2232 +0 -0
- package/npm-cache/_cacache/index-v5/58/94/c2cba79e0f16b4c10e95a87e32255741149e8222cc314a476aab67c39cc0 +0 -5
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { randomBytes, createHmac } from 'crypto';
|
|
2
|
+
import { logger } from '../../../core/logger.js';
|
|
3
|
+
import type { TwitterOAuthConfig, OAuthUser, OAuthTokens, OAuthState } from '../types.js';
|
|
4
|
+
|
|
5
|
+
// Twitter OAuth 2.0 with PKCE
|
|
6
|
+
const TWITTER_AUTH_URL = 'https://twitter.com/i/oauth2/authorize';
|
|
7
|
+
const TWITTER_TOKEN_URL = 'https://api.twitter.com/2/oauth2/token';
|
|
8
|
+
const TWITTER_USERINFO_URL = 'https://api.twitter.com/2/users/me';
|
|
9
|
+
|
|
10
|
+
const DEFAULT_SCOPES = ['tweet.read', 'users.read', 'offline.access'];
|
|
11
|
+
|
|
12
|
+
export class TwitterOAuthProvider {
|
|
13
|
+
private config: TwitterOAuthConfig;
|
|
14
|
+
private callbackUrl: string;
|
|
15
|
+
|
|
16
|
+
constructor(config: TwitterOAuthConfig, callbackBaseUrl: string) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.callbackUrl = `${callbackBaseUrl}/auth/oauth/twitter/callback`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generate authorization URL with PKCE
|
|
23
|
+
*/
|
|
24
|
+
generateAuthUrl(state?: string): { url: string; state: OAuthState } {
|
|
25
|
+
const stateValue = state || randomBytes(32).toString('hex');
|
|
26
|
+
const codeVerifier = randomBytes(32).toString('base64url');
|
|
27
|
+
const codeChallenge = createHmac('sha256', codeVerifier)
|
|
28
|
+
.update(codeVerifier)
|
|
29
|
+
.digest('base64url');
|
|
30
|
+
|
|
31
|
+
const params = new URLSearchParams({
|
|
32
|
+
response_type: 'code',
|
|
33
|
+
client_id: this.config.clientId,
|
|
34
|
+
redirect_uri: this.callbackUrl,
|
|
35
|
+
scope: DEFAULT_SCOPES.join(' '),
|
|
36
|
+
state: stateValue,
|
|
37
|
+
code_challenge: codeChallenge,
|
|
38
|
+
code_challenge_method: 'S256',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const oauthState: OAuthState = {
|
|
42
|
+
state: stateValue,
|
|
43
|
+
codeVerifier,
|
|
44
|
+
redirectUri: this.callbackUrl,
|
|
45
|
+
createdAt: Date.now(),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
url: `${TWITTER_AUTH_URL}?${params.toString()}`,
|
|
50
|
+
state: oauthState,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Exchange authorization code for tokens
|
|
56
|
+
*/
|
|
57
|
+
async exchangeCode(code: string, codeVerifier?: string): Promise<OAuthTokens> {
|
|
58
|
+
const params = new URLSearchParams({
|
|
59
|
+
code,
|
|
60
|
+
grant_type: 'authorization_code',
|
|
61
|
+
redirect_uri: this.callbackUrl,
|
|
62
|
+
code_verifier: codeVerifier || '',
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const credentials = Buffer.from(`${this.config.clientId}:${this.config.clientSecret}`).toString(
|
|
66
|
+
'base64'
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
const response = await fetch(TWITTER_TOKEN_URL, {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
headers: {
|
|
72
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
73
|
+
Authorization: `Basic ${credentials}`,
|
|
74
|
+
},
|
|
75
|
+
body: params.toString(),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
const error = await response.text();
|
|
80
|
+
logger.error({ error }, 'Twitter token exchange failed');
|
|
81
|
+
throw new Error(`Failed to exchange code: ${error}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const data = (await response.json()) as {
|
|
85
|
+
access_token: string;
|
|
86
|
+
refresh_token?: string;
|
|
87
|
+
expires_in: number;
|
|
88
|
+
token_type: string;
|
|
89
|
+
scope: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
accessToken: data.access_token,
|
|
94
|
+
refreshToken: data.refresh_token,
|
|
95
|
+
expiresIn: data.expires_in,
|
|
96
|
+
tokenType: data.token_type,
|
|
97
|
+
scope: data.scope,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get user information from Twitter
|
|
103
|
+
*/
|
|
104
|
+
async getUser(accessToken: string): Promise<OAuthUser> {
|
|
105
|
+
const params = new URLSearchParams({
|
|
106
|
+
'user.fields': 'id,name,username,profile_image_url,description,verified',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const response = await fetch(`${TWITTER_USERINFO_URL}?${params}`, {
|
|
110
|
+
headers: {
|
|
111
|
+
Authorization: `Bearer ${accessToken}`,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
const error = await response.text();
|
|
117
|
+
logger.error({ error }, 'Failed to get Twitter user info');
|
|
118
|
+
throw new Error(`Failed to get user info: ${error}`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const result = (await response.json()) as {
|
|
122
|
+
data: {
|
|
123
|
+
id: string;
|
|
124
|
+
name: string;
|
|
125
|
+
username: string;
|
|
126
|
+
profile_image_url?: string;
|
|
127
|
+
description?: string;
|
|
128
|
+
verified?: boolean;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const data = result.data;
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
id: data.id,
|
|
136
|
+
email: null, // Twitter doesn't provide email by default
|
|
137
|
+
emailVerified: false,
|
|
138
|
+
name: data.name,
|
|
139
|
+
firstName: data.name.split(' ')[0] ?? null,
|
|
140
|
+
lastName: data.name.split(' ').slice(1).join(' ') || null,
|
|
141
|
+
picture: data.profile_image_url?.replace('_normal', '') || null,
|
|
142
|
+
provider: 'twitter',
|
|
143
|
+
providerAccountId: data.id,
|
|
144
|
+
accessToken,
|
|
145
|
+
raw: data,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Refresh access token
|
|
151
|
+
*/
|
|
152
|
+
async refreshToken(refreshToken: string): Promise<OAuthTokens> {
|
|
153
|
+
const params = new URLSearchParams({
|
|
154
|
+
grant_type: 'refresh_token',
|
|
155
|
+
refresh_token: refreshToken,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const credentials = Buffer.from(`${this.config.clientId}:${this.config.clientSecret}`).toString(
|
|
159
|
+
'base64'
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
const response = await fetch(TWITTER_TOKEN_URL, {
|
|
163
|
+
method: 'POST',
|
|
164
|
+
headers: {
|
|
165
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
166
|
+
Authorization: `Basic ${credentials}`,
|
|
167
|
+
},
|
|
168
|
+
body: params.toString(),
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (!response.ok) {
|
|
172
|
+
throw new Error('Failed to refresh token');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const data = (await response.json()) as {
|
|
176
|
+
access_token: string;
|
|
177
|
+
refresh_token?: string;
|
|
178
|
+
expires_in: number;
|
|
179
|
+
token_type: string;
|
|
180
|
+
scope: string;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
accessToken: data.access_token,
|
|
185
|
+
refreshToken: data.refresh_token,
|
|
186
|
+
expiresIn: data.expires_in,
|
|
187
|
+
tokenType: data.token_type,
|
|
188
|
+
scope: data.scope,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Revoke access token
|
|
194
|
+
*/
|
|
195
|
+
async revokeToken(token: string): Promise<void> {
|
|
196
|
+
const params = new URLSearchParams({
|
|
197
|
+
token,
|
|
198
|
+
token_type_hint: 'access_token',
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const credentials = Buffer.from(`${this.config.clientId}:${this.config.clientSecret}`).toString(
|
|
202
|
+
'base64'
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
await fetch('https://api.twitter.com/2/oauth2/revoke', {
|
|
206
|
+
method: 'POST',
|
|
207
|
+
headers: {
|
|
208
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
209
|
+
Authorization: `Basic ${credentials}`,
|
|
210
|
+
},
|
|
211
|
+
body: params.toString(),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export type OAuthProvider = 'google' | 'facebook' | 'github' | 'twitter' | 'apple';
|
|
2
|
+
|
|
3
|
+
export interface OAuthConfig {
|
|
4
|
+
google?: GoogleOAuthConfig;
|
|
5
|
+
facebook?: FacebookOAuthConfig;
|
|
6
|
+
github?: GitHubOAuthConfig;
|
|
7
|
+
twitter?: TwitterOAuthConfig;
|
|
8
|
+
apple?: AppleOAuthConfig;
|
|
9
|
+
callbackBaseUrl: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface GoogleOAuthConfig {
|
|
13
|
+
clientId: string;
|
|
14
|
+
clientSecret: string;
|
|
15
|
+
scopes?: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface FacebookOAuthConfig {
|
|
19
|
+
clientId: string;
|
|
20
|
+
clientSecret: string;
|
|
21
|
+
scopes?: string[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GitHubOAuthConfig {
|
|
25
|
+
clientId: string;
|
|
26
|
+
clientSecret: string;
|
|
27
|
+
scopes?: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TwitterOAuthConfig {
|
|
31
|
+
clientId: string;
|
|
32
|
+
clientSecret: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface AppleOAuthConfig {
|
|
36
|
+
clientId: string;
|
|
37
|
+
teamId: string;
|
|
38
|
+
keyId: string;
|
|
39
|
+
privateKey: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface OAuthUser {
|
|
43
|
+
id: string;
|
|
44
|
+
email: string | null;
|
|
45
|
+
emailVerified: boolean;
|
|
46
|
+
name: string | null;
|
|
47
|
+
firstName: string | null;
|
|
48
|
+
lastName: string | null;
|
|
49
|
+
picture: string | null;
|
|
50
|
+
provider: OAuthProvider;
|
|
51
|
+
providerAccountId: string;
|
|
52
|
+
accessToken: string;
|
|
53
|
+
refreshToken?: string;
|
|
54
|
+
expiresAt?: number;
|
|
55
|
+
raw: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface OAuthTokens {
|
|
59
|
+
accessToken: string;
|
|
60
|
+
refreshToken?: string;
|
|
61
|
+
expiresIn?: number;
|
|
62
|
+
tokenType: string;
|
|
63
|
+
scope?: string;
|
|
64
|
+
idToken?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface OAuthState {
|
|
68
|
+
state: string;
|
|
69
|
+
codeVerifier?: string; // For PKCE
|
|
70
|
+
redirectUri: string;
|
|
71
|
+
createdAt: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface LinkedAccount {
|
|
75
|
+
id: string;
|
|
76
|
+
userId: string;
|
|
77
|
+
provider: OAuthProvider;
|
|
78
|
+
providerAccountId: string;
|
|
79
|
+
email?: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
picture?: string;
|
|
82
|
+
accessToken?: string;
|
|
83
|
+
refreshToken?: string;
|
|
84
|
+
expiresAt?: Date;
|
|
85
|
+
createdAt: Date;
|
|
86
|
+
updatedAt: Date;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface OAuthCallbackParams {
|
|
90
|
+
code: string;
|
|
91
|
+
state: string;
|
|
92
|
+
error?: string;
|
|
93
|
+
errorDescription?: string;
|
|
94
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { PaymentService, getPaymentService, createPaymentService } from './payment.service.js';
|
|
2
|
+
export type { PaymentServiceConfig } from './payment.service.js';
|
|
3
|
+
export { registerPaymentRoutes } from './payment.routes.js';
|
|
4
|
+
export { StripeProvider } from './providers/stripe.provider.js';
|
|
5
|
+
export { PayPalProvider } from './providers/paypal.provider.js';
|
|
6
|
+
export { MobileMoneyProvider } from './providers/mobile-money.provider.js';
|
|
7
|
+
export type {
|
|
8
|
+
Payment,
|
|
9
|
+
PaymentIntent,
|
|
10
|
+
PaymentProvider,
|
|
11
|
+
PaymentStatus,
|
|
12
|
+
PaymentMethod,
|
|
13
|
+
CreatePaymentData,
|
|
14
|
+
Subscription,
|
|
15
|
+
Plan,
|
|
16
|
+
StripeConfig,
|
|
17
|
+
PayPalConfig,
|
|
18
|
+
MobileMoneyConfig,
|
|
19
|
+
} from './types.js';
|