@azure/data-tables 13.2.3-alpha.20240122.2 → 13.2.3-alpha.20240131.1
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/index.js +30 -30
- package/dist/index.js.map +1 -1
- package/dist-esm/src/TableClient.js.map +1 -1
- package/dist-esm/src/TablePolicies.js +2 -2
- package/dist-esm/src/TablePolicies.js.map +1 -1
- package/dist-esm/src/TableServiceClient.js.map +1 -1
- package/dist-esm/src/TableTransaction.js.map +1 -1
- package/dist-esm/src/cosmosPathPolicy.js.map +1 -1
- package/dist-esm/src/generated/generatedClient.js.map +1 -1
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
- package/dist-esm/src/odata.js.map +1 -1
- package/dist-esm/src/sas/accountSasPermissions.js.map +1 -1
- package/dist-esm/src/sas/accountSasResourceTypes.js.map +1 -1
- package/dist-esm/src/sas/accountSasServices.js.map +1 -1
- package/dist-esm/src/sas/generateAccountSas.js.map +1 -1
- package/dist-esm/src/sas/generateTableSas.js.map +1 -1
- package/dist-esm/src/sas/sasIPRange.js.map +1 -1
- package/dist-esm/src/sas/sasQueryParameters.js +28 -28
- package/dist-esm/src/sas/sasQueryParameters.js.map +1 -1
- package/dist-esm/src/sas/tableSasPermisions.js.map +1 -1
- package/dist-esm/src/sas/tableSasSignatureValues.js.map +1 -1
- package/dist-esm/src/secondaryEndpointPolicy.js.map +1 -1
- package/dist-esm/src/serialization.js.map +1 -1
- package/dist-esm/src/tablesNamedCredentialPolicy.js.map +1 -1
- package/dist-esm/src/tablesSASTokenPolicy.js.map +1 -1
- package/dist-esm/src/utils/accountConnectionString.js.map +1 -1
- package/dist-esm/src/utils/bufferSerializer.browser.js.map +1 -1
- package/dist-esm/src/utils/bufferSerializer.js.map +1 -1
- package/dist-esm/src/utils/connectionString.js.map +1 -1
- package/dist-esm/src/utils/continuationToken.js.map +1 -1
- package/dist-esm/src/utils/errorHelpers.js.map +1 -1
- package/dist-esm/src/utils/isCosmosEndpoint.js.map +1 -1
- package/package.json +2 -2
- package/types/latest/tsdoc-metadata.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountSasResourceTypes.js","sourceRoot":"","sources":["../../../src/sas/accountSasResourceTypes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAAC,aAAqB;IACrE,MAAM,uBAAuB,GAA4B,EAAE,CAAC;IAE5D,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE;
|
|
1
|
+
{"version":3,"file":"accountSasResourceTypes.js","sourceRoot":"","sources":["../../../src/sas/accountSasResourceTypes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,iCAAiC,CAAC,aAAqB;IACrE,MAAM,uBAAuB,GAA4B,EAAE,CAAC;IAE5D,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE,CAAC;QAC9B,QAAQ,CAAC,EAAE,CAAC;YACV,KAAK,GAAG;gBACN,uBAAuB,CAAC,OAAO,GAAG,IAAI,CAAC;gBACvC,MAAM;YACR,KAAK,GAAG;gBACN,uBAAuB,CAAC,SAAS,GAAG,IAAI,CAAC;gBACzC,MAAM;YACR,KAAK,GAAG;gBACN,uBAAuB,CAAC,MAAM,GAAG,IAAI,CAAC;gBACtC,MAAM;YACR;gBACE,MAAM,IAAI,UAAU,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAC,aAAsC;IACpF,MAAM,mBAAmB,GAAa,EAAE,CAAC;IACzC,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;QAC1B,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,aAAa,CAAC,SAAS,EAAE,CAAC;QAC5B,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;QACzB,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Creates an {@link accountSasResourceTypesFromString} from the specified resource types string. This method will throw an\n * Error if it encounters a character that does not correspond to a valid resource type.\n *\n * @param resourceTypes -\n */\nexport function accountSasResourceTypesFromString(resourceTypes: string): AccountSasResourceTypes {\n const accountSasResourceTypes: AccountSasResourceTypes = {};\n\n for (const c of resourceTypes) {\n switch (c) {\n case \"s\":\n accountSasResourceTypes.service = true;\n break;\n case \"c\":\n accountSasResourceTypes.container = true;\n break;\n case \"o\":\n accountSasResourceTypes.object = true;\n break;\n default:\n throw new RangeError(`Invalid resource type: ${c}`);\n }\n }\n\n return accountSasResourceTypes;\n}\n\n/**\n * Converts the given resource types to a string.\n *\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-an-account-sas\n *\n */\nexport function accountSasResourceTypesToString(resourceTypes: AccountSasResourceTypes): string {\n const resourceTypesString: string[] = [];\n if (resourceTypes.service) {\n resourceTypesString.push(\"s\");\n }\n if (resourceTypes.container) {\n resourceTypesString.push(\"c\");\n }\n if (resourceTypes.object) {\n resourceTypesString.push(\"o\");\n }\n return resourceTypesString.join(\"\");\n}\n\n/**\n * Represents the Resources that are accessible by the SAS token\n */\nexport interface AccountSasResourceTypes {\n /**\n * Permission to access service level APIs granted.\n */\n service?: boolean;\n\n /**\n * Permission to access container level APIs (Blob Containers, Tables, Queues, File Shares) granted.\n */\n container?: boolean;\n\n /**\n * Permission to access object level APIs (Blobs, Table Entities, Queue Messages, Files) granted.\n */\n object?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountSasServices.js","sourceRoot":"","sources":["../../../src/sas/accountSasServices.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAAgB;IAC3D,MAAM,kBAAkB,GAAuB,EAAE,CAAC;IAElD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"accountSasServices.js","sourceRoot":"","sources":["../../../src/sas/accountSasServices.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,QAAgB;IAC3D,MAAM,kBAAkB,GAAuB,EAAE,CAAC;IAElD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,QAAQ,CAAC,EAAE,CAAC;YACV,KAAK,GAAG;gBACN,kBAAkB,CAAC,IAAI,GAAG,IAAI,CAAC;gBAC/B,MAAM;YACR,KAAK,GAAG;gBACN,kBAAkB,CAAC,IAAI,GAAG,IAAI,CAAC;gBAC/B,MAAM;YACR,KAAK,GAAG;gBACN,kBAAkB,CAAC,KAAK,GAAG,IAAI,CAAC;gBAChC,MAAM;YACR,KAAK,GAAG;gBACN,kBAAkB,CAAC,KAAK,GAAG,IAAI,CAAC;gBAChC,MAAM;YACR;gBACE,MAAM,IAAI,UAAU,CAAC,8BAA8B,CAAC,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,WAA+B,EAAE,KAAK,EAAE,IAAI,EAAE;IACvF,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClB,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClB,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Creates an {@link AccountSasServices} from the specified services string. This method will throw an\n * Error if it encounters a character that does not correspond to a valid service.\n *\n * @param services -\n */\nexport function accountSasServicesFromString(services: string): AccountSasServices {\n const accountSasServices: AccountSasServices = {};\n\n for (const c of services) {\n switch (c) {\n case \"b\":\n accountSasServices.blob = true;\n break;\n case \"f\":\n accountSasServices.file = true;\n break;\n case \"q\":\n accountSasServices.queue = true;\n break;\n case \"t\":\n accountSasServices.table = true;\n break;\n default:\n throw new RangeError(`Invalid service character: ${c}`);\n }\n }\n\n return accountSasServices;\n}\n\n/**\n * Converts the given services to a string.\n *\n */\nexport function accountSasServicesToString(services: AccountSasServices = { table: true }): string {\n const servicesString: string[] = [];\n if (services.blob) {\n servicesString.push(\"b\");\n }\n if (services.table) {\n servicesString.push(\"t\");\n }\n if (services.queue) {\n servicesString.push(\"q\");\n }\n if (services.file) {\n servicesString.push(\"f\");\n }\n return servicesString.join(\"\");\n}\n/**\n * Services that the SAS token can access\n */\nexport interface AccountSasServices {\n /**\n * Permission to access blob resources granted.\n */\n blob?: boolean;\n\n /**\n * Permission to access file resources granted.\n */\n file?: boolean;\n\n /**\n * Permission to access queue resources granted.\n */\n\n queue?: boolean;\n /**\n * Permission to access table resources granted.\n */\n table?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateAccountSas.js","sourceRoot":"","sources":["../../../src/sas/generateAccountSas.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAyB,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAEL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAsB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAEhF;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAA8B,EAC9B,UAA6B,EAAE;IAE/B,MAAM,EACJ,SAAS,EACT,WAAW,GAAG,+BAA+B,CAAC,IAAI,CAAC,EACnD,aAAa,GAAG,KAAK,EACrB,QAAQ,GAAG,4BAA4B,CAAC,GAAG,CAAC,KAE1C,OAAO,EADN,IAAI,UACL,OAAO,EANL,yDAML,CAAU,CAAC;IACZ,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"generateAccountSas.js","sourceRoot":"","sources":["../../../src/sas/generateAccountSas.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAyB,+BAA+B,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAEL,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAsB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAEhF;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAA8B,EAC9B,UAA6B,EAAE;IAE/B,MAAM,EACJ,SAAS,EACT,WAAW,GAAG,+BAA+B,CAAC,IAAI,CAAC,EACnD,aAAa,GAAG,KAAK,EACrB,QAAQ,GAAG,4BAA4B,CAAC,GAAG,CAAC,KAE1C,OAAO,EADN,IAAI,UACL,OAAO,EANL,yDAML,CAAU,CAAC;IACZ,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,MAAM,UAAU,CACd,+FAA+F,CAChG,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,GAAG,SAAS,CAAC;IAEvB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,GAAG,GAAG,iCAAiC,iBAEzC,WAAW,EACX,SAAS,EAAE,MAAM,EACjB,aAAa,EACb,QAAQ,EAAE,0BAA0B,CAAC,QAAQ,CAAC,IAC3C,IAAI,GAET,UAAU,CACX,CAAC,QAAQ,EAAE,CAAC;IAEb,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AccountSasPermissions, accountSasPermissionsFromString } from \"./accountSasPermissions\";\nimport {\n AccountSasServices,\n accountSasServicesFromString,\n accountSasServicesToString,\n} from \"./accountSasServices\";\nimport { NamedKeyCredential, isNamedKeyCredential } from \"@azure/core-auth\";\nimport { SasIPRange } from \"./sasIPRange\";\nimport { SasProtocol } from \"./sasQueryParameters\";\nimport { generateAccountSasQueryParameters } from \"./accountSasSignatureValues\";\n\n/**\n * Generates a Table Account Shared Access Signature (SAS) URI based on the client properties\n * and parameters passed in. The SAS is signed by the shared key credential of the client.\n *\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/create-account-sas\n *\n * @param options - Optional parameters.\n * @returns An account SAS token\n */\nexport function generateAccountSas(\n credential: NamedKeyCredential,\n options: AccountSasOptions = {},\n): string {\n const {\n expiresOn,\n permissions = accountSasPermissionsFromString(\"rl\"),\n resourceTypes = \"sco\",\n services = accountSasServicesFromString(\"t\"),\n ...rest\n } = options;\n if (!isNamedKeyCredential(credential)) {\n throw RangeError(\n \"Can only generate the account SAS when the client is initialized with a shared key credential\",\n );\n }\n\n let expiry = expiresOn;\n\n if (expiry === undefined) {\n const now = new Date();\n expiry = new Date(now.getTime() + 3600 * 1000);\n }\n\n const sas = generateAccountSasQueryParameters(\n {\n permissions,\n expiresOn: expiry,\n resourceTypes,\n services: accountSasServicesToString(services),\n ...rest,\n },\n credential,\n ).toString();\n\n return sas;\n}\n\n/**\n * Options to configure {@link generateAccountSas} operation.\n */\nexport interface AccountSasOptions {\n /**\n * The time at which the shared access signature becomes invalid. Default to an hour later if not provided.\n */\n expiresOn?: Date;\n /**\n * Specifies the list of permissions to be associated with the SAS.\n */\n permissions?: AccountSasPermissions;\n /**\n * Specifies the resource types associated with the shared access signature.\n */\n resourceTypes?: string;\n /**\n * The version of the service this SAS will target. If not specified, it will default to the version targeted by the\n * library.\n */\n version?: string;\n\n /**\n * SAS protocols allowed.\n */\n protocol?: SasProtocol;\n\n /**\n * When the SAS will take effect.\n */\n startsOn?: Date;\n /**\n * IP range allowed.\n */\n ipRange?: SasIPRange;\n /**\n * Account services\n */\n services?: AccountSasServices;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateTableSas.js","sourceRoot":"","sources":["../../../src/sas/generateTableSas.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAsB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAEL,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAiB,EACjB,UAA8B,EAC9B,UAAmC,EAAE;IAErC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEzC,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"generateTableSas.js","sourceRoot":"","sources":["../../../src/sas/generateTableSas.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAsB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAEL,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAiB,EACjB,UAA8B,EAC9B,UAAmC,EAAE;IAErC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEzC,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,MAAM,UAAU,CACd,+FAA+F,CAChG,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,8DAA8D;IAC9D,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACxB,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,WAAW,GAAG,6BAA6B,CAAC,GAAG,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,MAAM,GAAG,GAAG,+BAA+B,CAAC,SAAS,EAAE,UAAU,kCAC5D,OAAO,KACV,SAAS;QACT,WAAW,IACX,CAAC,QAAQ,EAAE,CAAC;IAEd,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { NamedKeyCredential, isNamedKeyCredential } from \"@azure/core-auth\";\nimport {\n TableSasSignatureValues,\n generateTableSasQueryParameters,\n} from \"./tableSasSignatureValues\";\nimport { tableSasPermissionsFromString } from \"./tableSasPermisions\";\n\n/**\n * Generates a Table Service Shared Access Signature (SAS) URI based on the client properties\n * and parameters passed in. The SAS is signed by the shared key credential of the client.\n *\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas\n *\n * @param options - Optional parameters.\n * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.\n */\nexport function generateTableSas(\n tableName: string,\n credential: NamedKeyCredential,\n options: TableSasSignatureValues = {},\n): string {\n let { expiresOn, permissions } = options;\n\n if (!isNamedKeyCredential(credential)) {\n throw RangeError(\n \"Can only generate the account SAS when the client is initialized with a shared key credential\",\n );\n }\n\n // expiresOn and permissions are optional if an identifier is provided\n // set defaults when no identifier and no values were provided\n if (!options.identifier) {\n if (!permissions) {\n permissions = tableSasPermissionsFromString(\"r\");\n }\n\n if (expiresOn === undefined) {\n const now = new Date();\n expiresOn = new Date(now.getTime() + 3600 * 1000);\n }\n }\n\n const sas = generateTableSasQueryParameters(tableName, credential, {\n ...options,\n expiresOn,\n permissions,\n }).toString();\n\n return sas;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sasIPRange.js","sourceRoot":"","sources":["../../../src/sas/sasIPRange.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAkBlC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,OAAoB;IAClD,IAAI,CAAC,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"sasIPRange.js","sourceRoot":"","sources":["../../../src/sas/sasIPRange.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAkBlC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,OAAoB;IAClD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;AACzE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Allowed IP range for a SAS.\n */\nexport interface SasIPRange {\n /**\n * Starting IP address in the IP range.\n * If end IP doesn't provide, start IP will the only IP allowed.\n */\n start: string;\n /**\n * Optional. IP address that ends the IP range.\n * If not provided, start IP will the only IP allowed.\n */\n end?: string;\n}\n\n/**\n * Generate SasIPRange format string. For example:\n *\n * \"8.8.8.8\" or \"1.1.1.1-255.255.255.255\"\n *\n * @param ipRange -\n */\nexport function ipRangeToString(ipRange?: SasIPRange): string {\n if (!ipRange) {\n return \"\";\n }\n\n return ipRange.end ? `${ipRange.start}-${ipRange.end}` : ipRange.start;\n}\n"]}
|
|
@@ -66,34 +66,34 @@ export class SasQueryParameters {
|
|
|
66
66
|
*/
|
|
67
67
|
toString() {
|
|
68
68
|
const params = [
|
|
69
|
-
"sv",
|
|
70
|
-
"ss",
|
|
71
|
-
"srt",
|
|
72
|
-
"spr",
|
|
73
|
-
"st",
|
|
74
|
-
"se",
|
|
75
|
-
"sip",
|
|
76
|
-
"si",
|
|
77
|
-
"skoid",
|
|
78
|
-
"sktid",
|
|
79
|
-
"skt",
|
|
80
|
-
"ske",
|
|
81
|
-
"sks",
|
|
82
|
-
"skv",
|
|
83
|
-
"sr",
|
|
84
|
-
"sp",
|
|
85
|
-
"sig",
|
|
86
|
-
"rscc",
|
|
87
|
-
"rscd",
|
|
88
|
-
"rsce",
|
|
89
|
-
"rscl",
|
|
90
|
-
"rsct",
|
|
91
|
-
"saoid",
|
|
92
|
-
"scid",
|
|
93
|
-
"tn",
|
|
94
|
-
"srk",
|
|
95
|
-
"spk",
|
|
96
|
-
"epk",
|
|
69
|
+
"sv", // SignedVersion
|
|
70
|
+
"ss", // SignedServices
|
|
71
|
+
"srt", // SignedResourceTypes
|
|
72
|
+
"spr", // SignedProtocol
|
|
73
|
+
"st", // SignedStart
|
|
74
|
+
"se", // SignedExpiry
|
|
75
|
+
"sip", // SignedIP
|
|
76
|
+
"si", // SignedIdentifier
|
|
77
|
+
"skoid", // Signed object ID
|
|
78
|
+
"sktid", // Signed tenant ID
|
|
79
|
+
"skt", // Signed key start time
|
|
80
|
+
"ske", // Signed key expiry time
|
|
81
|
+
"sks", // Signed key service
|
|
82
|
+
"skv", // Signed key version
|
|
83
|
+
"sr", // signedResource
|
|
84
|
+
"sp", // SignedPermission
|
|
85
|
+
"sig", // Signature
|
|
86
|
+
"rscc", // Cache-Control
|
|
87
|
+
"rscd", // Content-Disposition
|
|
88
|
+
"rsce", // Content-Encoding
|
|
89
|
+
"rscl", // Content-Language
|
|
90
|
+
"rsct", // Content-Type
|
|
91
|
+
"saoid", // signedAuthorizedObjectId
|
|
92
|
+
"scid", // signedCorrelationId
|
|
93
|
+
"tn", // TableName,
|
|
94
|
+
"srk", // StartRowKey
|
|
95
|
+
"spk", // StartPartitionKey
|
|
96
|
+
"epk", // EndPartitionKey
|
|
97
97
|
"erk", // EndRowKey
|
|
98
98
|
];
|
|
99
99
|
const queries = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sasQueryParameters.js","sourceRoot":"","sources":["../../../src/sas/sasQueryParameters.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOpE;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IAwI7B;;;;OAIG;IACH,IAAW,OAAO;QAChB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,OAAO;gBACL,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG;gBAC1B,KAAK,EAAE,IAAI,CAAC,YAAY,C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ACrE,MAAM;gBACR,KAAK,KAAK;oBACR,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;oBAC/D,MAAM;gBACR,KAAK,KAAK;oBACR,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;oBACnE,MAAM;gBACR,KAAK,KAAK;oBACR,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC7D,MAAM;aACT;SACF;QACD,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED;;;;;;OAMG;IACK,uBAAuB,CAAC,OAAiB,EAAE,GAAW,EAAE,KAAc;QAC5E,IAAI,CAAC,KAAK,EAAE;YACV,OAAO;SACR;QAED,GAAG,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAC9B,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACtC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC;SACjC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SasIPRange, ipRangeToString } from \"./sasIPRange\";\nimport { UserDelegationKey } from \"./models\";\nimport { truncatedISO8061Date } from \"../utils/truncateISO8061Date\";\n\n/**\n * Protocols for generated SAS.\n */\nexport type SasProtocol = \"https\" | \"https,http\";\n\n/**\n * Represents the components that make up an Azure SAS' query parameters. This type is not constructed directly\n * by the user; it is only generated by the {@link AccountSasSignatureValues} and {@link TableSasSignatureValues}\n * types. Once generated, it can be encoded into a `string` and appended to a URL directly (though caution should\n * be taken here in case there are existing query parameters, which might affect the appropriate means of appending\n * these query parameters).\n *\n * NOTE: Instances of this class are immutable.\n */\nexport class SasQueryParameters {\n /**\n * The Tables API version.\n */\n public readonly version: string;\n\n /**\n * Optional. Table name to generate the SAS for\n */\n public readonly tableName?: string;\n\n /**\n * Optional. The allowed HTTP protocol(s).\n */\n public readonly protocol?: SasProtocol;\n\n /**\n * Optional. The start time for this SAS token.\n */\n public readonly startsOn?: Date;\n\n /**\n * Optional only when identifier is provided. The expiry time for this SAS token.\n */\n public readonly expiresOn?: Date;\n\n /**\n * Optional only when identifier is provided.\n * Please refer to {@link AccountSasPermissions}, or {@link TableSasPermissions} for\n * more details.\n */\n public readonly permissions?: string;\n\n /**\n * Optional. The table services being accessed (only for Account SAS). Please refer to {@link AccountSasServices}\n * for more details.\n */\n public readonly services?: string;\n\n /**\n * Optional. The table resource types being accessed (only for Account SAS). Please refer to\n * {@link AccountSasResourceTypes} for more details.\n */\n public readonly resourceTypes?: string;\n\n /**\n * Optional. The signed identifier (only for {@link TableSasSignatureValues}).\n *\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/establishing-a-stored-access-policy\n */\n public readonly identifier?: string;\n\n /**\n * The signature for the SAS token.\n */\n public readonly signature: string;\n\n /**\n * Inner value of getter ipRange.\n */\n private readonly ipRangeInner?: SasIPRange;\n\n /**\n * The Azure Active Directory object ID in GUID format.\n * Property of user delegation key.\n */\n private readonly signedOid?: string;\n\n /**\n * The Azure Active Directory tenant ID in GUID format.\n * Property of user delegation key.\n */\n private readonly signedTenantId?: string;\n\n /**\n * The date-time the key is active.\n * Property of user delegation key.\n */\n private readonly signedStartsOn?: Date;\n\n /**\n * The date-time the key expires.\n * Property of user delegation key.\n */\n private readonly signedExpiresOn?: Date;\n\n /**\n * Abbreviation of the Azure Table service that accepts the user delegation key.\n * Property of user delegation key.\n */\n private readonly signedService?: string;\n\n /**\n * The service version that created the user delegation key.\n * Property of user delegation key.\n */\n private readonly signedVersion?: string;\n\n /**\n * Authorized AAD Object ID in GUID format. The AAD Object ID of a user authorized by the owner of the User Delegation Key\n * to perform the action granted by the SAS. The Azure Table service will ensure that the owner of the user delegation key\n * has the required permissions before granting access but no additional permission check for the user specified in\n * this value will be performed. This is only used for User Delegation SAS.\n */\n public readonly preauthorizedAgentObjectId?: string;\n\n /**\n * A GUID value that will be logged in the table diagnostic logs and can be used to correlate SAS generation with table resource access.\n * This is only used for User Delegation SAS.\n */\n public readonly correlationId?: string;\n\n /**\n * Optional, but startPartitionKey must accompany startRowKey. The minimum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no lower bound on the table entities that can be accessed.\n */\n public readonly startPartitionKey?: string;\n\n /**\n * Optional, but startPartitionKey must accompany startRowKey. The minimum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no lower bound on the table entities that can be accessed.\n */\n public readonly startRowKey?: string;\n\n /**\n * Optional, but endPartitionKey must accompany endRowKey. The maximum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no upper bound on the table entities that can be accessed.\n */\n public readonly endPartitionKey?: string;\n\n /**\n * Optional, but endPartitionKey must accompany endRowKey. The maximum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no upper bound on the table entities that can be accessed.\n */\n public readonly endRowKey?: string;\n\n /**\n * Optional. IP range allowed for this SAS.\n *\n * @readonly\n */\n public get ipRange(): SasIPRange | undefined {\n if (this.ipRangeInner) {\n return {\n end: this.ipRangeInner.end,\n start: this.ipRangeInner.start,\n };\n }\n return undefined;\n }\n\n /**\n * Creates an instance of SASQueryParameters.\n *\n * @param version - Representing the table service version\n * @param signature - Representing the signature for the SAS token\n * @param options - Optional. Options to construct the SASQueryParameters.\n */\n constructor(version: string, signature: string, options: SasQueryParametersOptions = {}) {\n this.version = version;\n this.signature = signature;\n\n this.permissions = options.permissions;\n this.services = options.services;\n this.resourceTypes = options.resourceTypes;\n this.protocol = options.protocol;\n this.startsOn = options.startsOn;\n this.expiresOn = options.expiresOn;\n this.ipRangeInner = options.ipRange;\n this.identifier = options.identifier;\n this.tableName = options.tableName;\n this.endPartitionKey = options.endPartitionKey;\n this.endRowKey = options.endRowKey;\n this.startPartitionKey = options.startPartitionKey;\n this.startRowKey = options.startRowKey;\n\n if (options.userDelegationKey) {\n this.signedOid = options.userDelegationKey.signedObjectId;\n this.signedTenantId = options.userDelegationKey.signedTenantId;\n this.signedStartsOn = options.userDelegationKey.signedStartsOn;\n this.signedExpiresOn = options.userDelegationKey.signedExpiresOn;\n this.signedService = options.userDelegationKey.signedService;\n this.signedVersion = options.userDelegationKey.signedVersion;\n\n this.preauthorizedAgentObjectId = options.preauthorizedAgentObjectId;\n this.correlationId = options.correlationId;\n }\n }\n\n /**\n * Encodes all SAS query parameters into a string that can be appended to a URL.\n *\n */\n public toString(): string {\n const params: string[] = [\n \"sv\", // SignedVersion\n \"ss\", // SignedServices\n \"srt\", // SignedResourceTypes\n \"spr\", // SignedProtocol\n \"st\", // SignedStart\n \"se\", // SignedExpiry\n \"sip\", // SignedIP\n \"si\", // SignedIdentifier\n \"skoid\", // Signed object ID\n \"sktid\", // Signed tenant ID\n \"skt\", // Signed key start time\n \"ske\", // Signed key expiry time\n \"sks\", // Signed key service\n \"skv\", // Signed key version\n \"sr\", // signedResource\n \"sp\", // SignedPermission\n \"sig\", // Signature\n \"rscc\", // Cache-Control\n \"rscd\", // Content-Disposition\n \"rsce\", // Content-Encoding\n \"rscl\", // Content-Language\n \"rsct\", // Content-Type\n \"saoid\", // signedAuthorizedObjectId\n \"scid\", // signedCorrelationId\n \"tn\", // TableName,\n \"srk\", // StartRowKey\n \"spk\", // StartPartitionKey\n \"epk\", // EndPartitionKey\n \"erk\", // EndRowKey\n ];\n const queries: string[] = [];\n\n for (const param of params) {\n switch (param) {\n case \"sv\":\n this.tryAppendQueryParameter(queries, param, this.version);\n break;\n case \"ss\":\n this.tryAppendQueryParameter(queries, param, this.services);\n break;\n case \"srt\":\n this.tryAppendQueryParameter(queries, param, this.resourceTypes);\n break;\n case \"spr\":\n this.tryAppendQueryParameter(queries, param, this.protocol);\n break;\n case \"st\":\n this.tryAppendQueryParameter(\n queries,\n param,\n this.startsOn ? truncatedISO8061Date(this.startsOn, false) : undefined,\n );\n break;\n case \"se\":\n this.tryAppendQueryParameter(\n queries,\n param,\n this.expiresOn ? truncatedISO8061Date(this.expiresOn, false) : undefined,\n );\n break;\n case \"sip\":\n this.tryAppendQueryParameter(\n queries,\n param,\n this.ipRange ? ipRangeToString(this.ipRange) : undefined,\n );\n break;\n case \"si\":\n this.tryAppendQueryParameter(queries, param, this.identifier);\n break;\n case \"skoid\": // Signed object ID\n this.tryAppendQueryParameter(queries, param, this.signedOid);\n break;\n case \"sktid\": // Signed tenant ID\n this.tryAppendQueryParameter(queries, param, this.signedTenantId);\n break;\n case \"skt\": // Signed key start time\n this.tryAppendQueryParameter(\n queries,\n param,\n this.signedStartsOn ? truncatedISO8061Date(this.signedStartsOn, false) : undefined,\n );\n break;\n case \"ske\": // Signed key expiry time\n this.tryAppendQueryParameter(\n queries,\n param,\n this.signedExpiresOn ? truncatedISO8061Date(this.signedExpiresOn, false) : undefined,\n );\n break;\n case \"sks\": // Signed key service\n this.tryAppendQueryParameter(queries, param, this.signedService);\n break;\n case \"skv\": // Signed key version\n this.tryAppendQueryParameter(queries, param, this.signedVersion);\n break;\n case \"sp\":\n this.tryAppendQueryParameter(queries, param, this.permissions);\n break;\n case \"sig\":\n this.tryAppendQueryParameter(queries, param, this.signature);\n break;\n case \"saoid\":\n this.tryAppendQueryParameter(queries, param, this.preauthorizedAgentObjectId);\n break;\n case \"scid\":\n this.tryAppendQueryParameter(queries, param, this.correlationId);\n break;\n case \"tn\":\n this.tryAppendQueryParameter(queries, param, this.tableName);\n break;\n case \"spk\":\n this.tryAppendQueryParameter(queries, param, this.startPartitionKey);\n break;\n case \"srk\":\n this.tryAppendQueryParameter(queries, param, this.startRowKey);\n break;\n case \"epk\":\n this.tryAppendQueryParameter(queries, param, this.endPartitionKey);\n break;\n case \"erk\":\n this.tryAppendQueryParameter(queries, param, this.endRowKey);\n break;\n }\n }\n return queries.join(\"&\");\n }\n\n /**\n * A private helper method used to filter and append query key/value pairs into an array.\n *\n * @param queries -\n * @param key -\n * @param value -\n */\n private tryAppendQueryParameter(queries: string[], key: string, value?: string): void {\n if (!value) {\n return;\n }\n\n key = encodeURIComponent(key);\n value = encodeURIComponent(value);\n if (key.length > 0 && value.length > 0) {\n queries.push(`${key}=${value}`);\n }\n }\n}\n\n/**\n * Options to construct {@link SasQueryParameters}.\n */\nexport interface SasQueryParametersOptions {\n /**\n * Optional only when identifier is provided.\n * Please refer to {@link AccountSasPermissions}, or {@link TableSasPermissions} for\n * more details.\n */\n permissions?: string;\n /**\n * Optional. Table name to generate the SAS for\n */\n tableName?: string;\n /**\n * Optional. The storage services being accessed (only for Account SAS). Please refer to {@link AccountSasServices}\n * for more details.\n */\n services?: string;\n /**\n * Optional. The storage resource types being accessed (only for Account SAS). Please refer to\n * {@link AccountSasResourceTypes} for more details.\n */\n resourceTypes?: string;\n /**\n * Optional. The allowed HTTP protocol(s).\n */\n protocol?: SasProtocol;\n /**\n * Optional. The start time for this SAS token.\n */\n startsOn?: Date;\n /**\n * Optional only when identifier is provided. The expiry time for this SAS token.\n */\n expiresOn?: Date;\n /**\n * Optional. IP ranges allowed in this SAS.\n */\n ipRange?: SasIPRange;\n /**\n * Optional. The signed identifier for access policy\n *\n * @see https://docs.microsoft.com/rest/api/storageservices/establishing-a-stored-access-policy\n */\n identifier?: string;\n /**\n * Optional. Specifies which resources are accessible via the SAS (only for {@link AccountSasSignatureValues}).\n * @see https://docs.microsoft.com/rest/api/storageservices/create-service-sas#specifying-the-signed-resource-blob-service-only\n */\n resource?: string;\n /**\n * User delegation key properties.\n */\n userDelegationKey?: UserDelegationKey;\n /**\n * Authorized AAD Object ID in GUID format. The AAD Object ID of a user authorized by the owner of the User Delegation Key\n * to perform the action granted by the SAS. The Azure Table service will ensure that the owner of the user delegation key\n * has the required permissions before granting access but no additional permission check for the user specified in\n * this value will be performed. This cannot be used in conjuction with {@link signedUnauthorizedUserObjectId}.\n * This is only used for User Delegation SAS.\n */\n preauthorizedAgentObjectId?: string;\n /**\n * A GUID value that will be logged in the storage diagnostic logs and can be used to correlate SAS generation with storage resource access.\n * This is only used for User Delegation SAS.\n */\n correlationId?: string;\n\n /**\n * Optional, but startPartitionKey must accompany startRowKey. The minimum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no lower bound on the table entities that can be accessed.\n */\n startPartitionKey?: string;\n\n /**\n * Optional, but startPartitionKey must accompany startRowKey. The minimum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no lower bound on the table entities that can be accessed.\n */\n startRowKey?: string;\n\n /**\n * Optional, but endPartitionKey must accompany endRowKey. The maximum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no upper bound on the table entities that can be accessed.\n */\n endPartitionKey?: string;\n\n /**\n * Optional, but endPartitionKey must accompany endRowKey. The maximum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no upper bound on the table entities that can be accessed.\n */\n endRowKey?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sasQueryParameters.js","sourceRoot":"","sources":["../../../src/sas/sasQueryParameters.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOpE;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IAwI7B;;;;OAIG;IACH,IAAW,OAAO;QAChB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO;gBACL,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG;gBAC1B,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK;aAC/B,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,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AE,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SasIPRange, ipRangeToString } from \"./sasIPRange\";\nimport { UserDelegationKey } from \"./models\";\nimport { truncatedISO8061Date } from \"../utils/truncateISO8061Date\";\n\n/**\n * Protocols for generated SAS.\n */\nexport type SasProtocol = \"https\" | \"https,http\";\n\n/**\n * Represents the components that make up an Azure SAS' query parameters. This type is not constructed directly\n * by the user; it is only generated by the {@link AccountSasSignatureValues} and {@link TableSasSignatureValues}\n * types. Once generated, it can be encoded into a `string` and appended to a URL directly (though caution should\n * be taken here in case there are existing query parameters, which might affect the appropriate means of appending\n * these query parameters).\n *\n * NOTE: Instances of this class are immutable.\n */\nexport class SasQueryParameters {\n /**\n * The Tables API version.\n */\n public readonly version: string;\n\n /**\n * Optional. Table name to generate the SAS for\n */\n public readonly tableName?: string;\n\n /**\n * Optional. The allowed HTTP protocol(s).\n */\n public readonly protocol?: SasProtocol;\n\n /**\n * Optional. The start time for this SAS token.\n */\n public readonly startsOn?: Date;\n\n /**\n * Optional only when identifier is provided. The expiry time for this SAS token.\n */\n public readonly expiresOn?: Date;\n\n /**\n * Optional only when identifier is provided.\n * Please refer to {@link AccountSasPermissions}, or {@link TableSasPermissions} for\n * more details.\n */\n public readonly permissions?: string;\n\n /**\n * Optional. The table services being accessed (only for Account SAS). Please refer to {@link AccountSasServices}\n * for more details.\n */\n public readonly services?: string;\n\n /**\n * Optional. The table resource types being accessed (only for Account SAS). Please refer to\n * {@link AccountSasResourceTypes} for more details.\n */\n public readonly resourceTypes?: string;\n\n /**\n * Optional. The signed identifier (only for {@link TableSasSignatureValues}).\n *\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/establishing-a-stored-access-policy\n */\n public readonly identifier?: string;\n\n /**\n * The signature for the SAS token.\n */\n public readonly signature: string;\n\n /**\n * Inner value of getter ipRange.\n */\n private readonly ipRangeInner?: SasIPRange;\n\n /**\n * The Azure Active Directory object ID in GUID format.\n * Property of user delegation key.\n */\n private readonly signedOid?: string;\n\n /**\n * The Azure Active Directory tenant ID in GUID format.\n * Property of user delegation key.\n */\n private readonly signedTenantId?: string;\n\n /**\n * The date-time the key is active.\n * Property of user delegation key.\n */\n private readonly signedStartsOn?: Date;\n\n /**\n * The date-time the key expires.\n * Property of user delegation key.\n */\n private readonly signedExpiresOn?: Date;\n\n /**\n * Abbreviation of the Azure Table service that accepts the user delegation key.\n * Property of user delegation key.\n */\n private readonly signedService?: string;\n\n /**\n * The service version that created the user delegation key.\n * Property of user delegation key.\n */\n private readonly signedVersion?: string;\n\n /**\n * Authorized AAD Object ID in GUID format. The AAD Object ID of a user authorized by the owner of the User Delegation Key\n * to perform the action granted by the SAS. The Azure Table service will ensure that the owner of the user delegation key\n * has the required permissions before granting access but no additional permission check for the user specified in\n * this value will be performed. This is only used for User Delegation SAS.\n */\n public readonly preauthorizedAgentObjectId?: string;\n\n /**\n * A GUID value that will be logged in the table diagnostic logs and can be used to correlate SAS generation with table resource access.\n * This is only used for User Delegation SAS.\n */\n public readonly correlationId?: string;\n\n /**\n * Optional, but startPartitionKey must accompany startRowKey. The minimum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no lower bound on the table entities that can be accessed.\n */\n public readonly startPartitionKey?: string;\n\n /**\n * Optional, but startPartitionKey must accompany startRowKey. The minimum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no lower bound on the table entities that can be accessed.\n */\n public readonly startRowKey?: string;\n\n /**\n * Optional, but endPartitionKey must accompany endRowKey. The maximum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no upper bound on the table entities that can be accessed.\n */\n public readonly endPartitionKey?: string;\n\n /**\n * Optional, but endPartitionKey must accompany endRowKey. The maximum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no upper bound on the table entities that can be accessed.\n */\n public readonly endRowKey?: string;\n\n /**\n * Optional. IP range allowed for this SAS.\n *\n * @readonly\n */\n public get ipRange(): SasIPRange | undefined {\n if (this.ipRangeInner) {\n return {\n end: this.ipRangeInner.end,\n start: this.ipRangeInner.start,\n };\n }\n return undefined;\n }\n\n /**\n * Creates an instance of SASQueryParameters.\n *\n * @param version - Representing the table service version\n * @param signature - Representing the signature for the SAS token\n * @param options - Optional. Options to construct the SASQueryParameters.\n */\n constructor(version: string, signature: string, options: SasQueryParametersOptions = {}) {\n this.version = version;\n this.signature = signature;\n\n this.permissions = options.permissions;\n this.services = options.services;\n this.resourceTypes = options.resourceTypes;\n this.protocol = options.protocol;\n this.startsOn = options.startsOn;\n this.expiresOn = options.expiresOn;\n this.ipRangeInner = options.ipRange;\n this.identifier = options.identifier;\n this.tableName = options.tableName;\n this.endPartitionKey = options.endPartitionKey;\n this.endRowKey = options.endRowKey;\n this.startPartitionKey = options.startPartitionKey;\n this.startRowKey = options.startRowKey;\n\n if (options.userDelegationKey) {\n this.signedOid = options.userDelegationKey.signedObjectId;\n this.signedTenantId = options.userDelegationKey.signedTenantId;\n this.signedStartsOn = options.userDelegationKey.signedStartsOn;\n this.signedExpiresOn = options.userDelegationKey.signedExpiresOn;\n this.signedService = options.userDelegationKey.signedService;\n this.signedVersion = options.userDelegationKey.signedVersion;\n\n this.preauthorizedAgentObjectId = options.preauthorizedAgentObjectId;\n this.correlationId = options.correlationId;\n }\n }\n\n /**\n * Encodes all SAS query parameters into a string that can be appended to a URL.\n *\n */\n public toString(): string {\n const params: string[] = [\n \"sv\", // SignedVersion\n \"ss\", // SignedServices\n \"srt\", // SignedResourceTypes\n \"spr\", // SignedProtocol\n \"st\", // SignedStart\n \"se\", // SignedExpiry\n \"sip\", // SignedIP\n \"si\", // SignedIdentifier\n \"skoid\", // Signed object ID\n \"sktid\", // Signed tenant ID\n \"skt\", // Signed key start time\n \"ske\", // Signed key expiry time\n \"sks\", // Signed key service\n \"skv\", // Signed key version\n \"sr\", // signedResource\n \"sp\", // SignedPermission\n \"sig\", // Signature\n \"rscc\", // Cache-Control\n \"rscd\", // Content-Disposition\n \"rsce\", // Content-Encoding\n \"rscl\", // Content-Language\n \"rsct\", // Content-Type\n \"saoid\", // signedAuthorizedObjectId\n \"scid\", // signedCorrelationId\n \"tn\", // TableName,\n \"srk\", // StartRowKey\n \"spk\", // StartPartitionKey\n \"epk\", // EndPartitionKey\n \"erk\", // EndRowKey\n ];\n const queries: string[] = [];\n\n for (const param of params) {\n switch (param) {\n case \"sv\":\n this.tryAppendQueryParameter(queries, param, this.version);\n break;\n case \"ss\":\n this.tryAppendQueryParameter(queries, param, this.services);\n break;\n case \"srt\":\n this.tryAppendQueryParameter(queries, param, this.resourceTypes);\n break;\n case \"spr\":\n this.tryAppendQueryParameter(queries, param, this.protocol);\n break;\n case \"st\":\n this.tryAppendQueryParameter(\n queries,\n param,\n this.startsOn ? truncatedISO8061Date(this.startsOn, false) : undefined,\n );\n break;\n case \"se\":\n this.tryAppendQueryParameter(\n queries,\n param,\n this.expiresOn ? truncatedISO8061Date(this.expiresOn, false) : undefined,\n );\n break;\n case \"sip\":\n this.tryAppendQueryParameter(\n queries,\n param,\n this.ipRange ? ipRangeToString(this.ipRange) : undefined,\n );\n break;\n case \"si\":\n this.tryAppendQueryParameter(queries, param, this.identifier);\n break;\n case \"skoid\": // Signed object ID\n this.tryAppendQueryParameter(queries, param, this.signedOid);\n break;\n case \"sktid\": // Signed tenant ID\n this.tryAppendQueryParameter(queries, param, this.signedTenantId);\n break;\n case \"skt\": // Signed key start time\n this.tryAppendQueryParameter(\n queries,\n param,\n this.signedStartsOn ? truncatedISO8061Date(this.signedStartsOn, false) : undefined,\n );\n break;\n case \"ske\": // Signed key expiry time\n this.tryAppendQueryParameter(\n queries,\n param,\n this.signedExpiresOn ? truncatedISO8061Date(this.signedExpiresOn, false) : undefined,\n );\n break;\n case \"sks\": // Signed key service\n this.tryAppendQueryParameter(queries, param, this.signedService);\n break;\n case \"skv\": // Signed key version\n this.tryAppendQueryParameter(queries, param, this.signedVersion);\n break;\n case \"sp\":\n this.tryAppendQueryParameter(queries, param, this.permissions);\n break;\n case \"sig\":\n this.tryAppendQueryParameter(queries, param, this.signature);\n break;\n case \"saoid\":\n this.tryAppendQueryParameter(queries, param, this.preauthorizedAgentObjectId);\n break;\n case \"scid\":\n this.tryAppendQueryParameter(queries, param, this.correlationId);\n break;\n case \"tn\":\n this.tryAppendQueryParameter(queries, param, this.tableName);\n break;\n case \"spk\":\n this.tryAppendQueryParameter(queries, param, this.startPartitionKey);\n break;\n case \"srk\":\n this.tryAppendQueryParameter(queries, param, this.startRowKey);\n break;\n case \"epk\":\n this.tryAppendQueryParameter(queries, param, this.endPartitionKey);\n break;\n case \"erk\":\n this.tryAppendQueryParameter(queries, param, this.endRowKey);\n break;\n }\n }\n return queries.join(\"&\");\n }\n\n /**\n * A private helper method used to filter and append query key/value pairs into an array.\n *\n * @param queries -\n * @param key -\n * @param value -\n */\n private tryAppendQueryParameter(queries: string[], key: string, value?: string): void {\n if (!value) {\n return;\n }\n\n key = encodeURIComponent(key);\n value = encodeURIComponent(value);\n if (key.length > 0 && value.length > 0) {\n queries.push(`${key}=${value}`);\n }\n }\n}\n\n/**\n * Options to construct {@link SasQueryParameters}.\n */\nexport interface SasQueryParametersOptions {\n /**\n * Optional only when identifier is provided.\n * Please refer to {@link AccountSasPermissions}, or {@link TableSasPermissions} for\n * more details.\n */\n permissions?: string;\n /**\n * Optional. Table name to generate the SAS for\n */\n tableName?: string;\n /**\n * Optional. The storage services being accessed (only for Account SAS). Please refer to {@link AccountSasServices}\n * for more details.\n */\n services?: string;\n /**\n * Optional. The storage resource types being accessed (only for Account SAS). Please refer to\n * {@link AccountSasResourceTypes} for more details.\n */\n resourceTypes?: string;\n /**\n * Optional. The allowed HTTP protocol(s).\n */\n protocol?: SasProtocol;\n /**\n * Optional. The start time for this SAS token.\n */\n startsOn?: Date;\n /**\n * Optional only when identifier is provided. The expiry time for this SAS token.\n */\n expiresOn?: Date;\n /**\n * Optional. IP ranges allowed in this SAS.\n */\n ipRange?: SasIPRange;\n /**\n * Optional. The signed identifier for access policy\n *\n * @see https://docs.microsoft.com/rest/api/storageservices/establishing-a-stored-access-policy\n */\n identifier?: string;\n /**\n * Optional. Specifies which resources are accessible via the SAS (only for {@link AccountSasSignatureValues}).\n * @see https://docs.microsoft.com/rest/api/storageservices/create-service-sas#specifying-the-signed-resource-blob-service-only\n */\n resource?: string;\n /**\n * User delegation key properties.\n */\n userDelegationKey?: UserDelegationKey;\n /**\n * Authorized AAD Object ID in GUID format. The AAD Object ID of a user authorized by the owner of the User Delegation Key\n * to perform the action granted by the SAS. The Azure Table service will ensure that the owner of the user delegation key\n * has the required permissions before granting access but no additional permission check for the user specified in\n * this value will be performed. This cannot be used in conjuction with {@link signedUnauthorizedUserObjectId}.\n * This is only used for User Delegation SAS.\n */\n preauthorizedAgentObjectId?: string;\n /**\n * A GUID value that will be logged in the storage diagnostic logs and can be used to correlate SAS generation with storage resource access.\n * This is only used for User Delegation SAS.\n */\n correlationId?: string;\n\n /**\n * Optional, but startPartitionKey must accompany startRowKey. The minimum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no lower bound on the table entities that can be accessed.\n */\n startPartitionKey?: string;\n\n /**\n * Optional, but startPartitionKey must accompany startRowKey. The minimum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no lower bound on the table entities that can be accessed.\n */\n startRowKey?: string;\n\n /**\n * Optional, but endPartitionKey must accompany endRowKey. The maximum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no upper bound on the table entities that can be accessed.\n */\n endPartitionKey?: string;\n\n /**\n * Optional, but endPartitionKey must accompany endRowKey. The maximum partition and row keys that are accessible with this shared access signature.\n * Key values are inclusive. If they're omitted, there's no upper bound on the table entities that can be accessed.\n */\n endRowKey?: string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableSasPermisions.js","sourceRoot":"","sources":["../../../src/sas/tableSasPermisions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,WAAmB;IAC/D,MAAM,mBAAmB,GAAwB,EAAE,CAAC;IACpD,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE;
|
|
1
|
+
{"version":3,"file":"tableSasPermisions.js","sourceRoot":"","sources":["../../../src/sas/tableSasPermisions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,WAAmB;IAC/D,MAAM,mBAAmB,GAAwB,EAAE,CAAC;IACpD,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,GAAG;gBACN,mBAAmB,CAAC,KAAK,GAAG,IAAI,CAAC;gBACjC,MAAM;YACR,KAAK,GAAG;gBACN,mBAAmB,CAAC,GAAG,GAAG,IAAI,CAAC;gBAC/B,MAAM;YACR,KAAK,GAAG;gBACN,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC;gBAClC,MAAM;YACR,KAAK,GAAG;gBACN,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC;gBAClC,MAAM;YACR;gBACE,MAAM,IAAI,UAAU,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,WAAiC;IAC3E,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,iBAAiB,GAAa,EAAE,CAAC;IACvC,IAAI,WAAW,CAAC,KAAK,EAAE,CAAC;QACtB,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,WAAW,CAAC,GAAG,EAAE,CAAC;QACpB,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACvB,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC;QACvB,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,OAAO,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Creates a {@link TableSasPermissions} from the specified permissions string. This method will throw an\n * Error if it encounters a character that does not correspond to a valid permission.\n *\n * @param permissions -\n */\nexport function tableSasPermissionsFromString(permissions: string): TableSasPermissions {\n const tableSasPermissions: TableSasPermissions = {};\n for (const char of permissions) {\n switch (char) {\n case \"r\":\n tableSasPermissions.query = true;\n break;\n case \"a\":\n tableSasPermissions.add = true;\n break;\n case \"u\":\n tableSasPermissions.update = true;\n break;\n case \"d\":\n tableSasPermissions.delete = true;\n break;\n default:\n throw new RangeError(`Invalid permission: ${char}`);\n }\n }\n\n return tableSasPermissions;\n}\n\n/**\n * Converts the given permissions to a string. Using this method will guarantee the permissions are in an\n * order accepted by the service.\n *\n * @returns A string which represents the TableSasPermissions\n */\nexport function tableSasPermissionsToString(permissions?: TableSasPermissions): string {\n if (!permissions) {\n return \"\";\n }\n\n const permissionsString: string[] = [];\n if (permissions.query) {\n permissionsString.push(\"r\");\n }\n if (permissions.add) {\n permissionsString.push(\"a\");\n }\n if (permissions.update) {\n permissionsString.push(\"u\");\n }\n\n if (permissions.delete) {\n permissionsString.push(\"d\");\n }\n return permissionsString.join(\"\");\n}\n\n/**\n * A type that looks like a Table SAS permission.\n * Used in {@link TableSasPermissions} to parse SAS permissions from raw objects.\n */\nexport interface TableSasPermissions {\n /**\n * Specifies Query access granted.\n */\n query?: boolean;\n\n /**\n * Specifies Add access granted.\n */\n add?: boolean;\n\n /**\n * Specifies Update access granted.\n */\n update?: boolean;\n\n /**\n * Specifies Delete access granted.\n */\n delete?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tableSasSignatureValues.js","sourceRoot":"","sources":["../../../src/sas/tableSasSignatureValues.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AAEH,OAAO,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAe,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAuB,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAExF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AA8EpE;;;;;;GAMG;AACH,MAAM,UAAU,+BAA+B,CAC7C,SAAiB,EACjB,UAA8B,EAC9B,uBAAgD;;IAEhD,MAAM,OAAO,GAAG,MAAA,uBAAuB,CAAC,OAAO,mCAAI,eAAe,CAAC;IAEnE,IAAI,UAAU,KAAK,SAAS,EAAE;
|
|
1
|
+
{"version":3,"file":"tableSasSignatureValues.js","sourceRoot":"","sources":["../../../src/sas/tableSasSignatureValues.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AAEH,OAAO,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAe,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAuB,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAExF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC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,CAAC;IACjE,MAAM,kBAAkB,GAAG,MAAA,uBAAuB,CAAC,eAAe,mCAAI,EAAE,CAAC;IACzE,MAAM,YAAY,GAAG,MAAA,uBAAuB,CAAC,SAAS,mCAAI,EAAE,CAAC;IAE7D,MAAM,YAAY,GAAG;QACnB,iBAAiB;QACjB,WAAW;QACX,YAAY;QACZ,qBAAqB;QACrB,gBAAgB;QAChB,QAAQ;QACR,cAAc;QACd,OAAO;QACP,oBAAoB;QACpB,cAAc;QACd,kBAAkB;QAClB,YAAY;KACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,MAAM,SAAS,GAAG,iBAAiB,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAElE,OAAO,IAAI,kBAAkB,CAAC,OAAO,EAAE,SAAS,EAAE;QAChD,WAAW,EAAE,iBAAiB;QAC9B,QAAQ,EAAE,uBAAuB,CAAC,QAAQ;QAC1C,QAAQ,EAAE,uBAAuB,CAAC,QAAQ;QAC1C,SAAS,EAAE,uBAAuB,CAAC,SAAS;QAC5C,OAAO,EAAE,uBAAuB,CAAC,OAAO;QACxC,UAAU,EAAE,uBAAuB,CAAC,UAAU;QAC9C,SAAS;QACT,iBAAiB,EAAE,uBAAuB,CAAC,iBAAiB;QAC5D,WAAW,EAAE,uBAAuB,CAAC,WAAW;QAChD,eAAe,EAAE,uBAAuB,CAAC,eAAe;QACxD,SAAS,EAAE,uBAAuB,CAAC,SAAS;KAC7C,CAAC,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,WAAmB,EAAE,SAAiB;IAC9D,yHAAyH;IACzH,yDAAyD;IACzD,OAAO,UAAU,WAAW,IAAI,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * ONLY AVAILABLE IN NODE.JS RUNTIME.\n *\n * TableSASSignatureValues is used to help generating SAS tokens for tables.\n */\n\nimport { SasIPRange, ipRangeToString } from \"./sasIPRange\";\nimport { SasProtocol, SasQueryParameters } from \"./sasQueryParameters\";\nimport { TableSasPermissions, tableSasPermissionsToString } from \"./tableSasPermisions\";\nimport { NamedKeyCredential } from \"@azure/core-auth\";\nimport { SERVICE_VERSION } from \"../utils/constants\";\nimport { computeHMACSHA256 } from \"../utils/computeHMACSHA256\";\nimport { truncatedISO8061Date } from \"../utils/truncateISO8061Date\";\n\n/**\n * ONLY AVAILABLE IN NODE.JS RUNTIME.\n *\n * TableSASSignatureValues is used to help generating Table service SAS tokens for tables\n */\nexport interface TableSasSignatureValues {\n /**\n * The version of the service this SAS will target. If not specified, it will default to the version targeted by the\n * library.\n */\n version?: string;\n\n /**\n * Optional. SAS protocols, HTTPS only or HTTPSandHTTP\n */\n protocol?: SasProtocol;\n\n /**\n * Optional. When the SAS will take effect.\n */\n startsOn?: Date;\n\n /**\n * Optional. If identifier is not provided has a default value of one hour from the time the token is generated.\n * The time after which the SAS will no longer work.\n */\n expiresOn?: Date;\n\n /**\n * Optional. If identifier is not provided has a default value of \"read\"\n * Please refer to {@link TableSasPermissions} depending on the resource\n * being accessed for help constructing the permissions string.\n */\n permissions?: TableSasPermissions;\n /**\n * Optional. IP ranges allowed in this SAS.\n */\n ipRange?: SasIPRange;\n\n /**\n * Optional. The name of the access policy on the container this SAS references if any.\n *\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/establishing-a-stored-access-policy\n */\n identifier?: string;\n\n /**\n * Define the start of a Partition Key range\n * Table queries will only return results that are within the range, and attempts to use the shared access signature to add, update, or delete entities outside this range will fail.\n * If startPartitionKey equals endPartitionKey the shared access signature only authorizes access to entities in one partition in the table.\n * If startPartitionKey equals endPartitionKey and startRowKey equals endRowKey, the shared access signature can only access one entity in one partition\n */\n startPartitionKey?: string;\n /**\n * Define the end of a Partition Key range\n * Table queries will only return results that are within the range, and attempts to use the shared access signature to add, update, or delete entities outside this range will fail.\n * If startPartitionKey equals endPartitionKey the shared access signature only authorizes access to entities in one partition in the table.\n * If startPartitionKey equals endPartitionKey and startRowKey equals endRowKey, the shared access signature can only access one entity in one partition\n */\n endPartitionKey?: string;\n /**\n * Define the start of a Row Key range\n * Table queries will only return results that are within the range, and attempts to use the shared access signature to add, update, or delete entities outside this range will fail.\n * If startPartitionKey equals endPartitionKey the shared access signature only authorizes access to entities in one partition in the table.\n * If startPartitionKey equals endPartitionKey and startRowKey equals endRowKey, the shared access signature can only access one entity in one partition\n */\n startRowKey?: string;\n /**\n * Define the end of a Row Key range\n * Table queries will only return results that are within the range, and attempts to use the shared access signature to add, update, or delete entities outside this range will fail.\n * If startPartitionKey equals endPartitionKey the shared access signature only authorizes access to entities in one partition in the table.\n * If startPartitionKey equals endPartitionKey and startRowKey equals endRowKey, the shared access signature can only access one entity in one partition\n */\n endRowKey?: string;\n}\n\n/**\n * ONLY AVAILABLE IN NODE.JS RUNTIME.\n *\n * Creates an instance of SASQueryParameters.\n *\n * **Note**: When identifier is not provided, permissions has a default value of \"read\" and expiresOn of one hour from the time the token is generated.\n */\nexport function generateTableSasQueryParameters(\n tableName: string,\n credential: NamedKeyCredential,\n tableSasSignatureValues: TableSasSignatureValues,\n): SasQueryParameters {\n const version = tableSasSignatureValues.version ?? SERVICE_VERSION;\n\n if (credential === undefined) {\n throw TypeError(\"Invalid NamedKeyCredential\");\n }\n\n if (!tableName) {\n throw new Error(\"Must provide a 'tableName'\");\n }\n\n const signedPermissions = tableSasPermissionsToString(tableSasSignatureValues.permissions);\n const signedStart = tableSasSignatureValues.startsOn\n ? truncatedISO8061Date(tableSasSignatureValues.startsOn, false /** withMilliseconds */)\n : \"\";\n const signedExpiry = tableSasSignatureValues.expiresOn\n ? truncatedISO8061Date(tableSasSignatureValues.expiresOn, false /** withMilliseconds */)\n : \"\";\n const canonicalizedResource = getCanonicalName(credential.name, tableName);\n const signedIdentifier = tableSasSignatureValues.identifier ?? \"\";\n const signedIP = ipRangeToString(tableSasSignatureValues.ipRange);\n const signedProtocol = tableSasSignatureValues.protocol || \"\";\n const startingPartitionKey = tableSasSignatureValues.startPartitionKey ?? \"\";\n const startingRowKey = tableSasSignatureValues.startRowKey ?? \"\";\n const endingPartitionKey = tableSasSignatureValues.endPartitionKey ?? \"\";\n const endingRowKey = tableSasSignatureValues.endRowKey ?? \"\";\n\n const stringToSign = [\n signedPermissions,\n signedStart,\n signedExpiry,\n canonicalizedResource,\n signedIdentifier,\n signedIP,\n signedProtocol,\n version,\n startingPartitionKey,\n startingRowKey,\n endingPartitionKey,\n endingRowKey,\n ].join(\"\\n\");\n\n const signature = computeHMACSHA256(stringToSign, credential.key);\n\n return new SasQueryParameters(version, signature, {\n permissions: signedPermissions,\n protocol: tableSasSignatureValues.protocol,\n startsOn: tableSasSignatureValues.startsOn,\n expiresOn: tableSasSignatureValues.expiresOn,\n ipRange: tableSasSignatureValues.ipRange,\n identifier: tableSasSignatureValues.identifier,\n tableName,\n startPartitionKey: tableSasSignatureValues.startPartitionKey,\n startRowKey: tableSasSignatureValues.startRowKey,\n endPartitionKey: tableSasSignatureValues.endPartitionKey,\n endRowKey: tableSasSignatureValues.endRowKey,\n });\n}\n\nfunction getCanonicalName(accountName: string, tableName: string): string {\n // Sample CanonicalName for URL = https://myaccount.table.core.windows.net/Employees(PartitionKey='Jeff',RowKey='Price'):\n // canonicalizedResource = \"/table/myaccount/employees\"\n return `/table/${accountName}/${tableName.toLowerCase()}`;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondaryEndpointPolicy.js","sourceRoot":"","sources":["../../src/secondaryEndpointPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,+BAA+B,CAAC;AACjF,MAAM,CAAC,MAAM,2BAA2B,GAAG,2BAA2B,CAAC;AACvE,MAAM,8BAA8B,GAAG,YAAY,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GA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A0B,CAAC,UAAkB;IACpD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,8BAA8B,EAAE,CAAC;IAC1D,CAAC;IACD,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE3C,OAAO,gBAAgB,CAAC,QAAQ,EAAE,CAAC;AACrC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationOptions } from \"@azure/core-client\";\nimport { PipelinePolicy } from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the tablesSecondaryEndpointPolicy.\n */\nexport const tablesSecondaryEndpointPolicyName = \"tablesSecondaryEndpointPolicy\";\nexport const SecondaryLocationHeaderName = \"tables-secondary-endpoint\";\nconst SecondaryLocationAccountSuffix = \"-secondary\";\n\n/**\n * Policy that would replace the Primary Endpoint with the secondary endpoint\n * when the `tables-secondary-endpoint` is set in the request\n */\nexport const tablesSecondaryEndpointPolicy: PipelinePolicy = {\n name: tablesSecondaryEndpointPolicyName,\n sendRequest: async (req, next) => {\n // Only replace the URL if the SecondaryLocationHeader is set\n if (req.headers.get(SecondaryLocationHeaderName)) {\n // Since the header is for internal use only, clean it up.\n req.headers.delete(SecondaryLocationHeaderName);\n // Calculate and update the secondary url\n req.url = getSecondaryUrlFromPrimary(req.url);\n }\n\n return next(req);\n },\n};\n\n/**\n * Utility function that injects the SecondaryEndpointHeader into an operation options\n */\nexport function injectSecondaryEndpointHeader(options: OperationOptions): OperationOptions {\n const headerToInject = { [SecondaryLocationHeaderName]: \"true\" };\n return {\n ...options,\n requestOptions: {\n ...options.requestOptions,\n customHeaders: {\n ...options.requestOptions?.customHeaders,\n ...headerToInject,\n },\n },\n };\n}\n\n/**\n * Utility function that calculates the secondary URL for a table instance given the primary URL.\n */\nfunction getSecondaryUrlFromPrimary(primaryUrl: string): string {\n const parsedPrimaryUrl = new URL(primaryUrl);\n const host = parsedPrimaryUrl.hostname.split(\".\");\n if (host.length > 1) {\n host[0] = `${host[0]}${SecondaryLocationAccountSuffix}`;\n }\n parsedPrimaryUrl.hostname = host.join(\".\");\n\n return parsedPrimaryUrl.toString();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/serialization.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAiB;IACnE,CAAC,cAAc,EAAE,cAAc,CAAC;IAChC,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,YAAY,EAAE,MAAM,CAAC;IACtB,CAAC,WAAW,EAAE,WAAW,CAAC;CAC3B,CAAC,CAAC;AAEH,MAAM,GAAG,GAAG;IACV,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,YAAY;CACZ,CAAC;AASX,SAAS,kBAAkB,CAAC,KAAU;IACpC,MAAM,eAAe,GAAmB,EAAE,KAAK,EAAE,CAAC;IAClD,IACE,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ;Q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,EAAE;QACV,WAAW,CAAC,MAAM,GAAG,MAAM;aACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;aAC7C,GAAG,CAAC,qCAAqC,CAAC;aAC1C,IAAI,CAAC,GAAG,CAAC,CAAC;KACd;IACD,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EdmTypes, SignedIdentifier, TableEntityQueryOptions } from \"./models\";\nimport {\n QueryOptions as GeneratedQueryOptions,\n SignedIdentifier as GeneratedSignedIdentifier,\n} from \"./generated/models\";\nimport { base64Decode, base64Encode } from \"./utils/bufferSerializer\";\nimport { truncatedISO8061Date } from \"./utils/truncateISO8061Date\";\n\nconst propertyCaseMap: Map<string, string> = new Map<string, string>([\n [\"PartitionKey\", \"partitionKey\"],\n [\"RowKey\", \"rowKey\"],\n [\"odata.etag\", \"etag\"],\n [\"Timestamp\", \"timestamp\"],\n]);\n\nconst Edm = {\n Binary: \"Edm.Binary\",\n Boolean: \"Edm.Boolean\",\n DateTime: \"Edm.DateTime\",\n Double: \"Edm.Double\",\n Guid: \"Edm.Guid\",\n Int32: \"Edm.Int32\",\n Int64: \"Edm.Int64\",\n String: \"Edm.String\",\n} as const;\n\ntype supportedTypes = boolean | string | number | Date | Uint8Array | bigint;\n\ntype serializedType = {\n value: supportedTypes;\n type?: string;\n};\n\nfunction serializePrimitive(value: any): serializedType {\n const serializedValue: serializedType = { value };\n if (\n value === undefined ||\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"string\" ||\n typeof value === \"number\"\n ) {\n serializedValue.value = value;\n } else if (typeof value === \"bigint\") {\n serializedValue.value = value.toString();\n serializedValue.type = Edm.Int64;\n } else if (value instanceof Date) {\n serializedValue.value = value;\n serializedValue.type = Edm.DateTime;\n } else if (value instanceof Uint8Array) {\n serializedValue.value = base64Encode(value);\n serializedValue.type = Edm.Binary;\n } else {\n throw new Error(`Unknown EDM type ${typeof value}`);\n }\n\n return serializedValue;\n}\n\nfunction serializeObject(obj: { value: any; type: EdmTypes }): serializedType {\n const serializedValue: serializedType = { value: obj.value };\n if (\n obj.type === \"Boolean\" ||\n obj.type === \"DateTime\" ||\n obj.type === \"Double\" ||\n obj.type === \"Guid\" ||\n obj.type === \"Int32\" ||\n obj.type === \"Int64\" ||\n obj.type === \"String\" ||\n obj.type === \"Binary\"\n ) {\n serializedValue.value = obj.value;\n serializedValue.type = Edm[obj.type];\n } else {\n throw new Error(`Unknown EDM type ${typeof obj.value}`);\n }\n\n return serializedValue;\n}\n\nfunction getSerializedValue(value: any): serializedType {\n if (typeof value === \"object\" && value?.value !== undefined && value?.type !== undefined) {\n return serializeObject(value);\n } else {\n return serializePrimitive(value);\n }\n}\n\nfunction translatePropertyNameForSerialization(propertyName: string): string {\n for (const [original, internal] of propertyCaseMap) {\n if (internal === propertyName) {\n return original;\n }\n }\n\n return propertyName;\n}\n\nexport function serialize(obj: object): Record<string, Record<string, unknown>> {\n const serialized: any = {};\n for (const [propertyName, propertyValue] of Object.entries(obj)) {\n const transformedKey = translatePropertyNameForSerialization(propertyName);\n const serializedVal = getSerializedValue(propertyValue);\n serialized[transformedKey] = serializedVal.value;\n if (serializedVal.type) {\n serialized[`${transformedKey}@odata.type`] = serializedVal.type;\n }\n }\n return serialized;\n}\n\nfunction getTypedObject(value: any, type: string, disableTypeConversion: boolean): any {\n switch (type) {\n case Edm.Boolean:\n return disableTypeConversion ? { value, type: \"Boolean\" } : value;\n case Edm.Double:\n return disableTypeConversion ? { value, type: \"Double\" } : value;\n case Edm.Int32:\n return disableTypeConversion ? { value, type: \"Int32\" } : value;\n case Edm.String:\n return disableTypeConversion ? { value, type: \"String\" } : value;\n case Edm.DateTime:\n return disableTypeConversion ? { value, type: \"DateTime\" } : new Date(value);\n case Edm.Int64:\n return disableTypeConversion ? { value, type: \"Int64\" } : BigInt(value);\n case Edm.Guid:\n return { value, type: \"Guid\" };\n case Edm.Binary:\n return disableTypeConversion ? { value, type: \"Binary\" } : base64Decode(value);\n default:\n throw new Error(`Unknown EDM type ${type}`);\n }\n}\n\nexport function deserialize<T extends object = Record<string, any>>(\n obj: object,\n disableTypeConversion: boolean = false,\n): T {\n const deserialized: any = {};\n for (const [key, value] of Object.entries(obj)) {\n if (key.indexOf(\"@odata.type\") === -1) {\n const transformedKey = propertyCaseMap.get(key) ?? key;\n let typedValue = value;\n if (`${key}@odata.type` in obj) {\n const type = (obj as any)[`${key}@odata.type`];\n typedValue = getTypedObject(value, type, disableTypeConversion);\n } else if (disableTypeConversion && [\"number\", \"string\", \"boolean\"].includes(typeof value)) {\n // The service, doesn't return type metadata for number, strings or booleans\n // if automatic type conversion is disabled we'll infer the EDM object\n typedValue = inferTypedObject(key, value);\n }\n\n deserialized[transformedKey] = typedValue;\n }\n }\n return deserialized;\n}\n\nfunction inferTypedObject(propertyName: string, value: number | string | boolean) {\n // We need to skip service metadata fields such as partitionKey and rowKey and use the same value returned by the service\n if (propertyCaseMap.has(propertyName)) {\n return value;\n }\n\n switch (typeof value) {\n case \"boolean\":\n return { value: String(value), type: \"Boolean\" };\n case \"number\":\n return getTypedNumber(value);\n case \"string\":\n return { value, type: \"String\" };\n default:\n return value;\n }\n}\n\n/**\n * Returns the number when typeConversion is enabled or the EDM object with the correct number format Double or Int32 if disabled\n */\nfunction getTypedNumber(value: number): { value: string; type: \"Int32\" | \"Double\" } {\n const valueStr = String(value);\n if (Number.isSafeInteger(value)) {\n return { value: valueStr, type: \"Int32\" };\n } else {\n return { value: valueStr, type: \"Double\" };\n }\n}\n\nexport function deserializeObjectsArray<T extends object>(\n objArray: object[],\n disableTypeConversion: boolean,\n): T[] {\n return objArray.map((obj) => deserialize<T>(obj, disableTypeConversion));\n}\n\n/**\n * For ACL endpoints the Tables Service takes an ISO Date without decimals however\n * serializing a JavaScript date gives us a date with decimals 2021-07-08T09:10:09.000Z\n * which makes the XML request body invalid, these 2 functions serialize and deserialize the\n * dates so that they are in the expected format\n */\nexport function serializeSignedIdentifiers(\n signedIdentifiers: SignedIdentifier[],\n): GeneratedSignedIdentifier[] {\n return signedIdentifiers.map((acl) => {\n const { id, accessPolicy } = acl;\n const { start, expiry, ...rest } = accessPolicy ?? {};\n const serializedStart = start\n ? truncatedISO8061Date(start, false /** withMilliseconds */)\n : undefined;\n const serializedExpiry = expiry\n ? truncatedISO8061Date(expiry, false /** withMilliseconds */)\n : undefined;\n\n return {\n id,\n accessPolicy: {\n ...(serializedExpiry && { expiry: serializedExpiry }),\n ...(serializedStart && { start: serializedStart }),\n ...rest,\n },\n };\n });\n}\n\nexport function deserializeSignedIdentifier(\n signedIdentifiers: GeneratedSignedIdentifier[],\n): SignedIdentifier[] {\n return signedIdentifiers.map((si) => {\n const { id, accessPolicy } = si;\n const { start, expiry, ...restAcl } = accessPolicy ?? {};\n const deserializedStart = start ? new Date(start) : undefined;\n const deserializedExpiry = expiry ? new Date(expiry) : undefined;\n\n return {\n id,\n accessPolicy: {\n ...(deserializedExpiry && { expiry: deserializedExpiry }),\n ...(deserializedStart && { start: deserializedStart }),\n ...restAcl,\n },\n };\n });\n}\n\nexport function serializeQueryOptions(query: TableEntityQueryOptions): GeneratedQueryOptions {\n const { select, ...queryOptions } = query;\n const mappedQuery: GeneratedQueryOptions = { ...queryOptions };\n // Properties that are always returned by the service but are not allowed in select\n const excludeFromSelect = [\"etag\", \"odata.etag\"];\n if (select) {\n mappedQuery.select = select\n .filter((p) => !excludeFromSelect.includes(p))\n .map(translatePropertyNameForSerialization)\n .join(\",\");\n }\n return mappedQuery;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/serialization.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAOlC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CA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Identifier, TableEntityQueryOptions } from \"./models\";\nimport {\n QueryOptions as GeneratedQueryOptions,\n SignedIdentifier as GeneratedSignedIdentifier,\n} from \"./generated/models\";\nimport { base64Decode, base64Encode } from \"./utils/bufferSerializer\";\nimport { truncatedISO8061Date } from \"./utils/truncateISO8061Date\";\n\nconst propertyCaseMap: Map<string, string> = new Map<string, string>([\n [\"PartitionKey\", \"partitionKey\"],\n [\"RowKey\", \"rowKey\"],\n [\"odata.etag\", \"etag\"],\n [\"Timestamp\", \"timestamp\"],\n]);\n\nconst Edm = {\n Binary: \"Edm.Binary\",\n Boolean: \"Edm.Boolean\",\n DateTime: \"Edm.DateTime\",\n Double: \"Edm.Double\",\n Guid: \"Edm.Guid\",\n Int32: \"Edm.Int32\",\n Int64: \"Edm.Int64\",\n String: \"Edm.String\",\n} as const;\n\ntype supportedTypes = boolean | string | number | Date | Uint8Array | bigint;\n\ntype serializedType = {\n value: supportedTypes;\n type?: string;\n};\n\nfunction serializePrimitive(value: any): serializedType {\n const serializedValue: serializedType = { value };\n if (\n value === undefined ||\n value === null ||\n typeof value === \"boolean\" ||\n typeof value === \"string\" ||\n typeof value === \"number\"\n ) {\n serializedValue.value = value;\n } else if (typeof value === \"bigint\") {\n serializedValue.value = value.toString();\n serializedValue.type = Edm.Int64;\n } else if (value instanceof Date) {\n serializedValue.value = value;\n serializedValue.type = Edm.DateTime;\n } else if (value instanceof Uint8Array) {\n serializedValue.value = base64Encode(value);\n serializedValue.type = Edm.Binary;\n } else {\n throw new Error(`Unknown EDM type ${typeof value}`);\n }\n\n return serializedValue;\n}\n\nfunction serializeObject(obj: { value: any; type: EdmTypes }): serializedType {\n const serializedValue: serializedType = { value: obj.value };\n if (\n obj.type === \"Boolean\" ||\n obj.type === \"DateTime\" ||\n obj.type === \"Double\" ||\n obj.type === \"Guid\" ||\n obj.type === \"Int32\" ||\n obj.type === \"Int64\" ||\n obj.type === \"String\" ||\n obj.type === \"Binary\"\n ) {\n serializedValue.value = obj.value;\n serializedValue.type = Edm[obj.type];\n } else {\n throw new Error(`Unknown EDM type ${typeof obj.value}`);\n }\n\n return serializedValue;\n}\n\nfunction getSerializedValue(value: any): serializedType {\n if (typeof value === \"object\" && value?.value !== undefined && value?.type !== undefined) {\n return serializeObject(value);\n } else {\n return serializePrimitive(value);\n }\n}\n\nfunction translatePropertyNameForSerialization(propertyName: string): string {\n for (const [original, internal] of propertyCaseMap) {\n if (internal === propertyName) {\n return original;\n }\n }\n\n return propertyName;\n}\n\nexport function serialize(obj: object): Record<string, Record<string, unknown>> {\n const serialized: any = {};\n for (const [propertyName, propertyValue] of Object.entries(obj)) {\n const transformedKey = translatePropertyNameForSerialization(propertyName);\n const serializedVal = getSerializedValue(propertyValue);\n serialized[transformedKey] = serializedVal.value;\n if (serializedVal.type) {\n serialized[`${transformedKey}@odata.type`] = serializedVal.type;\n }\n }\n return serialized;\n}\n\nfunction getTypedObject(value: any, type: string, disableTypeConversion: boolean): any {\n switch (type) {\n case Edm.Boolean:\n return disableTypeConversion ? { value, type: \"Boolean\" } : value;\n case Edm.Double:\n return disableTypeConversion ? { value, type: \"Double\" } : value;\n case Edm.Int32:\n return disableTypeConversion ? { value, type: \"Int32\" } : value;\n case Edm.String:\n return disableTypeConversion ? { value, type: \"String\" } : value;\n case Edm.DateTime:\n return disableTypeConversion ? { value, type: \"DateTime\" } : new Date(value);\n case Edm.Int64:\n return disableTypeConversion ? { value, type: \"Int64\" } : BigInt(value);\n case Edm.Guid:\n return { value, type: \"Guid\" };\n case Edm.Binary:\n return disableTypeConversion ? { value, type: \"Binary\" } : base64Decode(value);\n default:\n throw new Error(`Unknown EDM type ${type}`);\n }\n}\n\nexport function deserialize<T extends object = Record<string, any>>(\n obj: object,\n disableTypeConversion: boolean = false,\n): T {\n const deserialized: any = {};\n for (const [key, value] of Object.entries(obj)) {\n if (key.indexOf(\"@odata.type\") === -1) {\n const transformedKey = propertyCaseMap.get(key) ?? key;\n let typedValue = value;\n if (`${key}@odata.type` in obj) {\n const type = (obj as any)[`${key}@odata.type`];\n typedValue = getTypedObject(value, type, disableTypeConversion);\n } else if (disableTypeConversion && [\"number\", \"string\", \"boolean\"].includes(typeof value)) {\n // The service, doesn't return type metadata for number, strings or booleans\n // if automatic type conversion is disabled we'll infer the EDM object\n typedValue = inferTypedObject(key, value);\n }\n\n deserialized[transformedKey] = typedValue;\n }\n }\n return deserialized;\n}\n\nfunction inferTypedObject(propertyName: string, value: number | string | boolean) {\n // We need to skip service metadata fields such as partitionKey and rowKey and use the same value returned by the service\n if (propertyCaseMap.has(propertyName)) {\n return value;\n }\n\n switch (typeof value) {\n case \"boolean\":\n return { value: String(value), type: \"Boolean\" };\n case \"number\":\n return getTypedNumber(value);\n case \"string\":\n return { value, type: \"String\" };\n default:\n return value;\n }\n}\n\n/**\n * Returns the number when typeConversion is enabled or the EDM object with the correct number format Double or Int32 if disabled\n */\nfunction getTypedNumber(value: number): { value: string; type: \"Int32\" | \"Double\" } {\n const valueStr = String(value);\n if (Number.isSafeInteger(value)) {\n return { value: valueStr, type: \"Int32\" };\n } else {\n return { value: valueStr, type: \"Double\" };\n }\n}\n\nexport function deserializeObjectsArray<T extends object>(\n objArray: object[],\n disableTypeConversion: boolean,\n): T[] {\n return objArray.map((obj) => deserialize<T>(obj, disableTypeConversion));\n}\n\n/**\n * For ACL endpoints the Tables Service takes an ISO Date without decimals however\n * serializing a JavaScript date gives us a date with decimals 2021-07-08T09:10:09.000Z\n * which makes the XML request body invalid, these 2 functions serialize and deserialize the\n * dates so that they are in the expected format\n */\nexport function serializeSignedIdentifiers(\n signedIdentifiers: SignedIdentifier[],\n): GeneratedSignedIdentifier[] {\n return signedIdentifiers.map((acl) => {\n const { id, accessPolicy } = acl;\n const { start, expiry, ...rest } = accessPolicy ?? {};\n const serializedStart = start\n ? truncatedISO8061Date(start, false /** withMilliseconds */)\n : undefined;\n const serializedExpiry = expiry\n ? truncatedISO8061Date(expiry, false /** withMilliseconds */)\n : undefined;\n\n return {\n id,\n accessPolicy: {\n ...(serializedExpiry && { expiry: serializedExpiry }),\n ...(serializedStart && { start: serializedStart }),\n ...rest,\n },\n };\n });\n}\n\nexport function deserializeSignedIdentifier(\n signedIdentifiers: GeneratedSignedIdentifier[],\n): SignedIdentifier[] {\n return signedIdentifiers.map((si) => {\n const { id, accessPolicy } = si;\n const { start, expiry, ...restAcl } = accessPolicy ?? {};\n const deserializedStart = start ? new Date(start) : undefined;\n const deserializedExpiry = expiry ? new Date(expiry) : undefined;\n\n return {\n id,\n accessPolicy: {\n ...(deserializedExpiry && { expiry: deserializedExpiry }),\n ...(deserializedStart && { start: deserializedStart }),\n ...restAcl,\n },\n };\n });\n}\n\nexport function serializeQueryOptions(query: TableEntityQueryOptions): GeneratedQueryOptions {\n const { select, ...queryOptions } = query;\n const mappedQuery: GeneratedQueryOptions = { ...queryOptions };\n // Properties that are always returned by the service but are not allowed in select\n const excludeFromSelect = [\"etag\", \"odata.etag\"];\n if (select) {\n mappedQuery.select = select\n .filter((p) => !excludeFromSelect.includes(p))\n .map(translatePropertyNameForSerialization)\n .join(\",\");\n }\n return mappedQuery;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tablesNamedCredentialPolicy.js","sourceRoot":"","sources":["../../src/tablesNamedCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,gCAAgC,CAAC;AAEnF;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAAC,UAA8B;IAC3E,SAAS,WAAW,CAAC,OAAwB;QAC3C,MAAM,WAAW,GAAG,sBAAsB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAChE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,aAAa,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,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC;IACjC,IAAI,2BAA2B,GAAG,GAAG,GAAG,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;IAE/D,sKAAsK;IACtK,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE1C,IAAI,IAAI,EAAE,CAAC;QACT,2BAA2B,GAAG,GAAG,2BAA2B,SAAS,IAAI,EAAE,CAAC;IAC9E,CAAC;IAED,OAAO,2BAA2B,CAAC;AACrC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { HeaderConstants } from \"./utils/constants\";\nimport { NamedKeyCredential } from \"@azure/core-auth\";\nimport { computeHMACSHA256 } from \"./utils/computeHMACSHA256\";\n\n/**\n * The programmatic identifier of the tablesNamedKeyCredentialPolicy.\n */\nexport const tablesNamedKeyCredentialPolicyName = \"tablesNamedKeyCredentialPolicy\";\n\n/**\n * tablesNamedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key.\n */\nexport function tablesNamedKeyCredentialPolicy(credential: NamedKeyCredential): PipelinePolicy {\n function signRequest(request: PipelineRequest): void {\n const headerValue = getAuthorizationHeader(request, credential);\n request.headers.set(HeaderConstants.AUTHORIZATION, headerValue);\n }\n\n return {\n name: tablesNamedKeyCredentialPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n signRequest(request);\n return next(request);\n },\n };\n}\n\nexport function getAuthorizationHeader(\n request: PipelineRequest,\n credential: NamedKeyCredential,\n): string {\n if (!request.headers.has(HeaderConstants.X_MS_DATE)) {\n request.headers.set(HeaderConstants.X_MS_DATE, new Date().toUTCString());\n }\n\n if (request.body && typeof request.body === \"string\" && request.body.length > 0) {\n request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));\n }\n\n // If x-ms-date is present, use it otherwise date\n const dateHeader = getHeaderValueToSign(request, HeaderConstants.X_MS_DATE);\n\n if (!dateHeader) {\n throw new Error(\"Failed to sign request: x-ms-date or date header must be present\");\n }\n\n const stringToSign: string = [\n dateHeader,\n getCanonicalizedResourceString(request, credential),\n ].join(\"\\n\");\n\n const signature = computeHMACSHA256(stringToSign, credential.key);\n\n return `SharedKeyLite ${credential.name}:${signature}`;\n}\n\nfunction getHeaderValueToSign(request: PipelineRequest, headerName: string): string {\n const value = request.headers.get(headerName);\n\n if (!value) {\n return \"\";\n }\n return value;\n}\n\nfunction getCanonicalizedResourceString(\n request: PipelineRequest,\n credential: NamedKeyCredential,\n): string {\n // https://docs.microsoft.com/rest/api/storageservices/authorize-with-shared-key#shared-key-lite-and-table-service-format-for-2009-09-19-and-later\n const url = new URL(request.url);\n const path = url.pathname || \"/\";\n let canonicalizedResourceString = \"/\" + credential.name + path;\n\n // The query string should include the question mark and the comp parameter (for example, ?comp=metadata). No other parameters should be included on the query string.\n const comp = url.searchParams.get(\"comp\");\n\n if (comp) {\n canonicalizedResourceString = `${canonicalizedResourceString}?comp=${comp}`;\n }\n\n return canonicalizedResourceString;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tablesSASTokenPolicy.js","sourceRoot":"","sources":["../../src/tablesSASTokenPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAyB;IAC5D,OAAO;QACL,IAAI,EAAE,wBAAwB;QAC9B,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACpC,O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copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { SASCredential } from \"@azure/core-auth\";\n\n/**\n * The programmatic identifier of the tablesSASTokenPolicy.\n */\nexport const tablesSASTokenPolicyName = \"tablesSASTokenPolicy\";\n\n/**\n * tablesSASTokenPolicy is a policy used to sign HTTP request with a shared key.\n */\nexport function tablesSASTokenPolicy(credential: SASCredential): PipelinePolicy {\n return {\n name: tablesSASTokenPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n signURLWithSAS(request, credential);\n return next(request);\n },\n };\n}\n\nexport function signURLWithSAS(request: PipelineRequest, credential: SASCredential): void {\n const sasParams = new URLSearchParams(credential.signature);\n const url = new URL(request.url);\n\n for (const [name, value] of sasParams) {\n url.searchParams.append(name, value);\n }\n request.url = url.toString();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountConnectionString.js","sourceRoot":"","sources":["../../../src/utils/accountConnectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAG3D;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,cAAgC,EAChC,UAAqC,EAAE;IAEvC,MAAM,mBAAmB,GAAG,IAAI,uBAAuB,CACrD,cAAc,CAAC,WAAY,EAC3B,cAAc,CAAC,UAAU,CAC1B,CAAC;IAEF,OAAO;QACL,GAAG,EAAE,cAAc,CAAC,GAAG;QACvB,OAAO;QACP,UAAU,EAAE,mBAAmB;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,WAAmB,EACnB,UAAkB,EAClB,wBAAgC,EAChC,cAAuB,EACvB,aAAsB;IAEtB,IAAI,CAAC,aAAa,EAAE;
|
|
1
|
+
{"version":3,"file":"accountConnect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;QAClB,WAAW;QACX,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientParamsFromConnectionString, ConnectionString } from \"./internalModels\";\nimport { AzureNamedKeyCredential } from \"@azure/core-auth\";\nimport { TableServiceClientOptions } from \"..\";\n\n/**\n * Gets client parameters from an Account Connection String\n * Only supported in Node.js not supported for Browsers\n * @param extractedCreds - parsed connection string\n * @param options - TablesServiceClient options\n */\nexport function fromAccountConnectionString(\n extractedCreds: ConnectionString,\n options: TableServiceClientOptions = {},\n): ClientParamsFromConnectionString {\n const sharedKeyCredential = new AzureNamedKeyCredential(\n extractedCreds.accountName!,\n extractedCreds.accountKey,\n );\n\n return {\n url: extractedCreds.url,\n options,\n credential: sharedKeyCredential,\n };\n}\n\nexport function getAccountConnectionString(\n accountName: string,\n accountKey: string,\n defaultEndpointsProtocol: string,\n endpointSuffix?: string,\n tableEndpoint?: string,\n): ConnectionString {\n if (!tableEndpoint) {\n // TableEndpoint is not present in the Account connection string\n // Can be obtained from `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`\n const protocol = defaultEndpointsProtocol.toLowerCase();\n if (protocol !== \"https\" && protocol !== \"http\") {\n throw new Error(\n \"Invalid DefaultEndpointsProtocol in the provided Connection String. Expecting 'https' or 'http'\",\n );\n }\n if (!endpointSuffix) {\n throw new Error(\"Invalid EndpointSuffix in the provided Connection String\");\n }\n tableEndpoint = `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`;\n }\n\n if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided Connection String\");\n } else if (accountKey.length === 0) {\n throw new Error(\"Invalid AccountKey in the provided Connection String\");\n }\n\n return {\n kind: \"AccountConnString\",\n url: tableEndpoint,\n accountName,\n accountKey,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferSerializer.browser.js","sourceRoot":"","sources":["../../../src/utils/bufferSerializer.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAA0B;IACrD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"bufferSerializer.browser.js","sourceRoot":"","sources":["../../../src/utils/bufferSerializer.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAA0B;IACrD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,GAAG,GAAG,KAAK,CAAC;IACd,CAAC;SAAM,CAAC;QACN,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,SAAS,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Encodes a byte array in base64 format.\n * @param value - The Uint8Aray or string to encode\n */\nexport function base64Encode(value: Uint8Array | string): string {\n let str = \"\";\n if (typeof value === \"string\") {\n str = value;\n } else {\n for (let i = 0; i < value.length; i++) {\n str += String.fromCharCode(value[i]);\n }\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 */\nexport function base64Decode(value: string): Uint8Array {\n const byteString = atob(value);\n const byteArray = new Uint8Array(byteString.length);\n for (let i = 0; i < byteString.length; i++) {\n byteArray[i] = byteString.charCodeAt(i);\n }\n return byteArray;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferSerializer.js","sourceRoot":"","sources":["../../../src/utils/bufferSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAA0B;IACrD,IAAI,KAAK,YAAY,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"bufferSerializer.js","sourceRoot":"","sources":["../../../src/utils/bufferSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAA0B;IACrD,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,MAAM,WAAW,GAAG,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAChF,OAAO,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Encodes a byte array in base64 format.\n * @param value - The Uint8Aray or string to encode\n */\nexport function base64Encode(value: Uint8Array | string): string {\n if (value instanceof Uint8Array) {\n const bufferValue = value instanceof Buffer ? value : Buffer.from(value.buffer);\n return bufferValue.toString(\"base64\");\n } else {\n return Buffer.from(value).toString(\"base64\");\n }\n}\n\n/**\n * Decodes a base64 string into a byte array.\n * @param value - The base64 string to decode\n */\nexport function base64Decode(value: string): Uint8Array {\n return Buffer.from(value, \"base64\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionString.js","sourceRoot":"","sources":["../../../src/utils/connectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAIpG,MAAM,2BAA2B,GAC/B,sNAAsN,CAAC;AAEzN;;;;;;;;;GASG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAAwB,EACxB,UAAqC,EAAE;IAEvC,IAAI,gBAAgB,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/E,gBAAgB,GAAG,2BAA2B,CAAC;QAC/C,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;KACxC;IACD,MAAM,cAAc,GAAG,4BAA4B,CAAC,gBAAgB,CAAC,CAAC;IACtE,IAAI,cAAc,CAAC,IAAI,KAAK,mBAAmB,EAAE;QAC/C,OAAO,2BAA2B,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;KAC7D;SAAM,IAAI,cAAc,CAAC,IAAI,KAAK,eAAe,EAAE;QAClD,OAAO;YACL,GAAG,EAAE,GAAG,cAAc,CAAC,GAAG,IAAI,cAAc,CAAC,UAAU,EAAE;YACzD,OAAO;SACR,CAAC;KACH;SAAM;QAC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["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientParamsFromConnectionString, ConnectionString } from \"./internalModels\";\nimport { fromAccountConnectionString, getAccountConnectionString } from \"./accountConnectionString\";\n\nimport { TableServiceClientOptions } from \"../models\";\n\nconst DevelopmentConnectionString =\n \"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1\";\n\n/**\n * This function parses a connection string into a set of\n * parameters to pass to be passed to TableClientService,\n * depending on the connection string type these parameter would\n * contain:\n * - Account Connection String: A pipeline to sign the request with a SharedKey\n * - SAS Connection String: Attach a SAS token to the storage account url for authentication\n * @param connectionString - Connection string to parse\n * @param options - TableService client options\n */\nexport function getClientParamsFromConnectionString(\n connectionString: string,\n options: TableServiceClientOptions = {},\n): ClientParamsFromConnectionString {\n if (connectionString.toLowerCase().indexOf(\"usedevelopmentstorage=true\") !== -1) {\n connectionString = DevelopmentConnectionString;\n options.allowInsecureConnection = true;\n }\n const extractedCreds = extractConnectionStringParts(connectionString);\n if (extractedCreds.kind === \"AccountConnString\") {\n return fromAccountConnectionString(extractedCreds, options);\n } else if (extractedCreds.kind === \"SASConnString\") {\n return {\n url: `${extractedCreds.url}?${extractedCreds.accountSas}`,\n options,\n };\n } else {\n throw new Error(\n \"Connection string must be either an Account connection string or a SAS connection string\",\n );\n }\n}\n\n/**\n * Extracts the parts of an Storage account connection string.\n *\n * @param connectionString - Connection string.\n * @returns String key value pairs of the storage account's url and credentials.\n */\nexport function extractConnectionStringParts(connectionString: string): ConnectionString {\n // Matching TableEndpoint in the Account connection string\n let tableEndpoint = getValueInConnString(connectionString, \"TableEndpoint\");\n // Slicing off '/' at the end if exists\n // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)\n tableEndpoint = tableEndpoint.endsWith(\"/\") ? tableEndpoint.slice(0, -1) : tableEndpoint;\n\n if (isAccountConnectionString(connectionString)) {\n return getAccountConnectionString(\n getValueInConnString(connectionString, \"AccountName\"),\n getValueInConnString(connectionString, \"AccountKey\"),\n getValueInConnString(connectionString, \"DefaultEndpointsProtocol\"),\n getValueInConnString(connectionString, \"EndpointSuffix\"),\n tableEndpoint,\n );\n } else {\n return getSASConnectionString(connectionString, tableEndpoint);\n }\n}\n\n/**\n * Checks whether a connection string is an Account Connection string or not\n */\nfunction isAccountConnectionString(connectionString: string) {\n const lowercaseConnectionString = connectionString.toLowerCase();\n return (\n lowercaseConnectionString.search(\"defaultendpointsprotocol=\") !== -1 &&\n lowercaseConnectionString.search(\"accountkey=\") !== -1\n );\n}\n\nfunction getSASConnectionString(connectionString: string, tableEndpoint: string): ConnectionString {\n const accountName = getAccountNameFromUrl(tableEndpoint);\n const accountSas = getValueInConnString(connectionString, \"SharedAccessSignature\");\n if (!tableEndpoint) {\n throw new Error(\"Invalid TableEndpoint in the provided SAS Connection String\");\n } else if (!accountSas) {\n throw new Error(\"Invalid SharedAccessSignature in the provided SAS Connection String\");\n } else if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided SAS Connection String\");\n }\n\n return { kind: \"SASConnString\", url: tableEndpoint, accountName, accountSas };\n}\n\nfunction getValueInConnString(\n connectionString: string,\n argument:\n | \"TableEndpoint\"\n | \"AccountName\"\n | \"AccountKey\"\n | \"DefaultEndpointsProtocol\"\n | \"EndpointSuffix\"\n | \"SharedAccessSignature\",\n): string {\n const searchKey = argument.toLowerCase();\n const elements = connectionString.split(\";\").filter((e) => Boolean(e));\n for (const element of elements) {\n const trimmedElement = element.trim();\n const [elementKey, value] = getValuePair(trimmedElement);\n const key = elementKey.toLowerCase();\n if (key === searchKey) {\n return value;\n }\n }\n return \"\";\n}\n\nfunction getValuePair(kvp: string): string[] {\n // If the string is not in kvp format <key>=<valye> return an empty array\n if (!kvp || kvp.indexOf(\"=\") === -1) {\n return [];\n }\n // Get the substring before the first '='\n const key = kvp.substr(0, kvp.indexOf(\"=\"));\n // Get the substring after the first '='\n const value = kvp.substr(kvp.indexOf(\"=\") + 1);\n\n return [key, value];\n}\n\n/**\n * Extracts account name from the url\n * @param url - URL to extract the account name from\n * @returns The account name\n */\nfunction getAccountNameFromUrl(url: string): string {\n if (!url) {\n return url;\n }\n\n const parsedUrl = new URL(url);\n let accountName;\n\n const host = parsedUrl.host || \"\";\n const path = parsedUrl.pathname || \"\";\n const hostParts = host.split(\".\");\n const pathParts = path.split(\"/\");\n\n if (hostParts.length >= 1 && hostParts[1] === \"table\") {\n // `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`;\n // Slicing off '/' at the end if exists\n url = url.endsWith(\"/\") ? url.slice(0, -1) : url;\n accountName = host.split(\".\")[0];\n } else if (pathParts.length >= 1) {\n // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/\n // .getPath() -> /devstoreaccount1/\n accountName = pathParts[1];\n } else {\n throw new Error(\"Unable to extract accountName with provided information.\");\n }\n\n return accountName;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"connectionString.js","sourceRoot":"","sources":["../../../src/utils/connectionString.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAIpG,MAAM,2BAA2B,GAC/B,sNAAsN,CAAC;AAEzN;;;;;;;;;GASG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAAwB,EACxB,UAAqC,EAAE;IAEvC,IAAI,gBAAgB,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAChF,gBAAgB,GAAG,2BAA2B,CAAC;QAC/C,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC;IACzC,CAAC;IACD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AAG,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QACjD,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;SAAM,IAAI,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACjC,iFAAiF;QACjF,2GAA2G;QAC3G,mCAAmC;QACnC,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ClientParamsFromConnectionString, ConnectionString } from \"./internalModels\";\nimport { fromAccountConnectionString, getAccountConnectionString } from \"./accountConnectionString\";\n\nimport { TableServiceClientOptions } from \"../models\";\n\nconst DevelopmentConnectionString =\n \"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1\";\n\n/**\n * This function parses a connection string into a set of\n * parameters to pass to be passed to TableClientService,\n * depending on the connection string type these parameter would\n * contain:\n * - Account Connection String: A pipeline to sign the request with a SharedKey\n * - SAS Connection String: Attach a SAS token to the storage account url for authentication\n * @param connectionString - Connection string to parse\n * @param options - TableService client options\n */\nexport function getClientParamsFromConnectionString(\n connectionString: string,\n options: TableServiceClientOptions = {},\n): ClientParamsFromConnectionString {\n if (connectionString.toLowerCase().indexOf(\"usedevelopmentstorage=true\") !== -1) {\n connectionString = DevelopmentConnectionString;\n options.allowInsecureConnection = true;\n }\n const extractedCreds = extractConnectionStringParts(connectionString);\n if (extractedCreds.kind === \"AccountConnString\") {\n return fromAccountConnectionString(extractedCreds, options);\n } else if (extractedCreds.kind === \"SASConnString\") {\n return {\n url: `${extractedCreds.url}?${extractedCreds.accountSas}`,\n options,\n };\n } else {\n throw new Error(\n \"Connection string must be either an Account connection string or a SAS connection string\",\n );\n }\n}\n\n/**\n * Extracts the parts of an Storage account connection string.\n *\n * @param connectionString - Connection string.\n * @returns String key value pairs of the storage account's url and credentials.\n */\nexport function extractConnectionStringParts(connectionString: string): ConnectionString {\n // Matching TableEndpoint in the Account connection string\n let tableEndpoint = getValueInConnString(connectionString, \"TableEndpoint\");\n // Slicing off '/' at the end if exists\n // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)\n tableEndpoint = tableEndpoint.endsWith(\"/\") ? tableEndpoint.slice(0, -1) : tableEndpoint;\n\n if (isAccountConnectionString(connectionString)) {\n return getAccountConnectionString(\n getValueInConnString(connectionString, \"AccountName\"),\n getValueInConnString(connectionString, \"AccountKey\"),\n getValueInConnString(connectionString, \"DefaultEndpointsProtocol\"),\n getValueInConnString(connectionString, \"EndpointSuffix\"),\n tableEndpoint,\n );\n } else {\n return getSASConnectionString(connectionString, tableEndpoint);\n }\n}\n\n/**\n * Checks whether a connection string is an Account Connection string or not\n */\nfunction isAccountConnectionString(connectionString: string) {\n const lowercaseConnectionString = connectionString.toLowerCase();\n return (\n lowercaseConnectionString.search(\"defaultendpointsprotocol=\") !== -1 &&\n lowercaseConnectionString.search(\"accountkey=\") !== -1\n );\n}\n\nfunction getSASConnectionString(connectionString: string, tableEndpoint: string): ConnectionString {\n const accountName = getAccountNameFromUrl(tableEndpoint);\n const accountSas = getValueInConnString(connectionString, \"SharedAccessSignature\");\n if (!tableEndpoint) {\n throw new Error(\"Invalid TableEndpoint in the provided SAS Connection String\");\n } else if (!accountSas) {\n throw new Error(\"Invalid SharedAccessSignature in the provided SAS Connection String\");\n } else if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided SAS Connection String\");\n }\n\n return { kind: \"SASConnString\", url: tableEndpoint, accountName, accountSas };\n}\n\nfunction getValueInConnString(\n connectionString: string,\n argument:\n | \"TableEndpoint\"\n | \"AccountName\"\n | \"AccountKey\"\n | \"DefaultEndpointsProtocol\"\n | \"EndpointSuffix\"\n | \"SharedAccessSignature\",\n): string {\n const searchKey = argument.toLowerCase();\n const elements = connectionString.split(\";\").filter((e) => Boolean(e));\n for (const element of elements) {\n const trimmedElement = element.trim();\n const [elementKey, value] = getValuePair(trimmedElement);\n const key = elementKey.toLowerCase();\n if (key === searchKey) {\n return value;\n }\n }\n return \"\";\n}\n\nfunction getValuePair(kvp: string): string[] {\n // If the string is not in kvp format <key>=<valye> return an empty array\n if (!kvp || kvp.indexOf(\"=\") === -1) {\n return [];\n }\n // Get the substring before the first '='\n const key = kvp.substr(0, kvp.indexOf(\"=\"));\n // Get the substring after the first '='\n const value = kvp.substr(kvp.indexOf(\"=\") + 1);\n\n return [key, value];\n}\n\n/**\n * Extracts account name from the url\n * @param url - URL to extract the account name from\n * @returns The account name\n */\nfunction getAccountNameFromUrl(url: string): string {\n if (!url) {\n return url;\n }\n\n const parsedUrl = new URL(url);\n let accountName;\n\n const host = parsedUrl.host || \"\";\n const path = parsedUrl.pathname || \"\";\n const hostParts = host.split(\".\");\n const pathParts = path.split(\"/\");\n\n if (hostParts.length >= 1 && hostParts[1] === \"table\") {\n // `${defaultEndpointsProtocol}://${accountName}.table.${endpointSuffix}`;\n // Slicing off '/' at the end if exists\n url = url.endsWith(\"/\") ? url.slice(0, -1) : url;\n accountName = host.split(\".\")[0];\n } else if (pathParts.length >= 1) {\n // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/\n // .getPath() -> /devstoreaccount1/\n accountName = pathParts[1];\n } else {\n throw new Error(\"Unable to extract accountName with provided information.\");\n }\n\n return accountName;\n}\n"]}
|