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omBytes } from \"crypto\"\nimport { newError } from \"./index\"\n\nconst invalidName = \"options.name must be either a string or a Buffer\"\n\n// Node ID according to rfc4122#section-4.5\nconst randomHost = randomBytes(16)\nrandomHost[0] = randomHost[0] | 0x01\n\n// lookup table hex to byte\nconst hex2byte: any = {}\n\n// lookup table byte to hex\nconst byte2hex: Array<string> = []\n// populate lookup tables\nfor (let i = 0; i < 256; i++) {\n const hex = (i + 0x100).toString(16).substr(1)\n hex2byte[hex] = i\n byte2hex[i] = hex\n}\n\n// UUID class\nexport class UUID {\n private ascii: string | null = null\n private readonly binary: Buffer | null = null\n private readonly version: number\n\n // from rfc4122#appendix-C\n static readonly OID = UUID.parse(\"6ba7b812-9dad-11d1-80b4-00c04fd430c8\")\n\n constructor(uuid: Buffer | string) {\n const check = UUID.check(uuid)\n if (!check) {\n throw new Error(\"not a UUID\")\n }\n\n this.version = check.version!!\n\n if (check.format === \"ascii\") {\n this.ascii = uuid as string\n }\n else {\n this.binary = uuid as Buffer\n }\n }\n\n static v5(name: string | Buffer, namespace: Buffer) {\n return uuidNamed(name, \"sha1\", 0x50, namespace)\n }\n\n toString() {\n if (this.ascii == null) {\n this.ascii = stringify(this.binary!!)\n }\n return this.ascii\n }\n\n inspect() {\n return `UUID v${this.version} ${this.toString()}`\n }\n\n static check(uuid: Buffer | string, offset: number = 0) {\n if (typeof uuid === \"string\") {\n uuid = uuid.toLowerCase()\n\n if (!/^[a-f0-9]{8}(-[a-f0-9]{4}){3}-([a-f0-9]{12})$/.test(uuid)) {\n return false\n }\n\n if (uuid === \"00000000-0000-0000-0000-000000000000\") {\n return {version: undefined, variant: \"nil\", format: \"ascii\"}\n }\n\n return {\n version: (hex2byte[uuid[14] + uuid[15]] & 0xf0) >> 4,\n variant: getVariant((hex2byte[uuid[19] + uuid[20]] & 0xe0) >> 5),\n format: \"ascii\"\n }\n }\n\n if (Buffer.isBuffer(uuid)) {\n if (uuid.length < offset + 16) {\n return false\n }\n\n let i = 0\n for (; i < 16; i++) {\n if (uuid[offset + i] !== 0) {\n break\n }\n }\n if (i === 16) {\n return {version: undefined, variant: \"nil\", format: \"binary\"}\n }\n\n return {\n version: (uuid[offset + 6] & 0xf0) >> 4,\n variant: getVariant((uuid[offset + 8] & 0xe0) >> 5),\n format: \"binary\"\n }\n }\n\n throw newError(\"Unknown type of uuid\", \"ERR_UNKNOWN_UUID_TYPE\")\n }\n\n // read stringified uuid into a Buffer\n static parse(input: string) {\n const buffer = Buffer.allocUnsafe(16)\n let j = 0\n for (let i = 0; i < 16; i++) {\n buffer[i] = hex2byte[input[j++] + input[j++]]\n if (i === 3 || i === 5 || i === 7 || i === 9) {\n j += 1\n }\n }\n return buffer\n }\n}\n\n// according to rfc4122#section-4.1.1\nfunction getVariant(bits: number) {\n switch (bits) {\n case 0:\n case 1:\n case 3:\n return \"ncs\"\n case 4:\n case 5:\n return \"rfc4122\"\n case 6:\n return \"microsoft\"\n default:\n return \"future\"\n }\n}\n\nenum UuidEncoding {\n ASCII, BINARY, OBJECT\n}\n\n// v3 + v5\nfunction uuidNamed(name: string | Buffer, hashMethod: string, version: number, namespace: Buffer, encoding: UuidEncoding = UuidEncoding.ASCII) {\n const hash = createHash(hashMethod)\n\n const nameIsNotAString = typeof name !== \"string\"\n if (nameIsNotAString && !Buffer.isBuffer(name)) {\n throw newError(invalidName, \"ERR_INVALID_UUID_NAME\")\n }\n\n hash.update(namespace)\n hash.update(name)\n\n const buffer = hash.digest()\n let result: any\n switch (encoding) {\n case UuidEncoding.BINARY:\n buffer[6] = (buffer[6] & 0x0f) | version\n buffer[8] = (buffer[8] & 0x3f) | 0x80\n result = buffer\n break\n case UuidEncoding.OBJECT:\n buffer[6] = (buffer[6] & 0x0f) | version\n buffer[8] = (buffer[8] & 0x3f) | 0x80\n result = new UUID(buffer)\n break\n default:\n result = byte2hex[buffer[0]] + byte2hex[buffer[1]] +\n byte2hex[buffer[2]] + byte2hex[buffer[3]] + \"-\" +\n byte2hex[buffer[4]] + byte2hex[buffer[5]] + \"-\" +\n byte2hex[(buffer[6] & 0x0f) | version] +\n byte2hex[buffer[7]] + \"-\" +\n byte2hex[(buffer[8] & 0x3f) | 0x80] +\n byte2hex[buffer[9]] + \"-\" +\n byte2hex[buffer[10]] + byte2hex[buffer[11]] +\n byte2hex[buffer[12]] + byte2hex[buffer[13]] +\n byte2hex[buffer[14]] + byte2hex[buffer[15]]\n break\n }\n return result\n}\n\nfunction stringify(buffer: Buffer) {\n return byte2hex[buffer[0]] + byte2hex[buffer[1]] +\n byte2hex[buffer[2]] + byte2hex[buffer[3]] + \"-\" +\n byte2hex[buffer[4]] + byte2hex[buffer[5]] + \"-\" +\n byte2hex[buffer[6]] + byte2hex[buffer[7]] + \"-\" +\n byte2hex[buffer[8]] + byte2hex[buffer[9]] + \"-\" +\n byte2hex[buffer[10]] + byte2hex[buffer[11]] +\n byte2hex[buffer[12]] + byte2hex[buffer[13]] +\n byte2hex[buffer[14]] + byte2hex[buffer[15]]\n}\n\n// according to rfc4122#section-4.1.7\nexport const nil = new UUID(\"00000000-0000-0000-0000-000000000000\")\n\n// UUID.v4 = uuidRandom\n\n// UUID.v4fast = uuidRandomFast\n\n// UUID.v3 = function(options, callback) {\n// return uuidNamed(\"md5\", 0x30, options, callback)\n// }"],"sourceRoot":""}