@azure/core-client 1.10.2-alpha.20260227.2 → 1.10.2-alpha.20260306.4
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/dist/browser/base64.d.ts +1 -1
- package/dist/browser/base64.js +1 -1
- package/dist/browser/base64.js.map +1 -0
- package/dist/browser/index.d.ts +5 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/state.d.ts +1 -1
- package/dist/browser/state.js +1 -1
- package/dist/browser/state.js.map +1 -0
- package/dist/commonjs/index.d.ts +5 -5
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/state.d.ts +3 -2
- package/dist/commonjs/state.js +1 -1
- package/dist/commonjs/state.js.map +1 -0
- package/dist/esm/authorizeRequestOnClaimChallenge.js +44 -67
- package/dist/esm/authorizeRequestOnClaimChallenge.js.map +7 -1
- package/dist/esm/authorizeRequestOnTenantChallenge.js +72 -98
- package/dist/esm/authorizeRequestOnTenantChallenge.js.map +7 -1
- package/dist/esm/base64.js +15 -32
- package/dist/esm/base64.js.map +7 -1
- package/dist/esm/deserializationPolicy.js +205 -202
- package/dist/esm/deserializationPolicy.js.map +7 -1
- package/dist/esm/httpClientCache.js +8 -8
- package/dist/esm/httpClientCache.js.map +7 -1
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +31 -11
- package/dist/esm/index.js.map +7 -1
- package/dist/esm/interfaceHelpers.js +23 -35
- package/dist/esm/interfaceHelpers.js.map +7 -1
- package/dist/esm/interfaces.js +6 -11
- package/dist/esm/interfaces.js.map +7 -1
- package/dist/esm/log.js +4 -4
- package/dist/esm/log.js.map +7 -1
- package/dist/esm/operationHelpers.js +73 -82
- package/dist/esm/operationHelpers.js.map +7 -1
- package/dist/esm/pipeline.js +22 -23
- package/dist/esm/pipeline.js.map +7 -1
- package/dist/esm/serializationPolicy.js +163 -134
- package/dist/esm/serializationPolicy.js.map +7 -1
- package/dist/esm/serializer.js +812 -856
- package/dist/esm/serializer.js.map +7 -1
- package/dist/esm/serviceClient.js +151 -150
- package/dist/esm/serviceClient.js.map +7 -1
- package/dist/esm/state.js +4 -9
- package/dist/esm/state.js.map +7 -1
- package/dist/esm/urlHelpers.js +199 -206
- package/dist/esm/urlHelpers.js.map +7 -1
- package/dist/esm/utils.js +64 -118
- package/dist/esm/utils.js.map +7 -1
- package/dist/react-native/index.d.ts +5 -5
- package/dist/react-native/index.js.map +1 -1
- package/package.json +2 -19
- package/dist/browser/base64-browser.mjs.map +0 -1
- package/dist/browser/state-browser.mjs.map +0 -1
- package/dist/commonjs/state-cjs.cjs.map +0 -1
package/dist/browser/base64.d.ts
CHANGED
package/dist/browser/base64.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/base64.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\ndeclare global {\n // stub these out for the browser\n function btoa(input: string): string;\n function atob(input: string): string;\n}\n\n/**\n * Encodes a string in base64 format.\n * @param value - the string to encode\n * @internal\n */\nexport function encodeString(value: string): string {\n return btoa(value);\n}\n\n/**\n * Encodes a byte array in base64 format.\n * @param value - the Uint8Aray to encode\n * @internal\n */\nexport function encodeByteArray(value: Uint8Array): string {\n let str = \"\";\n for (let i = 0; i < value.length; i++) {\n str += String.fromCharCode(value[i]);\n }\n return btoa(str);\n}\n\n/**\n * Decodes a base64 string into a byte array.\n * @param value - the base64 string to decode\n * @internal\n */\nexport function decodeString(value: string): Uint8Array {\n const byteString = atob(value);\n const arr = new Uint8Array(byteString.length);\n for (let i = 0; i < byteString.length; i++) {\n arr[i] = byteString.charCodeAt(i);\n }\n return arr;\n}\n\n/**\n * Decodes a base64 string into a string.\n * @param value - the base64 string to decode\n * @internal\n */\nexport function decodeStringToString(value: string): string {\n return atob(value);\n}\n"]}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { createSerializer, MapperTypeNames } from "./serializer.js";
|
|
2
|
-
export { ServiceClient, ServiceClientOptions } from "./serviceClient.js";
|
|
3
|
-
export { createClientPipeline, InternalClientPipelineOptions } from "./pipeline.js";
|
|
4
|
-
export { OperationSpec, OperationArguments, OperationOptions, OperationResponseMap, OperationParameter, OperationQueryParameter, OperationURLParameter, Serializer, BaseMapper, Mapper, MapperType, SimpleMapperType, EnumMapper, EnumMapperType, SequenceMapper, SequenceMapperType, DictionaryMapper, DictionaryMapperType, CompositeMapper, CompositeMapperType, MapperConstraints, OperationRequest, OperationRequestOptions, OperationRequestInfo, QueryCollectionFormat, ParameterPath, FullOperationResponse, PolymorphicDiscriminator, SpanConfig, XML_ATTRKEY, XML_CHARKEY, XmlOptions, SerializerOptions, RawResponseCallback, CommonClientOptions, AdditionalPolicyConfig, } from "./interfaces.js";
|
|
5
|
-
export { deserializationPolicy, deserializationPolicyName, DeserializationPolicyOptions, DeserializationContentTypes, } from "./deserializationPolicy.js";
|
|
6
|
-
export { serializationPolicy, serializationPolicyName, SerializationPolicyOptions, } from "./serializationPolicy.js";
|
|
2
|
+
export { ServiceClient, type ServiceClientOptions } from "./serviceClient.js";
|
|
3
|
+
export { createClientPipeline, type InternalClientPipelineOptions } from "./pipeline.js";
|
|
4
|
+
export { type OperationSpec, type OperationArguments, type OperationOptions, type OperationResponseMap, type OperationParameter, type OperationQueryParameter, type OperationURLParameter, type Serializer, type BaseMapper, type Mapper, type MapperType, type SimpleMapperType, type EnumMapper, type EnumMapperType, type SequenceMapper, type SequenceMapperType, type DictionaryMapper, type DictionaryMapperType, type CompositeMapper, type CompositeMapperType, type MapperConstraints, type OperationRequest, type OperationRequestOptions, type OperationRequestInfo, type QueryCollectionFormat, type ParameterPath, type FullOperationResponse, type PolymorphicDiscriminator, type SpanConfig, XML_ATTRKEY, XML_CHARKEY, type XmlOptions, type SerializerOptions, type RawResponseCallback, type CommonClientOptions, type AdditionalPolicyConfig, } from "./interfaces.js";
|
|
5
|
+
export { deserializationPolicy, deserializationPolicyName, type DeserializationPolicyOptions, type DeserializationContentTypes, } from "./deserializationPolicy.js";
|
|
6
|
+
export { serializationPolicy, serializationPolicyName, type SerializationPolicyOptions, } from "./serializationPolicy.js";
|
|
7
7
|
export { authorizeRequestOnClaimChallenge } from "./authorizeRequestOnClaimChallenge.js";
|
|
8
8
|
export { authorizeRequestOnTenantChallenge } from "./authorizeRequestOnTenantChallenge.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAsC,MAAM,eAAe,CAAC;AACzF,OAAO,EA8BL,WAAW,EACX,WAAW,GAMZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAG1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GAExB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gCAAgC,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { createSerializer, MapperTypeNames } from \"./serializer.js\";\nexport { ServiceClient, type ServiceClientOptions } from \"./serviceClient.js\";\nexport { createClientPipeline, type InternalClientPipelineOptions } from \"./pipeline.js\";\nexport {\n type OperationSpec,\n type OperationArguments,\n type OperationOptions,\n type OperationResponseMap,\n type OperationParameter,\n type OperationQueryParameter,\n type OperationURLParameter,\n type Serializer,\n type BaseMapper,\n type Mapper,\n type MapperType,\n type SimpleMapperType,\n type EnumMapper,\n type EnumMapperType,\n type SequenceMapper,\n type SequenceMapperType,\n type DictionaryMapper,\n type DictionaryMapperType,\n type CompositeMapper,\n type CompositeMapperType,\n type MapperConstraints,\n type OperationRequest,\n type OperationRequestOptions,\n type OperationRequestInfo,\n type QueryCollectionFormat,\n type ParameterPath,\n type FullOperationResponse,\n type PolymorphicDiscriminator,\n type SpanConfig,\n XML_ATTRKEY,\n XML_CHARKEY,\n type XmlOptions,\n type SerializerOptions,\n type RawResponseCallback,\n type CommonClientOptions,\n type AdditionalPolicyConfig,\n} from \"./interfaces.js\";\nexport {\n deserializationPolicy,\n deserializationPolicyName,\n type DeserializationPolicyOptions,\n type DeserializationContentTypes,\n} from \"./deserializationPolicy.js\";\nexport {\n serializationPolicy,\n serializationPolicyName,\n type SerializationPolicyOptions,\n} from \"./serializationPolicy.js\";\nexport { authorizeRequestOnClaimChallenge } from \"./authorizeRequestOnClaimChallenge.js\";\nexport { authorizeRequestOnTenantChallenge } from \"./authorizeRequestOnTenantChallenge.js\";\n"]}
|
package/dist/browser/state.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import type { OperationRequestInfo } from "./interfaces.js";
|
|
|
5
5
|
export declare const state: {
|
|
6
6
|
operationRequestMap: WeakMap<import("@azure/core-rest-pipeline").PipelineRequest, OperationRequestInfo>;
|
|
7
7
|
};
|
|
8
|
-
//# sourceMappingURL=state
|
|
8
|
+
//# sourceMappingURL=state.d.ts.map
|
package/dist/browser/state.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,mBAAmB,EAAE,IAAI,OAAO,EAA0C;CAC3E,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationRequest, OperationRequestInfo } from \"./interfaces.js\";\n\n/**\n * Browser-only implementation of the module's state. The browser esm variant will not load the commonjs state, so we do not need to share state between the two.\n */\nexport const state = {\n operationRequestMap: new WeakMap<OperationRequest, OperationRequestInfo>(),\n};\n"]}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { createSerializer, MapperTypeNames } from "./serializer.js";
|
|
2
|
-
export { ServiceClient, ServiceClientOptions } from "./serviceClient.js";
|
|
3
|
-
export { createClientPipeline, InternalClientPipelineOptions } from "./pipeline.js";
|
|
4
|
-
export { OperationSpec, OperationArguments, OperationOptions, OperationResponseMap, OperationParameter, OperationQueryParameter, OperationURLParameter, Serializer, BaseMapper, Mapper, MapperType, SimpleMapperType, EnumMapper, EnumMapperType, SequenceMapper, SequenceMapperType, DictionaryMapper, DictionaryMapperType, CompositeMapper, CompositeMapperType, MapperConstraints, OperationRequest, OperationRequestOptions, OperationRequestInfo, QueryCollectionFormat, ParameterPath, FullOperationResponse, PolymorphicDiscriminator, SpanConfig, XML_ATTRKEY, XML_CHARKEY, XmlOptions, SerializerOptions, RawResponseCallback, CommonClientOptions, AdditionalPolicyConfig, } from "./interfaces.js";
|
|
5
|
-
export { deserializationPolicy, deserializationPolicyName, DeserializationPolicyOptions, DeserializationContentTypes, } from "./deserializationPolicy.js";
|
|
6
|
-
export { serializationPolicy, serializationPolicyName, SerializationPolicyOptions, } from "./serializationPolicy.js";
|
|
2
|
+
export { ServiceClient, type ServiceClientOptions } from "./serviceClient.js";
|
|
3
|
+
export { createClientPipeline, type InternalClientPipelineOptions } from "./pipeline.js";
|
|
4
|
+
export { type OperationSpec, type OperationArguments, type OperationOptions, type OperationResponseMap, type OperationParameter, type OperationQueryParameter, type OperationURLParameter, type Serializer, type BaseMapper, type Mapper, type MapperType, type SimpleMapperType, type EnumMapper, type EnumMapperType, type SequenceMapper, type SequenceMapperType, type DictionaryMapper, type DictionaryMapperType, type CompositeMapper, type CompositeMapperType, type MapperConstraints, type OperationRequest, type OperationRequestOptions, type OperationRequestInfo, type QueryCollectionFormat, type ParameterPath, type FullOperationResponse, type PolymorphicDiscriminator, type SpanConfig, XML_ATTRKEY, XML_CHARKEY, type XmlOptions, type SerializerOptions, type RawResponseCallback, type CommonClientOptions, type AdditionalPolicyConfig, } from "./interfaces.js";
|
|
5
|
+
export { deserializationPolicy, deserializationPolicyName, type DeserializationPolicyOptions, type DeserializationContentTypes, } from "./deserializationPolicy.js";
|
|
6
|
+
export { serializationPolicy, serializationPolicyName, type SerializationPolicyOptions, } from "./serializationPolicy.js";
|
|
7
7
|
export { authorizeRequestOnClaimChallenge } from "./authorizeRequestOnClaimChallenge.js";
|
|
8
8
|
export { authorizeRequestOnTenantChallenge } from "./authorizeRequestOnTenantChallenge.js";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iDAAoE;AAA3D,iHAAA,gBAAgB,OAAA;AAAE,gHAAA,eAAe,OAAA;AAC1C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iDAAoE;AAA3D,iHAAA,gBAAgB,OAAA;AAAE,gHAAA,eAAe,OAAA;AAC1C,uDAA8E;AAArE,iHAAA,aAAa,OAAA;AACtB,6CAAyF;AAAhF,mHAAA,oBAAoB,OAAA;AAC7B,iDAqCyB;AAPvB,4GAAA,WAAW,OAAA;AACX,4GAAA,WAAW,OAAA;AAOb,uEAKoC;AAJlC,iIAAA,qBAAqB,OAAA;AACrB,qIAAA,yBAAyB,OAAA;AAI3B,mEAIkC;AAHhC,6HAAA,mBAAmB,OAAA;AACnB,iIAAA,uBAAuB,OAAA;AAGzB,6FAAyF;AAAhF,uJAAA,gCAAgC,OAAA;AACzC,+FAA2F;AAAlF,yJAAA,iCAAiC,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { createSerializer, MapperTypeNames } from \"./serializer.js\";\nexport { ServiceClient, type ServiceClientOptions } from \"./serviceClient.js\";\nexport { createClientPipeline, type InternalClientPipelineOptions } from \"./pipeline.js\";\nexport {\n type OperationSpec,\n type OperationArguments,\n type OperationOptions,\n type OperationResponseMap,\n type OperationParameter,\n type OperationQueryParameter,\n type OperationURLParameter,\n type Serializer,\n type BaseMapper,\n type Mapper,\n type MapperType,\n type SimpleMapperType,\n type EnumMapper,\n type EnumMapperType,\n type SequenceMapper,\n type SequenceMapperType,\n type DictionaryMapper,\n type DictionaryMapperType,\n type CompositeMapper,\n type CompositeMapperType,\n type MapperConstraints,\n type OperationRequest,\n type OperationRequestOptions,\n type OperationRequestInfo,\n type QueryCollectionFormat,\n type ParameterPath,\n type FullOperationResponse,\n type PolymorphicDiscriminator,\n type SpanConfig,\n XML_ATTRKEY,\n XML_CHARKEY,\n type XmlOptions,\n type SerializerOptions,\n type RawResponseCallback,\n type CommonClientOptions,\n type AdditionalPolicyConfig,\n} from \"./interfaces.js\";\nexport {\n deserializationPolicy,\n deserializationPolicyName,\n type DeserializationPolicyOptions,\n type DeserializationContentTypes,\n} from \"./deserializationPolicy.js\";\nexport {\n serializationPolicy,\n serializationPolicyName,\n type SerializationPolicyOptions,\n} from \"./serializationPolicy.js\";\nexport { authorizeRequestOnClaimChallenge } from \"./authorizeRequestOnClaimChallenge.js\";\nexport { authorizeRequestOnTenantChallenge } from \"./authorizeRequestOnTenantChallenge.js\";\n"]}
|
package/dist/commonjs/state.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { OperationRequestInfo } from "./interfaces.js";
|
|
1
2
|
/**
|
|
2
3
|
* Holds the singleton operationRequestMap, to be shared across CJS and ESM imports.
|
|
3
4
|
*/
|
|
4
5
|
export declare const state: {
|
|
5
|
-
operationRequestMap: WeakMap<
|
|
6
|
+
operationRequestMap: WeakMap<import("@azure/core-rest-pipeline").PipelineRequest, OperationRequestInfo>;
|
|
6
7
|
};
|
|
7
|
-
//# sourceMappingURL=state
|
|
8
|
+
//# sourceMappingURL=state.d.ts.map
|
package/dist/commonjs/state.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC;;GAEG;AACU,QAAA,KAAK,GAAG;IACnB,mBAAmB,EAAE,IAAI,OAAO,EAA0C;CAC3E,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationRequest, OperationRequestInfo } from \"./interfaces.js\";\n\n/**\n * Holds the singleton operationRequestMap, to be shared across CJS and ESM imports.\n */\nexport const state = {\n operationRequestMap: new WeakMap<OperationRequest, OperationRequestInfo>(),\n};\n"]}
|
|
@@ -1,72 +1,49 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
1
|
import { logger as coreClientLogger } from "./log.js";
|
|
4
2
|
import { decodeStringToString } from "./base64.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const challengeParts = `${challenge.trim()}, `.split('", ').filter((x) => x);
|
|
15
|
-
const keyValuePairs = challengeParts.map((keyValue) => (([key, value]) => ({ [key]: value }))(keyValue.trim().split('="')));
|
|
16
|
-
// Key-value pairs to plain object:
|
|
17
|
-
return keyValuePairs.reduce((a, b) => ({ ...a, ...b }), {});
|
|
18
|
-
});
|
|
3
|
+
function parseCAEChallenge(challenges) {
|
|
4
|
+
const bearerChallenges = `, ${challenges.trim()}`.split(", Bearer ").filter((x) => x);
|
|
5
|
+
return bearerChallenges.map((challenge) => {
|
|
6
|
+
const challengeParts = `${challenge.trim()}, `.split('", ').filter((x) => x);
|
|
7
|
+
const keyValuePairs = challengeParts.map(
|
|
8
|
+
(keyValue) => (([key, value]) => ({ [key]: value }))(keyValue.trim().split('="'))
|
|
9
|
+
);
|
|
10
|
+
return keyValuePairs.reduce((a, b) => ({ ...a, ...b }), {});
|
|
11
|
+
});
|
|
19
12
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
* ```
|
|
44
|
-
* Bearer authorization_uri="https://login.windows-ppe.net/", error="invalid_token",
|
|
45
|
-
* error_description="User session has been revoked",
|
|
46
|
-
* claims="eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTYwMzc0MjgwMCJ9fX0="
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export async function authorizeRequestOnClaimChallenge(onChallengeOptions) {
|
|
50
|
-
const { scopes, response } = onChallengeOptions;
|
|
51
|
-
const logger = onChallengeOptions.logger || coreClientLogger;
|
|
52
|
-
const challenge = response.headers.get("WWW-Authenticate");
|
|
53
|
-
if (!challenge) {
|
|
54
|
-
logger.info(`The WWW-Authenticate header was missing. Failed to perform the Continuous Access Evaluation authentication flow.`);
|
|
55
|
-
return false;
|
|
13
|
+
async function authorizeRequestOnClaimChallenge(onChallengeOptions) {
|
|
14
|
+
const { scopes, response } = onChallengeOptions;
|
|
15
|
+
const logger = onChallengeOptions.logger || coreClientLogger;
|
|
16
|
+
const challenge = response.headers.get("WWW-Authenticate");
|
|
17
|
+
if (!challenge) {
|
|
18
|
+
logger.info(
|
|
19
|
+
`The WWW-Authenticate header was missing. Failed to perform the Continuous Access Evaluation authentication flow.`
|
|
20
|
+
);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const challenges = parseCAEChallenge(challenge) || [];
|
|
24
|
+
const parsedChallenge = challenges.find((x) => x.claims);
|
|
25
|
+
if (!parsedChallenge) {
|
|
26
|
+
logger.info(
|
|
27
|
+
`The WWW-Authenticate header was missing the necessary "claims" to perform the Continuous Access Evaluation authentication flow.`
|
|
28
|
+
);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const accessToken = await onChallengeOptions.getAccessToken(
|
|
32
|
+
parsedChallenge.scope ? [parsedChallenge.scope] : scopes,
|
|
33
|
+
{
|
|
34
|
+
claims: decodeStringToString(parsedChallenge.claims)
|
|
56
35
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (!accessToken) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
onChallengeOptions.request.headers.set("Authorization", `${accessToken.tokenType ?? "Bearer"} ${accessToken.token}`);
|
|
70
|
-
return true;
|
|
36
|
+
);
|
|
37
|
+
if (!accessToken) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
onChallengeOptions.request.headers.set(
|
|
41
|
+
"Authorization",
|
|
42
|
+
`${accessToken.tokenType ?? "Bearer"} ${accessToken.token}`
|
|
43
|
+
);
|
|
44
|
+
return true;
|
|
71
45
|
}
|
|
72
|
-
|
|
46
|
+
export {
|
|
47
|
+
authorizeRequestOnClaimChallenge,
|
|
48
|
+
parseCAEChallenge
|
|
49
|
+
};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/core-client/src/authorizeRequestOnClaimChallenge.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AuthorizeRequestOnChallengeOptions } from \"@azure/core-rest-pipeline\";\nimport { logger as coreClientLogger } from \"./log.js\";\nimport { decodeStringToString } from \"./base64.js\";\n\n/**\n * Converts: `Bearer a=\"b\", c=\"d\", Bearer d=\"e\", f=\"g\"`.\n * Into: `[ { a: 'b', c: 'd' }, { d: 'e', f: 'g' } ]`.\n *\n * @internal\n */\nexport function parseCAEChallenge(challenges: string): any[] {\n const bearerChallenges = `, ${challenges.trim()}`.split(\", Bearer \").filter((x) => x);\n return bearerChallenges.map((challenge) => {\n const challengeParts = `${challenge.trim()}, `.split('\", ').filter((x) => x);\n const keyValuePairs = challengeParts.map((keyValue) =>\n (([key, value]) => ({ [key]: value }))(keyValue.trim().split('=\"')),\n );\n // Key-value pairs to plain object:\n return keyValuePairs.reduce((a, b) => ({ ...a, ...b }), {});\n });\n}\n\n/**\n * CAE Challenge structure\n */\nexport interface CAEChallenge {\n scope: string;\n claims: string;\n}\n\n/**\n * This function can be used as a callback for the `bearerTokenAuthenticationPolicy` of `@azure/core-rest-pipeline`, to support CAE challenges:\n * [Continuous Access Evaluation](https://learn.microsoft.com/azure/active-directory/conditional-access/concept-continuous-access-evaluation).\n *\n * Call the `bearerTokenAuthenticationPolicy` with the following options:\n *\n * ```ts snippet:AuthorizeRequestOnClaimChallenge\n * import { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\n * import { authorizeRequestOnClaimChallenge } from \"@azure/core-client\";\n *\n * const policy = bearerTokenAuthenticationPolicy({\n * challengeCallbacks: {\n * authorizeRequestOnChallenge: authorizeRequestOnClaimChallenge,\n * },\n * scopes: [\"https://service/.default\"],\n * });\n * ```\n *\n * Once provided, the `bearerTokenAuthenticationPolicy` policy will internally handle Continuous Access Evaluation (CAE) challenges.\n * When it can't complete a challenge it will return the 401 (unauthorized) response from ARM.\n *\n * Example challenge with claims:\n *\n * ```\n * Bearer authorization_uri=\"https://login.windows-ppe.net/\", error=\"invalid_token\",\n * error_description=\"User session has been revoked\",\n * claims=\"eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTYwMzc0MjgwMCJ9fX0=\"\n * ```\n */\nexport async function authorizeRequestOnClaimChallenge(\n onChallengeOptions: AuthorizeRequestOnChallengeOptions,\n): Promise<boolean> {\n const { scopes, response } = onChallengeOptions;\n const logger = onChallengeOptions.logger || coreClientLogger;\n\n const challenge = response.headers.get(\"WWW-Authenticate\");\n if (!challenge) {\n logger.info(\n `The WWW-Authenticate header was missing. Failed to perform the Continuous Access Evaluation authentication flow.`,\n );\n return false;\n }\n const challenges: CAEChallenge[] = parseCAEChallenge(challenge) || [];\n\n const parsedChallenge = challenges.find((x) => x.claims);\n if (!parsedChallenge) {\n logger.info(\n `The WWW-Authenticate header was missing the necessary \"claims\" to perform the Continuous Access Evaluation authentication flow.`,\n );\n return false;\n }\n\n const accessToken = await onChallengeOptions.getAccessToken(\n parsedChallenge.scope ? [parsedChallenge.scope] : scopes,\n {\n claims: decodeStringToString(parsedChallenge.claims),\n },\n );\n\n if (!accessToken) {\n return false;\n }\n\n onChallengeOptions.request.headers.set(\n \"Authorization\",\n `${accessToken.tokenType ?? \"Bearer\"} ${accessToken.token}`,\n );\n return true;\n}\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,UAAU,wBAAwB;AAC3C,SAAS,4BAA4B;AAQ9B,SAAS,kBAAkB,YAA2B;AAC3D,QAAM,mBAAmB,KAAK,WAAW,KAAK,CAAC,GAAG,MAAM,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC;AACpF,SAAO,iBAAiB,IAAI,CAAC,cAAc;AACzC,UAAM,iBAAiB,GAAG,UAAU,KAAK,CAAC,KAAK,MAAM,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;AAC3E,UAAM,gBAAgB,eAAe;AAAA,MAAI,CAAC,cACvC,CAAC,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC,GAAG,GAAG,MAAM,IAAI,SAAS,KAAK,EAAE,MAAM,IAAI,CAAC;AAAA,IACpE;AAEA,WAAO,cAAc,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC;AAAA,EAC5D,CAAC;AACH;AAuCA,eAAsB,iCACpB,oBACkB;AAClB,QAAM,EAAE,QAAQ,SAAS,IAAI;AAC7B,QAAM,SAAS,mBAAmB,UAAU;AAE5C,QAAM,YAAY,SAAS,QAAQ,IAAI,kBAAkB;AACzD,MAAI,CAAC,WAAW;AACd,WAAO;AAAA,MACL;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACA,QAAM,aAA6B,kBAAkB,SAAS,KAAK,CAAC;AAEpE,QAAM,kBAAkB,WAAW,KAAK,CAAC,MAAM,EAAE,MAAM;AACvD,MAAI,CAAC,iBAAiB;AACpB,WAAO;AAAA,MACL;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,QAAM,cAAc,MAAM,mBAAmB;AAAA,IAC3C,gBAAgB,QAAQ,CAAC,gBAAgB,KAAK,IAAI;AAAA,IAClD;AAAA,MACE,QAAQ,qBAAqB,gBAAgB,MAAM;AAAA,IACrD;AAAA,EACF;AAEA,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AAEA,qBAAmB,QAAQ,QAAQ;AAAA,IACjC;AAAA,IACA,GAAG,YAAY,aAAa,QAAQ,IAAI,YAAY,KAAK;AAAA,EAC3D;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,116 +1,90 @@
|
|
|
1
|
-
// Copyright (c) Microsoft Corporation.
|
|
2
|
-
// Licensed under the MIT License.
|
|
3
|
-
/**
|
|
4
|
-
* A set of constants used internally when processing requests.
|
|
5
|
-
*/
|
|
6
1
|
const Constants = {
|
|
7
|
-
|
|
2
|
+
DefaultScope: "/.default",
|
|
3
|
+
/**
|
|
4
|
+
* Defines constants for use with HTTP headers.
|
|
5
|
+
*/
|
|
6
|
+
HeaderConstants: {
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
8
|
+
* The Authorization header.
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* The Authorization header.
|
|
14
|
-
*/
|
|
15
|
-
AUTHORIZATION: "authorization",
|
|
16
|
-
},
|
|
10
|
+
AUTHORIZATION: "authorization"
|
|
11
|
+
}
|
|
17
12
|
};
|
|
18
13
|
function isUuid(text) {
|
|
19
|
-
|
|
14
|
+
return /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/.test(
|
|
15
|
+
text
|
|
16
|
+
);
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
...requestOptions,
|
|
38
|
-
tenantId,
|
|
39
|
-
});
|
|
40
|
-
if (!accessToken) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
challengeOptions.request.headers.set(Constants.HeaderConstants.AUTHORIZATION, `${accessToken.tokenType ?? "Bearer"} ${accessToken.token}`);
|
|
44
|
-
return true;
|
|
18
|
+
const authorizeRequestOnTenantChallenge = async (challengeOptions) => {
|
|
19
|
+
const requestOptions = requestToOptions(challengeOptions.request);
|
|
20
|
+
const challenge = getChallenge(challengeOptions.response);
|
|
21
|
+
if (challenge) {
|
|
22
|
+
const challengeInfo = parseChallenge(challenge);
|
|
23
|
+
const challengeScopes = buildScopes(challengeOptions, challengeInfo);
|
|
24
|
+
const tenantId = extractTenantId(challengeInfo);
|
|
25
|
+
if (!tenantId) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const accessToken = await challengeOptions.getAccessToken(challengeScopes, {
|
|
29
|
+
...requestOptions,
|
|
30
|
+
tenantId
|
|
31
|
+
});
|
|
32
|
+
if (!accessToken) {
|
|
33
|
+
return false;
|
|
45
34
|
}
|
|
46
|
-
|
|
35
|
+
challengeOptions.request.headers.set(
|
|
36
|
+
Constants.HeaderConstants.AUTHORIZATION,
|
|
37
|
+
`${accessToken.tokenType ?? "Bearer"} ${accessToken.token}`
|
|
38
|
+
);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
47
42
|
};
|
|
48
|
-
/**
|
|
49
|
-
* Extracts the tenant id from the challenge information
|
|
50
|
-
* The tenant id is contained in the authorization_uri as the first
|
|
51
|
-
* path part.
|
|
52
|
-
*/
|
|
53
43
|
function extractTenantId(challengeInfo) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
44
|
+
const parsedAuthUri = new URL(challengeInfo.authorization_uri);
|
|
45
|
+
const pathSegments = parsedAuthUri.pathname.split("/");
|
|
46
|
+
const tenantId = pathSegments[1];
|
|
47
|
+
if (tenantId && isUuid(tenantId)) {
|
|
48
|
+
return tenantId;
|
|
49
|
+
}
|
|
50
|
+
return void 0;
|
|
61
51
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Builds the authentication scopes based on the information that comes in the
|
|
64
|
-
* challenge information. Scopes url is present in the resource_id, if it is empty
|
|
65
|
-
* we keep using the original scopes.
|
|
66
|
-
*/
|
|
67
52
|
function buildScopes(challengeOptions, challengeInfo) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return [scope];
|
|
53
|
+
if (!challengeInfo.resource_id) {
|
|
54
|
+
return challengeOptions.scopes;
|
|
55
|
+
}
|
|
56
|
+
const challengeScopes = new URL(challengeInfo.resource_id);
|
|
57
|
+
challengeScopes.pathname = Constants.DefaultScope;
|
|
58
|
+
let scope = challengeScopes.toString();
|
|
59
|
+
if (scope === "https://disk.azure.com/.default") {
|
|
60
|
+
scope = "https://disk.azure.com//.default";
|
|
61
|
+
}
|
|
62
|
+
return [scope];
|
|
79
63
|
}
|
|
80
|
-
/**
|
|
81
|
-
* We will retrieve the challenge only if the response status code was 401,
|
|
82
|
-
* and if the response contained the header "WWW-Authenticate" with a non-empty value.
|
|
83
|
-
*/
|
|
84
64
|
function getChallenge(response) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
65
|
+
const challenge = response.headers.get("WWW-Authenticate");
|
|
66
|
+
if (response.status === 401 && challenge) {
|
|
67
|
+
return challenge;
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
90
70
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Converts: `Bearer a="b" c="d"`.
|
|
93
|
-
* Into: `[ { a: 'b', c: 'd' }]`.
|
|
94
|
-
*
|
|
95
|
-
* @internal
|
|
96
|
-
*/
|
|
97
71
|
function parseChallenge(challenge) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
72
|
+
const bearerChallenge = challenge.slice("Bearer ".length);
|
|
73
|
+
const challengeParts = `${bearerChallenge.trim()} `.split(" ").filter((x) => x);
|
|
74
|
+
const keyValuePairs = challengeParts.map(
|
|
75
|
+
(keyValue) => (([key, value]) => ({ [key]: value }))(keyValue.trim().split("="))
|
|
76
|
+
);
|
|
77
|
+
return keyValuePairs.reduce((a, b) => ({ ...a, ...b }), {});
|
|
103
78
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Extracts the options form a Pipeline Request for later re-use
|
|
106
|
-
*/
|
|
107
79
|
function requestToOptions(request) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
80
|
+
return {
|
|
81
|
+
abortSignal: request.abortSignal,
|
|
82
|
+
requestOptions: {
|
|
83
|
+
timeout: request.timeout
|
|
84
|
+
},
|
|
85
|
+
tracingOptions: request.tracingOptions
|
|
86
|
+
};
|
|
115
87
|
}
|
|
116
|
-
|
|
88
|
+
export {
|
|
89
|
+
authorizeRequestOnTenantChallenge
|
|
90
|
+
};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/core-client/src/authorizeRequestOnTenantChallenge.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n AuthorizeRequestOnChallengeOptions,\n PipelineRequest,\n PipelineResponse,\n} from \"@azure/core-rest-pipeline\";\n\nimport type { GetTokenOptions } from \"@azure/core-auth\";\n\n/**\n * A set of constants used internally when processing requests.\n */\nconst Constants = {\n DefaultScope: \"/.default\",\n /**\n * Defines constants for use with HTTP headers.\n */\n HeaderConstants: {\n /**\n * The Authorization header.\n */\n AUTHORIZATION: \"authorization\",\n },\n};\n\nfunction isUuid(text: string): boolean {\n return /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/.test(\n text,\n );\n}\n\n/**\n * Defines a callback to handle auth challenge for Storage APIs.\n * This implements the bearer challenge process described here: https://learn.microsoft.com/rest/api/storageservices/authorize-with-azure-active-directory#bearer-challenge\n * Handling has specific features for storage that departs to the general AAD challenge docs.\n **/\nexport const authorizeRequestOnTenantChallenge: (\n challengeOptions: AuthorizeRequestOnChallengeOptions,\n) => Promise<boolean> = async (challengeOptions) => {\n const requestOptions = requestToOptions(challengeOptions.request);\n const challenge = getChallenge(challengeOptions.response);\n if (challenge) {\n const challengeInfo: Challenge = parseChallenge(challenge);\n const challengeScopes = buildScopes(challengeOptions, challengeInfo);\n const tenantId = extractTenantId(challengeInfo);\n if (!tenantId) {\n return false;\n }\n const accessToken = await challengeOptions.getAccessToken(challengeScopes, {\n ...requestOptions,\n tenantId,\n });\n\n if (!accessToken) {\n return false;\n }\n\n challengeOptions.request.headers.set(\n Constants.HeaderConstants.AUTHORIZATION,\n `${accessToken.tokenType ?? \"Bearer\"} ${accessToken.token}`,\n );\n return true;\n }\n return false;\n};\n\n/**\n * Extracts the tenant id from the challenge information\n * The tenant id is contained in the authorization_uri as the first\n * path part.\n */\nfunction extractTenantId(challengeInfo: Challenge): string | undefined {\n const parsedAuthUri = new URL(challengeInfo.authorization_uri);\n const pathSegments = parsedAuthUri.pathname.split(\"/\");\n const tenantId = pathSegments[1];\n if (tenantId && isUuid(tenantId)) {\n return tenantId;\n }\n return undefined;\n}\n\n/**\n * Builds the authentication scopes based on the information that comes in the\n * challenge information. Scopes url is present in the resource_id, if it is empty\n * we keep using the original scopes.\n */\nfunction buildScopes(\n challengeOptions: AuthorizeRequestOnChallengeOptions,\n challengeInfo: Challenge,\n): string[] {\n if (!challengeInfo.resource_id) {\n return challengeOptions.scopes;\n }\n\n const challengeScopes = new URL(challengeInfo.resource_id);\n challengeScopes.pathname = Constants.DefaultScope;\n let scope = challengeScopes.toString();\n if (scope === \"https://disk.azure.com/.default\") {\n // the extra slash is required by the service\n scope = \"https://disk.azure.com//.default\";\n }\n return [scope];\n}\n\n/**\n * We will retrieve the challenge only if the response status code was 401,\n * and if the response contained the header \"WWW-Authenticate\" with a non-empty value.\n */\nfunction getChallenge(response: PipelineResponse): string | undefined {\n const challenge = response.headers.get(\"WWW-Authenticate\");\n if (response.status === 401 && challenge) {\n return challenge;\n }\n return;\n}\n\n/**\n * Challenge structure\n */\ninterface Challenge {\n authorization_uri: string;\n resource_id?: string;\n}\n\n/**\n * Converts: `Bearer a=\"b\" c=\"d\"`.\n * Into: `[ { a: 'b', c: 'd' }]`.\n *\n * @internal\n */\nfunction parseChallenge(challenge: string): Challenge {\n const bearerChallenge = challenge.slice(\"Bearer \".length);\n const challengeParts = `${bearerChallenge.trim()} `.split(\" \").filter((x) => x);\n const keyValuePairs = challengeParts.map((keyValue) =>\n (([key, value]) => ({ [key]: value }))(keyValue.trim().split(\"=\")),\n );\n // Key-value pairs to plain object:\n return keyValuePairs.reduce((a, b) => ({ ...a, ...b }), {} as Challenge);\n}\n\n/**\n * Extracts the options form a Pipeline Request for later re-use\n */\nfunction requestToOptions(request: PipelineRequest): GetTokenOptions {\n return {\n abortSignal: request.abortSignal,\n requestOptions: {\n timeout: request.timeout,\n },\n tracingOptions: request.tracingOptions,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAcA,MAAM,YAAY;AAAA,EAChB,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,iBAAiB;AAAA;AAAA;AAAA;AAAA,IAIf,eAAe;AAAA,EACjB;AACF;AAEA,SAAS,OAAO,MAAuB;AACrC,SAAO,wFAAwF;AAAA,IAC7F;AAAA,EACF;AACF;AAOO,MAAM,oCAEW,OAAO,qBAAqB;AAClD,QAAM,iBAAiB,iBAAiB,iBAAiB,OAAO;AAChE,QAAM,YAAY,aAAa,iBAAiB,QAAQ;AACxD,MAAI,WAAW;AACb,UAAM,gBAA2B,eAAe,SAAS;AACzD,UAAM,kBAAkB,YAAY,kBAAkB,aAAa;AACnE,UAAM,WAAW,gBAAgB,aAAa;AAC9C,QAAI,CAAC,UAAU;AACb,aAAO;AAAA,IACT;AACA,UAAM,cAAc,MAAM,iBAAiB,eAAe,iBAAiB;AAAA,MACzE,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAED,QAAI,CAAC,aAAa;AAChB,aAAO;AAAA,IACT;AAEA,qBAAiB,QAAQ,QAAQ;AAAA,MAC/B,UAAU,gBAAgB;AAAA,MAC1B,GAAG,YAAY,aAAa,QAAQ,IAAI,YAAY,KAAK;AAAA,IAC3D;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOA,SAAS,gBAAgB,eAA8C;AACrE,QAAM,gBAAgB,IAAI,IAAI,cAAc,iBAAiB;AAC7D,QAAM,eAAe,cAAc,SAAS,MAAM,GAAG;AACrD,QAAM,WAAW,aAAa,CAAC;AAC/B,MAAI,YAAY,OAAO,QAAQ,GAAG;AAChC,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAOA,SAAS,YACP,kBACA,eACU;AACV,MAAI,CAAC,cAAc,aAAa;AAC9B,WAAO,iBAAiB;AAAA,EAC1B;AAEA,QAAM,kBAAkB,IAAI,IAAI,cAAc,WAAW;AACzD,kBAAgB,WAAW,UAAU;AACrC,MAAI,QAAQ,gBAAgB,SAAS;AACrC,MAAI,UAAU,mCAAmC;AAE/C,YAAQ;AAAA,EACV;AACA,SAAO,CAAC,KAAK;AACf;AAMA,SAAS,aAAa,UAAgD;AACpE,QAAM,YAAY,SAAS,QAAQ,IAAI,kBAAkB;AACzD,MAAI,SAAS,WAAW,OAAO,WAAW;AACxC,WAAO;AAAA,EACT;AACA;AACF;AAgBA,SAAS,eAAe,WAA8B;AACpD,QAAM,kBAAkB,UAAU,MAAM,UAAU,MAAM;AACxD,QAAM,iBAAiB,GAAG,gBAAgB,KAAK,CAAC,IAAI,MAAM,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC;AAC9E,QAAM,gBAAgB,eAAe;AAAA,IAAI,CAAC,cACvC,CAAC,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC,GAAG,GAAG,MAAM,IAAI,SAAS,KAAK,EAAE,MAAM,GAAG,CAAC;AAAA,EACnE;AAEA,SAAO,cAAc,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,CAAC,CAAc;AACzE;AAKA,SAAS,iBAAiB,SAA2C;AACnE,SAAO;AAAA,IACL,aAAa,QAAQ;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS,QAAQ;AAAA,IACnB;AAAA,IACA,gBAAgB,QAAQ;AAAA,EAC1B;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/base64.js
CHANGED
|
@@ -1,36 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Encodes a string in base64 format.
|
|
5
|
-
* @param value - the string to encode
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export function encodeString(value) {
|
|
9
|
-
return Buffer.from(value).toString("base64");
|
|
1
|
+
function encodeString(value) {
|
|
2
|
+
return Buffer.from(value).toString("base64");
|
|
10
3
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export function encodeByteArray(value) {
|
|
17
|
-
const bufferValue = value instanceof Buffer ? value : Buffer.from(value.buffer);
|
|
18
|
-
return bufferValue.toString("base64");
|
|
4
|
+
function encodeByteArray(value) {
|
|
5
|
+
const bufferValue = value instanceof Buffer ? value : Buffer.from(value.buffer);
|
|
6
|
+
return bufferValue.toString("base64");
|
|
19
7
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param value - the base64 string to decode
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
export function decodeString(value) {
|
|
26
|
-
return Buffer.from(value, "base64");
|
|
8
|
+
function decodeString(value) {
|
|
9
|
+
return Buffer.from(value, "base64");
|
|
27
10
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* @param value - the base64 string to decode
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
export function decodeStringToString(value) {
|
|
34
|
-
return Buffer.from(value, "base64").toString();
|
|
11
|
+
function decodeStringToString(value) {
|
|
12
|
+
return Buffer.from(value, "base64").toString();
|
|
35
13
|
}
|
|
36
|
-
|
|
14
|
+
export {
|
|
15
|
+
decodeString,
|
|
16
|
+
decodeStringToString,
|
|
17
|
+
encodeByteArray,
|
|
18
|
+
encodeString
|
|
19
|
+
};
|
package/dist/esm/base64.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/core-client/src/base64.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Encodes a string in base64 format.\n * @param value - the string to encode\n * @internal\n */\nexport function encodeString(value: string): string {\n return Buffer.from(value).toString(\"base64\");\n}\n\n/**\n * Encodes a byte array in base64 format.\n * @param value - the Uint8Aray to encode\n * @internal\n */\nexport function encodeByteArray(value: Uint8Array): string {\n const bufferValue = value instanceof Buffer ? value : Buffer.from(value.buffer as ArrayBuffer);\n return bufferValue.toString(\"base64\");\n}\n\n/**\n * Decodes a base64 string into a byte array.\n * @param value - the base64 string to decode\n * @internal\n */\nexport function decodeString(value: string): Uint8Array {\n return Buffer.from(value, \"base64\");\n}\n\n/**\n * Decodes a base64 string into a string.\n * @param value - the base64 string to decode\n * @internal\n */\nexport function decodeStringToString(value: string): string {\n return Buffer.from(value, \"base64\").toString();\n}\n"],
|
|
5
|
+
"mappings": "AAQO,SAAS,aAAa,OAAuB;AAClD,SAAO,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ;AAC7C;AAOO,SAAS,gBAAgB,OAA2B;AACzD,QAAM,cAAc,iBAAiB,SAAS,QAAQ,OAAO,KAAK,MAAM,MAAqB;AAC7F,SAAO,YAAY,SAAS,QAAQ;AACtC;AAOO,SAAS,aAAa,OAA2B;AACtD,SAAO,OAAO,KAAK,OAAO,QAAQ;AACpC;AAOO,SAAS,qBAAqB,OAAuB;AAC1D,SAAO,OAAO,KAAK,OAAO,QAAQ,EAAE,SAAS;AAC/C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|