IF Commons GitHub

uuid

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0001-crypto FR-007

UUIDs (RFC 9562): the branded Uuid, its text form read and written, the name-based version 5 (SHA-1 of a namespace and a name) and the namespaces RFC 9562 defines (Appendix A.4: DNS, URL, OID, X.500). A version 5 UUID is the same for the same namespace and name on every runtime, so the standard formats name what they describe by it and the same input gives the same document (commons 0007-grc FR-017, FR-018). SHA-1 is Web Crypto's (crypto.subtle.digest), so uuidV5 is asynchronous; it is used here as RFC 9562 uses it, to name, not to protect.

import { NAMESPACE_DNS, uuidV5 } from "./uuid.ts";
await uuidV5(NAMESPACE_DNS, "www.example.com"); // "2ed6657d-e927-568b-95e1-2665a8aea6a2"

Source: commons/crypto/src/uuid.ts

15 of 30 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

uuidnamespace
namespace uuid
uuid.Uuidtypeno test imports it
type Uuid = Brand<string, "Uuid">;

A UUID in RFC 9562's text form, lower-case: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; made only by uuidOf, uuidFromBytes and uuidV5.

uuid.uuidOffunctionno test imports it
function uuidOf(text: string): Uuid | undefined

Text as a Uuid (any case, with or without a urn:uuid: prefix), lower-cased; undefined where it is not one.

uuid.uuidFromBytesfunctionno test imports it
function uuidFromBytes(bytes: Uint8Array<ArrayBufferLike>): Uuid | undefined

Sixteen bytes as a Uuid, or undefined where there are not sixteen.

uuid.uuidBytesfunctionno test imports it
function uuidBytes(u: Uuid): Uint8Array<ArrayBufferLike>

A UUID's sixteen bytes.

uuid.uuidVersionfunctionno test imports it
function uuidVersion(u: Uuid): number

A UUID's version, the high four bits of its seventh byte (5 for a name-based UUID with SHA-1).

uuid.uuidUrnfunctionno test imports it
function uuidUrn(u: Uuid): `urn:uuid:${string}`

A UUID as a URN, urn:uuid:... (RFC 9562 Section 4).

uuid.NIL_UUIDconstno test imports it
const NIL_UUID: Uuid

The Nil UUID, all zeros (RFC 9562 Section 5.9).

uuid.NAMESPACE_DNSconstno test imports it
const NAMESPACE_DNS: Uuid

The namespace of fully qualified domain names (RFC 9562 Section 6.6).

uuid.NAMESPACE_URLconstno test imports it
const NAMESPACE_URL: Uuid

The namespace of URLs (RFC 9562 Section 6.6).

uuid.NAMESPACE_OIDconstno test imports it
const NAMESPACE_OID: Uuid

The namespace of ISO object identifiers (RFC 9562 Section 6.6).

uuid.NAMESPACE_X500constno test imports it
const NAMESPACE_X500: Uuid

The namespace of X.500 distinguished names, in DER or text (RFC 9562 Section 6.6).

uuid.uuidV5functionno test imports it
function uuidV5(namespace: Uuid, name: string | Uint8Array<ArrayBufferLike>): Promise<Uuid>

The version 5 UUID of a name in a namespace (RFC 9562 Section 5.5): the first sixteen bytes of SHA-1 over the namespace's bytes and then the name's (a string is taken as UTF-8), with the version (5) and the variant (10) set.

uuid.nameOffunctionno test imports it
function nameOf(parts: readonly string[]): string

A stable name made of parts, for uuidV5: the parts as a JSON array, so that no two lists of parts give the same name (["a/b"] and ["a", "b"] stay apart).

uuid.uuidV5Offunctionno test imports it
function uuidV5Of(namespace: Uuid, parts: readonly string[]): Promise<Uuid>

The version 5 UUID of a name made of parts (nameOf) in a namespace.

uuid.uuidDecoderconstno test imports it
const uuidDecoder: Decoder<Uuid>

The decoder of a UUID in text (any case, or a urn:uuid: URN).

Uuidtype
type Uuid = Brand<string, "Uuid">;

A UUID in RFC 9562's text form, lower-case: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; made only by uuidOf, uuidFromBytes and uuidV5.

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

uuidOffunction
function uuidOf(text: string): Uuid | undefined

Text as a Uuid (any case, with or without a urn:uuid: prefix), lower-cased; undefined where it is not one.

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

uuidFromBytesfunction
function uuidFromBytes(bytes: Uint8Array<ArrayBufferLike>): Uuid | undefined

Sixteen bytes as a Uuid, or undefined where there are not sixteen.

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

uuidBytesfunction
function uuidBytes(u: Uuid): Uint8Array<ArrayBufferLike>

A UUID's sixteen bytes.

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

uuidVersionfunction
function uuidVersion(u: Uuid): number

A UUID's version, the high four bits of its seventh byte (5 for a name-based UUID with SHA-1).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

uuidUrnfunction
function uuidUrn(u: Uuid): `urn:uuid:${string}`

A UUID as a URN, urn:uuid:... (RFC 9562 Section 4).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

NIL_UUIDconst
const NIL_UUID: Uuid

The Nil UUID, all zeros (RFC 9562 Section 5.9).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

NAMESPACE_DNSconst
const NAMESPACE_DNS: Uuid

The namespace of fully qualified domain names (RFC 9562 Section 6.6).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

NAMESPACE_URLconst
const NAMESPACE_URL: Uuid

The namespace of URLs (RFC 9562 Section 6.6).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

NAMESPACE_OIDconst
const NAMESPACE_OID: Uuid

The namespace of ISO object identifiers (RFC 9562 Section 6.6).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

NAMESPACE_X500const
const NAMESPACE_X500: Uuid

The namespace of X.500 distinguished names, in DER or text (RFC 9562 Section 6.6).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

uuidV5function
function uuidV5(namespace: Uuid, name: string | Uint8Array<ArrayBufferLike>): Promise<Uuid>

The version 5 UUID of a name in a namespace (RFC 9562 Section 5.5): the first sixteen bytes of SHA-1 over the namespace's bytes and then the name's (a string is taken as UTF-8), with the version (5) and the variant (10) set.

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

nameOffunction
function nameOf(parts: readonly string[]): string

A stable name made of parts, for uuidV5: the parts as a JSON array, so that no two lists of parts give the same name (["a/b"] and ["a", "b"] stay apart).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

uuidV5Offunction
function uuidV5Of(namespace: Uuid, parts: readonly string[]): Promise<Uuid>

The version 5 UUID of a name made of parts (nameOf) in a namespace.

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

uuidDecoderconst
const uuidDecoder: Decoder<Uuid>

The decoder of a UUID in text (any case, or a urn:uuid: URN).

Imported by 4 tests of the run (4 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.