Fix UUID validation
This commit is contained in:
@@ -77,7 +77,7 @@ export class LoginHandler
|
|||||||
// Ignore any error
|
// Ignore any error
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hardwareID === null || !validator.isUUID(String(hardwareID)))
|
if (hardwareID === null || !validator.isUUID(String(hardwareID), 'loose'))
|
||||||
{
|
{
|
||||||
hardwareID = UUID.random().toString();
|
hardwareID = UUID.random().toString();
|
||||||
await fs.promises.writeFile(hardwareIDFile, JSON.stringify({ id0: hardwareID }));
|
await fs.promises.writeFile(hardwareIDFile, JSON.stringify({ id0: hardwareID }));
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import { InventoryLibrary } from '../enums/InventoryLibrary';
|
|||||||
import { LandStatsEvent } from '../events/LandStatsEvent';
|
import { LandStatsEvent } from '../events/LandStatsEvent';
|
||||||
|
|
||||||
import * as LLSD from '@caspertech/llsd';
|
import * as LLSD from '@caspertech/llsd';
|
||||||
import type { CancelableRequest, Response } from 'got';
|
import type { CancelableRequest, Response as GotResponse } from 'got';
|
||||||
import got from 'got';
|
import got from 'got';
|
||||||
import * as Long from 'long';
|
import * as Long from 'long';
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ export class EventQueueClient
|
|||||||
public ack?: number;
|
public ack?: number;
|
||||||
public done = false;
|
public done = false;
|
||||||
|
|
||||||
private currentRequest?: CancelableRequest<Response<string>> = undefined;
|
private currentRequest?: CancelableRequest<GotResponse<string>> = undefined;
|
||||||
private readonly clientEvents: ClientEvents;
|
private readonly clientEvents: ClientEvents;
|
||||||
private readonly agent: Agent;
|
private readonly agent: Agent;
|
||||||
|
|
||||||
@@ -578,7 +578,7 @@ export class EventQueueClient
|
|||||||
}
|
}
|
||||||
public async request(url: string, data: string, contentType: string): Promise<string>
|
public async request(url: string, data: string, contentType: string): Promise<string>
|
||||||
{
|
{
|
||||||
let req: CancelableRequest<Response<string>> | undefined = undefined;
|
let req: CancelableRequest<GotResponse<string>> | undefined = undefined;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
req = got.post(url, {
|
req = got.post(url, {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export class UUID
|
|||||||
}
|
}
|
||||||
if (typeof obj[param] === 'string')
|
if (typeof obj[param] === 'string')
|
||||||
{
|
{
|
||||||
if (validator.isUUID(obj[param]))
|
if (validator.isUUID(obj[param], 'loose'))
|
||||||
{
|
{
|
||||||
return new UUID(obj[param]);
|
return new UUID(obj[param]);
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ export class UUID
|
|||||||
const u = obj[param].UUID[0];
|
const u = obj[param].UUID[0];
|
||||||
if (typeof u === 'string')
|
if (typeof u === 'string')
|
||||||
{
|
{
|
||||||
if (validator.isUUID(u))
|
if (validator.isUUID(u, 'loose'))
|
||||||
{
|
{
|
||||||
return new UUID(u);
|
return new UUID(u);
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ export class UUID
|
|||||||
public setUUID(val: string): boolean
|
public setUUID(val: string): boolean
|
||||||
{
|
{
|
||||||
const test = val.trim();
|
const test = val.trim();
|
||||||
if (validator.isUUID(test))
|
if (validator.isUUID(test, 'loose'))
|
||||||
{
|
{
|
||||||
this.mUUID = test;
|
this.mUUID = test;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ describe('UUID', () =>
|
|||||||
{
|
{
|
||||||
assert.fail('Returned UUID is not a string');
|
assert.fail('Returned UUID is not a string');
|
||||||
}
|
}
|
||||||
if (!validator.isUUID(uuid))
|
if (!validator.isUUID(uuid, 'loose'))
|
||||||
{
|
{
|
||||||
assert.fail('Returned string is not a valid UUID');
|
assert.fail('Returned string is not a valid UUID');
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ describe('UUID', () =>
|
|||||||
{
|
{
|
||||||
assert.fail('Returned second UUID is not a string');
|
assert.fail('Returned second UUID is not a string');
|
||||||
}
|
}
|
||||||
if (!validator.isUUID(secondUUID))
|
if (!validator.isUUID(secondUUID, 'loose'))
|
||||||
{
|
{
|
||||||
assert.fail('Second UUID is not a valid UUID');
|
assert.fail('Second UUID is not a valid UUID');
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ describe('UUID', () =>
|
|||||||
{
|
{
|
||||||
assert.fail('Returned UUID is not a string');
|
assert.fail('Returned UUID is not a string');
|
||||||
}
|
}
|
||||||
if (!validator.isUUID(uuid))
|
if (!validator.isUUID(uuid, 'loose'))
|
||||||
{
|
{
|
||||||
assert.fail('Returned string is not a valid UUID');
|
assert.fail('Returned string is not a valid UUID');
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ describe('UUID', () =>
|
|||||||
{
|
{
|
||||||
assert.fail('Returned UUID is not a string');
|
assert.fail('Returned UUID is not a string');
|
||||||
}
|
}
|
||||||
if (!validator.isUUID(str))
|
if (!validator.isUUID(str, 'loose'))
|
||||||
{
|
{
|
||||||
assert.fail('Returned string is not a valid UUID');
|
assert.fail('Returned string is not a valid UUID');
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ describe('UUID', () =>
|
|||||||
{
|
{
|
||||||
assert.fail('Returned UUID is not a string');
|
assert.fail('Returned UUID is not a string');
|
||||||
}
|
}
|
||||||
if (!validator.isUUID(result))
|
if (!validator.isUUID(result, 'loose'))
|
||||||
{
|
{
|
||||||
assert.fail('Returned string is not a valid UUID');
|
assert.fail('Returned string is not a valid UUID');
|
||||||
}
|
}
|
||||||
|
|||||||
4641
package-lock.json
generated
4641
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@caspertech/node-metaverse",
|
"name": "@caspertech/node-metaverse",
|
||||||
"version": "0.8.3",
|
"version": "0.8.5",
|
||||||
"description": "A node.js interface for Second Life.",
|
"description": "A node.js interface for Second Life.",
|
||||||
"main": "dist/lib/index.js",
|
"main": "dist/lib/index.js",
|
||||||
"types": "dist/lib/index.d.ts",
|
"types": "dist/lib/index.d.ts",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"@types/node": "^22.4.0",
|
"@types/node": "^22.4.0",
|
||||||
"@types/tiny-async-pool": "^2.0.2",
|
"@types/tiny-async-pool": "^2.0.2",
|
||||||
"@types/uuid": "^8.3.4",
|
"@types/uuid": "^8.3.4",
|
||||||
"@types/validator": "^13.12.2",
|
"@types/validator": "^13.15.2",
|
||||||
"@types/xml2js": "^0.4.14",
|
"@types/xml2js": "^0.4.14",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
||||||
"@typescript-eslint/parser": "^8.15.0",
|
"@typescript-eslint/parser": "^8.15.0",
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.1",
|
||||||
"tiny-async-pool": "^2.1.0",
|
"tiny-async-pool": "^2.1.0",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"validator": "^13.12.0",
|
"validator": "^13.15.15",
|
||||||
"vitest": "^2.1.6",
|
"vitest": "^2.1.6",
|
||||||
"winston": "^3.11.0",
|
"winston": "^3.11.0",
|
||||||
"xml": "^1.0.1",
|
"xml": "^1.0.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user