@guren/server 1.0.0-rc.13 → 1.0.0-rc.15
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/dist/{Application-DtWDHXr1.d.ts → Application-CddorcPa.d.ts} +41 -3
- package/dist/{ConsoleKernel-CqCVrdZs.d.ts → ConsoleKernel-BlCJEZTR.d.ts} +1 -1
- package/dist/{Gate-CNkBYf8m.d.ts → Gate-CynjZCtS.d.ts} +5 -0
- package/dist/api-token-BGOsfuI9.d.ts +598 -0
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.js +10 -5166
- package/dist/authorization/index.d.ts +2 -2
- package/dist/authorization/index.js +20 -4
- package/dist/index.d.ts +22 -13
- package/dist/index.js +11564 -16605
- package/dist/lambda/index.d.ts +6 -5
- package/dist/mail/index.d.ts +1 -0
- package/dist/mail/index.js +4 -0
- package/dist/mcp/index.d.ts +4 -3
- package/dist/notifications/index.d.ts +5 -4
- package/dist/queue/index.d.ts +5 -4
- package/dist/runtime/index.d.ts +5 -4
- package/dist/runtime/index.js +32 -6
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +8 -2
- package/package.json +6 -5
- package/dist/api-token-JOif2CtG.d.ts +0 -1792
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as Policy$1, A as AuthUser, a as AuthorizationResponse, G as Gate, b as AuthorizeOptions } from '../Gate-
|
|
2
|
-
export { c as GateCallback, d as GateDefinition, e as GateOptions, P as PolicyClass, g as PolicyMethod, h as PolicyRegistration, i as ResourceAction, R as Response, j as ResponseBuilder, k as authorize, l as can, m as cannot, n as createGate, o as defineGate, p as getGate, s as setGate } from '../Gate-
|
|
1
|
+
import { f as Policy$1, A as AuthUser, a as AuthorizationResponse, G as Gate, b as AuthorizeOptions } from '../Gate-CynjZCtS.js';
|
|
2
|
+
export { c as GateCallback, d as GateDefinition, e as GateOptions, P as PolicyClass, g as PolicyMethod, h as PolicyRegistration, i as ResourceAction, R as Response, j as ResponseBuilder, k as authorize, l as can, m as cannot, n as createGate, o as defineGate, p as getGate, s as setGate } from '../Gate-CynjZCtS.js';
|
|
3
3
|
import { Context } from 'hono';
|
|
4
4
|
import { M as Middleware } from '../index-9_Jzj5jo.js';
|
|
5
5
|
|
|
@@ -364,13 +364,29 @@ var Gate = class {
|
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
366
366
|
* Check a policy for the given ability.
|
|
367
|
+
*
|
|
368
|
+
* The subject may be a class instance (policy resolved via its constructor)
|
|
369
|
+
* or a `[ModelClass, record]` / `['key', record]` tuple. The tuple form is
|
|
370
|
+
* required for plain records returned by the ORM, which carry no constructor
|
|
371
|
+
* information.
|
|
367
372
|
*/
|
|
368
373
|
async checkPolicy(ability, user, model, additionalArgs) {
|
|
369
|
-
|
|
370
|
-
|
|
374
|
+
let policyKey;
|
|
375
|
+
let subject = model;
|
|
376
|
+
let hasSubject = true;
|
|
377
|
+
if (Array.isArray(model) && model.length === 2 && (typeof model[0] === "function" || typeof model[0] === "string")) {
|
|
378
|
+
policyKey = model[0];
|
|
379
|
+
subject = model[1];
|
|
380
|
+
} else if (typeof model === "function") {
|
|
381
|
+
policyKey = model;
|
|
382
|
+
hasSubject = false;
|
|
383
|
+
} else {
|
|
384
|
+
policyKey = model?.constructor;
|
|
385
|
+
}
|
|
386
|
+
if (!policyKey) {
|
|
371
387
|
return void 0;
|
|
372
388
|
}
|
|
373
|
-
const policyClass = this.policies.get(
|
|
389
|
+
const policyClass = this.policies.get(policyKey);
|
|
374
390
|
if (!policyClass) {
|
|
375
391
|
return void 0;
|
|
376
392
|
}
|
|
@@ -383,7 +399,7 @@ var Gate = class {
|
|
|
383
399
|
}
|
|
384
400
|
const method = policy[ability];
|
|
385
401
|
if (typeof method === "function") {
|
|
386
|
-
return method.call(policy, user,
|
|
402
|
+
return hasSubject ? method.call(policy, user, subject, ...additionalArgs) : method.call(policy, user, ...additionalArgs);
|
|
387
403
|
}
|
|
388
404
|
return void 0;
|
|
389
405
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { E as ErrorResponse, S as ServiceProvider, C as Container, c as ServiceBindings, Q as QueueManager, N as NotificationManager } from './Application-
|
|
2
|
-
export { A as Application, d as ApplicationListenOptions, e as AuthPayload, f as CSRF_FORM_FIELD, g as CSRF_HEADER_NAME, h as CSRF_TOKEN_KEY, P as ContainerProvider, i as ContextualBinding, j as ContextualBindingBuilder, k as ContextualNeedsBuilder, m as Controller, n as ControllerInertiaProps, o as CsrfOptions, p as DatabaseChannelOptions, q as DatabaseNotification, r as ExceptionClass, t as ExceptionHandler, u as ExceptionHandlerOptions, v as ExceptionRenderer, w as ExceptionReporter, F as FailedJob, H as HostAuthorizationOptions, x as HstsOptions, I as InertiaOptions, y as InertiaPagePayload, z as InertiaResponse, B as InertiaSharedProps, J as InertiaSsrContext, K as InertiaSsrOptions, L as InertiaSsrRenderer, M as InertiaSsrResult, O as InferInertiaProps, R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, X as Notifiable, Y as Notification, Z as NotificationAttachment, _ as NotificationChannel, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, a2 as NotificationManagerOptions, a3 as ProviderManager, a4 as QueueConfig, a5 as QueueDriver, a6 as QueueDriverFactory, a7 as QueuedJob, a8 as RendererRegistration, a9 as ResolvedSharedInertiaProps, aa as ResourceRouteOptions, ab as RouteBuilder, ac as RouteContractOptions, ad as RouteDefinition, ae as RouteOpenApiMetadata, af as RouteResourceAction, ag as Router, ah as SecurityHeadersOptions, ai as SentNotification, aj as ServiceBinding, ak as ServiceClass, al as ServiceFactory, am as ServiceProviderClass, an as ServiceProviderConstructor, ao as ServiceProviderOptions, ap as SharedInertiaPropsResolver, aq as SlackAttachment, ar as SlackBlock, as as SlackMessage, at as VALIDATED_DATA_KEY, au as ValidateRequestOptions, av as ValidationSchema, aw as WorkerOptions, ax as abort, ay as abortIf, az as abortUnless, aA as clearJobRegistry, aB as createApp, aC as createContainer, aD as createCsrfMiddleware, aE as createExceptionHandler, aF as createHostAuthorizationMiddleware, aG as createNotificationManager, aH as createQueueManager, aI as createSecurityHeaders, aJ as csrfField, aK as formatValidationErrors, aL as getContainer, aM as getCsrfToken, aN as getExceptionHandler, aO as getJob, aP as getNotificationManager, aQ as getQueueDriver, aR as getRegisteredJobs, aS as getValidatedData, aT as inertia, aU as parseRequestPayload, aV as registerJob, aW as resolve, aX as setContainer, aY as setExceptionHandler, aZ as setInertiaSharedProps, a_ as setNotificationManager, a$ as setQueueDriver, b0 as validate, b1 as validateRequest, b2 as validateRequestWith, b3 as validateSafe, b4 as verifyCsrfToken } from './Application-
|
|
1
|
+
import { E as ErrorResponse, S as ServiceProvider, C as Container, c as ServiceBindings, Q as QueueManager, N as NotificationManager } from './Application-CddorcPa.js';
|
|
2
|
+
export { A as Application, d as ApplicationListenOptions, e as AuthPayload, f as CSRF_FORM_FIELD, g as CSRF_HEADER_NAME, h as CSRF_TOKEN_KEY, P as ContainerProvider, i as ContextualBinding, j as ContextualBindingBuilder, k as ContextualNeedsBuilder, m as Controller, n as ControllerInertiaProps, o as CsrfOptions, p as DatabaseChannelOptions, q as DatabaseNotification, r as ExceptionClass, t as ExceptionHandler, u as ExceptionHandlerOptions, v as ExceptionRenderer, w as ExceptionReporter, F as FailedJob, H as HostAuthorizationOptions, x as HstsOptions, I as InertiaOptions, y as InertiaPagePayload, z as InertiaResponse, B as InertiaSharedProps, J as InertiaSsrContext, K as InertiaSsrOptions, L as InertiaSsrRenderer, M as InertiaSsrResult, O as InferInertiaProps, R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, X as Notifiable, Y as Notification, Z as NotificationAttachment, _ as NotificationChannel, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, a2 as NotificationManagerOptions, a3 as ProviderManager, a4 as QueueConfig, a5 as QueueDriver, a6 as QueueDriverFactory, a7 as QueuedJob, a8 as RendererRegistration, a9 as ResolvedSharedInertiaProps, aa as ResourceRouteOptions, ab as RouteBuilder, ac as RouteContractOptions, ad as RouteDefinition, ae as RouteOpenApiMetadata, af as RouteResourceAction, ag as Router, ah as SecurityHeadersOptions, ai as SentNotification, aj as ServiceBinding, ak as ServiceClass, al as ServiceFactory, am as ServiceProviderClass, an as ServiceProviderConstructor, ao as ServiceProviderOptions, ap as SharedInertiaPropsResolver, aq as SlackAttachment, ar as SlackBlock, as as SlackMessage, at as VALIDATED_DATA_KEY, au as ValidateRequestOptions, av as ValidationSchema, aw as WorkerOptions, ax as abort, ay as abortIf, az as abortUnless, aA as clearJobRegistry, aB as createApp, aC as createContainer, aD as createCsrfMiddleware, aE as createExceptionHandler, aF as createHostAuthorizationMiddleware, aG as createNotificationManager, aH as createQueueManager, aI as createSecurityHeaders, aJ as csrfField, aK as formatValidationErrors, aL as getContainer, aM as getCsrfToken, aN as getExceptionHandler, aO as getJob, aP as getNotificationManager, aQ as getQueueDriver, aR as getRegisteredJobs, aS as getValidatedData, aT as inertia, aU as parseRequestPayload, aV as registerJob, aW as resolve, aX as setContainer, aY as setExceptionHandler, aZ as setInertiaSharedProps, a_ as setNotificationManager, a$ as setQueueDriver, b0 as validate, b1 as validateRequest, b2 as validateRequestWith, b3 as validateSafe, b4 as verifyCsrfToken } from './Application-CddorcPa.js';
|
|
3
3
|
import * as hono from 'hono';
|
|
4
4
|
import { Context, MiddlewareHandler } from 'hono';
|
|
5
5
|
export { Context } from 'hono';
|
|
6
|
-
import { a as AuthContext } from './api-token-
|
|
7
|
-
export { c as API_TOKEN_KEY, b as ApiToken, d as ApiTokenStore, e as AuthCredentials, A as AuthManager, f as AuthManagerOptions, g as Authenticatable, B as BaseUserProvider, h as BearerTokenMiddlewareOptions, i as CreateApiTokenOptions, j as CreateApiTokenResult, G as Guard, k as GuardContext, l as GuardFactory, M as MemoryApiTokenStore, m as MemoryOAuthStateStore, n as MemorySessionStore, o as ModelUserProvider, p as OAuthAuthorizeOptions, q as OAuthCallbackPayload, O as OAuthManager, r as OAuthManagerOptions, s as OAuthProviderConfig, t as OAuthProviderFactoryInput, u as OAuthStateConfig, v as OAuthStatePayload, w as OAuthStateStore, x as OAuthTokenResult, y as OAuthUserProfile, P as ProviderFactory, S as Session, z as SessionData, D as SessionStore, U as UserProvider, E as buildOAuthAuthorizeUrl, F as buildOAuthRedirectUrl, H as createApiToken, I as createBearerTokenMiddleware, J as createDiscordOAuthProviderConfig, K as createGitHubOAuthProviderConfig, L as createGoogleOAuthProviderConfig, N as createOAuthManager, Q as createOAuthState, R as createSessionMiddleware, T as exchangeOAuthCode, V as fetchOAuthUserProfile, W as getApiToken, X as getApiTokenOrFail, Y as getSessionFromContext, Z as getUserApiTokens, _ as parseApiToken, $ as parseOAuthRedirectUrl, a0 as revokeAllApiTokens, a1 as revokeApiToken, a2 as tokenCan, a3 as tokenCanAll, a4 as tokenCanAny, a5 as verifyApiToken, a6 as verifyOAuthState } from './api-token-
|
|
6
|
+
import { a as AuthContext } from './api-token-BGOsfuI9.js';
|
|
7
|
+
export { c as API_TOKEN_KEY, b as ApiToken, d as ApiTokenStore, e as AuthCredentials, A as AuthManager, f as AuthManagerOptions, g as Authenticatable, B as BaseUserProvider, h as BearerTokenMiddlewareOptions, i as CreateApiTokenOptions, j as CreateApiTokenResult, G as Guard, k as GuardContext, l as GuardFactory, M as MemoryApiTokenStore, m as MemoryOAuthStateStore, n as MemorySessionStore, o as ModelUserProvider, p as OAuthAuthorizeOptions, q as OAuthCallbackPayload, O as OAuthManager, r as OAuthManagerOptions, s as OAuthProviderConfig, t as OAuthProviderFactoryInput, u as OAuthStateConfig, v as OAuthStatePayload, w as OAuthStateStore, x as OAuthTokenResult, y as OAuthUserProfile, P as ProviderFactory, S as Session, z as SessionData, D as SessionStore, U as UserProvider, E as buildOAuthAuthorizeUrl, F as buildOAuthRedirectUrl, H as createApiToken, I as createBearerTokenMiddleware, J as createDiscordOAuthProviderConfig, K as createGitHubOAuthProviderConfig, L as createGoogleOAuthProviderConfig, N as createOAuthManager, Q as createOAuthState, R as createSessionMiddleware, T as exchangeOAuthCode, V as fetchOAuthUserProfile, W as getApiToken, X as getApiTokenOrFail, Y as getSessionFromContext, Z as getUserApiTokens, _ as parseApiToken, $ as parseOAuthRedirectUrl, a0 as revokeAllApiTokens, a1 as revokeApiToken, a2 as tokenCan, a3 as tokenCanAll, a4 as tokenCanAny, a5 as verifyApiToken, a6 as verifyOAuthState } from './api-token-BGOsfuI9.js';
|
|
8
8
|
export { AuthenticatableModel, EmailVerificationConfig, EmailVerificationToken, EmailVerificationTokenResult, EmailVerificationTokenStore, ScryptHasher as Hash, MemoryEmailVerificationStore, MemoryPasswordResetStore, NodeHasher, PasswordResetConfig, PasswordResetTokenResult, PasswordResetTokenStore, ScryptHasher, SessionGuard, buildPasswordResetUrl, buildVerificationUrl, completeEmailVerification, completePasswordReset, createEmailVerificationToken, createPasswordResetToken, isEmailVerified, parsePasswordResetUrl, parseVerificationUrl, requireVerifiedEmail, verifyEmailToken, verifyPasswordResetToken } from './auth/index.js';
|
|
9
9
|
export { M as Middleware, d as defineMiddleware, j as jsonResponse } from './index-9_Jzj5jo.js';
|
|
10
10
|
import { E as EventManager } from './EventManager-CmIoLt7r.js';
|
|
@@ -35,15 +35,16 @@ export { DatabaseChannel, MailChannel, MailChannelOptions, MemoryChannel, SlackC
|
|
|
35
35
|
import { B as BroadcastManager } from './BroadcastManager-AkIWUGJo.js';
|
|
36
36
|
export { A as AuthMiddlewareOptions, a as BroadcastDriver, b as BroadcastDriverFactory, c as BroadcastEvent, d as BroadcastManagerOptions, e as BroadcastableEvent, C as Channel, f as ChannelAuthorizer, g as ChannelRegistration, P as PresenceBroadcastDriver, h as PresenceChannel, i as PresenceChannelAuthorizer, j as PresenceMember, k as PrivateChannel, S as SSEClient, l as SSEMiddlewareOptions, W as WebSocketClient, m as createBroadcastManager, n as getBroadcastManager, s as setBroadcastManager } from './BroadcastManager-AkIWUGJo.js';
|
|
37
37
|
export { RedisClient as BroadcastRedisClient, RedisDriverOptions as BroadcastRedisDriverOptions, MemoryDriver as MemoryBroadcastDriver, RedisDriver as RedisBroadcastDriver, createTypedBroadcaster } from './broadcasting/index.js';
|
|
38
|
-
import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-
|
|
39
|
-
export { A as ArgumentDefinition, c as CommandClass, C as ConsoleKernel, d as ConsoleKernelOptions, e as ProgressInterface, f as PromptInterface, S as ScheduledCommand, g as createConsoleKernel } from './ConsoleKernel-
|
|
38
|
+
import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-BlCJEZTR.js';
|
|
39
|
+
export { A as ArgumentDefinition, c as CommandClass, C as ConsoleKernel, d as ConsoleKernelOptions, e as ProgressInterface, f as PromptInterface, S as ScheduledCommand, g as createConsoleKernel } from './ConsoleKernel-BlCJEZTR.js';
|
|
40
40
|
import * as readline from 'readline';
|
|
41
|
-
export { R as AuthResponse, A as AuthUser, a as AuthorizationResponse, b as AuthorizeOptions, G as Gate, c as GateCallback, d as GateDefinition, e as GateOptions, P as PolicyClass, f as PolicyInterface, g as PolicyMethod, h as PolicyRegistration, i as ResourceAction, j as ResponseBuilder, k as authorizeAbility, l as can, m as cannot, n as createGate, o as defineGate, p as getGate, s as setGate } from './Gate-
|
|
41
|
+
export { R as AuthResponse, A as AuthUser, a as AuthorizationResponse, b as AuthorizeOptions, G as Gate, c as GateCallback, d as GateDefinition, e as GateOptions, P as PolicyClass, f as PolicyInterface, g as PolicyMethod, h as PolicyRegistration, i as ResourceAction, j as ResponseBuilder, k as authorizeAbility, l as can, m as cannot, n as createGate, o as defineGate, p as getGate, s as setGate } from './Gate-CynjZCtS.js';
|
|
42
42
|
export { AuthorizedContext, Policy, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, definePolicy, withAuthorization } from './authorization/index.js';
|
|
43
43
|
export { A as AppKeyring, D as DecryptOptions, a as EncryptOptions, b as EncryptedPayload, E as Encrypter, c as EncrypterConfig, H as HashAlgorithm, d as HmacOptions, P as PasswordHashOptions, R as RandomStringOptions, e as createEncrypter, f as decrypt, g as deriveAppKey, h as deriveAppKeyring, i as encrypt, j as generateAppKey, k as generateKey, l as getAppKeyringFromEnv, m as getEncrypter, n as normalizeAppKey, p as parseAppKey, o as parsePreviousAppKeys, s as setEncrypter } from './app-key-CsBfRC_Q.js';
|
|
44
44
|
export { MessageSigner, SignMessageOptions, SignedMessageClaims, SignedUrlOptions, VerifySignedMessageOptions, VerifySignedUrlOptions, check as checkHash, generateOtp, generatePassword, generateSlug, hash, hashPassword, hmac, md5, needsRehash, pick, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, sample, secureCompare, sha256, sha512, shuffle, signUrl, urlSafeToken, uuid, verifyHmac, verifyPassword, verifySignedUrl } from './encryption/index.js';
|
|
45
45
|
import Redis, { RedisOptions } from 'ioredis';
|
|
46
46
|
import 'vite';
|
|
47
|
+
import '@guren/orm';
|
|
47
48
|
|
|
48
49
|
interface RequireAuthOptions {
|
|
49
50
|
redirectTo?: string;
|
|
@@ -160,6 +161,17 @@ interface RateLimitOptions {
|
|
|
160
161
|
* @default 'rl:'
|
|
161
162
|
*/
|
|
162
163
|
keyPrefix?: string;
|
|
164
|
+
/**
|
|
165
|
+
* Trust reverse-proxy headers for client IP resolution, checked in order:
|
|
166
|
+
* `CF-Connecting-IP`, `True-Client-IP`, `X-Real-IP`, then the first entry
|
|
167
|
+
* of `X-Forwarded-For`. Falls back to `server.requestIP()` when none are set.
|
|
168
|
+
*
|
|
169
|
+
* Enable ONLY when every request passes through a proxy that sets or strips
|
|
170
|
+
* these headers — on direct deployments clients can spoof them to bypass
|
|
171
|
+
* per-client limits. Ignored when a custom `keyGenerator` is supplied.
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
174
|
+
trustProxy?: boolean;
|
|
163
175
|
}
|
|
164
176
|
/**
|
|
165
177
|
* Create a rate limiting middleware.
|
|
@@ -732,11 +744,6 @@ declare class MethodNotAllowedException extends HttpException {
|
|
|
732
744
|
static forMethod(method: string, allowedMethods: string[]): MethodNotAllowedException;
|
|
733
745
|
}
|
|
734
746
|
|
|
735
|
-
/**
|
|
736
|
-
* Generate a production-friendly HTML error page.
|
|
737
|
-
* Shows status code, a generic message, and a link back to the home page.
|
|
738
|
-
* No stack traces or internal details are exposed.
|
|
739
|
-
*/
|
|
740
747
|
declare function renderErrorPage(statusCode: number, message?: string): string;
|
|
741
748
|
|
|
742
749
|
type ViewRenderer = (template: string, props: Record<string, unknown>) => Response | Promise<Response>;
|
|
@@ -868,7 +875,9 @@ declare class SchedulingServiceProvider extends ServiceProvider {
|
|
|
868
875
|
}
|
|
869
876
|
|
|
870
877
|
/**
|
|
871
|
-
* Binds the Gate as a singleton in the container
|
|
878
|
+
* Binds the Gate as a singleton in the container and exposes it as the
|
|
879
|
+
* global gate so `getGate()`, `can()`, and controller authorization helpers
|
|
880
|
+
* work without manual wiring.
|
|
872
881
|
*/
|
|
873
882
|
declare class AuthorizationServiceProvider extends ServiceProvider {
|
|
874
883
|
register(): void;
|