asgard-tide 0.12.42 → 0.12.45

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 (96) hide show
  1. package/LICENSE +334 -0
  2. package/README.md +103 -2
  3. package/dist/cjs/contracts/BaseContract.d.ts +47 -0
  4. package/dist/cjs/contracts/BaseContract.d.ts.map +1 -0
  5. package/dist/{contracts → cjs/contracts}/BaseContract.js +39 -11
  6. package/dist/cjs/contracts/BaseContract.js.map +1 -0
  7. package/dist/{contracts → cjs/contracts}/GenericRealmAccessThresholdRoleContract.d.ts +3 -2
  8. package/dist/cjs/contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +1 -0
  9. package/dist/{contracts → cjs/contracts}/GenericRealmAccessThresholdRoleContract.js +6 -2
  10. package/dist/cjs/contracts/GenericRealmAccessThresholdRoleContract.js.map +1 -0
  11. package/dist/{contracts → cjs/contracts}/GenericResourceAccessThresholdRoleContract.d.ts +3 -2
  12. package/dist/cjs/contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +1 -0
  13. package/dist/{contracts → cjs/contracts}/GenericResourceAccessThresholdRoleContract.js +6 -2
  14. package/dist/cjs/contracts/GenericResourceAccessThresholdRoleContract.js.map +1 -0
  15. package/dist/cjs/index.d.ts +15 -0
  16. package/dist/cjs/index.d.ts.map +1 -0
  17. package/dist/{index.js → cjs/index.js} +7 -3
  18. package/dist/cjs/index.js.map +1 -0
  19. package/dist/cjs/models/CustomTideRequest.d.ts +19 -0
  20. package/dist/cjs/models/CustomTideRequest.d.ts.map +1 -0
  21. package/dist/cjs/models/CustomTideRequest.js +40 -0
  22. package/dist/cjs/models/CustomTideRequest.js.map +1 -0
  23. package/dist/{models → cjs/models}/Policy.d.ts +17 -2
  24. package/dist/cjs/models/Policy.d.ts.map +1 -0
  25. package/dist/{models → cjs/models}/Policy.js +126 -29
  26. package/dist/cjs/models/Policy.js.map +1 -0
  27. package/dist/cjs/models/TideRequest.d.ts.map +1 -0
  28. package/dist/{models → cjs/models}/TideRequest.js +1 -1
  29. package/dist/cjs/models/TideRequest.js.map +1 -0
  30. package/dist/cjs/utils/Serialization.d.ts.map +1 -0
  31. package/dist/cjs/utils/Serialization.js.map +1 -0
  32. package/dist/cjs/utils/TideMemory.d.ts.map +1 -0
  33. package/dist/cjs/utils/TideMemory.js.map +1 -0
  34. package/dist/esm/contracts/BaseContract.d.ts +47 -0
  35. package/dist/esm/contracts/BaseContract.d.ts.map +1 -0
  36. package/dist/esm/contracts/BaseContract.js +154 -0
  37. package/dist/esm/contracts/BaseContract.js.map +1 -0
  38. package/dist/esm/contracts/GenericRealmAccessThresholdRoleContract.d.ts +8 -0
  39. package/dist/esm/contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +1 -0
  40. package/dist/esm/contracts/GenericRealmAccessThresholdRoleContract.js +22 -0
  41. package/dist/esm/contracts/GenericRealmAccessThresholdRoleContract.js.map +1 -0
  42. package/dist/esm/contracts/GenericResourceAccessThresholdRoleContract.d.ts +8 -0
  43. package/dist/esm/contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +1 -0
  44. package/dist/esm/contracts/GenericResourceAccessThresholdRoleContract.js +22 -0
  45. package/dist/esm/contracts/GenericResourceAccessThresholdRoleContract.js.map +1 -0
  46. package/dist/esm/index.d.ts +15 -0
  47. package/dist/esm/index.d.ts.map +1 -0
  48. package/dist/{index.d.ts → esm/index.js} +5 -5
  49. package/dist/esm/index.js.map +1 -0
  50. package/dist/esm/models/CustomTideRequest.d.ts +19 -0
  51. package/dist/esm/models/CustomTideRequest.d.ts.map +1 -0
  52. package/dist/esm/models/CustomTideRequest.js +31 -0
  53. package/dist/esm/models/CustomTideRequest.js.map +1 -0
  54. package/dist/esm/models/Policy.d.ts +41 -0
  55. package/dist/esm/models/Policy.d.ts.map +1 -0
  56. package/dist/esm/models/Policy.js +263 -0
  57. package/dist/esm/models/Policy.js.map +1 -0
  58. package/dist/esm/models/TideRequest.d.ts +48 -0
  59. package/dist/esm/models/TideRequest.d.ts.map +1 -0
  60. package/dist/esm/models/TideRequest.js +252 -0
  61. package/dist/esm/models/TideRequest.js.map +1 -0
  62. package/dist/esm/utils/Serialization.d.ts +7 -0
  63. package/dist/esm/utils/Serialization.d.ts.map +1 -0
  64. package/dist/esm/utils/Serialization.js +98 -0
  65. package/dist/esm/utils/Serialization.js.map +1 -0
  66. package/dist/esm/utils/TideMemory.d.ts +10 -0
  67. package/dist/esm/utils/TideMemory.d.ts.map +1 -0
  68. package/dist/esm/utils/TideMemory.js +106 -0
  69. package/dist/esm/utils/TideMemory.js.map +1 -0
  70. package/package.json +14 -5
  71. package/dist/contracts/BaseContract.d.ts +0 -30
  72. package/dist/contracts/BaseContract.d.ts.map +0 -1
  73. package/dist/contracts/BaseContract.js.map +0 -1
  74. package/dist/contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +0 -1
  75. package/dist/contracts/GenericRealmAccessThresholdRoleContract.js.map +0 -1
  76. package/dist/contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +0 -1
  77. package/dist/contracts/GenericResourceAccessThresholdRoleContract.js.map +0 -1
  78. package/dist/index.d.ts.map +0 -1
  79. package/dist/index.js.map +0 -1
  80. package/dist/models/CustomTideRequest.d.ts +0 -16
  81. package/dist/models/CustomTideRequest.d.ts.map +0 -1
  82. package/dist/models/CustomTideRequest.js +0 -55
  83. package/dist/models/CustomTideRequest.js.map +0 -1
  84. package/dist/models/Policy.d.ts.map +0 -1
  85. package/dist/models/Policy.js.map +0 -1
  86. package/dist/models/TideRequest.d.ts.map +0 -1
  87. package/dist/models/TideRequest.js.map +0 -1
  88. package/dist/utils/Serialization.d.ts.map +0 -1
  89. package/dist/utils/Serialization.js.map +0 -1
  90. package/dist/utils/TideMemory.d.ts.map +0 -1
  91. package/dist/utils/TideMemory.js.map +0 -1
  92. /package/dist/{models → cjs/models}/TideRequest.d.ts +0 -0
  93. /package/dist/{utils → cjs/utils}/Serialization.d.ts +0 -0
  94. /package/dist/{utils → cjs/utils}/Serialization.js +0 -0
  95. /package/dist/{utils → cjs/utils}/TideMemory.d.ts +0 -0
  96. /package/dist/{utils → cjs/utils}/TideMemory.js +0 -0
package/LICENSE ADDED
@@ -0,0 +1,334 @@
1
+ Tide Community Open Code License
2
+
3
+ Preamble:
4
+ The Tide Community Open Code License is a copyright License for
5
+ software and other kinds of works designed to encourage the adoption
6
+ of the Tide Protocol. The aim of the Tide Protocol is to be the technological
7
+ infrastructure of a true zero-trust paradigm, addressing the data-breach
8
+ protection needs of platform vendors and their customers, the
9
+ self-sovereign authority needs of online users, and replace the reliance
10
+ on blind trust with proofs.
11
+
12
+ To that end, the Tide Community Open Code License gives you the
13
+ freedom to modify and distribute copies of software and other works
14
+ for free, or for a fee, as long as you do so in accordance with these
15
+ terms and the software adopts the Tide Protocol in full.
16
+
17
+ License Terms
18
+ Version: 2
19
+ Date of last revision: 1 December 2022
20
+
21
+ 1 Acceptance of these terms
22
+ (a) These terms are between the copyright holder (“we”, “us” and
23
+ “our”) identified in the notice embedded in or provided with
24
+ the source code, technical documentation or other material
25
+ relating to the Tide Foundation Limited’s (ACN 630 011 371)
26
+ (“Tide”) data decryption and key management platform
27
+ known as the “Tide Protocol” (“Tide Protocol”) and with which
28
+ these terms are packaged (“Materials”) and the person or
29
+ entity (“you” and “your”) accessing and/or using the Materials.
30
+ (b) By using, modifying or publishing the Materials or any Modified
31
+ Materials (as defined in clause 2(c) below), you agree to be
32
+ bound by these terms. If you are doing any of the foregoing in
33
+ the context of your employment with your employer or on behalf
34
+ of another entity, you are agreeing to be bound by these terms
35
+ on behalf of that employer or other entity and you represent
36
+ and warrant that you have the authority of that employer or
37
+ other entity to enter into these terms on their behalf. In such
38
+ circumstances, each reference in these terms “you” or “your”
39
+ includes that employer or other entity.
40
+ (c) These terms will remain in effect until terminated under
41
+ clause 9.
42
+
43
+ 2 Intellectual property rights
44
+ (a) In these terms, “Intellectual Property Rights” means all
45
+ intellectual property rights of whatever nature throughout the
46
+ world, including all rights conferred under statute, common
47
+ law or equity, whether existing now or at any time in the
48
+ future, including all rights in and to any patents, patent
49
+ applications, business names, trade names, domain names, trade
50
+ marks, copyright, trade secrets, circuit layout rights,
51
+ designs, confidential information, know-how, technical
52
+ information, data or developments. All of our Intellectual
53
+ Property Rights are protected by the laws in force in
54
+ Australia from time to time.
55
+ (b) You acknowledge and agree that we (or our licensors) retain all
56
+ right, title, and interest (including all Intellectual Property
57
+ Rights) in and to the Materials, and nothing you do with or in
58
+ relation to the Materials will transfer any right, title or
59
+ interest (including Intellectual Property Rights) to you or
60
+ License or otherwise permit you to exercise any Intellectual
61
+ Property Rights except as expressly granted under these terms.
62
+ (c) In these terms, “Modified Materials” means any work based on
63
+ one or more of the Materials, including a revision,
64
+ modification, adaptation, subset, addition, enhancement,
65
+ improvement, combination, translation, abridgment,
66
+ condensation, expansion, collection, compilation or any other
67
+ form in which such Materials may be recast, transformed or
68
+ adapted or any other new material derived from the Materials.
69
+
70
+ 3 Your License to the Materials
71
+ (a) Subject to paragraph (c) below and your compliance with these
72
+ terms, we grant you a limited, non-exclusive,
73
+ non-sub-licensable, revocable, worldwide, royalty free License
74
+ for the term of these terms to access, use, copy, modify,
75
+ adapt, distribute, publish and exploit the Materials, provided
76
+ that such License is exercised:
77
+ (i) solely in connection with the adoption and use of the
78
+ Tide Protocol;
79
+ (ii) solely in a manner which requires any payment or
80
+ exchange of value to be made via Tide Tokens (as
81
+ defined in paragraph (c) below); and
82
+ (iii) in accordance with clause 6 and on these terms in
83
+ respect of the right to distribute and publish the
84
+ Materials and Modified Materials.
85
+ The foregoing rights to distribute, publish and exploit the
86
+ Materials include the right to do so for a fee and applies
87
+ in respect of the Materials and the Modified Materials.
88
+ (b) Any access, use, copy, modification, adaptation, distribution,
89
+ publication or exploitation of any of the Materials for use
90
+ with applications that do not fully use, adopt and implement
91
+ the Tide Protocol is prohibited. This prohibition includes any
92
+ use or adaptation of the Materials for the purposes of any
93
+ protocol, system or platform competing with the Tide Protocol
94
+ or which facilitates any form of payment or exchange of value
95
+ other than through use of Tide Tokens (as defined in paragraph
96
+ (c) below).
97
+ (c) Without limiting paragraph (b), the License granted under
98
+ paragraph (a) does not permit you to, and in exercising the
99
+ rights granted to you under paragraph (a) you must not, under
100
+ any circumstances:
101
+ (i) remove, omit or in any way modify any component of the
102
+ Materials, including source code components, which
103
+ requires payment or exchange of value to be made via
104
+ Tide cryptographic tokens designed for settling
105
+ transactions entered into via the Tide Protocol (“Tide
106
+ Tokens”);
107
+ (ii) use the Materials which are source code or object code:
108
+ (A) in combination with any other code, script or
109
+ software (whether in source or object code form),
110
+ or otherwise in any manner, which would in any way
111
+ circumvent the requirement for any payment or
112
+ exchange of value to be made via Tide Tokens; or
113
+ (B) in any other way which does not properly use, adopt
114
+ and implement the Tide Protocol in its entirety,
115
+ including for the purposes of both data decryption
116
+ and key management;
117
+ (iii) violate any applicable laws or any rights of any person,
118
+ or use or permit or facilitate the use of the Materials
119
+ in any manner or for any purpose that is unlawful or is
120
+ in breach of any laws of jurisdiction anywhere in the
121
+ world;
122
+ (iv) distribute viruses, spyware, corrupted files, or any
123
+ other similar software or programs that may damage the
124
+ operation of any computer hardware or software, or the
125
+ Tide Protocol; or
126
+ (v) engage in any other conduct that is improper or brings
127
+ or is likely to bring us, the Materials, the Tide
128
+ Protocol or Tide Tokens into disrepute,
129
+ and you must ensure that where any third party is being engaged
130
+ to make modifications to the Materials on your behalf, their
131
+ rights to do so are subject to terms which incorporate the
132
+ restrictions in this clause 3.
133
+ (d) You must take your own precautions to ensure that the processes
134
+ which you employ for accessing and using the Materials do not
135
+ expose you to the risk of viruses, malicious computer code or
136
+ other forms of interference which may damage your computer
137
+ systems. We recommend that you install and use up-to-date
138
+ anti-virus, anti-spyware and firewall software on your computer
139
+ systems.
140
+
141
+ 4 Data security and privacy
142
+ You are fully responsible for ensuring:
143
+ (a) any use, adoption or implementation of the Materials, any
144
+ Modified Materials and/or the Tide Protocol appropriately
145
+ protects, encrypts and stores data; and
146
+ (b) all aspects of compliance with privacy and data protection laws.
147
+ We disclaim all warranties and liability regarding the same.
148
+
149
+ 5 Modification of Tide Protocol and Materials
150
+ You acknowledge that Tide may at any time without notice to you change
151
+ or update the whole or any part of the Tide Protocol and/or any of the
152
+ Materials, including in a manner which may result in applications or
153
+ processes you may have developed or implemented no longer being
154
+ compatible or otherwise working in the same manner with the Tide
155
+ Protocol or any Material, including any software development kit. We
156
+ may also withdraw or remove any part of the Materials or the Tide
157
+ Protocol at any stage without notice to you.
158
+
159
+ 6 Distribution
160
+ (a) Without limiting clause 3, in exercising the rights granted to
161
+ you under clause 3(a) to distribute or publish one or more
162
+ copies of any Materials verbatim as you receive the Materials,
163
+ you may do so in any medium, provided that:
164
+ (i) you provide all recipients of the Materials with a copy of
165
+ these terms along with the Materials:
166
+ (ii) you keep intact and do not remove, omit, or in any way
167
+ modify any of the following:
168
+ (A) any notices stating that these License terms apply;
169
+ (B) any hyperlink to these License terms; and
170
+ (C) any notices of the absence of any warranty;
171
+ (b) You may charge any price or no price for each copy of the
172
+ Materials or Modified Materials that you distribute or publish,
173
+ and you may offer support or warranty protection for a fee.
174
+ (c) Without limiting clause 3, in exercising the rights granted to
175
+ you under clause 3(a) to distribute or publish one or more
176
+ copies of any Modified Materials you create or cause to be
177
+ created, you may do so in any medium, provided that:
178
+ (i) you provide all recipients of the Modified Materials with
179
+ a copy of these terms along with the Modified Materials;
180
+ (ii) you keep intact and do not remove, omit, or in any way
181
+ modify any of the following:
182
+ (A) any notices stating that these License terms apply to
183
+ the unmodified Materials;
184
+ (B) any hyperlink to these License terms; and
185
+ (C) any notices of the absence of any warranty in respect
186
+ of the unmodified Materials; and
187
+ (iii) the whole of any Modified Materials must be licensed under
188
+ these terms (although this does not limit the operation of
189
+ paragraph (d)), but you may impose further restrictions
190
+ that do not conflict with or override these terms.
191
+ (d) Where you compile any source code Materials or Modified
192
+ Materials in an aggregate with any proprietary program, the
193
+ Materials remain governed by these License terms. For the
194
+ purposes of the foregoing, a compilation of any Materials with
195
+ other separate and independent works, which are not by their
196
+ nature extensions of the Materials, and which are not combined
197
+ with the Materials such as to form a larger program, in or on
198
+ a volume of a storage or distribution medium, is an “aggregate”
199
+ if the compilation and its resulting copyright are not used to
200
+ limit the access or legal rights of the compilation's users
201
+ beyond what the individual Materials permit. Inclusion of any
202
+ Materials in an aggregate does not cause these terms to apply
203
+ to the other parts of the aggregate.
204
+ (e) You may not initiate any proceedings or claims in respect of
205
+ infringement of any patent rights in respect of the access,
206
+ use, copy, modification, adaptation, distribution, publication
207
+ or exploitation of any of the Materials or Modified Materials
208
+ in accordance with these terms.
209
+
210
+ 7 Liability
211
+ (a) All express or implied guarantees, warranties, representations,
212
+ statements, terms or conditions relating to these terms or the
213
+ Materials that are not contained in these terms, are excluded
214
+ to the maximum extent permitted by law. Without limiting the
215
+ foregoing:
216
+ (i) the Materials are provided ‘as-is’ and neither we nor Tide
217
+ warrant or represent that they will work in any way, that
218
+ they are fit for any particular purpose, that your
219
+ requirements will be met, that your use of the Materials
220
+ will be uninterrupted or error free or that the Materials
221
+ are free of viruses or other harmful components; and
222
+ (ii) we and Tide are not responsible for any loss, corruption or
223
+ interception of data which occurs in connection with your
224
+ use or misuse of the Materials.
225
+ (b) Nothing in these terms excludes, restricts or modifies any
226
+ guarantee, term, condition, warranty, or any right or remedy,
227
+ implied or imposed by any law which cannot lawfully be excluded
228
+ or limited. (a “Non-Excludable Provision”). If any guarantee,
229
+ term, condition or warranty is implied into these terms under a
230
+ Non-Excludable Provision and we or Tide can limit your remedy
231
+ for a breach of the Non-Excludable Provision, then our and
232
+ Tide’s liability for breach of the Non-Excludable Provision is
233
+ limited to one or more of the following at our option:
234
+ (i) in the case of goods, the replacement of the goods or the
235
+ supply of equivalent goods, the repair of the goods, the
236
+ payment of the cost of replacing the goods or of acquiring
237
+ equivalent goods, or the payment of the cost of having the
238
+ goods repaired; or
239
+ (ii) in the case of services, the supplying of the services
240
+ again, or the payment of the cost of having the services
241
+ supplied again.
242
+ (c) To the maximum extent permitted by law but despite any other
243
+ clause in these terms, your use of the Materials is at your own
244
+ risk and neither we nor Tide are liable to you for any loss or
245
+ damage you (or any of your representatives or sub-licensees)
246
+ suffer, sustain or incur in connection with these terms,
247
+ exercise of any rights granted under these terms or otherwise
248
+ in connection with any access or use of the Materials, including
249
+ in respect of any loss, corruption or interception of data or
250
+ breach of privacy or security.
251
+ (d) Without limiting paragraph (c), to the maximum extent permitted
252
+ by law, neither we nor Tide are not liable to you for and no
253
+ measure of damages will under any circumstances include:
254
+ (i) special, indirect, consequential, incidental or punitive
255
+ damages; or
256
+ (ii) damages for loss of profits, revenue, goodwill,
257
+ opportunity, anticipated savings or loss or corruption of
258
+ data.
259
+ (e) The exclusions and limitations of liability in this clause 8
260
+ apply regardless of the basis on which such liability arises,
261
+ whether in contract, breach of warranty, tort (including
262
+ negligence), in equity, under statute, under an indemnity or
263
+ on any other basis.
264
+ (f) You will indemnify us and hold us, Tide and each of our
265
+ directors, officers, employees and contractors harmless from
266
+ and against any loss suffered or incurred by us or any of
267
+ those indemnified, arising out of or in connection with:
268
+ (i) your or any of your sub-licensee’s access or use of any of
269
+ the Materials or any other exercise of any of the rights
270
+ granted to you under these terms in connection with any of
271
+ the Materials;
272
+ (ii) your negligence or breach of these terms;
273
+ (iii) your violation of any applicable law or infringement of any
274
+ rights (including Intellectual Property Rights) of a third
275
+ party; or
276
+ (iv) any claim made by any third party arising out of or in
277
+ connection with any Modified Materials, including any
278
+ application developed using any of the Materials, and
279
+ including in respect of infringement of any person’s
280
+ Intellectual Property Rights.
281
+ 8 Termination
282
+ (a) Your License to use the Materials under clause 3(a) immediately
283
+ and automatically terminates without the need for us to give
284
+ notice to you if you breach these terms.
285
+ (b) You may terminate these terms at any time by ceasing all use
286
+ and removing all implementations of the Materials and the Tide
287
+ Protocol.
288
+ (c) Upon termination of these terms, all rights and Licenses
289
+ granted to you under these terms will also terminate and you
290
+ must immediately cease using the Materials and remove all
291
+ implementations of the Materials.
292
+ 9 General
293
+ (a) You remain fully responsible and liable for the acts and
294
+ omissions of any third party to whom you subcontract the
295
+ exercise or performance any of your rights or obligations under
296
+ these terms, as if such acts and omissions were your acts and
297
+ omissions.
298
+ (b) If any part of these terms is held to be unenforceable, the
299
+ unenforceable part is to be given effect to the greatest extent
300
+ possible and the remainder will remain in full force and effect.
301
+ (c) No waiver, delay or failure by us to take any action shall
302
+ constitute or be construed as a waiver of that or any other term,
303
+ condition, option, privilege or right we may have.
304
+ (d) The word “including” when used in these terms is not a term of
305
+ limitation.
306
+
307
+ ====================
308
+ End of License terms
309
+ ====================
310
+
311
+ If you develop a Modified Material and want to assert your copyright,
312
+ attach the following notices to the Modified Material. It is best to
313
+ attach them to the start of each source file to most effectively state
314
+ the exclusion of warranty and each file should have at least the
315
+ “copyright” line and a pointer to where the full notice is found.
316
+
317
+ <INSERT PROGRAM NAME and PURPOSE.>
318
+
319
+ Copyright (c) <year> <name of author>
320
+
321
+ This program is free software and is subject to the terms of the Tide
322
+ Community Open Code License as published by the Tide Foundation
323
+ Limited. You may modify it and redistribute it in accordance with
324
+ and subject to the terms of that License.
325
+
326
+ This program is distributed WITHOUT WARRANTY of any kind, including
327
+ without any implied warranty of MERCHANTABILITY or FITNESS FOR A
328
+ PARTICULAR PURPOSE. See the Tide Community Open Code License for
329
+ more details.
330
+
331
+ You should have received a copy of the Tide Community Open Code
332
+ License along with this program.
333
+
334
+ If not, see https://tide.org/licenses_tcoc2-0-0-en
package/README.md CHANGED
@@ -1,2 +1,103 @@
1
- # asgard
2
- Vendor server-side libraries to validate and test Tide Security
1
+ # Asgard
2
+ Vendor server-side libraries to validate and test Tide Security.
3
+
4
+ ## Quick overview of Tide specific terminologies
5
+ ### Tide Request
6
+ The data object used to communicate with the Tide Network. All information regarding the context of what you want to execute is provided inside this object.
7
+ Fields of is object include request name, id, authorization flow requested, authorized data, informational data etc.
8
+ ### Policies and Contracts
9
+ Together, policies and contracts create a rule system designed by you, enforced by the Tide Network.
10
+ Think of a contract as the function used to validate a request, and a policy as the parameters to that function.
11
+
12
+ Pseudocode example of policies + contracts:
13
+ ```js
14
+ // You create the policy
15
+ your_policy = {
16
+ max_btc_to_send: 5,
17
+ time_of_day_allowed: "between 10am and 4pm"
18
+ }
19
+
20
+ // You upload your own contract, or use one provided by the Network
21
+ function your_contract_validate_func(policy){
22
+ check current time is in policy.time_of_day_allowed
23
+ check tx to sign is sending less than policy.max_btc_to_send
24
+ return success
25
+ }
26
+
27
+ // The network enforces your policy
28
+ if your_contract_validate_func(your_policy) is success {
29
+ execute request
30
+ }
31
+ ```
32
+
33
+ ## Policies
34
+ A policy is a data object that contains a set of parameters which validate a specific tide request against a contract.
35
+
36
+ ### Policy Structure
37
+ A policy consists of a couple fields:
38
+ - `contractId` : The contract id that your policy is meant to execute against.
39
+ - `modelId` : The model id (request type) your policy/contract will validate the contents of. Could be Cardano Transaction, code signing, token signature etc.
40
+ - `keyId` : Your vendor id
41
+ - `approvalType`: Either set to `explicit` or `implicit`. Set to `explicit` if you require the user(s) to manually approve the use of the policy with a request, or set to `implicit` if you don't require the user to manually approve its use, thus allowing its use without the user of the policy knowing.
42
+ - `executionType`: Either set to `public` or `private`. Set ot `public` if you'd like anyone to be able to execute and retrieve the contents of the request. Or set to `private` if specific conditions for the user executing the request must be met (**logic set in contract**).
43
+ - `params` : A key/value map of the specific values your contract requires to validate the contents of the request. This is what gets enforced by your contract onto the request.
44
+ - `signature` : The signature of the policy from your vendor key. This is required to use a policy on the Tide Network.
45
+
46
+ Creating a policy:
47
+ ```js
48
+ const policyParameters = new Map();
49
+ policyParameters.set("myNumberParam", 1);
50
+ policyParameters.set("myStringParam", "test");
51
+ policyParameters.set("myBigIntParam", BigInt(2));
52
+ policyParameters.set("myBooleanParam", true);
53
+ policyParameters.set("myByteArrayParam", new Uint8Array([0, 2, 1, 3]));
54
+
55
+ const policy = new Policy({
56
+ modelId: "<model id to use with this policy>",
57
+ contractId: "<contract id to use with this policy>",
58
+ keyId: "<your vendor id>",
59
+ approvalType: "explicit",
60
+ executionType: "public",
61
+ params: policyParameters
62
+ });
63
+ ```
64
+
65
+ ### Creating a policy for your organization
66
+ Any policy you create will create a linkage between either a single Tide Request and a single Contract - or any Tide Request and a single Contract.
67
+
68
+ The relationship betweent the contract, policy and tide request is as follows:
69
+ 1. Contract contains the logic to check policy parameters against a tide request. Contract logic sits on the network's nodes.
70
+ 2. The policy contains the actual values the contract will check the tide request against. Policies sit on specific applications using the policy (such as a crypto wallet).
71
+ 3. The tide request contains the policy as part of its payload when sent to the network. Aside from that it is simply a data model.
72
+
73
+ To create a policy, you'll have to create the Policy object then execute a PolicySignRequest to authorize its use.
74
+
75
+ Here's the syntax for it:
76
+ ```js
77
+ const policySignRequest = PolicySignRequest.New(policy); // PolicySignRequest will return a single signature of the Policy you added to the PolicySignRequest
78
+ const policySignature = // see 7. Executing Tide Requests on tidecloak-js on how to execute a tide request
79
+ policy.signature = policySignature;
80
+ const policyDataToStore = policy.encode(); // You can now store this signed policy for your client application to use when authorizing tide requests you specified in policy.modelId
81
+ ```
82
+
83
+ ## Contracts
84
+ ### Contract Structure
85
+ All contracts that execute on the Tide Network require the implementation of 3 functions.
86
+
87
+ 1. `validate_request` - Always required for checking policy details against the request's contents.
88
+ 2. `validate_approvers` - Required if you intend to use policies with `approvalType` set to **explicit**. This is where the logic that determines if the users that approved this request has the specific roles/conditions to do so.
89
+ 3. `validate_executor` - Required if you intend to use policies with `executionType` set to **private**. This is where the logic that determines if the user that executed this request had the correct roles/condition to do so.
90
+
91
+ Constructing a contract on Tide for now is extraodinarily complex and you probably won't be doing it. TODO
92
+
93
+ ## Other specific niches to know about
94
+ ### Custom Requests
95
+ Looking to sign your own kind of custom data with Tide? Look no further. This is where I intend to butcher the explanation of it.
96
+
97
+ There are 3 types of `CustomRequest` on Tide - each intended to best fit your specific type of request.
98
+
99
+ 1. `BasicCustomRequest` - A basic request. You have all the data your require to be validated at the time of request creation.
100
+ 2. `DyanmicPayloadCustomRequest` - A request with the data to be signed in the dynamic part of the request (which can be changed from the time the request was created).
101
+ 3. `DynamicPayloadApprovedCustomRequest` - A request with the data to be signed in the dynamic part of the request that also requires `explicit` approval from the users. This requires the use of a Human Readable object in the authorized payload to ensure the details shown to an approver at approval time can be verified against the signing data added to the request dynamically later.
102
+
103
+ ### Basic Contract Test Validation
@@ -0,0 +1,47 @@
1
+ import { Policy } from "../models/Policy";
2
+ import BaseTideRequest from "../models/TideRequest";
3
+ import { TideMemory } from "../utils/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 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AkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAazC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAKjC"}
@@ -8,23 +8,51 @@ const Policy_1 = require("../models/Policy");
8
8
  const TideRequest_1 = __importDefault(require("../models/TideRequest"));
9
9
  const Serialization_1 = require("../utils/Serialization");
10
10
  class BaseContract {
11
+ /**
12
+ * Inheritors must implement this if the policy has set it's approvalType to EXPLICIT
13
+ * @param policy Policy object
14
+ * @param approverDokens Approver Dokens
15
+ */
16
+ validateApprovers(policy, approverDokens) {
17
+ throw `validateApprovers not implemented`;
18
+ }
19
+ /**
20
+ * Inheritors must implement this if the policy has set it's executionType to PRIVATE
21
+ * @param policy Policy object
22
+ * @param executorDoken Executor Doken
23
+ */
24
+ validateExecutor(policy, executorDoken) {
25
+ throw `validateExecutor not implemented`;
26
+ }
11
27
  /**
12
28
  * To help with clients testing if their Tide Request will pass their contract's specified contract
13
29
  * @param policy Serialized policy from Tide
14
30
  * @returns
15
31
  */
16
- async testPolicy(policy) {
17
- const p = policy instanceof Uint8Array ? new Policy_1.Policy(policy) : policy;
32
+ async testPolicy(policy, executorDoken = null) {
33
+ const p = policy instanceof Uint8Array ? Policy_1.Policy.from(policy) : policy;
18
34
  if (p.contractId !== this.id)
19
35
  throw `Mismatch between policy provided's contract (${p.contractId}) and this contract's id (${this.id})`;
20
36
  if (p.modelId !== this.tideRequest.id() && p.modelId !== "any")
21
37
  throw `Mismatch between policy provided model id (${p.modelId}) and tide request id (${this.tideRequest.id()})`;
22
38
  try {
23
- await this.test(p);
24
- return true;
39
+ await this.validateData(p);
40
+ if (p.approvalType == Policy_1.ApprovalType.EXPLICIT)
41
+ await this.validateApprovers(p, this.dokens);
42
+ if (p.executionType == Policy_1.ExecutionType.PRIVATE) {
43
+ if (!executorDoken)
44
+ throw `Policy as set it's execution type to PRIVATE. You must test this with the doken of the executor`;
45
+ await this.validateExecutor(p, new Doken(executorDoken));
46
+ }
47
+ return {
48
+ success: true
49
+ };
25
50
  }
26
51
  catch (ex) {
27
- return false;
52
+ return {
53
+ success: false,
54
+ failed: ex
55
+ };
28
56
  }
29
57
  }
30
58
  constructor(tideRequest) {
@@ -47,7 +75,7 @@ class Doken {
47
75
  if (!d || d.length === 0) {
48
76
  throw new Error('Doken constructor: received empty or null Uint8Array');
49
77
  }
50
- const tokenString = (0, Serialization_1.StringFromUint8Array)(d);
78
+ const tokenString = typeof d === "string" ? d : (0, Serialization_1.StringFromUint8Array)(d);
51
79
  const s = tokenString.split(".");
52
80
  if (s.length !== 3) {
53
81
  throw new Error(`Doken constructor: invalid token format. Expected 3 parts (header.payload.signature) but got ${s.length} parts in: "${tokenString.substring(0, 50)}..."`);
@@ -69,13 +97,13 @@ class Doken {
69
97
  if (!client)
70
98
  throw new Error('hasResourceAccessRole: client parameter is empty or undefined');
71
99
  if (!this.payload.resource_access) {
72
- throw new Error(`hasResourceAccessRole: token payload does not contain 'resource_access' field. Available fields: ${Object.keys(this.payload).join(', ')}`);
100
+ return false;
73
101
  }
74
102
  if (!this.payload.resource_access[client]) {
75
- throw new Error(`hasResourceAccessRole: client '${client}' not found in resource_access. Available clients: ${Object.keys(this.payload.resource_access).join(', ')}`);
103
+ return false;
76
104
  }
77
105
  if (!Array.isArray(this.payload.resource_access[client].roles)) {
78
- throw new Error(`hasResourceAccessRole: 'roles' field for client '${client}' is not an array. Got type: ${typeof this.payload.resource_access[client].roles}`);
106
+ return false;
79
107
  }
80
108
  return this.payload.resource_access[client].roles.includes(role);
81
109
  }
@@ -83,10 +111,10 @@ class Doken {
83
111
  if (!role)
84
112
  throw new Error('hasRealmAccessRole: role parameter is empty or undefined');
85
113
  if (!this.payload.realm_access) {
86
- throw new Error(`hasRealmAccessRole: token payload does not contain 'realm_access' field. Available fields: ${Object.keys(this.payload).join(', ')}`);
114
+ return false;
87
115
  }
88
116
  if (!Array.isArray(this.payload.realm_access.roles)) {
89
- throw new Error(`hasRealmAccessRole: 'roles' field in realm_access is not an array. Got type: ${typeof this.payload.realm_access.roles}`);
117
+ return false;
90
118
  }
91
119
  return this.payload.realm_access.roles.includes(role);
92
120
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseContract.js","sourceRoot":"","sources":["../../../src/contracts/BaseContract.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAuE;AACvE,wEAAoD;AACpD,0DAA8D;AAQ9D,MAAsB,YAAY;IAa9B;;;;OAIG;IACO,iBAAiB,CAAC,MAAc,EAAE,cAAuB;QAC/D,MAAM,mCAAmC,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACO,gBAAgB,CAAC,MAAc,EAAE,aAAoB;QAC3D,MAAM,kCAAkC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,MAA2B,EAAE,gBAAqC,IAAI;QACnF,MAAM,CAAC,GAAG,MAAM,YAAY,UAAU,CAAC,CAAC,CAAC,eAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtE,IAAG,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,EAAE;YAAE,MAAM,gDAAgD,CAAC,CAAC,UAAU,6BAA6B,IAAI,CAAC,EAAE,GAAG,CAAC;QACvI,IAAG,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,OAAO,KAAK,KAAK;YAAE,MAAM,8CAA8C,CAAC,CAAC,OAAO,0BAA0B,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,CAAA;QAC9K,IAAG,CAAC;YACA,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC3B,IAAG,CAAC,CAAC,YAAY,IAAI,qBAAY,CAAC,QAAQ;gBAAE,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACzF,IAAG,CAAC,CAAC,aAAa,IAAI,sBAAa,CAA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,SAAS,eAAe,CAAC,KAAa;IAClC,IAAI,MAAM,GAAG,KAAK;SACb,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC;SACpB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAE1B,QAAQ,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,KAAK,CAAC;YACF,MAAM;QACV,KAAK,CAAC;YACF,MAAM,IAAI,IAAI,CAAC;YACf,MAAM;QACV,KAAK,CAAC;YACF,MAAM,IAAI,GAAG,CAAC;YACd,MAAM;QACV;YACI,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,CAAC;QACD,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;AACL,CAAC;AACD,SAAS,gBAAgB,CAAC,KAAa;IACnC,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC3D,IAAI,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAEtD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClB,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;QACtB,CAAC;QAED,OAAO,GAAG,GAAG,IAAI,CAAC;IACtB,CAAC,CAAC,CAAC,CAAC;AACR,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { Policy } from "../models/Policy";
2
- import { BaseContract } from "./BaseContract";
2
+ import { BaseContract, Doken } from "./BaseContract";
3
3
  export declare class GenericRealmAccessThresholdRoleContract extends BaseContract {
4
+ protected validateData(policy: Policy): Promise<void>;
4
5
  id: string;
5
- protected test(policy: Policy): Promise<void>;
6
+ protected validateApprovers(policy: Policy, approverDokens: Doken[]): Promise<void>;
6
7
  }
7
8
  //# sourceMappingURL=GenericRealmAccessThresholdRoleContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericRealmAccessThresholdRoleContract.d.ts","sourceRoot":"","sources":["../../../src/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"}
@@ -7,9 +7,13 @@ class GenericRealmAccessThresholdRoleContract extends BaseContract_1.BaseContrac
7
7
  super(...arguments);
8
8
  this.id = "GenericRealmAccessThresholdRole:1";
9
9
  }
10
- async test(policy) {
10
+ validateData(policy) {
11
+ console.warn("Validate Data not implemented!");
12
+ return;
13
+ }
14
+ async validateApprovers(policy, approverDokens) {
11
15
  let successfulDokens = 0;
12
- this.dokens.forEach(d => {
16
+ approverDokens.forEach(d => {
13
17
  if (d.hasRealmAccessRole(policy.params.getParameter("role")))
14
18
  successfulDokens++;
15
19
  });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericRealmAccessThresholdRoleContract.js","sourceRoot":"","sources":["../../../src/contracts/GenericRealmAccessThresholdRoleContract.ts"],"names":[],"mappings":";;;AACA,iDAAqD;AAErD,MAAa,uCAAwC,SAAQ,2BAAY;IAAzE;;QAKW,OAAE,GAAW,mCAAmC,CAAC;IAS5D,CAAC;IAba,YAAY,CAAC,MAAc;QACjC,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QAC/C,OAAO;IACX,CAAC;IAES,KAAK,CAAC,iBAAiB,CAAC,MAAc,EAAE,cAAuB;QACrE,IAAI,gBAAgB,GAAG,CAAC,CAAC;QACzB,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACvB,IAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAS,MAAM,CAAC,CAAC;gBAAE,gBAAgB,EAAE,CAAC;QAC5F,CAAC,CAAC,CAAA;QACF,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAS,WAAW,CAAC,CAAC;QAClE,IAAG,gBAAgB,GAAG,SAAS;YAAE,MAAM,0DAA0D,CAAC;IACtG,CAAC;CACJ;AAdD,0FAcC"}
@@ -1,7 +1,8 @@
1
1
  import { Policy } from "../models/Policy";
2
- import { BaseContract } from "./BaseContract";
2
+ import { BaseContract, Doken } from "./BaseContract";
3
3
  export declare class GenericResourceAccessThresholdRoleContract extends BaseContract {
4
4
  id: string;
5
- protected test(policy: Policy): Promise<void>;
5
+ protected validateData(policy: Policy): Promise<void>;
6
+ protected validateApprovers(policy: Policy, approverDokens: Doken[]): Promise<void>;
6
7
  }
7
8
  //# sourceMappingURL=GenericResourceAccessThresholdRoleContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericResourceAccessThresholdRoleContract.d.ts","sourceRoot":"","sources":["../../../src/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"}