asgard-tide 0.12.43 → 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 (94) hide show
  1. package/README.md +103 -2
  2. package/dist/{contracts → cjs/contracts}/BaseContract.d.ts +16 -4
  3. package/dist/cjs/contracts/BaseContract.d.ts.map +1 -0
  4. package/dist/{contracts → cjs/contracts}/BaseContract.js +32 -9
  5. package/dist/cjs/contracts/BaseContract.js.map +1 -0
  6. package/dist/{contracts → cjs/contracts}/GenericRealmAccessThresholdRoleContract.d.ts +3 -2
  7. package/dist/cjs/contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +1 -0
  8. package/dist/{contracts → cjs/contracts}/GenericRealmAccessThresholdRoleContract.js +6 -2
  9. package/dist/cjs/contracts/GenericRealmAccessThresholdRoleContract.js.map +1 -0
  10. package/dist/{contracts → cjs/contracts}/GenericResourceAccessThresholdRoleContract.d.ts +3 -2
  11. package/dist/cjs/contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +1 -0
  12. package/dist/{contracts → cjs/contracts}/GenericResourceAccessThresholdRoleContract.js +6 -2
  13. package/dist/cjs/contracts/GenericResourceAccessThresholdRoleContract.js.map +1 -0
  14. package/dist/cjs/index.d.ts +15 -0
  15. package/dist/cjs/index.d.ts.map +1 -0
  16. package/dist/{index.js → cjs/index.js} +7 -3
  17. package/dist/cjs/index.js.map +1 -0
  18. package/dist/cjs/models/CustomTideRequest.d.ts +19 -0
  19. package/dist/cjs/models/CustomTideRequest.d.ts.map +1 -0
  20. package/dist/cjs/models/CustomTideRequest.js +40 -0
  21. package/dist/cjs/models/CustomTideRequest.js.map +1 -0
  22. package/dist/{models → cjs/models}/Policy.d.ts +17 -2
  23. package/dist/cjs/models/Policy.d.ts.map +1 -0
  24. package/dist/{models → cjs/models}/Policy.js +126 -29
  25. package/dist/cjs/models/Policy.js.map +1 -0
  26. package/dist/cjs/models/TideRequest.d.ts.map +1 -0
  27. package/dist/{models → cjs/models}/TideRequest.js +1 -1
  28. package/dist/cjs/models/TideRequest.js.map +1 -0
  29. package/dist/cjs/utils/Serialization.d.ts.map +1 -0
  30. package/dist/cjs/utils/Serialization.js.map +1 -0
  31. package/dist/cjs/utils/TideMemory.d.ts.map +1 -0
  32. package/dist/cjs/utils/TideMemory.js.map +1 -0
  33. package/dist/esm/contracts/BaseContract.d.ts +47 -0
  34. package/dist/esm/contracts/BaseContract.d.ts.map +1 -0
  35. package/dist/esm/contracts/BaseContract.js +154 -0
  36. package/dist/esm/contracts/BaseContract.js.map +1 -0
  37. package/dist/esm/contracts/GenericRealmAccessThresholdRoleContract.d.ts +8 -0
  38. package/dist/esm/contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +1 -0
  39. package/dist/esm/contracts/GenericRealmAccessThresholdRoleContract.js +22 -0
  40. package/dist/esm/contracts/GenericRealmAccessThresholdRoleContract.js.map +1 -0
  41. package/dist/esm/contracts/GenericResourceAccessThresholdRoleContract.d.ts +8 -0
  42. package/dist/esm/contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +1 -0
  43. package/dist/esm/contracts/GenericResourceAccessThresholdRoleContract.js +22 -0
  44. package/dist/esm/contracts/GenericResourceAccessThresholdRoleContract.js.map +1 -0
  45. package/dist/esm/index.d.ts +15 -0
  46. package/dist/esm/index.d.ts.map +1 -0
  47. package/dist/{index.d.ts → esm/index.js} +5 -5
  48. package/dist/esm/index.js.map +1 -0
  49. package/dist/esm/models/CustomTideRequest.d.ts +19 -0
  50. package/dist/esm/models/CustomTideRequest.d.ts.map +1 -0
  51. package/dist/esm/models/CustomTideRequest.js +31 -0
  52. package/dist/esm/models/CustomTideRequest.js.map +1 -0
  53. package/dist/esm/models/Policy.d.ts +41 -0
  54. package/dist/esm/models/Policy.d.ts.map +1 -0
  55. package/dist/esm/models/Policy.js +263 -0
  56. package/dist/esm/models/Policy.js.map +1 -0
  57. package/dist/esm/models/TideRequest.d.ts +48 -0
  58. package/dist/esm/models/TideRequest.d.ts.map +1 -0
  59. package/dist/esm/models/TideRequest.js +252 -0
  60. package/dist/esm/models/TideRequest.js.map +1 -0
  61. package/dist/esm/utils/Serialization.d.ts +7 -0
  62. package/dist/esm/utils/Serialization.d.ts.map +1 -0
  63. package/dist/esm/utils/Serialization.js +98 -0
  64. package/dist/esm/utils/Serialization.js.map +1 -0
  65. package/dist/esm/utils/TideMemory.d.ts +10 -0
  66. package/dist/esm/utils/TideMemory.d.ts.map +1 -0
  67. package/dist/esm/utils/TideMemory.js +106 -0
  68. package/dist/esm/utils/TideMemory.js.map +1 -0
  69. package/package.json +14 -5
  70. package/dist/contracts/BaseContract.d.ts.map +0 -1
  71. package/dist/contracts/BaseContract.js.map +0 -1
  72. package/dist/contracts/GenericRealmAccessThresholdRoleContract.d.ts.map +0 -1
  73. package/dist/contracts/GenericRealmAccessThresholdRoleContract.js.map +0 -1
  74. package/dist/contracts/GenericResourceAccessThresholdRoleContract.d.ts.map +0 -1
  75. package/dist/contracts/GenericResourceAccessThresholdRoleContract.js.map +0 -1
  76. package/dist/index.d.ts.map +0 -1
  77. package/dist/index.js.map +0 -1
  78. package/dist/models/CustomTideRequest.d.ts +0 -16
  79. package/dist/models/CustomTideRequest.d.ts.map +0 -1
  80. package/dist/models/CustomTideRequest.js +0 -55
  81. package/dist/models/CustomTideRequest.js.map +0 -1
  82. package/dist/models/Policy.d.ts.map +0 -1
  83. package/dist/models/Policy.js.map +0 -1
  84. package/dist/models/TideRequest.d.ts.map +0 -1
  85. package/dist/models/TideRequest.js.map +0 -1
  86. package/dist/utils/Serialization.d.ts.map +0 -1
  87. package/dist/utils/Serialization.js.map +0 -1
  88. package/dist/utils/TideMemory.d.ts.map +0 -1
  89. package/dist/utils/TideMemory.js.map +0 -1
  90. /package/dist/{models → cjs/models}/TideRequest.d.ts +0 -0
  91. /package/dist/{utils → cjs/utils}/Serialization.d.ts +0 -0
  92. /package/dist/{utils → cjs/utils}/Serialization.js +0 -0
  93. /package/dist/{utils → cjs/utils}/TideMemory.d.ts +0 -0
  94. /package/dist/{utils → cjs/utils}/TideMemory.js +0 -0
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
@@ -8,25 +8,37 @@ interface PolicyRunResult {
8
8
  export declare abstract class BaseContract {
9
9
  abstract id: string;
10
10
  private tideRequest;
11
- protected dokens: Doken[];
11
+ private dokens;
12
12
  protected authorizedRequestPayload: TideMemory;
13
13
  protected informationalRequestPayload: TideMemory;
14
14
  /**
15
15
  * Inheritors must implement this
16
16
  * @param policy Policy object
17
17
  */
18
- protected abstract test(policy: Policy): Promise<void>;
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>;
19
31
  /**
20
32
  * To help with clients testing if their Tide Request will pass their contract's specified contract
21
33
  * @param policy Serialized policy from Tide
22
34
  * @returns
23
35
  */
24
- testPolicy(policy: Uint8Array | Policy): Promise<PolicyRunResult>;
36
+ testPolicy(policy: Uint8Array | Policy, executorDoken?: string | undefined): Promise<PolicyRunResult>;
25
37
  constructor(tideRequest: Uint8Array | BaseTideRequest);
26
38
  }
27
39
  export declare class Doken {
28
40
  private payload;
29
- constructor(d: Uint8Array);
41
+ constructor(d: Uint8Array | string);
30
42
  hasResourceAccessRole(role: string, client: string): boolean;
31
43
  hasRealmAccessRole(role: string): boolean;
32
44
  hasVuid(vuid: string): boolean;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseContract.d.ts","sourceRoot":"","sources":["../../../src/contracts/BaseContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD,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"}
@@ -8,19 +8,42 @@ 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);
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
+ }
24
47
  return {
25
48
  success: true
26
49
  };
@@ -52,7 +75,7 @@ class Doken {
52
75
  if (!d || d.length === 0) {
53
76
  throw new Error('Doken constructor: received empty or null Uint8Array');
54
77
  }
55
- const tokenString = (0, Serialization_1.StringFromUint8Array)(d);
78
+ const tokenString = typeof d === "string" ? d : (0, Serialization_1.StringFromUint8Array)(d);
56
79
  const s = tokenString.split(".");
57
80
  if (s.length !== 3) {
58
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)}..."`);
@@ -74,13 +97,13 @@ class Doken {
74
97
  if (!client)
75
98
  throw new Error('hasResourceAccessRole: client parameter is empty or undefined');
76
99
  if (!this.payload.resource_access) {
77
- throw new Error(`hasResourceAccessRole: token payload does not contain 'resource_access' field. Available fields: ${Object.keys(this.payload).join(', ')}`);
100
+ return false;
78
101
  }
79
102
  if (!this.payload.resource_access[client]) {
80
- throw new Error(`hasResourceAccessRole: client '${client}' not found in resource_access. Available clients: ${Object.keys(this.payload.resource_access).join(', ')}`);
103
+ return false;
81
104
  }
82
105
  if (!Array.isArray(this.payload.resource_access[client].roles)) {
83
- 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;
84
107
  }
85
108
  return this.payload.resource_access[client].roles.includes(role);
86
109
  }
@@ -88,10 +111,10 @@ class Doken {
88
111
  if (!role)
89
112
  throw new Error('hasRealmAccessRole: role parameter is empty or undefined');
90
113
  if (!this.payload.realm_access) {
91
- throw new Error(`hasRealmAccessRole: token payload does not contain 'realm_access' field. Available fields: ${Object.keys(this.payload).join(', ')}`);
114
+ return false;
92
115
  }
93
116
  if (!Array.isArray(this.payload.realm_access.roles)) {
94
- throw new Error(`hasRealmAccessRole: 'roles' field in realm_access is not an array. Got type: ${typeof this.payload.realm_access.roles}`);
117
+ return false;
95
118
  }
96
119
  return this.payload.realm_access.roles.includes(role);
97
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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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"}
@@ -7,9 +7,13 @@ class GenericResourceAccessThresholdRoleContract extends BaseContract_1.BaseCont
7
7
  super(...arguments);
8
8
  this.id = "GenericResourceAccessThresholdRole: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.hasResourceAccessRole(policy.params.getParameter("role"), policy.params.getParameter("resource")))
14
18
  successfulDokens++;
15
19
  });
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericResourceAccessThresholdRoleContract.js","sourceRoot":"","sources":["../../../src/contracts/GenericResourceAccessThresholdRoleContract.ts"],"names":[],"mappings":";;;AACA,iDAAqD;AAErD,MAAa,0CAA2C,SAAQ,2BAAY;IAA5E;;QACW,OAAE,GAAW,sCAAsC,CAAC;IAa/D,CAAC;IAZa,YAAY,CAAC,MAAc;QACjC,OAAO,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QAC/C,OAAO;IACX,CAAC;IACS,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,qBAAqB,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAS,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAS,UAAU,CAAC,CAAC;gBAAE,gBAAgB,EAAE,CAAC;QAC/I,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,gGAcC"}
@@ -0,0 +1,15 @@
1
+ import { BaseContract } from "./contracts/BaseContract";
2
+ import { GenericResourceAccessThresholdRoleContract } from "./contracts/GenericResourceAccessThresholdRoleContract";
3
+ import { GenericRealmAccessThresholdRoleContract } from "./contracts/GenericRealmAccessThresholdRoleContract";
4
+ import { TideMemory } from "./utils/TideMemory";
5
+ import BaseTideRequest from "./models/TideRequest";
6
+ import { Policy, PolicyParameters, ApprovalType, ExecutionType } from "./models/Policy";
7
+ import { BasicCustomRequest, DynamicPayloadCustomRequest, DynamicPayloadApprovedCustomRequest } from "./models/CustomTideRequest";
8
+ export { GenericResourceAccessThresholdRoleContract };
9
+ export { BaseContract };
10
+ export { TideMemory };
11
+ export { BaseTideRequest };
12
+ export { Policy, PolicyParameters, ApprovalType, ExecutionType };
13
+ export { GenericRealmAccessThresholdRoleContract };
14
+ export { BasicCustomRequest, DynamicPayloadCustomRequest, DynamicPayloadApprovedCustomRequest };
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,0CAA0C,EAAE,MAAM,wDAAwD,CAAC;AACpH,OAAO,EAAE,uCAAuC,EAAE,MAAM,qDAAqD,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,4BAA4B,CAAC;AAElI,OAAO,EAAE,0CAA0C,EAAE,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,CAAA;AACrB,OAAO,EAAE,eAAe,EAAE,CAAA;AAC1B,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,CAAA;AAChE,OAAO,EAAE,uCAAuC,EAAE,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,CAAA"}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CustomTideRequest = exports.GenericRealmAccessThresholdRoleContract = exports.PolicyParameters = exports.Policy = exports.BaseTideRequest = exports.TideMemory = exports.BaseContract = exports.GenericResourceAccessThresholdRoleContract = void 0;
6
+ exports.DynamicPayloadApprovedCustomRequest = exports.DynamicPayloadCustomRequest = exports.BasicCustomRequest = exports.GenericRealmAccessThresholdRoleContract = exports.ExecutionType = exports.ApprovalType = exports.PolicyParameters = exports.Policy = exports.BaseTideRequest = exports.TideMemory = exports.BaseContract = exports.GenericResourceAccessThresholdRoleContract = void 0;
7
7
  const BaseContract_1 = require("./contracts/BaseContract");
8
8
  Object.defineProperty(exports, "BaseContract", { enumerable: true, get: function () { return BaseContract_1.BaseContract; } });
9
9
  const GenericResourceAccessThresholdRoleContract_1 = require("./contracts/GenericResourceAccessThresholdRoleContract");
@@ -17,6 +17,10 @@ exports.BaseTideRequest = TideRequest_1.default;
17
17
  const Policy_1 = require("./models/Policy");
18
18
  Object.defineProperty(exports, "Policy", { enumerable: true, get: function () { return Policy_1.Policy; } });
19
19
  Object.defineProperty(exports, "PolicyParameters", { enumerable: true, get: function () { return Policy_1.PolicyParameters; } });
20
- const CustomTideRequest_1 = __importDefault(require("./models/CustomTideRequest"));
21
- exports.CustomTideRequest = CustomTideRequest_1.default;
20
+ Object.defineProperty(exports, "ApprovalType", { enumerable: true, get: function () { return Policy_1.ApprovalType; } });
21
+ Object.defineProperty(exports, "ExecutionType", { enumerable: true, get: function () { return Policy_1.ExecutionType; } });
22
+ const CustomTideRequest_1 = require("./models/CustomTideRequest");
23
+ Object.defineProperty(exports, "BasicCustomRequest", { enumerable: true, get: function () { return CustomTideRequest_1.BasicCustomRequest; } });
24
+ Object.defineProperty(exports, "DynamicPayloadCustomRequest", { enumerable: true, get: function () { return CustomTideRequest_1.DynamicPayloadCustomRequest; } });
25
+ Object.defineProperty(exports, "DynamicPayloadApprovedCustomRequest", { enumerable: true, get: function () { return CustomTideRequest_1.DynamicPayloadApprovedCustomRequest; } });
22
26
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,2DAAwD;AAU/C,6FAVA,2BAAY,OAUA;AATrB,uHAAoH;AAQ3G,2HARA,uFAA0C,OAQA;AAPnD,iHAA8G;AAYrG,wHAZA,iFAAuC,OAYA;AAXhD,mDAAgD;AAQvC,2FARA,uBAAU,OAQA;AAPnB,uEAAmD;AAQ1C,0BARF,qBAAe,CAQE;AAPxB,4CAAwF;AAQ/E,uFARA,eAAM,OAQA;AAAE,iGARA,yBAAgB,OAQA;AAAE,6FARA,qBAAY,OAQA;AAAE,8FARA,sBAAa,OAQA;AAN9D,kEAAkI;AAQzH,mGARA,sCAAkB,OAQA;AAAE,4GARA,+CAA2B,OAQA;AAAE,oHARA,uDAAmC,OAQA"}
@@ -0,0 +1,19 @@
1
+ import BaseTideRequest from "./TideRequest";
2
+ export declare class BasicCustomRequest extends BaseTideRequest {
3
+ id(): string;
4
+ }
5
+ export declare class DynamicPayloadCustomRequest extends BaseTideRequest {
6
+ id(): string;
7
+ }
8
+ export declare class DynamicPayloadApprovedCustomRequest extends BaseTideRequest {
9
+ customInfo: CustomInfo | undefined;
10
+ constructor(name: string, version: string, authFlow: string, humanReadableName: string, additionalInfo: any, dyanmicData: Uint8Array);
11
+ id(): string;
12
+ getAdditionalInfoSupplied(): any;
13
+ }
14
+ interface CustomInfo {
15
+ humanReadableName: string;
16
+ additionalInfo: any;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=CustomTideRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomTideRequest.d.ts","sourceRoot":"","sources":["../../../src/models/CustomTideRequest.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,MAAM,eAAe,CAAC;AAE5C,qBAAa,kBAAmB,SAAQ,eAAe;IACnD,EAAE,IAAI,MAAM;CAGf;AAED,qBAAa,2BAA4B,SAAQ,eAAe;IAC5D,EAAE,IAAI,MAAM;CAGf;AAED,qBAAa,mCAAoC,SAAQ,eAAe;IACpE,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;gBAEvB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU;IAQpI,EAAE,IAAI,MAAM;IAIZ,yBAAyB,IAAI,GAAG;CAInC;AACD,UAAU,UAAU;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,GAAG,CAAC;CACvB"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DynamicPayloadApprovedCustomRequest = exports.DynamicPayloadCustomRequest = exports.BasicCustomRequest = void 0;
7
+ const Serialization_1 = require("../utils/Serialization");
8
+ const TideRequest_1 = __importDefault(require("./TideRequest"));
9
+ class BasicCustomRequest extends TideRequest_1.default {
10
+ id() {
11
+ return `BasicCustom<${this.name}>:BasicCustom<${this.version}>`;
12
+ }
13
+ }
14
+ exports.BasicCustomRequest = BasicCustomRequest;
15
+ class DynamicPayloadCustomRequest extends TideRequest_1.default {
16
+ id() {
17
+ return `DynamicCustom<${this.name}>:DynamicCustom<${this.version}>`;
18
+ }
19
+ }
20
+ exports.DynamicPayloadCustomRequest = DynamicPayloadCustomRequest;
21
+ class DynamicPayloadApprovedCustomRequest extends TideRequest_1.default {
22
+ constructor(name, version, authFlow, humanReadableName, additionalInfo, dyanmicData) {
23
+ const customInfo = {
24
+ humanReadableName: humanReadableName,
25
+ additionalInfo: additionalInfo
26
+ };
27
+ super(name, version, authFlow, (0, Serialization_1.StringToUint8Array)(JSON.stringify(customInfo)), dyanmicData);
28
+ }
29
+ id() {
30
+ return `DynamicApprovedCustom<${this.name}>:DynamicApprovedCustom<${this.version}>`;
31
+ }
32
+ getAdditionalInfoSupplied() {
33
+ if (this.draft.length > 0)
34
+ return JSON.parse((0, Serialization_1.StringFromUint8Array)(this.draft))["additionalInfo"];
35
+ else
36
+ return null;
37
+ }
38
+ }
39
+ exports.DynamicPayloadApprovedCustomRequest = DynamicPayloadApprovedCustomRequest;
40
+ //# sourceMappingURL=CustomTideRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomTideRequest.js","sourceRoot":"","sources":["../../../src/models/CustomTideRequest.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkF;AAElF,gEAA4C;AAE5C,MAAa,kBAAmB,SAAQ,qBAAe;IACnD,EAAE;QACE,OAAO,eAAe,IAAI,CAAC,IAAI,iBAAiB,IAAI,CAAC,OAAO,GAAG,CAAC;IACpE,CAAC;CACJ;AAJD,gDAIC;AAED,MAAa,2BAA4B,SAAQ,qBAAe;IAC5D,EAAE;QACE,OAAO,iBAAiB,IAAI,CAAC,IAAI,mBAAmB,IAAI,CAAC,OAAO,GAAG,CAAC;IACxE,CAAC;CACJ;AAJD,kEAIC;AAED,MAAa,mCAAoC,SAAQ,qBAAe;IAGpE,YAAY,IAAY,EAAE,OAAe,EAAE,QAAgB,EAAE,iBAAyB,EAAE,cAAmB,EAAE,WAAuB;QAChI,MAAM,UAAU,GAAG;YACf,iBAAiB,EAAE,iBAAiB;YACpC,cAAc,EAAE,cAAc;SACjC,CAAA;QACD,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAA,kCAAkB,EAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAChG,CAAC;IAED,EAAE;QACE,OAAO,yBAAyB,IAAI,CAAC,IAAI,2BAA2B,IAAI,CAAC,OAAO,GAAG,CAAC;IACxF,CAAC;IAED,yBAAyB;QACrB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,oCAAoB,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC;;YAC5F,OAAO,IAAI,CAAC;IACrB,CAAC;CACJ;AAnBD,kFAmBC"}
@@ -1,9 +1,20 @@
1
1
  import { TideMemory } from "../utils/TideMemory";
2
+ export declare enum ApprovalType {
3
+ EXPLICIT = 0,
4
+ IMPLICIT = 1
5
+ }
6
+ export declare enum ExecutionType {
7
+ PRIVATE = 0,
8
+ PUBLIC = 1
9
+ }
2
10
  export declare class Policy {
11
+ static latestVersion: string;
3
12
  version: string;
4
13
  contractId: string;
5
14
  modelId: string;
6
15
  keyId: string;
16
+ approvalType: ApprovalType;
17
+ executionType: ExecutionType;
7
18
  params: PolicyParameters;
8
19
  dataToVerify: TideMemory | undefined;
9
20
  signature: Uint8Array | undefined;
@@ -12,14 +23,18 @@ export declare class Policy {
12
23
  contractId: string;
13
24
  modelId: string;
14
25
  keyId: string;
15
- params: Map<string, any>;
16
- } | TideMemory | Uint8Array);
26
+ approvalType: ApprovalType;
27
+ executionType: ExecutionType;
28
+ params: Map<string, any> | PolicyParameters;
29
+ });
30
+ static from(data: Uint8Array): Policy;
17
31
  toBytes(): TideMemory;
18
32
  }
19
33
  export declare class PolicyParameters {
20
34
  entries: Map<string, any>;
21
35
  constructor(data: Map<string, any> | Uint8Array);
22
36
  private static fromBytes;
37
+ tryGetParameter<T extends string | number | bigint | boolean | Uint8Array>(key: string): [boolean, T];
23
38
  getParameter<T extends string | number | bigint | boolean | Uint8Array>(key: string): T;
24
39
  toBytes(): Uint8Array;
25
40
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Policy.d.ts","sourceRoot":"","sources":["../../../src/models/Policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,oBAAY,YAAY;IACpB,QAAQ,IAAA;IACR,QAAQ,IAAA;CACX;AACD,oBAAY,aAAa;IACrB,OAAO,IAAA;IACP,MAAM,IAAA;CACT;AACD,qBAAa,MAAM;IACf,MAAM,CAAC,aAAa,EAAE,MAAM,CAAO;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IAEzB,YAAY,EAAE,UAAU,GAAG,SAAS,CAAC;IACrC,SAAS,EAAE,UAAU,GAAG,SAAS,CAAC;gBAEtB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAA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