@@ -17,6 +17,7 @@ import {
17
17
IdentityStorage ,
18
18
InMemoryMerkleTreeStorage ,
19
19
IStateStorage ,
20
+ JsonDocumentObject ,
20
21
Profile ,
21
22
RootInfo ,
22
23
StateInfo ,
@@ -489,4 +490,71 @@ describe('Verify credential proof', () => {
489
490
const isValid = await credential . verifyProof ( ProofType . Iden3SparseMerkleTreeProof , resolverURL ) ;
490
491
expect ( isValid ) . to . be . eq ( true ) ;
491
492
} ) ;
493
+
494
+ it ( 'W3CCredential.fromJSON deep copy' , async ( ) => {
495
+ const credObject = {
496
+ id : 'urn:uuid:0f2a2d08-65e5-11ef-bc4e-0a58a9feac02' ,
497
+ '@context' : [
498
+ 'https://www.w3.org/2018/credentials/v1' ,
499
+ 'https://schema.iden3.io/core/jsonld/iden3proofs.jsonld' ,
500
+ 'ipfs://QmfK8fsSz5UWm44p5eN9KjsTzi1YEsDCG1LHMFcW9T2Dbe'
501
+ ] ,
502
+ type : [ 'VerifiableCredential' , 'HowManyAttribute' ] ,
503
+ issuanceDate : '2024-08-29T08:59:54.82008584Z' ,
504
+ credentialSubject : {
505
+ id : 'did:polygonid:privado:test:3LD3n5edw91PGdNh329rqRydBdaQj2Zwrqf7u49gU2' ,
506
+ type : 'HowManyAttribute' ,
507
+ 'att-1-string' : 'string' ,
508
+ 'att-2-int' : 22 ,
509
+ 'att-3-bool' : false ,
510
+ 'att-4-obj' : {
511
+ 'att-bool' : true ,
512
+ 'att-int' : 14 ,
513
+ 'att-string' : 'string2'
514
+ }
515
+ } ,
516
+ credentialStatus : {
517
+ id : 'https://issuer-node-api-v2-test.privado.id/v1/agent' ,
518
+ revocationNonce : 683471303 ,
519
+ type : 'Iden3commRevocationStatusV1.0'
520
+ } ,
521
+ issuer : 'did:polygonid:polygon:amoy:2qUPgJsiQP8sdQuckFEj73bDRU84NYnmzwQJr5M1Fd' ,
522
+ credentialSchema : {
523
+ id : 'https://ipfs.io/ipfs/QmQvWV4BJqV16czvr2Cpc8qe5mGG51sii4YuDyMPjSxYp7' ,
524
+ type : 'JsonSchema2023'
525
+ } ,
526
+ proof : [
527
+ {
528
+ type : 'BJJSignature2021' ,
529
+ issuerData : {
530
+ id : 'did:polygonid:polygon:amoy:2qUPgJsiQP8sdQuckFEj73bDRU84NYnmzwQJr5M1Fd' ,
531
+ state : {
532
+ claimsTreeRoot : '8a68b09bc81d49cea0e0a0f56990a0b3cb1bb55d963d309fb357356d7897140d' ,
533
+ value : '1c44078aa45ec70bebbb98f525edf3177ccb516e12beffd84fbdbaf86ad2bc13'
534
+ } ,
535
+ authCoreClaim :
536
+ 'cca3371a6cb1b715004407e325bd993c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000548961cf73cbd6b488027734ea8dc2dd913b15f2dccf2ce13c7bb1fad409cb1a0504589c8c855e1455cf136d2fd27a4c1cded8915633f8e36a06843ef753b21e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ,
537
+ mtp : {
538
+ existence : true ,
539
+ siblings : [ ]
540
+ } ,
541
+ credentialStatus : {
542
+ id : 'https://issuer-node-api-v2-test.privado.id/v1/agent' ,
543
+ revocationNonce : 0 ,
544
+ type : 'Iden3commRevocationStatusV1.0' ,
545
+ statusIssuer : null
546
+ }
547
+ } ,
548
+ coreClaim :
549
+ '31df932e35b3beef628544cf7d28dbcb2200000000000000000000000000000002a2c7b26f04aff4b573354055c1d44e3a35021a75ec5e941c10780719aa0b008489bda654ede194c8fbd7e82417f48813157f04fb917f3a4413be6209d338290000000000000000000000000000000000000000000000000000000000000000c7f1bc2800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ,
550
+ signature :
551
+ '4732c4e4350b84087cd43f463bbf4103b1a3561659ae6fb144ba0e78657281233d393fbef1490ba7492c56f3f89fe7e08e47ddcffef20d02f4a40bddfde06702'
552
+ }
553
+ ]
554
+ } ;
555
+ const cred = W3CCredential . fromJSON ( credObject ) ;
556
+ delete ( credObject . credentialSubject as JsonDocumentObject ) [ 'att-4-obj' ] ;
557
+ expect ( cred . credentialSubject [ 'att-4-obj' ] ) . not . to . be . eq ( undefined ) ;
558
+ expect ( cred . credentialSubject [ 'att-4-obj' ] [ 'att-bool' ] ) . to . be . eq ( true ) ;
559
+ } ) ;
492
560
} ) ;
0 commit comments