@owlmeans/web-captcha-recaptcha 0.0.0-stage → 0.2.0-alpha.0

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 (49) hide show
  1. package/README.md +80 -2
  2. package/agent-meta/manifest.json +16 -0
  3. package/agent-meta/skills/web-captcha-recaptcha/SKILL.md +78 -0
  4. package/build/append.d.ts +8 -0
  5. package/build/append.d.ts.map +1 -0
  6. package/build/append.js +8 -0
  7. package/build/append.js.map +1 -0
  8. package/build/client.d.ts +8 -0
  9. package/build/client.d.ts.map +1 -0
  10. package/build/client.js +20 -0
  11. package/build/client.js.map +1 -0
  12. package/build/consts.d.ts +34 -0
  13. package/build/consts.d.ts.map +1 -0
  14. package/build/consts.js +76 -0
  15. package/build/consts.js.map +1 -0
  16. package/build/index.d.ts +6 -0
  17. package/build/index.d.ts.map +1 -0
  18. package/build/index.js +5 -0
  19. package/build/index.js.map +1 -0
  20. package/build/loader.d.ts +9 -0
  21. package/build/loader.d.ts.map +1 -0
  22. package/build/loader.js +105 -0
  23. package/build/loader.js.map +1 -0
  24. package/build/react/checkbox.d.ts +8 -0
  25. package/build/react/checkbox.d.ts.map +1 -0
  26. package/build/react/checkbox.js +9 -0
  27. package/build/react/checkbox.js.map +1 -0
  28. package/build/react.d.ts +2 -0
  29. package/build/react.d.ts.map +1 -0
  30. package/build/react.js +2 -0
  31. package/build/react.js.map +1 -0
  32. package/build/types.d.ts +58 -0
  33. package/build/types.d.ts.map +1 -0
  34. package/build/types.js +2 -0
  35. package/build/types.js.map +1 -0
  36. package/package.json +58 -4
  37. package/src/append.ts +12 -0
  38. package/src/client.ts +22 -0
  39. package/src/consts.ts +87 -0
  40. package/src/index.ts +5 -0
  41. package/src/loader.ts +123 -0
  42. package/src/react/checkbox.tsx +17 -0
  43. package/src/react.ts +1 -0
  44. package/src/types.ts +60 -0
  45. package/tests/client.spec.ts +63 -0
  46. package/tests/context.ts +73 -0
  47. package/tests/loader.spec.ts +120 -0
  48. package/tests/react.spec.ts +36 -0
  49. package/tsconfig.json +16 -0
@@ -0,0 +1,36 @@
1
+ import { describe, expect, test } from 'bun:test'
2
+ import type { ReactElement } from 'react'
3
+ import ReCAPTCHA from 'react-google-recaptcha'
4
+ import { RecaptchaCheckbox } from '../src/react.js'
5
+
6
+ interface CheckboxProps {
7
+ sitekey: string
8
+ hl?: string
9
+ onChange: (token: string | null) => void
10
+ onExpired: () => void
11
+ onErrored: () => void
12
+ asyncScriptOnLoad: () => void
13
+ }
14
+
15
+ describe('@owlmeans/web-captcha-recaptcha/react — the v2 checkbox widget', () => {
16
+ test('renders Google\'s checkbox with the site key and reports tokens, expiry, readiness and errors', () => {
17
+ const tokens: (string | null)[] = []
18
+ const events: string[] = []
19
+ const element = (RecaptchaCheckbox as (props: unknown) => ReactElement<CheckboxProps>)({
20
+ siteKey: 'v2-key', language: 'pl',
21
+ onToken: (token: string | null) => { tokens.push(token) },
22
+ onReady: () => { events.push('ready') },
23
+ onError: (error: Error) => { events.push(error.message) },
24
+ })
25
+
26
+ expect(element.type).toBe(ReCAPTCHA)
27
+ expect(element.props.sitekey).toBe('v2-key')
28
+ expect(element.props.hl).toBe('pl')
29
+ element.props.onChange('token')
30
+ element.props.onExpired()
31
+ element.props.asyncScriptOnLoad()
32
+ element.props.onErrored()
33
+ expect(tokens).toEqual(['token', null])
34
+ expect(events).toEqual(['ready', 'reCAPTCHA could not load'])
35
+ })
36
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": [
3
+ "@owlmeans/dep-config/tsconfig.base.json",
4
+ "@owlmeans/dep-config/tsconfig.react.json"
5
+ ],
6
+ "compilerOptions": {
7
+ "rootDir": "./src/",
8
+ "outDir": "./build/"
9
+ },
10
+ "exclude": [
11
+ "./dist/**/*",
12
+ "./build/**/*",
13
+ "./tests/**/*",
14
+ "./*.ts"
15
+ ]
16
+ }