@graphql-mesh/hmac-upstream-signature 1.2.18 → 1.2.19-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19
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.
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +12 -8
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +12 -8
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# @graphql-mesh/hmac-upstream-signature
|
2
2
|
|
3
|
+
## 1.2.19-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- [#381](https://github.com/graphql-hive/gateway/pull/381) [`e31d79c`](https://github.com/graphql-hive/gateway/commit/e31d79c704014d5180074bdb3ce11dcd1675eb58) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
8
|
+
|
9
|
+
- Added dependency [`@graphql-tools/executor-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-tools/executor-common/v/workspace:^) (to `dependencies`)
|
10
|
+
- Removed dependency [`@graphql-mesh/transport-common@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-mesh/transport-common/v/workspace:^) (from `dependencies`)
|
11
|
+
|
12
|
+
- [#381](https://github.com/graphql-hive/gateway/pull/381) [`73dbe3a`](https://github.com/graphql-hive/gateway/commit/73dbe3a2dabb6b84105c4dac3586696daa3d4fcb) Thanks [@ardatan](https://github.com/ardatan)! - Like HMAC Upstream Signature plugin, different components of the gateway were using different ways of serializing the execution request.
|
13
|
+
Some of them were ignoring `variables` if it is empty, some of not, this was causing the signature generation to be different for the same query.
|
14
|
+
For example, it was working as expected in Proxy mode, but not working as expected in Federation Gateway mode.
|
15
|
+
|
16
|
+
With this change, now we have a shared helper to serialize the upstream execution request with a memoized `print` function for query AST etc to have a consistent serialization so consistent signature generation for HMAC.
|
17
|
+
|
18
|
+
- Updated dependencies [[`73dbe3a`](https://github.com/graphql-hive/gateway/commit/73dbe3a2dabb6b84105c4dac3586696daa3d4fcb)]:
|
19
|
+
- @graphql-tools/executor-common@0.0.1-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19
|
20
|
+
|
3
21
|
## 1.2.18
|
4
22
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var
|
3
|
+
var executorCommon = require('@graphql-tools/executor-common');
|
4
4
|
var utils = require('@graphql-tools/utils');
|
5
5
|
var jsonStableStringify = require('json-stable-stringify');
|
6
6
|
|
@@ -10,13 +10,17 @@ var jsonStableStringify__default = /*#__PURE__*/_interopDefault(jsonStableString
|
|
10
10
|
|
11
11
|
const DEFAULT_EXTENSION_NAME = "hmac-signature";
|
12
12
|
const DEFAULT_SHOULD_SIGN_FN = () => true;
|
13
|
-
const defaultExecutionRequestSerializer = (executionRequest) => jsonStableStringify__default.default(
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
const defaultExecutionRequestSerializer = (executionRequest) => jsonStableStringify__default.default(
|
14
|
+
executorCommon.serializeExecutionRequest({
|
15
|
+
executionRequest: {
|
16
|
+
document: executionRequest.document,
|
17
|
+
variables: executionRequest.variables
|
18
|
+
}
|
19
|
+
})
|
20
|
+
);
|
17
21
|
const defaultParamsSerializer = (params) => jsonStableStringify__default.default({
|
18
22
|
query: params.query,
|
19
|
-
variables: params.variables
|
23
|
+
variables: params.variables != null && Object.keys(params.variables).length > 0 ? params.variables : void 0
|
20
24
|
});
|
21
25
|
function createCryptoKey({
|
22
26
|
textEncoder,
|
@@ -40,7 +44,7 @@ function useHmacUpstreamSignature(options) {
|
|
40
44
|
}
|
41
45
|
const shouldSign = options.shouldSign || DEFAULT_SHOULD_SIGN_FN;
|
42
46
|
const extensionName = options.extensionName || DEFAULT_EXTENSION_NAME;
|
43
|
-
const
|
47
|
+
const serializeExecutionRequest2 = options.serializeExecutionRequest || defaultExecutionRequestSerializer;
|
44
48
|
let key$;
|
45
49
|
let fetchAPI;
|
46
50
|
let textEncoder;
|
@@ -69,7 +73,7 @@ function useHmacUpstreamSignature(options) {
|
|
69
73
|
});
|
70
74
|
return utils.mapMaybePromise(key$, async (key) => {
|
71
75
|
key$ = key;
|
72
|
-
const serializedExecutionRequest =
|
76
|
+
const serializedExecutionRequest = serializeExecutionRequest2(executionRequest);
|
73
77
|
const encodedContent = textEncoder.encode(serializedExecutionRequest);
|
74
78
|
const signature = await fetchAPI.crypto.subtle.sign(
|
75
79
|
"HMAC",
|
package/dist/index.d.cts
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
import { ExecutionRequest, Executor, ExecutionResult, MaybePromise, Maybe } from '@graphql-tools/utils';
|
2
2
|
import { Plugin, YogaInitialContext, GraphQLParams } from 'graphql-yoga';
|
3
|
-
import { TransportEntry } from '@graphql-mesh/transport-common';
|
4
|
-
import { Logger, OnFetchHook, MeshFetch, MeshPubSub, KeyValueCache } from '@graphql-mesh/types';
|
5
3
|
import { GraphQLSchema, FragmentDefinitionNode, FieldNode, GraphQLResolveInfo, SelectionSetNode, GraphQLOutputType, GraphQLFieldResolver, OperationTypeNode, GraphQLError, SelectionNode, ExecutionResult as ExecutionResult$1 } from 'graphql';
|
4
|
+
import { Logger, OnFetchHook, MeshFetch, MeshPubSub, KeyValueCache } from '@graphql-mesh/types';
|
6
5
|
import DataLoader from 'dataloader';
|
7
6
|
import { GraphQLResolveInfo as GraphQLResolveInfo$1, GraphQLOutputType as GraphQLOutputType$1 } from 'graphql/type';
|
8
7
|
|
8
|
+
interface TransportEntry<Options extends Record<string, any> = Record<string, any>> {
|
9
|
+
kind: string;
|
10
|
+
subgraph: string;
|
11
|
+
location?: string;
|
12
|
+
headers?: [string, string][];
|
13
|
+
options?: Options;
|
14
|
+
}
|
15
|
+
|
9
16
|
type SchemaTransform<TContext = Record<any, string>> = (originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, TContext>) => GraphQLSchema;
|
10
17
|
type RequestTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalRequest: ExecutionRequest, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionRequest;
|
11
18
|
type ResultTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalResult: ExecutionResult, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionResult;
|
package/dist/index.d.ts
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
import { ExecutionRequest, Executor, ExecutionResult, MaybePromise, Maybe } from '@graphql-tools/utils';
|
2
2
|
import { Plugin, YogaInitialContext, GraphQLParams } from 'graphql-yoga';
|
3
|
-
import { TransportEntry } from '@graphql-mesh/transport-common';
|
4
|
-
import { Logger, OnFetchHook, MeshFetch, MeshPubSub, KeyValueCache } from '@graphql-mesh/types';
|
5
3
|
import { GraphQLSchema, FragmentDefinitionNode, FieldNode, GraphQLResolveInfo, SelectionSetNode, GraphQLOutputType, GraphQLFieldResolver, OperationTypeNode, GraphQLError, SelectionNode, ExecutionResult as ExecutionResult$1 } from 'graphql';
|
4
|
+
import { Logger, OnFetchHook, MeshFetch, MeshPubSub, KeyValueCache } from '@graphql-mesh/types';
|
6
5
|
import DataLoader from 'dataloader';
|
7
6
|
import { GraphQLResolveInfo as GraphQLResolveInfo$1, GraphQLOutputType as GraphQLOutputType$1 } from 'graphql/type';
|
8
7
|
|
8
|
+
interface TransportEntry<Options extends Record<string, any> = Record<string, any>> {
|
9
|
+
kind: string;
|
10
|
+
subgraph: string;
|
11
|
+
location?: string;
|
12
|
+
headers?: [string, string][];
|
13
|
+
options?: Options;
|
14
|
+
}
|
15
|
+
|
9
16
|
type SchemaTransform<TContext = Record<any, string>> = (originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, TContext>) => GraphQLSchema;
|
10
17
|
type RequestTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalRequest: ExecutionRequest, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionRequest;
|
11
18
|
type ResultTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalResult: ExecutionResult, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionResult;
|
package/dist/index.js
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
-
import {
|
1
|
+
import { serializeExecutionRequest } from '@graphql-tools/executor-common';
|
2
2
|
import { mapMaybePromise } from '@graphql-tools/utils';
|
3
3
|
import jsonStableStringify from 'json-stable-stringify';
|
4
4
|
|
5
5
|
const DEFAULT_EXTENSION_NAME = "hmac-signature";
|
6
6
|
const DEFAULT_SHOULD_SIGN_FN = () => true;
|
7
|
-
const defaultExecutionRequestSerializer = (executionRequest) => jsonStableStringify(
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
const defaultExecutionRequestSerializer = (executionRequest) => jsonStableStringify(
|
8
|
+
serializeExecutionRequest({
|
9
|
+
executionRequest: {
|
10
|
+
document: executionRequest.document,
|
11
|
+
variables: executionRequest.variables
|
12
|
+
}
|
13
|
+
})
|
14
|
+
);
|
11
15
|
const defaultParamsSerializer = (params) => jsonStableStringify({
|
12
16
|
query: params.query,
|
13
|
-
variables: params.variables
|
17
|
+
variables: params.variables != null && Object.keys(params.variables).length > 0 ? params.variables : void 0
|
14
18
|
});
|
15
19
|
function createCryptoKey({
|
16
20
|
textEncoder,
|
@@ -34,7 +38,7 @@ function useHmacUpstreamSignature(options) {
|
|
34
38
|
}
|
35
39
|
const shouldSign = options.shouldSign || DEFAULT_SHOULD_SIGN_FN;
|
36
40
|
const extensionName = options.extensionName || DEFAULT_EXTENSION_NAME;
|
37
|
-
const
|
41
|
+
const serializeExecutionRequest2 = options.serializeExecutionRequest || defaultExecutionRequestSerializer;
|
38
42
|
let key$;
|
39
43
|
let fetchAPI;
|
40
44
|
let textEncoder;
|
@@ -63,7 +67,7 @@ function useHmacUpstreamSignature(options) {
|
|
63
67
|
});
|
64
68
|
return mapMaybePromise(key$, async (key) => {
|
65
69
|
key$ = key;
|
66
|
-
const serializedExecutionRequest =
|
70
|
+
const serializedExecutionRequest = serializeExecutionRequest2(executionRequest);
|
67
71
|
const encodedContent = textEncoder.encode(serializedExecutionRequest);
|
68
72
|
const signature = await fetchAPI.crypto.subtle.sign(
|
69
73
|
"HMAC",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-mesh/hmac-upstream-signature",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.19-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19",
|
4
4
|
"type": "module",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -43,15 +43,15 @@
|
|
43
43
|
},
|
44
44
|
"dependencies": {
|
45
45
|
"@graphql-mesh/cross-helpers": "^0.4.9",
|
46
|
-
"@graphql-mesh/transport-common": "^0.7.24",
|
47
46
|
"@graphql-mesh/types": "^0.103.6",
|
48
47
|
"@graphql-mesh/utils": "^0.103.6",
|
48
|
+
"@graphql-tools/executor-common": "0.0.1-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19",
|
49
49
|
"@graphql-tools/utils": "^10.7.0",
|
50
50
|
"json-stable-stringify": "^1.1.1",
|
51
51
|
"tslib": "^2.8.1"
|
52
52
|
},
|
53
53
|
"devDependencies": {
|
54
|
-
"@graphql-hive/gateway": "1.7.
|
54
|
+
"@graphql-hive/gateway": "1.7.4-alpha-3df7faeea69a8bf7e4423f5661c1cb8974232f19",
|
55
55
|
"@types/json-stable-stringify": "^1.1.0",
|
56
56
|
"graphql": "^16.9.0",
|
57
57
|
"graphql-yoga": "^5.10.6",
|