@@ -2,54 +2,53 @@ import {
22 bitcannManager ,
33} from './common/setup.js' ;
44import { parseRecords } from '../lib/util/parser.js' ;
5- import { createHash } from 'crypto ' ;
5+ import { binToHex , hexToBin , instantiateSha256 } from '@bitauth/libauth ' ;
66
77( async ( ) =>
88{
99 const name = 'satoshi' ;
1010 const records = await bitcannManager . getRecords ( { name } ) ;
1111 console . log ( records ) ;
12- } ) ( ) ;
1312
1413
15- const records = [
16- 'bio.name=Vikram Sarabhai' ,
17- 'bio.email.0=a@example.com' ,
18- 'bio.email.1=b@example.com' ,
19- 'bio.email.meta=type:array' ,
20- 'bio.description.0=Founder of ISRO.' ,
21- 'bio.description.1=Spearheaded India’s space program.' ,
22- 'bio.description.meta=type:text' ,
23- 'social.twitter=handle' ,
24- 'social.github=vikram123' ,
25- 'crypto.BCH.address=bitcoincash:qpm2qsznhks23z7629mms6s4cwef74abcdabdaabdc' ,
26- `revoked=${ createHash ( 'sha256' ) . update ( 'bio.email.1=b@example.com' )
27- . digest ( 'hex' ) } `,
28- `revoked=${ createHash ( 'sha256' ) . update ( 'social.github=vikram123' )
29- . digest ( 'hex' ) } `,
30- `revoked=${ createHash ( 'sha256' ) . update ( 'bio.description.meta=type:text' )
31- . digest ( 'hex' ) } `,
32- 'bio.name=Vikram Sarabhai' ,
33- 'bio.avatar=https://example.com/vikram.jpg' ,
34- 'bio.email=vikram@example.com' ,
35- 'bio.description.0=Founder of the Indian Space Research Organisation (ISRO).' ,
36- 'bio.description.1=Spearheaded India’s entry into the space age with the first satellite launch.' ,
37- 'bio.description.meta=type:text' ,
38- `revoked=${ createHash ( 'sha256' ) . update ( 'bio.description.meta=type:text' )
39- . digest ( 'hex' ) } `,
40- `revoked=${ createHash ( 'sha256' ) . update ( 'bio.description.1=Spearheaded India’s entry into the space age with the first satellite launch.' )
41- . digest ( 'hex' ) } `,
42- 'social.twitter=handle' ,
43- 'social.telegram=handle' ,
44- 'crypto.BCH.rpa=paycode:qygqyhh8kyxvda2rtatyh9dm0acvs89fgyhrpgplq0y6ac782cxhzaadq2l5tn8scc42kne6z6zfdx5t56ljkqsv9rg7thy0ffc42cdemyk82qqqqqqqq8cxkz4r' ,
45- 'crypto.BCH.address=bitcoincash:qpm2qsznhks23z7629mms6s4cwef74abcdabdaabdc' ,
46- 'crypto.USDT.version.ERC20.address=0xabcdef1234567890abcdef1234567890abcdef12' ,
47- 'token.EVM.ETH.address=0xabcdef1234567890abcdef1234567890abcdef12' ,
48- 'dns.a=192.168.1.1' ,
49- 'dns.aaaa=2606:2800:220:1:248:1893:25c8:194' ,
50- 'contract.fingerprint=0x1234567890abcdef1234567890abcdef12345678' ,
51- 'contract.params=1465077837 4 -789332029 e4' ,
52- ] ;
14+ const sha256 = await instantiateSha256 ( ) ;
15+
16+ const testRecords = [
17+ 'bio.name=Vikram Sarabhai' ,
18+ 'bio.email.0=a@example.com' ,
19+ 'bio.email.1=b@example.com' ,
20+ 'bio.email.meta=type:array' ,
21+ 'bio.description.0=Founder of ISRO.' ,
22+ 'bio.description.1=Spearheaded India’s space program.' ,
23+ 'bio.description.meta=type:text' ,
24+ 'social.twitter=handle' ,
25+ 'social.github=vikram123' ,
26+ 'crypto.BCH.address=bitcoincash:qpm2qsznhks23z7629mms6s4cwef74abcdabdaabdc' ,
27+ `revoked=${ binToHex ( sha256 . hash ( hexToBin ( 'bio.email.1=b@example.com' ) ) ) } ` ,
28+ `revoked=${ binToHex ( sha256 . hash ( hexToBin ( 'social.github=vikram123' ) ) ) } ` ,
29+ `revoked=${ binToHex ( sha256 . hash ( hexToBin ( 'bio.description.meta=type:text' ) ) ) } ` ,
30+ 'bio.name=Vikram Sarabhai' ,
31+ 'bio.avatar=https://example.com/vikram.jpg' ,
32+ 'bio.email=vikram@example.com' ,
33+ 'bio.description.0=Founder of the Indian Space Research Organisation (ISRO).' ,
34+ 'bio.description.1=Spearheaded India’s entry into the space age with the first satellite launch.' ,
35+ 'bio.description.meta=type:text' ,
36+ `revoked=${ binToHex ( sha256 . hash ( hexToBin ( 'bio.description.meta=type:text' ) ) ) } ` ,
37+ `revoked=${ binToHex ( sha256 . hash ( hexToBin ( 'bio.description.1=Spearheaded India’s entry into the space age with the first satellite launch.' ) ) ) } ` ,
38+ 'social.twitter=handle' ,
39+ 'social.telegram=handle' ,
40+ 'crypto.BCH.rpa=paycode:qygqyhh8kyxvda2rtatyh9dm0acvs89fgyhrpgplq0y6ac782cxhzaadq2l5tn8scc42kne6z6zfdx5t56ljkqsv9rg7thy0ffc42cdemyk82qqqqqqqq8cxkz4r' ,
41+ 'crypto.BCH.address=bitcoincash:qpm2qsznhks23z7629mms6s4cwef74abcdabdaabdc' ,
42+ 'crypto.USDT.version.ERC20.address=0xabcdef1234567890abcdef1234567890abcdef12' ,
43+ 'token.EVM.ETH.address=0xabcdef1234567890abcdef1234567890abcdef12' ,
44+ 'dns.a=192.168.1.1' ,
45+ 'dns.aaaa=2606:2800:220:1:248:1893:25c8:194' ,
46+ 'contract.fingerprint=0x1234567890abcdef1234567890abcdef12345678' ,
47+ 'contract.params=1465077837 4 -789332029 e4' ,
48+ ] ;
49+
50+
51+ const parsed = await parseRecords ( testRecords ) ;
52+ console . log ( JSON . stringify ( parsed , null , 2 ) ) ;
53+ } ) ( ) ;
5354
54- const parsed = parseRecords ( records ) ;
55- console . log ( JSON . stringify ( parsed , null , 2 ) ) ;
0 commit comments