@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,191 @@
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 { Encryption } from "../Cryptide/index";
18
+ import ClientBase from "./ClientBase";
19
+ import { BigIntFromByteArray, ConcatUint8Arrays, CreateTideMemoryFromArray, GetValue, base64ToBytes, bytesToBase64 } from "../Cryptide/Serialization";
20
+ import { Point } from "../Cryptide/Ed25519";
21
+ export default class NodeClient extends ClientBase {
22
+ constructor(url) {
23
+ super(url);
24
+ this.enabledTideDH = false;
25
+ }
26
+ async isActive() {
27
+ const response = await this._get("/active", 3000);
28
+ const responseData = await this._handleError(response, "Is Active");
29
+ return responseData;
30
+ }
31
+ async EnableTideDH(orkPublic, gSessKey, sessKey) {
32
+ if (!this.sessionKeyPrivateRaw)
33
+ throw Error("Add a session key to the client first");
34
+ this.enabledTideDH = true;
35
+ this.DHKey = await Encryption.DH.computeSharedKey(orkPublic, this.sessionKeyPrivateRaw);
36
+ return this;
37
+ }
38
+ async PreSign(index, vuid, request, voucher) {
39
+ if (!this.enabledTideDH)
40
+ throw Error("TideDH must be enabled");
41
+ const encrypted = await Encryption.AES.encryptData(CreateTideMemoryFromArray([request.encode()]), this.DHKey);
42
+ const data = this._createFormData({
43
+ 'encrypted': encrypted,
44
+ 'voucher': voucher
45
+ });
46
+ if (!this.token)
47
+ data.append("gSessKey", this.sessionKeyPublicEncoded);
48
+ const response = await this._post(`/Authentication/Key/v1/PreSign?vuid=${vuid}`, data);
49
+ const responseData = await this._handleError(response, 'PreSign');
50
+ const decrypted = await Encryption.AES.decryptDataRawOutput(base64ToBytes(responseData), this.DHKey);
51
+ const GRSection = GetValue(decrypted, 0);
52
+ if (GRSection.length % 32 != 0)
53
+ throw new Error("Unexpected response legnth. Must be divisible by 32");
54
+ let GRis = [];
55
+ for (let i = 0; i < GRSection.length; i += 32) {
56
+ GRis.push(Point.fromBytes(GRSection.slice(i, i + 32)));
57
+ }
58
+ this.orkCacheId = GetValue(decrypted, 2);
59
+ return {
60
+ index,
61
+ data: {
62
+ GRis,
63
+ AdditionalData: GetValue(decrypted, 1)
64
+ }
65
+ };
66
+ }
67
+ async Sign(vuid, request, GRs, bitwise, sessId) {
68
+ if (!this.enabledTideDH)
69
+ throw Error("TideDH must be enabled");
70
+ if (!this.orkCacheId)
71
+ throw Error("Call PreSign first");
72
+ const payload = CreateTideMemoryFromArray([
73
+ request.encode(),
74
+ ConcatUint8Arrays([new Uint8Array([GRs.length]), ...GRs.map(r => r.toRawBytes())]),
75
+ this.orkCacheId
76
+ ]);
77
+ const encrypted = await Encryption.AES.encryptData(payload, this.DHKey);
78
+ const data = this._createFormData({
79
+ 'encrypted': encrypted,
80
+ 'bitwise': bytesToBase64(bitwise)
81
+ });
82
+ if (!this.token)
83
+ data.append("gSessKey", this.sessionKeyPublicEncoded);
84
+ const response = await this._post(`/Authentication/Key/v1/Sign?vuid=${vuid}`, data);
85
+ const responseData = await this._handleError(response, 'Sign');
86
+ const decrypted = await Encryption.AES.decryptDataRawOutput(base64ToBytes(responseData), this.DHKey);
87
+ const signatureSection = GetValue(decrypted, 0);
88
+ let Sij = [];
89
+ for (let i = 0; i < signatureSection.length; i += 32) {
90
+ Sij.push(BigIntFromByteArray(signatureSection.slice(i, i + 32)));
91
+ }
92
+ delete this.orkCacheId;
93
+ return {
94
+ Sij,
95
+ AdditionalData: GetValue(decrypted, 1)
96
+ };
97
+ }
98
+ async Decrypt(index, vuid, request, voucher) {
99
+ if (!this.enabledTideDH)
100
+ throw Error("TideDH must be enabled");
101
+ const encrypted = await Encryption.AES.encryptData(CreateTideMemoryFromArray([request.encode()]), this.DHKey);
102
+ const data = this._createFormData({
103
+ 'encrypted': encrypted,
104
+ 'voucher': voucher
105
+ });
106
+ if (!this.token)
107
+ data.append("gSessKey", this.sessionKeyPublicEncoded);
108
+ const response = await this._post(`/Authentication/Key/v1/Decrypt?vuid=${vuid}`, data);
109
+ const responseData = await this._handleError(response, 'Decrypt');
110
+ const decrypted = await Encryption.AES.decryptDataRawOutput(base64ToBytes(responseData), this.DHKey);
111
+ if (decrypted.length % 32 != 0)
112
+ throw new Error("Unexpected response legnth. Must be divisible by 32");
113
+ let appliedC1s = [];
114
+ for (let i = 0; i < decrypted.length; i += 32) {
115
+ appliedC1s.push(Point.fromBytes(decrypted.slice(i, i + 32)));
116
+ }
117
+ return {
118
+ index,
119
+ appliedC1s
120
+ };
121
+ }
122
+ async CreateCheckoutSession(vendorData, redirectUrl, licensingTier) {
123
+ const licenseRequest = {
124
+ VendorData: vendorData,
125
+ RedirectUri: redirectUrl,
126
+ LicensingTier: licensingTier
127
+ };
128
+ return await this._postJSON(`/Payer/License/CreateCheckoutSession`, licenseRequest);
129
+ }
130
+ async IsLicenseActive(vendorId) {
131
+ const response = await this._getSilent(`/Payer/License/IsLicenseActive?obfGVVK=${vendorId}`);
132
+ const text = await response.text();
133
+ const isActive = text.trim().toLowerCase() === 'true';
134
+ return isActive;
135
+ }
136
+ async GetLicenseDetails(vendorId, timestamp, timestampSig) {
137
+ const data = this._createFormData({
138
+ "timestamp": timestamp,
139
+ "timestampSig": timestampSig
140
+ });
141
+ const response = await this._postSilent(`/Payer/License/getLicenseDetails?obfGVVK=${vendorId}`, data);
142
+ const responseData = await response.text();
143
+ if (responseData.startsWith("--FAILED--")) {
144
+ console.log("Error getting license details: " + responseData);
145
+ return;
146
+ }
147
+ return responseData;
148
+ }
149
+ async GetSubscriptionStatus(vendorId, initialSessionId, timestamp, timestampSig) {
150
+ const data = this._createFormData({
151
+ "initialSessionId": initialSessionId,
152
+ "timestamp": timestamp,
153
+ "timestampSig": timestampSig
154
+ });
155
+ const response = await this._postSilent(`/Payer/License/GetSubscriptionStatus?obfGVVK=${vendorId}`, data);
156
+ const responseData = await response.text();
157
+ if (responseData.startsWith("--FAILED--")) {
158
+ console.log("Error getting license details: " + responseData);
159
+ return;
160
+ }
161
+ const status = responseData.toLowerCase() === "active" ? "upcoming renewal" : responseData.toLowerCase();
162
+ return status;
163
+ }
164
+ async CreateCustomerPortalSession(vendorId, redirectUrl, timestamp, timestampSig) {
165
+ const data = this._createFormData({
166
+ "vendorId": vendorId,
167
+ "timestamp": timestamp,
168
+ "timestampSig": timestampSig,
169
+ "redirectUrl": redirectUrl
170
+ });
171
+ return await this._postSilent(`/Payer/License/CreateCustomerPortalSession?obfGVVK=${vendorId}`, data);
172
+ }
173
+ async UpdateSubscription(updateRequest, licenseId, timestamp, timestampSig) {
174
+ const data = this._createFormData({
175
+ "updateRequest": JSON.stringify(updateRequest),
176
+ "licenseId": licenseId,
177
+ "timestamp": timestamp,
178
+ "timestampSig": timestampSig
179
+ });
180
+ return await this._postSilent(`/Payer/License/updateSubscription`, data);
181
+ }
182
+ async CancelSubscription(licenseId, initialSessionId, timestamp, timestampSig) {
183
+ const data = this._createFormData({
184
+ "licenseId": licenseId,
185
+ "initialSessionId": initialSessionId,
186
+ "timestamp": timestamp,
187
+ "timestampSig": timestampSig
188
+ });
189
+ return await this._postSilent(`/Payer/License/CancelSubscription`, data);
190
+ }
191
+ }
@@ -0,0 +1,8 @@
1
+ import ClientBase from "./ClientBase";
2
+ import VoucherResponse from "../Models/Responses/Vendor/VoucherResponse";
3
+ import { Point } from "../Cryptide/Ed25519";
4
+ export default class VoucherClient extends ClientBase {
5
+ constructor(url: string);
6
+ GetVouchers(blurPORKi: Point[], actionRequest: string, blurerK: Point): Promise<VoucherResponse>;
7
+ }
8
+ //# sourceMappingURL=VoucherClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VoucherClient.d.ts","sourceRoot":"","sources":["../../Clients/VoucherClient.ts"],"names":[],"mappings":"AAiBA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,eAAe,MAAM,4CAA4C,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;gBACrC,GAAG,EAAE,MAAM;IAIjB,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK;CAgB9E"}
@@ -0,0 +1,36 @@
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 ClientBase from "./ClientBase";
18
+ import VoucherResponse from "../Models/Responses/Vendor/VoucherResponse";
19
+ export default class VoucherClient extends ClientBase {
20
+ constructor(url) {
21
+ super(url);
22
+ }
23
+ async GetVouchers(blurPORKi, actionRequest, blurerK) {
24
+ const request = JSON.stringify({
25
+ BlurPORKi: blurPORKi.map(blur => blur.toBase64()),
26
+ ActionRequest: actionRequest,
27
+ BlurerK: blurerK.toBase64()
28
+ });
29
+ const data = this._createFormData({
30
+ 'voucherRequest': request
31
+ });
32
+ const response = await this._post(``, data);
33
+ const respondeData = await this._handleError(response, "Get Vouchers", true);
34
+ return VoucherResponse.from(respondeData, blurerK.toBase64());
35
+ }
36
+ }
@@ -0,0 +1,5 @@
1
+ export { default as ClientBase } from './ClientBase';
2
+ export { default as NetworkClient } from './NetworkClient';
3
+ export { default as NodeClient } from './NodeClient';
4
+ export { default as VoucherClient } from './VoucherClient';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Clients/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,20 @@
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 ClientBase } from './ClientBase';
18
+ export { default as NetworkClient } from './NetworkClient';
19
+ export { default as NodeClient } from './NodeClient';
20
+ export { default as VoucherClient } from './VoucherClient';
@@ -0,0 +1,47 @@
1
+ import { Policy } from "../Models/Policy";
2
+ import BaseTideRequest from "../Models/BaseTideRequest";
3
+ import { TideMemory } from "../Tools/TideMemory";
4
+ interface PolicyRunResult {
5
+ failed?: unknown;
6
+ success: boolean;
7
+ }
8
+ export declare abstract class BaseContract {
9
+ abstract id: string;
10
+ private tideRequest;
11
+ private dokens;
12
+ protected authorizedRequestPayload: TideMemory;
13
+ protected informationalRequestPayload: TideMemory;
14
+ /**
15
+ * Inheritors must implement this
16
+ * @param policy Policy object
17
+ */
18
+ protected abstract validateData(policy: Policy): Promise<void>;
19
+ /**
20
+ * Inheritors must implement this if the policy has set it's approvalType to EXPLICIT
21
+ * @param policy Policy object
22
+ * @param approverDokens Approver Dokens
23
+ */
24
+ protected validateApprovers(policy: Policy, approverDokens: Doken[]): Promise<void>;
25
+ /**
26
+ * Inheritors must implement this if the policy has set it's executionType to PRIVATE
27
+ * @param policy Policy object
28
+ * @param executorDoken Executor Doken
29
+ */
30
+ protected validateExecutor(policy: Policy, executorDoken: Doken): Promise<void>;
31
+ /**
32
+ * To help with clients testing if their Tide Request will pass their contract's specified contract
33
+ * @param policy Serialized policy from Tide
34
+ * @returns
35
+ */
36
+ testPolicy(policy: Uint8Array | Policy, executorDoken?: string | undefined): Promise<PolicyRunResult>;
37
+ constructor(tideRequest: Uint8Array | BaseTideRequest);
38
+ }
39
+ export declare class Doken {
40
+ private payload;
41
+ constructor(d: Uint8Array | string);
42
+ hasResourceAccessRole(role: string, client: string): boolean;
43
+ hasRealmAccessRole(role: string): boolean;
44
+ hasVuid(vuid: string): boolean;
45
+ }
46
+ export {};
47
+ //# sourceMappingURL=BaseContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseContract.d.ts","sourceRoot":"","sources":["../../Contracts/BaseContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,UAAU,eAAe;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAA;CACnB;AAED,8BAAsB,YAAY;IAC9B,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,MAAM,CAAe;IAC7B,SAAS,CAAC,wBAAwB,EAAE,UAAU,CAAC;IAC/C,SAAS,CAAC,2BAA2B,EAAE,UAAU,CAAC;IAElD;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE9D;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInF;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/E;;;;OAIG;IACG,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,SAAgB,GAAG,OAAO,CAAC,eAAe,CAAC;gBAsBtG,WAAW,EAAE,UAAU,GAAG,eAAe;CAaxD;AAKD,qBAAa,KAAK;IACd,OAAO,CAAC,OAAO,CAAM;gBACT,CAAC,EAAE,UAAU,GAAG,MAAM;IAuBlC,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAkB5D,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAazC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAKjC"}
@@ -0,0 +1,153 @@
1
+ import { ApprovalType, ExecutionType, Policy } from "../Models/Policy";
2
+ import BaseTideRequest from "../Models/BaseTideRequest";
3
+ import { StringFromUint8Array } from "../Cryptide/Serialization";
4
+ export class BaseContract {
5
+ /**
6
+ * Inheritors must implement this if the policy has set it's approvalType to EXPLICIT
7
+ * @param policy Policy object
8
+ * @param approverDokens Approver Dokens
9
+ */
10
+ validateApprovers(policy, approverDokens) {
11
+ throw `validateApprovers not implemented`;
12
+ }
13
+ /**
14
+ * Inheritors must implement this if the policy has set it's executionType to PRIVATE
15
+ * @param policy Policy object
16
+ * @param executorDoken Executor Doken
17
+ */
18
+ validateExecutor(policy, executorDoken) {
19
+ throw `validateExecutor not implemented`;
20
+ }
21
+ /**
22
+ * To help with clients testing if their Tide Request will pass their contract's specified contract
23
+ * @param policy Serialized policy from Tide
24
+ * @returns
25
+ */
26
+ async testPolicy(policy, executorDoken = null) {
27
+ const p = policy instanceof Uint8Array ? Policy.from(policy) : policy;
28
+ if (p.contractId !== this.id)
29
+ throw `Mismatch between policy provided's contract (${p.contractId}) and this contract's id (${this.id})`;
30
+ if (!p.modelIds.includes(this.tideRequest.id()) && p.modelIds[0] !== "any")
31
+ throw `Mismatch between policy provided model id (${p.modelIds}) and tide request id (${this.tideRequest.id()})`;
32
+ try {
33
+ await this.validateData(p);
34
+ if (p.approvalType == ApprovalType.EXPLICIT)
35
+ await this.validateApprovers(p, this.dokens);
36
+ if (p.executionType == ExecutionType.PRIVATE) {
37
+ if (!executorDoken)
38
+ throw `Policy as set it's execution type to PRIVATE. You must test this with the doken of the executor`;
39
+ await this.validateExecutor(p, new Doken(executorDoken));
40
+ }
41
+ return {
42
+ success: true
43
+ };
44
+ }
45
+ catch (ex) {
46
+ return {
47
+ success: false,
48
+ failed: ex
49
+ };
50
+ }
51
+ }
52
+ constructor(tideRequest) {
53
+ this.dokens = []; // change to Doken type
54
+ this.tideRequest = tideRequest instanceof Uint8Array ? BaseTideRequest.decode(tideRequest) : tideRequest;
55
+ this.authorizedRequestPayload = this.tideRequest.draft;
56
+ this.informationalRequestPayload = this.tideRequest.dyanmicData;
57
+ // deserialize dokens
58
+ let res = { result: new Uint8Array() };
59
+ let i = 0;
60
+ while (this.tideRequest.authorizer.TryGetValue(i, res)) {
61
+ this.dokens.push(new Doken(res.result));
62
+ i++;
63
+ }
64
+ }
65
+ }
66
+ export class Doken {
67
+ constructor(d) {
68
+ if (!d || d.length === 0) {
69
+ throw new Error('Doken constructor: received empty or null Uint8Array');
70
+ }
71
+ const tokenString = typeof d === "string" ? d : StringFromUint8Array(d);
72
+ const s = tokenString.split(".");
73
+ if (s.length !== 3) {
74
+ throw new Error(`Doken constructor: invalid token format. Expected 3 parts (header.payload.signature) but got ${s.length} parts in: "${tokenString.substring(0, 50)}..."`);
75
+ }
76
+ try {
77
+ const decodedPayload = base64UrlDecode(s[1]);
78
+ this.payload = JSON.parse(decodedPayload);
79
+ }
80
+ catch (error) {
81
+ throw new Error(`Doken constructor: failed to parse token payload. ${error instanceof Error ? error.message : String(error)}. Raw payload part: "${s[1].substring(0, 50)}..."`);
82
+ }
83
+ if (!this.payload || typeof this.payload !== 'object') {
84
+ throw new Error(`Doken constructor: parsed payload is not a valid object. Got type: ${typeof this.payload}`);
85
+ }
86
+ }
87
+ hasResourceAccessRole(role, client) {
88
+ if (!role)
89
+ throw new Error('hasResourceAccessRole: role parameter is empty or undefined');
90
+ if (!client)
91
+ throw new Error('hasResourceAccessRole: client parameter is empty or undefined');
92
+ if (!this.payload.resource_access) {
93
+ return false;
94
+ }
95
+ if (!this.payload.resource_access[client]) {
96
+ return false;
97
+ }
98
+ if (!Array.isArray(this.payload.resource_access[client].roles)) {
99
+ return false;
100
+ }
101
+ return this.payload.resource_access[client].roles.includes(role);
102
+ }
103
+ hasRealmAccessRole(role) {
104
+ if (!role)
105
+ throw new Error('hasRealmAccessRole: role parameter is empty or undefined');
106
+ if (!this.payload.realm_access) {
107
+ return false;
108
+ }
109
+ if (!Array.isArray(this.payload.realm_access.roles)) {
110
+ return false;
111
+ }
112
+ return this.payload.realm_access.roles.includes(role);
113
+ }
114
+ hasVuid(vuid) {
115
+ if (!vuid)
116
+ throw new Error('hasVuid: vuid cannot be null');
117
+ if (!this.payload.vuid)
118
+ throw new Error("hasVuid: cannot find vuid in paylod");
119
+ return this.payload.vuid === vuid;
120
+ }
121
+ }
122
+ function base64UrlDecode(input) {
123
+ let output = input
124
+ .replaceAll("-", "+")
125
+ .replaceAll("_", "/");
126
+ switch (output.length % 4) {
127
+ case 0:
128
+ break;
129
+ case 2:
130
+ output += "==";
131
+ break;
132
+ case 3:
133
+ output += "=";
134
+ break;
135
+ default:
136
+ throw new Error("Input is not of the correct length.");
137
+ }
138
+ try {
139
+ return b64DecodeUnicode(output);
140
+ }
141
+ catch (error) {
142
+ return atob(output);
143
+ }
144
+ }
145
+ function b64DecodeUnicode(input) {
146
+ return decodeURIComponent(atob(input).replace(/(.)/g, (m, p) => {
147
+ let code = p.charCodeAt(0).toString(16).toUpperCase();
148
+ if (code.length < 2) {
149
+ code = "0" + code;
150
+ }
151
+ return "%" + code;
152
+ }));
153
+ }
@@ -0,0 +1,8 @@
1
+ import { Policy } from "../Models/Policy";
2
+ import { BaseContract, Doken } from "./BaseContract";
3
+ export declare class GenericRealmAccessThresholdRoleContract extends BaseContract {
4
+ protected validateData(policy: Policy): Promise<void>;
5
+ id: string;
6
+ protected validateApprovers(policy: Policy, approverDokens: Doken[]): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=GenericRealmAccessThresholdRoleContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericRealmAccessThresholdRoleContract.d.ts","sourceRoot":"","sources":["../../Contracts/GenericRealmAccessThresholdRoleContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErD,qBAAa,uCAAwC,SAAQ,YAAY;IACrE,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,EAAE,EAAE,MAAM,CAAuC;cACxC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ5F"}
@@ -0,0 +1,21 @@
1
+ import { BaseContract } from "./BaseContract";
2
+ export class GenericRealmAccessThresholdRoleContract extends BaseContract {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.id = "GenericRealmAccessThresholdRole:1";
6
+ }
7
+ validateData(policy) {
8
+ console.warn("Validate Data not implemented!");
9
+ return;
10
+ }
11
+ async validateApprovers(policy, approverDokens) {
12
+ let successfulDokens = 0;
13
+ approverDokens.forEach(d => {
14
+ if (d.hasRealmAccessRole(policy.params.getParameter("role")))
15
+ successfulDokens++;
16
+ });
17
+ const threshold = policy.params.getParameter("threshold");
18
+ if (successfulDokens < threshold)
19
+ throw 'Not enough successful dokens with requires roles/clients';
20
+ }
21
+ }
@@ -0,0 +1,8 @@
1
+ import { Policy } from "../Models/Policy";
2
+ import { BaseContract, Doken } from "./BaseContract";
3
+ export declare class GenericResourceAccessThresholdRoleContract extends BaseContract {
4
+ id: string;
5
+ protected validateData(policy: Policy): Promise<void>;
6
+ protected validateApprovers(policy: Policy, approverDokens: Doken[]): Promise<void>;
7
+ }
8
+ //# sourceMappingURL=GenericResourceAccessThresholdRoleContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericResourceAccessThresholdRoleContract.d.ts","sourceRoot":"","sources":["../../Contracts/GenericResourceAccessThresholdRoleContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErD,qBAAa,0CAA2C,SAAQ,YAAY;IACjE,EAAE,EAAE,MAAM,CAA0C;IAC3D,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;cAIrC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ5F"}
@@ -0,0 +1,21 @@
1
+ import { BaseContract } from "./BaseContract";
2
+ export class GenericResourceAccessThresholdRoleContract extends BaseContract {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.id = "GenericResourceAccessThresholdRole:1";
6
+ }
7
+ validateData(policy) {
8
+ console.warn("Validate Data not implemented!");
9
+ return;
10
+ }
11
+ async validateApprovers(policy, approverDokens) {
12
+ let successfulDokens = 0;
13
+ approverDokens.forEach(d => {
14
+ if (d.hasResourceAccessRole(policy.params.getParameter("role"), policy.params.getParameter("resource")))
15
+ successfulDokens++;
16
+ });
17
+ const threshold = policy.params.getParameter("threshold");
18
+ if (successfulDokens < threshold)
19
+ throw 'Not enough successful dokens with requires roles/clients';
20
+ }
21
+ }
@@ -0,0 +1,4 @@
1
+ export { BaseContract, Doken } from './BaseContract';
2
+ export { GenericRealmAccessThresholdRoleContract } from './GenericRealmAccessThresholdRoleContract';
3
+ export { GenericResourceAccessThresholdRoleContract } from './GenericResourceAccessThresholdRoleContract';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Contracts/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AACpG,OAAO,EAAE,0CAA0C,EAAE,MAAM,8CAA8C,CAAC"}
@@ -0,0 +1,19 @@
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 { BaseContract, Doken } from './BaseContract';
18
+ export { GenericRealmAccessThresholdRoleContract } from './GenericRealmAccessThresholdRoleContract';
19
+ export { GenericResourceAccessThresholdRoleContract } from './GenericResourceAccessThresholdRoleContract';
@@ -0,0 +1,56 @@
1
+ export declare class BaseComponent {
2
+ constructor();
3
+ static Name: any;
4
+ static Version: any;
5
+ Add(component: any): BaseComponent;
6
+ Multiply(component: any): BaseComponent;
7
+ Minus(component: any): BaseComponent;
8
+ Equals(component: any): never;
9
+ Mod(): BaseComponent;
10
+ ModInv(): BaseComponent;
11
+ AddComponent(component: any): void;
12
+ MultiplyComponent(component: any): void;
13
+ MinusComponent(component: any): void;
14
+ EqualsComponent(component: any): void;
15
+ ModComponent(): void;
16
+ ModInvComponent(): void;
17
+ SerializeComponent(): Uint8Array;
18
+ /**@returns {BaseScheme} */
19
+ get Scheme(): any;
20
+ /**@returns {string} */
21
+ get ComponentType(): string;
22
+ Serialize(): SerializedComponent;
23
+ static DeserializeComponent(serialized: Uint8Array | string): BaseComponent;
24
+ }
25
+ export declare class BaseSeedComponent extends BaseComponent {
26
+ get ComponentType(): string;
27
+ static New(): void;
28
+ GetPublic(): BasePublicComponent;
29
+ GetPrivate(): BasePrivateComponent;
30
+ get rawBytes(): Uint8Array;
31
+ }
32
+ export declare class BasePrivateComponent extends BaseComponent {
33
+ get ComponentType(): string;
34
+ static New(): void;
35
+ GetPublic(): BasePublicComponent;
36
+ get priv(): bigint;
37
+ get rawBytes(): Uint8Array;
38
+ }
39
+ export declare class BasePublicComponent extends BaseComponent {
40
+ get ComponentType(): string;
41
+ get public(): any;
42
+ }
43
+ export declare class SerializedComponent {
44
+ Bytes: any;
45
+ ComponentType: any;
46
+ constructor(bytes: Uint8Array, compentType: string);
47
+ ToBytes(): any;
48
+ ToString(): string;
49
+ }
50
+ export declare const Seed = "Seed";
51
+ export declare const Private = "Private";
52
+ export declare const Public = "Public";
53
+ export declare const Symmetric = "Symmetric";
54
+ export declare const QuantumPrivate = "QuantumPrivate";
55
+ export declare const QuantumPublic = "QuantumPublic";
56
+ //# sourceMappingURL=BaseComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseComponent.d.ts","sourceRoot":"","sources":["../../../Cryptide/Components/BaseComponent.ts"],"names":[],"mappings":"AAsBA,qBAAa,aAAa;;IAEtB,MAAM,CAAC,IAAI,EAAE,GAAG,CAAiD;IACjE,MAAM,CAAC,OAAO,EAAE,GAAG,CAAoD;IAEvE,GAAG,CAAC,SAAS,KAAA;IAOb,QAAQ,CAAC,SAAS,KAAA;IAOlB,KAAK,CAAC,SAAS,KAAA;IAOf,MAAM,CAAC,SAAS,KAAA;IAOhB,GAAG;IAKH,MAAM;IAMN,YAAY,CAAC,SAAS,KAAA;IACtB,iBAAiB,CAAC,SAAS,KAAA;IAC3B,cAAc,CAAC,SAAS,KAAA;IACxB,eAAe,CAAC,SAAS,KAAA;IACzB,YAAY;IACZ,eAAe;IACf,kBAAkB,IAAI,UAAU;IAChC,2BAA2B;IAC3B,IAAI,MAAM,IAAI,GAAG,CAAoC;IACrD,uBAAuB;IACvB,IAAI,aAAa,IAAI,MAAM,CAAoC;IAE/D,SAAS,IAAI,mBAAmB;IAYhC,MAAM,CAAC,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,GAAG,aAAa;CAoB9E;AAED,qBAAa,iBAAkB,SAAQ,aAAa;IAChD,IAAI,aAAa,WAAmB;IACpC,MAAM,CAAC,GAAG;IACV,SAAS,IAAI,mBAAmB;IAChC,UAAU,IAAI,oBAAoB;IAClC,IAAI,QAAQ,IAAI,UAAU,CAAoC;CACjE;AAED,qBAAa,oBAAqB,SAAQ,aAAa;IACnD,IAAI,aAAa,WAAsB;IACvC,MAAM,CAAC,GAAG;IACV,SAAS,IAAI,mBAAmB;IAChC,IAAI,IAAI,IAAI,MAAM,CAAoC;IACtD,IAAI,QAAQ,IAAI,UAAU,CAAoC;CACjE;AAED,qBAAa,mBAAoB,SAAQ,aAAa;IAClD,IAAI,aAAa,WAAqB;IACtC,IAAI,MAAM,IAAI,GAAG,CAAoC;CACxD;AAED,qBAAa,mBAAmB;IAC5B,KAAK,MAAC;IACN,aAAa,MAAC;gBAEF,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM;IAKlD,OAAO;IAGP,QAAQ;CAkBX;AAUD,eAAO,MAAM,IAAI,SAAS,CAAC;AAC3B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,aAAa,kBAAkB,CAAC"}