@foldspace-fe/casdoor-next-auth-kit 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.
Files changed (40) hide show
  1. package/dist/billing/index.d.ts +16 -0
  2. package/dist/billing/index.js +28 -0
  3. package/dist/billing/index.js.map +1 -0
  4. package/dist/callback-BTzHQK_r.d.ts +12 -0
  5. package/dist/casdoor/index.d.ts +28 -0
  6. package/dist/casdoor/index.js +40 -0
  7. package/dist/casdoor/index.js.map +1 -0
  8. package/dist/chunk-6E27SZ7V.js +291 -0
  9. package/dist/chunk-6E27SZ7V.js.map +1 -0
  10. package/dist/chunk-DONQHN4U.js +56 -0
  11. package/dist/chunk-DONQHN4U.js.map +1 -0
  12. package/dist/chunk-IQEVUR77.js +909 -0
  13. package/dist/chunk-IQEVUR77.js.map +1 -0
  14. package/dist/chunk-RGTVPBH7.js +182 -0
  15. package/dist/chunk-RGTVPBH7.js.map +1 -0
  16. package/dist/chunk-T2M5MVPE.js +20 -0
  17. package/dist/chunk-T2M5MVPE.js.map +1 -0
  18. package/dist/chunk-XMBHIEYL.js +1 -0
  19. package/dist/chunk-XMBHIEYL.js.map +1 -0
  20. package/dist/chunk-Y4GJ2AEI.js +192 -0
  21. package/dist/chunk-Y4GJ2AEI.js.map +1 -0
  22. package/dist/cli.d.ts +2 -0
  23. package/dist/cli.js +437 -0
  24. package/dist/cli.js.map +1 -0
  25. package/dist/index.d.ts +77 -0
  26. package/dist/index.js +148 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/next/index.d.ts +17 -0
  29. package/dist/next/index.js +24 -0
  30. package/dist/next/index.js.map +1 -0
  31. package/dist/options-JUwZSXu2.d.ts +40 -0
  32. package/dist/react/index.d.ts +242 -0
  33. package/dist/react/index.js +774 -0
  34. package/dist/react/index.js.map +1 -0
  35. package/dist/skills/casdoor-next-auth-kit/SKILL.md +158 -0
  36. package/dist/skills/casdoor-next-auth-kit/references/casdoor-api-reference.md +2387 -0
  37. package/dist/skills/casdoor-next-auth-kit/references/swagger.json +3686 -0
  38. package/dist/types-BPsPs5Rv.d.ts +337 -0
  39. package/dist/types-DqVXdUge.d.ts +121 -0
  40. package/package.json +69 -0
@@ -0,0 +1,337 @@
1
+ type BillingItemKind = 'subscription' | 'product' | 'credits';
2
+ type BillingInterval = 'month' | 'year';
3
+ interface BillingConversionRule {
4
+ productKey: string;
5
+ kind: 'grant-credits' | 'redeem-credits';
6
+ creditsPerUnit: number;
7
+ minQuantity?: number;
8
+ maxQuantity?: number;
9
+ }
10
+ interface BillingDefaults {
11
+ defaultReturnTo?: string;
12
+ defaultQuantity?: number;
13
+ defaultInterval?: BillingInterval;
14
+ }
15
+ interface BillingItem {
16
+ key: string;
17
+ kind: BillingItemKind;
18
+ title: string;
19
+ description?: string;
20
+ featured?: boolean;
21
+ badge?: string;
22
+ priceLabel?: string;
23
+ priceValue?: number;
24
+ interval?: BillingInterval;
25
+ credits?: number;
26
+ features?: string[];
27
+ backendRef: {
28
+ productId: string;
29
+ planId?: string;
30
+ priceId?: string;
31
+ };
32
+ creditGrant?: {
33
+ creditsPerUnit: number;
34
+ unitName?: string;
35
+ };
36
+ creditRedeem?: {
37
+ productKey: string;
38
+ creditsPerUnit: number;
39
+ };
40
+ metadata?: Record<string, string>;
41
+ }
42
+ interface BillingRuntimeConfig {
43
+ catalogKey: string;
44
+ items: BillingItem[];
45
+ conversionRules?: BillingConversionRule[];
46
+ defaults?: BillingDefaults;
47
+ }
48
+ interface BillingCatalogConfig extends BillingRuntimeConfig {
49
+ title?: string;
50
+ description?: string;
51
+ portalPath?: string;
52
+ successPath?: string;
53
+ cancelPath?: string;
54
+ }
55
+ type BillingActionKind = 'purchase' | 'subscribe' | 'manage' | 'upgrade' | 'cancel';
56
+ interface BillingSubscriptionPurchaseConfig {
57
+ productKey: string;
58
+ productId: string;
59
+ planId?: string;
60
+ priceId?: string;
61
+ interval?: BillingInterval;
62
+ quantity?: number;
63
+ metadata?: Record<string, string>;
64
+ }
65
+ interface BillingProductPurchaseConfig {
66
+ productKey: string;
67
+ productId: string;
68
+ priceId?: string;
69
+ quantity?: number;
70
+ creditGrant?: BillingItem['creditGrant'];
71
+ creditRedeem?: BillingItem['creditRedeem'];
72
+ metadata?: Record<string, string>;
73
+ }
74
+ interface BillingActionPayload {
75
+ key: string;
76
+ kind: BillingActionKind;
77
+ productId?: string;
78
+ planId?: string;
79
+ priceId?: string;
80
+ quantity?: number;
81
+ interval?: BillingInterval;
82
+ subscriptionConfig?: BillingSubscriptionPurchaseConfig;
83
+ productConfig?: BillingProductPurchaseConfig;
84
+ returnTo?: string;
85
+ metadata?: Record<string, string>;
86
+ }
87
+ interface BillingProductSnapshot {
88
+ productKey: string;
89
+ productId?: string;
90
+ title?: string;
91
+ kind: BillingItemKind;
92
+ planId?: string;
93
+ priceId?: string;
94
+ interval?: BillingInterval;
95
+ metadata?: Record<string, string>;
96
+ }
97
+ interface BillingSubscriptionState {
98
+ subscriptionId?: string;
99
+ planKey?: string;
100
+ planName?: string;
101
+ product?: BillingProductSnapshot;
102
+ status?: 'active' | 'trialing' | 'past_due' | 'canceled' | 'inactive';
103
+ interval?: BillingInterval;
104
+ renewAt?: string;
105
+ cancelAt?: string;
106
+ currentPeriodStart?: string;
107
+ currentPeriodEnd?: string;
108
+ autoRenew?: boolean;
109
+ }
110
+ interface BillingCreditsState {
111
+ balance: number;
112
+ used?: number;
113
+ reserved?: number;
114
+ unit?: string;
115
+ updatedAt?: string;
116
+ }
117
+ interface BillingProductState {
118
+ productKey: string;
119
+ productId?: string;
120
+ title?: string;
121
+ kind: 'product' | 'credits';
122
+ status?: 'active' | 'inactive' | 'archived';
123
+ quantity?: number;
124
+ owned?: boolean;
125
+ creditsBalance?: number;
126
+ updatedAt?: string;
127
+ }
128
+ interface BillingOrderHistoryItem {
129
+ orderId: string;
130
+ productKey?: string;
131
+ productId?: string;
132
+ productTitle?: string;
133
+ kind?: 'subscription' | 'product' | 'credits';
134
+ quantity?: number;
135
+ amount?: number;
136
+ currency?: string;
137
+ status?: 'pending' | 'paid' | 'failed' | 'canceled' | 'refunded';
138
+ paymentId?: string;
139
+ transactionId?: string;
140
+ createdAt?: string;
141
+ updatedAt?: string;
142
+ }
143
+ interface BillingPaymentHistoryItem {
144
+ paymentId: string;
145
+ orderId?: string;
146
+ productKey?: string;
147
+ amount?: number;
148
+ currency?: string;
149
+ status?: 'pending' | 'paid' | 'failed' | 'canceled' | 'refunded';
150
+ transactionId?: string;
151
+ createdAt?: string;
152
+ updatedAt?: string;
153
+ }
154
+ interface BillingSubscriptionHistoryItem {
155
+ subscriptionId: string;
156
+ product?: BillingProductSnapshot;
157
+ planKey?: string;
158
+ planName?: string;
159
+ status?: 'active' | 'trialing' | 'past_due' | 'canceled' | 'inactive';
160
+ interval?: BillingInterval;
161
+ orderId?: string;
162
+ paymentId?: string;
163
+ startedAt?: string;
164
+ endedAt?: string;
165
+ updatedAt?: string;
166
+ }
167
+ interface BillingEntitlementState {
168
+ features?: string[];
169
+ limits?: Record<string, number>;
170
+ flags?: Record<string, boolean>;
171
+ }
172
+ interface BillingStatusState {
173
+ loading: boolean;
174
+ refreshing: boolean;
175
+ error: string | null;
176
+ lastFetchedAt?: string;
177
+ }
178
+ interface BillingPurchaseStatus {
179
+ actionKey?: string;
180
+ orderId?: string;
181
+ paymentId?: string;
182
+ transactionId?: string;
183
+ status: 'idle' | 'pending' | 'requires_payment' | 'paid' | 'failed' | 'canceled' | 'refunded';
184
+ orderStatus?: string;
185
+ paymentStatus?: string;
186
+ transactionStatus?: string;
187
+ redirectTo?: string;
188
+ updatedAt?: string;
189
+ }
190
+ interface BillingApiClient {
191
+ fetchRuntimeConfig: (catalogKey: string) => Promise<BillingRuntimeConfig | BillingCatalogConfig>;
192
+ fetchSubscription: (args: {
193
+ userId?: string;
194
+ catalogKey?: string;
195
+ }) => Promise<BillingSubscriptionState>;
196
+ fetchSubscriptionHistory: (args: {
197
+ userId?: string;
198
+ catalogKey?: string;
199
+ }) => Promise<BillingSubscriptionHistoryItem[]>;
200
+ fetchProducts: (args: {
201
+ userId?: string;
202
+ catalogKey?: string;
203
+ }) => Promise<BillingProductState[]>;
204
+ fetchOrderHistory: (args: {
205
+ userId?: string;
206
+ catalogKey?: string;
207
+ productKey?: string;
208
+ }) => Promise<BillingOrderHistoryItem[]>;
209
+ fetchPaymentHistory: (args: {
210
+ userId?: string;
211
+ catalogKey?: string;
212
+ }) => Promise<BillingPaymentHistoryItem[]>;
213
+ fetchPurchaseStatus: (args: {
214
+ orderId?: string;
215
+ paymentId?: string;
216
+ transactionId?: string;
217
+ }) => Promise<BillingPurchaseStatus>;
218
+ fetchCredits: (args: {
219
+ userId?: string;
220
+ catalogKey?: string;
221
+ }) => Promise<BillingCreditsState>;
222
+ fetchEntitlements: (args: {
223
+ userId?: string;
224
+ catalogKey?: string;
225
+ }) => Promise<BillingEntitlementState>;
226
+ createAction: (payload: BillingActionPayload) => Promise<{
227
+ redirectTo?: string;
228
+ nextAction?: string;
229
+ status?: 'pending' | 'succeeded' | 'failed';
230
+ }>;
231
+ refresh: (args: {
232
+ userId?: string;
233
+ catalogKey?: string;
234
+ }) => Promise<void>;
235
+ }
236
+ interface BillingLoaders {
237
+ runtimeConfigLoader?: (catalogKey: string) => Promise<BillingRuntimeConfig | BillingCatalogConfig>;
238
+ subscriptionLoader?: (args: {
239
+ userId?: string;
240
+ catalogKey?: string;
241
+ }) => Promise<BillingSubscriptionState>;
242
+ subscriptionHistoryLoader?: (args: {
243
+ userId?: string;
244
+ catalogKey?: string;
245
+ }) => Promise<BillingSubscriptionHistoryItem[]>;
246
+ productsLoader?: (args: {
247
+ userId?: string;
248
+ catalogKey?: string;
249
+ }) => Promise<BillingProductState[]>;
250
+ orderHistoryLoader?: (args: {
251
+ userId?: string;
252
+ catalogKey?: string;
253
+ productKey?: string;
254
+ }) => Promise<BillingOrderHistoryItem[]>;
255
+ paymentHistoryLoader?: (args: {
256
+ userId?: string;
257
+ catalogKey?: string;
258
+ }) => Promise<BillingPaymentHistoryItem[]>;
259
+ purchaseStatusLoader?: (args: {
260
+ orderId?: string;
261
+ paymentId?: string;
262
+ transactionId?: string;
263
+ }) => Promise<BillingPurchaseStatus>;
264
+ creditsLoader?: (args: {
265
+ userId?: string;
266
+ catalogKey?: string;
267
+ }) => Promise<BillingCreditsState>;
268
+ entitlementsLoader?: (args: {
269
+ userId?: string;
270
+ catalogKey?: string;
271
+ }) => Promise<BillingEntitlementState>;
272
+ }
273
+ interface BillingActionExecutor {
274
+ (payload: BillingActionPayload): Promise<{
275
+ redirectTo?: string;
276
+ nextAction?: string;
277
+ status?: 'pending' | 'succeeded' | 'failed';
278
+ }>;
279
+ }
280
+ interface BillingSubscriptionContextValue {
281
+ availablePlans?: BillingItem[];
282
+ subscription?: BillingSubscriptionState;
283
+ subscriptionHistory?: BillingSubscriptionHistoryItem[];
284
+ entitlements?: BillingEntitlementState;
285
+ status?: BillingStatusState;
286
+ }
287
+ interface BillingProductContextValue {
288
+ availableProducts?: BillingItem[];
289
+ products?: BillingProductState[];
290
+ orderHistory?: BillingOrderHistoryItem[];
291
+ paymentHistory?: BillingPaymentHistoryItem[];
292
+ status?: BillingStatusState;
293
+ }
294
+ interface BillingCreditsContextValue {
295
+ credits?: BillingCreditsState;
296
+ status?: BillingStatusState;
297
+ }
298
+ interface BillingCoreContextValue {
299
+ apiClient: BillingApiClient;
300
+ runtimeConfigLoader?: BillingLoaders['runtimeConfigLoader'];
301
+ loaders?: BillingLoaders;
302
+ actionExecutor?: BillingActionExecutor;
303
+ defaults?: BillingDefaults;
304
+ runtimeConfig?: BillingRuntimeConfig;
305
+ runtimeCatalog?: BillingCatalogConfig;
306
+ runtimeConfigLoading: boolean;
307
+ runtimeConfigError: string | null;
308
+ subscription?: BillingSubscriptionState;
309
+ subscriptionHistory?: BillingSubscriptionHistoryItem[];
310
+ products?: BillingProductState[];
311
+ orderHistory?: BillingOrderHistoryItem[];
312
+ paymentHistory?: BillingPaymentHistoryItem[];
313
+ availablePlans?: BillingItem[];
314
+ availableProducts?: BillingItem[];
315
+ credits?: BillingCreditsState;
316
+ entitlements?: BillingEntitlementState;
317
+ purchaseStatus?: BillingPurchaseStatus;
318
+ status: BillingStatusState;
319
+ refresh: () => Promise<void>;
320
+ runAction: (payload: BillingActionPayload) => Promise<{
321
+ redirectTo?: string;
322
+ nextAction?: string;
323
+ status?: 'pending' | 'succeeded' | 'failed';
324
+ }>;
325
+ setRuntimeConfig: (config?: BillingRuntimeConfig) => void;
326
+ setSubscription: (value?: BillingSubscriptionState) => void;
327
+ setSubscriptionHistory: (value?: BillingSubscriptionHistoryItem[]) => void;
328
+ setProducts: (value?: BillingProductState[]) => void;
329
+ setOrderHistory: (value?: BillingOrderHistoryItem[]) => void;
330
+ setPaymentHistory: (value?: BillingPaymentHistoryItem[]) => void;
331
+ setCredits: (value?: BillingCreditsState) => void;
332
+ setEntitlements: (value?: BillingEntitlementState) => void;
333
+ setPurchaseStatus: (status?: BillingPurchaseStatus) => void;
334
+ setStatus: (status: BillingStatusState | ((current: BillingStatusState) => BillingStatusState)) => void;
335
+ }
336
+
337
+ export type { BillingSubscriptionPurchaseConfig as A, BillingActionPayload as B, BillingItem as a, BillingRuntimeConfig as b, BillingCatalogConfig as c, BillingApiClient as d, BillingLoaders as e, BillingActionExecutor as f, BillingDefaults as g, BillingSubscriptionState as h, BillingSubscriptionHistoryItem as i, BillingProductState as j, BillingOrderHistoryItem as k, BillingPaymentHistoryItem as l, BillingCreditsState as m, BillingEntitlementState as n, BillingStatusState as o, BillingPurchaseStatus as p, BillingProductSnapshot as q, BillingCoreContextValue as r, BillingActionKind as s, BillingConversionRule as t, BillingCreditsContextValue as u, BillingInterval as v, BillingItemKind as w, BillingProductContextValue as x, BillingProductPurchaseConfig as y, BillingSubscriptionContextValue as z };
@@ -0,0 +1,121 @@
1
+ interface CasdoorUserInfo {
2
+ id?: string;
3
+ sub?: string;
4
+ name?: string | null;
5
+ displayName?: string | null;
6
+ email?: string | null;
7
+ picture?: string | null;
8
+ avatarUrl?: string | null;
9
+ isAdmin?: boolean;
10
+ [key: string]: unknown;
11
+ }
12
+ interface OAuthTokens {
13
+ accessToken?: string;
14
+ refreshToken?: string;
15
+ idToken?: string;
16
+ expiresAt?: number;
17
+ access_token?: string;
18
+ refresh_token?: string;
19
+ id_token?: string;
20
+ expires_in?: number;
21
+ token_type?: string;
22
+ [key: string]: unknown;
23
+ }
24
+ interface AuthUser {
25
+ id: string;
26
+ name: string | null;
27
+ email: string | null;
28
+ image: string | null;
29
+ isAdmin: boolean;
30
+ tokenBalance: number;
31
+ isVip: boolean;
32
+ }
33
+ interface AuthDatabaseFieldRequirement {
34
+ name: string;
35
+ type: string;
36
+ required?: boolean;
37
+ notes?: string;
38
+ }
39
+ interface AuthDatabaseTableRequirement {
40
+ name: string;
41
+ purpose: string;
42
+ fields: AuthDatabaseFieldRequirement[];
43
+ uniqueKeys?: string[];
44
+ indexes?: string[];
45
+ }
46
+ interface AuthDatabaseContract {
47
+ tables: AuthDatabaseTableRequirement[];
48
+ notes?: string[];
49
+ }
50
+ interface AuthPersistenceAdapter {
51
+ syncAuthUser: (user: AuthUser) => Promise<void>;
52
+ findAuthUser?: (query: {
53
+ id?: string;
54
+ email?: string | null;
55
+ }) => Promise<AuthUser | null>;
56
+ syncCommerceRecord?: (kind: 'order' | 'subscription' | 'invoice', payload: Record<string, unknown>) => Promise<void>;
57
+ }
58
+ interface AuthKitConfig {
59
+ appUrl?: string;
60
+ nextauthSecret: string;
61
+ casdoor: {
62
+ serverUrl: string;
63
+ clientId: string;
64
+ clientSecret: string;
65
+ appName: string;
66
+ organizationName: string;
67
+ redirectPath?: string;
68
+ signinPath?: string;
69
+ };
70
+ cookie?: {
71
+ secure?: 'auto' | boolean;
72
+ };
73
+ session?: {
74
+ maxAgeSeconds?: number;
75
+ };
76
+ }
77
+ interface AuthBusinessAdapter {
78
+ onUserSync?: (profile: CasdoorUserInfo, tokens: OAuthTokens) => Promise<AuthUser>;
79
+ resolvePostLoginRedirect?: (user: AuthUser) => string;
80
+ isAdminEmail?: (email: string | null) => boolean;
81
+ resolveCommerceRedirect?: (action: 'purchase' | 'subscribe' | 'manage', payload: Record<string, unknown>) => string;
82
+ enrichCommercePayload?: (payload: Record<string, unknown>) => Record<string, unknown>;
83
+ }
84
+ interface AuthRuntimeContext {
85
+ config: AuthKitConfig;
86
+ adapter?: AuthBusinessAdapter;
87
+ database?: AuthDatabaseContract;
88
+ persistence?: AuthPersistenceAdapter;
89
+ }
90
+ interface AuthIndexHtmlOptions {
91
+ appName?: string;
92
+ organizationName?: string;
93
+ description?: string;
94
+ staticOrigin?: string;
95
+ casdoorOrigin?: string;
96
+ apiProxyPrefix?: string;
97
+ iconHref?: string;
98
+ manifestHref?: string;
99
+ }
100
+ type ManagedEnvFile = '.env' | '.env.local' | '.env.production' | '.env.example';
101
+ interface ManagedEnvVariableDefinition {
102
+ key: string;
103
+ description: string;
104
+ example: string;
105
+ local?: string;
106
+ production?: string;
107
+ base?: string;
108
+ }
109
+ interface PrismaSchemaFieldDefinition {
110
+ name: string;
111
+ type: string;
112
+ attributes?: string[];
113
+ }
114
+ interface PrismaSchemaModelDefinition {
115
+ name: string;
116
+ description: string;
117
+ fields: PrismaSchemaFieldDefinition[];
118
+ blockAttributes?: string[];
119
+ }
120
+
121
+ export type { AuthKitConfig as A, CasdoorUserInfo as C, ManagedEnvFile as M, OAuthTokens as O, PrismaSchemaModelDefinition as P, AuthBusinessAdapter as a, AuthPersistenceAdapter as b, AuthUser as c, ManagedEnvVariableDefinition as d, AuthIndexHtmlOptions as e, AuthDatabaseContract as f, AuthDatabaseFieldRequirement as g, AuthDatabaseTableRequirement as h, AuthRuntimeContext as i, PrismaSchemaFieldDefinition as j };
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@foldspace-fe/casdoor-next-auth-kit",
3
+ "version": "0.1.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/foldspace-stack/casdoor-next-auth-kit"
9
+ },
10
+ "homepage": "https://github.com/foldspace-stack/casdoor-next-auth-kit#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/foldspace-stack/casdoor-next-auth-kit/issues"
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.js"
20
+ },
21
+ "./casdoor": {
22
+ "types": "./dist/casdoor/index.d.ts",
23
+ "default": "./dist/casdoor/index.js"
24
+ },
25
+ "./next": {
26
+ "types": "./dist/next/index.d.ts",
27
+ "default": "./dist/next/index.js"
28
+ },
29
+ "./billing": {
30
+ "types": "./dist/billing/index.d.ts",
31
+ "default": "./dist/billing/index.js"
32
+ },
33
+ "./react": {
34
+ "types": "./dist/react/index.d.ts",
35
+ "default": "./dist/react/index.js"
36
+ }
37
+ },
38
+ "bin": {
39
+ "casdoor-next-auth-kit": "./dist/cli.js"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "provenance": true
44
+ },
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "scripts": {
49
+ "build": "tsup && node ./scripts/copy-skill.mjs",
50
+ "typecheck": "tsc -p tsconfig.json --noEmit",
51
+ "dev": "tsup --watch"
52
+ },
53
+ "peerDependencies": {
54
+ "next": ">=16",
55
+ "next-auth": "^4.24.0",
56
+ "react": ">=19",
57
+ "react-dom": ">=19"
58
+ },
59
+ "dependencies": {
60
+ "jose": "^6.1.0"
61
+ },
62
+ "devDependencies": {
63
+ "@types/node": "^22.15.0",
64
+ "@types/react": "^19.2.0",
65
+ "@types/react-dom": "^19.2.0",
66
+ "tsup": "^8.5.0",
67
+ "typescript": "^5.6.3"
68
+ }
69
+ }