@cedarjs/api 5.0.6 → 5.0.7-next.219

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 (120) hide show
  1. package/dist/auth/index.d.ts +9 -0
  2. package/dist/auth/index.d.ts.map +1 -1
  3. package/dist/auth/index.js +7 -0
  4. package/dist/bins/cedar.js +14 -0
  5. package/dist/bins/cfw.js +14 -0
  6. package/dist/bins/redwood.js +14 -0
  7. package/dist/bins/tsc.js +8 -0
  8. package/dist/errors.d.ts +9 -1
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/errors.js +9 -2
  11. package/dist/index.js +3 -3
  12. package/dist/logger/index.d.ts +7 -5
  13. package/dist/logger/index.d.ts.map +1 -1
  14. package/dist/runtime.d.ts +0 -26
  15. package/dist/runtime.d.ts.map +1 -1
  16. package/dist/runtime.js +1 -22
  17. package/package.json +17 -41
  18. package/dist/cjs/auth/index.d.ts +0 -64
  19. package/dist/cjs/auth/index.d.ts.map +0 -1
  20. package/dist/cjs/auth/index.js +0 -143
  21. package/dist/cjs/auth/parseJWT.d.ts +0 -6
  22. package/dist/cjs/auth/parseJWT.d.ts.map +0 -1
  23. package/dist/cjs/auth/parseJWT.js +0 -57
  24. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts +0 -18
  25. package/dist/cjs/auth/verifiers/base64Sha1Verifier.d.ts.map +0 -1
  26. package/dist/cjs/auth/verifiers/base64Sha1Verifier.js +0 -77
  27. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts +0 -18
  28. package/dist/cjs/auth/verifiers/base64Sha256Verifier.d.ts.map +0 -1
  29. package/dist/cjs/auth/verifiers/base64Sha256Verifier.js +0 -77
  30. package/dist/cjs/auth/verifiers/common.d.ts +0 -112
  31. package/dist/cjs/auth/verifiers/common.d.ts.map +0 -1
  32. package/dist/cjs/auth/verifiers/common.js +0 -89
  33. package/dist/cjs/auth/verifiers/index.d.ts +0 -8
  34. package/dist/cjs/auth/verifiers/index.d.ts.map +0 -1
  35. package/dist/cjs/auth/verifiers/index.js +0 -39
  36. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts +0 -18
  37. package/dist/cjs/auth/verifiers/jwtVerifier.d.ts.map +0 -1
  38. package/dist/cjs/auth/verifiers/jwtVerifier.js +0 -84
  39. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts +0 -11
  40. package/dist/cjs/auth/verifiers/secretKeyVerifier.d.ts.map +0 -1
  41. package/dist/cjs/auth/verifiers/secretKeyVerifier.js +0 -43
  42. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts +0 -17
  43. package/dist/cjs/auth/verifiers/sha1Verifier.d.ts.map +0 -1
  44. package/dist/cjs/auth/verifiers/sha1Verifier.js +0 -85
  45. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts +0 -17
  46. package/dist/cjs/auth/verifiers/sha256Verifier.d.ts.map +0 -1
  47. package/dist/cjs/auth/verifiers/sha256Verifier.js +0 -85
  48. package/dist/cjs/auth/verifiers/skipVerifier.d.ts +0 -11
  49. package/dist/cjs/auth/verifiers/skipVerifier.d.ts.map +0 -1
  50. package/dist/cjs/auth/verifiers/skipVerifier.js +0 -40
  51. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts +0 -14
  52. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.d.ts.map +0 -1
  53. package/dist/cjs/auth/verifiers/timestampSchemeVerifier.js +0 -86
  54. package/dist/cjs/bins/cedar.d.ts +0 -9
  55. package/dist/cjs/bins/cedar.d.ts.map +0 -1
  56. package/dist/cjs/bins/cedar.js +0 -36
  57. package/dist/cjs/bins/cfw.d.ts +0 -3
  58. package/dist/cjs/bins/cfw.d.ts.map +0 -1
  59. package/dist/cjs/bins/cfw.js +0 -36
  60. package/dist/cjs/bins/redwood.d.ts +0 -9
  61. package/dist/cjs/bins/redwood.d.ts.map +0 -1
  62. package/dist/cjs/bins/redwood.js +0 -36
  63. package/dist/cjs/bins/tsc.d.ts +0 -3
  64. package/dist/cjs/bins/tsc.d.ts.map +0 -1
  65. package/dist/cjs/bins/tsc.js +0 -30
  66. package/dist/cjs/cache/clients/BaseClient.d.ts +0 -11
  67. package/dist/cjs/cache/clients/BaseClient.d.ts.map +0 -1
  68. package/dist/cjs/cache/clients/BaseClient.js +0 -31
  69. package/dist/cjs/cache/clients/InMemoryClient.d.ts +0 -31
  70. package/dist/cjs/cache/clients/InMemoryClient.d.ts.map +0 -1
  71. package/dist/cjs/cache/clients/InMemoryClient.js +0 -94
  72. package/dist/cjs/cache/clients/MemcachedClient.d.ts +0 -16
  73. package/dist/cjs/cache/clients/MemcachedClient.d.ts.map +0 -1
  74. package/dist/cjs/cache/clients/MemcachedClient.js +0 -79
  75. package/dist/cjs/cache/clients/RedisClient.d.ts +0 -20
  76. package/dist/cjs/cache/clients/RedisClient.d.ts.map +0 -1
  77. package/dist/cjs/cache/clients/RedisClient.js +0 -83
  78. package/dist/cjs/cache/errors.d.ts +0 -4
  79. package/dist/cjs/cache/errors.d.ts.map +0 -1
  80. package/dist/cjs/cache/errors.js +0 -33
  81. package/dist/cjs/cache/index.d.ts +0 -35
  82. package/dist/cjs/cache/index.d.ts.map +0 -1
  83. package/dist/cjs/cache/index.js +0 -165
  84. package/dist/cjs/cors.d.ts +0 -16
  85. package/dist/cjs/cors.d.ts.map +0 -1
  86. package/dist/cjs/cors.js +0 -93
  87. package/dist/cjs/errors.d.ts +0 -5
  88. package/dist/cjs/errors.d.ts.map +0 -1
  89. package/dist/cjs/errors.js +0 -38
  90. package/dist/cjs/event.d.ts +0 -3
  91. package/dist/cjs/event.d.ts.map +0 -1
  92. package/dist/cjs/event.js +0 -34
  93. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts +0 -4
  94. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.d.ts.map +0 -1
  95. package/dist/cjs/functions/fixtures/apiGatewayProxyEvent.fixture.js +0 -72
  96. package/dist/cjs/index.d.ts +0 -15
  97. package/dist/cjs/index.d.ts.map +0 -1
  98. package/dist/cjs/index.js +0 -54
  99. package/dist/cjs/logger/index.d.ts +0 -179
  100. package/dist/cjs/logger/index.d.ts.map +0 -1
  101. package/dist/cjs/logger/index.js +0 -185
  102. package/dist/cjs/package.json +0 -1
  103. package/dist/cjs/runtime.d.ts +0 -68
  104. package/dist/cjs/runtime.d.ts.map +0 -1
  105. package/dist/cjs/runtime.js +0 -200
  106. package/dist/cjs/transforms.d.ts +0 -36
  107. package/dist/cjs/transforms.d.ts.map +0 -1
  108. package/dist/cjs/transforms.js +0 -176
  109. package/dist/cjs/types.d.ts +0 -25
  110. package/dist/cjs/types.d.ts.map +0 -1
  111. package/dist/cjs/types.js +0 -16
  112. package/dist/cjs/validations/errors.d.ts +0 -101
  113. package/dist/cjs/validations/errors.d.ts.map +0 -1
  114. package/dist/cjs/validations/errors.js +0 -298
  115. package/dist/cjs/validations/validations.d.ts +0 -235
  116. package/dist/cjs/validations/validations.d.ts.map +0 -1
  117. package/dist/cjs/validations/validations.js +0 -353
  118. package/dist/cjs/webhooks/index.d.ts +0 -77
  119. package/dist/cjs/webhooks/index.d.ts.map +0 -1
  120. package/dist/cjs/webhooks/index.js +0 -102
@@ -46,6 +46,15 @@ export type AuthContextPayload = [
46
46
  context?: LambdaContext;
47
47
  }
48
48
  ];
49
+ /**
50
+ * Whether a project has auth configured.
51
+ *
52
+ * An empty decoder array counts as no auth: there's nothing to decode with, so
53
+ * auth state can never be resolved. Anything deciding whether auth is set up
54
+ * has to agree with `buildCedarContext` on this, or they'll disagree about
55
+ * whether a request should have had auth state resolved.
56
+ */
57
+ export declare function hasAuthDecoder(authDecoder: Decoder | Decoder[] | undefined): authDecoder is Decoder | Decoder[];
49
58
  export type Decoder = (token: string, type: string, req: {
50
59
  /** The Lambda-style request event */
51
60
  event: APIGatewayProxyEvent | Request;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"m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UF,CAAA;AAED;;;;;;GAMG;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO;IACP;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,mBAAmB;IAEtC;QACE;;;;WAIG;QACH,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;QACrC;;;;WAIG;QACH,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,OAAO,CAAC,EAAE,aAAa,CAAA;KACxB;CACF,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,SAAS,GAC3C,WAAW,IAAI,OAAO,GAAG,OAAO,EAAE,CAMpC;AAED,MAAM,MAAM,OAAO,GAAG,CACpB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE;IACH,qCAAqC;IACrC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KACE,OAAO,CAAC,OAAO,CAAC,CAAA;AAErB;;;IAGI;AACJ,eAAO,MAAM,wBAAwB,GAAU,kCAI5C;IACD,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAA;IACjC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KAAG,OAAO,CAAC,SAAS,GAAG,kBAAkB,CA0EzC,CAAA"}
@@ -40,6 +40,12 @@ const parseAuthorizationHeader = (event) => {
40
40
  }
41
41
  return { schema, token };
42
42
  };
43
+ function hasAuthDecoder(authDecoder) {
44
+ if (Array.isArray(authDecoder)) {
45
+ return authDecoder.length > 0;
46
+ }
47
+ return !!authDecoder;
48
+ }
43
49
  const getAuthenticationContext = async ({
44
50
  authDecoder,
45
51
  event,
@@ -98,6 +104,7 @@ export {
98
104
  AUTH_PROVIDER_HEADER,
99
105
  getAuthProviderHeader,
100
106
  getAuthenticationContext,
107
+ hasAuthDecoder,
101
108
  parseAuthorizationCookie,
102
109
  parseAuthorizationHeader
103
110
  };
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ import { pathToFileURL } from "node:url";
4
+ const require2 = createRequire(import.meta.url);
5
+ const cliPackageJsonFileUrl = pathToFileURL(
6
+ require2.resolve("@cedarjs/cli/package.json")
7
+ );
8
+ const requireFromCli = createRequire(cliPackageJsonFileUrl);
9
+ const bins = requireFromCli("./package.json")["bin"];
10
+ const cliEntryPointUrl = new URL(bins["cedar"], cliPackageJsonFileUrl);
11
+ if (process.env.PROJECT_CWD) {
12
+ process.chdir(process.env.PROJECT_CWD);
13
+ }
14
+ import(cliEntryPointUrl.toString());
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ import { pathToFileURL } from "node:url";
4
+ const require2 = createRequire(import.meta.url);
5
+ const cliPackageJsonFileUrl = pathToFileURL(
6
+ require2.resolve("@cedarjs/cli/package.json")
7
+ );
8
+ const requireFromCli = createRequire(cliPackageJsonFileUrl);
9
+ const bins = requireFromCli("./package.json")["bin"];
10
+ const cliEntryPointUrl = new URL(bins["cfw"], cliPackageJsonFileUrl);
11
+ if (process.env.PROJECT_CWD) {
12
+ process.chdir(process.env.PROJECT_CWD);
13
+ }
14
+ import(cliEntryPointUrl.toString());
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ import { pathToFileURL } from "node:url";
4
+ const require2 = createRequire(import.meta.url);
5
+ const cliPackageJsonFileUrl = pathToFileURL(
6
+ require2.resolve("@cedarjs/cli/package.json")
7
+ );
8
+ const requireFromCli = createRequire(cliPackageJsonFileUrl);
9
+ const bins = requireFromCli("./package.json")["bin"];
10
+ const cliEntryPointUrl = new URL(bins["redwood"], cliPackageJsonFileUrl);
11
+ if (process.env.PROJECT_CWD) {
12
+ process.chdir(process.env.PROJECT_CWD);
13
+ }
14
+ import(cliEntryPointUrl.toString());
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
3
+ const require2 = createRequire(import.meta.url);
4
+ const requireFromTypeScript = createRequire(
5
+ require2.resolve("typescript/package.json")
6
+ );
7
+ const bins = requireFromTypeScript("./package.json")["bin"];
8
+ requireFromTypeScript(bins["tsc"]);
package/dist/errors.d.ts CHANGED
@@ -1,5 +1,13 @@
1
- export declare class RedwoodError extends Error {
1
+ export declare class CedarError extends Error {
2
2
  extensions: Record<string, any> | undefined;
3
3
  constructor(message: string, extensions?: Record<string, any>);
4
4
  }
5
+ /**
6
+ * @deprecated Use `CedarError` instead.
7
+ * Preserved as a distinct class to maintain backward compatibility for code that checks
8
+ * `error.name === 'RedwoodError'` or `instanceof RedwoodError`.
9
+ */
10
+ export declare class RedwoodError extends CedarError {
11
+ constructor(message: string, extensions?: Record<string, any>);
12
+ }
5
13
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;gBAC/B,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAQ9D"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAW,SAAQ,KAAK;IACnC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;gBAC/B,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAQ9D;AAED;;;;GAIG;AACH,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAI9D"}
package/dist/errors.js CHANGED
@@ -1,14 +1,21 @@
1
- class RedwoodError extends Error {
1
+ class CedarError extends Error {
2
2
  extensions;
3
3
  constructor(message, extensions) {
4
4
  super(message);
5
- this.name = "RedwoodError";
5
+ this.name = "CedarError";
6
6
  this.extensions = {
7
7
  ...extensions,
8
8
  code: extensions?.code || "REDWOODJS_ERROR"
9
9
  };
10
10
  }
11
11
  }
12
+ class RedwoodError extends CedarError {
13
+ constructor(message, extensions) {
14
+ super(message, extensions);
15
+ this.name = "RedwoodError";
16
+ }
17
+ }
12
18
  export {
19
+ CedarError,
13
20
  RedwoodError
14
21
  };
package/dist/index.js CHANGED
@@ -7,9 +7,9 @@ export * from "./transforms.js";
7
7
  export * from "./cors.js";
8
8
  export * from "./event.js";
9
9
  const prismaVersion = "7.8.0";
10
- const redwoodVersion = "5.0.6";
11
- const cedarjsVersion = "5.0.6";
12
- const cedarVersion = "5.0.6";
10
+ const redwoodVersion = "5.0.7-next.219";
11
+ const cedarjsVersion = "5.0.7-next.219";
12
+ const cedarVersion = "5.0.7-next.219";
13
13
  export {
14
14
  cedarVersion,
15
15
  cedarjsVersion,
@@ -90,24 +90,26 @@ export declare const defaultLoggerOptions: {
90
90
  redact: string[];
91
91
  };
92
92
  /**
93
- * RedwoodLoggerOptions defines custom logger options that extend those available in LoggerOptions
93
+ * CedarLoggerOptions defines custom logger options that extend those available in LoggerOptions
94
94
  * and can define a destination like a file or other supported pin log transport stream
95
95
  *
96
- * @typedef {Object} RedwoodLoggerOptions
96
+ * @typedef {Object} CedarLoggerOptions
97
97
  * @extends LoggerOptions
98
98
  * @property {options} LoggerOptions - options define how to log
99
99
  * @property {string | DestinationStream} destination - destination defines where to log
100
100
  * @property {boolean} showConfig - Display logger configuration on initialization
101
101
  */
102
- export interface RedwoodLoggerOptions {
102
+ export interface CedarLoggerOptions {
103
103
  options?: LoggerOptions;
104
104
  destination?: string | DestinationStream;
105
105
  showConfig?: boolean;
106
106
  }
107
+ /** @deprecated Use `CedarLoggerOptions` instead. */
108
+ export type RedwoodLoggerOptions = CedarLoggerOptions;
107
109
  /**
108
110
  * Creates the logger
109
111
  *
110
- * @param options {RedwoodLoggerOptions} - Override the default logger configuration
112
+ * @param options {CedarLoggerOptions} - Override the default logger configuration
111
113
  * @param destination {DestinationStream} - An optional destination stream
112
114
  * @param showConfig {Boolean} - Show the logger configuration. This is off by default.
113
115
  *
@@ -121,7 +123,7 @@ export interface RedwoodLoggerOptions {
121
123
  *
122
124
  * @return {Logger} - The configured logger
123
125
  */
124
- export declare const createLogger: ({ options, destination, showConfig, }: RedwoodLoggerOptions) => Logger;
126
+ export declare const createLogger: ({ options, destination, showConfig, }: CedarLoggerOptions) => Logger;
125
127
  /**
126
128
  * Determines the type and level of logging.
127
129
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,MAAM,CAAA;AAGzB;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAA;AAC7B,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,UAAU,CAAA;AACrC,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,iBAAiB,CAAA;AACnD,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,eAAe,CAAA;AAC/C,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,aAAa,CAAA;AAC3C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;AAI1D,KAAK,YAAY,GAAG,GAAG,CAAA;AAEvB,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,QAAQ,CAAA;IACf,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;CACzB,CAAA;AAgBD;;;;;G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,eAAO,MAAM,gBAAgB,EAAE,QAAQ,EAA8B,CAAA;AAErE;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,cAAc,QAAQ,EAAE,KAAG,aAAa,EAIrE,CAAA;AAED;;;;;;;;;;;GAWG;AACH,UAAU,mBAAmB;IAC3B,EAAE,EAAE,YAAY,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,QAAQ,EAAE,CAAA;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,mBAAmB,KAAG,IA8CjE,CAAA"}
package/dist/runtime.d.ts CHANGED
@@ -1,31 +1,5 @@
1
1
  import type { APIGatewayProxyEvent, APIGatewayProxyResult, Context as LambdaContext } from 'aws-lambda';
2
2
  import { getAuthenticationContext } from './auth/index.js';
3
- import type { Decoder } from './auth/index.js';
4
- /**
5
- * A decoder that decodes nothing.
6
- *
7
- * Resolving `serverAuthState` has to happen before the GraphQL server reads
8
- * the request body:
9
- *
10
- * 1. Resolving it materialises the request body — `getAuthenticationContext`
11
- * builds a Lambda-style event via `requestToBaseEvent`, which does
12
- * `request.clone().text()`
13
- * 2. `clone()` only works while the body is untouched
14
- * 3. So once the GraphQL server has read the body, resolving throws
15
- * `TypeError: unusable`
16
- *
17
- * `buildCedarContext` only resolves auth state when it's given a decoder, so
18
- * GraphQL call sites pass this one for projects that have no auth set up, to
19
- * keep the resolve eager. Resolving with it produces the same payload as
20
- * resolving with no decoders at all.
21
- *
22
- * (When it isn't resolved eagerly, `useRedwoodAuthContext` resolves it during
23
- * context building instead — too late. That's how this surfaces.)
24
- *
25
- * TODO: Remove this once the request body is captured at the entry point rather
26
- * than read lazily from the auth path, which drops the ordering constraint.
27
- */
28
- export declare const noopAuthDecoder: Decoder;
29
3
  export interface CedarRequestContext {
30
4
  params: Record<string, string>;
31
5
  query: URLSearchParams;
@@ -1 +1 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,EAAE,oBAAoB,CAAA;IAC3B,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,mBAAmB,CAAA;CAClC;AAED,MAAM,MAAM,mBAAmB,GAAG,qBAAqB,GAAG,QAAQ,CAAA;AAElE,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,aAAa,KACnB,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAA;AAyBvD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAoC9B;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,eAAe,EAAE,GAC5B,YAAY,CAMd;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EAAE,GACzB,gBAAgB,EAAE,CAOpB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAEtE;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,EAC5B,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAQd;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAoB/B;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,GAAG,QAAQ,CAsD5E"}
package/dist/runtime.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import * as cookie from "cookie";
2
2
  import { parse } from "picoquery";
3
- import { getAuthenticationContext } from "./auth/index.js";
3
+ import { getAuthenticationContext, hasAuthDecoder } from "./auth/index.js";
4
4
  import { requestToBaseEvent } from "./transforms.js";
5
- const noopAuthDecoder = async () => null;
6
5
  const DEFAULT_LAMBDA_CONTEXT = {
7
6
  callbackWaitsForEmptyEventLoop: false,
8
7
  functionName: "cedar",
@@ -25,12 +24,6 @@ const DEFAULT_LAMBDA_CONTEXT = {
25
24
  return void 0;
26
25
  }
27
26
  };
28
- function hasAuthDecoder(authDecoder) {
29
- if (Array.isArray(authDecoder)) {
30
- return authDecoder.length > 0;
31
- }
32
- return !!authDecoder;
33
- }
34
27
  async function buildCedarContext(request, options = {}) {
35
28
  const url = new URL(request.url);
36
29
  const query = url.searchParams;
@@ -91,7 +84,6 @@ async function requestToLegacyEvent(request, ctx) {
91
84
  return {
92
85
  ...base,
93
86
  queryStringParameters,
94
- multiValueQueryStringParameters: toMultiValueQueryStringParameters(url),
95
87
  pathParameters: Object.keys(ctx.params).length > 0 ? ctx.params : base.pathParameters
96
88
  };
97
89
  }
@@ -135,24 +127,11 @@ function legacyResultToResponse(result) {
135
127
  headers
136
128
  });
137
129
  }
138
- function toMultiValueQueryStringParameters(url) {
139
- const values = /* @__PURE__ */ new Map();
140
- for (const [name, value] of url.searchParams.entries()) {
141
- const existing = values.get(name) ?? [];
142
- existing.push(value);
143
- values.set(name, existing);
144
- }
145
- if (values.size === 0) {
146
- return null;
147
- }
148
- return Object.fromEntries(values.entries());
149
- }
150
130
  export {
151
131
  buildCedarContext,
152
132
  composeCedarMiddleware,
153
133
  createRouteManifest,
154
134
  legacyResultToResponse,
155
- noopAuthDecoder,
156
135
  requestToLegacyEvent,
157
136
  routeManifestToJSON,
158
137
  wrapLegacyHandler
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/api",
3
- "version": "5.0.6",
3
+ "version": "5.0.7-next.219",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -10,76 +10,52 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
- "import": {
13
+ "default": {
14
14
  "types": "./dist/index.d.ts",
15
15
  "default": "./dist/index.js"
16
- },
17
- "require": {
18
- "types": "./dist/cjs/index.d.ts",
19
- "default": "./dist/cjs/index.js"
20
16
  }
21
17
  },
22
18
  "./package.json": "./package.json",
23
19
  "./runtime": {
24
- "import": {
20
+ "default": {
25
21
  "types": "./dist/runtime.d.ts",
26
22
  "default": "./dist/runtime.js"
27
- },
28
- "require": {
29
- "types": "./dist/cjs/runtime.d.ts",
30
- "default": "./dist/cjs/runtime.js"
31
23
  }
32
24
  },
33
25
  "./auth": {
34
- "import": {
26
+ "default": {
35
27
  "types": "./dist/auth/index.d.ts",
36
28
  "default": "./dist/auth/index.js"
37
- },
38
- "require": {
39
- "types": "./dist/cjs/auth/index.d.ts",
40
- "default": "./dist/cjs/auth/index.js"
41
29
  }
42
30
  },
43
31
  "./cache": {
44
- "import": {
32
+ "default": {
45
33
  "types": "./dist/cache/index.d.ts",
46
34
  "default": "./dist/cache/index.js"
47
- },
48
- "require": {
49
- "types": "./dist/cjs/cache/index.d.ts",
50
- "default": "./dist/cjs/cache/index.js"
51
35
  }
52
36
  },
53
37
  "./logger": {
54
- "import": {
38
+ "default": {
55
39
  "types": "./dist/logger/index.d.ts",
56
40
  "default": "./dist/logger/index.js"
57
- },
58
- "require": {
59
- "types": "./dist/cjs/logger/index.d.ts",
60
- "default": "./dist/cjs/logger/index.js"
61
41
  }
62
42
  },
63
43
  "./webhooks": {
64
- "import": {
44
+ "default": {
65
45
  "types": "./dist/webhooks/index.d.ts",
66
46
  "default": "./dist/webhooks/index.js"
67
- },
68
- "require": {
69
- "types": "./dist/cjs/webhooks/index.d.ts",
70
- "default": "./dist/cjs/webhooks/index.js"
71
47
  }
72
48
  }
73
49
  },
74
50
  "main": "./dist/index.js",
75
51
  "types": "./dist/index.d.ts",
76
52
  "bin": {
77
- "cedar": "./dist/cjs/bins/cedar.js",
78
- "cedarjs": "./dist/cjs/bins/cedar.js",
79
- "cfw": "./dist/cjs/bins/cfw.js",
80
- "redwood": "./dist/cjs/bins/redwood.js",
81
- "rw": "./dist/cjs/bins/redwood.js",
82
- "tsc": "./dist/cjs/bins/tsc.js"
53
+ "cedar": "./dist/bins/cedar.js",
54
+ "cedarjs": "./dist/bins/cedar.js",
55
+ "cfw": "./dist/bins/cfw.js",
56
+ "redwood": "./dist/bins/redwood.js",
57
+ "rw": "./dist/bins/redwood.js",
58
+ "tsc": "./dist/bins/tsc.js"
83
59
  },
84
60
  "files": [
85
61
  "dist/",
@@ -88,7 +64,7 @@
88
64
  "scripts": {
89
65
  "build": "node ./build.mts && yarn build:types",
90
66
  "build:pack": "yarn pack -o cedarjs-api.tgz",
91
- "build:types": "tsc --build --verbose ./tsconfig.build.json ./tsconfig.cjs.json",
67
+ "build:types": "tsc --build --verbose ./tsconfig.build.json",
92
68
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
93
69
  "check:attw": "yarn cedar-fwtools-attw",
94
70
  "check:package": "concurrently npm:check:attw yarn:publint",
@@ -108,7 +84,7 @@
108
84
  "title-case": "3.0.3"
109
85
  },
110
86
  "devDependencies": {
111
- "@cedarjs/framework-tools": "5.0.6",
87
+ "@cedarjs/framework-tools": "5.0.7-next.219",
112
88
  "@types/aws-lambda": "8.10.162",
113
89
  "@types/jsonwebtoken": "9.0.10",
114
90
  "@types/memjs": "1",
@@ -116,12 +92,12 @@
116
92
  "@types/split2": "4.2.3",
117
93
  "concurrently": "9.2.4",
118
94
  "memjs": "1.3.2",
119
- "publint": "0.3.21",
95
+ "publint": "0.3.22",
120
96
  "redis": "5.12.1",
121
97
  "split2": "4.2.0",
122
98
  "ts-toolbelt": "9.6.0",
123
99
  "typescript": "5.9.3",
124
- "vitest": "3.2.6"
100
+ "vitest": "4.1.10"
125
101
  },
126
102
  "peerDependencies": {
127
103
  "memjs": "1.3.2",
@@ -1,64 +0,0 @@
1
- export * from './parseJWT.js';
2
- import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda';
3
- import type { Decoded } from './parseJWT.js';
4
- export type { Decoded };
5
- export declare const AUTH_PROVIDER_HEADER = "auth-provider";
6
- export declare const getAuthProviderHeader: (event: APIGatewayProxyEvent | Request) => string | undefined;
7
- export interface AuthorizationHeader {
8
- schema: 'Bearer' | 'Basic' | string;
9
- token: string;
10
- }
11
- export type AuthorizationCookies = {
12
- parsedCookie: Record<string, string | undefined>;
13
- rawCookie: string;
14
- type: string | undefined;
15
- } | null;
16
- export declare const parseAuthorizationCookie: (event: APIGatewayProxyEvent | Request) => AuthorizationCookies;
17
- /**
18
- * Split the `Authorization` header into a schema and token part.
19
- */
20
- export declare const parseAuthorizationHeader: (event: APIGatewayProxyEvent | Request) => AuthorizationHeader;
21
- /** @MARK Note that we do not send LambdaContext when making fetch requests
22
- *
23
- * This part is incomplete, as we need to decide how we will make the breaking change to
24
- * 1. getCurrentUser
25
- * 2. authDecoders
26
-
27
- */
28
- export type AuthContextPayload = [
29
- Decoded,
30
- {
31
- type: string;
32
- } & AuthorizationHeader,
33
- {
34
- /**
35
- * The Lambda-style event. On serverless deploys this is the canonical
36
- * request object; on fetch-native paths a synthetic one is provided for
37
- * backwards compatibility with existing `event.headers['key']` access.
38
- */
39
- event: APIGatewayProxyEvent | Request;
40
- /**
41
- * The native fetch `Request`, available on fetch-native paths. Prefer
42
- * this when available.
43
- * Do `request.headers.get('key')` to access headers
44
- */
45
- request?: Request;
46
- context?: LambdaContext;
47
- }
48
- ];
49
- export type Decoder = (token: string, type: string, req: {
50
- /** The Lambda-style request event */
51
- event: APIGatewayProxyEvent | Request;
52
- request?: Request;
53
- context?: LambdaContext;
54
- }) => Promise<Decoded>;
55
- /**
56
- * Get the authorization information from the request headers and request context.
57
- * @returns [decoded, { type, schema, token }, { event, context }]
58
- **/
59
- export declare const getAuthenticationContext: ({ authDecoder, event, context, }: {
60
- authDecoder?: Decoder | Decoder[];
61
- event: APIGatewayProxyEvent | Request;
62
- context?: LambdaContext;
63
- }) => Promise<undefined | AuthContextPayload>;
64
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","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,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KACE,OAAO,CAAC,OAAO,CAAC,CAAA;AAErB;;;IAGI;AACJ,eAAO,MAAM,wBAAwB,GAAU,kCAI5C;IACD,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAA;IACjC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KAAG,OAAO,CAAC,SAAS,GAAG,kBAAkB,CA0EzC,CAAA"}
@@ -1,143 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var auth_exports = {};
31
- __export(auth_exports, {
32
- AUTH_PROVIDER_HEADER: () => AUTH_PROVIDER_HEADER,
33
- getAuthProviderHeader: () => getAuthProviderHeader,
34
- getAuthenticationContext: () => getAuthenticationContext,
35
- parseAuthorizationCookie: () => parseAuthorizationCookie,
36
- parseAuthorizationHeader: () => parseAuthorizationHeader
37
- });
38
- module.exports = __toCommonJS(auth_exports);
39
- __reExport(auth_exports, require("./parseJWT.js"), module.exports);
40
- var cookie = __toESM(require("cookie"), 1);
41
- var import_event = require("../event.js");
42
- var import_transforms = require("../transforms.js");
43
- const AUTH_PROVIDER_HEADER = "auth-provider";
44
- const getAuthProviderHeader = (event) => {
45
- if ((0, import_transforms.isFetchApiRequest)(event)) {
46
- return event.headers.get(AUTH_PROVIDER_HEADER) ?? void 0;
47
- }
48
- const authProviderKey = Object.keys(event.headers ?? {}).find(
49
- (key) => key.toLowerCase() === AUTH_PROVIDER_HEADER
50
- );
51
- if (authProviderKey) {
52
- return event.headers[authProviderKey];
53
- }
54
- return void 0;
55
- };
56
- const parseAuthorizationCookie = (event) => {
57
- const cookieHeader = (0, import_event.getEventHeader)(event, "Cookie");
58
- if (!cookieHeader) {
59
- return null;
60
- }
61
- const parsedCookie = cookie.parse(cookieHeader);
62
- return {
63
- parsedCookie,
64
- rawCookie: cookieHeader,
65
- // When not unauthenticated, this will be null/undefined
66
- // Remember that the cookie header could contain other (unrelated) values!
67
- type: parsedCookie[AUTH_PROVIDER_HEADER]
68
- };
69
- };
70
- const parseAuthorizationHeader = (event) => {
71
- const parts = (0, import_event.getEventHeader)(event, "Authorization")?.split(" ");
72
- if (parts?.length !== 2) {
73
- throw new Error("The `Authorization` header is not valid.");
74
- }
75
- const [schema, token] = parts;
76
- if (!schema.length || !token.length) {
77
- throw new Error("The `Authorization` header is not valid.");
78
- }
79
- return { schema, token };
80
- };
81
- const getAuthenticationContext = async ({
82
- authDecoder,
83
- event,
84
- context
85
- }) => {
86
- const cookieHeader = parseAuthorizationCookie(event);
87
- const typeFromHeader = getAuthProviderHeader(event);
88
- if (!typeFromHeader && !cookieHeader) {
89
- return void 0;
90
- }
91
- let token;
92
- let type;
93
- let schema;
94
- if (cookieHeader?.type) {
95
- token = cookieHeader.rawCookie;
96
- type = cookieHeader.type;
97
- schema = "cookie";
98
- } else if (typeFromHeader) {
99
- const parsedAuthHeader = parseAuthorizationHeader(event);
100
- token = parsedAuthHeader.token;
101
- type = typeFromHeader;
102
- schema = parsedAuthHeader.schema;
103
- }
104
- if (!token || !type || !schema) {
105
- return void 0;
106
- }
107
- let authDecoders = [];
108
- if (Array.isArray(authDecoder)) {
109
- authDecoders = authDecoder;
110
- } else if (authDecoder) {
111
- authDecoders = [authDecoder];
112
- }
113
- let decoded = null;
114
- const normalizedEvent = (0, import_transforms.isFetchApiRequest)(event) ? await (0, import_transforms.requestToBaseEvent)(event) : event;
115
- const underlyingRequest = (0, import_transforms.isFetchApiRequest)(event) ? event : void 0;
116
- let i = 0;
117
- while (!decoded && i < authDecoders.length) {
118
- decoded = await authDecoders[i](token, type, {
119
- event: normalizedEvent,
120
- request: underlyingRequest,
121
- context
122
- });
123
- i++;
124
- }
125
- return [
126
- decoded,
127
- { type, schema, token },
128
- {
129
- event: normalizedEvent,
130
- request: underlyingRequest,
131
- context
132
- }
133
- ];
134
- };
135
- // Annotate the CommonJS export names for ESM import in node:
136
- 0 && (module.exports = {
137
- AUTH_PROVIDER_HEADER,
138
- getAuthProviderHeader,
139
- getAuthenticationContext,
140
- parseAuthorizationCookie,
141
- parseAuthorizationHeader,
142
- ...require("./parseJWT.js")
143
- });