File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ export function fromBuffer(buffer: Buffer): string {
6363
6464export function v5 ( name : string , namespace : string ) : string {
6565 const namespaceBuffer = Buffer . from ( namespace . replace ( / - / g, "" ) , "hex" ) ;
66+ if ( namespaceBuffer . length !== 16 ) {
67+ throw new Error ( "Namespace must be a 128-bit UUID" ) ;
68+ }
6669 const nameBuffer = Buffer . from ( name , "utf8" ) ;
6770
6871 const hash = crypto . createHash ( "sha1" ) ;
@@ -83,3 +86,10 @@ export function v5(name: string, namespace: string): string {
8386 digest . subarray ( 10 , 16 ) . toString ( "hex" ) ,
8487 ] . join ( "-" ) ;
8588}
89+
90+ export const NameSpace = {
91+ DNS : "6ba7b810-9dad-11d1-80b4-00c04fd430c8" ,
92+ URL : "6ba7b811-9dad-11d1-80b4-00c04fd430c8" ,
93+ OID : "6ba7b812-9dad-11d1-80b4-00c04fd430c8" ,
94+ X500 : "6ba7b814-9dad-11d1-80b4-00c04fd430c8" ,
95+ } ;
You can’t perform that action at this time.
0 commit comments