@keetanetwork/anchor 0.0.16 → 0.0.18
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/lib/certificates.d.ts +16 -1
- package/lib/certificates.d.ts.map +1 -1
- package/lib/certificates.generated.js +58 -8
- package/lib/certificates.generated.js.map +1 -1
- package/lib/certificates.js +161 -27
- package/lib/certificates.js.map +1 -1
- package/lib/encrypted-container.d.ts +11 -11
- package/lib/encrypted-container.d.ts.map +1 -1
- package/lib/encrypted-container.js +21 -9
- package/lib/encrypted-container.js.map +1 -1
- package/lib/utils/asn1.d.ts +7 -1
- package/lib/utils/asn1.d.ts.map +1 -1
- package/lib/utils/asn1.generated.d.ts +41 -0
- package/lib/utils/asn1.generated.d.ts.map +1 -0
- package/lib/utils/asn1.generated.js +221 -0
- package/lib/utils/asn1.generated.js.map +1 -0
- package/lib/utils/asn1.js +73 -13
- package/lib/utils/asn1.js.map +1 -1
- package/lib/utils/crypto.d.ts.map +1 -1
- package/lib/utils/crypto.js.map +1 -1
- package/lib/utils/external.d.ts +5 -3
- package/lib/utils/external.d.ts.map +1 -1
- package/lib/utils/external.js +49 -6
- package/lib/utils/external.js.map +1 -1
- package/npm-shrinkwrap.json +5 -5
- package/package.json +2 -2
- package/services/kyc/iso20022.generated.d.ts +7 -0
- package/services/kyc/iso20022.generated.d.ts.map +1 -1
- package/services/kyc/iso20022.generated.js.map +1 -1
- package/services/kyc/utils/generate-kyc-schema.js +17 -1
- package/services/kyc/utils/generate-kyc-schema.js.map +1 -1
package/lib/certificates.d.ts
CHANGED
|
@@ -113,9 +113,18 @@ export declare class Certificate extends KeetaNetClient.lib.Utils.Certificate.Ce
|
|
|
113
113
|
}
|
|
114
114
|
export declare namespace SharableCertificateAttributesTypes {
|
|
115
115
|
type ExportOptions = {
|
|
116
|
+
/**
|
|
117
|
+
* Format of the exported data
|
|
118
|
+
* - 'string': PEM-encoded string
|
|
119
|
+
* - 'arraybuffer': raw ArrayBuffer
|
|
120
|
+
*/
|
|
116
121
|
format?: 'string' | 'arraybuffer';
|
|
117
122
|
};
|
|
118
123
|
type ImportOptions = {
|
|
124
|
+
/**
|
|
125
|
+
* Principals that will be used to try to access the
|
|
126
|
+
* encrypted contents of the sharable certificate
|
|
127
|
+
*/
|
|
119
128
|
principals?: Set<KeetaNetAccount> | KeetaNetAccount[] | KeetaNetAccount | null;
|
|
120
129
|
};
|
|
121
130
|
type ContentsSchema = {
|
|
@@ -124,9 +133,15 @@ export declare namespace SharableCertificateAttributesTypes {
|
|
|
124
133
|
[name: string]: {
|
|
125
134
|
sensitive: true;
|
|
126
135
|
value: Awaited<ReturnType<SensitiveAttribute['getProof']>>;
|
|
136
|
+
references?: {
|
|
137
|
+
[id: string]: string;
|
|
138
|
+
};
|
|
127
139
|
} | {
|
|
128
140
|
sensitive: false;
|
|
129
141
|
value: string;
|
|
142
|
+
references?: {
|
|
143
|
+
[id: string]: string;
|
|
144
|
+
};
|
|
130
145
|
};
|
|
131
146
|
};
|
|
132
147
|
};
|
|
@@ -138,7 +153,7 @@ export declare class SharableCertificateAttributes {
|
|
|
138
153
|
private container;
|
|
139
154
|
private populatedFromInit;
|
|
140
155
|
static assertCertificateAttributeName: typeof assertCertificateAttributeNames;
|
|
141
|
-
constructor(input: ArrayBuffer | string, options?: SharableCertificateAttributesImportOptions);
|
|
156
|
+
constructor(input: ArrayBuffer | Buffer | string, options?: SharableCertificateAttributesImportOptions);
|
|
142
157
|
/**
|
|
143
158
|
* Create a SharableCertificateAttributes from a Certificate
|
|
144
159
|
* and a list of attribute names to include -- if no list is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"certificates.d.ts","sourceRoot":"","sources":["../../src/lib/certificates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,cAAc,MAAM,+BAA+B,CAAC;AAKhE,OAAO,EAAgD,MAAM,EAAuB,MAAM,mBAAmB,CAAC;AAG9G,OAAO,KAAK,EAA0B,yBAAyB,EAAE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IACnH,MAAM,CAAC,OAAO,CAAC,EAAE,0CAA0C,GAAG,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC;CA8B3F"}
|
|
@@ -6,9 +6,19 @@ export const assertSharableCertificateAttributesContentsSchema = (() => { const
|
|
|
6
6
|
if (undefined === value)
|
|
7
7
|
return true;
|
|
8
8
|
return "object" === typeof value && null !== value && _iu0(value);
|
|
9
|
-
}); const _io2 = input => true === input.sensitive && ("object" === typeof input.value && null !== input.value && _io3(input.value)); const _io3 = input => "string" === typeof input.value && ("object" === typeof input.hash && null !== input.hash && _io4(input.hash)); const _io4 = input => "string" === typeof input.salt; const _io5 = input =>
|
|
9
|
+
}); const _io2 = input => true === input.sensitive && ("object" === typeof input.value && null !== input.value && _io3(input.value)) && (undefined === input.references || "object" === typeof input.references && null !== input.references && false === Array.isArray(input.references) && _io5(input.references)); const _io3 = input => "string" === typeof input.value && ("object" === typeof input.hash && null !== input.hash && _io4(input.hash)); const _io4 = input => "string" === typeof input.salt; const _io5 = input => Object.keys(input).every(key => {
|
|
10
|
+
const value = input[key];
|
|
11
|
+
if (undefined === value)
|
|
12
|
+
return true;
|
|
13
|
+
return "string" === typeof value;
|
|
14
|
+
}); const _io6 = input => false === input.sensitive && "string" === typeof input.value && (undefined === input.references || "object" === typeof input.references && null !== input.references && false === Array.isArray(input.references) && _io7(input.references)); const _io7 = input => Object.keys(input).every(key => {
|
|
15
|
+
const value = input[key];
|
|
16
|
+
if (undefined === value)
|
|
17
|
+
return true;
|
|
18
|
+
return "string" === typeof value;
|
|
19
|
+
}); const _iu0 = input => (() => {
|
|
10
20
|
if (false === input.sensitive)
|
|
11
|
-
return
|
|
21
|
+
return _io6(input);
|
|
12
22
|
else if (true === input.sensitive)
|
|
13
23
|
return _io2(input);
|
|
14
24
|
else
|
|
@@ -35,12 +45,12 @@ export const assertSharableCertificateAttributesContentsSchema = (() => { const
|
|
|
35
45
|
return ("object" === typeof value && null !== value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
36
46
|
method: "typia.createAssert",
|
|
37
47
|
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
38
|
-
expected: "(__type.o1 | __type.
|
|
48
|
+
expected: "(__type.o1 | __type.o5)",
|
|
39
49
|
value: value
|
|
40
50
|
}, _errorFactory)) && _au0(value, _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key), true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
41
51
|
method: "typia.createAssert",
|
|
42
52
|
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
43
|
-
expected: "(__type.o1 | __type.
|
|
53
|
+
expected: "(__type.o1 | __type.o5)",
|
|
44
54
|
value: value
|
|
45
55
|
}, _errorFactory);
|
|
46
56
|
}); const _ao2 = (input, _path, _exceptionable = true) => (true === input.sensitive || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
@@ -58,6 +68,16 @@ export const assertSharableCertificateAttributesContentsSchema = (() => { const
|
|
|
58
68
|
path: _path + ".value",
|
|
59
69
|
expected: "__type.o2",
|
|
60
70
|
value: input.value
|
|
71
|
+
}, _errorFactory)) && (undefined === input.references || ("object" === typeof input.references && null !== input.references && false === Array.isArray(input.references) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
72
|
+
method: "typia.createAssert",
|
|
73
|
+
path: _path + ".references",
|
|
74
|
+
expected: "(__type.o4 | undefined)",
|
|
75
|
+
value: input.references
|
|
76
|
+
}, _errorFactory)) && _ao5(input.references, _path + ".references", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
77
|
+
method: "typia.createAssert",
|
|
78
|
+
path: _path + ".references",
|
|
79
|
+
expected: "(__type.o4 | undefined)",
|
|
80
|
+
value: input.references
|
|
61
81
|
}, _errorFactory)); const _ao3 = (input, _path, _exceptionable = true) => ("string" === typeof input.value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
62
82
|
method: "typia.createAssert",
|
|
63
83
|
path: _path + ".value",
|
|
@@ -78,7 +98,17 @@ export const assertSharableCertificateAttributesContentsSchema = (() => { const
|
|
|
78
98
|
path: _path + ".salt",
|
|
79
99
|
expected: "string",
|
|
80
100
|
value: input.salt
|
|
81
|
-
}, _errorFactory); const _ao5 = (input, _path, _exceptionable = true) =>
|
|
101
|
+
}, _errorFactory); const _ao5 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every(key => {
|
|
102
|
+
const value = input[key];
|
|
103
|
+
if (undefined === value)
|
|
104
|
+
return true;
|
|
105
|
+
return "string" === typeof value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
106
|
+
method: "typia.createAssert",
|
|
107
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
108
|
+
expected: "string",
|
|
109
|
+
value: value
|
|
110
|
+
}, _errorFactory);
|
|
111
|
+
}); const _ao6 = (input, _path, _exceptionable = true) => (false === input.sensitive || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
82
112
|
method: "typia.createAssert",
|
|
83
113
|
path: _path + ".sensitive",
|
|
84
114
|
expected: "false",
|
|
@@ -88,16 +118,36 @@ export const assertSharableCertificateAttributesContentsSchema = (() => { const
|
|
|
88
118
|
path: _path + ".value",
|
|
89
119
|
expected: "string",
|
|
90
120
|
value: input.value
|
|
91
|
-
}, _errorFactory))
|
|
121
|
+
}, _errorFactory)) && (undefined === input.references || ("object" === typeof input.references && null !== input.references && false === Array.isArray(input.references) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
122
|
+
method: "typia.createAssert",
|
|
123
|
+
path: _path + ".references",
|
|
124
|
+
expected: "(__type.o6 | undefined)",
|
|
125
|
+
value: input.references
|
|
126
|
+
}, _errorFactory)) && _ao7(input.references, _path + ".references", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
127
|
+
method: "typia.createAssert",
|
|
128
|
+
path: _path + ".references",
|
|
129
|
+
expected: "(__type.o6 | undefined)",
|
|
130
|
+
value: input.references
|
|
131
|
+
}, _errorFactory)); const _ao7 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every(key => {
|
|
132
|
+
const value = input[key];
|
|
133
|
+
if (undefined === value)
|
|
134
|
+
return true;
|
|
135
|
+
return "string" === typeof value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
136
|
+
method: "typia.createAssert",
|
|
137
|
+
path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
|
|
138
|
+
expected: "string",
|
|
139
|
+
value: value
|
|
140
|
+
}, _errorFactory);
|
|
141
|
+
}); const _au0 = (input, _path, _exceptionable = true) => (() => {
|
|
92
142
|
if (false === input.sensitive)
|
|
93
|
-
return
|
|
143
|
+
return _ao6(input, _path, true && _exceptionable);
|
|
94
144
|
else if (true === input.sensitive)
|
|
95
145
|
return _ao2(input, _path, true && _exceptionable);
|
|
96
146
|
else
|
|
97
147
|
return __typia_transform__assertGuard._assertGuard(_exceptionable, {
|
|
98
148
|
method: "typia.createAssert",
|
|
99
149
|
path: _path,
|
|
100
|
-
expected: "(__type.
|
|
150
|
+
expected: "(__type.o5 | __type.o1)",
|
|
101
151
|
value: input
|
|
102
152
|
}, _errorFactory);
|
|
103
153
|
})(); const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; return (input, errorFactory) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"certificates.generated.js","sourceRoot":"","sources":["../../src/lib/certificates.generated.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,CAAC,MAAM,iDAAiD
|
|
1
|
+
{"version":3,"file":"certificates.generated.js","sourceRoot":"","sources":["../../src/lib/certificates.generated.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,CAAC,MAAM,iDAAiD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAiJ,CAAC","sourcesContent":["import * as typia from 'typia';\nimport type { SharableCertificateAttributesTypes } from './certificates.js';\n\nexport const assertSharableCertificateAttributesContentsSchema: (input: unknown) => SharableCertificateAttributesTypes.ContentsSchema = typia.createAssert<SharableCertificateAttributesTypes.ContentsSchema>();\n"]}
|
package/lib/certificates.js
CHANGED
|
@@ -10,11 +10,52 @@ import { getOID, lookupByOID } from './utils/oid.js';
|
|
|
10
10
|
import { convertToJSON as convertToJSONUtil } from './utils/json.js';
|
|
11
11
|
import { EncryptedContainer } from './encrypted-container.js';
|
|
12
12
|
import { assertSharableCertificateAttributesContentsSchema } from './certificates.generated.js';
|
|
13
|
+
import { checkHashWithOID } from './utils/external.js';
|
|
13
14
|
/**
|
|
14
15
|
* Short alias for printing a debug representation of an object
|
|
15
16
|
*/
|
|
16
17
|
const DPO = KeetaNetClient.lib.Utils.Helper.debugPrintableObject.bind(KeetaNetClient.lib.Utils.Helper);
|
|
17
18
|
const KeetaNetAccount = KeetaNetClient.lib.Account;
|
|
19
|
+
function isBlob(input) {
|
|
20
|
+
if (typeof input !== 'object' || input === null) {
|
|
21
|
+
return (false);
|
|
22
|
+
}
|
|
23
|
+
if (!('arrayBuffer' in input)) {
|
|
24
|
+
return (false);
|
|
25
|
+
}
|
|
26
|
+
if (typeof input.arrayBuffer !== 'function') {
|
|
27
|
+
return (false);
|
|
28
|
+
}
|
|
29
|
+
return (true);
|
|
30
|
+
}
|
|
31
|
+
async function walkObject(input, keyTransformer) {
|
|
32
|
+
keyTransformer ??= async function (input) {
|
|
33
|
+
return (input);
|
|
34
|
+
};
|
|
35
|
+
if (typeof input !== 'object' || input === null) {
|
|
36
|
+
return (input);
|
|
37
|
+
}
|
|
38
|
+
if (Buffer.isBuffer(input)) {
|
|
39
|
+
return (input);
|
|
40
|
+
}
|
|
41
|
+
if (typeof input === 'function') {
|
|
42
|
+
return (input);
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(input)) {
|
|
45
|
+
const newArray = [];
|
|
46
|
+
let key = -1;
|
|
47
|
+
for (const item of input) {
|
|
48
|
+
key++;
|
|
49
|
+
newArray.push(await walkObject(await keyTransformer(String(key), item, input), keyTransformer));
|
|
50
|
+
}
|
|
51
|
+
return (newArray);
|
|
52
|
+
}
|
|
53
|
+
const newObj = {};
|
|
54
|
+
for (const [key, value] of Object.entries(input)) {
|
|
55
|
+
newObj[key] = await walkObject(await keyTransformer(key, value, input), keyTransformer);
|
|
56
|
+
}
|
|
57
|
+
return (newObj);
|
|
58
|
+
}
|
|
18
59
|
function toJSON(data) {
|
|
19
60
|
return (convertToJSONUtil(data));
|
|
20
61
|
}
|
|
@@ -131,12 +172,12 @@ function encodeForSensitive(name, value) {
|
|
|
131
172
|
}
|
|
132
173
|
return (Buffer.from(String(value), 'utf-8'));
|
|
133
174
|
}
|
|
134
|
-
async function decodeAttribute(name, value) {
|
|
175
|
+
async function decodeAttribute(name, value, principals) {
|
|
135
176
|
const schema = resolveSchema(name, CertificateAttributeSchema[name]);
|
|
136
177
|
// XXX:TODO Fix depth issue
|
|
137
178
|
// @ts-ignore
|
|
138
179
|
const decodedUnknown = new ASN1.BufferStorageASN1(value, schema).getASN1();
|
|
139
|
-
const candidate = normalizeDecodedASN1(decodedUnknown);
|
|
180
|
+
const candidate = normalizeDecodedASN1(decodedUnknown, principals);
|
|
140
181
|
return (asAttributeValue(name, candidate));
|
|
141
182
|
}
|
|
142
183
|
class SensitiveAttributeBuilder {
|
|
@@ -526,7 +567,7 @@ export class Certificate extends KeetaNetClient.lib.Utils.Certificate.Certificat
|
|
|
526
567
|
setSensitiveAttribute(name, value) {
|
|
527
568
|
const decodeForSensitive = async (data) => {
|
|
528
569
|
const bufferInput = Buffer.isBuffer(data) ? bufferToArrayBuffer(data) : data;
|
|
529
|
-
return (await decodeAttribute(name, bufferInput));
|
|
570
|
+
return (await decodeAttribute(name, bufferInput, [this.subjectKey]));
|
|
530
571
|
};
|
|
531
572
|
this.attributes[name] = {
|
|
532
573
|
sensitive: true,
|
|
@@ -546,11 +587,11 @@ export class Certificate extends KeetaNetClient.lib.Utils.Certificate.Certificat
|
|
|
546
587
|
}
|
|
547
588
|
if (attr instanceof SensitiveAttribute) {
|
|
548
589
|
const raw = await attr.get();
|
|
549
|
-
return (await decodeAttribute(attributeName, raw));
|
|
590
|
+
return (await decodeAttribute(attributeName, raw, [this.subjectKey]));
|
|
550
591
|
}
|
|
551
592
|
// Non-sensitive: ArrayBuffer or Buffer
|
|
552
593
|
if (attr instanceof ArrayBuffer || Buffer.isBuffer(attr)) {
|
|
553
|
-
return (await decodeAttribute(attributeName, attr));
|
|
594
|
+
return (await decodeAttribute(attributeName, attr, [this.subjectKey]));
|
|
554
595
|
}
|
|
555
596
|
throw (new Error(`Attribute ${attributeName} is not a supported type`));
|
|
556
597
|
}
|
|
@@ -629,6 +670,9 @@ export class SharableCertificateAttributes {
|
|
|
629
670
|
const base64Content = base64Lines.join('');
|
|
630
671
|
containerBuffer = Buffer.from(base64Content, 'base64');
|
|
631
672
|
}
|
|
673
|
+
else if (Buffer.isBuffer(input)) {
|
|
674
|
+
containerBuffer = input;
|
|
675
|
+
}
|
|
632
676
|
else {
|
|
633
677
|
containerBuffer = arrayBufferToBuffer(input);
|
|
634
678
|
}
|
|
@@ -667,16 +711,69 @@ export class SharableCertificateAttributes {
|
|
|
667
711
|
if (!attr) {
|
|
668
712
|
continue;
|
|
669
713
|
}
|
|
714
|
+
const references = {};
|
|
715
|
+
const walkResultAndReplaceReferences = async function (obj) {
|
|
716
|
+
return (await walkObject(obj, async function (key, value, parent) {
|
|
717
|
+
if (key === '$blob') {
|
|
718
|
+
try {
|
|
719
|
+
if (typeof parent !== 'object' || parent === null) {
|
|
720
|
+
throw (new Error('$blob->parent is not an object'));
|
|
721
|
+
}
|
|
722
|
+
if (!('digest' in parent) || typeof parent.digest !== 'object' || parent.digest === null) {
|
|
723
|
+
throw (new Error('$blob->parent->digest is not an object'));
|
|
724
|
+
}
|
|
725
|
+
if (!('digest' in parent.digest)) {
|
|
726
|
+
throw (new Error('$blob->parent->digest->digest is missing'));
|
|
727
|
+
}
|
|
728
|
+
const digest = parent.digest.digest;
|
|
729
|
+
if (!Buffer.isBuffer(digest)) {
|
|
730
|
+
throw (new TypeError('$blob digest is not a Buffer'));
|
|
731
|
+
}
|
|
732
|
+
if (typeof value !== 'function') {
|
|
733
|
+
throw (new TypeError('$blob value is not a function'));
|
|
734
|
+
}
|
|
735
|
+
/*
|
|
736
|
+
* We already validated that this is a function, so try to call
|
|
737
|
+
* it -- if it fails the catch block will handle it (by
|
|
738
|
+
* replacing this key with undefined)
|
|
739
|
+
*/
|
|
740
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-assignment
|
|
741
|
+
const reference = await value([certificate.subjectPublicKey]);
|
|
742
|
+
/* Verify that the reference is a Blob */
|
|
743
|
+
if (!isBlob(reference)) {
|
|
744
|
+
throw (new Error('$blob reference did not return a Blob'));
|
|
745
|
+
}
|
|
746
|
+
const referenceData = Buffer.from(await reference.arrayBuffer());
|
|
747
|
+
const referenceID = digest.toString('hex').toUpperCase();
|
|
748
|
+
references[referenceID] = referenceData.toString('base64');
|
|
749
|
+
return (async function () {
|
|
750
|
+
return (reference);
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
catch {
|
|
754
|
+
/* Ignore errors */
|
|
755
|
+
return (undefined);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
else {
|
|
759
|
+
return (value);
|
|
760
|
+
}
|
|
761
|
+
}));
|
|
762
|
+
};
|
|
763
|
+
const attrValue = await certificate.getAttributeValue(name);
|
|
764
|
+
await walkResultAndReplaceReferences(attrValue);
|
|
670
765
|
if (attr.sensitive) {
|
|
671
766
|
attributes[name] = {
|
|
672
767
|
sensitive: true,
|
|
673
|
-
value: await attr.value.getProof()
|
|
768
|
+
value: await attr.value.getProof(),
|
|
769
|
+
references: references
|
|
674
770
|
};
|
|
675
771
|
}
|
|
676
772
|
else {
|
|
677
773
|
attributes[name] = {
|
|
678
774
|
sensitive: false,
|
|
679
|
-
value: arrayBufferToBuffer(attr.value).toString('base64')
|
|
775
|
+
value: arrayBufferToBuffer(attr.value).toString('base64'),
|
|
776
|
+
references: references
|
|
680
777
|
};
|
|
681
778
|
}
|
|
682
779
|
}
|
|
@@ -689,7 +786,7 @@ export class SharableCertificateAttributes {
|
|
|
689
786
|
const contentsBufferCompressed = await KeetaNetClient.lib.Utils.Buffer.ZlibDeflateAsync(bufferToArrayBuffer(contentsBuffer));
|
|
690
787
|
const container = EncryptedContainer.fromPlaintext(arrayBufferToBuffer(contentsBufferCompressed), [temporaryUser], true);
|
|
691
788
|
const containerBuffer = await container.getEncodedBuffer();
|
|
692
|
-
const retval = new SharableCertificateAttributes(
|
|
789
|
+
const retval = new SharableCertificateAttributes(containerBuffer, { principals: temporaryUser });
|
|
693
790
|
await retval.revokeAccess(temporaryUser);
|
|
694
791
|
return (retval);
|
|
695
792
|
}
|
|
@@ -710,7 +807,7 @@ export class SharableCertificateAttributes {
|
|
|
710
807
|
}
|
|
711
808
|
this.populatedFromInit = true;
|
|
712
809
|
const contentsBuffer = await this.container.getPlaintext();
|
|
713
|
-
const contentsBufferDecompressed = await KeetaNetClient.lib.Utils.Buffer.ZlibInflateAsync(
|
|
810
|
+
const contentsBufferDecompressed = await KeetaNetClient.lib.Utils.Buffer.ZlibInflateAsync(contentsBuffer);
|
|
714
811
|
const contentsString = Buffer.from(contentsBufferDecompressed).toString('utf-8');
|
|
715
812
|
const contentsJSON = JSON.parse(contentsString);
|
|
716
813
|
const contents = assertSharableCertificateAttributesContentsSchema(contentsJSON);
|
|
@@ -742,7 +839,8 @@ export class SharableCertificateAttributes {
|
|
|
742
839
|
}
|
|
743
840
|
return ([name, {
|
|
744
841
|
sensitive: false,
|
|
745
|
-
value: sharedValue
|
|
842
|
+
value: sharedValue,
|
|
843
|
+
references: attr.references
|
|
746
844
|
}]);
|
|
747
845
|
}
|
|
748
846
|
if (!certAttribute.sensitive) {
|
|
@@ -754,7 +852,8 @@ export class SharableCertificateAttributes {
|
|
|
754
852
|
const attrValue = bufferToArrayBuffer(Buffer.from(attr.value.value, 'base64'));
|
|
755
853
|
return ([name, {
|
|
756
854
|
sensitive: true,
|
|
757
|
-
value: attrValue
|
|
855
|
+
value: attrValue,
|
|
856
|
+
references: attr.references
|
|
758
857
|
}]);
|
|
759
858
|
});
|
|
760
859
|
const resolvedAttributes = await Promise.all(attributePromises);
|
|
@@ -777,21 +876,56 @@ export class SharableCertificateAttributes {
|
|
|
777
876
|
if (buffer === undefined) {
|
|
778
877
|
return (undefined);
|
|
779
878
|
}
|
|
780
|
-
const
|
|
781
|
-
/*
|
|
782
|
-
*
|
|
783
|
-
*
|
|
784
|
-
*
|
|
785
|
-
* The schema for references is not yet defined, so this is
|
|
786
|
-
* left as a TODO for now.
|
|
787
|
-
*
|
|
788
|
-
* The return type would also need to be updated to reflect
|
|
789
|
-
* that we would map referenced types to something like
|
|
790
|
-
* { data: ArrayBuffer, contentType: string, source: <url>,
|
|
791
|
-
* hash: <hash> } (where source and hash should be named
|
|
792
|
-
* after whatever the actual schema is)
|
|
879
|
+
const retvalWithReferences = await decodeAttribute(name, buffer, this.principals);
|
|
880
|
+
/*
|
|
881
|
+
* For all remote references, replace them with their referenced values
|
|
882
|
+
* which we encoded into "references"
|
|
793
883
|
*/
|
|
794
|
-
|
|
884
|
+
const retval = await walkObject(retvalWithReferences, async (key, value, parent) => {
|
|
885
|
+
if (key === '$blob') {
|
|
886
|
+
if (typeof parent !== 'object' || parent === null) {
|
|
887
|
+
throw (new Error('$blob->parent is not an object'));
|
|
888
|
+
}
|
|
889
|
+
if (!('digest' in parent) || typeof parent.digest !== 'object' || parent.digest === null) {
|
|
890
|
+
throw (new Error('$blob->parent->digest is not an object'));
|
|
891
|
+
}
|
|
892
|
+
const digestInfo = parent.digest;
|
|
893
|
+
if (!('digest' in digestInfo)) {
|
|
894
|
+
throw (new Error('$blob->parent->digest->digest is missing'));
|
|
895
|
+
}
|
|
896
|
+
if (!Buffer.isBuffer(digestInfo.digest)) {
|
|
897
|
+
throw (new TypeError('$blob digest is not a Buffer'));
|
|
898
|
+
}
|
|
899
|
+
if (!('external' in parent) || typeof parent.external !== 'object' || parent.external === null) {
|
|
900
|
+
throw (new Error('$blob->parent->external is not an object'));
|
|
901
|
+
}
|
|
902
|
+
if (!('contentType' in parent.external) || typeof parent.external.contentType !== 'string') {
|
|
903
|
+
throw (new Error('$blob->parent->external->contentType is not a string'));
|
|
904
|
+
}
|
|
905
|
+
const referenceID = digestInfo.digest.toString('hex').toUpperCase();
|
|
906
|
+
const referenceValue = this.#attributes[name]?.references?.[referenceID];
|
|
907
|
+
const contentType = parent.external.contentType;
|
|
908
|
+
return (async function () {
|
|
909
|
+
if (!referenceValue) {
|
|
910
|
+
throw (new Error(`Missing reference value for ID ${referenceID}`));
|
|
911
|
+
}
|
|
912
|
+
const referenceData = Buffer.from(referenceValue, 'base64');
|
|
913
|
+
const referenceDataAB = arrayBufferToBuffer(referenceData);
|
|
914
|
+
/* Verify the hash matches what was certified */
|
|
915
|
+
const checkHash = await checkHashWithOID(referenceData, parent.digest);
|
|
916
|
+
if (checkHash !== true) {
|
|
917
|
+
throw (checkHash);
|
|
918
|
+
}
|
|
919
|
+
return (new Blob([referenceDataAB], { type: contentType }));
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
return (value);
|
|
923
|
+
});
|
|
924
|
+
/*
|
|
925
|
+
* We didn't change the type, so we can safely cast here
|
|
926
|
+
*/
|
|
927
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
928
|
+
return retval;
|
|
795
929
|
}
|
|
796
930
|
async getAttributeNames(includeUnknown) {
|
|
797
931
|
await this.#populate();
|
|
@@ -821,14 +955,14 @@ export class SharableCertificateAttributes {
|
|
|
821
955
|
}
|
|
822
956
|
const retvalBuffer = await this.container.getEncodedBuffer();
|
|
823
957
|
if (options.format === 'string') {
|
|
824
|
-
const retvalBase64 = retvalBuffer.toString('base64');
|
|
958
|
+
const retvalBase64 = Buffer.from(retvalBuffer).toString('base64');
|
|
825
959
|
const retvalLines = ['-----BEGIN KYC CERTIFICATE PROOF-----'];
|
|
826
960
|
retvalLines.push(...retvalBase64.match(/.{1,64}/g) ?? []);
|
|
827
961
|
retvalLines.push('-----END KYC CERTIFICATE PROOF-----');
|
|
828
962
|
return (retvalLines.join('\n'));
|
|
829
963
|
}
|
|
830
964
|
else if (options.format === 'arraybuffer') {
|
|
831
|
-
return (
|
|
965
|
+
return (retvalBuffer);
|
|
832
966
|
}
|
|
833
967
|
else {
|
|
834
968
|
throw (new Error(`Unsupported export format: ${String(options.format)}`));
|