* Deterministic UUIDv5 (SHA-1) of `name` within `namespace`. The same inputs * always yield the same UUID, which is how fork block identity stays stable.
(name: string, namespace: string)
| 17 | * always yield the same UUID, which is how fork block identity stays stable. |
| 18 | */ |
| 19 | function uuidV5(name: string, namespace: string): string { |
| 20 | const hash = createHash('sha1') |
| 21 | hash.update(uuidToBytes(namespace)) |
| 22 | hash.update(Buffer.from(name, 'utf8')) |
| 23 | const bytes = hash.digest().subarray(0, 16) |
| 24 | bytes[6] = (bytes[6] & 0x0f) | 0x50 |
| 25 | bytes[8] = (bytes[8] & 0x3f) | 0x80 |
| 26 | const hex = bytes.toString('hex') |
| 27 | return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}` |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Derive the target block id for a source block copied into a target workflow. |
no test coverage detected