@prosopo/procaptcha-icon-order 0.0.0-stage → 0.2.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.
- package/.turbo/turbo-build$colon$cjs.log +52 -0
- package/.turbo/turbo-build$colon$tsc.log +53 -0
- package/.turbo/turbo-build.log +54 -0
- package/CHANGELOG.md +36 -0
- package/LICENSE +201 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/components/iconOrderCanvas.cjs +321 -0
- package/dist/cjs/components/procaptchaIconOrder.cjs +7 -0
- package/dist/cjs/components/procaptchaWidget.cjs +198 -0
- package/dist/cjs/index.cjs +8 -0
- package/dist/cjs/services/Manager.cjs +207 -0
- package/dist/components/iconOrderCanvas.d.ts +20 -0
- package/dist/components/iconOrderCanvas.d.ts.map +1 -0
- package/dist/components/iconOrderCanvas.js +321 -0
- package/dist/components/iconOrderCanvas.js.map +1 -0
- package/dist/components/procaptchaIconOrder.d.ts +7 -0
- package/dist/components/procaptchaIconOrder.d.ts.map +1 -0
- package/dist/components/procaptchaIconOrder.js +6 -0
- package/dist/components/procaptchaIconOrder.js.map +1 -0
- package/dist/components/procaptchaWidget.d.ts +7 -0
- package/dist/components/procaptchaWidget.d.ts.map +1 -0
- package/dist/components/procaptchaWidget.js +198 -0
- package/dist/components/procaptchaWidget.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/services/Manager.d.ts +10 -0
- package/dist/services/Manager.d.ts.map +1 -0
- package/dist/services/Manager.js +206 -0
- package/dist/services/Manager.js.map +1 -0
- package/dist/tests/domHarness.d.ts +20 -0
- package/dist/tests/domHarness.d.ts.map +1 -0
- package/dist/tests/domHarness.js +56 -0
- package/dist/tests/domHarness.js.map +1 -0
- package/dist/tests/iconOrderCanvas.unit.test.d.ts +2 -0
- package/dist/tests/iconOrderCanvas.unit.test.d.ts.map +1 -0
- package/dist/tests/iconOrderCanvas.unit.test.js +415 -0
- package/dist/tests/iconOrderCanvas.unit.test.js.map +1 -0
- package/dist/tests/invisibleCanvasVisibility.unit.test.d.ts +2 -0
- package/dist/tests/invisibleCanvasVisibility.unit.test.d.ts.map +1 -0
- package/dist/tests/invisibleCanvasVisibility.unit.test.js +101 -0
- package/dist/tests/invisibleCanvasVisibility.unit.test.js.map +1 -0
- package/dist/tests/manager.unit.test.d.ts +2 -0
- package/dist/tests/manager.unit.test.d.ts.map +1 -0
- package/dist/tests/manager.unit.test.js +566 -0
- package/dist/tests/manager.unit.test.js.map +1 -0
- package/dist/tests/managerHarness.d.ts +21 -0
- package/dist/tests/managerHarness.d.ts.map +1 -0
- package/dist/tests/managerHarness.js +72 -0
- package/dist/tests/managerHarness.js.map +1 -0
- package/dist/tests/procaptchaIconOrder.test-d.d.ts +2 -0
- package/dist/tests/procaptchaIconOrder.test-d.d.ts.map +1 -0
- package/dist/tests/procaptchaIconOrder.test-d.js +102 -0
- package/dist/tests/procaptchaIconOrder.test-d.js.map +1 -0
- package/dist/tests/procaptchaIconOrder.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaIconOrder.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaIconOrder.unit.test.js +92 -0
- package/dist/tests/procaptchaIconOrder.unit.test.js.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.js +607 -0
- package/dist/tests/procaptchaWidget.unit.test.js.map +1 -0
- package/package.json +70 -3
- package/vite.cjs.config.ts +22 -0
- package/vite.esm.config.ts +20 -0
- package/vite.test.config.ts +26 -0
- package/README.md +0 -3
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
|
|
2
|
+
let _prosopo_types = require("@prosopo/types");
|
|
3
|
+
let _polkadot_util_string = require("@polkadot/util/string");
|
|
4
|
+
let _prosopo_api = require("@prosopo/api");
|
|
5
|
+
let _prosopo_common = require("@prosopo/common");
|
|
6
|
+
let _prosopo_util = require("@prosopo/util");
|
|
7
|
+
let _prosopo_util_crypto = require("@prosopo/util-crypto");
|
|
8
|
+
//#region src/services/Manager.ts
|
|
9
|
+
var Manager = (configInput, state, onStateUpdate, callbacks, frictionlessState, getHoneypotValue) => {
|
|
10
|
+
const events = (0, _prosopo_procaptcha_common.getDefaultEvents)(callbacks);
|
|
11
|
+
let storedChallengeResponse;
|
|
12
|
+
let storedProviderApi;
|
|
13
|
+
let storedProviderUrl;
|
|
14
|
+
let storedUser;
|
|
15
|
+
let storedClickX;
|
|
16
|
+
let storedClickY;
|
|
17
|
+
let previousProviderUrl;
|
|
18
|
+
const spentSession = (0, _prosopo_procaptcha_common.createSpentSessionGuard)();
|
|
19
|
+
const defaultState = () => {
|
|
20
|
+
return {
|
|
21
|
+
showModal: false,
|
|
22
|
+
loading: false,
|
|
23
|
+
index: 0,
|
|
24
|
+
challenge: void 0,
|
|
25
|
+
solutions: void 0,
|
|
26
|
+
isHuman: false,
|
|
27
|
+
captchaApi: void 0,
|
|
28
|
+
account: void 0
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const onFailed = () => {
|
|
32
|
+
updateState({
|
|
33
|
+
isHuman: false,
|
|
34
|
+
loading: false
|
|
35
|
+
});
|
|
36
|
+
events.onFailed();
|
|
37
|
+
resetState(frictionlessState?.restart);
|
|
38
|
+
};
|
|
39
|
+
const getConfig = () => {
|
|
40
|
+
const config = {
|
|
41
|
+
userAccountAddress: configInput.userAccountAddress || "",
|
|
42
|
+
...configInput
|
|
43
|
+
};
|
|
44
|
+
if (state.account) config.userAccountAddress = state.account.account.address;
|
|
45
|
+
return _prosopo_types.ProcaptchaConfigSchema.parse(config);
|
|
46
|
+
};
|
|
47
|
+
const getAccount = () => {
|
|
48
|
+
if (!state.account) throw new _prosopo_common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
|
|
49
|
+
return { account: state.account };
|
|
50
|
+
};
|
|
51
|
+
const getDappAccount = () => {
|
|
52
|
+
if (!state.dappAccount) throw new _prosopo_common.ProsopoEnvError("GENERAL.SITE_KEY_MISSING");
|
|
53
|
+
return state.dappAccount;
|
|
54
|
+
};
|
|
55
|
+
const updateState = (0, _prosopo_procaptcha_common.buildUpdateState)(state, onStateUpdate);
|
|
56
|
+
const lifecycle = (0, _prosopo_procaptcha_common.createManagerLifecycle)(state, updateState);
|
|
57
|
+
const resetState = (frictionlessRestart) => {
|
|
58
|
+
lifecycle.clearTimers();
|
|
59
|
+
updateState(defaultState());
|
|
60
|
+
events.onReset();
|
|
61
|
+
if (frictionlessRestart) frictionlessRestart();
|
|
62
|
+
storedChallengeResponse = void 0;
|
|
63
|
+
storedProviderApi = void 0;
|
|
64
|
+
storedProviderUrl = void 0;
|
|
65
|
+
storedUser = void 0;
|
|
66
|
+
storedClickX = void 0;
|
|
67
|
+
storedClickY = void 0;
|
|
68
|
+
};
|
|
69
|
+
const setValidChallengeTimeout = () => {
|
|
70
|
+
lifecycle.expireSolutionAfter(getConfig().captchas.iconOrder.solutionTimeout, () => {
|
|
71
|
+
updateState({ isHuman: false });
|
|
72
|
+
events.onExpired();
|
|
73
|
+
resetState(frictionlessState?.restart);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const start = async (x = 0, y = 0) => {
|
|
77
|
+
await (0, _prosopo_procaptcha_common.providerRetry)(async () => {
|
|
78
|
+
if (state.loading) return;
|
|
79
|
+
if (state.isHuman) return;
|
|
80
|
+
resetState();
|
|
81
|
+
storedClickX = x;
|
|
82
|
+
storedClickY = y;
|
|
83
|
+
updateState({ loading: true });
|
|
84
|
+
updateState({ attemptCount: state.attemptCount + 1 });
|
|
85
|
+
const config = getConfig();
|
|
86
|
+
const selectAccount = async () => {
|
|
87
|
+
if (frictionlessState) return frictionlessState.userAccount;
|
|
88
|
+
return new (await ((0, _prosopo_procaptcha_common.ExtensionLoader)(config.web2)))().getAccount(config);
|
|
89
|
+
};
|
|
90
|
+
const user = await selectAccount();
|
|
91
|
+
const userAccount = user.account.address;
|
|
92
|
+
updateState({ account: { account: { address: userAccount } } });
|
|
93
|
+
updateState({ dappAccount: config.account.address });
|
|
94
|
+
await (0, _prosopo_util.sleep)(100);
|
|
95
|
+
if (!config.web2 && !config.userAccountAddress) throw new _prosopo_common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account address has not been set for web3 mode" } });
|
|
96
|
+
let getRandomProviderResponse = void 0;
|
|
97
|
+
if (frictionlessState?.provider) getRandomProviderResponse = frictionlessState.provider;
|
|
98
|
+
else {
|
|
99
|
+
const currentConfig = getConfig();
|
|
100
|
+
getRandomProviderResponse = await (0, _prosopo_procaptcha_common.getProcaptchaRandomActiveProvider)(currentConfig.defaultEnvironment, (0, _prosopo_procaptcha_common.pickIpMode)(currentConfig), {
|
|
101
|
+
attempt: state.attemptCount,
|
|
102
|
+
excludeUrl: previousProviderUrl
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
const providerUrl = getRandomProviderResponse.provider.url;
|
|
106
|
+
previousProviderUrl = providerUrl;
|
|
107
|
+
const providerApi = new _prosopo_api.ProviderApi(providerUrl, getDappAccount());
|
|
108
|
+
const challengeSessionId = frictionlessState?.sessionId;
|
|
109
|
+
if (spentSession.isSpent(challengeSessionId)) {
|
|
110
|
+
updateState({
|
|
111
|
+
loading: false,
|
|
112
|
+
error: {
|
|
113
|
+
message: "No session found",
|
|
114
|
+
key: "CAPTCHA.NO_SESSION_FOUND"
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
events.onError(/* @__PURE__ */ new Error("No session found"));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const simdReadingsOnChallenge = frictionlessState?.getSimdReadings ? await frictionlessState.getSimdReadings(0) : void 0;
|
|
121
|
+
const challenge = await providerApi.getIconOrderCaptchaChallenge(userAccount, getDappAccount(), challengeSessionId, simdReadingsOnChallenge);
|
|
122
|
+
spentSession.markSpent(challengeSessionId);
|
|
123
|
+
if (challenge.error) {
|
|
124
|
+
updateState({
|
|
125
|
+
loading: false,
|
|
126
|
+
error: {
|
|
127
|
+
message: challenge.error.message,
|
|
128
|
+
key: challenge.error.key || "API.UNKNOWN_ERROR"
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
storedChallengeResponse = challenge;
|
|
134
|
+
storedProviderApi = providerApi;
|
|
135
|
+
storedProviderUrl = providerUrl;
|
|
136
|
+
storedUser = user;
|
|
137
|
+
updateState({ loading: false });
|
|
138
|
+
}, async () => {
|
|
139
|
+
await start(x, y);
|
|
140
|
+
}, () => {
|
|
141
|
+
resetState();
|
|
142
|
+
}, state.attemptCount, 3);
|
|
143
|
+
return storedChallengeResponse;
|
|
144
|
+
};
|
|
145
|
+
const submitSolution = async (clicks, iconOrderEvents) => {
|
|
146
|
+
if (!storedChallengeResponse || !storedProviderApi || !storedProviderUrl || !storedUser) throw new _prosopo_common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "No challenge data available. Call start() first." } });
|
|
147
|
+
updateState({ loading: true });
|
|
148
|
+
try {
|
|
149
|
+
const challenge = storedChallengeResponse;
|
|
150
|
+
const providerApi = storedProviderApi;
|
|
151
|
+
const providerUrl = storedProviderUrl;
|
|
152
|
+
const user = storedUser;
|
|
153
|
+
getConfig();
|
|
154
|
+
const signer = user.extension?.signer;
|
|
155
|
+
if (!signer || !signer.signRaw) throw new _prosopo_common.ProsopoEnvError("GENERAL.CANT_FIND_KEYRINGPAIR", { context: { error: "Signer is not defined, cannot sign message to prove account ownership" } });
|
|
156
|
+
const userTimestampSignature = await signer.signRaw({
|
|
157
|
+
address: user.account.address,
|
|
158
|
+
data: (0, _polkadot_util_string.stringToHex)(challenge[_prosopo_types.ApiParams.timestamp].toString()),
|
|
159
|
+
type: "bytes"
|
|
160
|
+
});
|
|
161
|
+
const encryptedBehavioralData = await (0, _prosopo_procaptcha_common.encryptBehavioralDataForSubmit)(frictionlessState);
|
|
162
|
+
let salt;
|
|
163
|
+
if (storedClickX !== void 0 && storedClickY !== void 0) {
|
|
164
|
+
const coords = [storedClickX, storedClickY];
|
|
165
|
+
const randomSalt = (0, _prosopo_util_crypto.randomAsHex)(coords.map((coord) => coord.toString(16).length + 4).reduce((acc, curr) => acc + curr, 0));
|
|
166
|
+
salt = (0, _prosopo_util.embedData)(randomSalt, coords);
|
|
167
|
+
}
|
|
168
|
+
const simdReadings = await (0, _prosopo_procaptcha_common.getSimdReadingsForSubmit)(frictionlessState);
|
|
169
|
+
const clientMetaData = (0, _prosopo_procaptcha_common.buildClientMetaData)(getHoneypotValue?.(), getConfig().clientSessionId);
|
|
170
|
+
const verifiedSolution = await providerApi.submitIconOrderCaptchaSolution(challenge, getAccount().account.account.address, getDappAccount(), clicks, iconOrderEvents, userTimestampSignature.signature.toString(), encryptedBehavioralData, salt, simdReadings, clientMetaData);
|
|
171
|
+
if (lifecycle.isDisposed()) return false;
|
|
172
|
+
if (verifiedSolution[_prosopo_types.ApiParams.verified]) {
|
|
173
|
+
updateState({
|
|
174
|
+
isHuman: true,
|
|
175
|
+
loading: false
|
|
176
|
+
});
|
|
177
|
+
events.onHuman((0, _prosopo_types.encodeProcaptchaOutput)({
|
|
178
|
+
[_prosopo_types.ApiParams.providerUrl]: providerUrl,
|
|
179
|
+
[_prosopo_types.ApiParams.user]: getAccount().account.account.address,
|
|
180
|
+
[_prosopo_types.ApiParams.dapp]: getDappAccount(),
|
|
181
|
+
[_prosopo_types.ApiParams.challenge]: challenge.challenge,
|
|
182
|
+
[_prosopo_types.ApiParams.timestamp]: challenge.timestamp,
|
|
183
|
+
[_prosopo_types.ApiParams.signature]: {
|
|
184
|
+
[_prosopo_types.ApiParams.provider]: challenge.signature.provider,
|
|
185
|
+
[_prosopo_types.ApiParams.user]: { [_prosopo_types.ApiParams.timestamp]: userTimestampSignature.signature.toString() }
|
|
186
|
+
},
|
|
187
|
+
[_prosopo_types.ApiParams.captchaType]: _prosopo_types.CaptchaType.iconOrder
|
|
188
|
+
}));
|
|
189
|
+
setValidChallengeTimeout();
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
onFailed();
|
|
193
|
+
return false;
|
|
194
|
+
} catch (error) {
|
|
195
|
+
updateState({ loading: false });
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
return {
|
|
200
|
+
start,
|
|
201
|
+
submitSolution,
|
|
202
|
+
resetState,
|
|
203
|
+
dispose: lifecycle.dispose
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
//#endregion
|
|
207
|
+
exports.Manager = Manager;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Translator } from "@prosopo/locale";
|
|
2
|
+
import { type AudioAlternativeOffer, type Component } from "@prosopo/procaptcha-common";
|
|
3
|
+
import type { IconClick, IconOrderEvent, PlacementType } from "@prosopo/types";
|
|
4
|
+
import type { Theme } from "@prosopo/widget-skeleton";
|
|
5
|
+
export interface IconOrderCanvasProps {
|
|
6
|
+
background: string;
|
|
7
|
+
legend: string;
|
|
8
|
+
legendIconSize: number;
|
|
9
|
+
onComplete: (clicks: IconClick[], events: IconOrderEvent[]) => void;
|
|
10
|
+
showRetry: boolean;
|
|
11
|
+
submitting: boolean;
|
|
12
|
+
theme: Theme;
|
|
13
|
+
translator: Translator;
|
|
14
|
+
placement?: PlacementType;
|
|
15
|
+
anchor?: HTMLElement | null;
|
|
16
|
+
onDismiss?: () => void;
|
|
17
|
+
audioAlternative?: AudioAlternativeOffer;
|
|
18
|
+
}
|
|
19
|
+
export declare const mountIconOrderCanvas: (initialProps: IconOrderCanvasProps) => Component<IconOrderCanvasProps>;
|
|
20
|
+
//# sourceMappingURL=iconOrderCanvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconOrderCanvas.d.ts","sourceRoot":"","sources":["../../src/components/iconOrderCanvas.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAEN,KAAK,qBAAqB,EAG1B,KAAK,SAAS,EAOd,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IAEpC,UAAU,EAAE,MAAM,CAAC;IAEnB,MAAM,EAAE,MAAM,CAAC;IAEf,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;IACpE,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IAEvB,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;CACzC;AAsBD,eAAO,MAAM,oBAAoB,iBAClB,oBAAoB,KAChC,SAAS,CAAC,oBAAoB,CAoYhC,CAAC"}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { Teardown, applyAttributes, applyStyles, createElement, mountAudioAlternativeFooter, mountChallengeSurface } from "@prosopo/procaptcha-common";
|
|
2
|
+
//#region src/components/iconOrderCanvas.ts
|
|
3
|
+
/**
|
|
4
|
+
* Must match `DEFAULT_GEOMETRY` in @prosopo/icon-order-assets: the provider
|
|
5
|
+
* grades clicks in this coordinate space.
|
|
6
|
+
*/
|
|
7
|
+
var CONTAINER_WIDTH = 300;
|
|
8
|
+
var CONTAINER_HEIGHT = 200;
|
|
9
|
+
var MARKER_RADIUS = 13;
|
|
10
|
+
var SHAKE_MS = 500;
|
|
11
|
+
/** `MouseEvent.button` for a primary click, a touch or a pen contact. */
|
|
12
|
+
var MAIN_BUTTON = 0;
|
|
13
|
+
var SHAKE_KEYFRAMES = `
|
|
14
|
+
@keyframes prosopo-icon-order-shake {
|
|
15
|
+
0%, 100% { transform: translateX(0); }
|
|
16
|
+
10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
|
|
17
|
+
20%, 40%, 60%, 80% { transform: translateX(4px); }
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
var mountIconOrderCanvas = (initialProps) => {
|
|
21
|
+
const teardown = new Teardown();
|
|
22
|
+
let props = initialProps;
|
|
23
|
+
let clicks = [];
|
|
24
|
+
let events = [];
|
|
25
|
+
let startedAt = Date.now();
|
|
26
|
+
let visible = false;
|
|
27
|
+
let shaking = false;
|
|
28
|
+
let shakeTimer;
|
|
29
|
+
const markers = [];
|
|
30
|
+
const t = (key, options) => props.translator.t(key, options);
|
|
31
|
+
const style = createElement("style", { text: SHAKE_KEYFRAMES });
|
|
32
|
+
const instruction = createElement("span");
|
|
33
|
+
const legend = createElement("img", {
|
|
34
|
+
style: {
|
|
35
|
+
imageRendering: "auto",
|
|
36
|
+
userSelect: "none"
|
|
37
|
+
},
|
|
38
|
+
attributes: { draggable: "false" }
|
|
39
|
+
});
|
|
40
|
+
const header = createElement("div", {
|
|
41
|
+
style: {
|
|
42
|
+
borderRadius: "20px 20px 0 0",
|
|
43
|
+
padding: "10px 16px",
|
|
44
|
+
width: `${CONTAINER_WIDTH}px`,
|
|
45
|
+
boxSizing: "border-box",
|
|
46
|
+
display: "flex",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
justifyContent: "space-between",
|
|
49
|
+
gap: "10px",
|
|
50
|
+
fontSize: "14px",
|
|
51
|
+
fontWeight: 500,
|
|
52
|
+
transition: "color 0.3s ease, border-color 0.3s ease"
|
|
53
|
+
},
|
|
54
|
+
children: [instruction, legend]
|
|
55
|
+
});
|
|
56
|
+
const background = createElement("img", {
|
|
57
|
+
style: {
|
|
58
|
+
position: "absolute",
|
|
59
|
+
inset: 0,
|
|
60
|
+
width: `${CONTAINER_WIDTH}px`,
|
|
61
|
+
height: `${CONTAINER_HEIGHT}px`,
|
|
62
|
+
pointerEvents: "none",
|
|
63
|
+
userSelect: "none"
|
|
64
|
+
},
|
|
65
|
+
attributes: {
|
|
66
|
+
alt: "",
|
|
67
|
+
draggable: "false"
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const frame = createElement("div", {
|
|
71
|
+
style: {
|
|
72
|
+
position: "relative",
|
|
73
|
+
width: `${CONTAINER_WIDTH}px`,
|
|
74
|
+
height: `${CONTAINER_HEIGHT}px`,
|
|
75
|
+
overflow: "hidden",
|
|
76
|
+
userSelect: "none",
|
|
77
|
+
touchAction: "none",
|
|
78
|
+
transition: "opacity 0.2s ease"
|
|
79
|
+
},
|
|
80
|
+
children: [background]
|
|
81
|
+
});
|
|
82
|
+
const resetButton = createElement("button", {
|
|
83
|
+
attributes: { type: "button" },
|
|
84
|
+
style: {
|
|
85
|
+
flex: "0 0 auto",
|
|
86
|
+
padding: "8px 12px",
|
|
87
|
+
borderRadius: "10px",
|
|
88
|
+
background: "transparent",
|
|
89
|
+
fontSize: "13px"
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const submitButton = createElement("button", {
|
|
93
|
+
attributes: { type: "button" },
|
|
94
|
+
style: {
|
|
95
|
+
flex: "1 1 auto",
|
|
96
|
+
padding: "8px 12px",
|
|
97
|
+
borderRadius: "10px",
|
|
98
|
+
border: "none",
|
|
99
|
+
fontSize: "14px",
|
|
100
|
+
fontWeight: 600
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
if ("production" !== process.env.NODE_ENV) {
|
|
104
|
+
applyAttributes(frame, { "data-cy": "prosopo-icon-order-frame" });
|
|
105
|
+
applyAttributes(resetButton, { "data-cy": "prosopo-icon-order-reset" });
|
|
106
|
+
applyAttributes(submitButton, { "data-cy": "prosopo-icon-order-submit" });
|
|
107
|
+
}
|
|
108
|
+
const controls = createElement("div", {
|
|
109
|
+
style: {
|
|
110
|
+
borderRadius: "0 0 20px 20px",
|
|
111
|
+
padding: "10px 16px",
|
|
112
|
+
width: `${CONTAINER_WIDTH}px`,
|
|
113
|
+
boxSizing: "border-box",
|
|
114
|
+
display: "flex",
|
|
115
|
+
alignItems: "center",
|
|
116
|
+
gap: "10px"
|
|
117
|
+
},
|
|
118
|
+
children: [resetButton, submitButton]
|
|
119
|
+
});
|
|
120
|
+
const panel = createElement("div", {
|
|
121
|
+
style: {
|
|
122
|
+
display: "flex",
|
|
123
|
+
flexDirection: "column",
|
|
124
|
+
alignItems: "center",
|
|
125
|
+
transition: "opacity 0.3s ease, transform 0.3s ease"
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
header,
|
|
129
|
+
frame,
|
|
130
|
+
controls
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
const surfaceProps = () => ({
|
|
134
|
+
show: true,
|
|
135
|
+
placement: props.placement,
|
|
136
|
+
anchor: props.anchor,
|
|
137
|
+
onDismiss: props.onDismiss,
|
|
138
|
+
scrim: visible ? "dim" : "none",
|
|
139
|
+
dialogLabel: t("WIDGET.ICON_ORDER.DIALOG_LABEL", { defaultValue: "Icon order challenge" })
|
|
140
|
+
});
|
|
141
|
+
const surface = mountChallengeSurface(surfaceProps());
|
|
142
|
+
surface.content.append(style, panel);
|
|
143
|
+
const audioAlternativeFooterProps = () => ({
|
|
144
|
+
offer: props.audioAlternative,
|
|
145
|
+
theme: props.theme,
|
|
146
|
+
width: CONTAINER_WIDTH
|
|
147
|
+
});
|
|
148
|
+
const audioAlternativeFooter = mountAudioAlternativeFooter(panel, audioAlternativeFooterProps());
|
|
149
|
+
const createMarker = () => createElement("div", { style: {
|
|
150
|
+
position: "absolute",
|
|
151
|
+
width: `${MARKER_RADIUS * 2}px`,
|
|
152
|
+
height: `${MARKER_RADIUS * 2}px`,
|
|
153
|
+
borderRadius: "50%",
|
|
154
|
+
border: "2px solid rgba(255, 255, 255, 0.9)",
|
|
155
|
+
boxShadow: "0 2px 6px rgba(0, 0, 0, 0.45)",
|
|
156
|
+
display: "flex",
|
|
157
|
+
alignItems: "center",
|
|
158
|
+
justifyContent: "center",
|
|
159
|
+
fontSize: "12px",
|
|
160
|
+
fontWeight: 700,
|
|
161
|
+
pointerEvents: "none",
|
|
162
|
+
userSelect: "none"
|
|
163
|
+
} });
|
|
164
|
+
const renderMarkers = () => {
|
|
165
|
+
while (markers.length > clicks.length) markers.pop()?.remove();
|
|
166
|
+
while (markers.length < clicks.length) {
|
|
167
|
+
const marker = createMarker();
|
|
168
|
+
frame.appendChild(marker);
|
|
169
|
+
markers.push(marker);
|
|
170
|
+
}
|
|
171
|
+
const { theme } = props;
|
|
172
|
+
clicks.forEach((click, index) => {
|
|
173
|
+
const marker = markers[index];
|
|
174
|
+
if (!marker) return;
|
|
175
|
+
marker.textContent = String(index + 1);
|
|
176
|
+
applyStyles(marker, {
|
|
177
|
+
left: `${click.x - MARKER_RADIUS}px`,
|
|
178
|
+
top: `${click.y - MARKER_RADIUS}px`,
|
|
179
|
+
backgroundColor: theme.palette.primary.main,
|
|
180
|
+
color: theme.palette.background.default,
|
|
181
|
+
fontFamily: theme.font.fontFamily
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
const render = () => {
|
|
186
|
+
const { theme, showRetry, submitting } = props;
|
|
187
|
+
const empty = 0 === clicks.length;
|
|
188
|
+
const inactive = submitting || empty;
|
|
189
|
+
applyStyles(panel, {
|
|
190
|
+
opacity: visible ? 1 : 0,
|
|
191
|
+
transform: visible ? "scale(1)" : "scale(0.9)",
|
|
192
|
+
animation: shaking ? `prosopo-icon-order-shake ${SHAKE_MS}ms ease` : "none"
|
|
193
|
+
});
|
|
194
|
+
instruction.textContent = showRetry ? t("WIDGET.ICON_ORDER.RETRY", { defaultValue: "Not quite — try again" }) : t("WIDGET.ICON_ORDER.SELECT", { defaultValue: "Select in this order" });
|
|
195
|
+
applyStyles(header, {
|
|
196
|
+
backgroundColor: theme.palette.surface,
|
|
197
|
+
fontFamily: theme.font.fontFamily,
|
|
198
|
+
color: showRetry ? theme.palette.error.main : theme.palette.onSurface,
|
|
199
|
+
borderBottom: `2px solid ${showRetry ? theme.palette.error.main : "transparent"}`
|
|
200
|
+
});
|
|
201
|
+
legend.src = props.legend;
|
|
202
|
+
legend.alt = t("WIDGET.ICON_ORDER.LEGEND_ALT", { defaultValue: "Icons to select, in order" });
|
|
203
|
+
applyStyles(legend, { height: `${props.legendIconSize}px` });
|
|
204
|
+
background.src = props.background;
|
|
205
|
+
applyStyles(frame, {
|
|
206
|
+
background: `linear-gradient(135deg, ${theme.palette.surface} 0%, ${theme.palette.primaryContainer.main} 50%, ${theme.palette.surface} 100%)`,
|
|
207
|
+
cursor: submitting ? "default" : "pointer",
|
|
208
|
+
opacity: submitting ? .6 : 1,
|
|
209
|
+
pointerEvents: submitting ? "none" : "auto"
|
|
210
|
+
});
|
|
211
|
+
renderMarkers();
|
|
212
|
+
applyStyles(controls, {
|
|
213
|
+
backgroundColor: theme.palette.surface,
|
|
214
|
+
borderRadius: props.audioAlternative ? "0" : "0 0 20px 20px"
|
|
215
|
+
});
|
|
216
|
+
audioAlternativeFooter.update(audioAlternativeFooterProps());
|
|
217
|
+
resetButton.textContent = t("WIDGET.ICON_ORDER.RESET", { defaultValue: "Reset" });
|
|
218
|
+
resetButton.disabled = inactive;
|
|
219
|
+
applyStyles(resetButton, {
|
|
220
|
+
border: `1px solid ${theme.palette.border}`,
|
|
221
|
+
color: theme.palette.onSurface,
|
|
222
|
+
fontFamily: theme.font.fontFamily,
|
|
223
|
+
cursor: inactive ? "default" : "pointer",
|
|
224
|
+
opacity: inactive ? .5 : 1
|
|
225
|
+
});
|
|
226
|
+
submitButton.textContent = submitting ? t("WIDGET.ICON_ORDER.CHECKING", { defaultValue: "Checking…" }) : t("WIDGET.ICON_ORDER.SUBMIT", { defaultValue: "OK" });
|
|
227
|
+
submitButton.disabled = inactive;
|
|
228
|
+
applyStyles(submitButton, {
|
|
229
|
+
backgroundColor: theme.palette.primary.main,
|
|
230
|
+
color: theme.palette.background.default,
|
|
231
|
+
fontFamily: theme.font.fontFamily,
|
|
232
|
+
cursor: inactive ? "default" : "pointer",
|
|
233
|
+
opacity: inactive ? .5 : 1
|
|
234
|
+
});
|
|
235
|
+
surface.update(surfaceProps());
|
|
236
|
+
};
|
|
237
|
+
const clearAnswer = () => {
|
|
238
|
+
clicks = [];
|
|
239
|
+
events = [];
|
|
240
|
+
startedAt = Date.now();
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Scales by the frame's measured box rather than the constants, so a host
|
|
244
|
+
* page that transforms the widget still reports clicks in the provider's
|
|
245
|
+
* coordinate space.
|
|
246
|
+
*/
|
|
247
|
+
const toFramePoint = (event) => {
|
|
248
|
+
if (props.submitting || !(event instanceof MouseEvent)) return null;
|
|
249
|
+
const rect = frame.getBoundingClientRect();
|
|
250
|
+
if (0 === rect.width || 0 === rect.height) return null;
|
|
251
|
+
return {
|
|
252
|
+
x: (event.clientX - rect.left) / rect.width * CONTAINER_WIDTH,
|
|
253
|
+
y: (event.clientY - rect.top) / rect.height * CONTAINER_HEIGHT
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
const recordEvent = (point) => {
|
|
257
|
+
events.push({
|
|
258
|
+
x: point.x,
|
|
259
|
+
y: point.y,
|
|
260
|
+
t: Date.now() - startedAt
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
teardown.addEventListener(frame, "pointermove", (event) => {
|
|
264
|
+
const point = toFramePoint(event);
|
|
265
|
+
if (point) recordEvent(point);
|
|
266
|
+
});
|
|
267
|
+
teardown.addEventListener(frame, "pointerup", (event) => {
|
|
268
|
+
if (event instanceof MouseEvent && MAIN_BUTTON !== event.button) return;
|
|
269
|
+
const point = toFramePoint(event);
|
|
270
|
+
if (!point) return;
|
|
271
|
+
recordEvent(point);
|
|
272
|
+
clicks = [...clicks, point];
|
|
273
|
+
render();
|
|
274
|
+
});
|
|
275
|
+
teardown.addEventListener(resetButton, "click", () => {
|
|
276
|
+
clearAnswer();
|
|
277
|
+
render();
|
|
278
|
+
});
|
|
279
|
+
teardown.addEventListener(submitButton, "click", () => {
|
|
280
|
+
if (props.submitting || 0 === clicks.length) return;
|
|
281
|
+
props.onComplete([...clicks], [...events]);
|
|
282
|
+
});
|
|
283
|
+
render();
|
|
284
|
+
const frameRequest = requestAnimationFrame(() => {
|
|
285
|
+
visible = true;
|
|
286
|
+
render();
|
|
287
|
+
});
|
|
288
|
+
teardown.add(() => cancelAnimationFrame(frameRequest));
|
|
289
|
+
const startShake = () => {
|
|
290
|
+
shaking = true;
|
|
291
|
+
render();
|
|
292
|
+
if (void 0 !== shakeTimer) clearTimeout(shakeTimer);
|
|
293
|
+
shakeTimer = setTimeout(() => {
|
|
294
|
+
shaking = false;
|
|
295
|
+
render();
|
|
296
|
+
}, SHAKE_MS);
|
|
297
|
+
};
|
|
298
|
+
teardown.add(() => {
|
|
299
|
+
if (void 0 !== shakeTimer) clearTimeout(shakeTimer);
|
|
300
|
+
});
|
|
301
|
+
if (props.showRetry) startShake();
|
|
302
|
+
return {
|
|
303
|
+
update: (nextProps) => {
|
|
304
|
+
const previous = props;
|
|
305
|
+
props = nextProps;
|
|
306
|
+
if (nextProps.background !== previous.background || nextProps.legend !== previous.legend) clearAnswer();
|
|
307
|
+
if (nextProps.showRetry && !previous.showRetry) {
|
|
308
|
+
startShake();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
render();
|
|
312
|
+
},
|
|
313
|
+
destroy: () => {
|
|
314
|
+
teardown.run();
|
|
315
|
+
audioAlternativeFooter.destroy();
|
|
316
|
+
surface.destroy();
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
//#endregion
|
|
321
|
+
export { mountIconOrderCanvas };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iconOrderCanvas.js","sourceRoot":"","sources":["../../src/components/iconOrderCanvas.ts"],"names":[],"mappings":"AAeA,OAAO,EAMN,QAAQ,EACR,eAAe,EACf,WAAW,EACX,aAAa,EACb,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAC;AA2BpC,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,eAAe,GAAG;;;;;;CAMvB,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CACnC,YAAkC,EACA,EAAE;IACpC,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,IAAI,KAAK,GAAG,YAAY,CAAC;IAEzB,IAAI,MAAM,GAAgB,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAqB,EAAE,CAAC;IAClC,IAAI,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,UAAqD,CAAC;IAC1D,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,MAAM,CAAC,GAAG,CAAC,GAAmB,EAAE,OAAiC,EAAU,EAAE,CAC5E,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAElC,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;IAEhE,MAAM,WAAW,GAAG,aAAa,CAAC,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;YAC9B,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1B,CAAC;IACF,CAAC,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACrB,UAAU,EAAE,CAAC;IACd,CAAC;IAED,OAAO;QACN,MAAM,EAAE,CAAC,SAA+B,EAAE,EAAE;YAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC;YACvB,KAAK,GAAG,SAAS,CAAC;YAGlB,IACC,SAAS,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU;gBAC5C,SAAS,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EACnC,CAAC;gBACF,WAAW,EAAE,CAAC;YACf,CAAC;YAED,IAAI,SAAS,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;gBAChD,UAAU,EAAE,CAAC;gBACb,OAAO;YACR,CAAC;YAED,MAAM,EAAE,CAAC;QACV,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACb,QAAQ,CAAC,GAAG,EAAE,CAAC;YACf,sBAAsB,CAAC,OAAO,EAAE,CAAC;YACjC,OAAO,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;KACD,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type WidgetMountFn } from "@prosopo/procaptcha-common";
|
|
2
|
+
import type { ProcaptchaIconOrderHandle } from "./procaptchaWidget.js";
|
|
3
|
+
export type { ProcaptchaIconOrderHandle };
|
|
4
|
+
export type ProcaptchaIconOrderMountFn = WidgetMountFn<ProcaptchaIconOrderHandle>;
|
|
5
|
+
export declare const loadProcaptchaIconOrder: () => Promise<ProcaptchaIconOrderMountFn>;
|
|
6
|
+
export declare const mountProcaptchaIconOrder: ProcaptchaIconOrderMountFn;
|
|
7
|
+
//# sourceMappingURL=procaptchaIconOrder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procaptchaIconOrder.d.ts","sourceRoot":"","sources":["../../src/components/procaptchaIconOrder.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEvE,YAAY,EAAE,yBAAyB,EAAE,CAAC;AAE1C,MAAM,MAAM,0BAA0B,GACrC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAE1C,eAAO,MAAM,uBAAuB,QACzB,OAAO,CAAC,0BAA0B,CAC2B,CAAC;AAEzE,eAAO,MAAM,wBAAwB,EAAE,0BAEtC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { lazyMount } from "@prosopo/procaptcha-common";
|
|
2
|
+
//#region src/components/procaptchaIconOrder.ts
|
|
3
|
+
var loadProcaptchaIconOrder = async () => (await import("./procaptchaWidget.js")).mountProcaptchaIconOrderWidget;
|
|
4
|
+
var mountProcaptchaIconOrder = lazyMount(loadProcaptchaIconOrder);
|
|
5
|
+
//#endregion
|
|
6
|
+
export { loadProcaptchaIconOrder, mountProcaptchaIconOrder };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procaptchaIconOrder.js","sourceRoot":"","sources":["../../src/components/procaptchaIconOrder.ts"],"names":[],"mappings":"AAcA,OAAO,EAAsB,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAQ3E,MAAM,CAAC,MAAM,uBAAuB,GACnC,KAAK,IAAyC,EAAE,CAC/C,CAAC,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,8BAA8B,CAAC;AAEzE,MAAM,CAAC,MAAM,wBAAwB,GAA+B,SAAS,CAC5E,uBAAuB,CACvB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ProcaptchaProps } from "@prosopo/types";
|
|
2
|
+
export interface ProcaptchaIconOrderHandle {
|
|
3
|
+
destroy(): void;
|
|
4
|
+
}
|
|
5
|
+
export declare const mountProcaptchaIconOrderWidget: (container: HTMLElement, props: ProcaptchaProps) => ProcaptchaIconOrderHandle;
|
|
6
|
+
export default mountProcaptchaIconOrderWidget;
|
|
7
|
+
//# sourceMappingURL=procaptchaWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/procaptchaWidget.ts"],"names":[],"mappings":"AAoCA,OAAO,EAKN,KAAK,eAAe,EAEpB,MAAM,gBAAgB,CAAC;AAUxB,MAAM,WAAW,yBAAyB;IACzC,OAAO,IAAI,IAAI,CAAC;CAChB;AAED,eAAO,MAAM,8BAA8B,cAC/B,WAAW,SACf,eAAe,KACpB,yBAwTF,CAAC;AAEF,eAAe,8BAA8B,CAAC"}
|