@nmshd/crypto 1.0.8 → 2.0.1

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.
Files changed (113) hide show
  1. package/dist/CoreBuffer.d.ts +0 -1
  2. package/dist/CoreBuffer.js +1 -4
  3. package/dist/CoreBuffer.js.map +1 -1
  4. package/dist/CryptoDerivation.js +2 -2
  5. package/dist/CryptoDerivation.js.map +1 -1
  6. package/dist/CryptoPrivateKey.d.ts +14 -17
  7. package/dist/CryptoPrivateKey.js +24 -39
  8. package/dist/CryptoPrivateKey.js.map +1 -1
  9. package/dist/CryptoPublicKey.d.ts +13 -16
  10. package/dist/CryptoPublicKey.js +22 -37
  11. package/dist/CryptoPublicKey.js.map +1 -1
  12. package/dist/CryptoSerializable.d.ts +5 -0
  13. package/dist/CryptoSerializable.js +15 -0
  14. package/dist/CryptoSerializable.js.map +1 -0
  15. package/dist/CryptoValidation.d.ts +4 -6
  16. package/dist/CryptoValidation.js +16 -29
  17. package/dist/CryptoValidation.js.map +1 -1
  18. package/dist/SodiumWrapper.js +5 -1
  19. package/dist/SodiumWrapper.js.map +1 -1
  20. package/dist/buildInformation.js +5 -5
  21. package/dist/encryption/CryptoCipher.d.ts +10 -11
  22. package/dist/encryption/CryptoCipher.js +62 -59
  23. package/dist/encryption/CryptoCipher.js.map +1 -1
  24. package/dist/encryption/CryptoEncryption.js +10 -12
  25. package/dist/encryption/CryptoEncryption.js.map +1 -1
  26. package/dist/encryption/CryptoSecretKey.d.ts +8 -9
  27. package/dist/encryption/CryptoSecretKey.js +36 -32
  28. package/dist/encryption/CryptoSecretKey.js.map +1 -1
  29. package/dist/exchange/CryptoExchange.d.ts +0 -2
  30. package/dist/exchange/CryptoExchange.js +5 -22
  31. package/dist/exchange/CryptoExchange.js.map +1 -1
  32. package/dist/exchange/CryptoExchangeKeypair.d.ts +10 -11
  33. package/dist/exchange/CryptoExchangeKeypair.js +33 -30
  34. package/dist/exchange/CryptoExchangeKeypair.js.map +1 -1
  35. package/dist/exchange/CryptoExchangePrivateKey.d.ts +8 -10
  36. package/dist/exchange/CryptoExchangePrivateKey.js +50 -31
  37. package/dist/exchange/CryptoExchangePrivateKey.js.map +1 -1
  38. package/dist/exchange/CryptoExchangePublicKey.d.ts +6 -7
  39. package/dist/exchange/CryptoExchangePublicKey.js +31 -32
  40. package/dist/exchange/CryptoExchangePublicKey.js.map +1 -1
  41. package/dist/exchange/CryptoExchangeSecrets.d.ts +10 -11
  42. package/dist/exchange/CryptoExchangeSecrets.js +33 -35
  43. package/dist/exchange/CryptoExchangeSecrets.js.map +1 -1
  44. package/dist/exchange/CryptoExchangeValidation.d.ts +7 -10
  45. package/dist/exchange/CryptoExchangeValidation.js +9 -36
  46. package/dist/exchange/CryptoExchangeValidation.js.map +1 -1
  47. package/dist/index.d.ts +1 -0
  48. package/dist/index.js +6 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/relationship/CryptoRelationshipPublicRequest.d.ts +8 -9
  51. package/dist/relationship/CryptoRelationshipPublicRequest.js +23 -42
  52. package/dist/relationship/CryptoRelationshipPublicRequest.js.map +1 -1
  53. package/dist/relationship/CryptoRelationshipPublicResponse.d.ts +8 -9
  54. package/dist/relationship/CryptoRelationshipPublicResponse.js +24 -38
  55. package/dist/relationship/CryptoRelationshipPublicResponse.js.map +1 -1
  56. package/dist/relationship/CryptoRelationshipRequestSecrets.d.ts +6 -7
  57. package/dist/relationship/CryptoRelationshipRequestSecrets.js +7 -10
  58. package/dist/relationship/CryptoRelationshipRequestSecrets.js.map +1 -1
  59. package/dist/relationship/CryptoRelationshipSecrets.d.ts +6 -7
  60. package/dist/relationship/CryptoRelationshipSecrets.js +8 -11
  61. package/dist/relationship/CryptoRelationshipSecrets.js.map +1 -1
  62. package/dist/signature/CryptoSignature.d.ts +12 -13
  63. package/dist/signature/CryptoSignature.js +39 -35
  64. package/dist/signature/CryptoSignature.js.map +1 -1
  65. package/dist/signature/CryptoSignatureAlgorithm.d.ts +5 -0
  66. package/dist/signature/CryptoSignatureAlgorithm.js +3 -0
  67. package/dist/signature/CryptoSignatureAlgorithm.js.map +1 -0
  68. package/dist/signature/CryptoSignatureKeypair.d.ts +10 -11
  69. package/dist/signature/CryptoSignatureKeypair.js +36 -38
  70. package/dist/signature/CryptoSignatureKeypair.js.map +1 -1
  71. package/dist/signature/CryptoSignaturePrivateKey.d.ts +10 -13
  72. package/dist/signature/CryptoSignaturePrivateKey.js +28 -37
  73. package/dist/signature/CryptoSignaturePrivateKey.js.map +1 -1
  74. package/dist/signature/CryptoSignaturePublicKey.d.ts +9 -12
  75. package/dist/signature/CryptoSignaturePublicKey.js +22 -44
  76. package/dist/signature/CryptoSignaturePublicKey.js.map +1 -1
  77. package/dist/signature/CryptoSignatureValidation.d.ts +10 -12
  78. package/dist/signature/CryptoSignatureValidation.js +13 -35
  79. package/dist/signature/CryptoSignatureValidation.js.map +1 -1
  80. package/dist/signature/CryptoSignatures.d.ts +1 -5
  81. package/dist/signature/CryptoSignatures.js +5 -5
  82. package/dist/signature/CryptoSignatures.js.map +1 -1
  83. package/dist/state/CryptoPrivateState.d.ts +12 -20
  84. package/dist/state/CryptoPrivateState.js +73 -77
  85. package/dist/state/CryptoPrivateState.js.map +1 -1
  86. package/dist/state/CryptoPrivateStateReceive.d.ts +4 -6
  87. package/dist/state/CryptoPrivateStateReceive.js +27 -39
  88. package/dist/state/CryptoPrivateStateReceive.js.map +1 -1
  89. package/dist/state/CryptoPrivateStateTransmit.d.ts +3 -4
  90. package/dist/state/CryptoPrivateStateTransmit.js +14 -40
  91. package/dist/state/CryptoPrivateStateTransmit.js.map +1 -1
  92. package/dist/state/CryptoPublicState.d.ts +11 -16
  93. package/dist/state/CryptoPublicState.js +44 -53
  94. package/dist/state/CryptoPublicState.js.map +1 -1
  95. package/dist/stream/CryptoStream.js +5 -2
  96. package/dist/stream/CryptoStream.js.map +1 -1
  97. package/dist/stream/CryptoStreamAddress.d.ts +7 -10
  98. package/dist/stream/CryptoStreamAddress.js +13 -29
  99. package/dist/stream/CryptoStreamAddress.js.map +1 -1
  100. package/dist/stream/CryptoStreamHeader.d.ts +9 -12
  101. package/dist/stream/CryptoStreamHeader.js +15 -18
  102. package/dist/stream/CryptoStreamHeader.js.map +1 -1
  103. package/dist/stream/CryptoStreamState.d.ts +6 -10
  104. package/dist/stream/CryptoStreamState.js +15 -33
  105. package/dist/stream/CryptoStreamState.js.map +1 -1
  106. package/lib-web/nmshd.crypto.js +795 -1023
  107. package/lib-web/nmshd.crypto.js.map +1 -1
  108. package/lib-web/nmshd.crypto.min.js +1 -1
  109. package/lib-web/nmshd.crypto.min.js.map +1 -1
  110. package/package.json +18 -18
  111. package/dist/CryptoSerializableAsync.d.ts +0 -5
  112. package/dist/CryptoSerializableAsync.js +0 -24
  113. package/dist/CryptoSerializableAsync.js.map +0 -1
@@ -4,8 +4,6 @@ exports.CryptoExchangeValidation = void 0;
4
4
  const CryptoError_1 = require("../CryptoError");
5
5
  const CryptoErrorCode_1 = require("../CryptoErrorCode");
6
6
  const CryptoValidation_1 = require("../CryptoValidation");
7
- const CryptoExchangePrivateKey_1 = require("./CryptoExchangePrivateKey");
8
- const CryptoExchangePublicKey_1 = require("./CryptoExchangePublicKey");
9
7
  class CryptoExchangeValidation extends CryptoValidation_1.CryptoValidation {
10
8
  static checkExchangeAlgorithm(algorithm, throwError = true) {
11
9
  let error;
@@ -22,20 +20,17 @@ class CryptoExchangeValidation extends CryptoValidation_1.CryptoValidation {
22
20
  throw error;
23
21
  return error;
24
22
  }
25
- static checkExchangePrivateKeyAsNumber(privateKey, algorithm, propertyName = "privateKey", throwError = true) {
23
+ static checkExchangePrivateKeyAsString(privateKey, algorithm, propertyName = "privateKey", throwError = true) {
26
24
  return super.checkSerializedBuffer(privateKey, this.PRIVATE_KEY_MIN_BYTES, this.PRIVATE_KEY_MAX_BYTES, propertyName, throwError);
27
25
  }
28
26
  static checkExchangePrivateKeyAsBuffer(privateKey, algorithm, propertyName = "privateKey", throwError = true) {
29
27
  return super.checkBuffer(privateKey, this.PRIVATE_KEY_MIN_BYTES, this.PRIVATE_KEY_MAX_BYTES, propertyName, throwError);
30
28
  }
31
- static checkExchangePrivateKey(privateKey, throwError = true) {
32
- let error;
33
- if (!(privateKey instanceof CryptoExchangePrivateKey_1.CryptoExchangePrivateKey)) {
34
- error = new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.ExchangeWrongPrivateKey, "PrivateKey is not set or supported.");
29
+ static checkExchangePrivateKey(privateKey, algorithm, propertyName = "privateKey", throwError = true) {
30
+ if (typeof privateKey === "string") {
31
+ return this.checkExchangePrivateKeyAsString(privateKey, algorithm, propertyName, throwError);
35
32
  }
36
- if (error && throwError)
37
- throw error;
38
- return error;
33
+ return this.checkExchangePrivateKeyAsBuffer(privateKey, algorithm, propertyName, throwError);
39
34
  }
40
35
  static checkExchangePublicKeyAsString(publicKey, algorithm, propertyName = "publicKey", throwError = true) {
41
36
  return super.checkSerializedBuffer(publicKey, this.PRIVATE_KEY_MIN_BYTES, this.PRIVATE_KEY_MAX_BYTES, propertyName, throwError);
@@ -43,33 +38,11 @@ class CryptoExchangeValidation extends CryptoValidation_1.CryptoValidation {
43
38
  static checkExchangePublicKeyAsBuffer(publicKey, algorithm, propertyName = "publicKey", throwError = true) {
44
39
  return super.checkBuffer(publicKey, this.PRIVATE_KEY_MIN_BYTES, this.PRIVATE_KEY_MAX_BYTES, propertyName, throwError);
45
40
  }
46
- static checkExchangePublicKey(publicKey, throwError = true) {
47
- let error;
48
- if (!(publicKey instanceof CryptoExchangePublicKey_1.CryptoExchangePublicKey)) {
49
- error = new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.ExchangeWrongPublicKey, "PublicKey is not set or supported.");
50
- }
51
- if (error && throwError)
52
- throw error;
53
- return error;
54
- }
55
- static checkExchangeKeypair(privateKey, publicKey, throwError = true) {
56
- let error;
57
- error = this.checkExchangePublicKey(publicKey);
58
- if (error && throwError)
59
- throw error;
60
- else if (error)
61
- return error;
62
- error = this.checkExchangePrivateKey(privateKey);
63
- if (error && throwError)
64
- throw error;
65
- else if (error)
66
- return error;
67
- if (privateKey.algorithm !== publicKey.algorithm) {
68
- error = new CryptoError_1.CryptoError(CryptoErrorCode_1.CryptoErrorCode.ExchangeWrongAlgorithm, "Algorithms of private and public key do not match.");
41
+ static checkExchangePublicKey(publicKey, algorithm, propertyName = "publicKey", throwError = true) {
42
+ if (typeof publicKey === "string") {
43
+ return this.checkExchangePublicKeyAsString(publicKey, algorithm, propertyName, throwError);
69
44
  }
70
- if (error && throwError)
71
- throw error;
72
- return error;
45
+ return this.checkExchangePublicKeyAsBuffer(publicKey, algorithm, propertyName, throwError);
73
46
  }
74
47
  }
75
48
  exports.CryptoExchangeValidation = CryptoExchangeValidation;
@@ -1 +1 @@
1
- {"version":3,"file":"CryptoExchangeValidation.js","sourceRoot":"","sources":["../../src/exchange/CryptoExchangeValidation.ts"],"names":[],"mappings":";;;AACA,gDAA6C;AAC7C,wDAAqD;AACrD,0DAAuD;AAEvD,yEAAsE;AACtE,uEAAoE;AAEpE,MAAa,wBAAyB,SAAQ,mCAAgB;IAMnD,MAAM,CAAC,sBAAsB,CAAC,SAAiB,EAAE,UAAU,GAAG,IAAI;QACrE,IAAI,KAAK,CAAC;QACV,QAAQ,SAAS,EAAE;YACf,uBAAuC;YACvC,uBAAuC;YACvC;gBACI,MAAM;YACV;gBACI,KAAK,GAAG,IAAI,yBAAW,CACnB,iCAAe,CAAC,sBAAsB,EACtC,6CAA6C,CAChD,CAAC;gBACF,MAAM;SACb;QACD,IAAI,KAAK,IAAI,UAAU;YAAE,MAAM,KAAK,CAAC;QACrC,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,+BAA+B,CACzC,UAAkB,EAClB,SAAkC,EAClC,YAAY,GAAG,YAAY,EAC3B,UAAU,GAAG,IAAI;QAEjB,OAAO,KAAK,CAAC,qBAAqB,CAC9B,UAAU,EACV,IAAI,CAAC,qB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AiB,EACjB,SAAkC,EAClC,YAAY,GAAG,WAAW,EAC1B,UAAU,GAAG,IAAI;QAEjB,OAAO,KAAK,CAAC,qBAAqB,CAC9B,SAAS,EACT,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,qBAAqB,EAC1B,YAAY,EACZ,UAAU,CACb,CAAC;IACN,CAAC;IAEM,MAAM,CAAC,8BAA8B,CACxC,SAAqB,EACrB,SAAkC,EAClC,YAAY,GAAG,WAAW,EAC1B,UAAU,GAAG,IAAI;QAEjB,OAAO,KAAK,CAAC,WAAW,CACpB,SAAS,EACT,IAAI,CAAC,qBAAqB,EAC1B,IAAI,CAAC,qBAAqB,EAC1B,YAAY,EACZ,UAAU,CACb,CAAC;IACN,CAAC;IAEM,MAAM,CAAC,sBAAsB,CAChC,SAA8B,EAC9B,SAAkC,EAClC,YAAY,GAAG,WAAW,EAC1B,UAAU,GAAG,IAAI;QAEjB,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YAC/B,OAAO,IAAI,CAAC,8BAA8B,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;SAC9F;QAED,OAAO,IAAI,CAAC,8BAA8B,CAAC,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;IAC/F,CAAC;;AA5GL,4DA6GC;AA5G0B,8CAAqB,GAAG,EAAE,CAAC;AAC3B,8CAAqB,GAAG,EAAE,CAAC;AAC3B,6CAAoB,GAAG,EAAE,CAAC;AAC1B,6CAAoB,GAAG,EAAE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -25,6 +25,7 @@ export * from "./relationship/CryptoRelationshipRequestSecrets";
25
25
  export * from "./relationship/CryptoRelationshipSecrets";
26
26
  export * from "./relationship/CryptoRelationshipType";
27
27
  export * from "./signature/CryptoSignature";
28
+ export * from "./signature/CryptoSignatureAlgorithm";
28
29
  export * from "./signature/CryptoSignatureKeypair";
29
30
  export * from "./signature/CryptoSignaturePrivateKey";
30
31
  export * from "./signature/CryptoSignaturePublicKey";
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -37,6 +41,7 @@ __exportStar(require("./relationship/CryptoRelationshipRequestSecrets"), exports
37
41
  __exportStar(require("./relationship/CryptoRelationshipSecrets"), exports);
38
42
  __exportStar(require("./relationship/CryptoRelationshipType"), exports);
39
43
  __exportStar(require("./signature/CryptoSignature"), exports);
44
+ __exportStar(require("./signature/CryptoSignatureAlgorithm"), exports);
40
45
  __exportStar(require("./signature/CryptoSignatureKeypair"), exports);
41
46
  __exportStar(require("./signature/CryptoSignaturePrivateKey"), exports);
42
47
  __exportStar(require("./signature/CryptoSignaturePublicKey"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,qDAAmC;AACnC,+CAA6B;AAC7B,qDAAmC;AACnC,gDAA8B;AAC9B,oDAAkC;AAClC,qDAAmC;AACnC,oDAAkC;AAClC,qDAAmC;AACnC,4DAA0C;AAC1C,gEAA8C;AAC9C,+DAA6C;AAC7C,4DAA0C;AAC1C,mEAAiD;AACjD,sEAAoD;AACpD,qEAAmD;AACnD,mEAAiD;AACjD,sEAAoD;AACpD,oDAAkC;AAClC,mEAAiD;AACjD,wDAAsC;AACtC,iFAA+D;AAC/D,kFAAgE;AAChE,kFAAgE;AAChE,2EAAyD;AACzD,wEAAsD;AACtD,8DAA4C;AAC5C,qEAAmD;AACnD,wEAAsD;AACtD,uEAAqD;AACrD,+DAA6C;AAC7C,wEAAsD;AACtD,kDAAgC;AAChC,6DAA2C;AAC3C,oEAAkD;AAClD,qEAAmD;AACnD,4DAA0C;AAC1C,0DAAwC;AACxC,wDAAsC;AACtC,+DAA6C;AAC7C,6DAA2C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,qDAAmC;AACnC,+CAA6B;AAC7B,qDAAmC;AACnC,gDAA8B;AAC9B,oDAAkC;AAClC,qDAAmC;AACnC,oDAAkC;AAClC,qDAAmC;AACnC,4DAA0C;AAC1C,gEAA8C;AAC9C,+DAA6C;AAC7C,4DAA0C;AAC1C,mEAAiD;AACjD,sEAAoD;AACpD,qEAAmD;AACnD,mEAAiD;AACjD,sEAAoD;AACpD,oDAAkC;AAClC,mEAAiD;AACjD,wDAAsC;AACtC,iFAA+D;AAC/D,kFAAgE;AAChE,kFAAgE;AAChE,2EAAyD;AACzD,wEAAsD;AACtD,8DAA4C;AAC5C,uEAAqD;AACrD,qEAAmD;AACnD,wEAAsD;AACtD,uEAAqD;AACrD,+DAA6C;AAC7C,wEAAsD;AACtD,kDAAgC;AAChC,6DAA2C;AAC3C,oEAAkD;AAClD,qEAAmD;AACnD,4DAA0C;AAC1C,0DAAwC;AACxC,wDAAsC;AACtC,+DAA6C;AAC7C,6DAA2C"}
@@ -1,6 +1,6 @@
1
- import { ISerializableAsync, ISerialized } from "@js-soft/ts-serval";
1
+ import { ISerializable, ISerialized } from "@js-soft/ts-serval";
2
2
  import { CoreBuffer, IClearable, ICoreBuffer } from "../CoreBuffer";
3
- import { CryptoSerializableAsync } from "../CryptoSerializableAsync";
3
+ import { CryptoSerializable } from "../CryptoSerializable";
4
4
  import { CryptoExchangePublicKey, ICryptoExchangePublicKey, ICryptoExchangePublicKeySerialized } from "../exchange/CryptoExchangePublicKey";
5
5
  import { CryptoSignaturePublicKey, ICryptoSignaturePublicKey, ICryptoSignaturePublicKeySerialized } from "../signature/CryptoSignaturePublicKey";
6
6
  export interface ICryptoRelationshipPublicRequestSerialized extends ISerialized {
@@ -10,24 +10,23 @@ export interface ICryptoRelationshipPublicRequestSerialized extends ISerialized
10
10
  eph: ICryptoExchangePublicKeySerialized;
11
11
  nnc: string;
12
12
  }
13
- export interface ICryptoRelationshipPublicRequest extends ISerializableAsync {
13
+ export interface ICryptoRelationshipPublicRequest extends ISerializable {
14
14
  id?: string;
15
15
  exchangeKey: ICryptoExchangePublicKey;
16
16
  signatureKey: ICryptoSignaturePublicKey;
17
17
  ephemeralKey: ICryptoExchangePublicKey;
18
18
  nonce: ICoreBuffer;
19
19
  }
20
- export declare class CryptoRelationshipPublicRequest extends CryptoSerializableAsync implements ICryptoRelationshipPublicRequest, IClearable {
20
+ export declare class CryptoRelationshipPublicRequest extends CryptoSerializable implements ICryptoRelationshipPublicRequest, IClearable {
21
21
  id?: string;
22
22
  signatureKey: CryptoSignaturePublicKey;
23
23
  exchangeKey: CryptoExchangePublicKey;
24
24
  ephemeralKey: CryptoExchangePublicKey;
25
25
  nonce: CoreBuffer;
26
- constructor(signatureKey: CryptoSignaturePublicKey, exchangeKey: CryptoExchangePublicKey, ephemeralKey: CryptoExchangePublicKey, nonce: CoreBuffer);
27
26
  toJSON(verbose?: boolean): ICryptoRelationshipPublicRequestSerialized;
28
27
  clear(): void;
29
- static from(value: CryptoRelationshipPublicRequest | ICryptoRelationshipPublicRequest): Promise<CryptoRelationshipPublicRequest>;
30
- static fromJSON(value: ICryptoRelationshipPublicRequestSerialized): Promise<CryptoRelationshipPublicRequest>;
31
- static fromBase64(value: string): Promise<CryptoRelationshipPublicRequest>;
32
- static deserialize(value: string): Promise<CryptoRelationshipPublicRequest>;
28
+ static from(value: CryptoRelationshipPublicRequest | ICryptoRelationshipPublicRequest): CryptoRelationshipPublicRequest;
29
+ protected static preFrom(value: any): any;
30
+ static fromJSON(value: ICryptoRelationshipPublicRequestSerialized): CryptoRelationshipPublicRequest;
31
+ static fromBase64(value: string): CryptoRelationshipPublicRequest;
33
32
  }
@@ -8,33 +8,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var CryptoRelationshipPublicRequest_1;
12
11
  Object.defineProperty(exports, "__esModule", { value: true });
13
12
  exports.CryptoRelationshipPublicRequest = void 0;
14
13
  const ts_serval_1 = require("@js-soft/ts-serval");
15
14
  const CoreBuffer_1 = require("../CoreBuffer");
16
- const CryptoSerializableAsync_1 = require("../CryptoSerializableAsync");
15
+ const CryptoSerializable_1 = require("../CryptoSerializable");
17
16
  const CryptoExchangePublicKey_1 = require("../exchange/CryptoExchangePublicKey");
18
17
  const CryptoSignaturePublicKey_1 = require("../signature/CryptoSignaturePublicKey");
19
- let CryptoRelationshipPublicRequest = CryptoRelationshipPublicRequest_1 = class CryptoRelationshipPublicRequest extends CryptoSerializableAsync_1.CryptoSerializableAsync {
20
- constructor(signatureKey, exchangeKey, ephemeralKey, nonce) {
21
- super();
22
- this.signatureKey = signatureKey;
23
- this.exchangeKey = exchangeKey;
24
- this.ephemeralKey = ephemeralKey;
25
- this.nonce = nonce;
26
- }
18
+ let CryptoRelationshipPublicRequest = class CryptoRelationshipPublicRequest extends CryptoSerializable_1.CryptoSerializable {
27
19
  toJSON(verbose = true) {
28
- const obj = {
20
+ return {
29
21
  exc: this.exchangeKey.toJSON(false),
30
22
  sig: this.signatureKey.toJSON(false),
31
23
  eph: this.ephemeralKey.toJSON(false),
32
- nnc: this.nonce.toBase64URL()
24
+ nnc: this.nonce.toBase64URL(),
25
+ "@type": verbose ? "CryptoRelationshipPublicRequest" : undefined
33
26
  };
34
- if (verbose) {
35
- obj["@type"] = "CryptoRelationshipPublicRequest";
36
- }
37
- return obj;
38
27
  }
39
28
  clear() {
40
29
  this.exchangeKey.clear();
@@ -42,29 +31,25 @@ let CryptoRelationshipPublicRequest = CryptoRelationshipPublicRequest_1 = class
42
31
  this.ephemeralKey.clear();
43
32
  this.nonce.clear();
44
33
  }
45
- static async from(value) {
46
- const [signatureKey, exchangeKey, ephemeralKey, nonce] = await Promise.all([
47
- CryptoSignaturePublicKey_1.CryptoSignaturePublicKey.from(value.signatureKey),
48
- CryptoExchangePublicKey_1.CryptoExchangePublicKey.from(value.exchangeKey),
49
- CryptoExchangePublicKey_1.CryptoExchangePublicKey.from(value.ephemeralKey),
50
- CoreBuffer_1.CoreBuffer.from(value.nonce)
51
- ]);
52
- return new CryptoRelationshipPublicRequest_1(signatureKey, exchangeKey, ephemeralKey, nonce);
34
+ static from(value) {
35
+ return this.fromAny(value);
53
36
  }
54
- static async fromJSON(value) {
55
- const [signatureKey, exchangeKey, ephemeralKey, nonce] = await Promise.all([
56
- CryptoSignaturePublicKey_1.CryptoSignaturePublicKey.fromJSON(value.sig),
57
- CryptoExchangePublicKey_1.CryptoExchangePublicKey.fromJSON(value.exc),
58
- CryptoExchangePublicKey_1.CryptoExchangePublicKey.fromJSON(value.eph),
59
- CoreBuffer_1.CoreBuffer.fromBase64URL(value.nnc)
60
- ]);
61
- return new CryptoRelationshipPublicRequest_1(signatureKey, exchangeKey, ephemeralKey, nonce);
37
+ static preFrom(value) {
38
+ if (value.exc) {
39
+ value = {
40
+ exchangeKey: value.exc,
41
+ signatureKey: value.sig,
42
+ ephemeralKey: value.eph,
43
+ nonce: value.nnc
44
+ };
45
+ }
46
+ return value;
62
47
  }
63
- static async fromBase64(value) {
64
- return await this.deserialize(CoreBuffer_1.CoreBuffer.base64_utf8(value));
48
+ static fromJSON(value) {
49
+ return this.fromAny(value);
65
50
  }
66
- static async deserialize(value) {
67
- return await this.fromJSON(JSON.parse(value));
51
+ static fromBase64(value) {
52
+ return this.deserialize(CoreBuffer_1.CoreBuffer.base64_utf8(value));
68
53
  }
69
54
  };
70
55
  __decorate([
@@ -92,12 +77,8 @@ __decorate([
92
77
  (0, ts_serval_1.serialize)(),
93
78
  __metadata("design:type", CoreBuffer_1.CoreBuffer)
94
79
  ], CryptoRelationshipPublicRequest.prototype, "nonce", void 0);
95
- CryptoRelationshipPublicRequest = CryptoRelationshipPublicRequest_1 = __decorate([
96
- (0, ts_serval_1.type)("CryptoRelationshipPublicRequest"),
97
- __metadata("design:paramtypes", [CryptoSignaturePublicKey_1.CryptoSignaturePublicKey,
98
- CryptoExchangePublicKey_1.CryptoExchangePublicKey,
99
- CryptoExchangePublicKey_1.CryptoExchangePublicKey,
100
- CoreBuffer_1.CoreBuffer])
80
+ CryptoRelationshipPublicRequest = __decorate([
81
+ (0, ts_serval_1.type)("CryptoRelationshipPublicRequest")
101
82
  ], CryptoRelationshipPublicRequest);
102
83
  exports.CryptoRelationshipPublicRequest = CryptoRelationshipPublicRequest;
103
84
  //# sourceMappingURL=CryptoRelationshipPublicRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CryptoRelationshipPublicRequest.js","sourceRoot":"","sources":["../../src/relationship/CryptoRelationshipPublicRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kDAAgG;AAChG,8CAAoE;AACpE,wEAAqE;AACrE,iFAI6C;AAC7C,oFAI+C;AAmB/C,IAAa,+BAA+B,uCAA5C,MAAa,+BACT,SAAQ,iDAAuB;IAuB/B,YACI,YAAsC,EACtC,WAAoC,EACpC,YAAqC,EACrC,KAAiB;QAEjB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,OAAO,GAAG,IAAI;QAC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,uBAAU;GA5BZ,+BAA+B,CA0F3C;AA1FY,0EAA+B"}
1
+ {"version":3,"file":"CryptoRelationshipPublicRequest.js","sourceRoot":"","sources":["../../src/relationship/CryptoRelationshipPublicRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2F;AAC3F,8CAAoE;AACpE,8DAA2D;AAC3D,iFAI6C;AAC7C,oFAI+C;AAmB/C,IAAa,+BAA+B,GAA5C,MAAa,+BACT,SAAQ,uCAAkB;IAuBV,MAAM,CAAC,OAAO,GAAG,IAAI;QACjC,OAAO;YACH,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YACnC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;YACpC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;YACpC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YAC7B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,SAAS;SACnE,CAAC;IACN,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,IAAI,CACd,KAAyE;QAEzE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAES,MAAM,CAAU,OAAO,CAAC,KAAU;QACxC,IAAI,KAAK,CAAC,GAAG,EAAE;YACX,KAAK,GAAG;gBACJ,WAAW,EAAE,KAAK,CAAC,GAAG;gBACtB,YAAY,EAAE,KAAK,CAAC,GAAG;gBACvB,YAAY,EAAE,KAAK,CAAC,GAAG;gBACvB,KAAK,EAAE,KAAK,CAAC,GAAG;aACnB,CAAC;SACL;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,KAAiD;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,WAAW,CAAC,uBAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ,CAAA;AA7DG;IAFC,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,IAAA,qBAAS,GAAE;;2DACO;AAInB;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACS,mDAAwB;qEAAC;AAI9C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACQ,iDAAuB;oEAAC;AAI5C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACS,iDAAuB;qEAAC;AAI7C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACE,uBAAU;8DAAC;AAtBhB,+BAA+B;IAD3C,IAAA,gBAAI,EAAC,iCAAiC,CAAC;GAC3B,+BAA+B,CAmE3C;AAnEY,0EAA+B"}
@@ -1,6 +1,6 @@
1
- import { ISerializableAsync, ISerialized } from "@js-soft/ts-serval";
1
+ import { ISerializable, ISerialized } from "@js-soft/ts-serval";
2
2
  import { CoreBuffer, IClearable } from "../CoreBuffer";
3
- import { CryptoSerializableAsync } from "../CryptoSerializableAsync";
3
+ import { CryptoSerializable } from "../CryptoSerializable";
4
4
  import { CryptoExchangePublicKey, ICryptoExchangePublicKey, ICryptoExchangePublicKeySerialized } from "../exchange/CryptoExchangePublicKey";
5
5
  import { CryptoSignature } from "../signature/CryptoSignature";
6
6
  import { CryptoSignaturePublicKey, ICryptoSignaturePublicKey, ICryptoSignaturePublicKeySerialized } from "../signature/CryptoSignaturePublicKey";
@@ -11,23 +11,22 @@ export interface ICryptoRelationshipPublicResponseSerialized extends ISerialized
11
11
  sig: ICryptoSignaturePublicKeySerialized;
12
12
  sta: ICryptoPublicStateSerialized;
13
13
  }
14
- export interface ICryptoRelationshipPublicResponse extends ISerializableAsync {
14
+ export interface ICryptoRelationshipPublicResponse extends ISerializable {
15
15
  id?: string;
16
16
  exchangeKey: ICryptoExchangePublicKey;
17
17
  signatureKey: ICryptoSignaturePublicKey;
18
18
  state: ICryptoPublicState;
19
19
  }
20
- export declare class CryptoRelationshipPublicResponse extends CryptoSerializableAsync implements ICryptoRelationshipPublicResponse, IClearable {
20
+ export declare class CryptoRelationshipPublicResponse extends CryptoSerializable implements ICryptoRelationshipPublicResponse, IClearable {
21
21
  id?: string;
22
22
  signatureKey: CryptoSignaturePublicKey;
23
23
  exchangeKey: CryptoExchangePublicKey;
24
24
  state: CryptoPublicState;
25
- constructor(signatureKey: CryptoSignaturePublicKey, exchangeKey: CryptoExchangePublicKey, state: CryptoPublicState);
26
25
  toJSON(verbose?: boolean): ICryptoRelationshipPublicResponseSerialized;
27
26
  clear(): void;
28
27
  verify(content: CoreBuffer, signature: CryptoSignature): Promise<boolean>;
29
- static from(value: CryptoRelationshipPublicResponse | ICryptoRelationshipPublicResponse): Promise<CryptoRelationshipPublicResponse>;
30
- static fromJSON(value: ICryptoRelationshipPublicResponseSerialized): Promise<CryptoRelationshipPublicResponse>;
31
- static fromBase64(value: string): Promise<CryptoRelationshipPublicResponse>;
32
- static deserialize(value: string): Promise<CryptoRelationshipPublicResponse>;
28
+ static from(value: CryptoRelationshipPublicResponse | ICryptoRelationshipPublicResponse): CryptoRelationshipPublicResponse;
29
+ protected static preFrom(value: any): any;
30
+ static fromJSON(value: ICryptoRelationshipPublicResponseSerialized): CryptoRelationshipPublicResponse;
31
+ static fromBase64(value: string): CryptoRelationshipPublicResponse;
33
32
  }
@@ -8,33 +8,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var CryptoRelationshipPublicResponse_1;
12
11
  Object.defineProperty(exports, "__esModule", { value: true });
13
12
  exports.CryptoRelationshipPublicResponse = void 0;
14
13
  const ts_serval_1 = require("@js-soft/ts-serval");
15
14
  const CoreBuffer_1 = require("../CoreBuffer");
16
- const CryptoSerializableAsync_1 = require("../CryptoSerializableAsync");
15
+ const CryptoSerializable_1 = require("../CryptoSerializable");
17
16
  const CryptoExchangePublicKey_1 = require("../exchange/CryptoExchangePublicKey");
18
17
  const CryptoSignaturePublicKey_1 = require("../signature/CryptoSignaturePublicKey");
19
18
  const CryptoSignatures_1 = require("../signature/CryptoSignatures");
20
19
  const CryptoPublicState_1 = require("../state/CryptoPublicState");
21
- let CryptoRelationshipPublicResponse = CryptoRelationshipPublicResponse_1 = class CryptoRelationshipPublicResponse extends CryptoSerializableAsync_1.CryptoSerializableAsync {
22
- constructor(signatureKey, exchangeKey, state) {
23
- super();
24
- this.signatureKey = signatureKey;
25
- this.exchangeKey = exchangeKey;
26
- this.state = state;
27
- }
20
+ let CryptoRelationshipPublicResponse = class CryptoRelationshipPublicResponse extends CryptoSerializable_1.CryptoSerializable {
28
21
  toJSON(verbose = true) {
29
- const obj = {
22
+ return {
30
23
  exc: this.exchangeKey.toJSON(false),
31
24
  sig: this.signatureKey.toJSON(false),
32
- sta: this.state.toJSON(false)
25
+ sta: this.state.toJSON(false),
26
+ id: this.id,
27
+ "@type": verbose ? "CryptoRelationshipPublicResponse" : undefined
33
28
  };
34
- if (verbose) {
35
- obj["@type"] = "CryptoRelationshipPublicResponse";
36
- }
37
- return obj;
38
29
  }
39
30
  clear() {
40
31
  this.exchangeKey.clear();
@@ -44,27 +35,25 @@ let CryptoRelationshipPublicResponse = CryptoRelationshipPublicResponse_1 = clas
44
35
  async verify(content, signature) {
45
36
  return await CryptoSignatures_1.CryptoSignatures.verify(content, signature, this.signatureKey);
46
37
  }
47
- static async from(value) {
48
- const [signatureKey, exchangeKey, state] = await Promise.all([
49
- CryptoSignaturePublicKey_1.CryptoSignaturePublicKey.from(value.signatureKey),
50
- CryptoExchangePublicKey_1.CryptoExchangePublicKey.from(value.exchangeKey),
51
- CryptoPublicState_1.CryptoPublicState.from(value.state)
52
- ]);
53
- return new CryptoRelationshipPublicResponse_1(signatureKey, exchangeKey, state);
38
+ static from(value) {
39
+ return this.fromAny(value);
54
40
  }
55
- static async fromJSON(value) {
56
- const [signatureKey, exchangeKey, state] = await Promise.all([
57
- CryptoSignaturePublicKey_1.CryptoSignaturePublicKey.fromJSON(value.sig),
58
- CryptoExchangePublicKey_1.CryptoExchangePublicKey.fromJSON(value.exc),
59
- CryptoPublicState_1.CryptoPublicState.fromJSON(value.sta)
60
- ]);
61
- return new CryptoRelationshipPublicResponse_1(signatureKey, exchangeKey, state);
41
+ static preFrom(value) {
42
+ if (value.exc) {
43
+ value = {
44
+ exchangeKey: value.exc,
45
+ signatureKey: value.sig,
46
+ state: value.sta,
47
+ id: value.id
48
+ };
49
+ }
50
+ return value;
62
51
  }
63
- static async fromBase64(value) {
64
- return await this.deserialize(CoreBuffer_1.CoreBuffer.base64_utf8(value));
52
+ static fromJSON(value) {
53
+ return this.fromAny(value);
65
54
  }
66
- static async deserialize(value) {
67
- return await this.fromJSON(JSON.parse(value));
55
+ static fromBase64(value) {
56
+ return this.deserialize(CoreBuffer_1.CoreBuffer.base64_utf8(value));
68
57
  }
69
58
  };
70
59
  __decorate([
@@ -87,11 +76,8 @@ __decorate([
87
76
  (0, ts_serval_1.serialize)(),
88
77
  __metadata("design:type", CryptoPublicState_1.CryptoPublicState)
89
78
  ], CryptoRelationshipPublicResponse.prototype, "state", void 0);
90
- CryptoRelationshipPublicResponse = CryptoRelationshipPublicResponse_1 = __decorate([
91
- (0, ts_serval_1.type)("CryptoRelationshipPublicResponse"),
92
- __metadata("design:paramtypes", [CryptoSignaturePublicKey_1.CryptoSignaturePublicKey,
93
- CryptoExchangePublicKey_1.CryptoExchangePublicKey,
94
- CryptoPublicState_1.CryptoPublicState])
79
+ CryptoRelationshipPublicResponse = __decorate([
80
+ (0, ts_serval_1.type)("CryptoRelationshipPublicResponse")
95
81
  ], CryptoRelationshipPublicResponse);
96
82
  exports.CryptoRelationshipPublicResponse = CryptoRelationshipPublicResponse;
97
83
  //# sourceMappingURL=CryptoRelationshipPublicResponse.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CryptoRelationshipPublicResponse.js","sourceRoot":"","sources":["../../src/relationship/CryptoRelationshipPublicResponse.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kDAAgG;AAChG,8CAAuD;AACvD,wEAAqE;AACrE,iFAI6C;AAE7C,oFAI+C;AAC/C,oEAAiE;AACjE,kEAAiH;AAiBjH,IAAa,gCAAgC,wCAA7C,MAAa,gCACT,SAAQ,iDAAuB;IAmB/B,YACI,YAAsC,EACtC,WAAoC,EACpC,KAAwB;QAExB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,OAAO,GAAG,IAAI;QACxB,MAAM,GAAG,GAAgD;YACrD,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YACnC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;YACpC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;SAChC,CAAC;QACF,IAAI,OAAO,EAAE;YACT,GAAG,CAAC,OAAO,CAAC,GAAG,kCAAkC,CAAC;SACrD;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAEM,KAAK;QACR,IAAI,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C,uBAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACjE,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAa;QACzC,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC;CACJ,CAAA;AA9EG;IAFC,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,IAAA,qBAAS,GAAE;;4DACO;AAInB;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACS,mDAAwB;sEAAC;AAI9C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACQ,iDAAuB;qEAAC;AAI5C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACE,qCAAiB;+DAAC;AAlBvB,gCAAgC;IAD5C,IAAA,gBAAI,EAAC,kCAAkC,CAAC;qCAsBnB,mDAAwB;QACzB,iDAAuB;QAC7B,qCAAiB;GAvBnB,gCAAgC,CAoF5C;AApFY,4EAAgC"}
1
+ {"version":3,"file":"CryptoRelationshipPublicResponse.js","sourceRoot":"","sources":["../../src/relationship/CryptoRelationshipPublicResponse.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2F;AAC3F,8CAAuD;AACvD,8DAA2D;AAC3D,iFAI6C;AAE7C,oFAI+C;AAC/C,oEAAiE;AACjE,kEAAiH;AAiBjH,IAAa,gCAAgC,GAA7C,MAAa,gCACT,SAAQ,uCAAkB;IAmBV,MAAM,CAAC,OAAO,GAAG,IAAI;QACjC,OAAO;YACH,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;YACnC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC;YACpC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,K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AFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACS,mDAAwB;sEAAC;AAI9C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACQ,iDAAuB;qEAAC;AAI5C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACE,qCAAiB;+DAAC;AAlBvB,gCAAgC;IAD5C,IAAA,gBAAI,EAAC,kCAAkC,CAAC;GAC5B,gCAAgC,CAkE5C;AAlEY,4EAAgC"}
@@ -1,6 +1,6 @@
1
- import { ISerializableAsync } from "@js-soft/ts-serval";
1
+ import { ISerializable } from "@js-soft/ts-serval";
2
2
  import { CoreBuffer, ICoreBuffer } from "../CoreBuffer";
3
- import { CryptoSerializableAsync } from "../CryptoSerializableAsync";
3
+ import { CryptoSerializable } from "../CryptoSerializable";
4
4
  import { CryptoCipher } from "../encryption/CryptoCipher";
5
5
  import { CryptoSecretKey, ICryptoSecretKey } from "../encryption/CryptoSecretKey";
6
6
  import { CryptoExchangeKeypair, ICryptoExchangeKeypair } from "../exchange/CryptoExchangeKeypair";
@@ -10,7 +10,7 @@ import { CryptoSignature } from "../signature/CryptoSignature";
10
10
  import { CryptoSignatureKeypair, ICryptoSignatureKeypair } from "../signature/CryptoSignatureKeypair";
11
11
  import { CryptoSignaturePublicKey, ICryptoSignaturePublicKey } from "../signature/CryptoSignaturePublicKey";
12
12
  import { CryptoRelationshipPublicRequest } from "./CryptoRelationshipPublicRequest";
13
- export interface ICryptoRelationshipRequestSecrets extends ISerializableAsync {
13
+ export interface ICryptoRelationshipRequestSecrets extends ISerializable {
14
14
  id?: string;
15
15
  exchangeKeypair: ICryptoExchangeKeypair;
16
16
  signatureKeypair: ICryptoSignatureKeypair;
@@ -20,7 +20,7 @@ export interface ICryptoRelationshipRequestSecrets extends ISerializableAsync {
20
20
  secretKey: ICryptoSecretKey;
21
21
  nonce: ICoreBuffer;
22
22
  }
23
- export declare class CryptoRelationshipRequestSecrets extends CryptoSerializableAsync implements ICryptoRelationshipRequestSecrets {
23
+ export declare class CryptoRelationshipRequestSecrets extends CryptoSerializable implements ICryptoRelationshipRequestSecrets {
24
24
  id?: string;
25
25
  exchangeKeypair: CryptoExchangeKeypair;
26
26
  ephemeralKeypair: CryptoExchangeKeypair;
@@ -29,13 +29,12 @@ export declare class CryptoRelationshipRequestSecrets extends CryptoSerializable
29
29
  peerExchangeKey: CryptoExchangePublicKey;
30
30
  secretKey: CryptoSecretKey;
31
31
  nonce: CoreBuffer;
32
- static from(value: ICryptoRelationshipRequestSecrets): Promise<CryptoRelationshipRequestSecrets>;
33
- static deserialize(value: string): Promise<CryptoRelationshipRequestSecrets>;
32
+ static from(value: ICryptoRelationshipRequestSecrets): CryptoRelationshipRequestSecrets;
34
33
  sign(content: CoreBuffer, algorithm?: CryptoHashAlgorithm): Promise<CryptoSignature>;
35
34
  verifyOwn(content: CoreBuffer, signature: CryptoSignature): Promise<boolean>;
36
35
  verifyPeerIdentity(content: CoreBuffer, signature: CryptoSignature): Promise<boolean>;
37
36
  encryptRequest(content: CoreBuffer): Promise<CryptoCipher>;
38
37
  decryptRequest(cipher: CryptoCipher): Promise<CoreBuffer>;
39
- toPublicRequest(): Promise<CryptoRelationshipPublicRequest>;
38
+ toPublicRequest(): CryptoRelationshipPublicRequest;
40
39
  static fromPeer(peerExchangeKey: CryptoExchangePublicKey, peerIdentityKey: CryptoSignaturePublicKey): Promise<CryptoRelationshipRequestSecrets>;
41
40
  }
@@ -14,7 +14,7 @@ exports.CryptoRelationshipRequestSecrets = void 0;
14
14
  const ts_serval_1 = require("@js-soft/ts-serval");
15
15
  const CoreBuffer_1 = require("../CoreBuffer");
16
16
  const CryptoDerivation_1 = require("../CryptoDerivation");
17
- const CryptoSerializableAsync_1 = require("../CryptoSerializableAsync");
17
+ const CryptoSerializable_1 = require("../CryptoSerializable");
18
18
  const CryptoEncryption_1 = require("../encryption/CryptoEncryption");
19
19
  const CryptoSecretKey_1 = require("../encryption/CryptoSecretKey");
20
20
  const CryptoExchange_1 = require("../exchange/CryptoExchange");
@@ -25,12 +25,9 @@ const CryptoSignatureKeypair_1 = require("../signature/CryptoSignatureKeypair");
25
25
  const CryptoSignaturePublicKey_1 = require("../signature/CryptoSignaturePublicKey");
26
26
  const CryptoSignatures_1 = require("../signature/CryptoSignatures");
27
27
  const CryptoRelationshipPublicRequest_1 = require("./CryptoRelationshipPublicRequest");
28
- let CryptoRelationshipRequestSecrets = CryptoRelationshipRequestSecrets_1 = class CryptoRelationshipRequestSecrets extends CryptoSerializableAsync_1.CryptoSerializableAsync {
29
- static async from(value) {
30
- return (await super.from(value, CryptoRelationshipRequestSecrets_1));
31
- }
32
- static async deserialize(value) {
33
- return (await super.deserialize(value, CryptoRelationshipRequestSecrets_1));
28
+ let CryptoRelationshipRequestSecrets = CryptoRelationshipRequestSecrets_1 = class CryptoRelationshipRequestSecrets extends CryptoSerializable_1.CryptoSerializable {
29
+ static from(value) {
30
+ return this.fromAny(value);
34
31
  }
35
32
  async sign(content, algorithm = 1 /* SHA256 */) {
36
33
  return await CryptoSignatures_1.CryptoSignatures.sign(content, this.signatureKeypair.privateKey, algorithm);
@@ -47,8 +44,8 @@ let CryptoRelationshipRequestSecrets = CryptoRelationshipRequestSecrets_1 = clas
47
44
  async decryptRequest(cipher) {
48
45
  return await CryptoEncryption_1.CryptoEncryption.decrypt(cipher, this.secretKey);
49
46
  }
50
- async toPublicRequest() {
51
- return await CryptoRelationshipPublicRequest_1.CryptoRelationshipPublicRequest.from({
47
+ toPublicRequest() {
48
+ return CryptoRelationshipPublicRequest_1.CryptoRelationshipPublicRequest.from({
52
49
  id: this.id,
53
50
  exchangeKey: this.exchangeKeypair.publicKey,
54
51
  signatureKey: this.signatureKeypair.publicKey,
@@ -65,7 +62,7 @@ let CryptoRelationshipRequestSecrets = CryptoRelationshipRequestSecrets_1 = clas
65
62
  ]);
66
63
  const masterKey = await CryptoExchange_1.CryptoExchange.deriveRequestor(ephemeralKeypair, peerExchangeKey);
67
64
  const secretKey = await CryptoDerivation_1.CryptoDerivation.deriveKeyFromBase(masterKey.transmissionKey, 1, "REQTMP01");
68
- return await CryptoRelationshipRequestSecrets_1.from({
65
+ return CryptoRelationshipRequestSecrets_1.from({
69
66
  exchangeKeypair: exchangeKeypair,
70
67
  ephemeralKeypair: ephemeralKeypair,
71
68
  signatureKeypair: signatureKeypair,
@@ -1 +1 @@
1
- {"version":3,"file":"CryptoRelationshipRequestSecrets.js","sourceRoot":"","sources":["../../src/relationship/CryptoRelationshipRequestSecrets.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kDAAmF;AACnF,8CAAwD;AACxD,0DAAuD;AACvD,wEAAqE;AAErE,qEAAkE;AAClE,mEAAkF;AAClF,+DAA4D;AAC5D,6EAAkG;AAClG,iFAAwG;AAExG,yDAAsD;AAEtD,gFAAsG;AACtG,oFAA4G;AAC5G,oEAAiE;AACjE,uFAAoF;AAcpF,IAAa,gCAAgC,wCAA7C,MAAa,gCACT,SAAQ,iDAAuB;IAmCxB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAwC;QAC7D,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,kCAAgC,CAAC,CAAqC,CAAC;IAC3G,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAa;QACzC,OAAO,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,kCAAgC,CAAC,CAAqC,CAAC;IAClH,CAAC;IAEM,KAAK,CAAC,IAAI,CACb,OAAmB,EACnB,0BAA2D;QAE3D,OAAO,MAAM,mCAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC7F,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,OAAmB,EAAE,SAA0B;QAClE,OAAO,MAAM,mCAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS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qBAAS,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;8BACd,uBAAU;+DAAC;AAlChB,gCAAgC;IAD5C,IAAA,gBAAI,EAAC,kCAAkC,CAAC;GAC5B,gCAAgC,CAqG5C;AArGY,4EAAgC"}
1
+ {"version":3,"file":"CryptoRelationshipRequestSecrets.js","sourceRoot":"","sources":["../../src/relationship/CryptoRelationshipRequestSecrets.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kDAA8E;AAC9E,8CAAwD;AACxD,0DAAuD;AACvD,8DAA2D;AAE3D,qEAAkE;AAClE,mEAAkF;AAClF,+DAA4D;AAC5D,6EAAkG;AAClG,iFAAwG;AAExG,yDAAsD;AAEtD,gFAAsG;AACtG,oFAA4G;AAC5G,oEAAiE;AACjE,uFAAoF;AAcpF,IAAa,gCAAgC,wCAA7C,MAAa,gCAAiC,SAAQ,uCAAkB;IAiC7D,MAAM,CAAC,IAAI,CAAC,KAAwC;QACvD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,IAAI,CACb,OAAmB,EACnB,0BAA2D;QAE3D,OAAO,MAAM,mCAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC7F,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,OAAmB,EAAE,SAA0B;QAClE,OAAO,MAAM,mCAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAC9F,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,OAAmB,EAAE,SAA0B;QAC3E,OAAO,MAAM,mCAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IACnF,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,OAAmB;QAC3C,OAAO,M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AAS,EAAE,SAAS;YACpB,KAAK,EAAE,KAAK;SACf,CAAC,CAAC;IACP,CAAC;CACJ,CAAA;AA3FG;IAFC,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,IAAA,qBAAS,GAAE;;4DACO;AAInB;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;8BACJ,6CAAqB;yEAAC;AAI9C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;8BACH,6CAAqB;0EAAC;AAI/C;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;8BACH,+CAAsB;0EAAC;AAIhD;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;8BACJ,mDAAwB;yEAAC;AAIjD;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;8BACJ,iDAAuB;yEAAC;AAIhD;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;8BACV,iCAAe;mEAAC;AAIlC;IAFC,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,EAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;8BACd,uBAAU;+DAAC;AA/BhB,gCAAgC;IAD5C,IAAA,gBAAI,EAAC,kCAAkC,CAAC;GAC5B,gCAAgC,CA8F5C;AA9FY,4EAAgC"}
@@ -1,6 +1,6 @@
1
- import { ISerializableAsync } from "@js-soft/ts-serval";
1
+ import { ISerializable } from "@js-soft/ts-serval";
2
2
  import { CoreBuffer } from "../CoreBuffer";
3
- import { CryptoSerializableAsync } from "../CryptoSerializableAsync";
3
+ import { CryptoSerializable } from "../CryptoSerializable";
4
4
  import { CryptoCipher } from "../encryption/CryptoCipher";
5
5
  import { CryptoSecretKey, ICryptoSecretKey } from "../encryption/CryptoSecretKey";
6
6
  import { CryptoExchangeKeypair, ICryptoExchangeKeypair } from "../exchange/CryptoExchangeKeypair";
@@ -16,7 +16,7 @@ import { CryptoRelationshipPublicRequest } from "./CryptoRelationshipPublicReque
16
16
  import { CryptoRelationshipPublicResponse } from "./CryptoRelationshipPublicResponse";
17
17
  import { CryptoRelationshipRequestSecrets } from "./CryptoRelationshipRequestSecrets";
18
18
  import { CryptoRelationshipType } from "./CryptoRelationshipType";
19
- export interface ICryptoRelationshipSecrets extends ISerializableAsync {
19
+ export interface ICryptoRelationshipSecrets extends ISerializable {
20
20
  id?: string;
21
21
  type: CryptoRelationshipType;
22
22
  exchangeKeypair: ICryptoExchangeKeypair;
@@ -29,7 +29,7 @@ export interface ICryptoRelationshipSecrets extends ISerializableAsync {
29
29
  peerIdentityKey?: ICryptoSignaturePublicKey;
30
30
  requestSecretKey: ICryptoSecretKey;
31
31
  }
32
- export declare class CryptoRelationshipSecrets extends CryptoSerializableAsync implements ICryptoRelationshipSecrets {
32
+ export declare class CryptoRelationshipSecrets extends CryptoSerializable implements ICryptoRelationshipSecrets {
33
33
  id?: string;
34
34
  type: CryptoRelationshipType;
35
35
  exchangeKeypair: CryptoExchangeKeypair;
@@ -41,8 +41,7 @@ export declare class CryptoRelationshipSecrets extends CryptoSerializableAsync i
41
41
  peerTemplateKey: CryptoExchangePublicKey;
42
42
  peerIdentityKey?: CryptoSignaturePublicKey;
43
43
  requestSecretKey: CryptoSecretKey;
44
- static from(value: ICryptoRelationshipSecrets): Promise<CryptoRelationshipSecrets>;
45
- static deserialize(value: string): Promise<CryptoRelationshipSecrets>;
44
+ static from(value: ICryptoRelationshipSecrets): CryptoRelationshipSecrets;
46
45
  sign(content: CoreBuffer, algorithm?: CryptoHashAlgorithm): Promise<CryptoSignature>;
47
46
  verifyOwn(content: CoreBuffer, signature: CryptoSignature): Promise<boolean>;
48
47
  verifyPeer(content: CoreBuffer, signature: CryptoSignature): Promise<boolean>;
@@ -51,7 +50,7 @@ export declare class CryptoRelationshipSecrets extends CryptoSerializableAsync i
51
50
  decryptOwn(cipher: CryptoCipher): Promise<CoreBuffer>;
52
51
  decryptPeer(cipher: CryptoCipher, omitCounterCheck?: boolean): Promise<CoreBuffer>;
53
52
  decryptRequest(cipher: CryptoCipher): Promise<CoreBuffer>;
54
- toPublicResponse(): Promise<CryptoRelationshipPublicResponse>;
53
+ toPublicResponse(): CryptoRelationshipPublicResponse;
55
54
  static fromRelationshipResponse(response: CryptoRelationshipPublicResponse, request: CryptoRelationshipRequestSecrets): Promise<CryptoRelationshipSecrets>;
56
55
  static fromRelationshipRequest(request: CryptoRelationshipPublicRequest, templateExchangeKeypair: CryptoExchangeKeypair): Promise<CryptoRelationshipSecrets>;
57
56
  static fromPeerNonce(peerExchangeKey: CryptoExchangePublicKey, peerTemplateKey: CryptoExchangePublicKey, peerSignatureKey: CryptoSignaturePublicKey, peerGeneratedNonce: CoreBuffer, templateExchangeKeypair: CryptoExchangeKeypair, peerIdentityKey?: CryptoSignaturePublicKey, peerType?: CryptoRelationshipType): Promise<CryptoRelationshipSecrets>;