Coder Social home page Coder Social logo

basaran / svelte-recaptcha-v2 Goto Github PK

View Code? Open in Web Editor NEW
42.0 42.0 15.0 598 KB

Google reCAPTCHA v2 implementation for Svelte SPA, SSR and sveltekit static sites.

Home Page: https://basaran.github.io/svelte-recaptcha-v2/demo

License: MIT License

JavaScript 20.70% Svelte 79.30%
recaptcha ssr svelte sveltekit

svelte-recaptcha-v2's People

Contributors

basaran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

svelte-recaptcha-v2's Issues

CORS Issue with the re-captcha

Hello!

Having some issues using the re-captcha in my svelte app. I manage to get the ready state to fire, but then all I get is this error:

caught DOMException: Blocked a frame with origin "https://www.google.com" from accessing a cross-origin frame.
    at Ci.Yy.w8 (https://www.gstatic.com/recaptcha/releases/85AXn53af-oJBEtL2o2WpAjZ/recaptcha__en.js:721:217)
    at Array.<anonymous> (https://www.gstatic.com/recaptcha/releases/85AXn53af-oJBEtL2o2WpAjZ/recaptcha__en.js:40:284)
    at Object.init (https://www.gstatic.com/recaptcha/releases/85AXn53af-oJBEtL2o2WpAjZ/recaptcha__en.js:730:258)
    at https://www.google.com/recaptcha/api2/bframe?hl=en&v=85AXn53af-oJBEtL2o2WpAjZ&k=6LfetkseAAAAAM2BZdN4nLPitmM3skOeY9_jkqyq:184:30

Has anyone seen this before? I've tried adding the captcha as a div I render on it's own but I get the same issue in the end.

Does it need to be hosted on a web server rather than just localhost? Not sure why it would work for others.

Can you provide Typescript types?

My project uses Typescript, and I would love to fully use this package, however, since my project uses Typescript, I cannot fully use it. I may try to write my own type declarations, and submit a pull request, but for now, I won't. This would really help me and others who need Typescript support. I can, for now, just do this in my .d.ts file:

declare module "svelte-recaptcha-v2"

so Typescript will work, however, this does not provide the error catching and intelisense that full Typescript supports.

Score of 0.000

When verifying the token given through this package i get 0.00 ranking, anyone have a solution?

Thank you

ReferenceError: module is not defined

First of all thank you making it easier to integrate ReCAPTCHA! :)

I'm using the latest version of sveltekit (SvelteKit v1.0.0-next.203) and just followed your instructions in the README one-by-one.

When I start the dev environment with npm run dev -- --open, I run into the error message below and the page won't get loaded at all.

My svelte.config.js looks like this:

import adapter from '@sveltejs/adapter-static';
import sveltePreprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
	preprocess: sveltePreprocess(),
	kit: {
		adapter: adapter({
			// default options are shown
			pages: 'build',
			assets: 'build',
			fallback: null,
			precompress: false
		}),
		// hydrate the <div id="svelte"> element in src/app.html
		target: '#svelte'
	}
};

export default config;

Error Message

[vite] Error when evaluating SSR module /node_modules/debug/src/index.js?v=338ddabd:
ReferenceError: module is not defined
    at /node_modules/debug/src/index.js?v=338ddabd:9:2
    at instantiateModule (/Users/**********/node_modules/vite/dist/node/chunks/dep-24a6b4c4.js:60096:15)

Do you know what the problem is? I don't even need SSR, it will be just a static page, but since the features even state 'svelte server side rendering (SSR) friendly', I guess I'm doing something wrong? ๐Ÿ˜…

Debug/Browser.js does not provide an export named 'default'

I am having the below error while doing import { Recaptcha, recaptcha, observer } from "svelte-recaptcha-v2";

SyntaxError: The requested module '/node_modules/debug/src/browser.js?v=9e58a267' does not provide an export named 'default'

I am using:

"@sveltejs/kit": "^1.0.0-next.221"
"@sveltejs/adapter-node": "^1.0.0-next.55"
"svelte-recaptcha-v2": "^0.0.2"

Unexpected Token error when importing module

After importing the module with the line:
import { Recaptcha, recaptcha, observer } from "svelte-recaptcha-v2";

I immediately get the following build error when compiling:

[!] Error: Unexpected token
node_modules/svelte-recaptcha-v2/node_modules/debug/src/browser.js (119:45)
117:   // initialized. Since we know we're in Chrome, we'll just detect this case
118:   // explicitly
119:   if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
                                                   ^
120:     return true;
121:   }
Error: Unexpected token
    at error (/home/node/app/node_modules/rollup/dist/shared/node-entry.js:5400:30)
    at Module.error (/home/node/app/node_modules/rollup/dist/shared/node-entry.js:9824:16)
    at tryParse (/home/node/app/node_modules/rollup/dist/shared/node-entry.js:9717:23)
    at Module.setSource (/home/node/app/node_modules/rollup/dist/shared/node-entry.js:10080:33)
    at /home/node/app/node_modules/rollup/dist/shared/node-entry.js:12366:20
    at async Promise.all (index 3)
    at async Promise.all (index 0)
    at async Promise.all (index 3)
    at async Promise.all (index 12)
    at async Promise.all (index 2)`

Let me know if there's any other details I should give to be more helpful :)

userTracker.resolve(event);

what is the userTracker ? it is undefined for me. Also do i need a v2 key ? where would i use the secret key ? does it work with enterprise key too ?

Use NPM instead of PNPM

Would you mind moving svelte-recaptcha-v2 to NPM instead of PNPM?

Most people use NPM and I had lots of trouble with PNPM (pnpm/pnpm#724 (comment)), that's why I'm unable to use svelte-recaptcha-v2, even though the project looks great and I'd really like to use it.

Please consider it. Thank you.

Uncaught Error: reCAPTCHA placeholder element must be an element or id

Seeing the above error when trying to add:

<Recaptcha sitekey={recaptchatoken}
             badge={"inline"}
             size={"normal"}
             on:success={onCaptchaSuccess}
             on:error={onCaptchaError}
             on:expired={onCaptchaExpire}
             on:close={onCaptchaClose}
             on:ready={onCaptchaReady} />

Does this need to sit inside of some placeholder div? If so what id/class is required?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.