@keetanetwork/anchor 0.0.25 → 0.0.26

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.
@@ -2,6 +2,12 @@ import * as KeetaNetClient from '@keetanetwork/keetanet-client';
2
2
  import { Buffer } from './utils/buffer.js';
3
3
  import type { CertificateAttributeValue } from '../services/kyc/iso20022.generated.js';
4
4
  import { CertificateAttributeOIDDB } from '../services/kyc/iso20022.generated.js';
5
+ type BaseCertificateClass = typeof KeetaNetClient.lib.Utils.Certificate.Certificate;
6
+ type BaseCertificate = InstanceType<BaseCertificateClass>;
7
+ declare const BaseCertificate: BaseCertificateClass;
8
+ type BaseCertificateBuilderClass = typeof KeetaNetClient.lib.Utils.Certificate.CertificateBuilder;
9
+ type BaseCertificateBuilder = InstanceType<BaseCertificateBuilderClass>;
10
+ declare const BaseCertificateBuilder: BaseCertificateBuilderClass;
5
11
  type AccountKeyAlgorithm = InstanceType<typeof KeetaNetClient.lib.Account>['keyType'];
6
12
  /**
7
13
  * An alias for the KeetaNetAccount type
@@ -45,7 +51,7 @@ declare class SensitiveAttribute<T = ArrayBuffer> {
45
51
  * Type for certificate attribute names (derived from generated OID database)
46
52
  */
47
53
  type CertificateAttributeNames = keyof typeof CertificateAttributeOIDDB;
48
- type BaseCertificateBuilderParams = NonNullable<ConstructorParameters<typeof KeetaNetClient.lib.Utils.Certificate.CertificateBuilder>[0]>;
54
+ type BaseCertificateBuilderParams = NonNullable<ConstructorParameters<BaseCertificateBuilderClass>[0]>;
49
55
  type CertificateBuilderParams = Required<Pick<BaseCertificateBuilderParams, 'issuer' | 'validFrom' | 'validTo' | 'serial' | 'hashLib' | 'issuerDN' | 'subjectDN' | 'isCA'> & {
50
56
  /**
51
57
  * The key of the subject -- used for Sensitive Attributes as well
@@ -54,7 +60,7 @@ type CertificateBuilderParams = Required<Pick<BaseCertificateBuilderParams, 'iss
54
60
  subject: BaseCertificateBuilderParams['subjectPublicKey'];
55
61
  }>;
56
62
  type CertificateAttributeInput<NAME extends CertificateAttributeNames> = CertificateAttributeValue<NAME>;
57
- export declare class CertificateBuilder extends KeetaNetClient.lib.Utils.Certificate.CertificateBuilder {
63
+ export declare class CertificateBuilder extends BaseCertificateBuilder {
58
64
  #private;
59
65
  /**
60
66
  * Map the parameters from the public interface to the internal
@@ -71,7 +77,7 @@ export declare class CertificateBuilder extends KeetaNetClient.lib.Utils.Certifi
71
77
  * value can be proven later without revealing it.
72
78
  */
73
79
  setAttribute<NAME extends CertificateAttributeNames>(name: NAME, sensitive: boolean, value: CertificateAttributeInput<NAME>): void;
74
- protected addExtensions(...args: Parameters<InstanceType<typeof KeetaNetClient.lib.Utils.Certificate.CertificateBuilder>['addExtensions']>): ReturnType<InstanceType<typeof KeetaNetClient.lib.Utils.Certificate.CertificateBuilder>['addExtensions']>;
80
+ protected addExtensions(...args: Parameters<BaseCertificateBuilder['addExtensions']>): ReturnType<BaseCertificateBuilder['addExtensions']>;
75
81
  /**
76
82
  * Create a Certificate object from the builder
77
83
  *
@@ -80,7 +86,7 @@ export declare class CertificateBuilder extends KeetaNetClient.lib.Utils.Certifi
80
86
  */
81
87
  build(params?: Partial<CertificateBuilderParams>): Promise<Certificate>;
82
88
  }
83
- export declare class Certificate extends KeetaNetClient.lib.Utils.Certificate.Certificate {
89
+ export declare class Certificate extends BaseCertificate {
84
90
  private readonly subjectKey;
85
91
  static readonly Builder: typeof CertificateBuilder;
86
92
  static readonly SharableAttributes: typeof SharableCertificateAttributes;
@@ -96,7 +102,7 @@ export declare class Certificate extends KeetaNetClient.lib.Utils.Certificate.Ce
96
102
  value: ArrayBuffer;
97
103
  };
98
104
  };
99
- constructor(input: ConstructorParameters<typeof KeetaNetClient.lib.Utils.Certificate.Certificate>[0], options?: ConstructorParameters<typeof KeetaNetClient.lib.Utils.Certificate.Certificate>[1] & {
105
+ constructor(input: ConstructorParameters<BaseCertificateClass>[0], options?: ConstructorParameters<BaseCertificateClass>[1] & {
100
106
  subjectKey?: KeetaNetAccount;
101
107
  });
102
108
  protected finalizeConstruction(): void;
@@ -129,6 +135,7 @@ export declare namespace SharableCertificateAttributesTypes {
129
135
  };
130
136
  type ContentsSchema = {
131
137
  certificate: string;
138
+ intermediates?: string[] | undefined;
132
139
  attributes: {
133
140
  [name: string]: {
134
141
  sensitive: true;
@@ -159,11 +166,21 @@ export declare class SharableCertificateAttributes {
159
166
  * and a list of attribute names to include -- if no list is
160
167
  * provided, all attributes are included.
161
168
  */
169
+ static fromCertificate(certificate: Certificate, intermediates?: Set<BaseCertificate>, attributeNames?: CertificateAttributeNames[]): Promise<SharableCertificateAttributes>;
170
+ /** @deprecated Use the overload with three parameters instead */
162
171
  static fromCertificate(certificate: Certificate, attributeNames?: CertificateAttributeNames[]): Promise<SharableCertificateAttributes>;
163
172
  grantAccess(principal: KeetaNetAccount): Promise<this>;
164
173
  revokeAccess(principal: KeetaNetAccount): Promise<this>;
165
174
  get principals(): KeetaNetAccount[];
166
175
  getCertificate(): Promise<Certificate>;
176
+ /**
177
+ * Get the intermediate certificates included in this sharable
178
+ * certificate container
179
+ *
180
+ * @return A set of BaseCertificate objects representing the
181
+ * intermediate certificates attached to this container
182
+ */
183
+ getIntermediates(): Promise<Set<BaseCertificate>>;
167
184
  getAttributeBuffer(name: string): Promise<ArrayBuffer | undefined>;
168
185
  getAttribute<NAME extends CertificateAttributeNames>(name: NAME): Promise<CertificateAttributeValue<NAME> | undefined>;
169
186
  getAttributeNames(includeUnknown: true): Promise<string[]>;
@@ -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,EAA8B,MAAM,uCAAuC,CAAC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O,CAAC,WAAW,GAAG,MAAM,CAAC;CA8B3F"}
@@ -1,7 +1,7 @@
1
1
  import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
2
2
  import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
3
3
  import * as typia from 'typia';
4
- export const assertSharableCertificateAttributesContentsSchema = (() => { const _io0 = input => "string" === typeof input.certificate && ("object" === typeof input.attributes && null !== input.attributes && false === Array.isArray(input.attributes) && _io1(input.attributes)); const _io1 = input => Object.keys(input).every(key => {
4
+ export const assertSharableCertificateAttributesContentsSchema = (() => { const _io0 = input => "string" === typeof input.certificate && (undefined === input.intermediates || Array.isArray(input.intermediates) && input.intermediates.every(elem => "string" === typeof elem)) && ("object" === typeof input.attributes && null !== input.attributes && false === Array.isArray(input.attributes) && _io1(input.attributes)); const _io1 = input => Object.keys(input).every(key => {
5
5
  const value = input[key];
6
6
  if (undefined === value)
7
7
  return true;
@@ -28,6 +28,21 @@ export const assertSharableCertificateAttributesContentsSchema = (() => { const
28
28
  path: _path + ".certificate",
29
29
  expected: "string",
30
30
  value: input.certificate
31
+ }, _errorFactory)) && (undefined === input.intermediates || (Array.isArray(input.intermediates) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
32
+ method: "typia.createAssert",
33
+ path: _path + ".intermediates",
34
+ expected: "(Array<string> | undefined)",
35
+ value: input.intermediates
36
+ }, _errorFactory)) && input.intermediates.every((elem, _index2) => "string" === typeof elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
37
+ method: "typia.createAssert",
38
+ path: _path + ".intermediates[" + _index2 + "]",
39
+ expected: "string",
40
+ value: elem
41
+ }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
42
+ method: "typia.createAssert",
43
+ path: _path + ".intermediates",
44
+ expected: "(Array<string> | undefined)",
45
+ value: input.intermediates
31
46
  }, _errorFactory)) && (("object" === typeof input.attributes && null !== input.attributes && false === Array.isArray(input.attributes) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
32
47
  method: "typia.createAssert",
33
48
  path: _path + ".attributes",
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"]}
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"]}
@@ -15,6 +15,8 @@ import { checkHashWithOID } from './utils/external.js';
15
15
  * Short alias for printing a debug representation of an object
16
16
  */
17
17
  const DPO = KeetaNetClient.lib.Utils.Helper.debugPrintableObject.bind(KeetaNetClient.lib.Utils.Helper);
18
+ const BaseCertificate = KeetaNetClient.lib.Utils.Certificate.Certificate;
19
+ const BaseCertificateBuilder = KeetaNetClient.lib.Utils.Certificate.CertificateBuilder;
18
20
  const KeetaNetAccount = KeetaNetClient.lib.Account;
19
21
  function isBlob(input) {
20
22
  if (typeof input !== 'object' || input === null) {
@@ -422,7 +424,7 @@ const CertificateKYCAttributeSchemaValidation = {
422
424
  ]
423
425
  }]
424
426
  };
425
- export class CertificateBuilder extends KeetaNetClient.lib.Utils.Certificate.CertificateBuilder {
427
+ export class CertificateBuilder extends BaseCertificateBuilder {
426
428
  #attributes = {};
427
429
  /**
428
430
  * Map the parameters from the public interface to the internal
@@ -521,7 +523,7 @@ export class CertificateBuilder extends KeetaNetClient.lib.Utils.Certificate.Cer
521
523
  }]);
522
524
  }
523
525
  if (certAttributes.length > 0) {
524
- retval.push(KeetaNetClient.lib.Utils.Certificate.CertificateBuilder.extension(oids.keeta.KYC_ATTRIBUTES, certAttributes));
526
+ retval.push(BaseCertificateBuilder.extension(oids.keeta.KYC_ATTRIBUTES, certAttributes));
525
527
  }
526
528
  return (retval);
527
529
  }
@@ -547,7 +549,7 @@ export class CertificateBuilder extends KeetaNetClient.lib.Utils.Certificate.Cer
547
549
  return (certificateObject);
548
550
  }
549
551
  }
550
- export class Certificate extends KeetaNetClient.lib.Utils.Certificate.Certificate {
552
+ export class Certificate extends BaseCertificate {
551
553
  subjectKey;
552
554
  static Builder = CertificateBuilder;
553
555
  static SharableAttributes;
@@ -630,6 +632,7 @@ export class Certificate extends KeetaNetClient.lib.Utils.Certificate.Certificat
630
632
  ;
631
633
  export class SharableCertificateAttributes {
632
634
  #certificate;
635
+ #intermediates;
633
636
  #attributes = {};
634
637
  container;
635
638
  populatedFromInit = false;
@@ -691,12 +694,28 @@ export class SharableCertificateAttributes {
691
694
  }
692
695
  this.container = EncryptedContainer.fromEncodedBuffer(containerBuffer, principals);
693
696
  }
694
- /**
695
- * Create a SharableCertificateAttributes from a Certificate
696
- * and a list of attribute names to include -- if no list is
697
- * provided, all attributes are included.
698
- */
699
- static async fromCertificate(certificate, attributeNames) {
697
+ static async fromCertificate(certificate, intermediatesOrAttributeNames, definitelyAttributeNames) {
698
+ let intermediates = undefined;
699
+ let attributeNames = undefined;
700
+ if (definitelyAttributeNames === undefined) {
701
+ if (intermediatesOrAttributeNames !== undefined) {
702
+ if (Array.isArray(intermediatesOrAttributeNames)) {
703
+ attributeNames = intermediatesOrAttributeNames;
704
+ }
705
+ else {
706
+ intermediates = intermediatesOrAttributeNames;
707
+ }
708
+ }
709
+ }
710
+ else {
711
+ if (intermediatesOrAttributeNames !== undefined) {
712
+ if (Array.isArray(intermediatesOrAttributeNames)) {
713
+ throw (new TypeError('Expected Set<BaseCertificate> for intermediates'));
714
+ }
715
+ intermediates = intermediatesOrAttributeNames;
716
+ }
717
+ attributeNames = definitelyAttributeNames;
718
+ }
700
719
  if (attributeNames === undefined) {
701
720
  /*
702
721
  * We know the keys are whatever the Certificate says they are, so
@@ -780,15 +799,28 @@ export class SharableCertificateAttributes {
780
799
  };
781
800
  }
782
801
  }
802
+ let intermediatesJSON;
803
+ intermediates ??= new Set();
804
+ if (intermediates.size === 0) {
805
+ intermediatesJSON = undefined;
806
+ }
807
+ else {
808
+ intermediatesJSON = Array.from(intermediates).map(function (intermediateCertificate) {
809
+ return (intermediateCertificate.toPEM());
810
+ });
811
+ }
783
812
  const contentsString = JSON.stringify({
784
813
  certificate: certificate.toPEM(),
814
+ intermediates: intermediatesJSON,
785
815
  attributes: attributes
786
816
  });
787
817
  const temporaryUser = KeetaNetAccount.fromSeed(KeetaNetAccount.generateRandomSeed(), 0);
788
818
  const contentsBuffer = Buffer.from(contentsString, 'utf-8');
789
819
  const container = EncryptedContainer.fromPlaintext(bufferToArrayBuffer(contentsBuffer), [temporaryUser], true);
790
820
  const containerBuffer = await container.getEncodedBuffer();
791
- const retval = new SharableCertificateAttributes(containerBuffer, { principals: temporaryUser });
821
+ const retval = new SharableCertificateAttributes(containerBuffer, {
822
+ principals: temporaryUser
823
+ });
792
824
  await retval.revokeAccess(temporaryUser);
793
825
  return (retval);
794
826
  }
@@ -824,6 +856,11 @@ export class SharableCertificateAttributes {
824
856
  const contentsString = Buffer.from(contentsBufferDecompressed).toString('utf-8');
825
857
  const contentsJSON = JSON.parse(contentsString);
826
858
  const contents = assertSharableCertificateAttributesContentsSchema(contentsJSON);
859
+ this.#intermediates = new Set();
860
+ for (const intermediatePEM of contents.intermediates ?? []) {
861
+ const intermediateCert = new BaseCertificate(intermediatePEM);
862
+ this.#intermediates.add(intermediateCert);
863
+ }
827
864
  this.#certificate = new Certificate(contents.certificate);
828
865
  const attributePromises = Object.entries(contents.attributes).map(async ([name, attr]) => {
829
866
  /*
@@ -879,6 +916,20 @@ export class SharableCertificateAttributes {
879
916
  }
880
917
  return (this.#certificate);
881
918
  }
919
+ /**
920
+ * Get the intermediate certificates included in this sharable
921
+ * certificate container
922
+ *
923
+ * @return A set of BaseCertificate objects representing the
924
+ * intermediate certificates attached to this container
925
+ */
926
+ async getIntermediates() {
927
+ await this.#populate();
928
+ if (this.#intermediates && this.#intermediates.size > 0) {
929
+ return (new Set(this.#intermediates));
930
+ }
931
+ return (new Set());
932
+ }
882
933
  async getAttributeBuffer(name) {
883
934
  await this.#populate();
884
935
  const attr = this.#attributes[name];
@@ -923,7 +974,7 @@ export class SharableCertificateAttributes {
923
974
  throw (new Error(`Missing reference value for ID ${referenceID}`));
924
975
  }
925
976
  const referenceData = Buffer.from(referenceValue, 'base64');
926
- const referenceDataAB = arrayBufferToBuffer(referenceData);
977
+ const referenceDataAB = bufferToArrayBuffer(referenceData);
927
978
  /* Verify the hash matches what was certified */
928
979
  const checkHash = await checkHashWithOID(referenceData, parent.digest);
929
980
  if (checkHash !== true) {