@aeriajs/security 0.0.231 → 0.0.233

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.
@@ -1,9 +1,9 @@
1
1
  import type { Context, CollectionProps, CollectionReadPayload, CollectionWritePayload } from '@aeriajs/types';
2
2
  import type { ReadMiddlewareReturn, WriteMiddlewareReturn } from '../types.js';
3
- import { Result, ACError } from '@aeriajs/types';
3
+ import { Result } from '@aeriajs/types';
4
4
  export declare const checkImmutabilityRead: <T extends CollectionReadPayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => ReadMiddlewareReturn<CollectionProps<T>>) => Promise<{
5
5
  readonly _tag: "Error";
6
- readonly error: ACError.TargetImmutable | ACError.ResourceNotFound;
6
+ readonly error: "RESOURCE_NOT_FOUND" | "TARGET_IMMUTABLE";
7
7
  readonly result: undefined;
8
- } | Result.Either<ACError.InvalidLimit | ACError.OwnershipError, CollectionProps<T>>>;
9
- export declare const checkImmutabilityWrite: <T extends CollectionWritePayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => WriteMiddlewareReturn<CollectionProps<T>>) => Promise<Result.Either<ACError.TargetImmutable | ACError.OwnershipError | ACError.ResourceNotFound, CollectionProps<T>>>;
8
+ } | Result.Either<"OWNERSHIP_ERROR" | "INVALID_LIMIT", CollectionProps<T>>>;
9
+ export declare const checkImmutabilityWrite: <T extends CollectionWritePayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => WriteMiddlewareReturn<CollectionProps<T>>) => Promise<Result.Either<"RESOURCE_NOT_FOUND" | "OWNERSHIP_ERROR" | "TARGET_IMMUTABLE", CollectionProps<T>>>;
@@ -1,5 +1,5 @@
1
1
  import type { Context, CollectionProps, CollectionReadPayload, CollectionWritePayload } from '@aeriajs/types';
2
2
  import type { ReadMiddlewareReturn, WriteMiddlewareReturn } from '../types.js';
3
- import { Result, ACError } from '@aeriajs/types';
4
- export declare const checkOwnershipRead: <T extends CollectionReadPayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => ReadMiddlewareReturn<CollectionProps<T>>) => Promise<Result.Either<ACError.InvalidLimit | ACError.OwnershipError, CollectionProps<T>>>;
5
- export declare const checkOwnershipWrite: <T extends CollectionWritePayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => WriteMiddlewareReturn<CollectionProps<T>>) => Promise<Result.Either<ACError.TargetImmutable | ACError.OwnershipError | ACError.ResourceNotFound, CollectionProps<T>>>;
3
+ import { Result } from '@aeriajs/types';
4
+ export declare const checkOwnershipRead: <T extends CollectionReadPayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => ReadMiddlewareReturn<CollectionProps<T>>) => Promise<Result.Either<"OWNERSHIP_ERROR" | "INVALID_LIMIT", CollectionProps<T>>>;
5
+ export declare const checkOwnershipWrite: <T extends CollectionWritePayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => WriteMiddlewareReturn<CollectionProps<T>>) => Promise<Result.Either<"RESOURCE_NOT_FOUND" | "OWNERSHIP_ERROR" | "TARGET_IMMUTABLE", CollectionProps<T>>>;
@@ -1,4 +1,4 @@
1
1
  import type { Context, CollectionProps, CollectionReadPayload } from '@aeriajs/types';
2
2
  import type { ReadMiddlewareReturn } from '../types.js';
3
- import { Result, ACError } from '@aeriajs/types';
4
- export declare const checkPagination: <T extends CollectionReadPayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => ReadMiddlewareReturn<CollectionProps<T>>) => Promise<Result.Either<ACError.InvalidLimit | ACError.OwnershipError, CollectionProps<T>>>;
3
+ import { Result } from '@aeriajs/types';
4
+ export declare const checkPagination: <T extends CollectionReadPayload>(props: Result.Result<CollectionProps<T>>, context: Context, next: (payload: typeof props, context: Context) => ReadMiddlewareReturn<CollectionProps<T>>) => Promise<Result.Either<"OWNERSHIP_ERROR" | "INVALID_LIMIT", CollectionProps<T>>>;
@@ -1,14 +1,14 @@
1
1
  import type { RouteContext, RateLimitingParams } from '@aeriajs/types';
2
- import { Result, HTTPStatus, RateLimitingError } from '@aeriajs/types';
2
+ import { Result } from '@aeriajs/types';
3
3
  export declare const getOrCreateUsageEntry: (params: RateLimitingParams, context: RouteContext) => Promise<any>;
4
4
  export declare const limitRate: (params: RateLimitingParams, context: RouteContext) => Promise<Result.Error<{
5
- readonly code: RateLimitingError.Unauthenticated;
5
+ readonly code: "UNAUTHENTICATED";
6
6
  } & {
7
- httpStatus: HTTPStatus.InternalServerError;
7
+ httpStatus: 500;
8
8
  }> | Result.Error<{
9
- readonly code: RateLimitingError.LimitReached;
9
+ readonly code: "LIMIT_REACHED";
10
10
  } & {
11
- httpStatus: HTTPStatus.TooManyRequests;
11
+ httpStatus: 429;
12
12
  }> | {
13
13
  readonly _tag: "Result";
14
14
  readonly error: undefined;
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import type { Result, ACError, CollectionProps } from '@aeriajs/types';
2
- export type ReadMiddlewareReturn<TProps extends CollectionProps<unknown>> = Promise<Result.Either<ACError.OwnershipError | ACError.InvalidLimit, TProps>>;
3
- export type WriteMiddlewareReturn<TProps extends CollectionProps<unknown>> = Promise<Result.Either<ACError.OwnershipError | ACError.ResourceNotFound | ACError.TargetImmutable, TProps>>;
2
+ export type ReadMiddlewareReturn<TProps extends CollectionProps<unknown>> = Promise<Result.Either<typeof ACError.OwnershipError | typeof ACError.InvalidLimit, TProps>>;
3
+ export type WriteMiddlewareReturn<TProps extends CollectionProps<unknown>> = Promise<Result.Either<typeof ACError.OwnershipError | typeof ACError.ResourceNotFound | typeof ACError.TargetImmutable, TProps>>;
package/dist/use.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { Context, Description, CollectionReadPayload, CollectionWritePayloa
2
2
  export declare const useSecurity: <TDescription extends Description>(context: Context<TDescription>) => {
3
3
  secureReadPayload: <TPayload extends Partial<CollectionReadPayload>>(payload: TPayload) => Promise<{
4
4
  readonly _tag: "Error";
5
- readonly error: import("@aeriajs/types").ACError.InvalidLimit | import("@aeriajs/types").ACError.OwnershipError;
5
+ readonly error: "OWNERSHIP_ERROR" | "INVALID_LIMIT";
6
6
  readonly result: undefined;
7
7
  } | {
8
8
  readonly _tag: "Result";
@@ -13,7 +13,7 @@ export declare const useSecurity: <TDescription extends Description>(context: Co
13
13
  }>;
14
14
  secureWritePayload: <TPayload extends CollectionWritePayload>(payload: TPayload) => Promise<{
15
15
  readonly _tag: "Error";
16
- readonly error: import("@aeriajs/types").ACError.TargetImmutable | import("@aeriajs/types").ACError.OwnershipError | import("@aeriajs/types").ACError.ResourceNotFound;
16
+ readonly error: "RESOURCE_NOT_FOUND" | "OWNERSHIP_ERROR" | "TARGET_IMMUTABLE";
17
17
  readonly result: undefined;
18
18
  } | {
19
19
  readonly _tag: "Result";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/security",
3
- "version": "0.0.231",
3
+ "version": "0.0.233",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,7 +28,7 @@
28
28
  "mongodb": "^6.5.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@aeriajs/core": "^0.0.231",
31
+ "@aeriajs/core": "^0.0.233",
32
32
  "@aeriajs/common": "^0.0.132",
33
33
  "@aeriajs/types": "^0.0.114",
34
34
  "mongodb": "^6.5.0"