🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@ngraveio/ur-uuid

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngraveio/ur-uuid

Provides BC UR type for uuid.

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
1
-87.5%
Maintainers
5
Weekly downloads
 
Created
Source

UUID CBOR type

Installing

To install, run:

yarn add @ngraveio/ur-uuid
npm install --save @ngraveio/ur-uuid

Source: https://github.com/lucas-clemente/cbor-specs/blob/master/uuid.md

UUID Tag for CBOR

This document specifies a tag for UUID in Concise Binary Object Representation (CBOR) [1].

Tag: 37
Data item: byte string
Semantics: Binary UUID (RFC 4122 section 4.1.2)
Point of contact: Lucas Clemente <lucas@clemente.io>
Description of semantics: https://github.com/lucas-clemente/cbor-specs/blob/master/uuid.md

Usage

Generating a UUID

import { UUID } from '@ngraveio/ur-uuid';

const uuid = UUID.generate();
console.log(uuid.toString()); // Prints the generated UUID as a string

Creating a UUID from a string

import { UUID } from '@ngraveio/ur-uuid';

const uuidString = '123e4567-e89b-12d3-a456-426614174000';
const uuid = new UUID(uuidString);
console.log(uuid.toString()); // Prints the UUID as a string

Creating a UUID from bytes

import { UUID } from '@ngraveio/ur-uuid';

const uuidBytes = new Uint8Array([18, 62, 69, 103, 232, 155, 18, 211, 164, 86, 66, 20, 23, 64, 0]);
const uuid = new UUID(uuidBytes);
console.log(uuid.toString()); // Prints the UUID as a string

Verifying a UUID

import { UUID } from '@ngraveio/ur-uuid';

const uuidString = '123e4567-e89b-12d3-a456-426614174000';
const uuid = new UUID(uuidString);
const verification = uuid.verifyInput(uuidString);
console.log(verification.valid); // Prints true if the UUID is valid

Semantics

Tag 37 can be applied to a byte string (major type 2) to indicate that the byte string is a UUID as defined in RFC 4122 section 4.1.2.

References

[1] C. Bormann, and P. Hoffman. "Concise Binary Object Representation (CBOR)". RFC 7049, October 2013.

Author

Lucas Clemente lucas@clemente.io

Keywords

ngrave

FAQs

Package last updated on 20 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts