@api-client/core 0.5.18 → 0.5.21
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 +10 -2
- package/build/browser.js +13 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +7 -2
- package/build/index.js +10 -0
- package/build/index.js.map +1 -1
- package/build/src/authorization/AuthorizationError.d.ts +23 -0
- package/build/src/authorization/AuthorizationError.js +33 -0
- package/build/src/authorization/AuthorizationError.js.map +1 -0
- package/build/src/authorization/CustomParameters.d.ts +24 -0
- package/build/src/authorization/CustomParameters.js +59 -0
- package/build/src/authorization/CustomParameters.js.map +1 -0
- package/build/src/authorization/OAuth2Authorization.d.ts +332 -0
- package/build/src/authorization/OAuth2Authorization.js +965 -0
- package/build/src/authorization/OAuth2Authorization.js.map +1 -0
- package/build/src/authorization/OidcAuthorization.d.ts +34 -0
- package/build/src/authorization/OidcAuthorization.js +139 -0
- package/build/src/authorization/OidcAuthorization.js.map +1 -0
- package/build/src/authorization/Utils.d.ts +51 -0
- package/build/src/authorization/Utils.js +122 -0
- package/build/src/authorization/Utils.js.map +1 -0
- package/build/src/authorization/lib/IframeAuthorization.d.ts +53 -0
- package/build/src/authorization/lib/IframeAuthorization.js +116 -0
- package/build/src/authorization/lib/IframeAuthorization.js.map +1 -0
- package/build/src/authorization/lib/KnownGrants.d.ts +6 -0
- package/build/src/authorization/lib/KnownGrants.js +7 -0
- package/build/src/authorization/lib/KnownGrants.js.map +1 -0
- package/build/src/authorization/lib/PopupAuthorization.d.ts +41 -0
- package/build/src/authorization/lib/PopupAuthorization.js +73 -0
- package/build/src/authorization/lib/PopupAuthorization.js.map +1 -0
- package/build/src/authorization/lib/Tokens.d.ts +55 -0
- package/build/src/authorization/lib/Tokens.js +117 -0
- package/build/src/authorization/lib/Tokens.js.map +1 -0
- package/build/src/authorization/types.d.ts +174 -0
- package/build/src/authorization/types.js +2 -0
- package/build/src/authorization/types.js.map +1 -0
- package/build/src/events/BaseEvents.d.ts +1 -1
- package/build/src/events/BaseEvents.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +0 -28
- package/build/src/events/Events.d.ts +0 -1
- package/build/src/events/models/ClientCertificateEvents.d.ts +6 -8
- package/build/src/events/models/ClientCertificateEvents.js +4 -6
- package/build/src/events/models/ClientCertificateEvents.js.map +1 -1
- package/build/src/events/models/ModelEventTypes.d.ts +0 -34
- package/build/src/events/models/ModelEventTypes.js +0 -34
- package/build/src/events/models/ModelEventTypes.js.map +1 -1
- package/build/src/events/models/ModelEvents.d.ts +0 -2
- package/build/src/events/models/ModelEvents.js +0 -2
- package/build/src/events/models/ModelEvents.js.map +1 -1
- package/build/src/lib/Buffer.d.ts +21 -0
- package/build/src/lib/Buffer.js +43 -0
- package/build/src/lib/Buffer.js.map +1 -0
- package/build/src/lib/definitions/HttpDefinitions.d.ts +33 -0
- package/build/src/lib/definitions/HttpDefinitions.js +58 -0
- package/build/src/lib/definitions/HttpDefinitions.js.map +1 -0
- package/build/src/lib/headers/Headers.d.ts +8 -1
- package/build/src/lib/headers/Headers.js +48 -34
- package/build/src/lib/headers/Headers.js.map +1 -1
- package/build/src/lib/headers/HeadersData.d.ts +35 -0
- package/build/src/lib/headers/HeadersData.js +678 -0
- package/build/src/lib/headers/HeadersData.js.map +1 -0
- package/build/src/lib/parsers/UrlProcessor.d.ts +2 -2
- package/build/src/lib/parsers/UrlProcessor.js +2 -2
- package/build/src/lib/parsers/UrlProcessor.js.map +1 -1
- package/build/src/models/ClientCertificate.d.ts +130 -25
- package/build/src/models/ClientCertificate.js +150 -1
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/Request.d.ts +3 -3
- package/build/src/models/Request.js +3 -2
- package/build/src/models/Request.js.map +1 -1
- package/build/src/runtime/http-engine/CoreEngine.js +4 -1
- package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.d.ts +4 -4
- package/build/src/runtime/http-engine/HttpEngine.js +38 -29
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/modules/ModulesRegistry.d.ts +2 -2
- package/build/src/runtime/node/ProjectRequestRunner.js +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/RequestFactory.d.ts +2 -2
- package/build/src/runtime/node/RequestFactory.js.map +1 -1
- package/oauth-popup.html +29 -0
- package/package.json +3 -1
- package/src/authorization/AuthorizationError.ts +25 -0
- package/src/authorization/CustomParameters.ts +61 -0
- package/src/authorization/OAuth2Authorization.ts +1027 -0
- package/src/authorization/OidcAuthorization.ts +143 -0
- package/src/authorization/Utils.ts +126 -0
- package/src/authorization/lib/IframeAuthorization.ts +128 -0
- package/src/authorization/lib/KnownGrants.ts +6 -0
- package/src/authorization/lib/PopupAuthorization.ts +80 -0
- package/src/authorization/lib/Tokens.ts +124 -0
- package/src/authorization/types.ts +176 -0
- package/src/events/BaseEvents.ts +1 -1
- package/src/events/models/ClientCertificateEvents.ts +11 -13
- package/src/events/models/ModelEventTypes.ts +0 -34
- package/src/events/models/ModelEvents.ts +0 -2
- package/src/lib/Buffer.ts +48 -0
- package/src/lib/definitions/HttpDefinitions.ts +63 -0
- package/src/lib/headers/Headers.ts +50 -34
- package/src/lib/headers/HeadersData.ts +788 -0
- package/src/lib/parsers/UrlProcessor.ts +3 -3
- package/src/models/ClientCertificate.ts +224 -25
- package/src/models/Request.ts +5 -5
- package/src/runtime/http-engine/CoreEngine.ts +4 -1
- package/src/runtime/http-engine/HttpEngine.ts +39 -33
- package/src/runtime/modules/ModulesRegistry.ts +2 -2
- package/src/runtime/node/ProjectRequestRunner.ts +1 -1
- package/src/runtime/node/RequestFactory.ts +2 -2
- package/build/src/events/models/ProjectEvents.d.ts +0 -221
- package/build/src/events/models/ProjectEvents.js +0 -253
- package/build/src/events/models/ProjectEvents.js.map +0 -1
- package/src/events/models/ProjectEvents.ts +0 -331
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
export interface OauthProcessingOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The number of milliseconds of an interval to check the popup state.
|
|
4
|
+
* Default to 250 ms.
|
|
5
|
+
*/
|
|
6
|
+
popupPullTimeout?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The event target on which to listen to the redirect page `message` event.
|
|
9
|
+
* This event should contain a list of authorization parameters returned by the authorization server.
|
|
10
|
+
*
|
|
11
|
+
* The library contains `oauth-popup.html` page that reads the data from the URL and posts it back to the opener.
|
|
12
|
+
* However, you can create `tokenInfoTranslation` to map returned by the popup parameters to the onces used by the library.
|
|
13
|
+
*/
|
|
14
|
+
messageTarget?: EventTarget;
|
|
15
|
+
/**
|
|
16
|
+
* A number of milliseconds after which the iframe triggers a timeout if the response is not present.
|
|
17
|
+
* Defaults to `1020`.
|
|
18
|
+
*/
|
|
19
|
+
iframeTimeout?: number;
|
|
20
|
+
/**
|
|
21
|
+
* When set it uses this value to prefix the call to the
|
|
22
|
+
* OAuth 2 token endpoint. This is to support use cases when
|
|
23
|
+
* the requests should be proxied through a server to avoid CORS problems.
|
|
24
|
+
*/
|
|
25
|
+
tokenProxy?: string;
|
|
26
|
+
/**
|
|
27
|
+
* When set it encodes the token URI value before adding it to the
|
|
28
|
+
* `tokenProxy`. This is to be used when the proxy takes the target
|
|
29
|
+
* URL as a query parameter.
|
|
30
|
+
*/
|
|
31
|
+
tokenProxyEncode?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IOpenIdProviderMetadata {
|
|
35
|
+
/**
|
|
36
|
+
* URL using the https scheme with no query or fragment component that the OP asserts as its Issuer Identifier. If Issuer discovery is supported (see Section 2), this value MUST be identical to the issuer value returned by WebFinger. This also MUST be identical to the iss Claim value in ID Tokens issued from this Issuer.
|
|
37
|
+
*/
|
|
38
|
+
issuer: string;
|
|
39
|
+
/**
|
|
40
|
+
* URL of the OP's OAuth 2.0 Authorization Endpoint [OpenID.Core].
|
|
41
|
+
*/
|
|
42
|
+
authorization_endpoint: string;
|
|
43
|
+
/**
|
|
44
|
+
* URL of the OP's OAuth 2.0 Token Endpoint [OpenID.Core]. This is REQUIRED unless only the Implicit Flow is used.
|
|
45
|
+
*/
|
|
46
|
+
token_endpoint?: string;
|
|
47
|
+
/**
|
|
48
|
+
* URL of the OP's UserInfo Endpoint [OpenID.Core]. This URL MUST use the https scheme and MAY contain port, path, and query parameter components.
|
|
49
|
+
*/
|
|
50
|
+
userinfo_endpoint?: string;
|
|
51
|
+
/**
|
|
52
|
+
* URL of the OP's JSON Web Key Set [JWK] document. This contains the signing key(s) the RP uses to validate signatures from the OP. The JWK Set MAY also contain the Server's encryption key(s), which are used by RPs to encrypt requests to the Server. When both signing and encryption keys are made available, a use (Key Use) parameter value is REQUIRED for all keys in the referenced JWK Set to indicate each key's intended usage. Although some algorithms allow the same key to be used for both signatures and encryption, doing so is NOT RECOMMENDED, as it is less secure. The JWK x5c parameter MAY be used to provide X.509 representations of keys provided. When used, the bare key values MUST still be present and MUST match those in the certificate.
|
|
53
|
+
*/
|
|
54
|
+
jwks_uri: string;
|
|
55
|
+
/**
|
|
56
|
+
* URL of the OP's Dynamic Client Registration Endpoint.
|
|
57
|
+
*/
|
|
58
|
+
registration_endpoint?: string;
|
|
59
|
+
/**
|
|
60
|
+
* JSON array containing a list of the OAuth 2.0 [RFC6749] scope values that this server supports. The server MUST support the openid scope value. Servers MAY choose not to advertise some supported scope values even when this parameter is used, although those defined in [OpenID.Core] SHOULD be listed, if supported.
|
|
61
|
+
*/
|
|
62
|
+
scopes_supported?: string[];
|
|
63
|
+
/**
|
|
64
|
+
* JSON array containing a list of the OAuth 2.0 response_type values that this OP supports. Dynamic OpenID Providers MUST support the code, id_token, and the token id_token Response Type values.
|
|
65
|
+
*/
|
|
66
|
+
response_types_supported: string[];
|
|
67
|
+
/**
|
|
68
|
+
* JSON array containing a list of the OAuth 2.0 response_mode values that this OP supports, as specified in OAuth 2.0 Multiple Response Type Encoding Practices [OAuth.Responses]. If omitted, the default for Dynamic OpenID Providers is ["query", "fragment"].
|
|
69
|
+
*/
|
|
70
|
+
response_modes_supported?: string[];
|
|
71
|
+
/**
|
|
72
|
+
* JSON array containing a list of the OAuth 2.0 Grant Type values that this OP supports. Dynamic OpenID Providers MUST support the authorization_code and implicit Grant Type values and MAY support other Grant Types. If omitted, the default value is ["authorization_code", "implicit"].
|
|
73
|
+
*/
|
|
74
|
+
grant_types_supported?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* JSON array containing a list of the Authentication Context Class References that this OP supports.
|
|
77
|
+
*/
|
|
78
|
+
acr_values_supported?: string[];
|
|
79
|
+
/**
|
|
80
|
+
* JSON array containing a list of the Subject Identifier types that this OP supports. Valid types include pairwise and public.
|
|
81
|
+
*/
|
|
82
|
+
subject_types_supported: string[];
|
|
83
|
+
/**
|
|
84
|
+
* JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]. The algorithm RS256 MUST be included. The value none MAY be supported, but MUST NOT be used unless the Response Type used returns no ID Token from the Authorization Endpoint (such as when using the Authorization Code Flow).
|
|
85
|
+
*/
|
|
86
|
+
id_token_signing_alg_values_supported: string[];
|
|
87
|
+
/**
|
|
88
|
+
* JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT].
|
|
89
|
+
*/
|
|
90
|
+
id_token_encryption_alg_values_supported?: string[];
|
|
91
|
+
/**
|
|
92
|
+
* JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT].
|
|
93
|
+
*/
|
|
94
|
+
id_token_encryption_enc_values_supported?: string[];
|
|
95
|
+
/**
|
|
96
|
+
* JSON array containing a list of the JWS [JWS] signing algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]. The value none MAY be included.
|
|
97
|
+
*/
|
|
98
|
+
userinfo_signing_alg_values_supported?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* JSON array containing a list of the JWE [JWE] encryption algorithms (alg values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT].
|
|
101
|
+
*/
|
|
102
|
+
userinfo_encryption_alg_values_supported?: string[];
|
|
103
|
+
/**
|
|
104
|
+
* JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT].
|
|
105
|
+
*/
|
|
106
|
+
userinfo_encryption_enc_values_supported?: string[];
|
|
107
|
+
/**
|
|
108
|
+
* JSON array containing a list of the JWS signing algorithms (alg values) supported by the OP for Request Objects, which are described in Section 6.1 of OpenID Connect Core 1.0 [OpenID.Core]. These algorithms are used both when the Request Object is passed by value (using the request parameter) and when it is passed by reference (using the request_uri parameter). Servers SHOULD support none and RS256.
|
|
109
|
+
*/
|
|
110
|
+
request_object_signing_alg_values_supported?: string[];
|
|
111
|
+
/**
|
|
112
|
+
* JSON array containing a list of the JWE encryption algorithms (alg values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference.
|
|
113
|
+
*/
|
|
114
|
+
request_object_encryption_alg_values_supported?: string[];
|
|
115
|
+
/**
|
|
116
|
+
* JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference.
|
|
117
|
+
*/
|
|
118
|
+
request_object_encryption_enc_values_supported?: string[];
|
|
119
|
+
/**
|
|
120
|
+
* JSON array containing a list of Client Authentication methods supported by this Token Endpoint. The options are client_secret_post, client_secret_basic, client_secret_jwt, and private_key_jwt, as described in Section 9 of OpenID Connect Core 1.0 [OpenID.Core]. Other authentication methods MAY be defined by extensions. If omitted, the default is client_secret_basic -- the HTTP Basic Authentication Scheme specified in Section 2.3.1 of OAuth 2.0 [RFC6749].
|
|
121
|
+
*/
|
|
122
|
+
token_endpoint_auth_methods_supported?: string[];
|
|
123
|
+
/**
|
|
124
|
+
* JSON array containing a list of the JWS signing algorithms (alg values) supported by the Token Endpoint for the signature on the JWT [JWT] used to authenticate the Client at the Token Endpoint for the private_key_jwt and client_secret_jwt authentication methods. Servers SHOULD support RS256. The value none MUST NOT be used.
|
|
125
|
+
*/
|
|
126
|
+
token_endpoint_auth_signing_alg_values_supported?: string[];
|
|
127
|
+
/**
|
|
128
|
+
* JSON array containing a list of the display parameter values that the OpenID Provider supports. These values are described in Section 3.1.2.1 of OpenID Connect Core 1.0 [OpenID.Core].
|
|
129
|
+
*/
|
|
130
|
+
display_values_supported?: string[];
|
|
131
|
+
/**
|
|
132
|
+
* JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. Values defined by this specification are normal, aggregated, and distributed. If omitted, the implementation supports only normal Claims.
|
|
133
|
+
*/
|
|
134
|
+
claim_types_supported?: string[];
|
|
135
|
+
/**
|
|
136
|
+
* JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list.
|
|
137
|
+
*/
|
|
138
|
+
claims_supported?: string[];
|
|
139
|
+
/**
|
|
140
|
+
* URL of a page containing human-readable information that developers might want or need to know when using the OpenID Provider. In particular, if the OpenID Provider does not support Dynamic Client Registration, then information on how to register Clients needs to be provided in this documentation.
|
|
141
|
+
*/
|
|
142
|
+
service_documentation?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Languages and scripts supported for values in Claims being returned, represented as a JSON array of BCP47 [RFC5646] language tag values. Not all languages and scripts are necessarily supported for all Claim values.
|
|
145
|
+
*/
|
|
146
|
+
claims_locales_supported?: string[];
|
|
147
|
+
/**
|
|
148
|
+
* Languages and scripts supported for the user interface, represented as a JSON array of BCP47 [RFC5646] language tag values.
|
|
149
|
+
*/
|
|
150
|
+
ui_locales_supported?: string[];
|
|
151
|
+
/**
|
|
152
|
+
* Boolean value specifying whether the OP supports use of the claims parameter, with true indicating support. If omitted, the default value is false.
|
|
153
|
+
*/
|
|
154
|
+
claims_parameter_supported?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Boolean value specifying whether the OP supports use of the request parameter, with true indicating support. If omitted, the default value is false.
|
|
157
|
+
*/
|
|
158
|
+
request_parameter_supported?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Boolean value specifying whether the OP supports use of the request_uri parameter, with true indicating support. If omitted, the default value is true.
|
|
161
|
+
*/
|
|
162
|
+
request_uri_parameter_supported?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Boolean value specifying whether the OP requires any request_uri values used to be pre-registered using the request_uris registration parameter. Pre-registration is REQUIRED when the value is true. If omitted, the default value is false.
|
|
165
|
+
*/
|
|
166
|
+
require_request_uri_registration?: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* URL that the OpenID Provider provides to the person registering the Client to read about the OP's requirements on how the Relying Party can use the data provided by the OP. The registration process SHOULD display this URL to the person registering the Client if it is given.
|
|
169
|
+
*/
|
|
170
|
+
op_policy_uri?: string;
|
|
171
|
+
/**
|
|
172
|
+
* URL that the OpenID Provider provides to the person registering the Client to read about OpenID Provider's terms of service. The registration process SHOULD display this URL to the person registering the Client if it is given.
|
|
173
|
+
*/
|
|
174
|
+
op_tos_uri?: string;
|
|
175
|
+
|
|
176
|
+
}
|
package/src/events/BaseEvents.ts
CHANGED
|
@@ -212,7 +212,7 @@ export interface ContextUpdateEventDetail<T> {
|
|
|
212
212
|
*
|
|
213
213
|
* @template T The object that is being updated.
|
|
214
214
|
*/
|
|
215
|
-
export class ContextUpdateEvent<T extends object> extends ContextEvent<ContextUpdateEventDetail<T>, ContextChangeRecord<
|
|
215
|
+
export class ContextUpdateEvent<T extends object, U = T> extends ContextEvent<ContextUpdateEventDetail<T>, ContextChangeRecord<U>> {
|
|
216
216
|
constructor(type: string, updateInfo: ContextUpdateEventDetail<T>) {
|
|
217
217
|
super(type, updateInfo);
|
|
218
218
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpCertificate, ICertificateCreateOptions } from '../../models/ClientCertificate.js';
|
|
2
2
|
import { ContextReadEvent, ContextListEvent, ContextListOptions, ContextListResult, ContextDeleteEvent, ContextDeleteRecord, ContextUpdateEvent, ContextChangeRecord, ContextStateUpdateEvent, ContextStateDeleteEvent } from '../BaseEvents.js';
|
|
3
3
|
import { ModelEventTypes } from './ModelEventTypes.js';
|
|
4
4
|
|
|
@@ -8,11 +8,10 @@ export class ClientCertificateEvents {
|
|
|
8
8
|
*
|
|
9
9
|
* @param target A node on which to dispatch the event.
|
|
10
10
|
* @param id The id of the client certificate
|
|
11
|
-
* @param rev The revision of the client certificate. If not set then the latest revision is used.
|
|
12
11
|
* @returns Promise resolved to a client certificate model.
|
|
13
12
|
*/
|
|
14
|
-
static async read(target: EventTarget, id: string
|
|
15
|
-
const e = new ContextReadEvent<
|
|
13
|
+
static async read(target: EventTarget, id: string): Promise<HttpCertificate | undefined> {
|
|
14
|
+
const e = new ContextReadEvent<HttpCertificate>(ModelEventTypes.ClientCertificate.read, id);
|
|
16
15
|
target.dispatchEvent(e);
|
|
17
16
|
return e.detail.result;
|
|
18
17
|
}
|
|
@@ -24,8 +23,8 @@ export class ClientCertificateEvents {
|
|
|
24
23
|
* @param opts Query options.
|
|
25
24
|
* @returns The list result.
|
|
26
25
|
*/
|
|
27
|
-
static async list(target: EventTarget, opts?: ContextListOptions): Promise<ContextListResult<
|
|
28
|
-
const e = new ContextListEvent<
|
|
26
|
+
static async list(target: EventTarget, opts?: ContextListOptions): Promise<ContextListResult<HttpCertificate> | undefined> {
|
|
27
|
+
const e = new ContextListEvent<HttpCertificate>(ModelEventTypes.ClientCertificate.list, opts);
|
|
29
28
|
target.dispatchEvent(e);
|
|
30
29
|
return e.detail.result;
|
|
31
30
|
}
|
|
@@ -35,11 +34,10 @@ export class ClientCertificateEvents {
|
|
|
35
34
|
*
|
|
36
35
|
* @param target A node on which to dispatch the event.
|
|
37
36
|
* @param id The id of the project to delete.
|
|
38
|
-
* @param rev The revision of the project. If not set then the latest revision is used.
|
|
39
37
|
* @returns Promise resolved to a new revision after delete.
|
|
40
38
|
*/
|
|
41
|
-
static async delete(target: EventTarget, id: string
|
|
42
|
-
const e = new ContextDeleteEvent(ModelEventTypes.ClientCertificate.delete, id, undefined
|
|
39
|
+
static async delete(target: EventTarget, id: string): Promise<ContextDeleteRecord | undefined> {
|
|
40
|
+
const e = new ContextDeleteEvent(ModelEventTypes.ClientCertificate.delete, id, undefined);
|
|
43
41
|
target.dispatchEvent(e);
|
|
44
42
|
return e.detail.result;
|
|
45
43
|
}
|
|
@@ -51,8 +49,8 @@ export class ClientCertificateEvents {
|
|
|
51
49
|
* @param item The certificate object.
|
|
52
50
|
* @returns Promise resolved to the change record
|
|
53
51
|
*/
|
|
54
|
-
static async insert(target: EventTarget, item:
|
|
55
|
-
const e = new ContextUpdateEvent<
|
|
52
|
+
static async insert(target: EventTarget, item: ICertificateCreateOptions): Promise<ContextChangeRecord<HttpCertificate> | undefined> {
|
|
53
|
+
const e = new ContextUpdateEvent<ICertificateCreateOptions, HttpCertificate>(ModelEventTypes.ClientCertificate.insert, { item, });
|
|
56
54
|
target.dispatchEvent(e);
|
|
57
55
|
return e.detail.result;
|
|
58
56
|
}
|
|
@@ -69,8 +67,8 @@ class StateEvents {
|
|
|
69
67
|
* @param target A node on which to dispatch the event.
|
|
70
68
|
* @param record Change record
|
|
71
69
|
*/
|
|
72
|
-
static update(target: EventTarget, record: ContextChangeRecord<
|
|
73
|
-
const e = new ContextStateUpdateEvent<
|
|
70
|
+
static update(target: EventTarget, record: ContextChangeRecord<HttpCertificate>): void {
|
|
71
|
+
const e = new ContextStateUpdateEvent<HttpCertificate>(ModelEventTypes.ClientCertificate.State.update, record);
|
|
74
72
|
target.dispatchEvent(e);
|
|
75
73
|
}
|
|
76
74
|
|
|
@@ -10,38 +10,4 @@ export const ModelEventTypes = {
|
|
|
10
10
|
delete: 'storestateclientcertificatedelete',
|
|
11
11
|
}),
|
|
12
12
|
}),
|
|
13
|
-
Project: Object.freeze({
|
|
14
|
-
create: 'storeprojectcreate',
|
|
15
|
-
read: 'storeprojectread',
|
|
16
|
-
update: 'storeprojectupdate',
|
|
17
|
-
delete: 'storeprojectdelete',
|
|
18
|
-
/**
|
|
19
|
-
* Moves objects inside a project between position and/or folders.
|
|
20
|
-
*/
|
|
21
|
-
move: 'storeprojectmove',
|
|
22
|
-
/**
|
|
23
|
-
* Makes a copy of the project and stores it as new.
|
|
24
|
-
*/
|
|
25
|
-
clone: 'storeprojectclone',
|
|
26
|
-
listAll: 'storeprojectlistall', // without pagination
|
|
27
|
-
Folder: Object.freeze({
|
|
28
|
-
create: 'storeprojectfoldercreate',
|
|
29
|
-
delete: 'storeprojectfolderdelete',
|
|
30
|
-
update: 'storeprojectfolderupdate',
|
|
31
|
-
}),
|
|
32
|
-
Request: Object.freeze({
|
|
33
|
-
create: 'storeprojectrequestcreate',
|
|
34
|
-
delete: 'storeprojectrequestdelete',
|
|
35
|
-
update: 'storeprojectrequestupdate',
|
|
36
|
-
}),
|
|
37
|
-
Environment: Object.freeze({
|
|
38
|
-
create: 'storeprojectenvironmentcreate',
|
|
39
|
-
delete: 'storeprojectenvironmentdelete',
|
|
40
|
-
update: 'storeprojectenvironmentupdate',
|
|
41
|
-
}),
|
|
42
|
-
State: Object.freeze({
|
|
43
|
-
update: 'storeprojectstateupdate',
|
|
44
|
-
delete: 'storeprojectstatedelete',
|
|
45
|
-
})
|
|
46
|
-
}),
|
|
47
13
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts base64 string to Uint8Array.
|
|
3
|
+
*
|
|
4
|
+
* @returns The restored array view.
|
|
5
|
+
*/
|
|
6
|
+
export function base64ToBuffer(str: string): Uint8Array {
|
|
7
|
+
const asciiString = atob(str);
|
|
8
|
+
return new Uint8Array([...asciiString].map((char) => char.charCodeAt(0)));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Converts incoming data to base64 string.
|
|
13
|
+
*
|
|
14
|
+
* @returns Safe to store string.
|
|
15
|
+
*/
|
|
16
|
+
export function bufferToBase64(view: Buffer | Uint8Array): string {
|
|
17
|
+
const str = view.reduce(
|
|
18
|
+
(data, byte) => data + String.fromCharCode(byte),
|
|
19
|
+
''
|
|
20
|
+
);
|
|
21
|
+
return btoa(str);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Reads file as ArrayBuffer
|
|
26
|
+
*/
|
|
27
|
+
export function fileToBuffer(blob: Blob): Promise<Uint8Array> {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
const reader = new FileReader();
|
|
30
|
+
reader.onload = (): void => { resolve(new Uint8Array(reader.result as ArrayBuffer)); };
|
|
31
|
+
/* istanbul ignore next */
|
|
32
|
+
reader.onerror = (): void => { reject(new Error('Unable to read file')); };
|
|
33
|
+
reader.readAsArrayBuffer(blob);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Reads file as string
|
|
39
|
+
*/
|
|
40
|
+
export function fileToString(blob: Blob): Promise<string> {
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const reader = new FileReader();
|
|
43
|
+
reader.onload = (): void => { resolve(reader.result as string); };
|
|
44
|
+
/* istanbul ignore next */
|
|
45
|
+
reader.onerror = (): void => { reject(new Error('Unable to read file')); };
|
|
46
|
+
reader.readAsText(blob);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { requestHeaders, responseHeaders, statusCodes, IHeaderDefinition, IStatusCodeDefinition } from '../headers/HeadersData.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Queries for headers containing a `query`. If query is not set
|
|
5
|
+
* (value is falsy) then it returns all headers definitions array.
|
|
6
|
+
*
|
|
7
|
+
* @param query A query to search for in the `key` field of the headers array.
|
|
8
|
+
* @param type If this equals `request` then it will look in the request headers array. Is the response headers list otherwise.
|
|
9
|
+
* @returns Array of the headers of selected `type` matched a `query` in a header's `key` field.
|
|
10
|
+
*/
|
|
11
|
+
export function queryHeaders(type: 'request' | 'response', query?: string): IHeaderDefinition[] {
|
|
12
|
+
const headers = type === 'request' ? requestHeaders : responseHeaders;
|
|
13
|
+
if (!query) {
|
|
14
|
+
return headers;
|
|
15
|
+
}
|
|
16
|
+
const lowerQuery = query.trim().toLowerCase();
|
|
17
|
+
return headers.filter(
|
|
18
|
+
(item) => item.key.toLowerCase().indexOf(lowerQuery) !== -1
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Queries for request headers that contains a `query`. If query is
|
|
24
|
+
* not set (value is falsy) then it returns all headers definitions array.
|
|
25
|
+
*
|
|
26
|
+
* @param name A header name to look for. It will match a header where the header name contains the `name` param.
|
|
27
|
+
* @returns Array of the request headers matched `name` in the header's `key` field.
|
|
28
|
+
*/
|
|
29
|
+
export function queryRequestHeaders(name?: string): IHeaderDefinition[] {
|
|
30
|
+
return queryHeaders('request', name);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Queries for response headers that contains a `query`. If query is
|
|
35
|
+
* not set (value is falsy) then it returns all headers definitions array.
|
|
36
|
+
*
|
|
37
|
+
* @param name A header name to look for. It will match a header where the header name contains the `name` param.
|
|
38
|
+
* @returns Array of the response headers matched `name` in the header's `key` field.
|
|
39
|
+
*/
|
|
40
|
+
export function queryResponseHeaders(name?: string): IHeaderDefinition[] {
|
|
41
|
+
return queryHeaders('response', name);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Convenient function to look for a status code in the array.
|
|
46
|
+
*
|
|
47
|
+
* @param codeArg The status code to look for.
|
|
48
|
+
* @returns Status code definition or null if not found.
|
|
49
|
+
*/
|
|
50
|
+
export function getStatusCode(codeArg: number): IStatusCodeDefinition|IStatusCodeDefinition[]|null {
|
|
51
|
+
if (!codeArg) {
|
|
52
|
+
return statusCodes;
|
|
53
|
+
}
|
|
54
|
+
const code = Number(codeArg);
|
|
55
|
+
if (Number.isNaN(code)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const res = statusCodes.filter((item) => item.key === code);
|
|
59
|
+
if (!res.length) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return res[0];
|
|
63
|
+
}
|
|
@@ -55,8 +55,8 @@ function* headersStringToList(string: string): Generator<string[]> {
|
|
|
55
55
|
if (sepPosition === -1) {
|
|
56
56
|
yield [line, ''];
|
|
57
57
|
} else {
|
|
58
|
-
const name = line.
|
|
59
|
-
const value = line.
|
|
58
|
+
const name = line.substring(0, sepPosition);
|
|
59
|
+
const value = line.substring(sepPosition + 1).trim();
|
|
60
60
|
yield [name, value];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -70,7 +70,8 @@ export class Headers {
|
|
|
70
70
|
/**
|
|
71
71
|
* The keys are canonical keys and the values are the input values.
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
_map: Record<string, RawValue> = {};
|
|
74
|
+
|
|
74
75
|
/**
|
|
75
76
|
* @param headers The headers to parse.
|
|
76
77
|
*/
|
|
@@ -99,7 +100,7 @@ export class Headers {
|
|
|
99
100
|
}
|
|
100
101
|
const normalizedName = normalizeName(name);
|
|
101
102
|
value = value ? normalizeValue(value) : '';
|
|
102
|
-
let item = this.
|
|
103
|
+
let item = this._map[normalizedName];
|
|
103
104
|
if (item) {
|
|
104
105
|
const oldValue = item.value;
|
|
105
106
|
item.value = oldValue ? `${oldValue},${value}` : value;
|
|
@@ -109,7 +110,7 @@ export class Headers {
|
|
|
109
110
|
value,
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
|
-
this.
|
|
113
|
+
this._map[normalizedName] = item;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
/**
|
|
@@ -117,7 +118,7 @@ export class Headers {
|
|
|
117
118
|
* @param name The header name
|
|
118
119
|
*/
|
|
119
120
|
delete(name: string): void {
|
|
120
|
-
delete this.
|
|
121
|
+
delete this._map[normalizeName(name)];
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
/**
|
|
@@ -126,14 +127,14 @@ export class Headers {
|
|
|
126
127
|
*/
|
|
127
128
|
get(name: string): string | undefined {
|
|
128
129
|
name = normalizeName(name);
|
|
129
|
-
return this.has(name) ? this.
|
|
130
|
+
return this.has(name) ? this._map[name].value : undefined;
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
/**
|
|
133
134
|
* Checks if the header exists.
|
|
134
135
|
*/
|
|
135
136
|
has(name: string): boolean {
|
|
136
|
-
return Object.prototype.hasOwnProperty.call(this.
|
|
137
|
+
return Object.prototype.hasOwnProperty.call(this._map, normalizeName(name));
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/**
|
|
@@ -141,7 +142,7 @@ export class Headers {
|
|
|
141
142
|
*/
|
|
142
143
|
set(name: string, value: string): void {
|
|
143
144
|
const normalizedName = normalizeName(name);
|
|
144
|
-
this.
|
|
145
|
+
this._map[normalizedName] = {
|
|
145
146
|
value: normalizeValue(value),
|
|
146
147
|
name,
|
|
147
148
|
};
|
|
@@ -151,11 +152,28 @@ export class Headers {
|
|
|
151
152
|
* Iterates over each header.
|
|
152
153
|
*/
|
|
153
154
|
forEach(callback: (value: string, name: string, headers: Headers) => void, thisArg?: unknown): void {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
const keys = Object.keys(this._map);
|
|
156
|
+
keys.forEach((key) => {
|
|
157
|
+
const item = this._map[key];
|
|
158
|
+
callback.call(thisArg, item.value, item.name, this);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Calls a defined callback function on each element of the headers, and returns an array that contains the results.
|
|
164
|
+
*
|
|
165
|
+
* @param callbackfn A function that accepts up to two arguments. The map method calls the callbackfn function one time for each header.
|
|
166
|
+
* @param thisArg An object to which the `this` keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
167
|
+
*/
|
|
168
|
+
map<U>(callbackfn: (name: string, value: string) => U, thisArg?: any): U[] {
|
|
169
|
+
const keys = Object.keys(this._map);
|
|
170
|
+
const results: U[] = [];
|
|
171
|
+
for (const name of keys) {
|
|
172
|
+
const item = this._map[name];
|
|
173
|
+
const cbReturn = callbackfn.call(thisArg, item.value, item.name);
|
|
174
|
+
results.push(cbReturn);
|
|
158
175
|
}
|
|
176
|
+
return results;
|
|
159
177
|
}
|
|
160
178
|
|
|
161
179
|
/**
|
|
@@ -163,13 +181,15 @@ export class Headers {
|
|
|
163
181
|
*/
|
|
164
182
|
toString(): string {
|
|
165
183
|
const result: string[] = [];
|
|
166
|
-
this.
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
184
|
+
const keys = Object.keys(this._map);
|
|
185
|
+
for (const name of keys) {
|
|
186
|
+
const item = this._map[name];
|
|
187
|
+
let tmp = `${item.name}: `;
|
|
188
|
+
if (item.value) {
|
|
189
|
+
tmp += item.value;
|
|
170
190
|
}
|
|
171
191
|
result.push(tmp);
|
|
172
|
-
}
|
|
192
|
+
}
|
|
173
193
|
return result.join('\n');
|
|
174
194
|
}
|
|
175
195
|
|
|
@@ -177,10 +197,9 @@ export class Headers {
|
|
|
177
197
|
* Iterates over keys.
|
|
178
198
|
*/
|
|
179
199
|
*keys(): IterableIterator<string> {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
200
|
+
const keys = Object.keys(this._map);
|
|
201
|
+
for (const name of keys) {
|
|
202
|
+
yield this._map[name].name;
|
|
184
203
|
}
|
|
185
204
|
}
|
|
186
205
|
|
|
@@ -188,10 +207,9 @@ export class Headers {
|
|
|
188
207
|
* Iterates over values.
|
|
189
208
|
*/
|
|
190
209
|
*values(): IterableIterator<string> {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
210
|
+
const keys = Object.keys(this._map);
|
|
211
|
+
for (const name of keys) {
|
|
212
|
+
yield this._map[name].value;
|
|
195
213
|
}
|
|
196
214
|
}
|
|
197
215
|
|
|
@@ -199,10 +217,9 @@ export class Headers {
|
|
|
199
217
|
* Iterates over headers.
|
|
200
218
|
*/
|
|
201
219
|
*entries(): IterableIterator<string[]> {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
220
|
+
const keys = Object.keys(this._map);
|
|
221
|
+
for (const name of keys) {
|
|
222
|
+
yield [this._map[name].name, this._map[name].value];
|
|
206
223
|
}
|
|
207
224
|
}
|
|
208
225
|
|
|
@@ -210,10 +227,9 @@ export class Headers {
|
|
|
210
227
|
* Iterates over headers.
|
|
211
228
|
*/
|
|
212
229
|
*[Symbol.iterator](): IterableIterator<string[]> {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
230
|
+
const keys = Object.keys(this._map);
|
|
231
|
+
for (const name of keys) {
|
|
232
|
+
yield [this._map[name].name, this._map[name].value];
|
|
217
233
|
}
|
|
218
234
|
}
|
|
219
235
|
}
|