mirror of
1
2
Fork 0

Fixed as much as possible

This commit is contained in:
Frank Lemanschik 2020-03-21 12:24:14 +01:00
parent 3296f8d2ba
commit b0ae0d2faa
6 changed files with 16 additions and 69 deletions

View File

@ -60,7 +60,7 @@ function uCaptchaBox(websiteKey) {
captchaBox.appendChild(btn);
checkbox.onclick = async function() {
/** @type {import('../shared/models/UserSession.js').UserSession} */
/** @type {import('../models/UserSession.js').UserSession} */
const session = await initializeSession(websiteKey);
const imageGrid = createElement('table', {id: 'ucaptcha-grid'});

View File

@ -1,5 +1,7 @@
import request from './util/request.js';
import UserSession from '../../shared/models/UserSession.js';
import request from '../util/request.js';
/**
* @typedef { import('../../models/UserSession.js').UserSession } UserSession
*/
/**
* Instantiate the uCaptcha loop

View File

@ -1,5 +1,5 @@
import request from '../util/request.js';
import UserSession from '../../shared/models/UserSession.js';
import UserSession from '../../models/UserSession.js';
/**
* @param {string} websiteKey

View File

@ -1,12 +1,16 @@
import request from './util/request.js';
import UserSession from '../../shared/models/UserSession.js';
import request from '../util/request.js';
/**
* @typedef { import('../../models/UserSession.js').UserSession } UserSession
*/
/**
* Verify the image
* @param {UserSession} session
* @param {HTMLElement} captchaGrid
*/
export default async function(session, captchaGrid) {
export async function verfiyImage(session, captchaGrid) {
const tds = captchaGrid.querySelectorAll('td');
const selectedTds = [];
@ -31,3 +35,5 @@ export default async function(session, captchaGrid) {
td.classList.remove('selected');
});
}
export default verfiyImage;

View File

@ -6,3 +6,4 @@
* @property {string} image Image URL for challenge
* @property {number} score How likely is the user to be a human?
*/
export const IDBSession = {};

View File

@ -1,62 +0,0 @@
/**
* User session model
* @type {Object} Session Object.
* @property {string} _sessionId The session identifier
* @property {string} _websiteKey The website id for session
*/
export class UserSession {
/**
* Set session ID
* @param {string} id
*/
set sessionId(id) {
this._sessionId = id;
}
/**
* Get the session ID
* @type {string}
*/
get sessionId() {
return this._sessionId;
}
/**
* Set session ID
* @param {string} id
*/
set websiteKey(id) {
this._websiteKey = id;
}
/**
* Get the session ID
* @type {string}
*/
get websiteKey() {
return this._websiteKey;
}
/**
* Serialize the session into a JSON object
* @return {Array<any>}
*/
serialize() {
const {sessionId, websiteKey} = this;
if (!sessionId || !websiteKey) {
throw Error();
}
return [sessionId, websiteKey];
}
/**
* Deserialize session data from JSON object
* @param {Array<any>} payload
*/
deserialize([sessionId, websiteKey]) {
Object.assign(this, {sessionId, websiteKey});
}
};
export default UserSession
;