@cedarjs/graphql-server 6.0.0-canary.2813 → 6.0.0-canary.2815

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 +1 @@
1
- {"version":3,"file":"useRedwoodAuthContext.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodAuthContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAsB,OAAO,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,gBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EACvD,cAAc,OAAO,GAAG,OAAO,EAAE,KAChC,MAAM,CAAC,mBAAmB,CAyC5B,CAAA"}
1
+ {"version":3,"file":"useRedwoodAuthContext.d.ts","sourceRoot":"","sources":["../../src/plugins/useRedwoodAuthContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAsB,OAAO,EAAE,MAAM,cAAc,CAAA;AAG/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,gBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EACvD,cAAc,OAAO,GAAG,OAAO,EAAE,KAChC,MAAM,CAAC,mBAAmB,CA2C5B,CAAA"}
@@ -1,22 +1,13 @@
1
- import { getAuthenticationContext } from "@cedarjs/api";
1
+ import { hasAuthDecoder } from "@cedarjs/api";
2
2
  const useRedwoodAuthContext = (getCurrentUser, authDecoder) => {
3
3
  return {
4
4
  async onContextBuilding({ context, extendContext }) {
5
- let authContext = context.cedarContext?.serverAuthState;
6
- try {
7
- if (!authContext) {
8
- const authEvent = getAuthEvent(context);
9
- authContext = await getAuthenticationContext({
10
- authDecoder,
11
- event: authEvent,
12
- context: context.requestContext
13
- });
14
- }
15
- } catch (error) {
5
+ if (!context.cedarContext && hasAuthDecoder(authDecoder)) {
16
6
  throw new Error(
17
- `Exception in getAuthenticationContext: ${error.message}`
7
+ "Auth state is resolved when a request enters Cedar and passed on the GraphQL context, but this context has no `cedarContext`. Whatever is invoking `yoga.handle` needs to build one with `buildCedarContext` from `@cedarjs/api/runtime` and pass it as `cedarContext`."
18
8
  );
19
9
  }
10
+ const authContext = context.cedarContext?.serverAuthState;
20
11
  try {
21
12
  if (authContext) {
22
13
  const currentUser = getCurrentUser ? await getCurrentUser(
@@ -34,17 +25,6 @@ const useRedwoodAuthContext = (getCurrentUser, authDecoder) => {
34
25
  }
35
26
  };
36
27
  };
37
- function getAuthEvent(context) {
38
- if (context.request) {
39
- return context.request;
40
- }
41
- if (context.event) {
42
- return context.event;
43
- }
44
- throw new Error(
45
- "GraphQL context contains neither a fetch-native Request nor a Lambda event. Please report this as a Cedar bug."
46
- );
47
- }
48
28
  export {
49
29
  useRedwoodAuthContext
50
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/graphql-server",
3
- "version": "6.0.0-canary.2813",
3
+ "version": "6.0.0-canary.2815",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -32,8 +32,8 @@
32
32
  "test:watch": "yarn test --watch"
33
33
  },
34
34
  "dependencies": {
35
- "@cedarjs/api": "6.0.0-canary.2813",
36
- "@cedarjs/context": "6.0.0-canary.2813",
35
+ "@cedarjs/api": "6.0.0-canary.2815",
36
+ "@cedarjs/context": "6.0.0-canary.2815",
37
37
  "@envelop/core": "5.5.1",
38
38
  "@envelop/depth-limit": "4.0.0",
39
39
  "@envelop/disable-introspection": "6.0.0",
@@ -56,9 +56,9 @@
56
56
  "devDependencies": {
57
57
  "@babel/cli": "7.29.7",
58
58
  "@babel/core": "^7.26.10",
59
- "@cedarjs/framework-tools": "6.0.0-canary.2813",
60
- "@cedarjs/project-config": "6.0.0-canary.2813",
61
- "@cedarjs/realtime": "6.0.0-canary.2813",
59
+ "@cedarjs/framework-tools": "6.0.0-canary.2815",
60
+ "@cedarjs/project-config": "6.0.0-canary.2815",
61
+ "@cedarjs/realtime": "6.0.0-canary.2815",
62
62
  "@envelop/types": "5.2.1",
63
63
  "@types/aws-lambda": "8.10.162",
64
64
  "@types/jsonwebtoken": "9.0.10",