@cedarjs/graphql-server 5.0.7-next.258 → 5.0.7-next.310
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":"useCedarTrustedDocuments.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarTrustedDocuments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAA;AAC9F,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useCedarTrustedDocuments.d.ts","sourceRoot":"","sources":["../../src/plugins/useCedarTrustedDocuments.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2CAA2C,CAAA;AAC9F,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,cAAc,CAAA;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,6BAA6B,EAC7B,uBAAuB,CACxB,GAAG;IACF;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACzC,GAAG,CACE;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAChE,CAAA;AAEH,6DAA6D;AAC7D,MAAM,MAAM,6BAA6B,GAAG,2BAA2B,CAAA;AAuEvE,eAAO,MAAM,wBAAwB,GACnC,SAAS,2BAA2B,KACnC,MAAM,CAAC,mBAAmB,CAyD5B,CAAA"}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { usePersistedOperations } from "@graphql-yoga/plugin-persisted-operations";
|
|
2
|
-
const CEDAR__AUTH_GET_CURRENT_USER_QUERY =
|
|
3
|
-
const CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION =
|
|
4
|
-
const CEDAR__STUDIO_TEMPLATE_MUTATION =
|
|
5
|
-
const allowCedarAuthCurrentUserQuery =
|
|
2
|
+
const CEDAR__AUTH_GET_CURRENT_USER_QUERY = "query __CEDAR__AUTH_GET_CURRENT_USER { cedar { currentUser } }";
|
|
3
|
+
const CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION = "mutation { resyncMailRenderers }";
|
|
4
|
+
const CEDAR__STUDIO_TEMPLATE_MUTATION = "mutation { resyncMailTemplate }";
|
|
5
|
+
const allowCedarAuthCurrentUserQuery = (request, params) => {
|
|
6
6
|
const headers = request.headers;
|
|
7
7
|
const hasContentType = headers.get("content-type") === "application/json";
|
|
8
8
|
const hasAuthProvider = !!headers.get("auth-provider");
|
|
9
9
|
const hasAuthorization = !!headers.get("authorization");
|
|
10
10
|
const hasAllowedHeaders = hasContentType && hasAuthProvider && hasAuthorization;
|
|
11
|
-
const
|
|
12
|
-
const hasAllowedQuery = query === CEDAR__AUTH_GET_CURRENT_USER_QUERY;
|
|
11
|
+
const hasAllowedQuery = params?.query === CEDAR__AUTH_GET_CURRENT_USER_QUERY;
|
|
13
12
|
return hasAllowedHeaders && hasAllowedQuery;
|
|
14
13
|
};
|
|
15
|
-
const allowCedarStudioResyncMailMutations =
|
|
14
|
+
const allowCedarStudioResyncMailMutations = (request, params) => {
|
|
16
15
|
const isLocalDevelopment = process.env.NODE_ENV === "development";
|
|
17
16
|
if (!isLocalDevelopment) {
|
|
18
17
|
return false;
|
|
19
18
|
}
|
|
20
19
|
const headers = request.headers;
|
|
21
20
|
const hasContentType = headers.get("content-type") === "application/json";
|
|
22
|
-
const
|
|
23
|
-
const isAllowedQuery = query === CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION || query === CEDAR__STUDIO_TEMPLATE_MUTATION;
|
|
21
|
+
const isAllowedQuery = params?.query === CEDAR__STUDIO_RESYNC_MAIL_RENDERERS_MUTATION || params?.query === CEDAR__STUDIO_TEMPLATE_MUTATION;
|
|
24
22
|
return hasContentType && isAllowedQuery;
|
|
25
23
|
};
|
|
26
24
|
const useCedarTrustedDocuments = (options) => {
|
|
27
|
-
|
|
25
|
+
const paramsByRequest = /* @__PURE__ */ new WeakMap();
|
|
26
|
+
const persistedOperations = usePersistedOperations({
|
|
28
27
|
...options,
|
|
29
28
|
customErrors: {
|
|
30
29
|
persistedQueryOnly: "Use Trusted Only!",
|
|
@@ -47,9 +46,17 @@ const useCedarTrustedDocuments = (options) => {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
const params = paramsByRequest.get(request);
|
|
50
|
+
return allowCedarAuthCurrentUserQuery(request, params) || allowCedarStudioResyncMailMutations(request, params);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
+
return {
|
|
54
|
+
...persistedOperations,
|
|
55
|
+
onParams(payload) {
|
|
56
|
+
paramsByRequest.set(payload.request, payload.params);
|
|
57
|
+
return persistedOperations.onParams?.(payload);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
53
60
|
};
|
|
54
61
|
export {
|
|
55
62
|
useCedarTrustedDocuments
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/graphql-server",
|
|
3
|
-
"version": "5.0.7-next.
|
|
3
|
+
"version": "5.0.7-next.310",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -32,29 +32,29 @@
|
|
|
32
32
|
"test:watch": "yarn test --watch"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@cedarjs/api": "5.0.7-next.
|
|
36
|
-
"@cedarjs/context": "5.0.7-next.
|
|
35
|
+
"@cedarjs/api": "5.0.7-next.310",
|
|
36
|
+
"@cedarjs/context": "5.0.7-next.310",
|
|
37
37
|
"@envelop/core": "5.5.1",
|
|
38
38
|
"@envelop/disable-introspection": "6.0.0",
|
|
39
39
|
"@envelop/filter-operation-type": "6.0.0",
|
|
40
40
|
"@envelop/on-resolve": "4.1.1",
|
|
41
41
|
"@escape.tech/graphql-armor": "3.0.1",
|
|
42
|
-
"@graphql-tools/merge": "9.2.
|
|
43
|
-
"@graphql-tools/schema": "10.0
|
|
42
|
+
"@graphql-tools/merge": "9.2.3",
|
|
43
|
+
"@graphql-tools/schema": "10.1.0",
|
|
44
44
|
"@graphql-tools/utils": "10.11.0",
|
|
45
|
-
"@graphql-yoga/plugin-persisted-operations": "3.21.
|
|
45
|
+
"@graphql-yoga/plugin-persisted-operations": "3.21.3",
|
|
46
46
|
"@opentelemetry/api": "1.9.1",
|
|
47
47
|
"cookie": "1.1.1",
|
|
48
48
|
"graphql": "16.14.2",
|
|
49
|
-
"graphql-scalars": "1.
|
|
49
|
+
"graphql-scalars": "1.26.0",
|
|
50
50
|
"graphql-tag": "2.12.6",
|
|
51
|
-
"graphql-yoga": "5.21.
|
|
51
|
+
"graphql-yoga": "5.21.3",
|
|
52
52
|
"lodash": "4.18.1",
|
|
53
53
|
"uuid": "11.1.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@cedarjs/framework-tools": "5.0.7-next.
|
|
57
|
-
"@cedarjs/realtime": "5.0.7-next.
|
|
56
|
+
"@cedarjs/framework-tools": "5.0.7-next.310",
|
|
57
|
+
"@cedarjs/realtime": "5.0.7-next.310",
|
|
58
58
|
"@envelop/types": "5.2.1",
|
|
59
59
|
"@escape.tech/graphql-armor-types": "0.7.0",
|
|
60
60
|
"@types/aws-lambda": "8.10.162",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/lodash": "4.17.25",
|
|
63
63
|
"@whatwg-node/promise-helpers": "^1.3.0",
|
|
64
64
|
"concurrently": "9.2.4",
|
|
65
|
-
"fastify": "5.
|
|
65
|
+
"fastify": "5.12.0",
|
|
66
66
|
"jsonwebtoken": "9.0.3",
|
|
67
67
|
"publint": "0.3.23",
|
|
68
68
|
"typescript": "5.9.3",
|