@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.
Files changed (54) hide show
  1. package/dist/browser/base64.d.ts +1 -1
  2. package/dist/browser/base64.js +1 -1
  3. package/dist/browser/base64.js.map +1 -0
  4. package/dist/browser/index.d.ts +5 -5
  5. package/dist/browser/index.js.map +1 -1
  6. package/dist/browser/state.d.ts +1 -1
  7. package/dist/browser/state.js +1 -1
  8. package/dist/browser/state.js.map +1 -0
  9. package/dist/commonjs/index.d.ts +5 -5
  10. package/dist/commonjs/index.js.map +1 -1
  11. package/dist/commonjs/state.d.ts +3 -2
  12. package/dist/commonjs/state.js +1 -1
  13. package/dist/commonjs/state.js.map +1 -0
  14. package/dist/esm/authorizeRequestOnClaimChallenge.js +44 -67
  15. package/dist/esm/authorizeRequestOnClaimChallenge.js.map +7 -1
  16. package/dist/esm/authorizeRequestOnTenantChallenge.js +72 -98
  17. package/dist/esm/authorizeRequestOnTenantChallenge.js.map +7 -1
  18. package/dist/esm/base64.js +15 -32
  19. package/dist/esm/base64.js.map +7 -1
  20. package/dist/esm/deserializationPolicy.js +205 -202
  21. package/dist/esm/deserializationPolicy.js.map +7 -1
  22. package/dist/esm/httpClientCache.js +8 -8
  23. package/dist/esm/httpClientCache.js.map +7 -1
  24. package/dist/esm/index.d.ts +5 -5
  25. package/dist/esm/index.js +31 -11
  26. package/dist/esm/index.js.map +7 -1
  27. package/dist/esm/interfaceHelpers.js +23 -35
  28. package/dist/esm/interfaceHelpers.js.map +7 -1
  29. package/dist/esm/interfaces.js +6 -11
  30. package/dist/esm/interfaces.js.map +7 -1
  31. package/dist/esm/log.js +4 -4
  32. package/dist/esm/log.js.map +7 -1
  33. package/dist/esm/operationHelpers.js +73 -82
  34. package/dist/esm/operationHelpers.js.map +7 -1
  35. package/dist/esm/pipeline.js +22 -23
  36. package/dist/esm/pipeline.js.map +7 -1
  37. package/dist/esm/serializationPolicy.js +163 -134
  38. package/dist/esm/serializationPolicy.js.map +7 -1
  39. package/dist/esm/serializer.js +812 -856
  40. package/dist/esm/serializer.js.map +7 -1
  41. package/dist/esm/serviceClient.js +151 -150
  42. package/dist/esm/serviceClient.js.map +7 -1
  43. package/dist/esm/state.js +4 -9
  44. package/dist/esm/state.js.map +7 -1
  45. package/dist/esm/urlHelpers.js +199 -206
  46. package/dist/esm/urlHelpers.js.map +7 -1
  47. package/dist/esm/utils.js +64 -118
  48. package/dist/esm/utils.js.map +7 -1
  49. package/dist/react-native/index.d.ts +5 -5
  50. package/dist/react-native/index.js.map +1 -1
  51. package/package.json +2 -19
  52. package/dist/browser/base64-browser.mjs.map +0 -1
  53. package/dist/browser/state-browser.mjs.map +0 -1
  54. package/dist/commonjs/state-cjs.cjs.map +0 -1
@@ -26,4 +26,4 @@ export declare function decodeString(value: string): Uint8Array;
26
26
  * @internal
27
27
  */
28
28
  export declare function decodeStringToString(value: string): string;
29
- //# sourceMappingURL=base64-browser.d.mts.map
29
+ //# sourceMappingURL=base64.d.ts.map
@@ -41,4 +41,4 @@ export function decodeString(value) {
41
41
  export function decodeStringToString(value) {
42
42
  return atob(value);
43
43
  }
44
- //# sourceMappingURL=base64-browser.mjs.map
44
+ //# sourceMappingURL=base64.js.map
@@ -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"]}
@@ -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,EAAwB,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAiC,MAAM,eAAe,CAAC;AACpF,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, ServiceClientOptions } from \"./serviceClient.js\";\nexport { createClientPipeline, InternalClientPipelineOptions } from \"./pipeline.js\";\nexport {\n OperationSpec,\n OperationArguments,\n OperationOptions,\n OperationResponseMap,\n OperationParameter,\n OperationQueryParameter,\n OperationURLParameter,\n Serializer,\n BaseMapper,\n Mapper,\n MapperType,\n SimpleMapperType,\n EnumMapper,\n EnumMapperType,\n SequenceMapper,\n SequenceMapperType,\n DictionaryMapper,\n DictionaryMapperType,\n CompositeMapper,\n CompositeMapperType,\n MapperConstraints,\n OperationRequest,\n OperationRequestOptions,\n OperationRequestInfo,\n QueryCollectionFormat,\n ParameterPath,\n FullOperationResponse,\n PolymorphicDiscriminator,\n SpanConfig,\n XML_ATTRKEY,\n XML_CHARKEY,\n XmlOptions,\n SerializerOptions,\n RawResponseCallback,\n CommonClientOptions,\n AdditionalPolicyConfig,\n} from \"./interfaces.js\";\nexport {\n deserializationPolicy,\n deserializationPolicyName,\n DeserializationPolicyOptions,\n DeserializationContentTypes,\n} from \"./deserializationPolicy.js\";\nexport {\n serializationPolicy,\n serializationPolicyName,\n SerializationPolicyOptions,\n} from \"./serializationPolicy.js\";\nexport { authorizeRequestOnClaimChallenge } from \"./authorizeRequestOnClaimChallenge.js\";\nexport { authorizeRequestOnTenantChallenge } from \"./authorizeRequestOnTenantChallenge.js\";\n"]}
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"]}
@@ -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-browser.d.mts.map
8
+ //# sourceMappingURL=state.d.ts.map
@@ -6,4 +6,4 @@
6
6
  export const state = {
7
7
  operationRequestMap: new WeakMap(),
8
8
  };
9
- //# sourceMappingURL=state-browser.mjs.map
9
+ //# sourceMappingURL=state.js.map
@@ -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"]}
@@ -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,uDAAyE;AAAhE,iHAAA,aAAa,OAAA;AACtB,6CAAoF;AAA3E,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, ServiceClientOptions } from \"./serviceClient.js\";\nexport { createClientPipeline, InternalClientPipelineOptions } from \"./pipeline.js\";\nexport {\n OperationSpec,\n OperationArguments,\n OperationOptions,\n OperationResponseMap,\n OperationParameter,\n OperationQueryParameter,\n OperationURLParameter,\n Serializer,\n BaseMapper,\n Mapper,\n MapperType,\n SimpleMapperType,\n EnumMapper,\n EnumMapperType,\n SequenceMapper,\n SequenceMapperType,\n DictionaryMapper,\n DictionaryMapperType,\n CompositeMapper,\n CompositeMapperType,\n MapperConstraints,\n OperationRequest,\n OperationRequestOptions,\n OperationRequestInfo,\n QueryCollectionFormat,\n ParameterPath,\n FullOperationResponse,\n PolymorphicDiscriminator,\n SpanConfig,\n XML_ATTRKEY,\n XML_CHARKEY,\n XmlOptions,\n SerializerOptions,\n RawResponseCallback,\n CommonClientOptions,\n AdditionalPolicyConfig,\n} from \"./interfaces.js\";\nexport {\n deserializationPolicy,\n deserializationPolicyName,\n DeserializationPolicyOptions,\n DeserializationContentTypes,\n} from \"./deserializationPolicy.js\";\nexport {\n serializationPolicy,\n serializationPolicyName,\n SerializationPolicyOptions,\n} from \"./serializationPolicy.js\";\nexport { authorizeRequestOnClaimChallenge } from \"./authorizeRequestOnClaimChallenge.js\";\nexport { authorizeRequestOnTenantChallenge } from \"./authorizeRequestOnTenantChallenge.js\";\n"]}
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"]}
@@ -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<WeakKey, any>;
6
+ operationRequestMap: WeakMap<import("@azure/core-rest-pipeline").PipelineRequest, OperationRequestInfo>;
6
7
  };
7
- //# sourceMappingURL=state-cjs.d.cts.map
8
+ //# sourceMappingURL=state.d.ts.map
@@ -9,4 +9,4 @@ exports.state = void 0;
9
9
  exports.state = {
10
10
  operationRequestMap: new WeakMap(),
11
11
  };
12
- //# sourceMappingURL=state-cjs.cjs.map
12
+ //# sourceMappingURL=state.js.map
@@ -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
- * Converts: `Bearer a="b", c="d", Bearer d="e", f="g"`.
7
- * Into: `[ { a: 'b', c: 'd' }, { d: 'e', f: 'g' } ]`.
8
- *
9
- * @internal
10
- */
11
- export function parseCAEChallenge(challenges) {
12
- const bearerChallenges = `, ${challenges.trim()}`.split(", Bearer ").filter((x) => x);
13
- return bearerChallenges.map((challenge) => {
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
- * This function can be used as a callback for the `bearerTokenAuthenticationPolicy` of `@azure/core-rest-pipeline`, to support CAE challenges:
22
- * [Continuous Access Evaluation](https://learn.microsoft.com/azure/active-directory/conditional-access/concept-continuous-access-evaluation).
23
- *
24
- * Call the `bearerTokenAuthenticationPolicy` with the following options:
25
- *
26
- * ```ts snippet:AuthorizeRequestOnClaimChallenge
27
- * import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline";
28
- * import { authorizeRequestOnClaimChallenge } from "@azure/core-client";
29
- *
30
- * const policy = bearerTokenAuthenticationPolicy({
31
- * challengeCallbacks: {
32
- * authorizeRequestOnChallenge: authorizeRequestOnClaimChallenge,
33
- * },
34
- * scopes: ["https://service/.default"],
35
- * });
36
- * ```
37
- *
38
- * Once provided, the `bearerTokenAuthenticationPolicy` policy will internally handle Continuous Access Evaluation (CAE) challenges.
39
- * When it can't complete a challenge it will return the 401 (unauthorized) response from ARM.
40
- *
41
- * Example challenge with claims:
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
- const challenges = parseCAEChallenge(challenge) || [];
58
- const parsedChallenge = challenges.find((x) => x.claims);
59
- if (!parsedChallenge) {
60
- logger.info(`The WWW-Authenticate header was missing the necessary "claims" to perform the Continuous Access Evaluation authentication flow.`);
61
- return false;
62
- }
63
- const accessToken = await onChallengeOptions.getAccessToken(parsedChallenge.scope ? [parsedChallenge.scope] : scopes, {
64
- claims: decodeStringToString(parsedChallenge.claims),
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
- //# sourceMappingURL=authorizeRequestOnClaimChallenge.js.map
46
+ export {
47
+ authorizeRequestOnClaimChallenge,
48
+ parseCAEChallenge
49
+ };
@@ -1 +1,7 @@
1
- {"version":3,"file":"authorizeRequestOnClaimChallenge.js","sourceRoot":"","sources":["../../src/authorizeRequestOnClaimChallenge.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,MAAM,gBAAgB,GAAG,KAAK,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACtF,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QACxC,MAAM,cAAc,GAAG,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7E,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACpD,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CACpE,CAAC;QACF,mCAAmC;QACnC,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC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C,KAAK,EAAE,CAC5D,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC","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"]}
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
- DefaultScope: "/.default",
2
+ DefaultScope: "/.default",
3
+ /**
4
+ * Defines constants for use with HTTP headers.
5
+ */
6
+ HeaderConstants: {
8
7
  /**
9
- * Defines constants for use with HTTP headers.
8
+ * The Authorization header.
10
9
  */
11
- HeaderConstants: {
12
- /**
13
- * The Authorization header.
14
- */
15
- AUTHORIZATION: "authorization",
16
- },
10
+ AUTHORIZATION: "authorization"
11
+ }
17
12
  };
18
13
  function isUuid(text) {
19
- 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(text);
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
- * Defines a callback to handle auth challenge for Storage APIs.
23
- * This implements the bearer challenge process described here: https://learn.microsoft.com/rest/api/storageservices/authorize-with-azure-active-directory#bearer-challenge
24
- * Handling has specific features for storage that departs to the general AAD challenge docs.
25
- **/
26
- export const authorizeRequestOnTenantChallenge = async (challengeOptions) => {
27
- const requestOptions = requestToOptions(challengeOptions.request);
28
- const challenge = getChallenge(challengeOptions.response);
29
- if (challenge) {
30
- const challengeInfo = parseChallenge(challenge);
31
- const challengeScopes = buildScopes(challengeOptions, challengeInfo);
32
- const tenantId = extractTenantId(challengeInfo);
33
- if (!tenantId) {
34
- return false;
35
- }
36
- const accessToken = await challengeOptions.getAccessToken(challengeScopes, {
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
- return false;
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
- const parsedAuthUri = new URL(challengeInfo.authorization_uri);
55
- const pathSegments = parsedAuthUri.pathname.split("/");
56
- const tenantId = pathSegments[1];
57
- if (tenantId && isUuid(tenantId)) {
58
- return tenantId;
59
- }
60
- return undefined;
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
- if (!challengeInfo.resource_id) {
69
- return challengeOptions.scopes;
70
- }
71
- const challengeScopes = new URL(challengeInfo.resource_id);
72
- challengeScopes.pathname = Constants.DefaultScope;
73
- let scope = challengeScopes.toString();
74
- if (scope === "https://disk.azure.com/.default") {
75
- // the extra slash is required by the service
76
- scope = "https://disk.azure.com//.default";
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
- const challenge = response.headers.get("WWW-Authenticate");
86
- if (response.status === 401 && challenge) {
87
- return challenge;
88
- }
89
- return;
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
- const bearerChallenge = challenge.slice("Bearer ".length);
99
- const challengeParts = `${bearerChallenge.trim()} `.split(" ").filter((x) => x);
100
- const keyValuePairs = challengeParts.map((keyValue) => (([key, value]) => ({ [key]: value }))(keyValue.trim().split("=")));
101
- // Key-value pairs to plain object:
102
- return keyValuePairs.reduce((a, b) => ({ ...a, ...b }), {});
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
- return {
109
- abortSignal: request.abortSignal,
110
- requestOptions: {
111
- timeout: request.timeout,
112
- },
113
- tracingOptions: request.tracingOptions,
114
- };
80
+ return {
81
+ abortSignal: request.abortSignal,
82
+ requestOptions: {
83
+ timeout: request.timeout
84
+ },
85
+ tracingOptions: request.tracingOptions
86
+ };
115
87
  }
116
- //# sourceMappingURL=authorizeRequestOnTenantChallenge.js.map
88
+ export {
89
+ authorizeRequestOnTenantChallenge
90
+ };
@@ -1 +1,7 @@
1
- {"version":3,"file":"authorizeRequestOnTenantChallenge.js","sourceRoot":"","sources":["../../src/authorizeRequestOnTenantChallenge.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC;;GAEG;AACH,MAAM,SAAS,GAAG;IAChB,YAAY,EAAE,WAAW;IACzB;;OAEG;IACH,eAAe,EAAE;QACf;;WAE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C,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAChF,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACpD,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CACnE,CAAC;IACF,mCAAmC;IACnC,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,EAAe,CAAC,CAAC;AAC3E,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CAAC,OAAwB;IAChD,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,cAAc,EAAE;YACd,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB;QACD,cAAc,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC;AACJ,CAAC","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"]}
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;AAC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vC,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
+ }
@@ -1,36 +1,19 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
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
- * Encodes a byte array in base64 format.
13
- * @param value - the Uint8Aray to encode
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
- * Decodes a base64 string into a byte array.
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
- * Decodes a base64 string into a string.
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
- //# sourceMappingURL=base64.js.map
14
+ export {
15
+ decodeString,
16
+ decodeStringToString,
17
+ encodeByteArray,
18
+ encodeString
19
+ };
@@ -1 +1,7 @@
1
- {"version":3,"file":"base64.js","sourceRoot":"","sources":["../../src/base64.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAiB;IAC/C,MAAM,WAAW,GAAG,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAqB,CAAC,CAAC;IAC/F,OAAO,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;AACjD,CAAC","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"]}
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
+ }