@ahmadissa/cloudworker-proxy 1.1.121 → 1.1.123

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 (42) hide show
  1. package/dist/index.js +4 -4
  2. package/dist/index.js.map +3 -3
  3. package/dist/src/constants.d.ts +21 -0
  4. package/dist/src/encryption/aes.d.ts +11 -0
  5. package/dist/src/encryption/hash.d.ts +2 -0
  6. package/dist/src/handlers/basic-auth.d.ts +17 -0
  7. package/dist/src/handlers/bodySizeLimit.d.ts +3 -0
  8. package/dist/src/handlers/cache.d.ts +5 -0
  9. package/dist/src/handlers/cloudfunction.d.ts +6 -0
  10. package/dist/src/handlers/cors.d.ts +10 -0
  11. package/dist/src/handlers/gcpCloudrun.d.ts +11 -0
  12. package/dist/src/handlers/geo-decorator.d.ts +1 -0
  13. package/dist/src/handlers/headers.d.ts +4 -0
  14. package/dist/src/handlers/index.d.ts +1 -0
  15. package/dist/src/handlers/jwt-refresh.d.ts +6 -0
  16. package/dist/src/handlers/jwt.d.ts +17 -0
  17. package/dist/src/handlers/kv-storage-binding.d.ts +8 -0
  18. package/dist/src/handlers/kv-storage.d.ts +13 -0
  19. package/dist/src/handlers/lambda.d.ts +6 -0
  20. package/dist/src/handlers/loadbalancer.d.ts +3 -0
  21. package/dist/src/handlers/logger.d.ts +1 -0
  22. package/dist/src/handlers/oauth2.d.ts +23 -0
  23. package/dist/src/handlers/origin.d.ts +1 -0
  24. package/dist/src/handlers/rate-limit.d.ts +5 -0
  25. package/dist/src/handlers/recaptcha.d.ts +5 -0
  26. package/dist/src/handlers/recaptchav3.d.ts +14 -0
  27. package/dist/src/handlers/response.d.ts +5 -0
  28. package/dist/src/handlers/s3.d.ts +9 -0
  29. package/dist/src/handlers/signature.d.ts +3 -0
  30. package/dist/src/handlers/split.d.ts +3 -0
  31. package/dist/src/handlers/transform.d.ts +4 -0
  32. package/dist/src/handlers/user-input-validation.d.ts +4 -0
  33. package/dist/src/index.d.ts +3 -0
  34. package/dist/src/loggers/chunker.d.ts +21 -0
  35. package/dist/src/loggers/flatten.d.ts +2 -0
  36. package/dist/src/loggers/http.d.ts +5 -0
  37. package/dist/src/loggers/kinesis.d.ts +5 -0
  38. package/dist/src/proxy-hono.d.ts +13 -0
  39. package/dist/src/services/cache.d.ts +7 -0
  40. package/dist/src/services/kv-storage.d.ts +27 -0
  41. package/dist/src/utils.d.ts +11 -0
  42. package/package.json +2 -1
@@ -0,0 +1,21 @@
1
+ declare const _default: {
2
+ methodsMethodsWithBody: string[];
3
+ http: {
4
+ statusMessages: {
5
+ 404: string;
6
+ };
7
+ };
8
+ mime: {
9
+ css: string;
10
+ csv: string;
11
+ html: string;
12
+ ico: string;
13
+ jpeg: string;
14
+ js: string;
15
+ json: string;
16
+ png: string;
17
+ svg: string;
18
+ xml: string;
19
+ };
20
+ };
21
+ export default _default;
@@ -0,0 +1,11 @@
1
+ declare function deriveAesGcmKey(seed: any, salt: any): Promise<CryptoKey>;
2
+ declare function getSalt(): Promise<string>;
3
+ declare function decrypt(key: any, message: any): Promise<string>;
4
+ declare function encrypt(key: any, message: any): Promise<string>;
5
+ declare const _default: {
6
+ decrypt: typeof decrypt;
7
+ deriveAesGcmKey: typeof deriveAesGcmKey;
8
+ encrypt: typeof encrypt;
9
+ getSalt: typeof getSalt;
10
+ };
11
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare function hash(data: any): Promise<string>;
2
+ export default hash;
@@ -0,0 +1,17 @@
1
+ import type { Context } from 'hono';
2
+ type User = {
3
+ username: string;
4
+ authToken: string;
5
+ };
6
+ type Options = {
7
+ users: User[];
8
+ logoutPath?: string;
9
+ realm?: string;
10
+ };
11
+ /**
12
+ * Basic Auth using Hono's built-in middleware, plus:
13
+ * - logoutPath (forces 401)
14
+ * - store username at c.set('user', ...)
15
+ */
16
+ export default function basicAuthHandler({ users, logoutPath, realm }: Options): (c: Context, next: () => Promise<void>) => Promise<void | Response>;
17
+ export {};
@@ -0,0 +1,3 @@
1
+ export default function bodySizeLimitHandler({ bodySizeLimit }?: {
2
+ bodySizeLimit?: number | undefined;
3
+ }): (ctx: any, next: (ctx: any) => Promise<any>) => Promise<any>;
@@ -0,0 +1,5 @@
1
+ export default function cacheFactory({ cacheDuration, cacheKeyTemplate, headerBlacklist, }: {
2
+ cacheDuration: any;
3
+ cacheKeyTemplate: any;
4
+ headerBlacklist?: string[] | undefined;
5
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ export default function cloudfunction({ project_id, region, functionName, serviceAccount }: {
2
+ project_id: any;
3
+ region: any;
4
+ functionName: any;
5
+ serviceAccount: any;
6
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,10 @@
1
+ export default function corsHandler({ allowedOrigins, allowedMethods, allowCredentials, allowedHeaders, allowedExposeHeaders, maxAge, optionsSuccessStatus, terminatePreflight, }: {
2
+ allowedOrigins?: string[] | undefined;
3
+ allowedMethods?: string[] | undefined;
4
+ allowCredentials?: boolean | undefined;
5
+ allowedHeaders?: string[] | undefined;
6
+ allowedExposeHeaders?: never[] | undefined;
7
+ maxAge?: number | undefined;
8
+ optionsSuccessStatus?: number | undefined;
9
+ terminatePreflight?: boolean | undefined;
10
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,11 @@
1
+ import type { Context } from 'hono';
2
+ type GcpCloudRunOpts = {
3
+ /** e.g. 'https://your-service-abc-ue.a.run.app' (no trailing slash required) */
4
+ domain: string;
5
+ /** Service account JSON fields or whatever your getToken expects */
6
+ serviceAccount: any;
7
+ /** Optional whitelist of route param keys to validate */
8
+ allowedKeys?: string[];
9
+ };
10
+ export default function gcpCloudrun({ domain, serviceAccount, allowedKeys }: GcpCloudRunOpts): (c: Context, next: () => Promise<void>) => Promise<Response>;
11
+ export {};
@@ -0,0 +1 @@
1
+ export default function geoHandler(): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ export default function headersHandler({ headers, headersFN, }: {
2
+ headers?: Record<string, string>;
3
+ headersFN?: Function;
4
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1 @@
1
+ export { default as gcpCloudrun } from './gcpCloudrun';
@@ -0,0 +1,6 @@
1
+ export default function refreshAccessToken({ refresh_token, authDomain, clientId, clientSecret, }: {
2
+ refresh_token: any;
3
+ authDomain: any;
4
+ clientId: any;
5
+ clientSecret: any;
6
+ }): Promise<any>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Parse and decode a JWT.
3
+ * A JWT is three, base64 encoded, strings concatenated with ‘.’:
4
+ * a header, a payload, and the signature.
5
+ * The signature is “URL safe”, in that ‘/+’ characters have been replaced by ‘_-’
6
+ *
7
+ * Steps:
8
+ * 1. Split the token at the ‘.’ character
9
+ * 2. Base64 decode the individual parts
10
+ * 3. Retain the raw Bas64 encoded strings to verify the signature
11
+ */
12
+ export default function jwtHandler({ jwksUri, iss, aud, allowPublicAccess }: {
13
+ jwksUri: any;
14
+ iss: any;
15
+ aud: any;
16
+ allowPublicAccess?: boolean | undefined;
17
+ }): (ctx: any, next: any) => Promise<any>;
@@ -0,0 +1,8 @@
1
+ export default function kvStorageHandler({ kvNamespaceBinding, kvBasePath, kvKey, defaultExtension, defaultIndexDocument, defaultErrorDocument, }: {
2
+ kvNamespaceBinding: any;
3
+ kvBasePath?: string | undefined;
4
+ kvKey?: string | undefined;
5
+ defaultExtension?: string | undefined;
6
+ defaultIndexDocument: any;
7
+ defaultErrorDocument: any;
8
+ }): (ctx: any) => Promise<void>;
@@ -0,0 +1,13 @@
1
+ export default function kvStorageHandler({ kvAccountId, kvNamespace, kvAuthEmail, kvAuthKey, kvBasePath, kvKey, defaultExtension, defaultIndexDocument, defaultErrorDocument, mime, mode, }: {
2
+ kvAccountId: any;
3
+ kvNamespace: any;
4
+ kvAuthEmail: any;
5
+ kvAuthKey: any;
6
+ kvBasePath?: string | undefined;
7
+ kvKey?: string | undefined;
8
+ defaultExtension?: string | undefined;
9
+ defaultIndexDocument: any;
10
+ defaultErrorDocument: any;
11
+ mime?: {} | undefined;
12
+ mode?: string | undefined;
13
+ }): (ctx: any) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ export default function lambdaHandlerFactory({ accessKeyId, secretAccessKey, region, lambdaName }: {
2
+ accessKeyId: any;
3
+ secretAccessKey: any;
4
+ region: any;
5
+ lambdaName: any;
6
+ }): (ctx: any) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ export default function loadbalancerHandler({ sources }: {
2
+ sources?: never[] | undefined;
3
+ }): (ctx: any) => Promise<void>;
@@ -0,0 +1 @@
1
+ export default function logger(options: any): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,23 @@
1
+ export default function oauth2Handler({ cookieName, cookieHttpOnly, allowPublicAccess, kvAccountId, kvNamespace, kvAuthEmail, kvAuthKey, kvTtl, // A month
2
+ oauth2AuthDomain, oauth2ClientId, oauth2ClientSecret, oauth2Audience, oauth2Scopes, oauth2CallbackPath, oauth2CallbackType, oauth2LogoutPath, oauth2LoginPath, oauth2ServerTokenPath, oauth2ServerAuthorizePath, oauth2ServerLogoutPath, }: {
3
+ cookieName?: string | undefined;
4
+ cookieHttpOnly?: boolean | undefined;
5
+ allowPublicAccess?: boolean | undefined;
6
+ kvAccountId: any;
7
+ kvNamespace: any;
8
+ kvAuthEmail: any;
9
+ kvAuthKey: any;
10
+ kvTtl?: number | undefined;
11
+ oauth2AuthDomain: any;
12
+ oauth2ClientId: any;
13
+ oauth2ClientSecret: any;
14
+ oauth2Audience: any;
15
+ oauth2Scopes?: never[] | undefined;
16
+ oauth2CallbackPath?: string | undefined;
17
+ oauth2CallbackType?: string | undefined;
18
+ oauth2LogoutPath?: string | undefined;
19
+ oauth2LoginPath?: string | undefined;
20
+ oauth2ServerTokenPath?: string | undefined;
21
+ oauth2ServerAuthorizePath?: string | undefined;
22
+ oauth2ServerLogoutPath: any;
23
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1 @@
1
+ export default function originHandler(options: any): (ctx: any) => Promise<void>;
@@ -0,0 +1,5 @@
1
+ export default function rateLimitHandler({ type, scope, limit }: {
2
+ type?: string | undefined;
3
+ scope?: string | undefined;
4
+ limit?: number | undefined;
5
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,5 @@
1
+ export default function recaptcha({ projectID, API_KEY, siteKey }: {
2
+ projectID: any;
3
+ API_KEY: any;
4
+ siteKey: any;
5
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Middleware for reCAPTCHA v3 (free).
3
+ * Expects the client to send the token in a header (choose one):
4
+ * - "x-recaptcha-token" (default)
5
+ * - "g-recaptcha-token" (fallback)
6
+ * Optionally send "x-recaptcha-action" to specify action explicitly.
7
+ */
8
+ export default function recaptchaV3({ secret, // reCAPTCHA v3 SECRET
9
+ headerName, minScore, requireActionMatch, }: {
10
+ secret: string;
11
+ headerName?: string;
12
+ minScore?: number;
13
+ requireActionMatch?: boolean;
14
+ }): (ctx: any, next: (ctx?: any) => Promise<unknown>) => Promise<void>;
@@ -0,0 +1,5 @@
1
+ export default function responseHandler({ body, headers, status, }: {
2
+ body?: string | Record<string, object>;
3
+ headers?: Record<string, string>;
4
+ status?: number;
5
+ }): (ctx: any) => Promise<void>;
@@ -0,0 +1,9 @@
1
+ export default function s3HandlerFactory({ accessKeyId, secretAccessKey, bucket, region, endpoint, forcePathStyle, enableBucketOperations, }: {
2
+ accessKeyId: string;
3
+ secretAccessKey: string;
4
+ bucket: string;
5
+ region?: string;
6
+ endpoint?: string;
7
+ forcePathStyle?: boolean;
8
+ enableBucketOperations?: boolean;
9
+ }): (ctx: any) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ export default function signatureHandler({ secret }: {
2
+ secret: any;
3
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ export default function splitHandler({ host }: {
2
+ host: any;
3
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ export default function transformFactory({ transforms, statusCodes }: {
2
+ transforms?: never[] | undefined;
3
+ statusCodes?: number[] | undefined;
4
+ }): (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ export declare const validatePathParms: (ctx: any, allowedKeys: any) => boolean;
2
+ export default function userInputValidation({ allowedKeys }: {
3
+ allowedKeys: any;
4
+ }): (ctx: any, next: any) => Promise<false | undefined>;
@@ -0,0 +1,3 @@
1
+ export { Proxy, type Rule, type HandlerFactory } from './proxy-hono';
2
+ export type { Context } from 'hono';
3
+ export { Hono } from 'hono';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Concatinates messages in chunks based on count and timeout
3
+ */
4
+ export default class chunker {
5
+ maxSeconds: number;
6
+ maxSize: number;
7
+ queue: any[];
8
+ sink: any;
9
+ flushing: boolean;
10
+ timer: any;
11
+ resolveTimer: any;
12
+ rejectTimer: any;
13
+ cancelationToken: any;
14
+ constructor({ maxSize, maxSeconds, sink }: {
15
+ maxSize?: number | undefined;
16
+ maxSeconds?: number | undefined;
17
+ sink: any;
18
+ });
19
+ push(message: any): Promise<any>;
20
+ flush(): Promise<void>;
21
+ }
@@ -0,0 +1,2 @@
1
+ declare function flatten(obj: any, delimiter?: string, path?: string): any;
2
+ export default flatten;
@@ -0,0 +1,5 @@
1
+ export default class HttpLogger {
2
+ constructor(options: any);
3
+ log(message: any): Promise<void>;
4
+ sendMessage(data: any): Promise<Response>;
5
+ }
@@ -0,0 +1,5 @@
1
+ export default class KinesisLogger {
2
+ constructor(options: any);
3
+ log(message: any): Promise<void>;
4
+ sendMessage(message: any): Promise<any>;
5
+ }
@@ -0,0 +1,13 @@
1
+ import { type Context } from 'hono';
2
+ export interface Rule {
3
+ path: string;
4
+ method?: string;
5
+ handlerName: string;
6
+ options?: unknown;
7
+ }
8
+ export type HandlerFactory = (opts?: unknown) => (c: Context, next: () => Promise<void>) => Promise<Response | void> | void;
9
+ export declare class Proxy {
10
+ private app;
11
+ constructor(rules?: Rule[], handlers?: Record<string, HandlerFactory>);
12
+ fetch: (request: Request, env: unknown, ctx: ExecutionContext) => Response | Promise<Response>;
13
+ }
@@ -0,0 +1,7 @@
1
+ export declare function get(req: any): Promise<any>;
2
+ export declare function set(req: any, res: any): Promise<any>;
3
+ declare const _default: {
4
+ get: typeof get;
5
+ set: typeof set;
6
+ };
7
+ export default _default;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * This replaces the in-worker api calls for kv-storage with rest-api calls.
3
+ */
4
+ export default class KvStorage {
5
+ accountId: string;
6
+ namespace: string;
7
+ authEmail: string;
8
+ authKey: string;
9
+ ttl: number;
10
+ constructor({ accountId, namespace, authEmail, authKey, ttl, }: {
11
+ accountId: string;
12
+ namespace: string;
13
+ authEmail: string;
14
+ authKey: string;
15
+ ttl: number;
16
+ });
17
+ getNamespaceUrl(): URL;
18
+ getUrlForKey(key: any): URL;
19
+ list(prefix: any, limit?: number): Promise<any>;
20
+ get(key: any, type?: string): Promise<any>;
21
+ getWithMetadata(key: any, type: any): Promise<{
22
+ value: any;
23
+ metadata: any;
24
+ }>;
25
+ put(key: any, value: any, metadata?: {}): Promise<boolean>;
26
+ delete(key: any): Promise<Response>;
27
+ }
@@ -0,0 +1,11 @@
1
+ export declare function resolveParams(url: any, params?: {}): any;
2
+ export declare function instanceToJson(instance: any): object;
3
+ export declare function mergeHeaders(responseHeaders: any, ctx: any): void;
4
+ export declare function canonicalHeaderName(name: any): any;
5
+ declare const _default: {
6
+ canonicalHeaderName: typeof canonicalHeaderName;
7
+ resolveParams: typeof resolveParams;
8
+ instanceToJson: typeof instanceToJson;
9
+ mergeHeaders: typeof mergeHeaders;
10
+ };
11
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahmadissa/cloudworker-proxy",
3
- "version": "1.1.121",
3
+ "version": "1.1.123",
4
4
  "description": "An api gateway for cloudflare workers",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,6 +28,7 @@
28
28
  "lint": "eslint src",
29
29
  "package": "bun install; npm run build",
30
30
  "test": "npm run unit && npm run lint",
31
+ "publish": "npm run package && npm publish",
31
32
  "test:integration": "node integration/run.js",
32
33
  "unit": "bun test",
33
34
  "semantic-release": "semantic-release",