@cedarjs/api 7.1.1-next.471 → 7.2.0-rc.34

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 (43) hide show
  1. package/README.md +0 -12
  2. package/dist/__tests__/mergePrismaWithSdlTypes.test-d.d.ts +2 -0
  3. package/dist/__tests__/mergePrismaWithSdlTypes.test-d.d.ts.map +1 -0
  4. package/dist/cache/clients/MemcachedClient.d.ts +2 -7
  5. package/dist/cache/clients/MemcachedClient.d.ts.map +1 -1
  6. package/dist/cache/clients/MemcachedClient.js +0 -5
  7. package/dist/index.d.ts +0 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +4 -5
  10. package/dist/transforms.d.ts +4 -22
  11. package/dist/transforms.d.ts.map +1 -1
  12. package/dist/transforms.js +9 -11
  13. package/dist/types.d.ts +14 -4
  14. package/dist/types.d.ts.map +1 -1
  15. package/package.json +10 -17
  16. package/dist/__tests__/removeNulls.test-d.d.ts +0 -2
  17. package/dist/__tests__/removeNulls.test-d.d.ts.map +0 -1
  18. package/dist/sandbox/concurrencyLimiter.d.ts +0 -22
  19. package/dist/sandbox/concurrencyLimiter.d.ts.map +0 -1
  20. package/dist/sandbox/concurrencyLimiter.js +0 -33
  21. package/dist/sandbox/findChildScript.d.ts +0 -29
  22. package/dist/sandbox/findChildScript.d.ts.map +0 -1
  23. package/dist/sandbox/findChildScript.js +0 -35
  24. package/dist/sandbox/index.d.ts +0 -11
  25. package/dist/sandbox/index.d.ts.map +0 -1
  26. package/dist/sandbox/index.js +0 -22
  27. package/dist/sandbox/noNetworkPreload.d.ts +0 -16
  28. package/dist/sandbox/noNetworkPreload.d.ts.map +0 -1
  29. package/dist/sandbox/noNetworkPreload.js +0 -109
  30. package/dist/sandbox/runSandboxedChild.d.ts +0 -186
  31. package/dist/sandbox/runSandboxedChild.d.ts.map +0 -1
  32. package/dist/sandbox/runSandboxedChild.js +0 -213
  33. package/dist/sandbox/sandboxPackages.d.ts +0 -16
  34. package/dist/sandbox/sandboxPackages.d.ts.map +0 -1
  35. package/dist/sandbox/sandboxPackages.js +0 -53
  36. package/dist/signedTokens/index.d.ts +0 -2
  37. package/dist/signedTokens/index.d.ts.map +0 -1
  38. package/dist/signedTokens/index.js +0 -1
  39. package/dist/signedTokens/signedTokens.d.ts +0 -99
  40. package/dist/signedTokens/signedTokens.d.ts.map +0 -1
  41. package/dist/signedTokens/signedTokens.js +0 -100
  42. package/dist/webhooks/__tests__/webhooks.test-d.d.ts +0 -2
  43. package/dist/webhooks/__tests__/webhooks.test-d.d.ts.map +0 -1
package/README.md CHANGED
@@ -39,18 +39,6 @@ Note: CedarJS logging is setup for its api side only. For browser and web side e
39
39
 
40
40
  For detailed logger configuration, see the CedarJS logger package [README](./src/logger/README.md).
41
41
 
42
- ### Sandbox
43
-
44
- `@cedarjs/api/sandbox` runs a Node script on untrusted input — an uploaded
45
- photo, a third party's PDF — in a locked-down child process: none of your app's environment
46
- variables (on Windows a few system ones remain), read access only to its
47
- script, the packages it imports and the paths you allow, no writes, no
48
- child processes, no network, a heap cap, a timeout and output limits. Use it
49
- for parsing, decoding or converting files you didn't create (sharp, pdf.js,
50
- …). It's defense in depth on top of Node's permission model, not a security
51
- boundary, and native addons aren't limited by that model. See the sandbox
52
- [README](./src/sandbox/README.md).
53
-
54
42
  ## Contributing
55
43
 
56
44
  `@cedarjs/api` uses a few things you should be familiar with:
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mergePrismaWithSdlTypes.test-d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergePrismaWithSdlTypes.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/mergePrismaWithSdlTypes.test-d.ts"],"names":[],"mappings":""}
@@ -2,14 +2,9 @@ import type { Client as ClientType, ClientOptions, ServerOptions } from 'memjs';
2
2
  import { BaseClient } from './BaseClient.js';
3
3
  export declare class MemcachedClient extends BaseClient {
4
4
  client?: ClientType | null;
5
- servers: string | undefined;
5
+ servers: string;
6
6
  options: (ClientOptions<string | Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike> | null> & ServerOptions) | undefined;
7
- /**
8
- * @param servers - The memcached servers to connect to. When this is
9
- * undefined memjs falls back to the `MEMCACHIER_SERVERS` and
10
- * `MEMCACHE_SERVERS` environment variables, and then to `localhost:11211`
11
- */
12
- constructor(servers: string | undefined, options?: ClientOptions & ServerOptions);
7
+ constructor(servers: string, options?: ClientOptions & ServerOptions);
13
8
  connect(): Promise<void>;
14
9
  disconnect(): Promise<void>;
15
10
  get(key: string): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"MemcachedClient.d.ts","sourceRoot":"","sources":["../../../src/cache/clients/MemcachedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC1B,OAAO,qBAAA;IACP,OAAO,gHAAA;IAEP;;;;OAIG;gBAED,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa;IAOnC,OAAO;IAKP,UAAU;IAKV,GAAG,CAAC,GAAG,EAAE,MAAM;IAcf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAQ9D,GAAG,CAAC,GAAG,EAAE,MAAM;CAQtB"}
1
+ {"version":3,"file":"MemcachedClient.d.ts","sourceRoot":"","sources":["../../../src/cache/clients/MemcachedClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAC1B,OAAO,SAAA;IACP,OAAO,gHAAA;gBAEK,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa;IAM9D,OAAO;IAKP,UAAU;IAKV,GAAG,CAAC,GAAG,EAAE,MAAM;IAcf,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAQ9D,GAAG,CAAC,GAAG,EAAE,MAAM;CAQtB"}
@@ -3,11 +3,6 @@ class MemcachedClient extends BaseClient {
3
3
  client;
4
4
  servers;
5
5
  options;
6
- /**
7
- * @param servers - The memcached servers to connect to. When this is
8
- * undefined memjs falls back to the `MEMCACHIER_SERVERS` and
9
- * `MEMCACHE_SERVERS` environment variables, and then to `localhost:11211`
10
- */
11
6
  constructor(servers, options) {
12
7
  super();
13
8
  this.servers = servers;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,6 @@ export * from './types.js';
6
6
  export * from './transforms.js';
7
7
  export * from './cors.js';
8
8
  export * from './event.js';
9
- export * from './signedTokens/index.js';
10
9
  export declare const prismaVersion: string | undefined;
11
10
  /** @deprecated - use `cedarVersion` instead */
12
11
  export declare const redwoodVersion: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AAUvC,eAAO,MAAM,aAAa,EAAE,MAAM,GAAG,SAAqC,CAAA;AAC1E,+CAA+C;AAC/C,eAAO,MAAM,cAAc,QAAwB,CAAA;AACnD,+CAA+C;AAC/C,eAAO,MAAM,cAAc,QAAwB,CAAA;AACnD,eAAO,MAAM,YAAY,QAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,yBAAyB,CAAA;AACvC,cAAc,YAAY,CAAA;AAC1B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAU1B,eAAO,MAAM,aAAa,EAAE,MAAM,GAAG,SAAqC,CAAA;AAC1E,+CAA+C;AAC/C,eAAO,MAAM,cAAc,QAAwB,CAAA;AACnD,+CAA+C;AAC/C,eAAO,MAAM,cAAc,QAAwB,CAAA;AACnD,eAAO,MAAM,YAAY,QAAwB,CAAA"}
package/dist/index.js CHANGED
@@ -6,11 +6,10 @@ export * from "./types.js";
6
6
  export * from "./transforms.js";
7
7
  export * from "./cors.js";
8
8
  export * from "./event.js";
9
- export * from "./signedTokens/index.js";
10
- const prismaVersion = "7.10.0";
11
- const redwoodVersion = "7.1.1-next.471";
12
- const cedarjsVersion = "7.1.1-next.471";
13
- const cedarVersion = "7.1.1-next.471";
9
+ const prismaVersion = "7.10.1";
10
+ const redwoodVersion = "7.2.0-rc.34";
11
+ const cedarjsVersion = "7.2.0-rc.34";
12
+ const cedarVersion = "7.2.0-rc.34";
14
13
  export {
15
14
  cedarVersion,
16
15
  cedarjsVersion,
@@ -28,27 +28,9 @@ export declare const isFetchApiRequest: (event: Request | APIGatewayProxyEvent)
28
28
  */
29
29
  export declare function normalizeRequest(event: APIGatewayProxyEvent | Request): Promise<PartialRequest>;
30
30
  /**
31
- * The type of `T` after `removeNulls`: each field that can be `null` can be
32
- * `undefined` instead.
31
+ * Useful for removing nulls from an object, such as an input from a GraphQL mutation used directly in a Prisma query
32
+ * @param input - Object to remove nulls from
33
+ * See {@link https://www.prisma.io/docs/concepts/components/prisma-client/null-and-undefined Prisma docs: null vs undefined}
33
34
  */
34
- export type RemoveNulls<T> = {
35
- [K in keyof T]: null extends T[K] ? Exclude<T[K], null> | undefined : T[K];
36
- };
37
- /**
38
- * Returns a copy of `input` with every `null` field set to `undefined`.
39
- *
40
- * GraphQL input types make every field nullable, but Prisma doesn't accept
41
- * `null` for required fields. `undefined` leaves the field unchanged, so this
42
- * lets you pass a GraphQL mutation input straight to Prisma:
43
- *
44
- * ```ts
45
- * db.post.update({ data: removeNulls(input), where: { id } })
46
- * ```
47
- *
48
- * Only top-level fields are changed. Nested objects, such as `Json` field
49
- * values, are passed through as they are.
50
- *
51
- * See {@link https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/null-and-undefined Prisma docs: null vs undefined}
52
- */
53
- export declare function removeNulls<T extends object>(input: T): RemoveNulls<T>;
35
+ export declare const removeNulls: (input: Record<number | symbol | string, any>) => Record<string | number | symbol, any>;
54
36
  //# sourceMappingURL=transforms.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKtD,MAAM,WAAW,cAAc,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACzD,QAAQ,EAAE,KAAK,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,GAAG,CAAA;CACX;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,OAAO,oBAAoB,QAU/D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAU,OAA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AAoB,CAgE9B,CAAA;AAoCD,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,GAAG,oBAAoB,KACpC,KAAK,IAAI,OAcX,CAAA;AAaD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,oBAAoB,GAAG,OAAO,GACpC,OAAO,CAAC,cAAc,CAAC,CAkBzB;AAID;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,0CAcvE,CAAA"}
@@ -131,18 +131,16 @@ async function normalizeRequest(event) {
131
131
  jsonBody
132
132
  };
133
133
  }
134
- function removeNulls(input) {
135
- if (Array.isArray(input)) {
136
- return input.map(
137
- (value) => value === null ? void 0 : value
138
- );
139
- }
140
- const result = {};
141
- for (const [key, value] of Object.entries(input)) {
142
- result[key] = value === null ? void 0 : value;
134
+ const removeNulls = (input) => {
135
+ for (const key in input) {
136
+ if (input[key] === null) {
137
+ input[key] = void 0;
138
+ } else if (typeof input[key] === "object" && !(input[key] instanceof Date)) {
139
+ input[key] = removeNulls(input[key]);
140
+ }
143
141
  }
144
- return result;
145
- }
142
+ return input;
143
+ };
146
144
  export {
147
145
  isFetchApiRequest,
148
146
  normalizeRequest,
package/dist/types.d.ts CHANGED
@@ -8,18 +8,28 @@ import type { O, A } from 'ts-toolbelt';
8
8
  * Prisma types is source of truth for VALUES (unless SDL-only field)
9
9
  */
10
10
  type AnyObject = Record<string | symbol | number, unknown>;
11
- type SdlOnlyFields<TPrisma, TSdl> = Omit<TSdl, keyof TPrisma>;
11
+ type SdlOnlyFields<TPrisma, TSdl, TResolved extends PropertyKey> = Omit<TSdl, keyof TPrisma | TResolved> & {
12
+ [k in Exclude<Extract<keyof TSdl, TResolved>, keyof TPrisma>]?: TSdl[k];
13
+ };
12
14
  type PrismaTypeWithOptionalKeysFromSdl<TPrisma extends AnyObject, TSdl extends AnyObject> = Pick<TPrisma, O.OptionalKeys<TSdl>>;
13
15
  type PrismaTypeWithOptionalKeysAndNullableValues<TPrisma extends AnyObject, TSdl extends AnyObject> = {
14
16
  [k in keyof PrismaTypeWithOptionalKeysFromSdl<TPrisma, TSdl>]?: PrismaTypeWithOptionalKeysFromSdl<TPrisma, TSdl>[k] | null;
15
17
  };
16
- type PrismaTypeWithRequiredKeysFromSdl<TPrisma extends AnyObject, TSdl extends AnyObject> = Pick<TPrisma, O.RequiredKeys<TSdl>>;
17
- type OptionalsAndSdlOnly<TPrisma extends AnyObject, TSdl extends AnyObject> = PrismaTypeWithOptionalKeysAndNullableValues<TPrisma, TSdl> & SdlOnlyFields<TPrisma, TSdl>;
18
+ type PrismaTypeWithRequiredKeysFromSdl<TPrisma extends AnyObject, TSdl extends AnyObject> = Pick<TPrisma, Extract<O.RequiredKeys<TSdl>, keyof TPrisma>>;
19
+ type OptionalsAndSdlOnly<TPrisma extends AnyObject, TSdl extends AnyObject, TResolved extends PropertyKey> = PrismaTypeWithOptionalKeysAndNullableValues<TPrisma, TSdl> & SdlOnlyFields<TPrisma, TSdl, TResolved>;
18
20
  export type MakeRelationsOptional<T, TAllMappedModels> = {
19
21
  [key in keyof T as T[key] extends TAllMappedModels ? key : never]?: MakeRelationsOptional<T[key], TAllMappedModels>;
20
22
  } & {
21
23
  [key in keyof T as T[key] extends TAllMappedModels ? never : key]: T[key];
22
24
  };
23
- export type MergePrismaWithSdlTypes<TPrisma extends AnyObject, TSdl extends AnyObject, TAllMappedModels> = A.Compute<OptionalsAndSdlOnly<TPrisma, MakeRelationsOptional<TSdl, TAllMappedModels>> & PrismaTypeWithRequiredKeysFromSdl<TPrisma, MakeRelationsOptional<TSdl, TAllMappedModels>>>;
25
+ /**
26
+ * The type resolvers return for a GraphQL type that's backed by a Prisma model.
27
+ *
28
+ * `TResolved` is the union of field names the type's field resolvers (the
29
+ * service export named after the type) provide. SDL-only fields in that union
30
+ * are optional. Fields that also exist on the Prisma model stay as Prisma
31
+ * types them, because their field resolvers read them from `root`.
32
+ */
33
+ export type MergePrismaWithSdlTypes<TPrisma extends AnyObject, TSdl extends AnyObject, TAllMappedModels, TResolved extends PropertyKey = never> = A.Compute<OptionalsAndSdlOnly<TPrisma, MakeRelationsOptional<TSdl, TAllMappedModels>, TResolved> & PrismaTypeWithRequiredKeysFromSdl<TPrisma, MakeRelationsOptional<TSdl, TAllMappedModels>>>;
24
34
  export {};
25
35
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,aAAa,CAAA;AAEvC;;;;GAIG;AAEH,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAAA;AAE1D,KAAK,aAAa,CAAC,OAAO,EAAE,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,CAAA;AAG7D,KAAK,iCAAiC,CACpC,OAAO,SAAS,SAAS,EACzB,IAAI,SAAS,SAAS,IACpB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;AAGvC,KAAK,2CAA2C,CAC9C,OAAO,SAAS,SAAS,EACzB,IAAI,SAAS,SAAS,IACpB;KACD,CAAC,IAAI,MAAM,iCAAiC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAC5D,iCAAiC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAC7D,CAAA;AAGD,KAAK,iCAAiC,CACpC,OAAO,SAAS,SAAS,EACzB,IAAI,SAAS,SAAS,IACpB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;AAGvC,KAAK,mBAAmB,CACtB,OAAO,SAAS,SAAS,EACzB,IAA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AC1E,CAAA;AAID;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,CACjC,OAAO,SAAS,SAAS,EACzB,IAAI,SAAS,SAAS,EACtB,gBAAgB,EAChB,SAAS,SAAS,WAAW,GAAG,KAAK,IACnC,CAAC,CAAC,OAAO,CACX,mBAAmB,CACjB,OAAO,EACP,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAC7C,SAAS,CACV,GACC,iCAAiC,CAC/B,OAAO,EACP,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAC9C,CACJ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/api",
3
- "version": "7.1.1-next.471",
3
+ "version": "7.2.0-rc.34",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -40,12 +40,6 @@
40
40
  "default": "./dist/logger/index.js"
41
41
  }
42
42
  },
43
- "./sandbox": {
44
- "default": {
45
- "types": "./dist/sandbox/index.d.ts",
46
- "default": "./dist/sandbox/index.js"
47
- }
48
- },
49
43
  "./webhooks": {
50
44
  "default": {
51
45
  "types": "./dist/webhooks/index.d.ts",
@@ -79,28 +73,27 @@
79
73
  "test:watch": "vitest watch"
80
74
  },
81
75
  "dependencies": {
82
- "@prisma/client": "7.10.0",
83
- "@whatwg-node/fetch": "0.12.1",
76
+ "@prisma/client": "7.10.1",
77
+ "@types/jsonwebtoken": "9.0.10",
78
+ "@whatwg-node/fetch": "0.10.13",
84
79
  "cookie": "1.1.1",
85
80
  "humanize-string": "2.1.0",
86
81
  "jsonwebtoken": "9.0.3",
87
82
  "pascalcase": "1.0.0",
88
83
  "picoquery": "2.5.0",
89
- "pino": "10.4.0",
84
+ "pino": "9.7.0",
90
85
  "title-case": "3.0.3"
91
86
  },
92
87
  "devDependencies": {
93
- "@cedarjs/framework-tools": "7.1.1-next.471",
94
- "@types/aws-lambda": "8.10.164",
95
- "@types/jsonwebtoken": "9.0.10",
88
+ "@cedarjs/framework-tools": "7.2.0-rc.34",
89
+ "@types/aws-lambda": "8.10.163",
96
90
  "@types/memjs": "1",
97
91
  "@types/pascalcase": "1.0.3",
98
92
  "@types/split2": "4.2.3",
99
93
  "concurrently": "9.2.5",
100
94
  "memjs": "1.3.2",
101
- "publint": "0.3.25",
102
- "redis": "6.3.0",
103
- "sharp": "0.35.5",
95
+ "publint": "0.3.24",
96
+ "redis": "6.2.1",
104
97
  "split2": "4.2.0",
105
98
  "ts-toolbelt": "9.6.0",
106
99
  "typescript": "5.9.3",
@@ -108,7 +101,7 @@
108
101
  },
109
102
  "peerDependencies": {
110
103
  "memjs": "1.3.2",
111
- "redis": "6.3.0"
104
+ "redis": "6.2.1"
112
105
  },
113
106
  "peerDependenciesMeta": {
114
107
  "memjs": {
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=removeNulls.test-d.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"removeNulls.test-d.d.ts","sourceRoot":"","sources":["../../src/__tests__/removeNulls.test-d.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- /**
2
- * Runs `fn` once a slot is free; resolves or rejects with what `fn` does.
3
- */
4
- export type ConcurrencyLimiter = <T>(fn: () => Promise<T>) => Promise<T>;
5
- /**
6
- * A limiter that lets at most `max` tasks run at once; the rest wait their
7
- * turn, first come first served. Use it around `runSandboxedChild()`: each
8
- * sandboxed child is a whole Node process, and a burst of uploads shouldn't
9
- * start a hundred of them.
10
- *
11
- * The limit is per limiter, in this process. Create one per kind of work
12
- * at module level, not one per call.
13
- *
14
- * @example
15
- * ```ts
16
- * const limit = createConcurrencyLimiter(2)
17
- *
18
- * const result = await limit(() => runSandboxedChild({ ... }))
19
- * ```
20
- */
21
- export declare const createConcurrencyLimiter: (max: number) => ConcurrencyLimiter;
22
- //# sourceMappingURL=concurrencyLimiter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"concurrencyLimiter.d.ts","sourceRoot":"","sources":["../../src/sandbox/concurrencyLimiter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;AAExE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,GAAI,KAAK,MAAM,KAAG,kBAkCtD,CAAA"}
@@ -1,33 +0,0 @@
1
- const createConcurrencyLimiter = (max) => {
2
- if (!Number.isInteger(max) || max < 1) {
3
- throw new Error(`max must be a positive integer, got ${max}`);
4
- }
5
- let running = 0;
6
- const waiting = [];
7
- const acquire = async () => {
8
- if (running < max) {
9
- running += 1;
10
- return;
11
- }
12
- await new Promise((resolve) => waiting.push(resolve));
13
- };
14
- const release = () => {
15
- const next = waiting.shift();
16
- if (next) {
17
- next();
18
- } else {
19
- running -= 1;
20
- }
21
- };
22
- return async (fn) => {
23
- await acquire();
24
- try {
25
- return await fn();
26
- } finally {
27
- release();
28
- }
29
- };
30
- };
31
- export {
32
- createConcurrencyLimiter
33
- };
@@ -1,29 +0,0 @@
1
- /**
2
- * Finds a sandboxed child's script for the module that runs it. Call it
3
- * with `import.meta.dirname` and the script's name without extension, the
4
- * same way in every build:
5
- *
6
- * - from source (tests, `cedar exec`), `<baseName>.ts` (or `.js`) in
7
- * `dir`, which Node runs by stripping its types;
8
- * - in a regular build, `<baseName>.js` in `dir`, where the build puts it
9
- * next to its caller;
10
- * - in a bundled build (`cedar build --ud`, and so on Netlify and Vercel),
11
- * where the caller is part of a bundle,
12
- * `api/dist/ud/sandbox-children/<baseName>.js` in the app (looked for
13
- * from `dir` up). A bundled build needs each child's name to be unique
14
- * in `api/src`.
15
- *
16
- * Throws when there's no such script, so a build that lost it fails loudly
17
- * instead of running without it.
18
- *
19
- * Keep the child script plain enough to run as-is: no path aliases like
20
- * `src/…`, no TypeScript-only syntax such as enums, and imports of packages
21
- * only, never of your app's own modules.
22
- *
23
- * @example
24
- * ```ts
25
- * const script = findChildScript(import.meta.dirname, 'resize.child')
26
- * ```
27
- */
28
- export declare const findChildScript: (dir: string, baseName: string) => string;
29
- //# sourceMappingURL=findChildScript.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findChildScript.d.ts","sourceRoot":"","sources":["../../src/sandbox/findChildScript.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,KAAG,MAiB/D,CAAA"}
@@ -1,35 +0,0 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- const SANDBOX_CHILDREN_DIR = path.join("api", "dist", "ud", "sandbox-children");
4
- const findBundledChild = (dir, baseName) => {
5
- let current = dir;
6
- for (; ; ) {
7
- const candidate = path.join(current, SANDBOX_CHILDREN_DIR, `${baseName}.js`);
8
- if (fs.existsSync(candidate)) {
9
- return candidate;
10
- }
11
- const parent = path.dirname(current);
12
- if (parent === current) {
13
- return null;
14
- }
15
- current = parent;
16
- }
17
- };
18
- const findChildScript = (dir, baseName) => {
19
- for (const name of [`${baseName}.js`, `${baseName}.ts`]) {
20
- const candidate = path.join(dir, name);
21
- if (fs.existsSync(candidate)) {
22
- return candidate;
23
- }
24
- }
25
- const bundled = findBundledChild(dir, baseName);
26
- if (bundled) {
27
- return bundled;
28
- }
29
- throw new Error(
30
- `findChildScript: no ${baseName}.js or ${baseName}.ts in ${dir}, and no ${path.join(SANDBOX_CHILDREN_DIR, `${baseName}.js`)} from it up`
31
- );
32
- };
33
- export {
34
- findChildScript
35
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * Run code on untrusted input in a sandboxed, locked-down child process.
3
- * See `runSandboxedChild()` and ./README.md.
4
- */
5
- export { DEFAULT_SANDBOX_HEAP_MB, DEFAULT_SANDBOX_MAX_INPUT_BYTES, DEFAULT_SANDBOX_MAX_OUTPUT_BYTES, DEFAULT_SANDBOX_TIMEOUT_MS, runSandboxedChild, sandboxedChildArgs, } from './runSandboxedChild.js';
6
- export type { RunSandboxedChildOptions, SandboxedChildArgsOptions, SandboxedChildFailure, SandboxedChildResult, } from './runSandboxedChild.js';
7
- export { createConcurrencyLimiter } from './concurrencyLimiter.js';
8
- export type { ConcurrencyLimiter } from './concurrencyLimiter.js';
9
- export { permissionModelBlocksNetwork } from './noNetworkPreload.js';
10
- export { findChildScript } from './findChildScript.js';
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,gCAAgC,EAChC,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EACV,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AAClE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
@@ -1,22 +0,0 @@
1
- import {
2
- DEFAULT_SANDBOX_HEAP_MB,
3
- DEFAULT_SANDBOX_MAX_INPUT_BYTES,
4
- DEFAULT_SANDBOX_MAX_OUTPUT_BYTES,
5
- DEFAULT_SANDBOX_TIMEOUT_MS,
6
- runSandboxedChild,
7
- sandboxedChildArgs
8
- } from "./runSandboxedChild.js";
9
- import { createConcurrencyLimiter } from "./concurrencyLimiter.js";
10
- import { permissionModelBlocksNetwork } from "./noNetworkPreload.js";
11
- import { findChildScript } from "./findChildScript.js";
12
- export {
13
- DEFAULT_SANDBOX_HEAP_MB,
14
- DEFAULT_SANDBOX_MAX_INPUT_BYTES,
15
- DEFAULT_SANDBOX_MAX_OUTPUT_BYTES,
16
- DEFAULT_SANDBOX_TIMEOUT_MS,
17
- createConcurrencyLimiter,
18
- findChildScript,
19
- permissionModelBlocksNetwork,
20
- runSandboxedChild,
21
- sandboxedChildArgs
22
- };
@@ -1,16 +0,0 @@
1
- /**
2
- * Whether this Node's permission model restricts network access. On Node
3
- * 25 and later it does: under `--permission`, without `--allow-net`, a
4
- * child can't open sockets, listen, look up names or `fetch`. On Node 24
5
- * it doesn't, so `runSandboxedChild()` loads a preload that takes the
6
- * network away from JavaScript instead (see `NO_NETWORK_PRELOAD`).
7
- *
8
- * Neither limits native code: an addon makes its own system calls.
9
- */
10
- export declare const permissionModelBlocksNetwork: () => boolean;
11
- /**
12
- * The `--import` argument that loads the no-network preload, as a `data:`
13
- * URL. Loading it needs no file and no read permission.
14
- */
15
- export declare const noNetworkPreloadArg: () => string;
16
- //# sourceMappingURL=noNetworkPreload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"noNetworkPreload.d.ts","sourceRoot":"","sources":["../../src/sandbox/noNetworkPreload.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,eACe,CAAA;AAiIxD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,cAC2C,CAAA"}
@@ -1,109 +0,0 @@
1
- const permissionModelBlocksNetwork = () => process.allowedNodeEnvironmentFlags.has("--allow-net");
2
- const NO_NETWORK_PRELOAD = String.raw`
3
- const BLOCKED = new Set([
4
- 'net',
5
- 'tls',
6
- 'dgram',
7
- 'dns',
8
- 'dns/promises',
9
- 'http',
10
- 'https',
11
- 'http2',
12
- '_http_agent',
13
- '_http_client',
14
- '_http_common',
15
- '_http_incoming',
16
- '_http_outgoing',
17
- '_http_server',
18
- '_tls_common',
19
- '_tls_wrap',
20
- ])
21
-
22
- const isBlocked = (id) =>
23
- typeof id === 'string' && BLOCKED.has(id.replace(/^node:/, ''))
24
-
25
- const refuse = (what) =>
26
- function noNetwork() {
27
- throw new Error('No network access in a sandboxed child (' + what + ')')
28
- }
29
-
30
- const getBuiltinModule = process.getBuiltinModule.bind(process)
31
- const { registerHooks, syncBuiltinESMExports } =
32
- getBuiltinModule('node:module')
33
-
34
- // The modules themselves first, before the hooks below make them
35
- // unreachable. Builtin modules are shared, so Node's own users of them
36
- // (http uses net) get the patched functions too
37
- const net = getBuiltinModule('node:net')
38
- net.Socket.prototype.connect = refuse('net.Socket#connect')
39
- net.Server.prototype.listen = refuse('net.Server#listen')
40
- net.connect = refuse('net.connect')
41
- net.createConnection = refuse('net.createConnection')
42
-
43
- const tls = getBuiltinModule('node:tls')
44
- tls.connect = refuse('tls.connect')
45
-
46
- const dgram = getBuiltinModule('node:dgram')
47
- for (const name of ['bind', 'connect', 'send']) {
48
- dgram.Socket.prototype[name] = refuse('dgram.Socket#' + name)
49
- }
50
-
51
- const dns = getBuiltinModule('node:dns')
52
- for (const [label, api] of [
53
- ['dns', dns],
54
- ['dns.promises', dns.promises],
55
- ]) {
56
- for (const name of Object.keys(api)) {
57
- if (typeof api[name] === 'function') {
58
- api[name] = refuse(label + '.' + name)
59
- }
60
- }
61
- }
62
-
63
- // The handles under stdin, stdout and stderr (a Pipe or a TTY). Their
64
- // class can make new handles that connect or bind, e.g. to a Unix socket.
65
- // Reading process.stdin and friends here also opens the child's own stdio
66
- // before open() is taken away
67
- for (const stream of [process.stdin, process.stdout, process.stderr]) {
68
- const handle = stream._handle
69
- const proto = handle && Object.getPrototypeOf(handle)
70
- if (!proto) {
71
- continue
72
- }
73
- for (const name of ['bind', 'bind6', 'connect', 'connect6', 'listen', 'open']) {
74
- if (typeof proto[name] === 'function') {
75
- proto[name] = refuse(handle.constructor.name + '#' + name)
76
- }
77
- }
78
- }
79
-
80
- syncBuiltinESMExports()
81
-
82
- // Then the ways to the modules
83
- registerHooks({
84
- resolve(specifier, context, nextResolve) {
85
- if (isBlocked(specifier)) {
86
- refuse('import of ' + specifier)()
87
- }
88
- return nextResolve(specifier, context)
89
- },
90
- })
91
-
92
- process.getBuiltinModule = (id) => {
93
- if (isBlocked(id)) {
94
- refuse('process.getBuiltinModule(' + id + ')')()
95
- }
96
- return getBuiltinModule(id)
97
- }
98
-
99
- for (const name of ['fetch', 'WebSocket', 'EventSource']) {
100
- delete globalThis[name]
101
- }
102
-
103
- //# sourceURL=cedar-sandbox-no-network-preload.js
104
- `;
105
- const noNetworkPreloadArg = () => `--import=data:text/javascript,${encodeURIComponent(NO_NETWORK_PRELOAD)}`;
106
- export {
107
- noNetworkPreloadArg,
108
- permissionModelBlocksNetwork
109
- };