Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/builders/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Util from '../utils/util.js'
import CoT from '../cot.js';
import type JSONCoT from '../types/types.js';
import type { Static } from '@sinclair/typebox';
import { v4 as randomUUID } from 'uuid';

export type MissionChatMember = {
uid: string;
Expand All @@ -27,7 +26,7 @@ export type MissionChatInput = {

export class MissionChat extends CoT {
constructor(chat: MissionChatInput) {
const messageId = chat.messageId || randomUUID();
const messageId = chat.messageId || crypto.randomUUID();

const cot: Static<typeof JSONCoT> = {
event: {
Expand Down Expand Up @@ -113,7 +112,7 @@ export class DirectChat extends CoT {
_attributes: {
parent: chat.parent || 'RootContactGroup',
groupOwner: chat.groupOwner ? 'true' : 'false',
messageId: chat.messageId || randomUUID(),
messageId: chat.messageId || crypto.randomUUID(),
chatroom: chat.chatroom || chat.to.callsign,
id: chat.to.uid,
senderCallsign: chat.from.callsign
Expand All @@ -130,7 +129,7 @@ export class DirectChat extends CoT {
}
}

cot.event._attributes.uid = `GeoChat.${chat.from.uid}.${chat.to.uid}.${randomUUID()}`;
cot.event._attributes.uid = `GeoChat.${chat.from.uid}.${chat.to.uid}.${crypto.randomUUID()}`;

if (!cot.event.detail) cot.event.detail = {};

Expand Down
3 changes: 1 addition & 2 deletions lib/builders/fileshare.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Util from '../utils/util.js'
import { v4 as randomUUID } from 'uuid';
import CoT from '../cot.js';
import type JSONCoT from '../types/types.js';
import type { FileShareAttributes } from '../types/types.js';
Expand All @@ -17,7 +16,7 @@ export class FileShare extends CoT {
},
ackrequest: {
_attributes: {
uid: randomUUID(),
uid: crypto.randomUUID(),
tag: 'transfer',
ackrequested: true
}
Expand Down
3 changes: 1 addition & 2 deletions lib/cot.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v4 as randomUUID } from 'uuid';
import Err from '@openaddresses/batch-error';
import type { Static } from '@sinclair/typebox';
import type {
Expand Down Expand Up @@ -198,7 +197,7 @@ export default class CoT {
} else if (video.uid && connection && !connection.uid) {
connection.uid = video.uid;
} else if (!video.uid) {
video.uid = randomUUID();
video.uid = crypto.randomUUID();
}

detail.__video = {
Expand Down
9 changes: 4 additions & 5 deletions lib/data-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Err from '@openaddresses/batch-error';
import { ZipArchive } from '@archiver/archiver';
import StreamZip from 'node-stream-zip'
import { Readable } from 'node:stream';
import { v4 as randomUUID } from 'uuid';
import CoT from './cot.js';
import { CoTParser } from './parser.js';
import xmljs from 'xml-js';
Expand Down Expand Up @@ -94,7 +93,7 @@ async function materializeDataPackageInput(
}

const ext = path.parse(name || 'package.zip').ext || '.zip';
const inputPath = path.resolve(os.tmpdir(), `${randomUUID()}${ext}`);
const inputPath = path.resolve(os.tmpdir(), `${crypto.randomUUID()}${ext}`);

if (input instanceof Buffer) {
await fsp.writeFile(inputPath, input);
Expand Down Expand Up @@ -150,7 +149,7 @@ export class DataPackage {
if (opts && opts.path) {
this.path = opts.path;
} else {
this.path = os.tmpdir() + '/' + randomUUID();
this.path = os.tmpdir() + '/' + crypto.randomUUID();
}

this.destroyed = false;
Expand All @@ -160,7 +159,7 @@ export class DataPackage {
this.version = '2';
this.unknown = {};
this.settings = {
uid: uid ?? randomUUID(),
uid: uid ?? crypto.randomUUID(),
name: name ?? 'New Data Package'
};
this.contents = [];
Expand Down Expand Up @@ -535,7 +534,7 @@ export class DataPackage {
if (this.destroyed) throw new Err(400, null, 'Attempt to access Data Package after it has been destroyed');
if (!opts.ignore) opts.ignore = false;

const uid = opts.uid ?? randomUUID();
const uid = opts.uid ?? crypto.randomUUID();

this.#addContent(`${uid}/${opts.name}`, opts.attachment || uid, opts.name, opts.ignore);
await fsp.mkdir(`${this.path}/raw/${uid}/`, { recursive: true });
Expand Down
5 changes: 2 additions & 3 deletions lib/parser/from_geojson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Err from '@openaddresses/batch-error';
import { v4 as randomUUID } from 'uuid';
import type { Static } from '@sinclair/typebox';
import type {
LinkAttributes,
Expand Down Expand Up @@ -68,7 +67,7 @@ export async function from_geojson(
if (feature.id) {
cot.event._attributes.uid = String(feature.id);
} else {
cot.event._attributes.uid = randomUUID();
cot.event._attributes.uid = crypto.randomUUID();
}

if (!cot.event.detail) cot.event.detail = {};
Expand Down Expand Up @@ -490,7 +489,7 @@ export async function from_geojson(
cot.event.detail.link.push({
_attributes: {
type: 'b-m-p-c',
uid: randomUUID(),
uid: crypto.randomUUID(),
callsign: "",
point: `${coord[1]},${coord[0]}`
}
Expand Down
3 changes: 1 addition & 2 deletions lib/parser/normalize_geojson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Err from '@openaddresses/batch-error';
import { v4 as randomUUID } from 'uuid';
import type { Static } from '@sinclair/typebox';
import { coordEach } from "@turf/meta";
import TypeValidator from '../type.js';
Expand All @@ -24,7 +23,7 @@ export async function normalize_geojson(
}

if (!feature.id) {
feature.id = randomUUID();
feature.id = crypto.randomUUID();
}

const props = feature.properties;
Expand Down
3 changes: 1 addition & 2 deletions lib/utils/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { v4 as randomUUID } from 'uuid';
import type { Static } from '@sinclair/typebox';
import type {
EventAttributes,
Expand Down Expand Up @@ -73,7 +72,7 @@ export default class Util {
* Generate a random UUID
*/
static cot_uuid(): string {
return randomUUID()
return crypto.randomUUID()
}

/**
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"milsymbol": "^3.0.2",
"node-stream-zip": "^1.15.0",
"protobufjs": "^8.0.0",
"uuid": "^14.0.0",
"xml-js": "^1.6.11"
},
"devDependencies": {
Expand Down
Loading