All files Widget.svelte

100% Statements 15/15
100% Branches 3/3
75% Functions 3/4
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                                  1x 1x       5x   5x   9x   5x   8x 4x 8x     4x 4x     6x           4x   4x                                    
<!--
  @component
 
  foo bar
-->
<script lang="ts">
  /*
   * mCaptcha is a PoW based DoS protection software.
   * This is the frontend web component of the mCaptcha system
   * Copyright © 2021 Aravinth Manivnanan <realaravinth@batsense.net>.
   *
   * Use of this source code is governed by Apache 2.0 or MIT license.
   * You shoud have received a copy of MIT and Apache 2.0 along with
   * this program. If not, see <https://spdx.org/licenses/MIT.html> for
   * MIT or <http://www.apache.org/licenses/LICENSE-2.0> for Apache.
   */
 
	import { onMount, onDestroy } from 'svelte';
	import {default as CoreWidget} from '@mcaptcha/core-glue';
	import {WidgetConfig, INPUT_NAME} from '@mcaptcha/core-glue';
 
	//export const ssr = false;
	export let config: WidgetConfig;
 
	let token = '';
 
	const setToken = (t: string) => (token = t);
 
	const w = new CoreWidget(config, setToken);
 
	onMount(() => w.listen());
	const cleanup = (): void => w.destroy();
	onDestroy(() => cleanup);
</script>
 
<div class="mcaptcha__widget-container">
	<input
		id="mcaptcha__token"
		name="mcaptcha__token"
		value={token}
		readonly
		hidden
		required
		type="text"
	/>
	<iframe
		title="mCaptcha"
		src={w.widgetLink.toString()}
		role="presentation"
		name="mcaptcha-widget__iframe"
		id="mcaptcha-widget__iframe"
		scrolling="no"
		sandbox="allow-same-origin allow-scripts"
		width="304"
		height="78"
		frameBorder="0"
	/>
</div>
 
<style>
	.mcaptcha__widget-container {
		width: 340px;
		height: 78px;
	}
</style>