@central-ticket/queue-sdk 0.0.1 → 0.0.2
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/dist/centralq-C3ukDo0x.d.mts +134 -0
- package/dist/centralq-C3ukDo0x.d.ts +134 -0
- package/dist/{chunk-A4HITWM4.mjs → chunk-4MXU7S6A.mjs} +1 -1
- package/dist/{chunk-42RGFZKP.mjs → chunk-A37B25XO.mjs} +27 -0
- package/dist/chunk-BVCZFNM3.mjs +329 -0
- package/dist/{chunk-JR7BCYB5.mjs → chunk-GWPLLJTU.mjs} +2 -2
- package/dist/chunk-JJ33EJ65.mjs +31 -0
- package/dist/chunk-P73Q2ZIO.mjs +167 -0
- package/dist/chunk-XIQ6LS62.mjs +312 -0
- package/dist/index.d.mts +31 -3
- package/dist/index.d.ts +31 -3
- package/dist/index.js +166 -4
- package/dist/index.mjs +3 -3
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +70 -2
- package/dist/react.mjs +2 -2
- package/dist/server.js +1 -1
- package/dist/server.mjs +2 -2
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +70 -2
- package/dist/svelte.mjs +2 -2
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -223,13 +223,13 @@ var QueueHttpClient = class {
|
|
|
223
223
|
}
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
|
-
async issueQueueInitToken(eventId, userId) {
|
|
226
|
+
async issueQueueInitToken(eventId, userId, admissionProof) {
|
|
227
227
|
const res = await fetch(
|
|
228
228
|
`${this.apiUrl}/api/queue/init/${encodeURIComponent(eventId)}`,
|
|
229
229
|
{
|
|
230
230
|
method: "POST",
|
|
231
231
|
headers: this.headers,
|
|
232
|
-
body: JSON.stringify({ userId })
|
|
232
|
+
body: JSON.stringify({ userId, admissionProof })
|
|
233
233
|
}
|
|
234
234
|
);
|
|
235
235
|
const body = await res.json().catch(() => ({}));
|
|
@@ -248,8 +248,155 @@ var QueueHttpClient = class {
|
|
|
248
248
|
expiresAt: body.expiresAt
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
|
+
async getProtection(eventId) {
|
|
252
|
+
const res = await fetch(
|
|
253
|
+
`${this.apiUrl}/api/queue/${encodeURIComponent(eventId)}/protection`,
|
|
254
|
+
{ headers: this.headers }
|
|
255
|
+
);
|
|
256
|
+
const body = await res.json().catch(() => ({}));
|
|
257
|
+
if (!res.ok) {
|
|
258
|
+
throw new Error(
|
|
259
|
+
body.message ?? `Error ${res.status} al consultar protecci\xF3n`
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
eventId: body.eventId ?? eventId,
|
|
264
|
+
configured: body.configured === true,
|
|
265
|
+
protected: body.protected === true,
|
|
266
|
+
isActive: body.isActive === true,
|
|
267
|
+
admissionMode: body.admissionMode ?? "PUBLIC",
|
|
268
|
+
challengeRequired: body.challengeRequired === true
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
async getAdmissionChallenge(eventId) {
|
|
272
|
+
const res = await fetch(
|
|
273
|
+
`${this.apiUrl}/api/queue/${encodeURIComponent(eventId)}/admission`,
|
|
274
|
+
{ headers: this.headers }
|
|
275
|
+
);
|
|
276
|
+
const body = await res.json().catch(() => ({}));
|
|
277
|
+
if (!res.ok) {
|
|
278
|
+
throw new Error(
|
|
279
|
+
body.message ?? `Error ${res.status} al preparar la admisi\xF3n`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
if (body.required !== true) return { required: false };
|
|
283
|
+
if (!("publicKey" in body) || !body.publicKey) {
|
|
284
|
+
throw new Error("Respuesta inv\xE1lida al preparar la admisi\xF3n");
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
required: true,
|
|
288
|
+
publicKey: body.publicKey,
|
|
289
|
+
appearance: "interaction-only"
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
async verifyToken(eventId, token) {
|
|
293
|
+
const res = await fetch(
|
|
294
|
+
`${this.apiUrl}/api/queue/verify/${encodeURIComponent(eventId)}`,
|
|
295
|
+
{
|
|
296
|
+
method: "POST",
|
|
297
|
+
headers: this.headers,
|
|
298
|
+
body: JSON.stringify({ token })
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
const body = await res.json().catch(() => ({
|
|
302
|
+
valid: false,
|
|
303
|
+
reason: "Respuesta inv\xE1lida"
|
|
304
|
+
}));
|
|
305
|
+
if (body.valid === true && body.userId && body.eventId && body.expiresAt) {
|
|
306
|
+
return body;
|
|
307
|
+
}
|
|
308
|
+
if (body.valid === false) {
|
|
309
|
+
return { valid: false, reason: body.reason ?? "Token inv\xE1lido" };
|
|
310
|
+
}
|
|
311
|
+
if (!res.ok) {
|
|
312
|
+
return {
|
|
313
|
+
valid: false,
|
|
314
|
+
reason: body.message ?? `Error ${res.status} al validar token de cola`
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
return { valid: false, reason: "Respuesta inv\xE1lida" };
|
|
318
|
+
}
|
|
251
319
|
};
|
|
252
320
|
|
|
321
|
+
// src/admission.ts
|
|
322
|
+
var turnstileScript = null;
|
|
323
|
+
function loadManagedAdmissionDriver() {
|
|
324
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
325
|
+
return Promise.reject(
|
|
326
|
+
new Error("La admisi\xF3n administrada requiere un navegador")
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
if (window.turnstile) return Promise.resolve(window.turnstile);
|
|
330
|
+
if (turnstileScript) return turnstileScript;
|
|
331
|
+
turnstileScript = new Promise((resolve, reject) => {
|
|
332
|
+
const script = document.createElement("script");
|
|
333
|
+
script.src = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";
|
|
334
|
+
script.async = true;
|
|
335
|
+
script.defer = true;
|
|
336
|
+
script.onload = () => {
|
|
337
|
+
if (window.turnstile) resolve(window.turnstile);
|
|
338
|
+
else {
|
|
339
|
+
turnstileScript = null;
|
|
340
|
+
reject(new Error("No se pudo inicializar la admisi\xF3n administrada"));
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
script.onerror = () => {
|
|
344
|
+
turnstileScript = null;
|
|
345
|
+
reject(new Error("No se pudo cargar la admisi\xF3n administrada"));
|
|
346
|
+
};
|
|
347
|
+
document.head.appendChild(script);
|
|
348
|
+
});
|
|
349
|
+
return turnstileScript;
|
|
350
|
+
}
|
|
351
|
+
async function acquireManagedAdmissionProof(publicKey) {
|
|
352
|
+
const driver = await loadManagedAdmissionDriver();
|
|
353
|
+
const container = document.createElement("div");
|
|
354
|
+
container.style.position = "fixed";
|
|
355
|
+
container.style.inset = "0";
|
|
356
|
+
container.style.zIndex = "2147483647";
|
|
357
|
+
container.style.display = "grid";
|
|
358
|
+
container.style.placeItems = "center";
|
|
359
|
+
container.style.pointerEvents = "auto";
|
|
360
|
+
document.body.appendChild(container);
|
|
361
|
+
return new Promise((resolve, reject) => {
|
|
362
|
+
let widgetId = "";
|
|
363
|
+
let timeout;
|
|
364
|
+
const cleanup = () => {
|
|
365
|
+
clearTimeout(timeout);
|
|
366
|
+
if (widgetId) driver.remove(widgetId);
|
|
367
|
+
container.remove();
|
|
368
|
+
};
|
|
369
|
+
timeout = setTimeout(() => {
|
|
370
|
+
cleanup();
|
|
371
|
+
reject(new Error("La validaci\xF3n de admisi\xF3n agot\xF3 el tiempo de espera"));
|
|
372
|
+
}, 15e3);
|
|
373
|
+
try {
|
|
374
|
+
widgetId = driver.render(container, {
|
|
375
|
+
sitekey: publicKey,
|
|
376
|
+
appearance: "interaction-only",
|
|
377
|
+
execution: "execute",
|
|
378
|
+
action: "centralq_admission",
|
|
379
|
+
callback: (token) => {
|
|
380
|
+
cleanup();
|
|
381
|
+
resolve(token);
|
|
382
|
+
},
|
|
383
|
+
"error-callback": () => {
|
|
384
|
+
cleanup();
|
|
385
|
+
reject(new Error("La validaci\xF3n de admisi\xF3n fall\xF3"));
|
|
386
|
+
},
|
|
387
|
+
"expired-callback": () => {
|
|
388
|
+
cleanup();
|
|
389
|
+
reject(new Error("La validaci\xF3n de admisi\xF3n expir\xF3"));
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
driver.execute(widgetId);
|
|
393
|
+
} catch {
|
|
394
|
+
cleanup();
|
|
395
|
+
reject(new Error("No se pudo ejecutar la admisi\xF3n administrada"));
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
253
400
|
// src/centralq.ts
|
|
254
401
|
var CentralQ = class _CentralQ {
|
|
255
402
|
constructor(options) {
|
|
@@ -454,7 +601,22 @@ var CentralQClient = class {
|
|
|
454
601
|
this.defaults.apiUrl,
|
|
455
602
|
this.defaults.apiKey
|
|
456
603
|
);
|
|
457
|
-
return
|
|
604
|
+
return this.issueInitToken(client, eventId, userId);
|
|
605
|
+
}
|
|
606
|
+
async issueInitToken(client, eventId, userId) {
|
|
607
|
+
if (typeof window === "undefined") {
|
|
608
|
+
return client.issueQueueInitToken(eventId, userId);
|
|
609
|
+
}
|
|
610
|
+
const protection = await client.getProtection(eventId);
|
|
611
|
+
if (!protection.challengeRequired) {
|
|
612
|
+
return client.issueQueueInitToken(eventId, userId);
|
|
613
|
+
}
|
|
614
|
+
const challenge = await client.getAdmissionChallenge(eventId);
|
|
615
|
+
if (!challenge.required) {
|
|
616
|
+
throw new Error("El evento requiere admisi\xF3n administrada");
|
|
617
|
+
}
|
|
618
|
+
const proof = await acquireManagedAdmissionProof(challenge.publicKey);
|
|
619
|
+
return client.issueQueueInitToken(eventId, userId, proof);
|
|
458
620
|
}
|
|
459
621
|
createQueue(options) {
|
|
460
622
|
return CentralQ.init({
|
|
@@ -482,7 +644,7 @@ function normalizeApiUrl2(apiUrl) {
|
|
|
482
644
|
async function validateQueueTokenServer(options) {
|
|
483
645
|
const apiUrl = options.apiUrl ?? CENTRALQ_DEFAULT_API_URL;
|
|
484
646
|
const response = await fetch(
|
|
485
|
-
`${normalizeApiUrl2(apiUrl)}/api/verify/${encodeURIComponent(options.eventId)}`,
|
|
647
|
+
`${normalizeApiUrl2(apiUrl)}/api/queue/verify/${encodeURIComponent(options.eventId)}`,
|
|
486
648
|
{
|
|
487
649
|
method: "POST",
|
|
488
650
|
headers: {
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validateQueueTokenServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JJ33EJ65.mjs";
|
|
4
4
|
import {
|
|
5
5
|
CentralQ,
|
|
6
6
|
CentralQClient,
|
|
7
7
|
createCentralQClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-BVCZFNM3.mjs";
|
|
9
9
|
import {
|
|
10
10
|
CENTRALQ_DEFAULT_API_URL,
|
|
11
11
|
QueueHttpClient
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-P73Q2ZIO.mjs";
|
|
13
13
|
import "./chunk-XRJFNASX.mjs";
|
|
14
14
|
export {
|
|
15
15
|
CENTRALQ_DEFAULT_API_URL,
|
package/dist/react.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, d as CentralQOptions } from './centralq-
|
|
1
|
+
import { C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, d as CentralQOptions } from './centralq-C3ukDo0x.mjs';
|
|
2
2
|
|
|
3
3
|
interface UseCentralQReturn {
|
|
4
4
|
/** Token JWT si el usuario fue admitido, null si no */
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, d as CentralQOptions } from './centralq-
|
|
1
|
+
import { C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, d as CentralQOptions } from './centralq-C3ukDo0x.js';
|
|
2
2
|
|
|
3
3
|
interface UseCentralQReturn {
|
|
4
4
|
/** Token JWT si el usuario fue admitido, null si no */
|
package/dist/react.js
CHANGED
|
@@ -220,13 +220,13 @@ var QueueHttpClient = class {
|
|
|
220
220
|
}
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
|
-
async issueQueueInitToken(eventId, userId) {
|
|
223
|
+
async issueQueueInitToken(eventId, userId, admissionProof) {
|
|
224
224
|
const res = await fetch(
|
|
225
225
|
`${this.apiUrl}/api/queue/init/${encodeURIComponent(eventId)}`,
|
|
226
226
|
{
|
|
227
227
|
method: "POST",
|
|
228
228
|
headers: this.headers,
|
|
229
|
-
body: JSON.stringify({ userId })
|
|
229
|
+
body: JSON.stringify({ userId, admissionProof })
|
|
230
230
|
}
|
|
231
231
|
);
|
|
232
232
|
const body = await res.json().catch(() => ({}));
|
|
@@ -245,6 +245,74 @@ var QueueHttpClient = class {
|
|
|
245
245
|
expiresAt: body.expiresAt
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
|
+
async getProtection(eventId) {
|
|
249
|
+
const res = await fetch(
|
|
250
|
+
`${this.apiUrl}/api/queue/${encodeURIComponent(eventId)}/protection`,
|
|
251
|
+
{ headers: this.headers }
|
|
252
|
+
);
|
|
253
|
+
const body = await res.json().catch(() => ({}));
|
|
254
|
+
if (!res.ok) {
|
|
255
|
+
throw new Error(
|
|
256
|
+
body.message ?? `Error ${res.status} al consultar protecci\xF3n`
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
eventId: body.eventId ?? eventId,
|
|
261
|
+
configured: body.configured === true,
|
|
262
|
+
protected: body.protected === true,
|
|
263
|
+
isActive: body.isActive === true,
|
|
264
|
+
admissionMode: body.admissionMode ?? "PUBLIC",
|
|
265
|
+
challengeRequired: body.challengeRequired === true
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
async getAdmissionChallenge(eventId) {
|
|
269
|
+
const res = await fetch(
|
|
270
|
+
`${this.apiUrl}/api/queue/${encodeURIComponent(eventId)}/admission`,
|
|
271
|
+
{ headers: this.headers }
|
|
272
|
+
);
|
|
273
|
+
const body = await res.json().catch(() => ({}));
|
|
274
|
+
if (!res.ok) {
|
|
275
|
+
throw new Error(
|
|
276
|
+
body.message ?? `Error ${res.status} al preparar la admisi\xF3n`
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
if (body.required !== true) return { required: false };
|
|
280
|
+
if (!("publicKey" in body) || !body.publicKey) {
|
|
281
|
+
throw new Error("Respuesta inv\xE1lida al preparar la admisi\xF3n");
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
required: true,
|
|
285
|
+
publicKey: body.publicKey,
|
|
286
|
+
appearance: "interaction-only"
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
async verifyToken(eventId, token) {
|
|
290
|
+
const res = await fetch(
|
|
291
|
+
`${this.apiUrl}/api/queue/verify/${encodeURIComponent(eventId)}`,
|
|
292
|
+
{
|
|
293
|
+
method: "POST",
|
|
294
|
+
headers: this.headers,
|
|
295
|
+
body: JSON.stringify({ token })
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
const body = await res.json().catch(() => ({
|
|
299
|
+
valid: false,
|
|
300
|
+
reason: "Respuesta inv\xE1lida"
|
|
301
|
+
}));
|
|
302
|
+
if (body.valid === true && body.userId && body.eventId && body.expiresAt) {
|
|
303
|
+
return body;
|
|
304
|
+
}
|
|
305
|
+
if (body.valid === false) {
|
|
306
|
+
return { valid: false, reason: body.reason ?? "Token inv\xE1lido" };
|
|
307
|
+
}
|
|
308
|
+
if (!res.ok) {
|
|
309
|
+
return {
|
|
310
|
+
valid: false,
|
|
311
|
+
reason: body.message ?? `Error ${res.status} al validar token de cola`
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
return { valid: false, reason: "Respuesta inv\xE1lida" };
|
|
315
|
+
}
|
|
248
316
|
};
|
|
249
317
|
|
|
250
318
|
// src/centralq.ts
|
package/dist/react.mjs
CHANGED
package/dist/server.js
CHANGED
|
@@ -34,7 +34,7 @@ function normalizeApiUrl(apiUrl) {
|
|
|
34
34
|
async function validateQueueTokenServer(options) {
|
|
35
35
|
const apiUrl = options.apiUrl ?? CENTRALQ_DEFAULT_API_URL;
|
|
36
36
|
const response = await fetch(
|
|
37
|
-
`${normalizeApiUrl(apiUrl)}/api/verify/${encodeURIComponent(options.eventId)}`,
|
|
37
|
+
`${normalizeApiUrl(apiUrl)}/api/queue/verify/${encodeURIComponent(options.eventId)}`,
|
|
38
38
|
{
|
|
39
39
|
method: "POST",
|
|
40
40
|
headers: {
|
package/dist/server.mjs
CHANGED
package/dist/svelte.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'svelte/store';
|
|
2
|
-
import { Q as QueueStatus, C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, d as CentralQOptions } from './centralq-
|
|
2
|
+
import { Q as QueueStatus, C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, d as CentralQOptions } from './centralq-C3ukDo0x.mjs';
|
|
3
3
|
|
|
4
4
|
interface CentralQStores {
|
|
5
5
|
/** Store con el token JWT si el usuario fue admitido */
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'svelte/store';
|
|
2
|
-
import { Q as QueueStatus, C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, d as CentralQOptions } from './centralq-
|
|
2
|
+
import { Q as QueueStatus, C as CentralQ, c as CentralQCreateOptions, a as CentralQClient, d as CentralQOptions } from './centralq-C3ukDo0x.js';
|
|
3
3
|
|
|
4
4
|
interface CentralQStores {
|
|
5
5
|
/** Store con el token JWT si el usuario fue admitido */
|
package/dist/svelte.js
CHANGED
|
@@ -221,13 +221,13 @@ var QueueHttpClient = class {
|
|
|
221
221
|
}
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
|
-
async issueQueueInitToken(eventId, userId) {
|
|
224
|
+
async issueQueueInitToken(eventId, userId, admissionProof) {
|
|
225
225
|
const res = await fetch(
|
|
226
226
|
`${this.apiUrl}/api/queue/init/${encodeURIComponent(eventId)}`,
|
|
227
227
|
{
|
|
228
228
|
method: "POST",
|
|
229
229
|
headers: this.headers,
|
|
230
|
-
body: JSON.stringify({ userId })
|
|
230
|
+
body: JSON.stringify({ userId, admissionProof })
|
|
231
231
|
}
|
|
232
232
|
);
|
|
233
233
|
const body = await res.json().catch(() => ({}));
|
|
@@ -246,6 +246,74 @@ var QueueHttpClient = class {
|
|
|
246
246
|
expiresAt: body.expiresAt
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
|
+
async getProtection(eventId) {
|
|
250
|
+
const res = await fetch(
|
|
251
|
+
`${this.apiUrl}/api/queue/${encodeURIComponent(eventId)}/protection`,
|
|
252
|
+
{ headers: this.headers }
|
|
253
|
+
);
|
|
254
|
+
const body = await res.json().catch(() => ({}));
|
|
255
|
+
if (!res.ok) {
|
|
256
|
+
throw new Error(
|
|
257
|
+
body.message ?? `Error ${res.status} al consultar protecci\xF3n`
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
eventId: body.eventId ?? eventId,
|
|
262
|
+
configured: body.configured === true,
|
|
263
|
+
protected: body.protected === true,
|
|
264
|
+
isActive: body.isActive === true,
|
|
265
|
+
admissionMode: body.admissionMode ?? "PUBLIC",
|
|
266
|
+
challengeRequired: body.challengeRequired === true
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
async getAdmissionChallenge(eventId) {
|
|
270
|
+
const res = await fetch(
|
|
271
|
+
`${this.apiUrl}/api/queue/${encodeURIComponent(eventId)}/admission`,
|
|
272
|
+
{ headers: this.headers }
|
|
273
|
+
);
|
|
274
|
+
const body = await res.json().catch(() => ({}));
|
|
275
|
+
if (!res.ok) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
body.message ?? `Error ${res.status} al preparar la admisi\xF3n`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
if (body.required !== true) return { required: false };
|
|
281
|
+
if (!("publicKey" in body) || !body.publicKey) {
|
|
282
|
+
throw new Error("Respuesta inv\xE1lida al preparar la admisi\xF3n");
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
required: true,
|
|
286
|
+
publicKey: body.publicKey,
|
|
287
|
+
appearance: "interaction-only"
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
async verifyToken(eventId, token) {
|
|
291
|
+
const res = await fetch(
|
|
292
|
+
`${this.apiUrl}/api/queue/verify/${encodeURIComponent(eventId)}`,
|
|
293
|
+
{
|
|
294
|
+
method: "POST",
|
|
295
|
+
headers: this.headers,
|
|
296
|
+
body: JSON.stringify({ token })
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
const body = await res.json().catch(() => ({
|
|
300
|
+
valid: false,
|
|
301
|
+
reason: "Respuesta inv\xE1lida"
|
|
302
|
+
}));
|
|
303
|
+
if (body.valid === true && body.userId && body.eventId && body.expiresAt) {
|
|
304
|
+
return body;
|
|
305
|
+
}
|
|
306
|
+
if (body.valid === false) {
|
|
307
|
+
return { valid: false, reason: body.reason ?? "Token inv\xE1lido" };
|
|
308
|
+
}
|
|
309
|
+
if (!res.ok) {
|
|
310
|
+
return {
|
|
311
|
+
valid: false,
|
|
312
|
+
reason: body.message ?? `Error ${res.status} al validar token de cola`
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
return { valid: false, reason: "Respuesta inv\xE1lida" };
|
|
316
|
+
}
|
|
249
317
|
};
|
|
250
318
|
|
|
251
319
|
// src/centralq.ts
|
package/dist/svelte.mjs
CHANGED
package/dist/vue.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
|
-
import { c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, C as CentralQ } from './centralq-
|
|
2
|
+
import { c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, C as CentralQ } from './centralq-C3ukDo0x.mjs';
|
|
3
3
|
|
|
4
4
|
interface QueueData {
|
|
5
5
|
token: string | null;
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
|
-
import { c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, C as CentralQ } from './centralq-
|
|
2
|
+
import { c as CentralQCreateOptions, a as CentralQClient, Q as QueueStatus, C as CentralQ } from './centralq-C3ukDo0x.js';
|
|
3
3
|
|
|
4
4
|
interface QueueData {
|
|
5
5
|
token: string | null;
|