@azure/core-client 1.3.3 → 1.4.0-alpha.20220104.5
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/CHANGELOG.md +13 -0
- package/dist/index.js +125 -32
- package/dist/index.js.map +1 -1
- package/dist-esm/src/authorizeRequestOnClaimChallenge.js +70 -0
- package/dist-esm/src/authorizeRequestOnClaimChallenge.js.map +1 -0
- package/dist-esm/src/base64.browser.js +7 -0
- package/dist-esm/src/base64.browser.js.map +1 -1
- package/dist-esm/src/base64.js +8 -0
- package/dist-esm/src/base64.js.map +1 -1
- package/dist-esm/src/deserializationPolicy.js +10 -9
- package/dist-esm/src/deserializationPolicy.js.map +1 -1
- package/dist-esm/src/index.js +4 -3
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/interfaces.js.map +1 -1
- package/dist-esm/src/operationHelpers.js +1 -1
- package/dist-esm/src/operationHelpers.js.map +1 -1
- package/dist-esm/src/pipeline.js +3 -3
- package/dist-esm/src/pipeline.js.map +1 -1
- package/dist-esm/src/serializationPolicy.js +7 -7
- package/dist-esm/src/serializationPolicy.js.map +1 -1
- package/dist-esm/src/serializer.js +29 -14
- package/dist-esm/src/serializer.js.map +1 -1
- package/dist-esm/src/serviceClient.js +2 -2
- package/dist-esm/src/serviceClient.js.map +1 -1
- package/dist-esm/src/urlHelpers.js +2 -2
- package/dist-esm/src/urlHelpers.js.map +1 -1
- package/dist-esm/src/utils.js +1 -1
- package/dist-esm/src/utils.js.map +1 -1
- package/package.json +8 -9
- package/types/3.1/core-client.d.ts +205 -2
- package/types/latest/core-client.d.ts +206 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbortSignalLike } from '@azure/abort-controller';
|
|
2
|
+
import { AuthorizeRequestOnChallengeOptions } from '@azure/core-rest-pipeline';
|
|
2
3
|
import { HttpClient } from '@azure/core-rest-pipeline';
|
|
3
4
|
import { HttpMethods } from '@azure/core-rest-pipeline';
|
|
4
5
|
import { InternalPipelineOptions } from '@azure/core-rest-pipeline';
|
|
@@ -11,6 +12,37 @@ import { PipelineResponse } from '@azure/core-rest-pipeline';
|
|
|
11
12
|
import { TokenCredential } from '@azure/core-auth';
|
|
12
13
|
import { TransferProgressEvent } from '@azure/core-rest-pipeline';
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* This function can be used as a callback for the `bearerTokenAuthenticationPolicy` of `@azure/core-rest-pipeline`, to support CAE challenges:
|
|
17
|
+
* [Continuous Access Evaluation](https://docs.microsoft.com/azure/active-directory/conditional-access/concept-continuous-access-evaluation).
|
|
18
|
+
*
|
|
19
|
+
* Call the `bearerTokenAuthenticationPolicy` with the following options:
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
|
|
23
|
+
* import { authorizeRequestOnClaimChallenge } from "@azure/core-client";
|
|
24
|
+
*
|
|
25
|
+
* const bearerTokenAuthenticationPolicy = bearerTokenAuthenticationPolicy({
|
|
26
|
+
* authorizeRequestOnChallenge: authorizeRequestOnClaimChallenge
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Once provided, the `bearerTokenAuthenticationPolicy` policy will internally handle Continuous Access Evaluation (CAE) challenges.
|
|
31
|
+
* When it can't complete a challenge it will return the 401 (unauthorized) response from ARM.
|
|
32
|
+
*
|
|
33
|
+
* Example challenge with claims:
|
|
34
|
+
*
|
|
35
|
+
* ```
|
|
36
|
+
* Bearer authorization_uri="https://login.windows-ppe.net/", error="invalid_token",
|
|
37
|
+
* error_description="User session has been revoked",
|
|
38
|
+
* claims="eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTYwMzc0MjgwMCJ9fX0="
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function authorizeRequestOnClaimChallenge(onChallengeOptions: AuthorizeRequestOnChallengeOptions): Promise<boolean>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The base definition of a mapper. Can be used for XML and plain JavaScript objects.
|
|
45
|
+
*/
|
|
14
46
|
export declare interface BaseMapper {
|
|
15
47
|
/**
|
|
16
48
|
* Name for the xml element
|
|
@@ -84,18 +116,47 @@ export declare interface CommonClientOptions extends PipelineOptions {
|
|
|
84
116
|
allowInsecureConnection?: boolean;
|
|
85
117
|
}
|
|
86
118
|
|
|
119
|
+
/**
|
|
120
|
+
* A mapper composed of other mappers.
|
|
121
|
+
*/
|
|
87
122
|
export declare interface CompositeMapper extends BaseMapper {
|
|
123
|
+
/**
|
|
124
|
+
* The type descriptor of the `CompositeMapper`.
|
|
125
|
+
*/
|
|
88
126
|
type: CompositeMapperType;
|
|
89
127
|
}
|
|
90
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Helps build a mapper that describes how to map a set of properties of an object based on other mappers.
|
|
131
|
+
*
|
|
132
|
+
* Only one of the following properties should be present: `className`, `modelProperties` and `additionalProperties`.
|
|
133
|
+
*/
|
|
91
134
|
export declare interface CompositeMapperType {
|
|
135
|
+
/**
|
|
136
|
+
* Name of the composite mapper type.
|
|
137
|
+
*/
|
|
92
138
|
name: "Composite";
|
|
139
|
+
/**
|
|
140
|
+
* Use `className` to reference another type definition.
|
|
141
|
+
*/
|
|
93
142
|
className?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Use `modelProperties` when the reference to the other type has been resolved.
|
|
145
|
+
*/
|
|
94
146
|
modelProperties?: {
|
|
95
147
|
[propertyName: string]: Mapper;
|
|
96
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Used when a model has `additionalProperties: true`. Allows the generic processing of unnamed model properties on the response object.
|
|
151
|
+
*/
|
|
97
152
|
additionalProperties?: Mapper;
|
|
153
|
+
/**
|
|
154
|
+
* The name of the top-most parent scheme, the one that has no parents.
|
|
155
|
+
*/
|
|
98
156
|
uberParent?: string;
|
|
157
|
+
/**
|
|
158
|
+
* A polymorphic discriminator.
|
|
159
|
+
*/
|
|
99
160
|
polymorphicDiscriminator?: PolymorphicDiscriminator;
|
|
100
161
|
}
|
|
101
162
|
|
|
@@ -162,22 +223,55 @@ export declare interface DeserializationPolicyOptions {
|
|
|
162
223
|
serializerOptions?: SerializerOptions;
|
|
163
224
|
}
|
|
164
225
|
|
|
226
|
+
/**
|
|
227
|
+
* A mapper describing plain JavaScript objects used as key/value pairs.
|
|
228
|
+
*/
|
|
165
229
|
export declare interface DictionaryMapper extends BaseMapper {
|
|
230
|
+
/**
|
|
231
|
+
* The type descriptor of the `DictionaryMapper`.
|
|
232
|
+
*/
|
|
166
233
|
type: DictionaryMapperType;
|
|
234
|
+
/**
|
|
235
|
+
* Optionally, a prefix to add to the header collection.
|
|
236
|
+
*/
|
|
167
237
|
headerCollectionPrefix?: string;
|
|
168
238
|
}
|
|
169
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Helps build a mapper that describes how to parse a dictionary of mapped values.
|
|
242
|
+
*/
|
|
170
243
|
export declare interface DictionaryMapperType {
|
|
244
|
+
/**
|
|
245
|
+
* Name of the sequence type mapper.
|
|
246
|
+
*/
|
|
171
247
|
name: "Dictionary";
|
|
248
|
+
/**
|
|
249
|
+
* The mapper to use to map the value of each property in the dictionary.
|
|
250
|
+
*/
|
|
172
251
|
value: Mapper;
|
|
173
252
|
}
|
|
174
253
|
|
|
254
|
+
/**
|
|
255
|
+
* A mapper describing an enum value.
|
|
256
|
+
*/
|
|
175
257
|
export declare interface EnumMapper extends BaseMapper {
|
|
258
|
+
/**
|
|
259
|
+
* The type descriptor of the `EnumMapper`.
|
|
260
|
+
*/
|
|
176
261
|
type: EnumMapperType;
|
|
177
262
|
}
|
|
178
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Helps build a mapper that describes how to parse an enum value.
|
|
266
|
+
*/
|
|
179
267
|
export declare interface EnumMapperType {
|
|
268
|
+
/**
|
|
269
|
+
* Name of the enum type mapper.
|
|
270
|
+
*/
|
|
180
271
|
name: "Enum";
|
|
272
|
+
/**
|
|
273
|
+
* Values allowed by this mapper.
|
|
274
|
+
*/
|
|
181
275
|
allowedValues: any[];
|
|
182
276
|
}
|
|
183
277
|
|
|
@@ -225,22 +319,65 @@ export declare interface InternalClientPipelineOptions extends InternalPipelineO
|
|
|
225
319
|
serializationOptions?: SerializationPolicyOptions;
|
|
226
320
|
}
|
|
227
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Mappers are definitions of the data models used in the library.
|
|
324
|
+
* These data models are part of the Operation or Client definitions in the responses or parameters.
|
|
325
|
+
*/
|
|
228
326
|
export declare type Mapper = BaseMapper | CompositeMapper | SequenceMapper | DictionaryMapper | EnumMapper;
|
|
229
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Description of various value constraints such as integer ranges and string regex.
|
|
330
|
+
*/
|
|
230
331
|
export declare interface MapperConstraints {
|
|
332
|
+
/**
|
|
333
|
+
* The value should be less than or equal to the `InclusiveMaximum` value.
|
|
334
|
+
*/
|
|
231
335
|
InclusiveMaximum?: number;
|
|
336
|
+
/**
|
|
337
|
+
* The value should be less than the `ExclusiveMaximum` value.
|
|
338
|
+
*/
|
|
232
339
|
ExclusiveMaximum?: number;
|
|
340
|
+
/**
|
|
341
|
+
* The value should be greater than or equal to the `InclusiveMinimum` value.
|
|
342
|
+
*/
|
|
233
343
|
InclusiveMinimum?: number;
|
|
344
|
+
/**
|
|
345
|
+
* The value should be greater than the `InclusiveMinimum` value.
|
|
346
|
+
*/
|
|
234
347
|
ExclusiveMinimum?: number;
|
|
348
|
+
/**
|
|
349
|
+
* The length should be smaller than the `MaxLength`.
|
|
350
|
+
*/
|
|
235
351
|
MaxLength?: number;
|
|
352
|
+
/**
|
|
353
|
+
* The length should be bigger than the `MinLength`.
|
|
354
|
+
*/
|
|
236
355
|
MinLength?: number;
|
|
356
|
+
/**
|
|
357
|
+
* The value must match the pattern.
|
|
358
|
+
*/
|
|
237
359
|
Pattern?: RegExp;
|
|
360
|
+
/**
|
|
361
|
+
* The value must contain fewer items than the MaxItems value.
|
|
362
|
+
*/
|
|
238
363
|
MaxItems?: number;
|
|
364
|
+
/**
|
|
365
|
+
* The value must contain more items than the `MinItems` value.
|
|
366
|
+
*/
|
|
239
367
|
MinItems?: number;
|
|
368
|
+
/**
|
|
369
|
+
* The value must contain only unique items.
|
|
370
|
+
*/
|
|
240
371
|
UniqueItems?: true;
|
|
372
|
+
/**
|
|
373
|
+
* The value should be exactly divisible by the `MultipleOf` value.
|
|
374
|
+
*/
|
|
241
375
|
MultipleOf?: number;
|
|
242
376
|
}
|
|
243
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Type of the mapper. Includes known mappers.
|
|
380
|
+
*/
|
|
244
381
|
export declare type MapperType = SimpleMapperType | CompositeMapperType | SequenceMapperType | DictionaryMapperType | EnumMapperType;
|
|
245
382
|
|
|
246
383
|
/**
|
|
@@ -504,9 +641,25 @@ export declare type ParameterPath = string | string[] | {
|
|
|
504
641
|
[propertyName: string]: ParameterPath;
|
|
505
642
|
};
|
|
506
643
|
|
|
644
|
+
/**
|
|
645
|
+
* Used to disambiguate discriminated type unions.
|
|
646
|
+
* For example, if response can have many shapes but also includes a 'kind' field (or similar),
|
|
647
|
+
* that field can be used to determine how to deserialize the response to the correct type.
|
|
648
|
+
*/
|
|
507
649
|
export declare interface PolymorphicDiscriminator {
|
|
650
|
+
/**
|
|
651
|
+
* Name of the discriminant property in the original JSON payload, e.g. `@odata.kind`.
|
|
652
|
+
*/
|
|
508
653
|
serializedName: string;
|
|
654
|
+
/**
|
|
655
|
+
* Name to use on the resulting object instead of the original property name.
|
|
656
|
+
* Useful since the JSON property could be difficult to work with.
|
|
657
|
+
* For example: For a field received as `@odata.kind`, the final object could instead include a property simply named `kind`.
|
|
658
|
+
*/
|
|
509
659
|
clientName: string;
|
|
660
|
+
/**
|
|
661
|
+
* It may contain any other property.
|
|
662
|
+
*/
|
|
510
663
|
[key: string]: string;
|
|
511
664
|
}
|
|
512
665
|
|
|
@@ -522,12 +675,27 @@ export declare type QueryCollectionFormat = "CSV" | "SSV" | "TSV" | "Pipes" | "M
|
|
|
522
675
|
*/
|
|
523
676
|
export declare type RawResponseCallback = (rawResponse: FullOperationResponse, flatResponse: unknown) => void;
|
|
524
677
|
|
|
678
|
+
/**
|
|
679
|
+
* A mapper describing arrays.
|
|
680
|
+
*/
|
|
525
681
|
export declare interface SequenceMapper extends BaseMapper {
|
|
682
|
+
/**
|
|
683
|
+
* The type descriptor of the `SequenceMapper`.
|
|
684
|
+
*/
|
|
526
685
|
type: SequenceMapperType;
|
|
527
686
|
}
|
|
528
687
|
|
|
688
|
+
/**
|
|
689
|
+
* Helps build a mapper that describes how to parse a sequence of mapped values.
|
|
690
|
+
*/
|
|
529
691
|
export declare interface SequenceMapperType {
|
|
692
|
+
/**
|
|
693
|
+
* Name of the sequence type mapper.
|
|
694
|
+
*/
|
|
530
695
|
name: "Sequence";
|
|
696
|
+
/**
|
|
697
|
+
* The mapper to use to map each one of the properties of the sequence.
|
|
698
|
+
*/
|
|
531
699
|
element: Mapper;
|
|
532
700
|
}
|
|
533
701
|
|
|
@@ -558,16 +726,46 @@ export declare interface SerializationPolicyOptions {
|
|
|
558
726
|
|
|
559
727
|
/**
|
|
560
728
|
* Used to map raw response objects to final shapes.
|
|
561
|
-
*
|
|
562
|
-
*
|
|
729
|
+
* Helps packing and unpacking Dates and other encoded types that are not intrinsic to JSON.
|
|
730
|
+
* Also allows pulling values from headers, as well as inserting default values and constants.
|
|
563
731
|
*/
|
|
564
732
|
export declare interface Serializer {
|
|
733
|
+
/**
|
|
734
|
+
* The provided model mapper.
|
|
735
|
+
*/
|
|
565
736
|
readonly modelMappers: {
|
|
566
737
|
[key: string]: any;
|
|
567
738
|
};
|
|
739
|
+
/**
|
|
740
|
+
* Whether the contents are XML or not.
|
|
741
|
+
*/
|
|
568
742
|
readonly isXML: boolean;
|
|
743
|
+
/**
|
|
744
|
+
* Validates constraints, if any. This function will throw if the provided value does not respect those constraints.
|
|
745
|
+
* @param mapper - The definition of data models.
|
|
746
|
+
* @param value - The value.
|
|
747
|
+
* @param objectName - Name of the object. Used in the error messages.
|
|
748
|
+
*/
|
|
569
749
|
validateConstraints(mapper: Mapper, value: any, objectName: string): void;
|
|
750
|
+
/**
|
|
751
|
+
* Serialize the given object based on its metadata defined in the mapper.
|
|
752
|
+
*
|
|
753
|
+
* @param mapper - The mapper which defines the metadata of the serializable object.
|
|
754
|
+
* @param object - A valid Javascript object to be serialized.
|
|
755
|
+
* @param objectName - Name of the serialized object.
|
|
756
|
+
* @param options - additional options to deserialization.
|
|
757
|
+
* @returns A valid serialized Javascript object.
|
|
758
|
+
*/
|
|
570
759
|
serialize(mapper: Mapper, object: any, objectName?: string, options?: SerializerOptions): any;
|
|
760
|
+
/**
|
|
761
|
+
* Deserialize the given object based on its metadata defined in the mapper.
|
|
762
|
+
*
|
|
763
|
+
* @param mapper - The mapper which defines the metadata of the serializable object.
|
|
764
|
+
* @param responseBody - A valid Javascript entity to be deserialized.
|
|
765
|
+
* @param objectName - Name of the deserialized object.
|
|
766
|
+
* @param options - Controls behavior of XML parser and builder.
|
|
767
|
+
* @returns A valid deserialized Javascript object.
|
|
768
|
+
*/
|
|
571
769
|
deserialize(mapper: Mapper, responseBody: any, objectName: string, options?: SerializerOptions): any;
|
|
572
770
|
}
|
|
573
771
|
|
|
@@ -654,7 +852,13 @@ export declare interface ServiceClientOptions extends CommonClientOptions {
|
|
|
654
852
|
pipeline?: Pipeline;
|
|
655
853
|
}
|
|
656
854
|
|
|
855
|
+
/**
|
|
856
|
+
* The type of a simple mapper.
|
|
857
|
+
*/
|
|
657
858
|
export declare interface SimpleMapperType {
|
|
859
|
+
/**
|
|
860
|
+
* Name of the type of the property.
|
|
861
|
+
*/
|
|
658
862
|
name: "Base64Url" | "Boolean" | "ByteArray" | "Date" | "DateTime" | "DateTimeRfc1123" | "Object" | "Stream" | "String" | "TimeSpan" | "UnixTime" | "Uuid" | "Number" | "any";
|
|
659
863
|
}
|
|
660
864
|
|