@tideorg/js 0.13.19

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 (234) hide show
  1. package/LICENSE +333 -0
  2. package/README.md +12 -0
  3. package/dist/Clients/ClientBase.d.ts +24 -0
  4. package/dist/Clients/ClientBase.d.ts.map +1 -0
  5. package/dist/Clients/ClientBase.js +160 -0
  6. package/dist/Clients/NetworkClient.d.ts +11 -0
  7. package/dist/Clients/NetworkClient.d.ts.map +1 -0
  8. package/dist/Clients/NetworkClient.js +68 -0
  9. package/dist/Clients/NodeClient.d.ts +34 -0
  10. package/dist/Clients/NodeClient.d.ts.map +1 -0
  11. package/dist/Clients/NodeClient.js +191 -0
  12. package/dist/Clients/VoucherClient.d.ts +8 -0
  13. package/dist/Clients/VoucherClient.d.ts.map +1 -0
  14. package/dist/Clients/VoucherClient.js +36 -0
  15. package/dist/Clients/index.d.ts +5 -0
  16. package/dist/Clients/index.d.ts.map +1 -0
  17. package/dist/Clients/index.js +20 -0
  18. package/dist/Contracts/BaseContract.d.ts +47 -0
  19. package/dist/Contracts/BaseContract.d.ts.map +1 -0
  20. package/dist/Contracts/BaseContract.js +153 -0
  21. package/dist/Contracts/GenericRealmAccessThresholdRoleContract.d.ts +8 -0
  22. package/dist/Contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +1 -0
  23. package/dist/Contracts/GenericRealmAccessThresholdRoleContract.js +21 -0
  24. package/dist/Contracts/GenericResourceAccessThresholdRoleContract.d.ts +8 -0
  25. package/dist/Contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +1 -0
  26. package/dist/Contracts/GenericResourceAccessThresholdRoleContract.js +21 -0
  27. package/dist/Contracts/index.d.ts +4 -0
  28. package/dist/Contracts/index.d.ts.map +1 -0
  29. package/dist/Contracts/index.js +19 -0
  30. package/dist/Cryptide/Components/BaseComponent.d.ts +56 -0
  31. package/dist/Cryptide/Components/BaseComponent.d.ts.map +1 -0
  32. package/dist/Cryptide/Components/BaseComponent.js +176 -0
  33. package/dist/Cryptide/Components/ComponentRegistry.d.ts +18 -0
  34. package/dist/Cryptide/Components/ComponentRegistry.d.ts.map +1 -0
  35. package/dist/Cryptide/Components/ComponentRegistry.js +39 -0
  36. package/dist/Cryptide/Components/Schemes/AES/AESScheme.d.ts +5 -0
  37. package/dist/Cryptide/Components/Schemes/AES/AESScheme.d.ts.map +1 -0
  38. package/dist/Cryptide/Components/Schemes/AES/AESScheme.js +20 -0
  39. package/dist/Cryptide/Components/Schemes/AES/index.d.ts +2 -0
  40. package/dist/Cryptide/Components/Schemes/AES/index.d.ts.map +1 -0
  41. package/dist/Cryptide/Components/Schemes/AES/index.js +17 -0
  42. package/dist/Cryptide/Components/Schemes/BaseScheme.d.ts +7 -0
  43. package/dist/Cryptide/Components/Schemes/BaseScheme.d.ts.map +1 -0
  44. package/dist/Cryptide/Components/Schemes/BaseScheme.js +23 -0
  45. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.d.ts +52 -0
  46. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.d.ts.map +1 -0
  47. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Components.js +171 -0
  48. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.d.ts +13 -0
  49. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.d.ts.map +1 -0
  50. package/dist/Cryptide/Components/Schemes/Ed25519/Ed25519Scheme.js +71 -0
  51. package/dist/Cryptide/Components/Schemes/Ed25519/index.d.ts +3 -0
  52. package/dist/Cryptide/Components/Schemes/Ed25519/index.d.ts.map +1 -0
  53. package/dist/Cryptide/Components/Schemes/Ed25519/index.js +18 -0
  54. package/dist/Cryptide/Components/Schemes/SchemeRegistry.d.ts +3 -0
  55. package/dist/Cryptide/Components/Schemes/SchemeRegistry.d.ts.map +1 -0
  56. package/dist/Cryptide/Components/Schemes/SchemeRegistry.js +22 -0
  57. package/dist/Cryptide/Components/Schemes/index.d.ts +5 -0
  58. package/dist/Cryptide/Components/Schemes/index.d.ts.map +1 -0
  59. package/dist/Cryptide/Components/Schemes/index.js +20 -0
  60. package/dist/Cryptide/Components/index.d.ts +4 -0
  61. package/dist/Cryptide/Components/index.d.ts.map +1 -0
  62. package/dist/Cryptide/Components/index.js +19 -0
  63. package/dist/Cryptide/Ed25519.d.ts +106 -0
  64. package/dist/Cryptide/Ed25519.d.ts.map +1 -0
  65. package/dist/Cryptide/Ed25519.js +522 -0
  66. package/dist/Cryptide/Encryption/AES.d.ts +6 -0
  67. package/dist/Cryptide/Encryption/AES.d.ts.map +1 -0
  68. package/dist/Cryptide/Encryption/AES.js +76 -0
  69. package/dist/Cryptide/Encryption/DH.d.ts +4 -0
  70. package/dist/Cryptide/Encryption/DH.d.ts.map +1 -0
  71. package/dist/Cryptide/Encryption/DH.js +38 -0
  72. package/dist/Cryptide/Encryption/ElGamal.d.ts +12 -0
  73. package/dist/Cryptide/Encryption/ElGamal.d.ts.map +1 -0
  74. package/dist/Cryptide/Encryption/ElGamal.js +61 -0
  75. package/dist/Cryptide/Encryption/index.d.ts +4 -0
  76. package/dist/Cryptide/Encryption/index.d.ts.map +1 -0
  77. package/dist/Cryptide/Encryption/index.js +19 -0
  78. package/dist/Cryptide/Hashing/H2P.d.ts +6 -0
  79. package/dist/Cryptide/Hashing/H2P.d.ts.map +1 -0
  80. package/dist/Cryptide/Hashing/H2P.js +235 -0
  81. package/dist/Cryptide/Hashing/Hash.d.ts +8 -0
  82. package/dist/Cryptide/Hashing/Hash.d.ts.map +1 -0
  83. package/dist/Cryptide/Hashing/Hash.js +43 -0
  84. package/dist/Cryptide/Hashing/index.d.ts +3 -0
  85. package/dist/Cryptide/Hashing/index.d.ts.map +1 -0
  86. package/dist/Cryptide/Hashing/index.js +18 -0
  87. package/dist/Cryptide/Interpolation.d.ts +20 -0
  88. package/dist/Cryptide/Interpolation.d.ts.map +1 -0
  89. package/dist/Cryptide/Interpolation.js +68 -0
  90. package/dist/Cryptide/Math.d.ts +11 -0
  91. package/dist/Cryptide/Math.d.ts.map +1 -0
  92. package/dist/Cryptide/Math.js +81 -0
  93. package/dist/Cryptide/Serialization.d.ts +66 -0
  94. package/dist/Cryptide/Serialization.d.ts.map +1 -0
  95. package/dist/Cryptide/Serialization.js +517 -0
  96. package/dist/Cryptide/Signing/BlindSig.d.ts +10 -0
  97. package/dist/Cryptide/Signing/BlindSig.d.ts.map +1 -0
  98. package/dist/Cryptide/Signing/BlindSig.js +41 -0
  99. package/dist/Cryptide/Signing/EdDSA.d.ts +14 -0
  100. package/dist/Cryptide/Signing/EdDSA.d.ts.map +1 -0
  101. package/dist/Cryptide/Signing/EdDSA.js +67 -0
  102. package/dist/Cryptide/Signing/TideSignature.d.ts +54 -0
  103. package/dist/Cryptide/Signing/TideSignature.d.ts.map +1 -0
  104. package/dist/Cryptide/Signing/TideSignature.js +110 -0
  105. package/dist/Cryptide/Signing/index.d.ts +4 -0
  106. package/dist/Cryptide/Signing/index.d.ts.map +1 -0
  107. package/dist/Cryptide/Signing/index.js +19 -0
  108. package/dist/Cryptide/TideKey.d.ts +17 -0
  109. package/dist/Cryptide/TideKey.d.ts.map +1 -0
  110. package/dist/Cryptide/TideKey.js +84 -0
  111. package/dist/Cryptide/TideMemoryObjects.d.ts +4 -0
  112. package/dist/Cryptide/TideMemoryObjects.d.ts.map +1 -0
  113. package/dist/Cryptide/TideMemoryObjects.js +32 -0
  114. package/dist/Cryptide/index.d.ts +11 -0
  115. package/dist/Cryptide/index.d.ts.map +1 -0
  116. package/dist/Cryptide/index.js +28 -0
  117. package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.d.ts +16 -0
  118. package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.d.ts.map +1 -0
  119. package/dist/Flow/DecryptionFlows/dVVKDecryptionFlow.js +47 -0
  120. package/dist/Flow/DecryptionFlows/index.d.ts +2 -0
  121. package/dist/Flow/DecryptionFlows/index.d.ts.map +1 -0
  122. package/dist/Flow/DecryptionFlows/index.js +17 -0
  123. package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.d.ts +13 -0
  124. package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.d.ts.map +1 -0
  125. package/dist/Flow/EncryptionFlows/AuthorizedEncryptionFlow.js +183 -0
  126. package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.d.ts +57 -0
  127. package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.d.ts.map +1 -0
  128. package/dist/Flow/EncryptionFlows/PolicyAuthorizedEncryptionFlow.js +220 -0
  129. package/dist/Flow/EncryptionFlows/index.d.ts +3 -0
  130. package/dist/Flow/EncryptionFlows/index.d.ts.map +1 -0
  131. package/dist/Flow/EncryptionFlows/index.js +18 -0
  132. package/dist/Flow/SigningFlows/AuthorizedSigningFlow.d.ts +12 -0
  133. package/dist/Flow/SigningFlows/AuthorizedSigningFlow.d.ts.map +1 -0
  134. package/dist/Flow/SigningFlows/AuthorizedSigningFlow.js +50 -0
  135. package/dist/Flow/SigningFlows/dTestVVkSigningFlow.d.ts +15 -0
  136. package/dist/Flow/SigningFlows/dTestVVkSigningFlow.d.ts.map +1 -0
  137. package/dist/Flow/SigningFlows/dTestVVkSigningFlow.js +67 -0
  138. package/dist/Flow/SigningFlows/dVVKSigningFlow.d.ts +17 -0
  139. package/dist/Flow/SigningFlows/dVVKSigningFlow.d.ts.map +1 -0
  140. package/dist/Flow/SigningFlows/dVVKSigningFlow.js +61 -0
  141. package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.d.ts +28 -0
  142. package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.d.ts.map +1 -0
  143. package/dist/Flow/SigningFlows/dVVKSigningFlow2Step.js +118 -0
  144. package/dist/Flow/SigningFlows/index.d.ts +5 -0
  145. package/dist/Flow/SigningFlows/index.d.ts.map +1 -0
  146. package/dist/Flow/SigningFlows/index.js +20 -0
  147. package/dist/Flow/VoucherFlows/VoucherFlow.d.ts +16 -0
  148. package/dist/Flow/VoucherFlows/VoucherFlow.d.ts.map +1 -0
  149. package/dist/Flow/VoucherFlows/VoucherFlow.js +34 -0
  150. package/dist/Flow/VoucherFlows/index.d.ts +2 -0
  151. package/dist/Flow/VoucherFlows/index.d.ts.map +1 -0
  152. package/dist/Flow/VoucherFlows/index.js +17 -0
  153. package/dist/Flow/index.d.ts +5 -0
  154. package/dist/Flow/index.d.ts.map +1 -0
  155. package/dist/Flow/index.js +20 -0
  156. package/dist/Math/KeyDecryption.d.ts +3 -0
  157. package/dist/Math/KeyDecryption.d.ts.map +1 -0
  158. package/dist/Math/KeyDecryption.js +24 -0
  159. package/dist/Math/KeySigning.d.ts +4 -0
  160. package/dist/Math/KeySigning.d.ts.map +1 -0
  161. package/dist/Math/KeySigning.js +28 -0
  162. package/dist/Math/index.d.ts +3 -0
  163. package/dist/Math/index.d.ts.map +1 -0
  164. package/dist/Math/index.js +18 -0
  165. package/dist/Models/AuthRequest.d.ts +13 -0
  166. package/dist/Models/AuthRequest.d.ts.map +1 -0
  167. package/dist/Models/AuthRequest.js +46 -0
  168. package/dist/Models/BaseTideRequest.d.ts +55 -0
  169. package/dist/Models/BaseTideRequest.d.ts.map +1 -0
  170. package/dist/Models/BaseTideRequest.js +299 -0
  171. package/dist/Models/CustomTideRequest.d.ts +19 -0
  172. package/dist/Models/CustomTideRequest.d.ts.map +1 -0
  173. package/dist/Models/CustomTideRequest.js +30 -0
  174. package/dist/Models/Datum.d.ts +11 -0
  175. package/dist/Models/Datum.d.ts.map +1 -0
  176. package/dist/Models/Datum.js +33 -0
  177. package/dist/Models/Doken.d.ts +33 -0
  178. package/dist/Models/Doken.d.ts.map +1 -0
  179. package/dist/Models/Doken.js +133 -0
  180. package/dist/Models/EnclaveEntry.d.ts +14 -0
  181. package/dist/Models/EnclaveEntry.d.ts.map +1 -0
  182. package/dist/Models/EnclaveEntry.js +49 -0
  183. package/dist/Models/Infos/KeyInfo.d.ts +24 -0
  184. package/dist/Models/Infos/KeyInfo.d.ts.map +1 -0
  185. package/dist/Models/Infos/KeyInfo.js +51 -0
  186. package/dist/Models/Infos/OrkInfo.d.ts +18 -0
  187. package/dist/Models/Infos/OrkInfo.d.ts.map +1 -0
  188. package/dist/Models/Infos/OrkInfo.js +58 -0
  189. package/dist/Models/Infos/index.d.ts +3 -0
  190. package/dist/Models/Infos/index.d.ts.map +1 -0
  191. package/dist/Models/Infos/index.js +18 -0
  192. package/dist/Models/ModelRegistry.d.ts +29 -0
  193. package/dist/Models/ModelRegistry.d.ts.map +1 -0
  194. package/dist/Models/ModelRegistry.js +321 -0
  195. package/dist/Models/Policy.d.ts +41 -0
  196. package/dist/Models/Policy.d.ts.map +1 -0
  197. package/dist/Models/Policy.js +317 -0
  198. package/dist/Models/PolicyProtectedSerializedField.d.ts +12 -0
  199. package/dist/Models/PolicyProtectedSerializedField.d.ts.map +1 -0
  200. package/dist/Models/PolicyProtectedSerializedField.js +50 -0
  201. package/dist/Models/Responses/Vendor/VoucherResponse.d.ts +12 -0
  202. package/dist/Models/Responses/Vendor/VoucherResponse.d.ts.map +1 -0
  203. package/dist/Models/Responses/Vendor/VoucherResponse.js +39 -0
  204. package/dist/Models/Responses/Vendor/index.d.ts +2 -0
  205. package/dist/Models/Responses/Vendor/index.d.ts.map +1 -0
  206. package/dist/Models/Responses/Vendor/index.js +17 -0
  207. package/dist/Models/Responses/index.d.ts +2 -0
  208. package/dist/Models/Responses/index.d.ts.map +1 -0
  209. package/dist/Models/Responses/index.js +17 -0
  210. package/dist/Models/SerializedField.d.ts +12 -0
  211. package/dist/Models/SerializedField.d.ts.map +1 -0
  212. package/dist/Models/SerializedField.js +50 -0
  213. package/dist/Models/VendorData.d.ts +12 -0
  214. package/dist/Models/VendorData.d.ts.map +1 -0
  215. package/dist/Models/VendorData.js +38 -0
  216. package/dist/Models/VendorSettings.d.ts +9 -0
  217. package/dist/Models/VendorSettings.d.ts.map +1 -0
  218. package/dist/Models/VendorSettings.js +32 -0
  219. package/dist/Models/index.d.ts +13 -0
  220. package/dist/Models/index.d.ts.map +1 -0
  221. package/dist/Models/index.js +30 -0
  222. package/dist/Tools/TideMemory.d.ts +10 -0
  223. package/dist/Tools/TideMemory.d.ts.map +1 -0
  224. package/dist/Tools/TideMemory.js +105 -0
  225. package/dist/Tools/Utils.d.ts +13 -0
  226. package/dist/Tools/Utils.d.ts.map +1 -0
  227. package/dist/Tools/Utils.js +242 -0
  228. package/dist/Tools/index.d.ts +3 -0
  229. package/dist/Tools/index.d.ts.map +1 -0
  230. package/dist/Tools/index.js +18 -0
  231. package/dist/index.d.ts +10 -0
  232. package/dist/index.d.ts.map +1 -0
  233. package/dist/index.js +26 -0
  234. package/package.json +27 -0
@@ -0,0 +1,51 @@
1
+ //
2
+ // Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
3
+ // Copyright (C) 2022 Tide Foundation Ltd
4
+ //
5
+ // This program is free software and is subject to the terms of
6
+ // the Tide Community Open Code License as published by the
7
+ // Tide Foundation Limited. You may modify it and redistribute
8
+ // it in accordance with and subject to the terms of that License.
9
+ // This program is distributed WITHOUT WARRANTY of any kind,
10
+ // including without any implied warranty of MERCHANTABILITY or
11
+ // FITNESS FOR A PARTICULAR PURPOSE.
12
+ // See the Tide Community Open Code License for more details.
13
+ // You should have received a copy of the Tide Community Open
14
+ // Code License along with this program.
15
+ // If not, see https://tide.org/licenses_tcoc2-0-0-en
16
+ //
17
+ import { Point } from "../../Cryptide/Ed25519";
18
+ import OrkInfo from "./OrkInfo";
19
+ export default class KeyInfo {
20
+ constructor(userId, userPublic, userM, orkInfo) {
21
+ this.UserId = userId;
22
+ this.UserPublic = userPublic;
23
+ this.UserM = userM;
24
+ this.OrkInfo = orkInfo;
25
+ }
26
+ toString() {
27
+ return JSON.stringify({
28
+ UserId: this.UserId,
29
+ UserPublic: this.UserPublic.toBase64(),
30
+ UserM: this.UserM,
31
+ OrkInfos: this.OrkInfo.map(info => info.toString())
32
+ });
33
+ }
34
+ toNativeTypeObject() {
35
+ return {
36
+ UserId: this.UserId,
37
+ UserPublic: this.UserPublic.toBase64(),
38
+ UserM: this.UserM,
39
+ OrkInfos: this.OrkInfo.map(info => info.toNativeTypeObject())
40
+ };
41
+ }
42
+ static from(data) {
43
+ const json = JSON.parse(data);
44
+ const pub = Point.fromBase64(json.UserPublic);
45
+ const orkInfo = json.OrkInfos.map(orkInfo => OrkInfo.from(orkInfo));
46
+ return new KeyInfo(json.UserId, pub, json.UserM, orkInfo);
47
+ }
48
+ static fromNativeTypeObject(json) {
49
+ return new KeyInfo(json.UserId, Point.fromBase64(json.UserPublic), json.UserM, json.OrkInfos.map(o => OrkInfo.fromNativeTypeObject(o)));
50
+ }
51
+ }
@@ -0,0 +1,18 @@
1
+ import { Point } from "../../Cryptide/Ed25519";
2
+ export default class OrkInfo {
3
+ orkID: string;
4
+ orkPublic: Point;
5
+ orkURL: string;
6
+ orkPaymentPublic: Point;
7
+ constructor(orkID: string, orkPublic: Point, orkURL: string, orkPaymentPublic: Point);
8
+ toString(): string;
9
+ toNativeTypeObject(): {
10
+ Id: string;
11
+ PublicKey: string;
12
+ URL: string;
13
+ PaymentPublicKey: string;
14
+ };
15
+ static fromNativeTypeObject(json: any): OrkInfo;
16
+ static from(json: any): OrkInfo;
17
+ }
18
+ //# sourceMappingURL=OrkInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrkInfo.d.ts","sourceRoot":"","sources":["../../../Models/Infos/OrkInfo.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAG/C,MAAM,CAAC,OAAO,OAAO,OAAO;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,KAAK,CAAC;gBAEZ,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK;IAOpF,QAAQ;IASR,kBAAkB;;;;;;IASlB,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,GAAG;IAIrC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG;CAMxB"}
@@ -0,0 +1,58 @@
1
+ //
2
+ // Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
3
+ // Copyright (C) 2022 Tide Foundation Ltd
4
+ //
5
+ // This program is free software and is subject to the terms of
6
+ // the Tide Community Open Code License as published by the
7
+ // Tide Foundation Limited. You may modify it and redistribute
8
+ // it in accordance with and subject to the terms of that License.
9
+ // This program is distributed WITHOUT WARRANTY of any kind,
10
+ // including without any implied warranty of MERCHANTABILITY or
11
+ // FITNESS FOR A PARTICULAR PURPOSE.
12
+ // See the Tide Community Open Code License for more details.
13
+ // You should have received a copy of the Tide Community Open
14
+ // Code License along with this program.
15
+ // If not, see https://tide.org/licenses_tcoc2-0-0-en
16
+ //
17
+ import { Point } from "../../Cryptide/Ed25519";
18
+ import { Hex2Bytes } from "../../Cryptide/Serialization";
19
+ export default class OrkInfo {
20
+ constructor(orkID, orkPublic, orkURL, orkPaymentPublic) {
21
+ this.orkID = orkID;
22
+ this.orkPublic = orkPublic;
23
+ this.orkURL = orkURL;
24
+ this.orkPaymentPublic = orkPaymentPublic;
25
+ }
26
+ toString() {
27
+ return JSON.stringify({
28
+ Id: this.orkID,
29
+ PublicKey: this.orkPublic.toBase64(),
30
+ URL: this.orkURL,
31
+ PaymentPublicKey: this.orkPaymentPublic.toBase64()
32
+ });
33
+ }
34
+ toNativeTypeObject() {
35
+ return {
36
+ Id: this.orkID,
37
+ PublicKey: this.orkPublic.toBase64(),
38
+ URL: this.orkURL,
39
+ PaymentPublicKey: this.orkPaymentPublic.toBase64()
40
+ };
41
+ }
42
+ static fromNativeTypeObject(json) {
43
+ return new OrkInfo(json.Id, Point.fromBase64(json.PublicKey), json.URL, Point.fromBase64(json.PaymentPublicKey));
44
+ }
45
+ static from(json) {
46
+ const { publickey, paymentpublickey, id, url } = normalizeKeys(json);
47
+ const pub = Point.fromBytes(Hex2Bytes(publickey).slice(3));
48
+ const paymentPub = Point.fromBytes(Hex2Bytes(paymentpublickey).slice(3));
49
+ return new OrkInfo(id, pub, url, paymentPub);
50
+ }
51
+ }
52
+ function normalizeKeys(obj) {
53
+ const normalized = {};
54
+ Object.keys(obj).forEach(key => {
55
+ normalized[key.toLowerCase()] = obj[key];
56
+ });
57
+ return normalized;
58
+ }
@@ -0,0 +1,3 @@
1
+ export { default as KeyInfo } from './KeyInfo';
2
+ export { default as OrkInfo } from './OrkInfo';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../Models/Infos/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,18 @@
1
+ //
2
+ // Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
3
+ // Copyright (C) 2022 Tide Foundation Ltd
4
+ //
5
+ // This program is free software and is subject to the terms of
6
+ // the Tide Community Open Code License as published by the
7
+ // Tide Foundation Limited. You may modify it and redistribute
8
+ // it in accordance with and subject to the terms of that License.
9
+ // This program is distributed WITHOUT WARRANTY of any kind,
10
+ // including without any implied warranty of MERCHANTABILITY or
11
+ // FITNESS FOR A PARTICULAR PURPOSE.
12
+ // See the Tide Community Open Code License for more details.
13
+ // You should have received a copy of the Tide Community Open
14
+ // Code License along with this program.
15
+ // If not, see https://tide.org/licenses_tcoc2-0-0-en
16
+ //
17
+ export { default as KeyInfo } from './KeyInfo';
18
+ export { default as OrkInfo } from './OrkInfo';
@@ -0,0 +1,29 @@
1
+ import BaseTideRequest from "./BaseTideRequest";
2
+ export declare class ModelRegistry {
3
+ static getHumanReadableModelBuilder(reqId: string, data: Uint8Array): HumanReadableModelBuilder;
4
+ }
5
+ export declare class HumanReadableModelBuilder {
6
+ _humanReadableName: any;
7
+ _data: any;
8
+ _draft: any;
9
+ request: BaseTideRequest | undefined;
10
+ reqId: any;
11
+ constructor(data: any, reqId: any);
12
+ static create(data: any, reqId: any): HumanReadableModelBuilder;
13
+ getDetailsMap(): any[];
14
+ getRequestDataJson(): {};
15
+ getExpiry(): number;
16
+ getDataToApprove(): Promise<Uint8Array<ArrayBuffer>>;
17
+ }
18
+ export declare class OffboardSignRequestBuilder extends HumanReadableModelBuilder {
19
+ _name: string;
20
+ _version: string;
21
+ _humanReadableName: string;
22
+ get _id(): string;
23
+ constructor(data: any, reqId: any);
24
+ getDetailsMap(): any;
25
+ getRequestDataJson(): {
26
+ "Vendor Rotating Key for Offboarding": string;
27
+ };
28
+ }
29
+ //# sourceMappingURL=ModelRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelRegistry.d.ts","sourceRoot":"","sources":["../../Models/ModelRegistry.ts"],"names":[],"mappings":"AAkBA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAIhD,qBAAa,aAAa;IACtB,MAAM,CAAC,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,yBAAyB;CAWlG;AAED,qBAAa,yBAAyB;IAClC,kBAAkB,MAAQ;IAC1B,KAAK,EAAE,GAAG,CAAC;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,eAAe,GAAG,SAAS,CAAC;IACrC,KAAK,EAAE,GAAG,CAAC;gBACC,IAAI,KAAA,EAAE,KAAK,KAAA;IAQvB,MAAM,CAAC,MAAM,CAAC,IAAI,KAAA,EAAE,KAAK,KAAA;IAGzB,aAAa;IAIb,kBAAkB;IAKlB,SAAS;IAIH,gBAAgB;CAGzB;AAkGD,qBAAa,0BAA2B,SAAQ,yBAAyB;IACrE,KAAK,SAAc;IACnB,QAAQ,SAAO;IACf,kBAAkB,SAA6C;IAE/D,IAAI,GAAG,WAA+C;gBAC1C,IAAI,KAAA,EAAE,KAAK,KAAA;IAGvB,aAAa,IAAI,GAAG;IAUpB,kBAAkB;;;CAOrB"}
@@ -0,0 +1,321 @@
1
+ //
2
+ // Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm
3
+ // Copyright (C) 2022 Tide Foundation Ltd
4
+ //
5
+ // This program is free software and is subject to the terms of
6
+ // the Tide Community Open Code License as published by the
7
+ // Tide Foundation Limited. You may modify it and redistribute
8
+ // it in accordance with and subject to the terms of that License.
9
+ // This program is distributed WITHOUT WARRANTY of any kind,
10
+ // including without any implied warranty of MERCHANTABILITY or
11
+ // FITNESS FOR A PARTICULAR PURPOSE.
12
+ // See the Tide Community Open Code License for more details.
13
+ // You should have received a copy of the Tide Community Open
14
+ // Code License along with this program.
15
+ // If not, see https://tide.org/licenses_tcoc2-0-0-en
16
+ //
17
+ import { AuthorizerPack, Bytes2Hex, GetValue, StringFromUint8Array, TryGetValue } from "../Cryptide/Serialization";
18
+ import BaseTideRequest from "./BaseTideRequest";
19
+ import { Policy, ApprovalType, ExecutionType } from "./Policy";
20
+ import { Serialization } from "../Cryptide/index";
21
+ export class ModelRegistry {
22
+ static getHumanReadableModelBuilder(reqId, data) {
23
+ const r = BaseTideRequest.decode(data);
24
+ const nameMatch = r.name.match(/^Custom<(.*)>$/)?.[1];
25
+ const versionMatch = r.version.match(/^Custom<(.*)>$/)?.[1];
26
+ if (nameMatch && versionMatch) {
27
+ return new CustomSignRequestBuilder(data, reqId);
28
+ }
29
+ const c = modelBuildersMap[r.id()];
30
+ if (!c)
31
+ throw Error("Could not find model: " + r.id());
32
+ return c.create(data, reqId);
33
+ }
34
+ }
35
+ export class HumanReadableModelBuilder {
36
+ constructor(data, reqId) {
37
+ this._humanReadableName = null;
38
+ if (data) {
39
+ this._data = data;
40
+ this._draft = GetValue(this._data, 3);
41
+ this.request = BaseTideRequest.decode(data);
42
+ }
43
+ this.reqId = reqId;
44
+ }
45
+ static create(data, reqId) {
46
+ return new this(data, reqId);
47
+ }
48
+ getDetailsMap() {
49
+ // the summary
50
+ return [];
51
+ }
52
+ getRequestDataJson() {
53
+ // raw json
54
+ return {};
55
+ }
56
+ getExpiry() {
57
+ return this.request.expiry;
58
+ }
59
+ async getDataToApprove() {
60
+ return this.request.dataToApprove();
61
+ }
62
+ }
63
+ // MODELS ----------------------------------------------------------------
64
+ class CustomSignRequestBuilder extends HumanReadableModelBuilder {
65
+ get _id() { return this._name + ":" + this._version; }
66
+ constructor(data, reqId) {
67
+ super(data, reqId);
68
+ this._name = this.request.name.match(/^Custom<(.*)>$/)?.[1];
69
+ this._version = this.request.version.match(/^Custom<(.*)>$/)?.[1];
70
+ this.humanReadableJson = JSON.parse(StringFromUint8Array(GetValue(this.request.draft, 0)));
71
+ this._humanReadableName = this.humanReadableJson["humanReadableName"];
72
+ }
73
+ getRequestDataJson() {
74
+ return this.humanReadableJson["additionalInfo"];
75
+ }
76
+ }
77
+ // Need this while we work on better custom models
78
+ class HederaSignRequestBuilder extends HumanReadableModelBuilder {
79
+ get _id() { return this._name + ":" + this._version; }
80
+ constructor(data, reqId) {
81
+ super(data, reqId);
82
+ this._name = "HederaTx";
83
+ this._version = "1";
84
+ if (data) {
85
+ this.customInfo = JSON.parse(StringFromUint8Array(Serialization.GetValue(this.request.draft, 0)));
86
+ this.additionalInfo = this.customInfo["additionalInfo"];
87
+ this._humanReadableName = `Request to send ${BigInt(this.additionalInfo["Total being spent (tinybar)"]) / BigInt(100000000)} HBAR`;
88
+ }
89
+ }
90
+ getRequestDataJson() {
91
+ return this.additionalInfo;
92
+ }
93
+ }
94
+ class UserContextSignRequestBuilder extends HumanReadableModelBuilder {
95
+ get _id() { return this._name + ":" + this._version; }
96
+ constructor(data, reqId) {
97
+ super(data, reqId);
98
+ this._name = "UserContext"; // Model ID
99
+ this._humanReadableName = "User Access Change";
100
+ this._version = "1";
101
+ }
102
+ static create(data, reqId) {
103
+ return super.create(data, reqId);
104
+ }
105
+ getRequestDataJson() {
106
+ // deserialize draft here and return a pretty object for user
107
+ let prettyObject = {};
108
+ let draftIndex = 0;
109
+ // make sure user context is JSON
110
+ let cont = true;
111
+ prettyObject.UserContexts = [];
112
+ while (cont) {
113
+ try {
114
+ prettyObject.UserContexts.push(JSON.parse(StringFromUint8Array(GetValue(this._draft, draftIndex))));
115
+ draftIndex++;
116
+ }
117
+ catch {
118
+ cont = false;
119
+ }
120
+ }
121
+ // return a nice object of InitCert? and usercontexts
122
+ return prettyObject;
123
+ }
124
+ getDetailsMap() {
125
+ // deserialize draft here and return a pretty object for user
126
+ let prettyObject = {};
127
+ let draftIndex = 0;
128
+ // make sure user context is JSON
129
+ let cont = true;
130
+ prettyObject.UserContexts = [];
131
+ while (cont) {
132
+ try {
133
+ prettyObject.UserContexts.push(JSON.parse(StringFromUint8Array(GetValue(this._draft, draftIndex))));
134
+ draftIndex++;
135
+ }
136
+ catch {
137
+ cont = false;
138
+ }
139
+ }
140
+ // Create summary
141
+ let summary = {};
142
+ // Get the clients involved in this approval
143
+ // All clients will be either realm-management or under resource_management
144
+ let clients = [];
145
+ prettyObject.UserContexts.map(c => {
146
+ if (c.realm_access)
147
+ clients.push("realm_access");
148
+ if (typeof c.resource_access === "object") {
149
+ clients.push(...Object.keys(c.resource_access));
150
+ }
151
+ });
152
+ clients = [...new Set(clients)];
153
+ summary["Applications affected"] = clients.join(", ");
154
+ // return a nice object of InitCert? and usercontexts
155
+ return summary;
156
+ }
157
+ }
158
+ export class OffboardSignRequestBuilder extends HumanReadableModelBuilder {
159
+ get _id() { return this._name + ":" + this._version; }
160
+ constructor(data, reqId) {
161
+ super(data, reqId);
162
+ this._name = "Offboard";
163
+ this._version = "1";
164
+ this._humanReadableName = "Cancel Tide Subscription and Protection";
165
+ }
166
+ getDetailsMap() {
167
+ let summary = {};
168
+ summary["WARNING WARNING WARNING"] = "";
169
+ summary["APPROVING THIS REQUEST WILL CRIPPLE YOUR LICENSED TIDE ACCOUNT"] = "";
170
+ summary["ONLY APPROVE THIS REQUEST IF YOU INTEND TO OFFBOARD FROM THE TIDE NETWORK"] = "";
171
+ summary["THIS ACTION IS UNRECOVERABLE"] = "";
172
+ return summary;
173
+ }
174
+ getRequestDataJson() {
175
+ const vrk = Bytes2Hex(GetValue(this._draft, 0));
176
+ let body = {
177
+ "Vendor Rotating Key for Offboarding": vrk
178
+ };
179
+ return body;
180
+ }
181
+ }
182
+ class PolicySignRequestBuilder extends HumanReadableModelBuilder {
183
+ get _id() { return this._name + ":" + this._version; }
184
+ constructor(data, expiry) {
185
+ super(data, expiry);
186
+ this._name = "Policy";
187
+ this._version = "1";
188
+ this._humanReadableName = "Approve new policy for use with Tide";
189
+ }
190
+ getDetailsMap() {
191
+ let summary = {};
192
+ const draftBytes = this._draft;
193
+ if (!draftBytes)
194
+ return { error: 'No draft data' };
195
+ const policyBytes = GetValue(draftBytes, 0);
196
+ const policy = Policy.from(policyBytes);
197
+ summary['Version'] = policy.version;
198
+ summary['ContractId'] = policy.contractId;
199
+ summary['ModelId'] = policy.modelIds.join(", ");
200
+ summary["KeyId"] = policy.keyId;
201
+ summary['Approval Type'] = ApprovalType[policy.approvalType];
202
+ summary["Execution Type"] = ExecutionType[policy.executionType];
203
+ for (const [key, value] of policy.params.entries.entries()) {
204
+ if (!(value instanceof Uint8Array))
205
+ summary[`Parameter:${key}`] = value;
206
+ }
207
+ let res = {};
208
+ if (TryGetValue(draftBytes, 1, res)) {
209
+ const contractBytes = res.result;
210
+ const contractType = StringFromUint8Array(GetValue(contractBytes, 0));
211
+ summary["Contract To Upload Type"] = contractType;
212
+ summary["Contract Included"] = "Yes - see Request Data for source code";
213
+ }
214
+ return summary;
215
+ }
216
+ getRequestDataJson() {
217
+ let data = {};
218
+ const draftBytes = this._draft;
219
+ if (!draftBytes)
220
+ return data;
221
+ // Only show contract source code - other info is in the summary
222
+ // Structure: draft[1] = contractTransport = ["forseti", forsetiData]
223
+ // forsetiData = [placeholder, innerPayload]
224
+ // innerPayload = [sourceCode, entryType?]
225
+ let res = {};
226
+ if (TryGetValue(draftBytes, 1, res)) {
227
+ const contractBytes = res.result;
228
+ // contractBytes[1] = forsetiData
229
+ let forsetiDataRes = {};
230
+ if (TryGetValue(contractBytes, 1, forsetiDataRes)) {
231
+ const forsetiData = forsetiDataRes.result;
232
+ // forsetiData[1] = innerPayload
233
+ let innerPayloadRes = {};
234
+ if (TryGetValue(forsetiData, 1, innerPayloadRes)) {
235
+ const innerPayload = innerPayloadRes.result;
236
+ // innerPayload[0] = sourceCode
237
+ let sourceCodeRes = {};
238
+ if (TryGetValue(innerPayload, 0, sourceCodeRes)) {
239
+ const contractCode = StringFromUint8Array(sourceCodeRes.result);
240
+ data["Contract Source Code"] = contractCode;
241
+ }
242
+ }
243
+ }
244
+ }
245
+ return data;
246
+ }
247
+ }
248
+ class PolicyEnabledEncryptionRequestBuilder extends HumanReadableModelBuilder {
249
+ get _id() { return this._name + ":" + this._version; }
250
+ constructor(data, expiry) {
251
+ super(data, expiry);
252
+ this._name = "PolicyEnabledEncryption";
253
+ this._version = "1";
254
+ if (data) {
255
+ const timestamp = GetValue(this.request.draft, 0);
256
+ let resultObj = { result: undefined };
257
+ let i = 1;
258
+ while (TryGetValue(this.request.draft, i, resultObj)) {
259
+ i++;
260
+ }
261
+ const count = i - 1; // subtract 1 as i starts at 1 (skipping timestamp)
262
+ this._humanReadableName = `Encrypt ${count} piece${count != 1 ? "s" : ""} of data`;
263
+ }
264
+ }
265
+ }
266
+ class PolicyEnabledDecryptionRequestBuilder extends HumanReadableModelBuilder {
267
+ get _id() { return this._name + ":" + this._version; }
268
+ constructor(data, expiry) {
269
+ super(data, expiry);
270
+ this._name = "PolicyEnabledDecryption";
271
+ this._version = "1";
272
+ if (data) {
273
+ let resultObj = { result: undefined };
274
+ let i = 0;
275
+ while (TryGetValue(this.request.draft, i, resultObj)) {
276
+ i++;
277
+ }
278
+ this._humanReadableName = `Decrypt ${i} piece${i != 1 ? "s" : ""} of data`;
279
+ }
280
+ }
281
+ }
282
+ class LicenseSignRequestBuilder extends HumanReadableModelBuilder {
283
+ get _id() { return this._name + ":" + this._version; }
284
+ constructor(data, expiry) {
285
+ super(data, expiry);
286
+ this._name = "RotateVRK";
287
+ this._version = "1";
288
+ this._humanReadableName = "Renew License with New Permissions";
289
+ }
290
+ getDetailsMap() {
291
+ const authPack = new AuthorizerPack(this._draft);
292
+ let summary = [];
293
+ summary["Signing new license"] = authPack.Authorizer.GVRK.Serialize().ToString();
294
+ summary["Approved Models to Sign"] = authPack.SignModels;
295
+ return summary;
296
+ }
297
+ }
298
+ class TestInitSignRequestBuilder extends HumanReadableModelBuilder {
299
+ get _id() { return this._name + ":" + this._version; }
300
+ constructor(data, expiry) {
301
+ super(data, expiry);
302
+ this._name = "TestInit";
303
+ this._version = "1";
304
+ this._humanReadableName = "Test Tide Request";
305
+ }
306
+ getDetailsMap() {
307
+ let summary = [];
308
+ summary["Draft Detail"] = StringFromUint8Array(this._draft);
309
+ return summary;
310
+ }
311
+ }
312
+ const modelBuildersMap = {
313
+ [new UserContextSignRequestBuilder(null, null)._id]: UserContextSignRequestBuilder,
314
+ [new OffboardSignRequestBuilder(null, null)._id]: OffboardSignRequestBuilder,
315
+ [new LicenseSignRequestBuilder(null, null)._id]: LicenseSignRequestBuilder,
316
+ [new TestInitSignRequestBuilder(null, null)._id]: TestInitSignRequestBuilder,
317
+ [new PolicySignRequestBuilder(null, null)._id]: PolicySignRequestBuilder,
318
+ [new HederaSignRequestBuilder(null, null)._id]: HederaSignRequestBuilder,
319
+ [new PolicyEnabledEncryptionRequestBuilder(null, null)._id]: PolicyEnabledEncryptionRequestBuilder,
320
+ [new PolicyEnabledDecryptionRequestBuilder(null, null)._id]: PolicyEnabledDecryptionRequestBuilder,
321
+ };
@@ -0,0 +1,41 @@
1
+ import { TideMemory } from "../Tools/TideMemory";
2
+ export declare enum ApprovalType {
3
+ EXPLICIT = 0,
4
+ IMPLICIT = 1
5
+ }
6
+ export declare enum ExecutionType {
7
+ PRIVATE = 0,
8
+ PUBLIC = 1
9
+ }
10
+ export declare class Policy {
11
+ static latestVersion: string;
12
+ version: string;
13
+ contractId: string;
14
+ modelIds: string[];
15
+ keyId: string;
16
+ approvalType: ApprovalType;
17
+ executionType: ExecutionType;
18
+ params: PolicyParameters;
19
+ dataToVerify: TideMemory | undefined;
20
+ signature: Uint8Array | undefined;
21
+ constructor(data: {
22
+ version: string;
23
+ contractId: string;
24
+ modelId: string[] | string;
25
+ keyId: string;
26
+ approvalType: ApprovalType;
27
+ executionType: ExecutionType;
28
+ params: Map<string, any> | PolicyParameters;
29
+ });
30
+ static from(data: Uint8Array): Policy;
31
+ toBytes(): TideMemory;
32
+ }
33
+ export declare class PolicyParameters {
34
+ entries: Map<string, any>;
35
+ constructor(data: Map<string, any> | Uint8Array);
36
+ private static fromBytes;
37
+ tryGetParameter<T extends string | number | bigint | boolean | Uint8Array>(key: string): [boolean, T];
38
+ getParameter<T extends string | number | bigint | boolean | Uint8Array>(key: string): T;
39
+ toBytes(): Uint8Array;
40
+ }
41
+ //# sourceMappingURL=Policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Policy.d.ts","sourceRoot":"","sources":["../../Models/Policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,oBAAY,YAAY;IACpB,QAAQ,IAAA;IACR,QAAQ,IAAA;CACX;AACD,oBAAY,aAAa;IACrB,OAAO,IAAA;IACP,MAAM,IAAA;CACT;AACD,qBAAa,MAAM;IACf,MAAM,CAAC,aAAa,EAAE,MAAM,CAAO;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IAEzB,YAAY,EAAE,UAAU,GAAG,SAAS,CAAC;IACrC,SAAS,EAAE,UAAU,GAAG,SAAS,CAAC;gBAEtB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,YAAY,CAAC;QAAC,aAAa,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB,CAAA;KAAE;IAkC3M,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;IAgDrC,OAAO;CAgBV;AAED,qBAAa,gBAAgB;IACzB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBACd,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,UAAU;IAQ/C,OAAO,CAAC,MAAM,CAAC,SAAS;IAgDxB,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAQrG,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAkCvF,OAAO,IAAI,UAAU;CAsCxB"}