@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,32 @@
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 class VendorSettings {
18
+ constructor(regOn, backupOn, imageURL, logoURL) {
19
+ this.regOn = regOn;
20
+ this.backupOn = backupOn;
21
+ this.imageURL = imageURL;
22
+ this.logoURL = logoURL;
23
+ }
24
+ toString() {
25
+ return JSON.stringify({
26
+ RegOn: this.regOn,
27
+ BackupOn: this.backupOn,
28
+ ImageURL: this.imageURL,
29
+ LogoURL: this.logoURL
30
+ });
31
+ }
32
+ }
@@ -0,0 +1,13 @@
1
+ export { default as AuthRequest } from './AuthRequest';
2
+ export { default as BaseTideRequest } from './BaseTideRequest';
3
+ export { default as Datum } from './Datum';
4
+ export { Doken } from './Doken';
5
+ export { default as EnclaveEntry } from './EnclaveEntry';
6
+ export { ModelRegistry, HumanReadableModelBuilder, OffboardSignRequestBuilder } from './ModelRegistry';
7
+ export { Policy, ApprovalType, ExecutionType } from './Policy';
8
+ export { default as SerializedField } from './SerializedField';
9
+ export { default as VendorData } from './VendorData';
10
+ export { default as VendorSettings } from './VendorSettings';
11
+ export * as Infos from './Infos';
12
+ export * as Responses from './Responses';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Models/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC"}
@@ -0,0 +1,30 @@
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
+ // Direct exports
18
+ export { default as AuthRequest } from './AuthRequest';
19
+ export { default as BaseTideRequest } from './BaseTideRequest';
20
+ export { default as Datum } from './Datum';
21
+ export { Doken } from './Doken';
22
+ export { default as EnclaveEntry } from './EnclaveEntry';
23
+ export { ModelRegistry, HumanReadableModelBuilder, OffboardSignRequestBuilder } from './ModelRegistry';
24
+ export { Policy, ApprovalType, ExecutionType } from './Policy';
25
+ export { default as SerializedField } from './SerializedField';
26
+ export { default as VendorData } from './VendorData';
27
+ export { default as VendorSettings } from './VendorSettings';
28
+ // Namespace exports
29
+ export * as Infos from './Infos';
30
+ export * as Responses from './Responses';
@@ -0,0 +1,10 @@
1
+ export declare class TideMemory extends Uint8Array {
2
+ static CreateFromArray(datas: Uint8Array[]): TideMemory;
3
+ static Create(initialValue: Uint8Array, totalLength: number, version?: number): TideMemory;
4
+ WriteValue(index: number, value: Uint8Array): void;
5
+ GetValue(index: number): TideMemory;
6
+ TryGetValue(index: number, returnObj: {
7
+ result: Uint8Array | undefined;
8
+ }): boolean;
9
+ }
10
+ //# sourceMappingURL=TideMemory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TideMemory.d.ts","sourceRoot":"","sources":["../../Tools/TideMemory.ts"],"names":[],"mappings":"AACA,qBAAa,UAAW,SAAQ,UAAU;IACtC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU;IASvD,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,MAAU,GAAG,UAAU;IAyB7F,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAwClD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU;IAwCnC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE;QAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAA;KAAC,GAAG,OAAO;CASnF"}
@@ -0,0 +1,105 @@
1
+ // Tide Memory Object helper functions from tide-js
2
+ export class TideMemory extends Uint8Array {
3
+ static CreateFromArray(datas) {
4
+ if (datas.length == 0)
5
+ return new TideMemory();
6
+ const length = datas.reduce((sum, next) => sum + 4 + next.length, 0);
7
+ const mem = this.Create(datas[0], length);
8
+ for (let i = 1; i < datas.length; i++) {
9
+ mem.WriteValue(i, datas[i]);
10
+ }
11
+ return mem;
12
+ }
13
+ static Create(initialValue, totalLength, version = 1) {
14
+ if (totalLength < initialValue.length + 4) {
15
+ throw new Error("Not enough space to allocate requested data. Make sure to request more space in totalLength than length of InitialValue plus 4 bytes for length.");
16
+ }
17
+ // Total buffer length is 4 (version) + totalLength
18
+ const bufferLength = 4 + totalLength;
19
+ const buffer = new TideMemory(bufferLength);
20
+ const dataView = new DataView(buffer.buffer);
21
+ // Write version at position 0 (4 bytes)
22
+ dataView.setInt32(0, version, true); // true for little-endian
23
+ let dataLocationIndex = 4;
24
+ // Write data length of initialValue at position 4 (4 bytes)
25
+ dataView.setInt32(dataLocationIndex, initialValue.length, true);
26
+ dataLocationIndex += 4;
27
+ // Write initialValue starting from position 8
28
+ buffer.set(initialValue, dataLocationIndex);
29
+ return buffer;
30
+ }
31
+ WriteValue(index, value) {
32
+ if (index < 0)
33
+ throw new Error("Index cannot be less than 0");
34
+ if (index === 0)
35
+ throw new Error("Use CreateTideMemory to set value at index 0");
36
+ if (this.length < 4 + value.length)
37
+ throw new Error("Could not write to memory. Memory too small for this value");
38
+ const dataView = new DataView(this.buffer);
39
+ let dataLocationIndex = 4; // Start after the version number
40
+ // Navigate through existing data segments
41
+ for (let i = 0; i < index; i++) {
42
+ if (dataLocationIndex + 4 > this.length) {
43
+ throw new RangeError("Index out of range.");
44
+ }
45
+ // Read data length at current position
46
+ const nextDataLength = dataView.getInt32(dataLocationIndex, true);
47
+ dataLocationIndex += 4;
48
+ dataLocationIndex += nextDataLength;
49
+ }
50
+ // Check if there's enough space to write the value
51
+ if (dataLocationIndex + 4 + value.length > this.length) {
52
+ throw new RangeError("Not enough space to write value");
53
+ }
54
+ // Check if data has already been written to this index
55
+ const existingLength = dataView.getInt32(dataLocationIndex, true);
56
+ if (existingLength !== 0) {
57
+ throw new Error("Data has already been written to this index");
58
+ }
59
+ // Write data length of value at current position
60
+ dataView.setInt32(dataLocationIndex, value.length, true);
61
+ dataLocationIndex += 4;
62
+ // Write value starting from current position
63
+ this.set(value, dataLocationIndex);
64
+ }
65
+ GetValue(index) {
66
+ // 'a' should be an ArrayBuffer or Uint8Array
67
+ if (this.length < 4) {
68
+ throw new Error("Insufficient data to read.");
69
+ }
70
+ // Create a DataView for reading integers in little-endian format
71
+ const dataView = new DataView(this.buffer, this.byteOffset, this.byteLength);
72
+ // Optional: Read the version if needed
73
+ // const version = dataView.getInt32(0, true);
74
+ let dataLocationIndex = 4;
75
+ for (let i = 0; i < index; i++) {
76
+ // Check if there's enough data to read the length of the next segment
77
+ if (dataLocationIndex + 4 > this.length) {
78
+ throw new RangeError("Index out of range.");
79
+ }
80
+ const nextDataLength = dataView.getInt32(dataLocationIndex, true);
81
+ dataLocationIndex += 4 + nextDataLength;
82
+ }
83
+ // Check if there's enough data to read the length of the final segment
84
+ if (dataLocationIndex + 4 > this.length) {
85
+ throw new RangeError("Index out of range.");
86
+ }
87
+ const finalDataLength = dataView.getInt32(dataLocationIndex, true);
88
+ dataLocationIndex += 4;
89
+ // Check if the final data segment is within bounds
90
+ if (dataLocationIndex + finalDataLength > this.length) {
91
+ throw new RangeError("Index out of range.");
92
+ }
93
+ return this.subarray(dataLocationIndex, dataLocationIndex + finalDataLength);
94
+ }
95
+ TryGetValue(index, returnObj) {
96
+ try {
97
+ returnObj.result = this.GetValue(index);
98
+ return true;
99
+ }
100
+ catch {
101
+ returnObj.result = undefined;
102
+ return false;
103
+ }
104
+ }
105
+ }
@@ -0,0 +1,13 @@
1
+ import OrkInfo from "../Models/Infos/OrkInfo";
2
+ export declare const Threshold = 14;
3
+ export declare const Max = 20;
4
+ export declare function CurrentTime(): number;
5
+ export declare function WaitForNumberofORKs(orkList_Ref: OrkInfo[], pre_responses: Promise<any>[], keyType: string, amountRequired?: number, bitwise_p?: (0 | 1)[], optionalArray?: any[], customTimeout?: number, customPromiseChecker?: Function): Promise<{
6
+ fulfilledResponses: any[];
7
+ bitwise: any[];
8
+ }>;
9
+ export declare function removeRandomElements(array: any[], targetArraySize: number): any[];
10
+ export declare function randBetween(x: any, y: any): bigint;
11
+ export declare function sortORKs(orks: OrkInfo[]): OrkInfo[];
12
+ export declare function randomiseEmails(arr: any): any[];
13
+ //# sourceMappingURL=Utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../Tools/Utils.ts"],"names":[],"mappings":"AAiBA,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAE9C,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,GAAG,KAAK,CAAC;AAEtB,wBAAgB,WAAW,WAE1B;AAiFD,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,GAAE,MAAkB,EAAE,SAAS,GAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAS,EAAE,aAAa,GAAE,GAAG,EAAS,EAAE,aAAa,GAAE,MAAa,EAAE,oBAAoB,GAAE,QAAe;;;GAgFlR;AACD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,GAAG,EAAE,CAejF;AAED,wBAAgB,WAAW,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,UAc/B;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,aAOvC;AAGD,wBAAgB,eAAe,CAAC,GAAG,KAAA,SA8BlC"}
@@ -0,0 +1,242 @@
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 const Threshold = 14;
18
+ export const Max = 20;
19
+ export function CurrentTime() {
20
+ return Math.floor(Date.now() / 1000); // this will be affected by the 2038 problem
21
+ }
22
+ async function PromiseRace(promises, keyType, amountRequired, customTimeout = null, customPromiseChecker = null) {
23
+ let results = [];
24
+ let failed = [];
25
+ let timeoutReached = false;
26
+ let initLength = promises.length;
27
+ // Function to set a timeout promise
28
+ const timeout = (ms, id) => new Promise(resolve => setTimeout(resolve, ms, id));
29
+ // Start the timeout checks
30
+ const oneSecondCheck = timeout(1000, '1s');
31
+ const timeoutLength = customTimeout == null ? 8000 : customTimeout;
32
+ const timeoutCheck = timeout(timeoutLength, 'ts');
33
+ promises.push(oneSecondCheck);
34
+ promises.push(timeoutCheck);
35
+ let oneSecCheckPassed = false;
36
+ let fullyCompletedPromises = 0;
37
+ while (promises.length > 0 && fullyCompletedPromises < initLength) {
38
+ const racePromises = promises.map((p, index) => p.then(result => ({ result, index })).catch(error => ({ error, index })));
39
+ const fastestPromise = await Promise.race(racePromises);
40
+ if (fastestPromise.result === '1s') {
41
+ oneSecCheckPassed = true;
42
+ }
43
+ else if (fastestPromise.result === 'ts') {
44
+ if (fullyCompletedPromises >= amountRequired) {
45
+ break;
46
+ }
47
+ else if (failed.length > 0) {
48
+ console.log("Errors in flow:");
49
+ failed.forEach(f => console.error(f));
50
+ break;
51
+ }
52
+ else {
53
+ timeoutReached = true;
54
+ break;
55
+ }
56
+ }
57
+ else {
58
+ if (!fastestPromise.error) {
59
+ if (customPromiseChecker != null) {
60
+ if (customPromiseChecker(fastestPromise.result)) {
61
+ fullyCompletedPromises++;
62
+ }
63
+ results.push(fastestPromise.result); // Promise resolved successfully
64
+ }
65
+ else {
66
+ fullyCompletedPromises++;
67
+ results.push(fastestPromise.result); // Promise resolved successfully
68
+ }
69
+ }
70
+ else {
71
+ failed.push(fastestPromise.error); // Promise rejected
72
+ }
73
+ }
74
+ // Removed one sec check passed condition for slighly faster requests - add back in when we start penalising orks
75
+ //if(oneSecCheckPassed && fullyCompletedPromises >=amountRequired) break;
76
+ if (fullyCompletedPromises >= amountRequired)
77
+ break;
78
+ // Remove the resolved or rejected promise from the list
79
+ promises.splice(fastestPromise.index, 1);
80
+ }
81
+ // Error checking and finalization
82
+ if (fullyCompletedPromises >= amountRequired) {
83
+ return results; // Return results if threshold amount is met
84
+ }
85
+ else {
86
+ if (failed.some(ex => ex === "Too many attempts")) {
87
+ throw Error("enclave.throttled");
88
+ }
89
+ else if (failed.length > 0) {
90
+ throw Error(failed[0]);
91
+ }
92
+ else if (timeoutReached) {
93
+ throw Error("enclave.thresholdTimeoutFailure");
94
+ }
95
+ else {
96
+ throw Error(keyType + " Orks for this account are down");
97
+ }
98
+ }
99
+ }
100
+ export async function WaitForNumberofORKs(orkList_Ref, pre_responses, keyType, amountRequired = Threshold, bitwise_p = null, optionalArray = null, customTimeout = null, customPromiseChecker = null) {
101
+ // See Utils.cs on Midgard Core for how this can be improved
102
+ // Basically, you don't need indexes in the responses, just use .indexOf
103
+ const unsortedResponses = await PromiseRace(pre_responses, keyType, amountRequired, customTimeout, customPromiseChecker);
104
+ const sortedResponses = unsortedResponses.sort((a, b) => a.index - b.index);
105
+ let bitwise = [];
106
+ if (bitwise_p != null) {
107
+ // bitwise provided, this func is being called from a sequential flow
108
+ // ork array will be modified
109
+ // bitwise returned will be new/updated bitwise
110
+ // Get an array of active ork indexs (used to update bitwise)
111
+ let previousActiveOrkIndexes = [];
112
+ bitwise_p.forEach((b, i) => {
113
+ if (b == 1)
114
+ previousActiveOrkIndexes.push(i);
115
+ });
116
+ // This is too confusing to try and explain. Ask chatgpt.
117
+ // Hint: We have to skip existing unavilable orks in the bitwise and
118
+ // take the indexes in the unresponsive list as the nth active bitwise element to switch off
119
+ let currentUnresponsiveOrkIndexs = []; // unresponsive ork indexes from an array that previpusly contained only active orks
120
+ let i = 0, j = 0;
121
+ console.log("total: " + orkList_Ref.length);
122
+ console.log("responded: " + sortedResponses.length);
123
+ while (i < orkList_Ref.length && j < sortedResponses.length) {
124
+ if (i === sortedResponses[j].index) {
125
+ i++;
126
+ j++;
127
+ }
128
+ else {
129
+ currentUnresponsiveOrkIndexs.push(i);
130
+ console.log(orkList_Ref[i].orkID + ":" + orkList_Ref[i].orkURL + " is slow");
131
+ i++;
132
+ }
133
+ }
134
+ // Add any remaining elements from orkLiftRef
135
+ while (i < orkList_Ref.length) {
136
+ currentUnresponsiveOrkIndexs.push(i);
137
+ console.log(orkList_Ref[i].orkID + ":" + orkList_Ref[i].orkURL + " is slow");
138
+ i++;
139
+ }
140
+ console.log("didn't respond: " + currentUnresponsiveOrkIndexs.length);
141
+ // TODO: once this works, shorten the code
142
+ bitwise = bitwise_p.slice();
143
+ let occurrenceCount = 0;
144
+ let indexCount = 0;
145
+ for (let i = 0; i < bitwise.length; i++) {
146
+ if (bitwise[i] === 1) {
147
+ occurrenceCount++;
148
+ if (occurrenceCount === currentUnresponsiveOrkIndexs[indexCount] + 1) { // + 1 as we are converting a index to a counter
149
+ bitwise[i] = 0;
150
+ indexCount++;
151
+ }
152
+ }
153
+ }
154
+ }
155
+ else {
156
+ bitwise = Array(Max).fill(0).map((_, i) => sortedResponses.every(resp => resp.index != i) ? 0 : 1);
157
+ }
158
+ const newOrkList = orkList_Ref.filter((_, i) => !sortedResponses.every(resp => resp.index != i)); // if ork at index 0 does not include a response with index 0, remove ork
159
+ orkList_Ref.splice(0, orkList_Ref.length);
160
+ newOrkList.forEach(el => orkList_Ref.push(el));
161
+ if (optionalArray != null) {
162
+ const newOptArray = optionalArray.filter((_, i) => !sortedResponses.every(resp => resp.index != i)); // modifies array!
163
+ optionalArray.splice(0, optionalArray.length);
164
+ newOptArray.forEach(el => optionalArray.push(el));
165
+ }
166
+ // remove index field from json, return the OTHER (unknown to us) field
167
+ const cleanedResponses = sortedResponses.map(resp => {
168
+ for (let key in resp) {
169
+ if (resp.hasOwnProperty(key) && key !== "index" && key !== "tag")
170
+ return resp[key];
171
+ }
172
+ throw Error("WaitForThresholdNumberofORKs should only be used on NodeClient responses that return an index in the JSON");
173
+ });
174
+ return { fulfilledResponses: cleanedResponses, bitwise };
175
+ }
176
+ export function removeRandomElements(array, targetArraySize) {
177
+ let newArray = array.slice();
178
+ // Check if the array size is > n
179
+ if (newArray.length < targetArraySize) {
180
+ throw new Error("Array size must be greater than n.");
181
+ }
182
+ else if (newArray.length == targetArraySize)
183
+ return newArray;
184
+ // Randomly remove elements until the array size is n
185
+ while (newArray.length > targetArraySize) {
186
+ let randomIndex = Math.floor(Math.random() * newArray.length);
187
+ newArray.splice(randomIndex, 1);
188
+ }
189
+ return newArray;
190
+ }
191
+ export function randBetween(x, y) {
192
+ // Swapping x and y if x is greater than y
193
+ x = BigInt(x);
194
+ y = BigInt(y);
195
+ if (x > y) {
196
+ const temp = x;
197
+ x = y;
198
+ y = temp;
199
+ }
200
+ // Generating random BigInt between x and y
201
+ const range = BigInt(y) - BigInt(x) + BigInt(1);
202
+ const randNum = Math.floor(Math.random() * Number(range));
203
+ const rand = BigInt(randNum);
204
+ return rand + BigInt(x);
205
+ }
206
+ export function sortORKs(orks) {
207
+ const orkRef = orks.slice(); // don't modify original
208
+ return orkRef.sort((a, b) => {
209
+ if (BigInt(a.orkID) < BigInt(b.orkID))
210
+ return -1;
211
+ if (BigInt(a.orkID) > BigInt(b.orkID))
212
+ return 1;
213
+ return 0;
214
+ });
215
+ }
216
+ export function randomiseEmails(arr) {
217
+ // Thanks ChatGPT
218
+ // Validation
219
+ if (arr == null) {
220
+ return Array(Max).fill(null);
221
+ }
222
+ // Prepare the output array
223
+ let output = [];
224
+ const repetitions = Math.floor(Max / arr.length); // Base number of repetitions for each element
225
+ let remainingSpaces = Max % arr.length; // Additional repetitions needed
226
+ // Fill the output array
227
+ arr.forEach(item => {
228
+ for (let i = 0; i < repetitions; i++) {
229
+ output.push(item);
230
+ }
231
+ if (remainingSpaces > 0) {
232
+ output.push(item);
233
+ remainingSpaces--;
234
+ }
235
+ });
236
+ // Shuffle the output array (Fisher-Yates shuffle)
237
+ for (let i = output.length - 1; i > 0; i--) {
238
+ const j = Math.floor(Math.random() * (i + 1));
239
+ [output[i], output[j]] = [output[j], output[i]]; // Swap elements
240
+ }
241
+ return output;
242
+ }
@@ -0,0 +1,3 @@
1
+ export * from './Utils';
2
+ export * from './TideMemory';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Tools/index.ts"],"names":[],"mappings":"AAiBA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,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 * from './Utils';
18
+ export * from './TideMemory';
@@ -0,0 +1,10 @@
1
+ export * as Clients from './Clients';
2
+ export * as Contracts from './Contracts';
3
+ export * as Cryptide from './Cryptide';
4
+ export * as Flow from './Flow';
5
+ export * as Math from './Math';
6
+ export * as Models from './Models';
7
+ export * as Tools from './Tools';
8
+ import * as Utils from './Tools';
9
+ export { Utils };
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
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 * as Clients from './Clients';
18
+ export * as Contracts from './Contracts';
19
+ export * as Cryptide from './Cryptide';
20
+ export * as Flow from './Flow';
21
+ export * as Math from './Math';
22
+ export * as Models from './Models';
23
+ export * as Tools from './Tools';
24
+ // Backwards compatibility alias
25
+ import * as Utils from './Tools';
26
+ export { Utils };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@tideorg/js",
3
+ "version": "0.13.19",
4
+ "description": "Browser side modules required to interact with the Tide's Cybersecurity Fabric.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/tide-foundation/tide-js.git"
17
+ },
18
+ "author": "",
19
+ "license": "SEE LICENSE IN LICENSE",
20
+ "bugs": {
21
+ "url": "https://github.com/tide-foundation/tide-js/issues"
22
+ },
23
+ "homepage": "https://github.com/tide-foundation/tide-js#readme",
24
+ "devDependencies": {
25
+ "typescript": "^5.9.3"
26
+ }
27
+ }