@keetanetwork/anchor 0.0.15 → 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 +162 -37
- 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/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/uri.d.ts +28 -0
- package/lib/uri.d.ts.map +1 -0
- package/lib/uri.js +100 -0
- package/lib/uri.js.map +1 -0
- 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 +212 -72
- package/package.json +2 -2
- package/services/kyc/iso20022.generated.d.ts +65 -48
- package/services/kyc/iso20022.generated.d.ts.map +1 -1
- package/services/kyc/iso20022.generated.js +57 -36
- package/services/kyc/iso20022.generated.js.map +1 -1
- package/services/kyc/oids.generated.d.ts +18 -24
- package/services/kyc/oids.generated.d.ts.map +1 -1
- package/services/kyc/oids.generated.js +32 -42
- package/services/kyc/oids.generated.js.map +1 -1
- package/services/kyc/utils/generate-kyc-schema.js +61 -3
- 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,MAAM,uCAAuC,CAAC;AAC/G,OAAO,EAAE,yBAAyB,
|
|
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,MAAM,uCAAuC,CAAC;AAC/G,OAAO,EAAE,yBAAyB,EAA8B,MAAM,uCAAuC,CAAC;AAa9G,KAAK,mBAAmB,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;AAEtF;;GAEG;AACH,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC;AACnG,QAAA,MAAM,eAAe,EAAE,OAAO,cAAc,CAAC,GAAG,CAAC,OAAoC,CAAC;AAsJtF,iBAAS,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,IAAI,yBAAyB,CAIhG;AAqJD,cAAM,kBAAkB,CAAC,CAAC,GAAG,WAAW;;gBAK3B,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,GA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MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,0CAA0C,EAAE,QAAQ,CAAC,GAAG;QAAE,MAAM,EAAE,aAAa,CAAA;KAAE,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAC/H,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,0CAA0C,EAAE,QAAQ,CAAC,GAAG;QAAE,MAAM,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;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
|
@@ -5,16 +5,57 @@ import { ASN1toJS, contextualizeStructSchema, encodeValueBySchema, normalizeDeco
|
|
|
5
5
|
import { arrayBufferLikeToBuffer, arrayBufferToBuffer, Buffer, bufferToArrayBuffer } from './utils/buffer.js';
|
|
6
6
|
import crypto from './utils/crypto.js';
|
|
7
7
|
import { assertNever } from './utils/never.js';
|
|
8
|
-
import { CertificateAttributeOIDDB, CertificateAttributeSchema
|
|
8
|
+
import { CertificateAttributeOIDDB, CertificateAttributeSchema } from '../services/kyc/iso20022.generated.js';
|
|
9
9
|
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
|
}
|
|
@@ -91,16 +132,7 @@ function asCertificateAttributeNames(name) {
|
|
|
91
132
|
assertCertificateAttributeNames(name);
|
|
92
133
|
return (name);
|
|
93
134
|
}
|
|
94
|
-
const DOCUMENT_SCHEMA_ATTRIBUTES = new Set([
|
|
95
|
-
'document',
|
|
96
|
-
'documentDriversLicenseFront',
|
|
97
|
-
'documentDriversLicenseBack',
|
|
98
|
-
'documentPassport'
|
|
99
|
-
]);
|
|
100
135
|
function resolveSchema(name, schema) {
|
|
101
|
-
if (DOCUMENT_SCHEMA_ATTRIBUTES.has(name)) {
|
|
102
|
-
return (contextualizeStructSchema(ReferenceSchema));
|
|
103
|
-
}
|
|
104
136
|
return (contextualizeStructSchema(schema));
|
|
105
137
|
}
|
|
106
138
|
function encodeAttribute(name, value) {
|
|
@@ -140,12 +172,12 @@ function encodeForSensitive(name, value) {
|
|
|
140
172
|
}
|
|
141
173
|
return (Buffer.from(String(value), 'utf-8'));
|
|
142
174
|
}
|
|
143
|
-
async function decodeAttribute(name, value) {
|
|
175
|
+
async function decodeAttribute(name, value, principals) {
|
|
144
176
|
const schema = resolveSchema(name, CertificateAttributeSchema[name]);
|
|
145
177
|
// XXX:TODO Fix depth issue
|
|
146
178
|
// @ts-ignore
|
|
147
179
|
const decodedUnknown = new ASN1.BufferStorageASN1(value, schema).getASN1();
|
|
148
|
-
const candidate = normalizeDecodedASN1(decodedUnknown);
|
|
180
|
+
const candidate = normalizeDecodedASN1(decodedUnknown, principals);
|
|
149
181
|
return (asAttributeValue(name, candidate));
|
|
150
182
|
}
|
|
151
183
|
class SensitiveAttributeBuilder {
|
|
@@ -535,7 +567,7 @@ export class Certificate extends KeetaNetClient.lib.Utils.Certificate.Certificat
|
|
|
535
567
|
setSensitiveAttribute(name, value) {
|
|
536
568
|
const decodeForSensitive = async (data) => {
|
|
537
569
|
const bufferInput = Buffer.isBuffer(data) ? bufferToArrayBuffer(data) : data;
|
|
538
|
-
return (await decodeAttribute(name, bufferInput));
|
|
570
|
+
return (await decodeAttribute(name, bufferInput, [this.subjectKey]));
|
|
539
571
|
};
|
|
540
572
|
this.attributes[name] = {
|
|
541
573
|
sensitive: true,
|
|
@@ -555,11 +587,11 @@ export class Certificate extends KeetaNetClient.lib.Utils.Certificate.Certificat
|
|
|
555
587
|
}
|
|
556
588
|
if (attr instanceof SensitiveAttribute) {
|
|
557
589
|
const raw = await attr.get();
|
|
558
|
-
return (await decodeAttribute(attributeName, raw));
|
|
590
|
+
return (await decodeAttribute(attributeName, raw, [this.subjectKey]));
|
|
559
591
|
}
|
|
560
592
|
// Non-sensitive: ArrayBuffer or Buffer
|
|
561
593
|
if (attr instanceof ArrayBuffer || Buffer.isBuffer(attr)) {
|
|
562
|
-
return (await decodeAttribute(attributeName, attr));
|
|
594
|
+
return (await decodeAttribute(attributeName, attr, [this.subjectKey]));
|
|
563
595
|
}
|
|
564
596
|
throw (new Error(`Attribute ${attributeName} is not a supported type`));
|
|
565
597
|
}
|
|
@@ -638,6 +670,9 @@ export class SharableCertificateAttributes {
|
|
|
638
670
|
const base64Content = base64Lines.join('');
|
|
639
671
|
containerBuffer = Buffer.from(base64Content, 'base64');
|
|
640
672
|
}
|
|
673
|
+
else if (Buffer.isBuffer(input)) {
|
|
674
|
+
containerBuffer = input;
|
|
675
|
+
}
|
|
641
676
|
else {
|
|
642
677
|
containerBuffer = arrayBufferToBuffer(input);
|
|
643
678
|
}
|
|
@@ -676,16 +711,69 @@ export class SharableCertificateAttributes {
|
|
|
676
711
|
if (!attr) {
|
|
677
712
|
continue;
|
|
678
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);
|
|
679
765
|
if (attr.sensitive) {
|
|
680
766
|
attributes[name] = {
|
|
681
767
|
sensitive: true,
|
|
682
|
-
value: await attr.value.getProof()
|
|
768
|
+
value: await attr.value.getProof(),
|
|
769
|
+
references: references
|
|
683
770
|
};
|
|
684
771
|
}
|
|
685
772
|
else {
|
|
686
773
|
attributes[name] = {
|
|
687
774
|
sensitive: false,
|
|
688
|
-
value: arrayBufferToBuffer(attr.value).toString('base64')
|
|
775
|
+
value: arrayBufferToBuffer(attr.value).toString('base64'),
|
|
776
|
+
references: references
|
|
689
777
|
};
|
|
690
778
|
}
|
|
691
779
|
}
|
|
@@ -698,7 +786,7 @@ export class SharableCertificateAttributes {
|
|
|
698
786
|
const contentsBufferCompressed = await KeetaNetClient.lib.Utils.Buffer.ZlibDeflateAsync(bufferToArrayBuffer(contentsBuffer));
|
|
699
787
|
const container = EncryptedContainer.fromPlaintext(arrayBufferToBuffer(contentsBufferCompressed), [temporaryUser], true);
|
|
700
788
|
const containerBuffer = await container.getEncodedBuffer();
|
|
701
|
-
const retval = new SharableCertificateAttributes(
|
|
789
|
+
const retval = new SharableCertificateAttributes(containerBuffer, { principals: temporaryUser });
|
|
702
790
|
await retval.revokeAccess(temporaryUser);
|
|
703
791
|
return (retval);
|
|
704
792
|
}
|
|
@@ -719,7 +807,7 @@ export class SharableCertificateAttributes {
|
|
|
719
807
|
}
|
|
720
808
|
this.populatedFromInit = true;
|
|
721
809
|
const contentsBuffer = await this.container.getPlaintext();
|
|
722
|
-
const contentsBufferDecompressed = await KeetaNetClient.lib.Utils.Buffer.ZlibInflateAsync(
|
|
810
|
+
const contentsBufferDecompressed = await KeetaNetClient.lib.Utils.Buffer.ZlibInflateAsync(contentsBuffer);
|
|
723
811
|
const contentsString = Buffer.from(contentsBufferDecompressed).toString('utf-8');
|
|
724
812
|
const contentsJSON = JSON.parse(contentsString);
|
|
725
813
|
const contents = assertSharableCertificateAttributesContentsSchema(contentsJSON);
|
|
@@ -751,7 +839,8 @@ export class SharableCertificateAttributes {
|
|
|
751
839
|
}
|
|
752
840
|
return ([name, {
|
|
753
841
|
sensitive: false,
|
|
754
|
-
value: sharedValue
|
|
842
|
+
value: sharedValue,
|
|
843
|
+
references: attr.references
|
|
755
844
|
}]);
|
|
756
845
|
}
|
|
757
846
|
if (!certAttribute.sensitive) {
|
|
@@ -763,7 +852,8 @@ export class SharableCertificateAttributes {
|
|
|
763
852
|
const attrValue = bufferToArrayBuffer(Buffer.from(attr.value.value, 'base64'));
|
|
764
853
|
return ([name, {
|
|
765
854
|
sensitive: true,
|
|
766
|
-
value: attrValue
|
|
855
|
+
value: attrValue,
|
|
856
|
+
references: attr.references
|
|
767
857
|
}]);
|
|
768
858
|
});
|
|
769
859
|
const resolvedAttributes = await Promise.all(attributePromises);
|
|
@@ -786,21 +876,56 @@ export class SharableCertificateAttributes {
|
|
|
786
876
|
if (buffer === undefined) {
|
|
787
877
|
return (undefined);
|
|
788
878
|
}
|
|
789
|
-
const
|
|
790
|
-
/*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
* The schema for references is not yet defined, so this is
|
|
795
|
-
* left as a TODO for now.
|
|
796
|
-
*
|
|
797
|
-
* The return type would also need to be updated to reflect
|
|
798
|
-
* that we would map referenced types to something like
|
|
799
|
-
* { data: ArrayBuffer, contentType: string, source: <url>,
|
|
800
|
-
* hash: <hash> } (where source and hash should be named
|
|
801
|
-
* 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"
|
|
802
883
|
*/
|
|
803
|
-
|
|
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;
|
|
804
929
|
}
|
|
805
930
|
async getAttributeNames(includeUnknown) {
|
|
806
931
|
await this.#populate();
|
|
@@ -830,14 +955,14 @@ export class SharableCertificateAttributes {
|
|
|
830
955
|
}
|
|
831
956
|
const retvalBuffer = await this.container.getEncodedBuffer();
|
|
832
957
|
if (options.format === 'string') {
|
|
833
|
-
const retvalBase64 = retvalBuffer.toString('base64');
|
|
958
|
+
const retvalBase64 = Buffer.from(retvalBuffer).toString('base64');
|
|
834
959
|
const retvalLines = ['-----BEGIN KYC CERTIFICATE PROOF-----'];
|
|
835
960
|
retvalLines.push(...retvalBase64.match(/.{1,64}/g) ?? []);
|
|
836
961
|
retvalLines.push('-----END KYC CERTIFICATE PROOF-----');
|
|
837
962
|
return (retvalLines.join('\n'));
|
|
838
963
|
}
|
|
839
964
|
else if (options.format === 'arraybuffer') {
|
|
840
|
-
return (
|
|
965
|
+
return (retvalBuffer);
|
|
841
966
|
}
|
|
842
967
|
else {
|
|
843
968
|
throw (new Error(`Unsupported export format: ${String(options.format)}`));
|