@api-client/core 0.3.3 → 0.3.6
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.
- package/build/browser.d.ts +3 -0
- package/build/browser.js +9 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +11 -2
- package/build/index.js +20 -2
- package/build/index.js.map +1 -1
- package/build/src/lib/fs/Fs.d.ts +52 -0
- package/build/src/lib/fs/Fs.js +245 -0
- package/build/src/lib/fs/Fs.js.map +1 -0
- package/build/src/lib/timers/Timers.d.ts +5 -0
- package/build/src/lib/timers/Timers.js +10 -0
- package/build/src/lib/timers/Timers.js.map +1 -0
- package/build/src/mocking/ProjectMock.d.ts +13 -0
- package/build/src/mocking/ProjectMock.js +16 -0
- package/build/src/mocking/ProjectMock.js.map +1 -0
- package/build/src/mocking/lib/Request.d.ts +32 -0
- package/build/src/mocking/lib/Request.js +63 -0
- package/build/src/mocking/lib/Request.js.map +1 -0
- package/build/src/mocking/lib/Response.d.ts +33 -0
- package/build/src/mocking/lib/Response.js +79 -0
- package/build/src/mocking/lib/Response.js.map +1 -0
- package/build/src/models/ErrorResponse.d.ts +5 -4
- package/build/src/models/ErrorResponse.js +18 -5
- package/build/src/models/ErrorResponse.js.map +1 -1
- package/build/src/models/SerializableError.d.ts +30 -0
- package/build/src/models/SerializableError.js +63 -0
- package/build/src/models/SerializableError.js.map +1 -0
- package/build/src/runtime/http-engine/ArcEngine.js +8 -4
- package/build/src/runtime/http-engine/ArcEngine.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.d.ts +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js +3 -3
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/http-engine/NodeEngine.js +9 -4
- package/build/src/runtime/http-engine/NodeEngine.js.map +1 -1
- package/build/src/runtime/http-engine/NodeEngineDirect.js +8 -2
- package/build/src/runtime/http-engine/NodeEngineDirect.js.map +1 -1
- package/build/src/runtime/node/BaseRunner.d.ts +21 -0
- package/build/src/runtime/node/BaseRunner.js +27 -0
- package/build/src/runtime/node/BaseRunner.js.map +1 -0
- package/build/src/runtime/node/ProjectParallelRunner.d.ts +81 -0
- package/build/src/runtime/node/ProjectParallelRunner.js +173 -0
- package/build/src/runtime/node/ProjectParallelRunner.js.map +1 -0
- package/build/src/runtime/node/ProjectRequestRunner.d.ts +125 -0
- package/build/src/runtime/node/ProjectRequestRunner.js +185 -0
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -0
- package/build/src/runtime/node/ProjectRunner.d.ts +166 -64
- package/build/src/runtime/node/ProjectRunner.js +191 -139
- package/build/src/runtime/node/ProjectRunner.js.map +1 -1
- package/build/src/runtime/node/ProjectRunnerWorker.d.ts +1 -0
- package/build/src/runtime/node/ProjectRunnerWorker.js +58 -0
- package/build/src/runtime/node/ProjectRunnerWorker.js.map +1 -0
- package/build/src/runtime/node/ProjectSerialRunner.d.ts +11 -0
- package/build/src/runtime/node/ProjectSerialRunner.js +34 -0
- package/build/src/runtime/node/ProjectSerialRunner.js.map +1 -0
- package/build/src/runtime/reporters/ProjectRunCliReporter.d.ts +7 -0
- package/build/src/runtime/reporters/ProjectRunCliReporter.js +73 -0
- package/build/src/runtime/reporters/ProjectRunCliReporter.js.map +1 -0
- package/build/src/runtime/reporters/Reporter.d.ts +62 -0
- package/build/src/runtime/reporters/Reporter.js +98 -0
- package/build/src/runtime/reporters/Reporter.js.map +1 -0
- package/build/src/testing/TestCliHelper.d.ts +23 -0
- package/build/src/testing/TestCliHelper.js +71 -0
- package/build/src/testing/TestCliHelper.js.map +1 -0
- package/build/src/testing/getPort.d.ts +52 -0
- package/build/src/testing/getPort.js +169 -0
- package/build/src/testing/getPort.js.map +1 -0
- package/package.json +2 -1
- package/src/data/DataReader.ts +11 -0
- package/src/data/DataUtils.ts +108 -0
- package/src/data/JmesparthReader.ts +26 -0
- package/src/data/Json2Xml.ts +190 -0
- package/src/data/JsonReader.ts +41 -0
- package/src/data/PayloadPointer.ts +48 -0
- package/src/data/RequestDataExtractor.ts +133 -0
- package/src/data/UrlEncodedReader.ts +20 -0
- package/src/data/XmlReader.ts +103 -0
- package/src/events/BaseEvents.ts +259 -0
- package/src/events/CustomEvent.ts +27 -0
- package/src/events/EventTypes.ts +19 -0
- package/src/events/Events.ts +19 -0
- package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
- package/src/events/authorization/AuthorizationEvents.ts +61 -0
- package/src/events/cookies/CookieEventTypes.ts +13 -0
- package/src/events/cookies/CookieEvents.ts +157 -0
- package/src/events/encryption/EncryptionEventTypes.ts +4 -0
- package/src/events/encryption/EncryptionEvents.ts +51 -0
- package/src/events/environment/EnvironmentEventTypes.ts +3 -0
- package/src/events/environment/EnvironmentEvents.ts +24 -0
- package/src/events/models/ClientCertificateEvents.ts +87 -0
- package/src/events/models/ModelEventTypes.ts +47 -0
- package/src/events/models/ModelEvents.ts +7 -0
- package/src/events/models/ProjectEvents.ts +331 -0
- package/src/events/process/ProcessEventTypes.ts +5 -0
- package/src/events/process/ProcessEvents.ts +76 -0
- package/src/events/readme.md +22 -0
- package/src/events/reporting/ReportingEventTypes.ts +3 -0
- package/src/events/reporting/ReportingEvents.ts +28 -0
- package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
- package/src/events/telemetry/TelemetryEvents.ts +156 -0
- package/src/lib/cookies/Cookie.ts +312 -0
- package/src/lib/cookies/Cookies.ts +326 -0
- package/src/lib/cookies/Utils.ts +168 -0
- package/src/lib/fs/Fs.ts +258 -0
- package/src/lib/headers/Headers.ts +219 -0
- package/src/lib/logging/DefaultLogger.ts +19 -0
- package/src/lib/logging/DummyLogger.ts +21 -0
- package/src/lib/logging/Logger.ts +16 -0
- package/src/lib/timers/Timers.ts +9 -0
- package/src/lib/transformers/PayloadSerializer.ts +332 -0
- package/src/lib/transformers/Utils.ts +18 -0
- package/src/lib/uuid.ts +40 -0
- package/src/mocking/LegacyInterfaces.ts +52 -0
- package/src/mocking/LegacyMock.ts +37 -0
- package/src/mocking/ProjectMock.ts +20 -0
- package/src/mocking/legacy/Authorization.ts +39 -0
- package/src/mocking/legacy/Certificates.ts +145 -0
- package/src/mocking/legacy/Cookies.ts +51 -0
- package/src/mocking/legacy/HostRules.ts +43 -0
- package/src/mocking/legacy/Http.ts +236 -0
- package/src/mocking/legacy/HttpResponse.ts +106 -0
- package/src/mocking/legacy/RestApi.ts +68 -0
- package/src/mocking/legacy/Urls.ts +44 -0
- package/src/mocking/legacy/Variables.ts +53 -0
- package/src/mocking/lib/Request.ts +85 -0
- package/src/mocking/lib/Response.ts +101 -0
- package/src/models/ArcResponse.ts +166 -0
- package/src/models/Authorization.ts +481 -0
- package/src/models/AuthorizationData.ts +60 -0
- package/src/models/Backend.ts +107 -0
- package/src/models/ClientCertificate.ts +68 -0
- package/src/models/Environment.ts +279 -0
- package/src/models/ErrorResponse.ts +113 -0
- package/src/models/HistoryIndex.ts +76 -0
- package/src/models/HistoryRequest.ts +28 -0
- package/src/models/HostRule.ts +163 -0
- package/src/models/HttpCookie.ts +285 -0
- package/src/models/HttpProject.ts +1294 -0
- package/src/models/HttpProjectListItem.ts +23 -0
- package/src/models/HttpRequest.ts +124 -0
- package/src/models/HttpResponse.ts +143 -0
- package/src/models/License.ts +113 -0
- package/src/models/ProjectDefinitionProperty.ts +40 -0
- package/src/models/ProjectFolder.ts +439 -0
- package/src/models/ProjectItem.ts +135 -0
- package/src/models/ProjectParent.ts +113 -0
- package/src/models/ProjectRequest.ts +277 -0
- package/src/models/ProjectSchema.ts +202 -0
- package/src/models/Property.ts +423 -0
- package/src/models/Provider.ts +98 -0
- package/src/models/README.md +20 -0
- package/src/models/Request.ts +452 -0
- package/src/models/RequestActions.ts +163 -0
- package/src/models/RequestAuthorization.ts +115 -0
- package/src/models/RequestConfig.ts +317 -0
- package/src/models/RequestLog.ts +159 -0
- package/src/models/RequestTime.ts +108 -0
- package/src/models/RequestUiMeta.ts +258 -0
- package/src/models/RequestsSize.ts +65 -0
- package/src/models/ResponseAuthorization.ts +104 -0
- package/src/models/ResponseRedirect.ts +158 -0
- package/src/models/RevisionInfo.ts +37 -0
- package/src/models/SentRequest.ts +125 -0
- package/src/models/SerializableError.ts +80 -0
- package/src/models/SerializablePayload.ts +68 -0
- package/src/models/Server.ts +153 -0
- package/src/models/Thing.ts +110 -0
- package/src/models/Url.ts +90 -0
- package/src/models/User.ts +120 -0
- package/src/models/WebApi.ts +234 -0
- package/src/models/WebApiIndex.ts +122 -0
- package/src/models/Workspace.ts +182 -0
- package/src/models/actions/Action.ts +213 -0
- package/src/models/actions/ActionView.ts +40 -0
- package/src/models/actions/Condition.ts +207 -0
- package/src/models/actions/ConditionView.ts +42 -0
- package/src/models/actions/Enums.ts +29 -0
- package/src/models/actions/RunnableAction.ts +144 -0
- package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
- package/src/models/actions/runnable/Runnable.ts +9 -0
- package/src/models/actions/runnable/SetCookieAction.ts +216 -0
- package/src/models/actions/runnable/SetVariableAction.ts +81 -0
- package/src/models/legacy/DataExport.ts +172 -0
- package/src/models/legacy/Normalizer.ts +110 -0
- package/src/models/legacy/actions/Actions.ts +269 -0
- package/src/models/legacy/authorization/Authorization.ts +572 -0
- package/src/models/legacy/models/ApiTypes.ts +202 -0
- package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
- package/src/models/legacy/models/AuthData.ts +17 -0
- package/src/models/legacy/models/ClientCertificate.ts +95 -0
- package/src/models/legacy/models/Cookies.ts +52 -0
- package/src/models/legacy/models/HostRule.ts +35 -0
- package/src/models/legacy/models/RestApi.ts +49 -0
- package/src/models/legacy/models/UrlHistory.ts +37 -0
- package/src/models/legacy/models/Variable.ts +43 -0
- package/src/models/legacy/models/base.d.ts +95 -0
- package/src/models/legacy/request/ArcRequest.ts +405 -0
- package/src/models/legacy/request/ArcResponse.ts +177 -0
- package/src/models/legacy/request/HistoryData.ts +47 -0
- package/src/models/legacy/request/Legacy.ts +45 -0
- package/src/models/legacy/request/RequestBody.ts +87 -0
- package/src/models/transformers/ArcDexieTransformer.ts +323 -0
- package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
- package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
- package/src/models/transformers/ArcPouchTransformer.ts +184 -0
- package/src/models/transformers/BaseTransformer.ts +116 -0
- package/src/models/transformers/ImportUtils.ts +141 -0
- package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
- package/src/models/transformers/LegacyExportProcessor.ts +252 -0
- package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
- package/src/models/transformers/PostmanDataTransformer.ts +50 -0
- package/src/models/transformers/PostmanTransformer.ts +106 -0
- package/src/models/transformers/PostmanV21Transformer.ts +311 -0
- package/src/models/transformers/PostmanV2Transformer.ts +308 -0
- package/src/models/transformers/har.ts +865 -0
- package/src/runtime/actions/ActionRunner.ts +83 -0
- package/src/runtime/actions/ConditionRunner.ts +194 -0
- package/src/runtime/actions/RunnableCondition.ts +57 -0
- package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
- package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
- package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
- package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
- package/src/runtime/http-engine/ArcEngine.ts +1068 -0
- package/src/runtime/http-engine/FormData.ts +85 -0
- package/src/runtime/http-engine/HttpEngine.ts +874 -0
- package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
- package/src/runtime/http-engine/NodeEngine.ts +792 -0
- package/src/runtime/http-engine/NodeEngineDirect.ts +482 -0
- package/src/runtime/http-engine/PayloadSupport.ts +84 -0
- package/src/runtime/http-engine/RequestUtils.ts +164 -0
- package/src/runtime/http-engine/ntlm/Des.ts +345 -0
- package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
- package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
- package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
- package/src/runtime/modules/BasicAuthCache.ts +133 -0
- package/src/runtime/modules/ExecutionResponse.ts +4 -0
- package/src/runtime/modules/ModulesRegistry.ts +136 -0
- package/src/runtime/modules/RequestAuthorization.ts +110 -0
- package/src/runtime/modules/RequestCookies.ts +145 -0
- package/src/runtime/node/BaseRunner.ts +29 -0
- package/src/runtime/node/ProjectParallelRunner.ts +234 -0
- package/src/runtime/node/ProjectRequestRunner.ts +281 -0
- package/src/runtime/node/ProjectRunner.ts +374 -0
- package/src/runtime/node/ProjectRunnerWorker.ts +62 -0
- package/src/runtime/node/ProjectSerialRunner.ts +36 -0
- package/src/runtime/node/RequestFactory.ts +422 -0
- package/src/runtime/node/VariablesStore.ts +25 -0
- package/src/runtime/reporters/ProjectRunCliReporter.ts +79 -0
- package/src/runtime/reporters/Reporter.ts +142 -0
- package/src/runtime/store/StoreSdk.ts +838 -0
- package/src/runtime/variables/Cache.ts +53 -0
- package/src/runtime/variables/EvalFunctions.ts +132 -0
- package/src/runtime/variables/ProjectVariables.ts +6 -0
- package/src/runtime/variables/VariablesProcessor.ts +543 -0
- package/src/runtime/variables/VariablesTokenizer.ts +55 -0
- package/src/testing/TestCliHelper.ts +76 -0
- package/src/testing/getPort.ts +212 -0
- package/build/src/runtime/http-engine/Errors.d.ts +0 -10
- package/build/src/runtime/http-engine/Errors.js +0 -14
- package/build/src/runtime/http-engine/Errors.js.map +0 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import CustomEvent from './CustomEvent.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base event detail definition for the events that returns a `result`
|
|
5
|
+
* property on the `detail` object
|
|
6
|
+
*/
|
|
7
|
+
export interface ContextEventDetailWithResult<T> {
|
|
8
|
+
/**
|
|
9
|
+
* This property is set by the context provider, a promise resolved when the operation finish
|
|
10
|
+
* with the corresponding result.
|
|
11
|
+
*/
|
|
12
|
+
result?: Promise<T> | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A base class to use with context providers.
|
|
17
|
+
*/
|
|
18
|
+
export class ContextEvent<S extends object, R> extends CustomEvent<ContextEventDetailWithResult<R>> {
|
|
19
|
+
/**
|
|
20
|
+
* @param type The event type
|
|
21
|
+
* @param detail The optional detail object. It adds object's properties to the `detail` with the `result` property.
|
|
22
|
+
*/
|
|
23
|
+
constructor(type: string, detail: S) {
|
|
24
|
+
super(type, {
|
|
25
|
+
bubbles: true,
|
|
26
|
+
composed: true,
|
|
27
|
+
cancelable: true,
|
|
28
|
+
detail: {
|
|
29
|
+
result: undefined,
|
|
30
|
+
...detail,
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ContextReadEventDetail {
|
|
37
|
+
/**
|
|
38
|
+
* The id of the state object to read.
|
|
39
|
+
*/
|
|
40
|
+
id: string;
|
|
41
|
+
/**
|
|
42
|
+
* Optional revision of the state, when supported by the context provider.
|
|
43
|
+
*/
|
|
44
|
+
rev?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* An event to be used to read a state from a context provider.
|
|
49
|
+
*/
|
|
50
|
+
export class ContextReadEvent<T> extends ContextEvent<ContextReadEventDetail, T> {
|
|
51
|
+
/**
|
|
52
|
+
* @param type The type of the event
|
|
53
|
+
* @param id The domain id of the object to read
|
|
54
|
+
* @param rev Optional revision of the state, when supported by the context provider.
|
|
55
|
+
*/
|
|
56
|
+
constructor(type: string, id: string, rev?: string) {
|
|
57
|
+
super(type, { id, rev });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface ContextReadBulkEventDetail {
|
|
62
|
+
/**
|
|
63
|
+
* The list of ids to read.
|
|
64
|
+
*/
|
|
65
|
+
ids: string[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* An event to be used to read a list of object from the API store.
|
|
70
|
+
*/
|
|
71
|
+
export class ContextReadBulkEvent<T> extends ContextEvent<ContextReadBulkEventDetail, T> {
|
|
72
|
+
/**
|
|
73
|
+
* @param type The type of the event
|
|
74
|
+
* @param ids The list of domain ids to read. These must be of the same domain type.
|
|
75
|
+
*/
|
|
76
|
+
constructor(type: string, ids: string[]) {
|
|
77
|
+
super(type, { ids });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A general purpose change record.
|
|
83
|
+
* Set on the `detail` object of the `CustomEvent` when a change occurs in the context store.
|
|
84
|
+
*/
|
|
85
|
+
export interface ContextChangeRecord<T> {
|
|
86
|
+
/**
|
|
87
|
+
* The data kind of the changed item.
|
|
88
|
+
* May not be present when this is used with the old architecture.
|
|
89
|
+
*/
|
|
90
|
+
kind?: string;
|
|
91
|
+
/**
|
|
92
|
+
* The ID of the changed context state object.
|
|
93
|
+
*/
|
|
94
|
+
key: string;
|
|
95
|
+
/**
|
|
96
|
+
* The revision of the updated context state object.
|
|
97
|
+
* It is not set when old revision is unavailable (new entity is created) or when the context provider does not support this value.
|
|
98
|
+
*/
|
|
99
|
+
oldRev?: string;
|
|
100
|
+
/**
|
|
101
|
+
* New revision of updated state object. May not be set when the context provider does not support this value.
|
|
102
|
+
*/
|
|
103
|
+
rev?: string;
|
|
104
|
+
/**
|
|
105
|
+
* The updated context state object.
|
|
106
|
+
*/
|
|
107
|
+
item?: T;
|
|
108
|
+
/**
|
|
109
|
+
* Optionally, when relevant, the id of the parent of the changed object.
|
|
110
|
+
*/
|
|
111
|
+
parent?: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface ContextDeleteEventDetail {
|
|
115
|
+
/**
|
|
116
|
+
* The id of the domain object to remove.
|
|
117
|
+
*/
|
|
118
|
+
id: string;
|
|
119
|
+
/**
|
|
120
|
+
* The id of the parent object, if applicable.
|
|
121
|
+
*/
|
|
122
|
+
parent?: string;
|
|
123
|
+
/**
|
|
124
|
+
* The revision to delete, when applicable.
|
|
125
|
+
*/
|
|
126
|
+
rev?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* An event to be used to delete a state in the context provider.
|
|
131
|
+
*/
|
|
132
|
+
export class ContextDeleteEvent extends ContextEvent<ContextDeleteEventDetail, ContextDeleteRecord> {
|
|
133
|
+
/**
|
|
134
|
+
* @param type The type of the event to dispatch.
|
|
135
|
+
* @param id The id of the object to delete
|
|
136
|
+
* @param parent The id of the parent object, if applicable.
|
|
137
|
+
*/
|
|
138
|
+
constructor(type: string, id: string, parent?: string, rev?: string) {
|
|
139
|
+
super(type, { id, parent, rev });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface ContextDeleteRecord {
|
|
144
|
+
/**
|
|
145
|
+
* The data kind of the deleted item.
|
|
146
|
+
* May not be present when this is used with the old architecture.
|
|
147
|
+
*/
|
|
148
|
+
kind?: string;
|
|
149
|
+
/**
|
|
150
|
+
* The id of the removed object.
|
|
151
|
+
*/
|
|
152
|
+
id: string;
|
|
153
|
+
/**
|
|
154
|
+
* The id of the parent object, if applicable.
|
|
155
|
+
*/
|
|
156
|
+
parent?: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* An event dispatched when a context store object has been deleted.
|
|
161
|
+
* In general a single context store uses the same event to dispatch the change record.
|
|
162
|
+
* For example the `data-store` dispatches the `x` event and the change record has the
|
|
163
|
+
* `kind` property that is used to recognize the type of the data object.
|
|
164
|
+
*/
|
|
165
|
+
export class ContextStateDeleteEvent extends CustomEvent<ContextDeleteRecord> {
|
|
166
|
+
/**
|
|
167
|
+
* @param type The type of the event to dispatch.
|
|
168
|
+
* @param record The delete record.
|
|
169
|
+
*/
|
|
170
|
+
constructor(type: string, record: ContextDeleteRecord) {
|
|
171
|
+
super(type, {
|
|
172
|
+
bubbles: true,
|
|
173
|
+
composed: true,
|
|
174
|
+
cancelable: false,
|
|
175
|
+
detail: record,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* An event dispatched when a context store object has been updated.
|
|
182
|
+
*/
|
|
183
|
+
export class ContextStateUpdateEvent<T> extends CustomEvent<ContextChangeRecord<T>> {
|
|
184
|
+
/**
|
|
185
|
+
* @param type The type of the event to dispatch.
|
|
186
|
+
* @param record The delete record.
|
|
187
|
+
*/
|
|
188
|
+
constructor(type: string, record: ContextChangeRecord<T>) {
|
|
189
|
+
super(type, {
|
|
190
|
+
bubbles: true,
|
|
191
|
+
composed: true,
|
|
192
|
+
cancelable: false,
|
|
193
|
+
detail: record,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export interface ContextUpdateEventDetail<T> {
|
|
199
|
+
/**
|
|
200
|
+
* The context store object to be updated by the context provider.
|
|
201
|
+
*/
|
|
202
|
+
item: T;
|
|
203
|
+
/**
|
|
204
|
+
* The id of the parent object, if applicable.
|
|
205
|
+
*/
|
|
206
|
+
parent?: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* An event that is dispatched to update the entire object in the store.
|
|
211
|
+
* This is equivalent to PUT operation in REST HTTP.
|
|
212
|
+
*
|
|
213
|
+
* @template T The object that is being updated.
|
|
214
|
+
*/
|
|
215
|
+
export class ContextUpdateEvent<T extends object> extends ContextEvent<ContextUpdateEventDetail<T>, ContextChangeRecord<T>> {
|
|
216
|
+
constructor(type: string, updateInfo: ContextUpdateEventDetail<T>) {
|
|
217
|
+
super(type, updateInfo);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Data store query result object.
|
|
223
|
+
*/
|
|
224
|
+
export interface ContextListResult<T> {
|
|
225
|
+
/**
|
|
226
|
+
* Next page token to be used with pagination.
|
|
227
|
+
* It is not set when the query has not returned any results.
|
|
228
|
+
*/
|
|
229
|
+
nextPageToken?: string;
|
|
230
|
+
/**
|
|
231
|
+
* The list of items in the response.
|
|
232
|
+
* May be empty array when there was no more results.
|
|
233
|
+
*/
|
|
234
|
+
items: T[];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Base query options for the data store.
|
|
239
|
+
*/
|
|
240
|
+
export interface ContextListOptions {
|
|
241
|
+
/**
|
|
242
|
+
* The number of results per the page.
|
|
243
|
+
*/
|
|
244
|
+
limit?: number;
|
|
245
|
+
/**
|
|
246
|
+
* A string that should be used with the pagination.
|
|
247
|
+
*/
|
|
248
|
+
nextPageToken?: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export class ContextListEvent<T> extends ContextEvent<ContextListOptions, ContextListResult<T>> {
|
|
252
|
+
/**
|
|
253
|
+
* @param type The type of the event
|
|
254
|
+
* @param opts Query options.
|
|
255
|
+
*/
|
|
256
|
+
constructor(type: string, opts: ContextListOptions = {}) {
|
|
257
|
+
super(type, opts);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var ctor: typeof CustomEvent;
|
|
2
|
+
|
|
3
|
+
if (typeof CustomEvent === 'function') {
|
|
4
|
+
ctor = CustomEvent;
|
|
5
|
+
} else {
|
|
6
|
+
const detailSymbol = Symbol('detail');
|
|
7
|
+
ctor = class CustomEvent<T> extends Event {
|
|
8
|
+
[detailSymbol]: T;
|
|
9
|
+
|
|
10
|
+
get detail(): T {
|
|
11
|
+
return this[detailSymbol];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
constructor(type: string, eventInitDict?: CustomEventInit | undefined) {
|
|
15
|
+
super(type, eventInitDict);
|
|
16
|
+
if (eventInitDict && eventInitDict.detail) {
|
|
17
|
+
this[detailSymbol] = eventInitDict.detail;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
initCustomEvent(type: string, bubbles?: boolean, cancelable?: boolean, detail?: T): void {
|
|
22
|
+
throw new Error(`This is deprecated. Do not use this function.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default ctor;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModelEventTypes } from './models/ModelEventTypes.js';
|
|
2
|
+
import { CookieEventTypes } from './cookies/CookieEventTypes.js';
|
|
3
|
+
import { AuthorizationEventTypes } from './authorization/AuthorizationEventTypes.js';
|
|
4
|
+
import { EncryptionEventTypes } from './encryption/EncryptionEventTypes.js';
|
|
5
|
+
import { ProcessEventTypes } from './process/ProcessEventTypes.js';
|
|
6
|
+
import { ReportingEventTypes } from './reporting/ReportingEventTypes.js';
|
|
7
|
+
import { TelemetryEventTypes } from './telemetry/TelemetryEventTypes.js';
|
|
8
|
+
import { EnvironmentEventTypes } from './environment/EnvironmentEventTypes.js';
|
|
9
|
+
|
|
10
|
+
export const EventTypes = Object.freeze({
|
|
11
|
+
Authorization: AuthorizationEventTypes,
|
|
12
|
+
Cookie: CookieEventTypes,
|
|
13
|
+
Encryption: EncryptionEventTypes,
|
|
14
|
+
Model: ModelEventTypes,
|
|
15
|
+
Process: ProcessEventTypes,
|
|
16
|
+
Reporting: ReportingEventTypes,
|
|
17
|
+
Telemetry: TelemetryEventTypes,
|
|
18
|
+
Environment: EnvironmentEventTypes,
|
|
19
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModelEvents } from './models/ModelEvents.js';
|
|
2
|
+
import { CookieEvents } from './cookies/CookieEvents.js';
|
|
3
|
+
import { AuthorizationEvents } from './authorization/AuthorizationEvents.js';
|
|
4
|
+
import { EncryptionEvents } from './encryption/EncryptionEvents.js';
|
|
5
|
+
import { ProcessEvents } from './process/ProcessEvents.js';
|
|
6
|
+
import { ReportingEvents } from './reporting/ReportingEvents.js';
|
|
7
|
+
import { TelemetryEvents } from './telemetry/TelemetryEvents.js';
|
|
8
|
+
import { EnvironmentEvents } from './environment/EnvironmentEvents.js';
|
|
9
|
+
|
|
10
|
+
export const Events = Object.freeze({
|
|
11
|
+
Authorization: AuthorizationEvents,
|
|
12
|
+
Cookie: CookieEvents,
|
|
13
|
+
Encryption: EncryptionEvents,
|
|
14
|
+
Model: ModelEvents,
|
|
15
|
+
Process: ProcessEvents,
|
|
16
|
+
Reporting: ReportingEvents,
|
|
17
|
+
Telemetry: TelemetryEvents,
|
|
18
|
+
Environment: EnvironmentEvents,
|
|
19
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const AuthorizationEventTypes = Object.freeze({
|
|
2
|
+
OAuth2: Object.freeze({
|
|
3
|
+
/**
|
|
4
|
+
* Authorization with auth configuration on detail
|
|
5
|
+
*/
|
|
6
|
+
authorize: 'oauth2authorize',
|
|
7
|
+
/**
|
|
8
|
+
* Removes cached token for the provider
|
|
9
|
+
*/
|
|
10
|
+
removeToken: 'oauth2removetoken',
|
|
11
|
+
}),
|
|
12
|
+
Oidc: Object.freeze({
|
|
13
|
+
/**
|
|
14
|
+
* Authorization the user with the provided configuration.
|
|
15
|
+
*/
|
|
16
|
+
authorize: 'oidcauthorize',
|
|
17
|
+
/**
|
|
18
|
+
* Removes cached tokens for the provider
|
|
19
|
+
*/
|
|
20
|
+
removeTokens: 'oidcremovetokens',
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { IOAuth2Authorization, ITokenRemoveOptions, IOidcTokenInfo, IOidcTokenError, ITokenInfo } from '../../models/Authorization.js';
|
|
2
|
+
import { AuthorizationEventTypes } from './AuthorizationEventTypes.js';
|
|
3
|
+
import { ContextEvent } from "../BaseEvents.js";
|
|
4
|
+
|
|
5
|
+
export class AuthorizationEvents {
|
|
6
|
+
static get OAuth2(): typeof OAuth2Events {
|
|
7
|
+
return OAuth2Events;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static get Oidc(): typeof OidcEvents {
|
|
11
|
+
return OidcEvents;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class OAuth2Events {
|
|
16
|
+
/**
|
|
17
|
+
* @param target A node on which to dispatch the event.
|
|
18
|
+
* @param config Authorization options.
|
|
19
|
+
* @returns Promise resolved with authorization result
|
|
20
|
+
*/
|
|
21
|
+
static async authorize(target: EventTarget, config: IOAuth2Authorization): Promise<ITokenInfo | undefined> {
|
|
22
|
+
const e = new ContextEvent<IOAuth2Authorization, ITokenInfo>(AuthorizationEventTypes.OAuth2.authorize, config);
|
|
23
|
+
target.dispatchEvent(e);
|
|
24
|
+
return e.detail.result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param target A node on which to dispatch the event.
|
|
29
|
+
* @param config Authorization options.
|
|
30
|
+
* @returns Promise resolved when the token is removed
|
|
31
|
+
*/
|
|
32
|
+
static async removeToken(target: EventTarget, config: ITokenRemoveOptions): Promise<void> {
|
|
33
|
+
const e = new ContextEvent<ITokenRemoveOptions, void>(AuthorizationEventTypes.OAuth2.removeToken, config);
|
|
34
|
+
target.dispatchEvent(e);
|
|
35
|
+
return e.detail.result;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class OidcEvents {
|
|
40
|
+
/**
|
|
41
|
+
* @param target A node on which to dispatch the event.
|
|
42
|
+
* @param config Authorization options.
|
|
43
|
+
* @returns Promise resolved with authorization result
|
|
44
|
+
*/
|
|
45
|
+
static async authorize(target: EventTarget, config: IOAuth2Authorization): Promise<(IOidcTokenInfo|IOidcTokenError)[] | undefined> {
|
|
46
|
+
const e = new ContextEvent<IOAuth2Authorization, (IOidcTokenInfo|IOidcTokenError)[]>(AuthorizationEventTypes.Oidc.authorize, config);
|
|
47
|
+
target.dispatchEvent(e);
|
|
48
|
+
return e.detail.result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param target A node on which to dispatch the event.
|
|
53
|
+
* @param config Authorization options.
|
|
54
|
+
* @returns Promise resolved when the token is removed
|
|
55
|
+
*/
|
|
56
|
+
static async removeToken(target: EventTarget, config: ITokenRemoveOptions): Promise<void> {
|
|
57
|
+
const e = new ContextEvent<ITokenRemoveOptions, void>(AuthorizationEventTypes.Oidc.removeTokens, config);
|
|
58
|
+
target.dispatchEvent(e);
|
|
59
|
+
return e.detail.result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const CookieEventTypes = Object.freeze({
|
|
2
|
+
listAll: 'sessioncookielistall',
|
|
3
|
+
listDomain: 'sessioncookielistdomain',
|
|
4
|
+
listUrl: 'sessioncookielisturl',
|
|
5
|
+
delete: 'sessioncookiedelete',
|
|
6
|
+
deleteUrl: 'sessioncookiedeleteurl',
|
|
7
|
+
update: 'sessioncookieupdate',
|
|
8
|
+
updateBulk: 'sessioncookieupdatebulk',
|
|
9
|
+
State: Object.freeze({
|
|
10
|
+
delete: 'sessioncookiestatedelete',
|
|
11
|
+
update: 'sessioncookiestateupdate',
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { CookieEventTypes } from './CookieEventTypes.js';
|
|
2
|
+
import { IHttpCookie } from "../../models/HttpCookie.js";
|
|
3
|
+
import { ContextEventDetailWithResult, ContextEvent, ContextChangeRecord, ContextUpdateEvent, ContextStateUpdateEvent } from "../BaseEvents.js";
|
|
4
|
+
|
|
5
|
+
export interface ICookieDomainListDetail {
|
|
6
|
+
domain: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ICookieUrlListDetail {
|
|
10
|
+
url: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ICookieItemsDetail {
|
|
14
|
+
cookies: IHttpCookie[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ICookieDetail {
|
|
18
|
+
cookie: IHttpCookie;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ICookieDeleteUrlDetail {
|
|
22
|
+
url: string;
|
|
23
|
+
name?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class CookieEvents {
|
|
27
|
+
/**
|
|
28
|
+
* Lists all projects in the data store.
|
|
29
|
+
* This does not return the whole project record. Instead it only returns the index object of the project.
|
|
30
|
+
*
|
|
31
|
+
* @param target The target on which to dispatch the event
|
|
32
|
+
* @returns The list of project index objects.
|
|
33
|
+
*/
|
|
34
|
+
static async listAll(target: EventTarget): Promise<IHttpCookie[] | undefined> {
|
|
35
|
+
const detail: ContextEventDetailWithResult<IHttpCookie[]> = {};
|
|
36
|
+
const e = new CustomEvent(CookieEventTypes.listAll, {
|
|
37
|
+
bubbles: true,
|
|
38
|
+
composed: true,
|
|
39
|
+
cancelable: true,
|
|
40
|
+
detail,
|
|
41
|
+
});
|
|
42
|
+
target.dispatchEvent(e);
|
|
43
|
+
return e.detail.result;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param target The target on which to dispatch the event
|
|
48
|
+
* @param domain The cookie domain
|
|
49
|
+
* @returns The list of project index objects.
|
|
50
|
+
*/
|
|
51
|
+
static async listDomain(target: EventTarget, domain: string): Promise<IHttpCookie[] | undefined> {
|
|
52
|
+
const detail: ICookieDomainListDetail = { domain };
|
|
53
|
+
const e = new ContextEvent<ICookieDomainListDetail, IHttpCookie[]>(CookieEventTypes.listDomain, detail);
|
|
54
|
+
target.dispatchEvent(e);
|
|
55
|
+
return e.detail.result;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param target The target on which to dispatch the event
|
|
60
|
+
* @param url The cookie URL
|
|
61
|
+
* @returns The list of project index objects.
|
|
62
|
+
*/
|
|
63
|
+
static async listUrl(target: EventTarget, url: string): Promise<IHttpCookie[] | undefined> {
|
|
64
|
+
const detail: ICookieUrlListDetail = { url };
|
|
65
|
+
const e = new ContextEvent<ICookieUrlListDetail, IHttpCookie[]>(CookieEventTypes.listUrl, detail);
|
|
66
|
+
target.dispatchEvent(e);
|
|
67
|
+
return e.detail.result;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Deletes cookies from the store.
|
|
72
|
+
*
|
|
73
|
+
* @param target The target on which to dispatch the event
|
|
74
|
+
* @param cookies The list of cookies to remove
|
|
75
|
+
*/
|
|
76
|
+
static async delete(target: EventTarget, cookies: IHttpCookie[]): Promise<void> {
|
|
77
|
+
const detail: ICookieItemsDetail = { cookies };
|
|
78
|
+
const e = new ContextEvent<ICookieItemsDetail, void>(CookieEventTypes.delete, detail);
|
|
79
|
+
target.dispatchEvent(e);
|
|
80
|
+
return e.detail.result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Deletes cookies from the store.
|
|
85
|
+
*
|
|
86
|
+
* @param target The target on which to dispatch the event
|
|
87
|
+
* @param url The url associated with the cookie. Depending on the session mechanism the URL or the domain and the path is used.
|
|
88
|
+
* @param name The name of the cookie to remove. When not set all cookies are removed for the given URL.
|
|
89
|
+
*/
|
|
90
|
+
static async deleteUrl(target: EventTarget, url: string, name?: string): Promise<void> {
|
|
91
|
+
const detail: ICookieDeleteUrlDetail = { url, name };
|
|
92
|
+
const e = new ContextEvent<ICookieDeleteUrlDetail, void>(CookieEventTypes.deleteUrl, detail);
|
|
93
|
+
target.dispatchEvent(e);
|
|
94
|
+
return e.detail.result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Updates a cookie in the store.
|
|
99
|
+
*
|
|
100
|
+
* @param target The target on which to dispatch the event
|
|
101
|
+
* @param cookie A cookie to update
|
|
102
|
+
* @returns The change record of the updated cookie.
|
|
103
|
+
*/
|
|
104
|
+
static async update(target: EventTarget, cookie: IHttpCookie): Promise<ContextChangeRecord<IHttpCookie> | undefined> {
|
|
105
|
+
const e = new ContextUpdateEvent(CookieEventTypes.update, { item: cookie });
|
|
106
|
+
target.dispatchEvent(e);
|
|
107
|
+
return e.detail.result;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Updates a cookie in the store in a bulk operation.
|
|
112
|
+
*
|
|
113
|
+
* @param target The target on which to dispatch the event
|
|
114
|
+
* @param cookies A list of cookies to update
|
|
115
|
+
* @returns The change record of the updated cookie.
|
|
116
|
+
*/
|
|
117
|
+
static async updateBulk(target: EventTarget, cookies: IHttpCookie[]): Promise<void> {
|
|
118
|
+
const detail: ICookieItemsDetail = { cookies };
|
|
119
|
+
const e = new ContextEvent<ICookieItemsDetail, void>(CookieEventTypes.updateBulk, detail);
|
|
120
|
+
target.dispatchEvent(e);
|
|
121
|
+
return e.detail.result;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Events related to a state of a cookie store.
|
|
126
|
+
*/
|
|
127
|
+
static get State(): typeof StateEvents {
|
|
128
|
+
return StateEvents;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
class StateEvents {
|
|
133
|
+
/**
|
|
134
|
+
* Event dispatched when a cookie was deleted from the context store
|
|
135
|
+
* @param target The target on which to dispatch the event
|
|
136
|
+
* @param cookie The schema of the removed cookie
|
|
137
|
+
*/
|
|
138
|
+
static delete(target: EventTarget, cookie: IHttpCookie): void {
|
|
139
|
+
const e = new CustomEvent<ICookieDetail>(CookieEventTypes.State.delete, {
|
|
140
|
+
bubbles: true,
|
|
141
|
+
composed: true,
|
|
142
|
+
cancelable: false,
|
|
143
|
+
detail: { cookie },
|
|
144
|
+
});
|
|
145
|
+
target.dispatchEvent(e);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Event dispatched when a cookie was deleted from the context store
|
|
150
|
+
* @param target The target on which to dispatch the event
|
|
151
|
+
* @param record The change record.
|
|
152
|
+
*/
|
|
153
|
+
static update(target: EventTarget, record: ContextChangeRecord<IHttpCookie>): void {
|
|
154
|
+
const e = new ContextStateUpdateEvent<IHttpCookie>(CookieEventTypes.State.update, record);
|
|
155
|
+
target.dispatchEvent(e);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { EncryptionEventTypes } from './EncryptionEventTypes.js';
|
|
2
|
+
import { ContextEvent } from "../BaseEvents.js";
|
|
3
|
+
|
|
4
|
+
export interface IEncryptionEventDetail {
|
|
5
|
+
/**
|
|
6
|
+
* The data to export
|
|
7
|
+
*/
|
|
8
|
+
data: any;
|
|
9
|
+
/**
|
|
10
|
+
* The passphrase to use in 2-way data encryption
|
|
11
|
+
*/
|
|
12
|
+
passphrase: string;
|
|
13
|
+
/**
|
|
14
|
+
* Encryption method to use
|
|
15
|
+
*/
|
|
16
|
+
method: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class EncryptionEvents {
|
|
20
|
+
/**
|
|
21
|
+
* Dispatches an event handled by the encryption module to encrypt the data
|
|
22
|
+
*
|
|
23
|
+
* @param target A node on which to dispatch the event.
|
|
24
|
+
* @param data The data to encrypt
|
|
25
|
+
* @param passphrase The passphrase to use in 2-way data encryption
|
|
26
|
+
* @param method Encryption method to use
|
|
27
|
+
* @returns Promise resolved to the encryption result
|
|
28
|
+
*/
|
|
29
|
+
static async encrypt(target: EventTarget, data: any, passphrase: string, method: string): Promise<string | undefined> {
|
|
30
|
+
const config: IEncryptionEventDetail = { data, passphrase, method };
|
|
31
|
+
const e = new ContextEvent<IEncryptionEventDetail, string>(EncryptionEventTypes.encrypt, config);
|
|
32
|
+
target.dispatchEvent(e);
|
|
33
|
+
return e.detail.result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Dispatches an event handled by the encryption module to decrypt the data
|
|
38
|
+
*
|
|
39
|
+
* @param target A node on which to dispatch the event.
|
|
40
|
+
* @param data The data to decrypt
|
|
41
|
+
* @param passphrase The passphrase to use to decrypt the data
|
|
42
|
+
* @param method Method used to encrypt the data
|
|
43
|
+
* @returns Promise resolved to the decrypted result
|
|
44
|
+
*/
|
|
45
|
+
static async decrypt(target: EventTarget, data: any, passphrase: string, method: string): Promise<string | undefined> {
|
|
46
|
+
const config: IEncryptionEventDetail = { data, passphrase, method };
|
|
47
|
+
const e = new ContextEvent<IEncryptionEventDetail, string>(EncryptionEventTypes.decrypt, config);
|
|
48
|
+
target.dispatchEvent(e);
|
|
49
|
+
return e.detail.result;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EnvironmentEventTypes } from './EnvironmentEventTypes.js';
|
|
2
|
+
import { ContextEvent } from "../BaseEvents.js";
|
|
3
|
+
|
|
4
|
+
export interface ISetVariableDetail {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class EnvironmentEvents {
|
|
10
|
+
/**
|
|
11
|
+
* An event dispatched to set a variable in the current environment.
|
|
12
|
+
*
|
|
13
|
+
* @param target A node on which to dispatch the event.
|
|
14
|
+
* @param name Variable name
|
|
15
|
+
* @param value Variable value
|
|
16
|
+
* @returns Nothing. The promise resolves when the variable is set.
|
|
17
|
+
*/
|
|
18
|
+
static async set(target: EventTarget, name: string, value: string): Promise<void> {
|
|
19
|
+
const detail: ISetVariableDetail = { name, value };
|
|
20
|
+
const e = new ContextEvent<ISetVariableDetail, void>(EnvironmentEventTypes.set, detail);
|
|
21
|
+
target.dispatchEvent(e);
|
|
22
|
+
return e.detail.result;
|
|
23
|
+
}
|
|
24
|
+
}
|