@nmshd/transport 7.0.0-alpha.4 → 7.0.0-alpha.41

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 (220) hide show
  1. package/README.md +2 -2
  2. package/dist/buildInformation.js +5 -5
  3. package/dist/core/Transport.d.ts +3 -4
  4. package/dist/core/Transport.d.ts.map +1 -1
  5. package/dist/core/Transport.js +3 -6
  6. package/dist/core/Transport.js.map +1 -1
  7. package/dist/core/TransportCoreErrors.d.ts +0 -1
  8. package/dist/core/TransportCoreErrors.d.ts.map +1 -1
  9. package/dist/core/TransportCoreErrors.js +0 -3
  10. package/dist/core/TransportCoreErrors.js.map +1 -1
  11. package/dist/core/TransportIds.d.ts +1 -1
  12. package/dist/core/TransportIds.d.ts.map +1 -1
  13. package/dist/core/TransportIds.js +6 -6
  14. package/dist/core/TransportIds.js.map +1 -1
  15. package/dist/core/backbone/BackboneIds.d.ts +1 -1
  16. package/dist/core/backbone/BackboneIds.d.ts.map +1 -1
  17. package/dist/core/backbone/BackboneIds.js +7 -7
  18. package/dist/core/backbone/BackboneIds.js.map +1 -1
  19. package/dist/core/backbone/ClientResult.d.ts +2 -0
  20. package/dist/core/backbone/ClientResult.d.ts.map +1 -1
  21. package/dist/core/backbone/ClientResult.js +2 -0
  22. package/dist/core/backbone/ClientResult.js.map +1 -1
  23. package/dist/core/backbone/PlatformParameters.d.ts +2 -0
  24. package/dist/core/backbone/PlatformParameters.d.ts.map +1 -1
  25. package/dist/core/backbone/RESTClient.d.ts +1 -0
  26. package/dist/core/backbone/RESTClient.d.ts.map +1 -1
  27. package/dist/core/backbone/RESTClient.js +31 -4
  28. package/dist/core/backbone/RESTClient.js.map +1 -1
  29. package/dist/core/backbone/RESTClientAuthenticate.d.ts +1 -0
  30. package/dist/core/backbone/RESTClientAuthenticate.d.ts.map +1 -1
  31. package/dist/core/backbone/RESTClientAuthenticate.js +5 -0
  32. package/dist/core/backbone/RESTClientAuthenticate.js.map +1 -1
  33. package/dist/core/backbone/RequestError.d.ts.map +1 -1
  34. package/dist/core/backbone/RequestError.js +3 -0
  35. package/dist/core/backbone/RequestError.js.map +1 -1
  36. package/dist/core/index.d.ts +0 -2
  37. package/dist/core/index.d.ts.map +1 -1
  38. package/dist/core/index.js +0 -2
  39. package/dist/core/index.js.map +1 -1
  40. package/dist/core/types/PasswordProtection.d.ts +5 -6
  41. package/dist/core/types/PasswordProtection.d.ts.map +1 -1
  42. package/dist/core/types/PasswordProtection.js +12 -11
  43. package/dist/core/types/PasswordProtection.js.map +1 -1
  44. package/dist/core/types/PasswordProtectionCreationParameters.d.ts +3 -0
  45. package/dist/core/types/PasswordProtectionCreationParameters.d.ts.map +1 -1
  46. package/dist/core/types/PasswordProtectionCreationParameters.js +7 -1
  47. package/dist/core/types/PasswordProtectionCreationParameters.js.map +1 -1
  48. package/dist/core/types/index.d.ts +0 -1
  49. package/dist/core/types/index.d.ts.map +1 -1
  50. package/dist/core/types/index.js +0 -1
  51. package/dist/core/types/index.js.map +1 -1
  52. package/dist/events/FileOwnershipClaimedEvent.d.ts +7 -0
  53. package/dist/events/FileOwnershipClaimedEvent.d.ts.map +1 -0
  54. package/dist/events/FileOwnershipClaimedEvent.js +12 -0
  55. package/dist/events/FileOwnershipClaimedEvent.js.map +1 -0
  56. package/dist/events/FileOwnershipLockedEvent.d.ts +7 -0
  57. package/dist/events/FileOwnershipLockedEvent.d.ts.map +1 -0
  58. package/dist/events/FileOwnershipLockedEvent.js +12 -0
  59. package/dist/events/FileOwnershipLockedEvent.js.map +1 -0
  60. package/dist/events/RelationshipTemplateAllocationsExhaustedEvent.d.ts +7 -0
  61. package/dist/events/RelationshipTemplateAllocationsExhaustedEvent.d.ts.map +1 -0
  62. package/dist/events/RelationshipTemplateAllocationsExhaustedEvent.js +12 -0
  63. package/dist/events/RelationshipTemplateAllocationsExhaustedEvent.js.map +1 -0
  64. package/dist/events/index.d.ts +3 -0
  65. package/dist/events/index.d.ts.map +1 -1
  66. package/dist/events/index.js +3 -0
  67. package/dist/events/index.js.map +1 -1
  68. package/dist/modules/accounts/AccountController.d.ts +2 -0
  69. package/dist/modules/accounts/AccountController.d.ts.map +1 -1
  70. package/dist/modules/accounts/AccountController.js +4 -2
  71. package/dist/modules/accounts/AccountController.js.map +1 -1
  72. package/dist/modules/announcements/AnnouncementController.d.ts +11 -0
  73. package/dist/modules/announcements/AnnouncementController.d.ts.map +1 -0
  74. package/dist/modules/announcements/AnnouncementController.js +26 -0
  75. package/dist/modules/announcements/AnnouncementController.js.map +1 -0
  76. package/dist/modules/announcements/backbone/AnnouncementClient.d.ts +6 -0
  77. package/dist/modules/announcements/backbone/AnnouncementClient.d.ts.map +1 -0
  78. package/dist/modules/announcements/backbone/AnnouncementClient.js +11 -0
  79. package/dist/modules/announcements/backbone/AnnouncementClient.js.map +1 -0
  80. package/dist/modules/announcements/backbone/BackboneGetAnnouncements.d.ts +13 -0
  81. package/dist/modules/announcements/backbone/BackboneGetAnnouncements.d.ts.map +1 -0
  82. package/dist/modules/announcements/backbone/BackboneGetAnnouncements.js +3 -0
  83. package/dist/modules/announcements/backbone/BackboneGetAnnouncements.js.map +1 -0
  84. package/dist/modules/announcements/data/Announcement.d.ts +27 -0
  85. package/dist/modules/announcements/data/Announcement.d.ts.map +1 -0
  86. package/dist/modules/announcements/data/Announcement.js +65 -0
  87. package/dist/modules/announcements/data/Announcement.js.map +1 -0
  88. package/dist/modules/devices/DeviceController.js +1 -1
  89. package/dist/modules/devices/DeviceSecretController.d.ts +1 -1
  90. package/dist/modules/devices/DeviceSecretController.js +1 -1
  91. package/dist/modules/devices/DevicesController.js +1 -1
  92. package/dist/modules/files/FileController.d.ts +7 -3
  93. package/dist/modules/files/FileController.d.ts.map +1 -1
  94. package/dist/modules/files/FileController.js +39 -8
  95. package/dist/modules/files/FileController.js.map +1 -1
  96. package/dist/modules/files/backbone/BackbonePostFiles.d.ts +1 -0
  97. package/dist/modules/files/backbone/BackbonePostFiles.d.ts.map +1 -1
  98. package/dist/modules/files/backbone/FileClient.d.ts +9 -0
  99. package/dist/modules/files/backbone/FileClient.d.ts.map +1 -1
  100. package/dist/modules/files/backbone/FileClient.js +9 -0
  101. package/dist/modules/files/backbone/FileClient.js.map +1 -1
  102. package/dist/modules/files/local/File.d.ts +9 -4
  103. package/dist/modules/files/local/File.d.ts.map +1 -1
  104. package/dist/modules/files/local/File.js +38 -8
  105. package/dist/modules/files/local/File.js.map +1 -1
  106. package/dist/modules/index.d.ts +2 -1
  107. package/dist/modules/index.d.ts.map +1 -1
  108. package/dist/modules/index.js +2 -1
  109. package/dist/modules/index.js.map +1 -1
  110. package/dist/modules/messages/MessageController.d.ts.map +1 -1
  111. package/dist/modules/messages/MessageController.js +2 -2
  112. package/dist/modules/messages/MessageController.js.map +1 -1
  113. package/dist/modules/messages/transmission/MessageContentWrapper.d.ts +1 -2
  114. package/dist/modules/messages/transmission/MessageContentWrapper.d.ts.map +1 -1
  115. package/dist/modules/messages/transmission/MessageContentWrapper.js +1 -2
  116. package/dist/modules/messages/transmission/MessageContentWrapper.js.map +1 -1
  117. package/dist/modules/relationshipTemplates/RelationshipTemplateController.d.ts +2 -1
  118. package/dist/modules/relationshipTemplates/RelationshipTemplateController.d.ts.map +1 -1
  119. package/dist/modules/relationshipTemplates/RelationshipTemplateController.js +7 -6
  120. package/dist/modules/relationshipTemplates/RelationshipTemplateController.js.map +1 -1
  121. package/dist/modules/relationshipTemplates/local/RelationshipTemplate.d.ts +1 -2
  122. package/dist/modules/relationshipTemplates/local/RelationshipTemplate.d.ts.map +1 -1
  123. package/dist/modules/relationshipTemplates/local/RelationshipTemplate.js +2 -5
  124. package/dist/modules/relationshipTemplates/local/RelationshipTemplate.js.map +1 -1
  125. package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.d.ts +1 -1
  126. package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.d.ts.map +1 -1
  127. package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.js +2 -1
  128. package/dist/modules/relationshipTemplates/transmission/RelationshipTemplateReference.js.map +1 -1
  129. package/dist/modules/relationships/RelationshipsController.d.ts +1 -1
  130. package/dist/modules/relationships/RelationshipsController.d.ts.map +1 -1
  131. package/dist/modules/relationships/RelationshipsController.js +7 -1
  132. package/dist/modules/relationships/RelationshipsController.js.map +1 -1
  133. package/dist/modules/secrets/SecretController.d.ts +1 -1
  134. package/dist/modules/secrets/SecretController.js +1 -1
  135. package/dist/modules/sync/ChangedItems.d.ts +5 -2
  136. package/dist/modules/sync/ChangedItems.d.ts.map +1 -1
  137. package/dist/modules/sync/ChangedItems.js +6 -1
  138. package/dist/modules/sync/ChangedItems.js.map +1 -1
  139. package/dist/modules/sync/SyncController.d.ts +0 -1
  140. package/dist/modules/sync/SyncController.d.ts.map +1 -1
  141. package/dist/modules/sync/SyncController.js +2 -22
  142. package/dist/modules/sync/SyncController.js.map +1 -1
  143. package/dist/modules/sync/externalEventProcessors/ExternalEventProcessor.d.ts +2 -1
  144. package/dist/modules/sync/externalEventProcessors/ExternalEventProcessor.d.ts.map +1 -1
  145. package/dist/modules/sync/externalEventProcessors/ExternalEventProcessor.js.map +1 -1
  146. package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.d.ts.map +1 -1
  147. package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js +6 -0
  148. package/dist/modules/sync/externalEventProcessors/ExternalEventProcessorRegistry.js.map +1 -1
  149. package/dist/modules/sync/externalEventProcessors/FileOwnershipClaimedExternalEventProcessor.d.ts +7 -0
  150. package/dist/modules/sync/externalEventProcessors/FileOwnershipClaimedExternalEventProcessor.d.ts.map +1 -0
  151. package/dist/modules/sync/externalEventProcessors/FileOwnershipClaimedExternalEventProcessor.js +37 -0
  152. package/dist/modules/sync/externalEventProcessors/FileOwnershipClaimedExternalEventProcessor.js.map +1 -0
  153. package/dist/modules/sync/externalEventProcessors/FileOwnershipLockedExternalEventProcessor.d.ts +7 -0
  154. package/dist/modules/sync/externalEventProcessors/FileOwnershipLockedExternalEventProcessor.d.ts.map +1 -0
  155. package/dist/modules/sync/externalEventProcessors/FileOwnershipLockedExternalEventProcessor.js +37 -0
  156. package/dist/modules/sync/externalEventProcessors/FileOwnershipLockedExternalEventProcessor.js.map +1 -0
  157. package/dist/modules/sync/externalEventProcessors/RelationshipReactivationCompletedExternalEventProcessor.d.ts.map +1 -1
  158. package/dist/modules/sync/externalEventProcessors/RelationshipReactivationCompletedExternalEventProcessor.js +2 -0
  159. package/dist/modules/sync/externalEventProcessors/RelationshipReactivationCompletedExternalEventProcessor.js.map +1 -1
  160. package/dist/modules/sync/externalEventProcessors/RelationshipReactivationRequestedExternalEventProcessor.d.ts.map +1 -1
  161. package/dist/modules/sync/externalEventProcessors/RelationshipReactivationRequestedExternalEventProcessor.js +2 -0
  162. package/dist/modules/sync/externalEventProcessors/RelationshipReactivationRequestedExternalEventProcessor.js.map +1 -1
  163. package/dist/modules/sync/externalEventProcessors/RelationshipStatusChangedExternalEventProcessor.d.ts.map +1 -1
  164. package/dist/modules/sync/externalEventProcessors/RelationshipStatusChangedExternalEventProcessor.js +2 -0
  165. package/dist/modules/sync/externalEventProcessors/RelationshipStatusChangedExternalEventProcessor.js.map +1 -1
  166. package/dist/modules/sync/externalEventProcessors/RelationshipTemplateAllocationsExhaustedProcessor.d.ts +6 -0
  167. package/dist/modules/sync/externalEventProcessors/RelationshipTemplateAllocationsExhaustedProcessor.d.ts.map +1 -0
  168. package/dist/modules/sync/externalEventProcessors/RelationshipTemplateAllocationsExhaustedProcessor.js +34 -0
  169. package/dist/modules/sync/externalEventProcessors/RelationshipTemplateAllocationsExhaustedProcessor.js.map +1 -0
  170. package/dist/modules/tags/backbone/TagClient.d.ts +1 -1
  171. package/dist/modules/tags/backbone/TagClient.d.ts.map +1 -1
  172. package/dist/modules/tags/backbone/TagClient.js +13 -2
  173. package/dist/modules/tags/backbone/TagClient.js.map +1 -1
  174. package/dist/modules/tokens/AnonymousTokenController.d.ts +2 -1
  175. package/dist/modules/tokens/AnonymousTokenController.d.ts.map +1 -1
  176. package/dist/modules/tokens/AnonymousTokenController.js +3 -4
  177. package/dist/modules/tokens/AnonymousTokenController.js.map +1 -1
  178. package/dist/modules/tokens/TokenController.d.ts +2 -1
  179. package/dist/modules/tokens/TokenController.d.ts.map +1 -1
  180. package/dist/modules/tokens/TokenController.js +5 -5
  181. package/dist/modules/tokens/TokenController.js.map +1 -1
  182. package/dist/modules/tokens/local/Token.d.ts +1 -2
  183. package/dist/modules/tokens/local/Token.d.ts.map +1 -1
  184. package/dist/modules/tokens/local/Token.js +2 -5
  185. package/dist/modules/tokens/local/Token.js.map +1 -1
  186. package/dist/modules/tokens/transmission/TokenContentRelationshipTemplate.d.ts +1 -2
  187. package/dist/modules/tokens/transmission/TokenContentRelationshipTemplate.d.ts.map +1 -1
  188. package/dist/modules/tokens/transmission/TokenContentRelationshipTemplate.js +1 -2
  189. package/dist/modules/tokens/transmission/TokenContentRelationshipTemplate.js.map +1 -1
  190. package/dist/modules/tokens/transmission/TokenReference.d.ts +1 -1
  191. package/dist/modules/tokens/transmission/TokenReference.d.ts.map +1 -1
  192. package/dist/modules/tokens/transmission/TokenReference.js +2 -1
  193. package/dist/modules/tokens/transmission/TokenReference.js.map +1 -1
  194. package/dist/util/PasswordGenerator.js +10 -10
  195. package/dist/util/PasswordGenerator.js.map +1 -1
  196. package/dist/util/index.d.ts +0 -1
  197. package/dist/util/index.d.ts.map +1 -1
  198. package/dist/util/index.js +0 -1
  199. package/dist/util/index.js.map +1 -1
  200. package/package.json +11 -11
  201. package/dist/core/CoreIdHelper.d.ts +0 -12
  202. package/dist/core/CoreIdHelper.d.ts.map +0 -1
  203. package/dist/core/CoreIdHelper.js +0 -34
  204. package/dist/core/CoreIdHelper.js.map +0 -1
  205. package/dist/core/Reference.d.ts +0 -25
  206. package/dist/core/Reference.d.ts.map +0 -1
  207. package/dist/core/Reference.js +0 -101
  208. package/dist/core/Reference.js.map +0 -1
  209. package/dist/core/types/SharedPasswordProtection.d.ts +0 -14
  210. package/dist/core/types/SharedPasswordProtection.d.ts.map +0 -1
  211. package/dist/core/types/SharedPasswordProtection.js +0 -51
  212. package/dist/core/types/SharedPasswordProtection.js.map +0 -1
  213. package/dist/modules/files/transmission/FileReference.d.ts +0 -8
  214. package/dist/modules/files/transmission/FileReference.d.ts.map +0 -1
  215. package/dist/modules/files/transmission/FileReference.js +0 -25
  216. package/dist/modules/files/transmission/FileReference.js.map +0 -1
  217. package/dist/util/Random.d.ts +0 -51
  218. package/dist/util/Random.d.ts.map +0 -1
  219. package/dist/util/Random.js +0 -128
  220. package/dist/util/Random.js.map +0 -1
@@ -1,101 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Reference = void 0;
13
- const ts_serval_1 = require("@js-soft/ts-serval");
14
- const core_types_1 = require("@nmshd/core-types");
15
- const crypto_1 = require("@nmshd/crypto");
16
- const TransportCoreErrors_1 = require("./TransportCoreErrors");
17
- const types_1 = require("./types");
18
- let Reference = class Reference extends ts_serval_1.Serializable {
19
- truncate() {
20
- const idPart = this.backboneBaseUrl ? `${this.id.toString()}@${this.backboneBaseUrl}` : this.id.toString();
21
- const truncatedReference = crypto_1.CoreBuffer.fromUtf8(`${idPart}|${this.key.algorithm}|${this.key.secretKey.toBase64URL()}|${this.forIdentityTruncated ?? ""}|${this.passwordProtection?.truncate() ?? ""}`);
22
- return truncatedReference.toBase64URL();
23
- }
24
- static fromTruncated(value) {
25
- const truncatedBuffer = crypto_1.CoreBuffer.fromBase64URL(value);
26
- const splitted = truncatedBuffer.toUtf8().split("|");
27
- if (![3, 5].includes(splitted.length)) {
28
- throw TransportCoreErrors_1.TransportCoreErrors.general.invalidTruncatedReference(`A truncated reference must consist of either exactly 3 or exactly 5 components, but it consists of '${splitted.length}' components.`);
29
- }
30
- const idPart = splitted[0];
31
- const [id, backboneBaseUrl] = idPart.split("@");
32
- const secretKey = this.parseSecretKey(splitted[1], splitted[2]);
33
- const forIdentityTruncated = splitted[3] ? splitted[3] : undefined;
34
- const passwordProtection = types_1.SharedPasswordProtection.fromTruncated(splitted[4]);
35
- return this.from({
36
- id: core_types_1.CoreId.from(id),
37
- backboneBaseUrl,
38
- key: secretKey,
39
- forIdentityTruncated,
40
- passwordProtection
41
- });
42
- }
43
- static parseSecretKey(alg, secretKey) {
44
- let algorithm;
45
- try {
46
- algorithm = parseInt(alg);
47
- }
48
- catch (_) {
49
- throw TransportCoreErrors_1.TransportCoreErrors.general.invalidTruncatedReference("The encryption algorithm must be indicated by an integer in the TruncatedReference.");
50
- }
51
- if (Number.isNaN(algorithm) || typeof algorithm === "undefined") {
52
- throw TransportCoreErrors_1.TransportCoreErrors.general.invalidTruncatedReference("The encryption algorithm must be indicated by an integer in the TruncatedReference.");
53
- }
54
- return crypto_1.CryptoSecretKey.from({
55
- algorithm,
56
- secretKey: crypto_1.CoreBuffer.fromBase64URL(secretKey)
57
- });
58
- }
59
- static validateId(value, helper) {
60
- if (!value?.id)
61
- return;
62
- if (!helper.validate(value.id)) {
63
- throw new ts_serval_1.ValidationError(this.name, "id", `id must start with '${helper.prefix}' but is '${value.id}'`);
64
- }
65
- }
66
- static from(value) {
67
- if (typeof value === "string")
68
- return this.fromTruncated(value);
69
- return this.fromAny(value);
70
- }
71
- };
72
- exports.Reference = Reference;
73
- __decorate([
74
- (0, ts_serval_1.validate)({ regExp: new RegExp("^[A-Za-z0-9]{20}$") }),
75
- (0, ts_serval_1.serialize)(),
76
- __metadata("design:type", core_types_1.CoreId)
77
- ], Reference.prototype, "id", void 0);
78
- __decorate([
79
- (0, ts_serval_1.validate)({ nullable: true }),
80
- (0, ts_serval_1.serialize)(),
81
- __metadata("design:type", String)
82
- ], Reference.prototype, "backboneBaseUrl", void 0);
83
- __decorate([
84
- (0, ts_serval_1.validate)(),
85
- (0, ts_serval_1.serialize)(),
86
- __metadata("design:type", crypto_1.CryptoSecretKey)
87
- ], Reference.prototype, "key", void 0);
88
- __decorate([
89
- (0, ts_serval_1.validate)({ nullable: true, regExp: new RegExp("^[0-9a-f]{4}$") }),
90
- (0, ts_serval_1.serialize)(),
91
- __metadata("design:type", String)
92
- ], Reference.prototype, "forIdentityTruncated", void 0);
93
- __decorate([
94
- (0, ts_serval_1.validate)({ nullable: true }),
95
- (0, ts_serval_1.serialize)(),
96
- __metadata("design:type", types_1.SharedPasswordProtection)
97
- ], Reference.prototype, "passwordProtection", void 0);
98
- exports.Reference = Reference = __decorate([
99
- (0, ts_serval_1.type)("Reference")
100
- ], Reference);
101
- //# sourceMappingURL=Reference.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Reference.js","sourceRoot":"","sources":["../../src/core/Reference.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA6G;AAC7G,kDAAoD;AACpD,0CAA8E;AAE9E,+DAA4D;AAC5D,mCAA8E;AAWvE,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,wBAAY;IAqBhC,QAAQ;QACX,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC;QAE3G,MAAM,kBA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AK,CAAC,CAAC;IAC/B,CAAC;CACJ,CAAA;AAzFY,8BAAS;AAGX;IAFN,IAAA,oBAAQ,EAAC,EAAE,MAAM,EAAE,IAAI,MAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC;IACrD,IAAA,qBAAS,GAAE;8BACD,mBAAM;qCAAC;AAIX;IAFN,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,IAAA,qBAAS,GAAE;;kDACoB;AAIzB;IAFN,IAAA,oBAAQ,GAAE;IACV,IAAA,qBAAS,GAAE;8BACA,wBAAe;sCAAC;AAIrB;IAFN,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;IACjE,IAAA,qBAAS,GAAE;;uDACyB;AAI9B;IAFN,IAAA,oBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC5B,IAAA,qBAAS,GAAE;8BACgB,gCAAwB;qDAAC;oBAnB5C,SAAS;IADrB,IAAA,gBAAI,EAAC,WAAW,CAAC;GACL,SAAS,CAyFrB"}
@@ -1,14 +0,0 @@
1
- import { ISerializable, Serializable } from "@js-soft/ts-serval";
2
- import { CoreBuffer, ICoreBuffer } from "@nmshd/crypto";
3
- export interface ISharedPasswordProtection extends ISerializable {
4
- passwordType: "pw" | `pin${number}`;
5
- salt: ICoreBuffer;
6
- }
7
- export declare class SharedPasswordProtection extends Serializable implements ISharedPasswordProtection {
8
- passwordType: "pw" | `pin${number}`;
9
- salt: CoreBuffer;
10
- static from(value: ISharedPasswordProtection): SharedPasswordProtection;
11
- static fromTruncated(value?: string): SharedPasswordProtection | undefined;
12
- truncate(): string;
13
- }
14
- //# sourceMappingURL=SharedPasswordProtection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SharedPasswordProtection.d.ts","sourceRoot":"","sources":["../../../src/core/types/SharedPasswordProtection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,WAAW,yBAA0B,SAAQ,aAAa;IAC5D,YAAY,EAAE,IAAI,GAAG,MAAM,MAAM,EAAE,CAAC;IACpC,IAAI,EAAE,WAAW,CAAC;CACrB;AAED,qBAAa,wBAAyB,SAAQ,YAAa,YAAW,yBAAyB;IAGpF,YAAY,EAAE,IAAI,GAAG,MAAM,MAAM,EAAE,CAAC;IAIpC,IAAI,EAAE,UAAU,CAAC;WAEV,IAAI,CAAC,KAAK,EAAE,yBAAyB,GAAG,wBAAwB;WAIhE,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS;IAiB1E,QAAQ,IAAI,MAAM;CAG5B"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SharedPasswordProtection = void 0;
13
- const ts_serval_1 = require("@js-soft/ts-serval");
14
- const crypto_1 = require("@nmshd/crypto");
15
- const TransportCoreErrors_1 = require("../TransportCoreErrors");
16
- class SharedPasswordProtection extends ts_serval_1.Serializable {
17
- static from(value) {
18
- return this.fromAny(value);
19
- }
20
- static fromTruncated(value) {
21
- if (value === undefined || value === "")
22
- return undefined;
23
- const splittedPasswordParts = value.split("&");
24
- if (splittedPasswordParts.length !== 2) {
25
- throw TransportCoreErrors_1.TransportCoreErrors.general.invalidTruncatedReference("The password part of a TruncatedReference must consist of exactly 2 components.");
26
- }
27
- const passwordType = splittedPasswordParts[0];
28
- try {
29
- const salt = crypto_1.CoreBuffer.fromBase64(splittedPasswordParts[1]);
30
- return SharedPasswordProtection.from({ passwordType, salt });
31
- }
32
- catch (_) {
33
- throw TransportCoreErrors_1.TransportCoreErrors.general.invalidTruncatedReference("The salt needs to be a Base64 value.");
34
- }
35
- }
36
- truncate() {
37
- return `${this.passwordType}&${this.salt.toBase64()}`;
38
- }
39
- }
40
- exports.SharedPasswordProtection = SharedPasswordProtection;
41
- __decorate([
42
- (0, ts_serval_1.validate)({ regExp: /^(pw|pin(4|5|6|7|8|9|10|11|12|13|14|15|16))$/ }),
43
- (0, ts_serval_1.serialize)(),
44
- __metadata("design:type", String)
45
- ], SharedPasswordProtection.prototype, "passwordType", void 0);
46
- __decorate([
47
- (0, ts_serval_1.validate)({ customValidator: (v) => (v.buffer.byteLength === 16 ? undefined : "must be 16 bytes long") }),
48
- (0, ts_serval_1.serialize)(),
49
- __metadata("design:type", crypto_1.CoreBuffer)
50
- ], SharedPasswordProtection.prototype, "salt", void 0);
51
- //# sourceMappingURL=SharedPasswordProtection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SharedPasswordProtection.js","sourceRoot":"","sources":["../../../src/core/types/SharedPasswordProtection.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAsF;AACtF,0CAAwD;AACxD,gEAA6D;AAO7D,MAAa,wBAAyB,SAAQ,wBAAY;IAS/C,MAAM,CAAC,IAAI,CAAC,KAAgC;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,KAAc;QACtC,IAAI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are class FileReference extends Reference implements IFileReference {
5
- protected static preFrom(value: any): any;
6
- static from(value: IFileReference | string): FileReference;
7
- }
8
- //# sourceMappingURL=FileReference.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileReference.d.ts","sourceRoot":"","sources":["../../../../src/modules/files/transmission/FileReference.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEnE,MAAM,WAAW,cAAe,SAAQ,UAAU;CAAG;AAErD,qBACa,aAAc,SAAQ,SAAU,YAAW,cAAc;qBACxC,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG;WAM3B,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,aAAa;CAG7E"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.FileReference = void 0;
10
- const ts_serval_1 = require("@js-soft/ts-serval");
11
- const core_1 = require("../../../core");
12
- let FileReference = class FileReference extends core_1.Reference {
13
- static preFrom(value) {
14
- super.validateId(value, core_1.BackboneIds.file);
15
- return value;
16
- }
17
- static from(value) {
18
- return super.from(value);
19
- }
20
- };
21
- exports.FileReference = FileReference;
22
- exports.FileReference = FileReference = __decorate([
23
- (0, ts_serval_1.type)("FileReference")
24
- ], FileReference);
25
- //# sourceMappingURL=FileReference.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FileReference.js","sourceRoot":"","sources":["../../../../src/modules/files/transmission/FileReference.ts"],"names":[],"mappings":";;;;;;;;;AAAA,kDAA0C;AAC1C,wCAAmE;AAK5D,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,gBAAS;IAC9B,MAAM,CAAU,OAAO,CAAC,KAAU;QACxC,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,kBAAW,CAAC,IAAI,CAAC,CAAC;QAE1C,OAAO,KAAK,CAAC;IACjB,CAAC;IAEM,MAAM,CAAU,IAAI,CAAC,KAA8B;QACtD,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;CACJ,CAAA;AAVY,sCAAa;wBAAb,aAAa;IADzB,IAAA,gBAAI,EAAC,eAAe,CAAC;GACT,aAAa,CAUzB"}
@@ -1,51 +0,0 @@
1
- import { ICoreBuffer } from "@nmshd/crypto";
2
- export declare enum RandomCharacterRange {
3
- Digit = "0123456789",
4
- DigitEase = "123456789",
5
- Hex = "0123456789ABCDEF",
6
- LowerCase = "abcdefghijklmnopqrstuvwxyz",
7
- LowerCaseEase = "abcdefghijkmnpqrstuvwxyz",
8
- UpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
9
- UpperCaseEase = "ABCDEFGHJKLMNPQRSTUVWXYZ",
10
- Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
11
- Alphanumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
12
- AlphanumericEase = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789",
13
- AlphanumericUpperCaseEase = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789",
14
- GermanUmlaut = "\u00C4\u00D6\u00DC\u00E4\u00F6\u00FC",
15
- SpecialCharacters = "!?-_.:,;#+"
16
- }
17
- export interface RandomCharacterBucket {
18
- minLength: number;
19
- maxLength: number;
20
- allowedChars: string | string[];
21
- }
22
- export interface IRandom {
23
- }
24
- export interface IRandomStatic {
25
- new (): IRandom;
26
- bytes(length: number): Promise<ICoreBuffer>;
27
- int(length: number): Promise<number>;
28
- array(length: number): Promise<any>;
29
- uuid(): Promise<string>;
30
- scramble(input: string): Promise<string>;
31
- intBetween(min: number, max: number): Promise<number>;
32
- intRandomLength(minLength: number, maxLength: number): Promise<number>;
33
- scrambleWithBuckets(buckets: RandomCharacterBucket[]): Promise<string>;
34
- stringWithBuckets(buckets: RandomCharacterBucket[]): Promise<string>;
35
- string(length: number, allowedChars?: string | string[]): Promise<string>;
36
- stringRandomLength(minLength: number, maxLength: number, allowedChars?: string | string[]): Promise<string>;
37
- }
38
- export declare class Random implements IRandom {
39
- static bytes(length: number): Promise<ICoreBuffer>;
40
- static int(length: number): Promise<number>;
41
- static array(length: number): Promise<any>;
42
- static uuid(): string;
43
- static scramble(input: string): Promise<string>;
44
- static intBetween(min: number, max: number): Promise<number>;
45
- static intRandomLength(minLength: number, maxLength: number): Promise<number>;
46
- static scrambleWithBuckets(buckets: RandomCharacterBucket[]): Promise<string>;
47
- static stringWithBuckets(buckets: RandomCharacterBucket[]): Promise<string>;
48
- static string(length: number, allowedChars?: string | string[]): Promise<string>;
49
- static stringRandomLength(minLength: number, maxLength: number, allowedChars?: string | string[]): Promise<string>;
50
- }
51
- //# sourceMappingURL=Random.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Random.d.ts","sourceRoot":"","sources":["../../src/util/Random.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,WAAW,EAAE,MAAM,eAAe,CAAC;AAG1D,oBAAY,oBAAoB;IAC5B,KAAK,eAAe;IACpB,SAAS,cAAc;IACvB,GAAG,qBAAqB;IACxB,SAAS,+BAA+B;IACxC,aAAa,6BAA6B;IAC1C,SAAS,+BAA+B;IACxC,aAAa,6BAA6B;IAC1C,QAAQ,yDAAyD;IACjE,YAAY,mEAAmE;IAE/E,gBAAgB,8DAA8D;IAC9E,yBAAyB,uCAA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AC;CAC/G;AAED,qBAAa,MAAO,YAAW,OAAO;WACd,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;WAG3C,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAMpC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;WAIzC,IAAI,IAAI,MAAM;WAIR,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAYxC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WA0BrD,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAOtE,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;WAKtE,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;WAQpE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,GAAE,MAAM,GAAG,MAAM,EAAsC,GAAG,OAAO,CAAC,MAAM,CAAC;WAyB5G,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAYlI"}
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Random = exports.RandomCharacterRange = void 0;
4
- const crypto_1 = require("@nmshd/crypto");
5
- const uuid_1 = require("uuid");
6
- var RandomCharacterRange;
7
- (function (RandomCharacterRange) {
8
- RandomCharacterRange["Digit"] = "0123456789";
9
- RandomCharacterRange["DigitEase"] = "123456789";
10
- RandomCharacterRange["Hex"] = "0123456789ABCDEF";
11
- RandomCharacterRange["LowerCase"] = "abcdefghijklmnopqrstuvwxyz";
12
- RandomCharacterRange["LowerCaseEase"] = "abcdefghijkmnpqrstuvwxyz";
13
- RandomCharacterRange["UpperCase"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
14
- RandomCharacterRange["UpperCaseEase"] = "ABCDEFGHJKLMNPQRSTUVWXYZ";
15
- RandomCharacterRange["Alphabet"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
16
- RandomCharacterRange["Alphanumeric"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
17
- // Without I, l, O, o, 0
18
- RandomCharacterRange["AlphanumericEase"] = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789";
19
- RandomCharacterRange["AlphanumericUpperCaseEase"] = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789";
20
- RandomCharacterRange["GermanUmlaut"] = "\u00C4\u00D6\u00DC\u00E4\u00F6\u00FC";
21
- RandomCharacterRange["SpecialCharacters"] = "!?-_.:,;#+";
22
- })(RandomCharacterRange || (exports.RandomCharacterRange = RandomCharacterRange = {}));
23
- class Random {
24
- static async bytes(length) {
25
- return await crypto_1.CryptoRandom.bytes(length);
26
- }
27
- static async int(length) {
28
- if (length > 21 || length <= 0) {
29
- throw new Error("Length must be between 1 and 21.");
30
- }
31
- return parseInt(await this.string(length, RandomCharacterRange.Digit));
32
- }
33
- static async array(length) {
34
- return (await crypto_1.CryptoRandom.bytes(length)).toArray();
35
- }
36
- static uuid() {
37
- return (0, uuid_1.v4)();
38
- }
39
- static async scramble(input) {
40
- const out = [];
41
- const inar = input.split("");
42
- const length = input.length;
43
- for (let i = 0; i < length - 1; i++) {
44
- const charAt = await Random.intBetween(0, length - 1 - i);
45
- out.push(inar.splice(charAt, 1)[0]);
46
- }
47
- out.push(inar[0]);
48
- return out.join("");
49
- }
50
- static async intBetween(min, max) {
51
- if (max <= min) {
52
- throw new Error("Max must be larger than min.");
53
- }
54
- const diff = max - min + 1;
55
- const bitLength = Math.abs(Math.ceil(Math.log2(diff)));
56
- if (bitLength > 32) {
57
- throw new Error("The range between the numbers is too big, 32 bit is the maximum -> 4294967296");
58
- }
59
- const byteLength = Math.ceil(bitLength / 8);
60
- const bitMask = Math.pow(2, bitLength) - 1;
61
- const randomArray = await this.bytes(byteLength);
62
- let value = 0;
63
- let p = (byteLength - 1) * 8;
64
- for (let i = 0; i < byteLength; i++) {
65
- value += randomArray.buffer[i] * Math.pow(2, p);
66
- p -= 8;
67
- }
68
- value = value & bitMask;
69
- if (value >= diff) {
70
- return await this.intBetween(min, max);
71
- }
72
- return min + value;
73
- }
74
- static async intRandomLength(minLength, maxLength) {
75
- if (maxLength > 21) {
76
- throw new Error("Max must be below 22.");
77
- }
78
- return parseInt(await this.stringRandomLength(minLength, maxLength, RandomCharacterRange.Digit));
79
- }
80
- static async scrambleWithBuckets(buckets) {
81
- const str = await this.stringWithBuckets(buckets);
82
- return await this.scramble(str);
83
- }
84
- static async stringWithBuckets(buckets) {
85
- const str = [];
86
- for (const bucket of buckets) {
87
- str.push(await this.stringRandomLength(bucket.minLength, bucket.maxLength, bucket.allowedChars));
88
- }
89
- return str.join("");
90
- }
91
- static async string(length, allowedChars = RandomCharacterRange.Alphanumeric) {
92
- if (length <= 0)
93
- return "";
94
- if (allowedChars.length > 256) {
95
- throw new Error("Input exceeds maximum length of 256.");
96
- }
97
- const ar = [];
98
- const inputLength = allowedChars.length;
99
- const random = await this.array(length + 10);
100
- const max = 255 - (255 % inputLength);
101
- for (let i = 0; i < length; i++) {
102
- const nmb = random[i];
103
- if (nmb > max) {
104
- // Reject random value to remove bias if we are at the
105
- // upper (and incomplete end) of possible random values
106
- continue;
107
- }
108
- ar.push(allowedChars[nmb % inputLength]);
109
- }
110
- let retStr = ar.join("");
111
- if (retStr.length < length) {
112
- retStr += await this.string(length - retStr.length, allowedChars);
113
- }
114
- return retStr;
115
- }
116
- static async stringRandomLength(minLength, maxLength, allowedChars) {
117
- if (minLength > maxLength) {
118
- throw new Error("maxLength must be larger than minLength.");
119
- }
120
- if (minLength < 0) {
121
- throw new Error("minlength must not be less than zero.");
122
- }
123
- const length = maxLength > minLength ? await this.intBetween(minLength, maxLength) : maxLength;
124
- return await this.string(length, allowedChars);
125
- }
126
- }
127
- exports.Random = Random;
128
- //# sourceMappingURL=Random.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Random.js","sourceRoot":"","sources":["../../src/util/Random.ts"],"names":[],"mappings":";;;AAAA,0CAA0D;AAC1D,+BAAoC;AAEpC,IAAY,oBAeX;AAfD,WAAY,oBAAoB;IAC5B,4CAAoB,CAAA;IACpB,+CAAuB,CAAA;IACvB,gDAAwB,CAAA;IACxB,gEAAwC,CAAA;IACxC,kEAA0C,CAAA;IAC1C,gEAAwC,CAAA;IACxC,kEAA0C,CAAA;IAC1C,yFAAiE,CAAA;IACjE,uGAA+E,CAAA;IAC/E,wBAAwB;IACxB,sGAA8E,CAAA;IAC9E,wFAAgE,CAAA;IAChE,6EAAuB,CAAA;IACvB,wDAAgC,CAAA;AACpC,CAAC,EAfW,oBAAoB,oCAApB,oBAAoB,QAe/B;AAyBD,MAAa,MAAM;IACR,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAc;QACpC,OAAO,MAAM,qBAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,MAAc;QAClC,IAAI,MAAM,GAAG,EAAE,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,QAAQ,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,KAAK,CAA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