@bifold/verifier 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/build/commonjs/README.md +4 -0
- package/build/commonjs/constants.js +9 -0
- package/build/commonjs/constants.js.map +1 -0
- package/build/commonjs/hooks/proofs.js +22 -0
- package/build/commonjs/hooks/proofs.js.map +1 -0
- package/build/commonjs/index.js +120 -0
- package/build/commonjs/index.js.map +1 -0
- package/build/commonjs/request-templates.js +59 -0
- package/build/commonjs/request-templates.js.map +1 -0
- package/build/commonjs/types/agent.js +9 -0
- package/build/commonjs/types/agent.js.map +1 -0
- package/build/commonjs/types/metadata.js +11 -0
- package/build/commonjs/types/metadata.js.map +1 -0
- package/build/commonjs/types/proof-reqeust-template.js +12 -0
- package/build/commonjs/types/proof-reqeust-template.js.map +1 -0
- package/build/commonjs/types/proof.js +26 -0
- package/build/commonjs/types/proof.js.map +1 -0
- package/build/commonjs/utils/proof-request.js +163 -0
- package/build/commonjs/utils/proof-request.js.map +1 -0
- package/build/commonjs/utils/proof.js +184 -0
- package/build/commonjs/utils/proof.js.map +1 -0
- package/build/module/README.md +4 -0
- package/build/module/constants.js +3 -0
- package/build/module/constants.js.map +1 -0
- package/build/module/hooks/proofs.js +15 -0
- package/build/module/hooks/proofs.js.map +1 -0
- package/build/module/index.js +7 -0
- package/build/module/index.js.map +1 -0
- package/build/module/request-templates.js +52 -0
- package/build/module/request-templates.js.map +1 -0
- package/build/module/types/agent.js +5 -0
- package/build/module/types/agent.js.map +1 -0
- package/build/module/types/metadata.js +5 -0
- package/build/module/types/metadata.js.map +1 -0
- package/build/module/types/proof-reqeust-template.js +8 -0
- package/build/module/types/proof-reqeust-template.js.map +1 -0
- package/build/module/types/proof.js +18 -0
- package/build/module/types/proof.js.map +1 -0
- package/build/module/utils/proof-request.js +151 -0
- package/build/module/utils/proof-request.js.map +1 -0
- package/build/module/utils/proof.js +171 -0
- package/build/module/utils/proof.js.map +1 -0
- package/build/typescript/__tests__/verifier/proof-request.test.d.ts +2 -0
- package/build/typescript/__tests__/verifier/proof-request.test.d.ts.map +1 -0
- package/build/typescript/__tests__/verifier/proof.test.d.ts +2 -0
- package/build/typescript/__tests__/verifier/proof.test.d.ts.map +1 -0
- package/build/typescript/constants.d.ts +3 -0
- package/build/typescript/constants.d.ts.map +1 -0
- package/build/typescript/hooks/proofs.d.ts +3 -0
- package/build/typescript/hooks/proofs.d.ts.map +1 -0
- package/build/typescript/index.d.ts +11 -0
- package/build/typescript/index.d.ts.map +1 -0
- package/build/typescript/request-templates.d.ts +3 -0
- package/build/typescript/request-templates.d.ts.map +1 -0
- package/build/typescript/types/agent.d.ts +12 -0
- package/build/typescript/types/agent.d.ts.map +1 -0
- package/build/typescript/types/metadata.d.ts +9 -0
- package/build/typescript/types/metadata.d.ts.map +1 -0
- package/build/typescript/types/proof-reqeust-template.d.ts +48 -0
- package/build/typescript/types/proof-reqeust-template.d.ts.map +1 -0
- package/build/typescript/types/proof.d.ts +51 -0
- package/build/typescript/types/proof.d.ts.map +1 -0
- package/build/typescript/utils/proof-request.d.ts +30 -0
- package/build/typescript/utils/proof-request.d.ts.map +1 -0
- package/build/typescript/utils/proof.d.ts +18 -0
- package/build/typescript/utils/proof.d.ts.map +1 -0
- package/package.json +59 -0
- package/src/README.md +4 -0
- package/src/__tests__/verifier/__snapshots__/proof-request.test.ts.snap +72 -0
- package/src/__tests__/verifier/__snapshots__/proof.test.ts.snap +135 -0
- package/src/__tests__/verifier/proof-request.test.ts +34 -0
- package/src/__tests__/verifier/proof.test.ts +99 -0
- package/src/constants.ts +2 -0
- package/src/hooks/proofs.ts +20 -0
- package/src/index.ts +45 -0
- package/src/request-templates.ts +62 -0
- package/src/types/agent.ts +53 -0
- package/src/types/metadata.ts +9 -0
- package/src/types/proof-reqeust-template.ts +59 -0
- package/src/types/proof.ts +68 -0
- package/src/utils/proof-request.ts +177 -0
- package/src/utils/proof.ts +173 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# verifier
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.protocolVersion = exports.domain = void 0;
|
|
7
|
+
const protocolVersion = exports.protocolVersion = 'v2';
|
|
8
|
+
const domain = exports.domain = 'didcomm://invite';
|
|
9
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["protocolVersion","exports","domain"],"sourceRoot":"../../src","sources":["constants.ts"],"mappings":";;;;;;AAAO,MAAMA,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,IAAI;AAC5B,MAAME,MAAM,GAAAD,OAAA,CAAAC,MAAA,GAAG,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useProofsByTemplateId = void 0;
|
|
7
|
+
var _reactHooks = require("@credo-ts/react-hooks");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _metadata = require("../types/metadata");
|
|
10
|
+
const useProofsByTemplateId = templateId => {
|
|
11
|
+
const {
|
|
12
|
+
records: proofs
|
|
13
|
+
} = (0, _reactHooks.useProofs)();
|
|
14
|
+
return (0, _react.useMemo)(() => proofs.filter(proof => {
|
|
15
|
+
const metadata = proof === null || proof === void 0 ? void 0 : proof.metadata.get(_metadata.ProofMetadata.customMetadata);
|
|
16
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.proof_request_template_id) === templateId) {
|
|
17
|
+
return proof;
|
|
18
|
+
}
|
|
19
|
+
}), [proofs, templateId]);
|
|
20
|
+
};
|
|
21
|
+
exports.useProofsByTemplateId = useProofsByTemplateId;
|
|
22
|
+
//# sourceMappingURL=proofs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactHooks","require","_react","_metadata","useProofsByTemplateId","templateId","records","proofs","useProofs","useMemo","filter","proof","metadata","get","ProofMetadata","customMetadata","proof_request_template_id","exports"],"sourceRoot":"../../../src","sources":["hooks/proofs.ts"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAIC,UAAkB,IAA4B;EAClF,MAAM;IAAEC,OAAO,EAAEC;EAAO,CAAC,GAAG,IAAAC,qBAAS,EAAC,CAAC;EAEvC,OAAO,IAAAC,cAAO,EACZ,MACEF,MAAM,CAACG,MAAM,CAAEC,KAA0B,IAAK;IAC5C,MAAMC,QAAQ,GAAGD,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEC,QAAQ,CAACC,GAAG,CAACC,uBAAa,CAACC,cAAc,CAAwB;IACzF,IAAI,CAAAH,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEI,yBAAyB,MAAKX,UAAU,EAAE;MACtD,OAAOM,KAAK;IACd;EACF,CAAC,CAAC,EACJ,CAACJ,MAAM,EAAEF,UAAU,CACrB,CAAC;AACH,CAAC;AAAAY,OAAA,CAAAb,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ProofMetadata", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _metadata.ProofMetadata;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ProofRequestType", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _proofReqeustTemplate.ProofRequestType;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "buildProofRequestDataForTemplate", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _proofRequest.buildProofRequestDataForTemplate;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "createConnectionlessProofRequestInvitation", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _proofRequest.createConnectionlessProofRequestInvitation;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "findProofRequestMessage", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _proofRequest.findProofRequestMessage;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "getProofData", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _proof.getProofData;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "getProofIdentifiers", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _proof.getProofIdentifiers;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "getProofRequestTemplates", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _requestTemplates.getProofRequestTemplates;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "groupSharedProofDataByCredential", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _proof.groupSharedProofDataByCredential;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "hasPredicates", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _proofRequest.hasPredicates;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "isParameterizable", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _proofRequest.isParameterizable;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "isPresentationFailed", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _proof.isPresentationFailed;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "isPresentationReceived", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () {
|
|
81
|
+
return _proof.isPresentationReceived;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "linkProofWithTemplate", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () {
|
|
87
|
+
return _proof.linkProofWithTemplate;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "markProofAsViewed", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _proof.markProofAsViewed;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "parseAnonCredsProof", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () {
|
|
99
|
+
return _proof.parseAnonCredsProof;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "sendProofRequest", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function () {
|
|
105
|
+
return _proofRequest.sendProofRequest;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "useProofsByTemplateId", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () {
|
|
111
|
+
return _proofs.useProofsByTemplateId;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
var _proofReqeustTemplate = require("./types/proof-reqeust-template");
|
|
115
|
+
var _metadata = require("./types/metadata");
|
|
116
|
+
var _proofs = require("./hooks/proofs");
|
|
117
|
+
var _proof = require("./utils/proof");
|
|
118
|
+
var _proofRequest = require("./utils/proof-request");
|
|
119
|
+
var _requestTemplates = require("./request-templates");
|
|
120
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_proofReqeustTemplate","require","_metadata","_proofs","_proof","_proofRequest","_requestTemplates"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAuBA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAWA,IAAAI,aAAA,GAAAJ,OAAA;AAQA,IAAAK,iBAAA,GAAAL,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getProofRequestTemplates = void 0;
|
|
7
|
+
var _proofReqeustTemplate = require("./types/proof-reqeust-template");
|
|
8
|
+
const getProofRequestTemplates = useDevRestrictions => {
|
|
9
|
+
const studentRestrictions = [{
|
|
10
|
+
cred_def_id: 'XUxBrVSALWHLeycAUhrNr9:3:CL:26293:student_card'
|
|
11
|
+
}];
|
|
12
|
+
const studentDevRestrictions = [{
|
|
13
|
+
schema_name: 'student_card'
|
|
14
|
+
}];
|
|
15
|
+
const restrictions = useDevRestrictions ? studentDevRestrictions : studentRestrictions;
|
|
16
|
+
const defaultProofRequestTemplates = [{
|
|
17
|
+
id: 'Aries:5:StudentFullName:0.0.1:indy',
|
|
18
|
+
name: 'Student full name',
|
|
19
|
+
description: 'Verify the full name of a student',
|
|
20
|
+
version: '0.0.1',
|
|
21
|
+
payload: {
|
|
22
|
+
type: _proofReqeustTemplate.ProofRequestType.AnonCreds,
|
|
23
|
+
data: [{
|
|
24
|
+
schema: 'XUxBrVSALWHLeycAUhrNr9:3:CL:26293:Student Card',
|
|
25
|
+
requestedAttributes: [{
|
|
26
|
+
name: 'student_first_name',
|
|
27
|
+
restrictions
|
|
28
|
+
}, {
|
|
29
|
+
name: 'student_last_name',
|
|
30
|
+
restrictions
|
|
31
|
+
}]
|
|
32
|
+
}]
|
|
33
|
+
}
|
|
34
|
+
}, {
|
|
35
|
+
id: 'Aries:5:StudentFullNameAndExpirationDate:0.0.1:indy',
|
|
36
|
+
name: 'Student full name and expiration date',
|
|
37
|
+
description: 'Verify that full name of a student and that he/she has a not expired student card.',
|
|
38
|
+
version: '0.0.1',
|
|
39
|
+
payload: {
|
|
40
|
+
type: _proofReqeustTemplate.ProofRequestType.AnonCreds,
|
|
41
|
+
data: [{
|
|
42
|
+
schema: 'XUxBrVSALWHLeycAUhrNr9:3:CL:26293:Student Card',
|
|
43
|
+
requestedAttributes: [{
|
|
44
|
+
names: ['student_first_name', 'student_last_name'],
|
|
45
|
+
restrictions
|
|
46
|
+
}],
|
|
47
|
+
requestedPredicates: [{
|
|
48
|
+
name: 'expiry_date',
|
|
49
|
+
predicateType: '>=',
|
|
50
|
+
predicateValue: 20240101,
|
|
51
|
+
restrictions
|
|
52
|
+
}]
|
|
53
|
+
}]
|
|
54
|
+
}
|
|
55
|
+
}];
|
|
56
|
+
return defaultProofRequestTemplates;
|
|
57
|
+
};
|
|
58
|
+
exports.getProofRequestTemplates = getProofRequestTemplates;
|
|
59
|
+
//# sourceMappingURL=request-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_proofReqeustTemplate","require","getProofRequestTemplates","useDevRestrictions","studentRestrictions","cred_def_id","studentDevRestrictions","schema_name","restrictions","defaultProofRequestTemplates","id","name","description","version","payload","type","ProofRequestType","AnonCreds","data","schema","requestedAttributes","names","requestedPredicates","predicateType","predicateValue","exports"],"sourceRoot":"../../src","sources":["request-templates.ts"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AAEO,MAAMC,wBAAwB,GAAIC,kBAA2B,IAAK;EACvE,MAAMC,mBAAmB,GAAG,CAAC;IAAEC,WAAW,EAAE;EAAiD,CAAC,CAAC;EAC/F,MAAMC,sBAAsB,GAAG,CAAC;IAAEC,WAAW,EAAE;EAAe,CAAC,CAAC;EAChE,MAAMC,YAAY,GAAGL,kBAAkB,GAAGG,sBAAsB,GAAGF,mBAAmB;EACtF,MAAMK,4BAAyD,GAAG,CAChE;IACEC,EAAE,EAAE,oCAAoC;IACxCC,IAAI,EAAE,mBAAmB;IACzBC,WAAW,EAAE,mCAAmC;IAChDC,OAAO,EAAE,OAAO;IAChBC,OAAO,EAAE;MACPC,IAAI,EAAEC,sCAAgB,CAACC,SAAS;MAChCC,IAAI,EAAE,CACJ;QACEC,MAAM,EAAE,gDAAgD;QACxDC,mBAAmB,EAAE,CACnB;UACET,IAAI,EAAE,oBAAoB;UAC1BH;QACF,CAAC,EACD;UACEG,IAAI,EAAE,mBAAmB;UACzBH;QACF,CAAC;MAEL,CAAC;IAEL;EACF,CAAC,EACD;IACEE,EAAE,EAAE,qDAAqD;IACzDC,IAAI,EAAE,uCAAuC;IAC7CC,WAAW,EAAE,oFAAoF;IACjGC,OAAO,EAAE,OAAO;IAChBC,OAAO,EAAE;MACPC,IAAI,EAAEC,sCAAgB,CAACC,SAAS;MAChCC,IAAI,EAAE,CACJ;QACEC,MAAM,EAAE,gDAAgD;QACxDC,mBAAmB,EAAE,CACnB;UACEC,KAAK,EAAE,CAAC,oBAAoB,EAAE,mBAAmB,CAAC;UAClDb;QACF,CAAC,CACF;QACDc,mBAAmB,EAAE,CACnB;UACEX,IAAI,EAAE,aAAa;UACnBY,aAAa,EAAE,IAAI;UACnBC,cAAc,EAAE,QAAQ;UACxBhB;QACF,CAAC;MAEL,CAAC;IAEL;EACF,CAAC,CACF;EACD,OAAOC,4BAA4B;AACrC,CAAC;AAAAgB,OAAA,CAAAvB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getAgentModules"],"sourceRoot":"../../../src","sources":["types/agent.ts"],"mappings":";;;;;AAqBA,SAASA,eAAeA,CAAA,EAAG;EACzB,OAAO,IAAI;AA4Bb","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ProofMetadata = void 0;
|
|
7
|
+
let ProofMetadata = exports.ProofMetadata = /*#__PURE__*/function (ProofMetadata) {
|
|
8
|
+
ProofMetadata["customMetadata"] = "customMetadata";
|
|
9
|
+
return ProofMetadata;
|
|
10
|
+
}({});
|
|
11
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ProofMetadata","exports"],"sourceRoot":"../../../src","sources":["types/metadata.ts"],"mappings":";;;;;;IAAYA,aAAa,GAAAC,OAAA,CAAAD,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ProofRequestType = void 0;
|
|
7
|
+
let ProofRequestType = exports.ProofRequestType = /*#__PURE__*/function (ProofRequestType) {
|
|
8
|
+
ProofRequestType["AnonCreds"] = "anoncreds";
|
|
9
|
+
ProofRequestType["DIF"] = "dif";
|
|
10
|
+
return ProofRequestType;
|
|
11
|
+
}({}); // eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
12
|
+
//# sourceMappingURL=proof-reqeust-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ProofRequestType","exports"],"sourceRoot":"../../../src","sources":["types/proof-reqeust-template.ts"],"mappings":";;;;;;IAiCYA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA,OAU5B","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ParsedAnonCredsProof = exports.CredentialSharedProofData = void 0;
|
|
7
|
+
class ParsedAnonCredsProof {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.sharedAttributes = [];
|
|
10
|
+
this.sharedAttributeGroups = [];
|
|
11
|
+
this.resolvedPredicates = [];
|
|
12
|
+
this.unresolvedAttributes = [];
|
|
13
|
+
this.unresolvedAttributeGroups = [];
|
|
14
|
+
this.unresolvedPredicates = [];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ParsedAnonCredsProof = ParsedAnonCredsProof;
|
|
18
|
+
class CredentialSharedProofData {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.sharedAttributes = [];
|
|
21
|
+
this.sharedAttributeGroups = [];
|
|
22
|
+
this.resolvedPredicates = [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.CredentialSharedProofData = CredentialSharedProofData;
|
|
26
|
+
//# sourceMappingURL=proof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ParsedAnonCredsProof","constructor","sharedAttributes","sharedAttributeGroups","resolvedPredicates","unresolvedAttributes","unresolvedAttributeGroups","unresolvedPredicates","exports","CredentialSharedProofData"],"sourceRoot":"../../../src","sources":["types/proof.ts"],"mappings":";;;;;;AAoCO,MAAMA,oBAAoB,CAAC;EAQzBC,WAAWA,CAAA,EAAG;IACnB,IAAI,CAACC,gBAAgB,GAAG,EAAE;IAC1B,IAAI,CAACC,qBAAqB,GAAG,EAAE;IAC/B,IAAI,CAACC,kBAAkB,GAAG,EAAE;IAC5B,IAAI,CAACC,oBAAoB,GAAG,EAAE;IAC9B,IAAI,CAACC,yBAAyB,GAAG,EAAE;IACnC,IAAI,CAACC,oBAAoB,GAAG,EAAE;EAChC;AACF;AAACC,OAAA,CAAAR,oBAAA,GAAAA,oBAAA;AAEM,MAAMS,yBAAyB,CAAC;EAK9BR,WAAWA,CAAA,EAAG;IACnB,IAAI,CAACC,gBAAgB,GAAG,EAAE;IAC1B,IAAI,CAACC,qBAAqB,GAAG,EAAE;IAC/B,IAAI,CAACC,kBAAkB,GAAG,EAAE;EAC9B;AACF;AAACI,OAAA,CAAAC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.sendProofRequest = exports.isParameterizable = exports.hasPredicates = exports.findProofRequestMessage = exports.createConnectionlessProofRequestInvitation = exports.buildProofRequestDataForTemplate = void 0;
|
|
7
|
+
var _anoncreds = require("@credo-ts/anoncreds");
|
|
8
|
+
var _core = require("@credo-ts/core");
|
|
9
|
+
var _proofReqeustTemplate = require("../types/proof-reqeust-template");
|
|
10
|
+
const protocolVersion = 'v2';
|
|
11
|
+
const domain = 'http://aries-mobile-agent.com';
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Find Proof Request message in the storage by the given id
|
|
15
|
+
* */
|
|
16
|
+
const findProofRequestMessage = async (agent, id) => {
|
|
17
|
+
const message = await agent.proofs.findRequestMessage(id);
|
|
18
|
+
if (message && message instanceof _anoncreds.V1RequestPresentationMessage && message.indyProofRequest) {
|
|
19
|
+
return message.indyProofRequest;
|
|
20
|
+
} else {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* Build Proof Request data from for provided template
|
|
27
|
+
* */
|
|
28
|
+
/*
|
|
29
|
+
* Build Proof Request data for provided template
|
|
30
|
+
* */
|
|
31
|
+
exports.findProofRequestMessage = findProofRequestMessage;
|
|
32
|
+
const buildProofRequestDataForTemplate = (template, customValues) => {
|
|
33
|
+
if (template.payload.type === _proofReqeustTemplate.ProofRequestType.AnonCreds) {
|
|
34
|
+
const requestedAttributes = {};
|
|
35
|
+
const requestedPredicates = {};
|
|
36
|
+
let index = 0;
|
|
37
|
+
template.payload.data.forEach(data => {
|
|
38
|
+
var _data$requestedAttrib, _data$requestedPredic;
|
|
39
|
+
if ((_data$requestedAttrib = data.requestedAttributes) !== null && _data$requestedAttrib !== void 0 && _data$requestedAttrib.length) {
|
|
40
|
+
data.requestedAttributes.forEach(requestedAttribute => {
|
|
41
|
+
requestedAttributes[`referent_${index}`] = {
|
|
42
|
+
name: requestedAttribute.name,
|
|
43
|
+
names: requestedAttribute.names,
|
|
44
|
+
non_revoked: requestedAttribute.nonRevoked,
|
|
45
|
+
restrictions: requestedAttribute.restrictions
|
|
46
|
+
};
|
|
47
|
+
index++;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if ((_data$requestedPredic = data.requestedPredicates) !== null && _data$requestedPredic !== void 0 && _data$requestedPredic.length) {
|
|
51
|
+
data.requestedPredicates.forEach(requestedPredicate => {
|
|
52
|
+
const customValue = customValues && customValues[data.schema] ? customValues[data.schema][requestedPredicate.name] : undefined;
|
|
53
|
+
requestedPredicates[`referent_${index}`] = {
|
|
54
|
+
name: requestedPredicate.name,
|
|
55
|
+
p_value: requestedPredicate.parameterizable && customValue ? customValue : requestedPredicate.predicateValue,
|
|
56
|
+
p_type: requestedPredicate.predicateType,
|
|
57
|
+
non_revoked: requestedPredicate.nonRevoked,
|
|
58
|
+
restrictions: requestedPredicate.restrictions
|
|
59
|
+
};
|
|
60
|
+
index++;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
anoncreds: {
|
|
66
|
+
name: template.name,
|
|
67
|
+
version: template.version,
|
|
68
|
+
nonce: Date.now().toString(),
|
|
69
|
+
requested_attributes: requestedAttributes,
|
|
70
|
+
requested_predicates: requestedPredicates
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (template.payload.type === _proofReqeustTemplate.ProofRequestType.DIF) {
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
exports.buildProofRequestDataForTemplate = buildProofRequestDataForTemplate;
|
|
79
|
+
/*
|
|
80
|
+
* Create connectionless proof request invitation for provided template
|
|
81
|
+
* */
|
|
82
|
+
const createConnectionlessProofRequestInvitation = async (agent, template, customPredicateValues) => {
|
|
83
|
+
const proofFormats = buildProofRequestDataForTemplate(template, customPredicateValues);
|
|
84
|
+
if (!proofFormats) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
const {
|
|
88
|
+
message: request,
|
|
89
|
+
proofRecord
|
|
90
|
+
} = await agent.proofs.createRequest({
|
|
91
|
+
protocolVersion,
|
|
92
|
+
autoAcceptProof: _core.AutoAcceptProof.Always,
|
|
93
|
+
proofFormats
|
|
94
|
+
});
|
|
95
|
+
const {
|
|
96
|
+
message: invitation,
|
|
97
|
+
invitationUrl
|
|
98
|
+
} = await agent.oob.createLegacyConnectionlessInvitation({
|
|
99
|
+
recordId: proofRecord.id,
|
|
100
|
+
message: request,
|
|
101
|
+
domain
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
request,
|
|
105
|
+
proofRecord,
|
|
106
|
+
invitation,
|
|
107
|
+
invitationUrl
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
exports.createConnectionlessProofRequestInvitation = createConnectionlessProofRequestInvitation;
|
|
111
|
+
/*
|
|
112
|
+
* Build Proof Request for provided template and send it to provided connection
|
|
113
|
+
* */
|
|
114
|
+
const sendProofRequest = async (agent, template, connectionId, customPredicateValues) => {
|
|
115
|
+
const proofFormats = buildProofRequestDataForTemplate(template, customPredicateValues);
|
|
116
|
+
if (!proofFormats) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const proofRecord = await agent.proofs.requestProof({
|
|
120
|
+
protocolVersion,
|
|
121
|
+
connectionId,
|
|
122
|
+
proofFormats
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
proofRecord
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* Check if the Proof Request template contains at least one predicate
|
|
131
|
+
* */
|
|
132
|
+
exports.sendProofRequest = sendProofRequest;
|
|
133
|
+
const hasPredicates = record => {
|
|
134
|
+
if (record.payload.type === _proofReqeustTemplate.ProofRequestType.AnonCreds) {
|
|
135
|
+
return record.payload.data.some(d => {
|
|
136
|
+
var _d$requestedPredicate;
|
|
137
|
+
return d.requestedPredicates && ((_d$requestedPredicate = d.requestedPredicates) === null || _d$requestedPredicate === void 0 ? void 0 : _d$requestedPredicate.length) > 0;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (record.payload.type === _proofReqeustTemplate.ProofRequestType.DIF) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
* Check if the Proof Request template contains parameterizable predicates
|
|
148
|
+
* */
|
|
149
|
+
exports.hasPredicates = hasPredicates;
|
|
150
|
+
const isParameterizable = record => {
|
|
151
|
+
if (record.payload.type === _proofReqeustTemplate.ProofRequestType.AnonCreds) {
|
|
152
|
+
return record.payload.data.some(d => {
|
|
153
|
+
var _d$requestedPredicate2;
|
|
154
|
+
return (_d$requestedPredicate2 = d.requestedPredicates) === null || _d$requestedPredicate2 === void 0 ? void 0 : _d$requestedPredicate2.some(predicate => predicate.parameterizable);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (record.payload.type === _proofReqeustTemplate.ProofRequestType.DIF) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
};
|
|
162
|
+
exports.isParameterizable = isParameterizable;
|
|
163
|
+
//# sourceMappingURL=proof-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_anoncreds","require","_core","_proofReqeustTemplate","protocolVersion","domain","findProofRequestMessage","agent","id","message","proofs","findRequestMessage","V1RequestPresentationMessage","indyProofRequest","undefined","exports","buildProofRequestDataForTemplate","template","customValues","payload","type","ProofRequestType","AnonCreds","requestedAttributes","requestedPredicates","index","data","forEach","_data$requestedAttrib","_data$requestedPredic","length","requestedAttribute","name","names","non_revoked","nonRevoked","restrictions","requestedPredicate","customValue","schema","p_value","parameterizable","predicateValue","p_type","predicateType","anoncreds","version","nonce","Date","now","toString","requested_attributes","requested_predicates","DIF","createConnectionlessProofRequestInvitation","customPredicateValues","proofFormats","request","proofRecord","createRequest","autoAcceptProof","AutoAcceptProof","Always","invitation","invitationUrl","oob","createLegacyConnectionlessInvitation","recordId","sendProofRequest","connectionId","requestProof","hasPredicates","record","some","d","_d$requestedPredicate","isParameterizable","_d$requestedPredicate2","predicate"],"sourceRoot":"../../../src","sources":["utils/proof-request.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AAGA,IAAAE,qBAAA,GAAAF,OAAA;AAEA,MAAMG,eAAe,GAAG,IAAI;AAC5B,MAAMC,MAAM,GAAG,+BAA+B;;AAE9C;AACA;AACA;AACO,MAAMC,uBAAuB,GAAG,MAAAA,CACrCC,KAAY,EACZC,EAAU,KACsC;EAChD,MAAMC,OAAO,GAAG,MAAMF,KAAK,CAACG,MAAM,CAACC,k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