@graphcommerce/googlerecaptcha 10.0.0-canary.67 → 10.0.0-canary.72
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 +14 -0
- package/link/recaptchaLink.ts +11 -11
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.0.0-canary.72
|
|
4
|
+
|
|
5
|
+
## 10.0.0-canary.71
|
|
6
|
+
|
|
7
|
+
## 10.0.0-canary.70
|
|
8
|
+
|
|
9
|
+
### Major Changes
|
|
10
|
+
|
|
11
|
+
- [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
|
|
12
|
+
|
|
13
|
+
## 10.0.0-canary.69
|
|
14
|
+
|
|
15
|
+
## 10.0.0-canary.68
|
|
16
|
+
|
|
3
17
|
## 10.0.0-canary.67
|
|
4
18
|
|
|
5
19
|
## 10.0.0-canary.66
|
package/link/recaptchaLink.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { ApolloLink } from '@graphcommerce/graphql'
|
|
2
|
+
import { SetContextLink } from '@graphcommerce/graphql/apollo'
|
|
3
3
|
import { Kind, OperationTypeNode } from 'graphql'
|
|
4
4
|
import { RecaptchaV3ConfigDocument } from '../graphql'
|
|
5
5
|
|
|
6
|
-
const isMutation = (operation:
|
|
6
|
+
const isMutation = (operation: ApolloLink.Request) =>
|
|
7
7
|
operation.query.definitions.some(
|
|
8
8
|
(definition) =>
|
|
9
9
|
definition.kind === Kind.OPERATION_DEFINITION &&
|
|
@@ -11,11 +11,11 @@ const isMutation = (operation: GraphQLRequest) =>
|
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
/** Apollo link that adds the Google reCAPTCHA token to the request context. */
|
|
14
|
-
export const recaptchaLink =
|
|
15
|
-
const siteKey =
|
|
16
|
-
?.website_key
|
|
14
|
+
export const recaptchaLink = new SetContextLink(async (prevContext, operation) => {
|
|
15
|
+
const siteKey = prevContext.cache?.readQuery({ query: RecaptchaV3ConfigDocument })
|
|
16
|
+
?.recaptchaV3Config?.website_key
|
|
17
17
|
|
|
18
|
-
if (!siteKey || !globalThis.grecaptcha || !isMutation(operation)) return
|
|
18
|
+
if (!siteKey || !globalThis.grecaptcha || !isMutation(operation)) return {}
|
|
19
19
|
|
|
20
20
|
await new Promise<void>((resolve) => {
|
|
21
21
|
globalThis.grecaptcha?.ready(resolve)
|
|
@@ -35,10 +35,10 @@ export const recaptchaLink = setContext(async (operation, context) => {
|
|
|
35
35
|
|
|
36
36
|
if (!token) {
|
|
37
37
|
console.error('Failed to get reCAPTCHA token after 5 attempts')
|
|
38
|
-
return
|
|
38
|
+
return prevContext
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
return {
|
|
42
|
+
headers: { ...prevContext.headers, 'X-ReCaptcha': token },
|
|
43
|
+
}
|
|
44
44
|
})
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/googlerecaptcha",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "10.0.0-canary.
|
|
5
|
+
"version": "10.0.0-canary.72",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"@types/grecaptcha": "^3.0.9"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.
|
|
27
|
-
"@graphcommerce/graphql": "^10.0.0-canary.
|
|
28
|
-
"@graphcommerce/graphql-mesh": "^10.0.0-canary.
|
|
29
|
-
"@graphcommerce/magento-store": "^10.0.0-canary.
|
|
30
|
-
"@graphcommerce/next-ui": "^10.0.0-canary.
|
|
31
|
-
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.
|
|
32
|
-
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.
|
|
33
|
-
"@mui/material": "^
|
|
26
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.72",
|
|
27
|
+
"@graphcommerce/graphql": "^10.0.0-canary.72",
|
|
28
|
+
"@graphcommerce/graphql-mesh": "^10.0.0-canary.72",
|
|
29
|
+
"@graphcommerce/magento-store": "^10.0.0-canary.72",
|
|
30
|
+
"@graphcommerce/next-ui": "^10.0.0-canary.72",
|
|
31
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.72",
|
|
32
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.72",
|
|
33
|
+
"@mui/material": "^7.0.0",
|
|
34
34
|
"graphql": "^16.9.0",
|
|
35
35
|
"next": "*",
|
|
36
36
|
"react": "^19.2.0",
|