diff --git a/sdk/core/core-http/src/credentials/accessTokenRefresher.ts b/sdk/core/core-http/src/credentials/accessTokenRefresher.ts new file mode 100644 index 000000000000..a9a6a1271768 --- /dev/null +++ b/sdk/core/core-http/src/credentials/accessTokenRefresher.ts @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import { AccessToken, TokenCredential, GetTokenOptions } from "@azure/core-auth"; + +/** + * Helps the core-http token authentication policies with requesting a new token if we're not currently waiting for a new token. + */ +export class AccessTokenRefresher { + private promise: Promise | undefined; + private lastCalled = 0; + + constructor( + private credential: TokenCredential, + private scopes: string | string[], + private requiredMillisecondsBeforeNewRefresh: number = 30000 + ) {} + + public isReady(): boolean { + // We're only ready for a new refresh if the required milliseconds have passed. + return ( + !this.lastCalled || Date.now() - this.lastCalled > this.requiredMillisecondsBeforeNewRefresh + ); + } + + /** + * Stores the time in which it is called, + * then requests a new token, + * then sets this.promise to undefined, + * then returns the token. + * @param options getToken options + */ + private async getToken(options: GetTokenOptions): Promise { + this.lastCalled = Date.now(); + const token = await this.credential.getToken(this.scopes, options); + this.promise = undefined; + return token || undefined; + } + + /** + * Requests a new token if we're not currently waiting for a new token. + * Returns null if the required time between each call hasn't been reached. + * @param options getToken options + */ + public refresh(options: GetTokenOptions): Promise { + if (!this.promise) { + this.promise = this.getToken(options); + } + + return this.promise; + } +} diff --git a/sdk/core/core-http/src/nodeFetchHttpClient.ts b/sdk/core/core-http/src/nodeFetchHttpClient.ts index 8ba1d06566ea..6a2e0f4a1e3a 100644 --- a/sdk/core/core-http/src/nodeFetchHttpClient.ts +++ b/sdk/core/core-http/src/nodeFetchHttpClient.ts @@ -84,7 +84,7 @@ export class NodeFetchHttpClient extends FetchHttpClient { // eslint-disable-next-line @azure/azure-sdk/ts-apisurface-standardized-verbs async fetch(input: CommonRequestInfo, init?: CommonRequestInit): Promise { - return node_fetch(input, init) as unknown as Promise; + return (node_fetch(input, init) as unknown) as Promise; } async prepareRequest(httpRequest: WebResourceLike): Promise> { diff --git a/sdk/core/core-http/src/policies/bearerTokenAuthenticationPolicy.ts b/sdk/core/core-http/src/policies/bearerTokenAuthenticationPolicy.ts index 8a99c76a2096..9b038280f0b7 100644 --- a/sdk/core/core-http/src/policies/bearerTokenAuthenticationPolicy.ts +++ b/sdk/core/core-http/src/policies/bearerTokenAuthenticationPolicy.ts @@ -13,6 +13,7 @@ import { HttpOperationResponse } from "../httpOperationResponse"; import { HttpHeaders } from "../httpHeaders"; import { WebResourceLike } from "../webResource"; import { AccessTokenCache, ExpiringAccessTokenCache } from "../credentials/accessTokenCache"; +import { AccessTokenRefresher } from "../credentials/accessTokenRefresher"; /** * Creates a new BearerTokenAuthenticationPolicy factory. @@ -38,6 +39,13 @@ export function bearerTokenAuthenticationPolicy( }; } +/** + * The automated token refresh will only start to happen at the + * expiration date minus the value of timeBetweenRefreshAttemptsInMs, + * which is by default 30 seconds. + */ +const timeBetweenRefreshAttemptsInMs = 30000; + /** * * Provides a RequestPolicy that can request a token from a TokenCredential @@ -46,6 +54,8 @@ export function bearerTokenAuthenticationPolicy( * */ export class BearerTokenAuthenticationPolicy extends BaseRequestPolicy { + private tokenRefresher: AccessTokenRefresher; + /** * Creates a new BearerTokenAuthenticationPolicy object. * @@ -63,6 +73,11 @@ export class BearerTokenAuthenticationPolicy extends BaseRequestPolicy { private tokenCache: AccessTokenCache ) { super(nextPolicy, options); + this.tokenRefresher = new AccessTokenRefresher( + this.credential, + this.scopes, + timeBetweenRefreshAttemptsInMs + ); } /** @@ -81,11 +96,27 @@ export class BearerTokenAuthenticationPolicy extends BaseRequestPolicy { return this._nextPolicy.sendRequest(webResource); } + /** + * Attempts a token update if any other time related conditionals have been reached based on the tokenRefresher class. + */ + private async updateTokenIfNeeded(options: GetTokenOptions): Promise { + if (this.tokenRefresher.isReady()) { + const accessToken = await this.tokenRefresher.refresh(options); + this.tokenCache.setCachedToken(accessToken); + } + } + private async getToken(options: GetTokenOptions): Promise { let accessToken = this.tokenCache.getCachedToken(); if (accessToken === undefined) { - accessToken = (await this.credential.getToken(this.scopes, options)) || undefined; - this.tokenCache.setCachedToken(accessToken); + // Waiting for the next refresh only if the cache is unable to retrieve the access token, + // which means that it has expired, or it has never been set. + accessToken = await this.tokenRefresher.refresh(options); + } else { + // If we still have a cached access token, + // And any other time related conditionals have been reached based on the tokenRefresher class, + // then attempt to refresh without waiting. + this.updateTokenIfNeeded(options); } return accessToken ? accessToken.token : undefined; diff --git a/sdk/core/core-http/test/policies/bearerTokenAuthenticationPolicyTests.ts b/sdk/core/core-http/test/policies/bearerTokenAuthenticationPolicyTests.ts index 9df960596703..9c5d3dcf5970 100644 --- a/sdk/core/core-http/test/policies/bearerTokenAuthenticationPolicyTests.ts +++ b/sdk/core/core-http/test/policies/bearerTokenAuthenticationPolicyTests.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { fake } from "sinon"; +import { fake, createSandbox } from "sinon"; import { OperationSpec } from "../../src/operationSpec"; import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-auth"; import { RequestPolicy, RequestPolicyOptions } from "../../src/policies/requestPolicy"; @@ -15,6 +15,7 @@ import { ExpiringAccessTokenCache, TokenRefreshBufferMs } from "../../src/credentials/accessTokenCache"; +import { AccessTokenRefresher } from "../../src/credentials/accessTokenRefresher"; describe("BearerTokenAuthenticationPolicy", function() { const mockPolicy: RequestPolicy = { @@ -61,7 +62,7 @@ describe("BearerTokenAuthenticationPolicy", function() { const credentialsToTest: [MockRefreshAzureCredential, number][] = [ [refreshCred1, 2], [refreshCred2, 2], - [notRefreshCred1, 1] + [notRefreshCred1, 2] ]; const request = createRequest(); @@ -73,6 +74,20 @@ describe("BearerTokenAuthenticationPolicy", function() { } }); + it("tests that AccessTokenRefresher is working", async function() { + const now = Date.now(); + const credentialToTest = new MockRefreshAzureCredential(now); + const request = createRequest(); + const policy = createBearerTokenPolicy("testscope", credentialToTest); + await policy.sendRequest(request); + + const sandbox = createSandbox(); + sandbox.replace(AccessTokenRefresher.prototype, "isReady", () => true); + await policy.sendRequest(request); + sandbox.restore(); + assert.strictEqual(credentialToTest.authCount, 2); + }); + function createRequest(operationSpec?: OperationSpec): WebResource { const request = new WebResource(); request.operationSpec = operationSpec; diff --git a/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_content_from_a_pdf_file_stream.js b/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_content_from_a_pdf_file_stream.js index 5e6182674b19..fb78cf7ca8c1 100644 --- a/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_content_from_a_pdf_file_stream.js +++ b/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_content_from_a_pdf_file_stream.js @@ -1,6 +1,6 @@ let nock = require('nock'); -module.exports.hash = "64850fe36298fc7618a36c97201a10eb"; +module.exports.hash = "c43ab86e3dd829322e1e665b57502496"; module.exports.testInfo = {"uniqueName":{},"newDate":{}} @@ -8,9 +8,11 @@ nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ 'Cache-Control', - 'no-cache, no-store', + 'no-store, no-cache', 'Pragma', 'no-cache', + 'Content-Length', + '1417', 'Content-Type', 'application/json; charset=utf-8', 'Expires', @@ -19,22 +21,20 @@ nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) 'max-age=31536000; includeSubDomains', 'X-Content-Type-Options', 'nosniff', - 'x-ms-request-id', - 'a047a00e-efb4-4aa7-9008-7f69a18a0e00', - 'x-ms-ests-server', - '2.1.10922.14 - WUS2 ProdSlices', 'P3P', 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'acb03e10-4b72-4dfa-a62d-22eb441de300', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', 'Set-Cookie', - 'fpc=AolBG49wEXRCl5I3Blpq7nz0CyfMAQAAALI3vdYOAAAA; expires=Fri, 04-Sep-2020 23:28:50 GMT; path=/; secure; HttpOnly; SameSite=None', + 'fpc=ArO2WTcpeg1GnfeEdRg80MD0CyfMAQAAAOOtx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:48 GMT; path=/; secure; HttpOnly; SameSite=None', 'Set-Cookie', - 'x-ms-gateway-slice=prod; path=/; SameSite=None; secure; HttpOnly', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', 'Set-Cookie', - 'stsservicecookie=ests; path=/; SameSite=None; secure; HttpOnly', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', 'Date', - 'Wed, 05 Aug 2020 23:28:50 GMT', - 'Content-Length', - '1417' + 'Thu, 13 Aug 2020 21:55:47 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) @@ -43,72 +43,171 @@ nock('https://endpoint:443', {"encodedQueryParams":true}) 'Content-Length', '0', 'Operation-Location', - 'https://endpoint/formrecognizer/v2.0/layout/analyzeResults/0964a1b9-933f-4879-b34f-cf63fa27a0cd', + 'https://endpoint/formrecognizer/v2.0/layout/analyzeResults/ee285799-d612-4faa-be3e-618d86c47f52', 'x-envoy-upstream-service-time', - '64', + '63', 'apim-request-id', - '0964a1b9-933f-4879-b34f-cf63fa27a0cd', + 'ee285799-d612-4faa-be3e-618d86c47f52', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:28:51 GMT' + 'Thu, 13 Aug 2020 21:55:47 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Length', + '1417', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'be1ef2b6-1ba4-4a61-ad35-636455343701', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=ArO2WTcpeg1GnfeEdRg80MD0CyfMAgAAAOOtx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:48 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:55:48 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/layout/analyzeResults/0964a1b9-933f-4879-b34f-cf63fa27a0cd') - .reply(200, {"status":"running","createdDateTime":"2020-08-05T23:28:51Z","lastUpdatedDateTime":"2020-08-05T23:28:51Z"}, [ + .get('/formrecognizer/v2.0/layout/analyzeResults/ee285799-d612-4faa-be3e-618d86c47f52') + .reply(200, {"status":"running","createdDateTime":"2020-08-13T21:55:48Z","lastUpdatedDateTime":"2020-08-13T21:55:48Z"}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '14', + '10', 'apim-request-id', - 'e912d447-9a16-4ece-bca3-7311228a3062', + '2a118004-8dcb-4877-8f67-beb5b3885574', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:28:51 GMT' + 'Thu, 13 Aug 2020 21:55:47 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Length', + '1417', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'bfe1f865-96dc-46dd-9672-6cbacb853601', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=ArO2WTcpeg1GnfeEdRg80MD0CyfMAwAAAOOtx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:48 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:55:48 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/layout/analyzeResults/0964a1b9-933f-4879-b34f-cf63fa27a0cd') - .reply(200, {"status":"running","createdDateTime":"2020-08-05T23:28:51Z","lastUpdatedDateTime":"2020-08-05T23:28:51Z"}, [ + .get('/formrecognizer/v2.0/layout/analyzeResults/ee285799-d612-4faa-be3e-618d86c47f52') + .reply(200, {"status":"running","createdDateTime":"2020-08-13T21:55:48Z","lastUpdatedDateTime":"2020-08-13T21:55:48Z"}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '26', + '11', 'apim-request-id', - 'b6f7fcba-7a69-4b53-ade8-352cd1f6fd84', + 'b77c5385-7385-43eb-b909-42249c4f9e3d', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:28:51 GMT' + 'Thu, 13 Aug 2020 21:55:48 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Length', + '1417', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'e1b03ce5-c479-4109-8014-153de3353701', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=ArO2WTcpeg1GnfeEdRg80MD0CyfMBAAAAOOtx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:53 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:55:53 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/layout/analyzeResults/0964a1b9-933f-4879-b34f-cf63fa27a0cd') - .reply(200, {"status":"succeeded","createdDateTime":"2020-08-05T23:28:51Z","lastUpdatedDateTime":"2020-08-05T23:28:56Z","analyzeResult":{"version":"2.0.0","readResults":[{"page":1,"language":"en","angle":0,"width":8.5,"height":11,"unit":"inch","lines":[{"boundingBox":[0.5384,1.1583,1.4466,1.1583,1.4466,1.3534,0.5384,1.3534],"text":"Contoso","words":[{"boundingBox":[0.5384,1.1583,1.4466,1.1583,1.4466,1.3534,0.5384,1.3534],"text":"Contoso","confidence":1}]},{"boundingBox":[0.7994,1.5143,1.3836,1.5143,1.3836,1.6154,0.7994,1.6154],"text":"Address:","words":[{"boundingBox":[0.7994,1.5143,1.3836,1.5143,1.3836,1.6154,0.7994,1.6154],"text":"Address:","confidence":1}]},{"boundingBox":[4.4033,1.5114,5.8155,1.5114,5.8155,1.6155,4.4033,1.6155],"text":"Invoice For: Microsoft","words":[{"boundingBox":[4.4033,1.5143,4.8234,1.5143,4.8234,1.6155,4.4033,1.6155],"text":"Invoice","confidence":1},{"boundingBox":[4.8793,1.5143,5.1013,1.5143,5.1013,1.6154,4.8793,1.6154],"text":"For:","confidence":1},{"boundingBox":[5.2045,1.5114,5.8155,1.5114,5.8155,1.6151,5.2045,1.6151],"text":"Microsoft","confidence":1}]},{"boundingBox":[0.8106,1.7033,2.1445,1.7033,2.1445,1.8342,0.8106,1.8342],"text":"1 Redmond way Suite","words":[{"boundingBox":[0.8106,1.708,0.8463,1.708,0.8463,1.8053,0.8106,1.8053],"text":"1","confidence":1},{"boundingBox":[0.923,1.7047,1.5018,1.7047,1.5018,1.8068,0.923,1.8068],"text":"Redmond","confidence":1},{"boundingBox":[1.5506,1.7309,1.7949,1.7309,1.7949,1.8342,1.5506,1.8342],"text":"way","confidence":1},{"boundingBox":[1.8415,1.7033,2.1445,1.7033,2.1445,1.8078,1.8415,1.8078],"text":"Suite","confidence":1}]},{"boundingBox":[5.2036,1.716,6.5436,1.716,6.5436,1.8459,5.2036,1.8459],"text":"1020 Enterprise Way","words":[{"boundingBox":[5.2036,1.716,5.4935,1.716,5.4935,1.8185,5.2036,1.8185],"text":"1020","confidence":1},{"boundingBox":[5.5488,1.7164,6.2178,1.7164,6.2178,1.8441,5.5488,1.8441],"text":"Enterprise","confidence":1},{"boundingBox":[6.2618,1.7164,6.5436,1.7164,6.5436,1.8459,6.2618,1.8459],"text":"Way","confidence":1}]},{"boundingBox":[0.8019,1.896,2.0384,1.896,2.0384,2.0171,0.8019,2.0171],"text":"6000 Redmond, WA","words":[{"boundingBox":[0.8019,1.896,1.0991,1.896,1.0991,1.9994,0.8019,1.9994],"text":"6000","confidence":1},{"boundingBox":[1.1537,1.8964,1.7689,1.8964,1.7689,2.0171,1.1537,2.0171],"text":"Redmond,","confidence":1},{"boundingBox":[1.8196,1.8976,2.0384,1.8976,2.0384,1.9969,1.8196,1.9969],"text":"WA","confidence":1}]},{"boundingBox":[5.196,1.9047,6.6526,1.9047,6.6526,2.0359,5.196,2.0359],"text":"Sunnayvale, CA 87659","words":[{"boundingBox":[5.196,1.9047,5.9894,1.9047,5.9894,2.0359,5.196,2.0359],"text":"Sunnayvale,","confidence":1},{"boundingBox":[6.0427,1.9047,6.2354,1.9047,6.2354,2.0085,6.0427,2.0085],"text":"CA","confidence":1},{"boundingBox":[6.2801,1.906,6.6526,1.906,6.6526,2.0086,6.2801,2.0086],"text":"87659","confidence":1}]},{"boundingBox":[0.8025,2.0876,1.175,2.0876,1.175,2.1911,0.8025,2.1911],"text":"99243","words":[{"boundingBox":[0.8025,2.0876,1.175,2.0876,1.175,2.1911,0.8025,2.1911],"text":"99243","confidence":1}]},{"boundingBox":[0.5439,2.8733,1.5729,2.8733,1.5729,2.9754,0.5439,2.9754],"text":"Invoice Number","words":[{"boundingBox":[0.5439,2.8733,1.0098,2.8733,1.0098,2.9754,0.5439,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[1.0611,2.8743,1.5729,2.8743,1.5729,2.9754,1.0611,2.9754],"text":"Number","confidence":1}]},{"boundingBox":[1.9491,2.8733,2.7527,2.8733,2.7527,2.9754,1.9491,2.9754],"text":"Invoice Date","words":[{"boundingBox":[1.9491,2.8733,2.415,2.8733,2.415,2.9754,1.9491,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[2.4673,2.8743,2.7527,2.8743,2.7527,2.9754,2.4673,2.9754],"text":"Date","confidence":1}]},{"boundingBox":[3.3495,2.8733,4.4547,2.8733,4.4547,2.9754,3.3495,2.9754],"text":"Invoice Due Date","words":[{"boundingBox":[3.3495,2.8733,3.8155,2.8733,3.8155,2.9754,3.3495,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[3.8677,2.8743,4.1149,2.8743,4.1149,2.9754,3.8677,2.9754],"text":"Due","confidence":1},{"boundingBox":[4.1678,2.8743,4.4547,2.8743,4.4547,2.9754,4.1678,2.9754],"text":"Date","confidence":1}]},{"boundingBox":[4.7468,2.8717,5.289,2.8717,5.289,3.0035,4.7468,3.0035],"text":"Charges","words":[{"boundingBox":[4.7468,2.8717,5.289,2.8717,5.289,3.0035,4.7468,3.0035],"text":"Charges","confidence":1}]},{"boundingBox":[6.141,2.873,6.5875,2.873,6.5875,2.9736,6.141,2.9736],"text":"VAT ID","words":[{"boundingBox":[6.141,2.873,6.4147,2.873,6.4147,2.9736,6.141,2.9736],"text":"VAT","confidence":1},{"boundingBox":[6.4655,2.873,6.5875,2.873,6.5875,2.9736,6.4655,2.9736],"text":"ID","confidence":1}]},{"boundingBox":[0.5397,3.411,1.1457,3.411,1.1457,3.5144,0.5397,3.5144],"text":"34278587","words":[{"boundingBox":[0.5397,3.411,1.1457,3.411,1.1457,3.5144,0.5397,3.5144],"text":"34278587","confidence":1}]},{"boundingBox":[1.9455,3.41,2.551,3.41,2.551,3.5144,1.9455,3.5144],"text":"6/18/2017","words":[{"boundingBox":[1.9455,3.41,2.551,3.41,2.551,3.5144,1.9455,3.5144],"text":"6/18/2017","confidence":1}]},{"boundingBox":[3.346,3.41,3.9514,3.41,3.9514,3.5144,3.346,3.5144],"text":"6/24/2017","words":[{"boundingBox":[3.346,3.41,3.9514,3.41,3.9514,3.5144,3.346,3.5144],"text":"6/24/2017","confidence":1}]},{"boundingBox":[5.3871,3.4047,6.0702,3.4047,6.0702,3.5321,5.3871,3.5321],"text":"$56,651.49","words":[{"boundingBox":[5.3871,3.4047,6.0702,3.4047,6.0702,3.5321,5.3871,3.5321],"text":"$56,651.49","confidence":1}]},{"boundingBox":[6.2285,3.4114,6.3919,3.4114,6.3919,3.5119,6.2285,3.5119],"text":"PT","words":[{"boundingBox":[6.2285,3.4114,6.3919,3.4114,6.3919,3.5119,6.2285,3.5119],"text":"PT","confidence":1}]}]}],"pageResults":[{"page":1,"tables":[{"rows":2,"columns":6,"cells":[{"rowIndex":0,"columnIndex":0,"text":"Invoice Number","boundingBox":[0.5075,2.8088,1.9061,2.8088,1.9061,3.3219,0.5075,3.3219],"elements":["#/readResults/0/lines/8/words/0","#/readResults/0/lines/8/words/1"]},{"rowIndex":0,"columnIndex":1,"text":"Invoice Date","boundingBox":[1.9061,2.8088,3.3074,2.8088,3.3074,3.3219,1.9061,3.3219],"elements":["#/readResults/0/lines/9/words/0","#/readResults/0/lines/9/words/1"]},{"rowIndex":0,"columnIndex":2,"text":"Invoice Due Date","boundingBox":[3.3074,2.8088,4.7074,2.8088,4.7074,3.3219,3.3074,3.3219],"elements":["#/readResults/0/lines/10/words/0","#/readResults/0/lines/10/words/1","#/readResults/0/lines/10/words/2"]},{"rowIndex":0,"columnIndex":3,"text":"Charges","boundingBox":[4.7074,2.8088,5.386,2.8088,5.386,3.3219,4.7074,3.3219],"elements":["#/readResults/0/lines/11/words/0"]},{"rowIndex":0,"columnIndex":5,"text":"VAT ID","boundingBox":[6.1051,2.8088,7.5038,2.8088,7.5038,3.3219,6.1051,3.3219],"elements":["#/readResults/0/lines/12/words/0","#/readResults/0/lines/12/words/1"]},{"rowIndex":1,"columnIndex":0,"text":"34278587","boundingBox":[0.5075,3.3219,1.9061,3.3219,1.9061,3.859,0.5075,3.859],"elements":["#/readResults/0/lines/13/words/0"]},{"rowIndex":1,"columnIndex":1,"text":"6/18/2017","boundingBox":[1.9061,3.3219,3.3074,3.3219,3.3074,3.859,1.9061,3.859],"elements":["#/readResults/0/lines/14/words/0"]},{"rowIndex":1,"columnIndex":2,"text":"6/24/2017","boundingBox":[3.3074,3.3219,4.7074,3.3219,4.7074,3.859,3.3074,3.859],"elements":["#/readResults/0/lines/15/words/0"]},{"rowIndex":1,"columnIndex":3,"columnSpan":2,"text":"$56,651.49","boundingBox":[4.7074,3.3219,6.1051,3.3219,6.1051,3.859,4.7074,3.859],"elements":["#/readResults/0/lines/16/words/0"]},{"rowIndex":1,"columnIndex":5,"text":"PT","boundingBox":[6.1051,3.3219,7.5038,3.3219,7.5038,3.859,6.1051,3.859],"elements":["#/readResults/0/lines/17/words/0"]}]}]}]}}, [ + .get('/formrecognizer/v2.0/layout/analyzeResults/ee285799-d612-4faa-be3e-618d86c47f52') + .reply(200, {"status":"succeeded","createdDateTime":"2020-08-13T21:55:48Z","lastUpdatedDateTime":"2020-08-13T21:55:53Z","analyzeResult":{"version":"2.0.0","readResults":[{"page":1,"language":"en","angle":0,"width":8.5,"height":11,"unit":"inch","lines":[{"boundingBox":[0.5384,1.1583,1.4466,1.1583,1.4466,1.3534,0.5384,1.3534],"text":"Contoso","words":[{"boundingBox":[0.5384,1.1583,1.4466,1.1583,1.4466,1.3534,0.5384,1.3534],"text":"Contoso","confidence":1}]},{"boundingBox":[0.7994,1.5143,1.3836,1.5143,1.3836,1.6154,0.7994,1.6154],"text":"Address:","words":[{"boundingBox":[0.7994,1.5143,1.3836,1.5143,1.3836,1.6154,0.7994,1.6154],"text":"Address:","confidence":1}]},{"boundingBox":[4.4033,1.5114,5.8155,1.5114,5.8155,1.6155,4.4033,1.6155],"text":"Invoice For: Microsoft","words":[{"boundingBox":[4.4033,1.5143,4.8234,1.5143,4.8234,1.6155,4.4033,1.6155],"text":"Invoice","confidence":1},{"boundingBox":[4.8793,1.5143,5.1013,1.5143,5.1013,1.6154,4.8793,1.6154],"text":"For:","confidence":1},{"boundingBox":[5.2045,1.5114,5.8155,1.5114,5.8155,1.6151,5.2045,1.6151],"text":"Microsoft","confidence":1}]},{"boundingBox":[0.8106,1.7033,2.1445,1.7033,2.1445,1.8342,0.8106,1.8342],"text":"1 Redmond way Suite","words":[{"boundingBox":[0.8106,1.708,0.8463,1.708,0.8463,1.8053,0.8106,1.8053],"text":"1","confidence":1},{"boundingBox":[0.923,1.7047,1.5018,1.7047,1.5018,1.8068,0.923,1.8068],"text":"Redmond","confidence":1},{"boundingBox":[1.5506,1.7309,1.7949,1.7309,1.7949,1.8342,1.5506,1.8342],"text":"way","confidence":1},{"boundingBox":[1.8415,1.7033,2.1445,1.7033,2.1445,1.8078,1.8415,1.8078],"text":"Suite","confidence":1}]},{"boundingBox":[5.2036,1.716,6.5436,1.716,6.5436,1.8459,5.2036,1.8459],"text":"1020 Enterprise Way","words":[{"boundingBox":[5.2036,1.716,5.4935,1.716,5.4935,1.8185,5.2036,1.8185],"text":"1020","confidence":1},{"boundingBox":[5.5488,1.7164,6.2178,1.7164,6.2178,1.8441,5.5488,1.8441],"text":"Enterprise","confidence":1},{"boundingBox":[6.2618,1.7164,6.5436,1.7164,6.5436,1.8459,6.2618,1.8459],"text":"Way","confidence":1}]},{"boundingBox":[0.8019,1.896,2.0384,1.896,2.0384,2.0171,0.8019,2.0171],"text":"6000 Redmond, WA","words":[{"boundingBox":[0.8019,1.896,1.0991,1.896,1.0991,1.9994,0.8019,1.9994],"text":"6000","confidence":1},{"boundingBox":[1.1537,1.8964,1.7689,1.8964,1.7689,2.0171,1.1537,2.0171],"text":"Redmond,","confidence":1},{"boundingBox":[1.8196,1.8976,2.0384,1.8976,2.0384,1.9969,1.8196,1.9969],"text":"WA","confidence":1}]},{"boundingBox":[5.196,1.9047,6.6526,1.9047,6.6526,2.0359,5.196,2.0359],"text":"Sunnayvale, CA 87659","words":[{"boundingBox":[5.196,1.9047,5.9894,1.9047,5.9894,2.0359,5.196,2.0359],"text":"Sunnayvale,","confidence":1},{"boundingBox":[6.0427,1.9047,6.2354,1.9047,6.2354,2.0085,6.0427,2.0085],"text":"CA","confidence":1},{"boundingBox":[6.2801,1.906,6.6526,1.906,6.6526,2.0086,6.2801,2.0086],"text":"87659","confidence":1}]},{"boundingBox":[0.8025,2.0876,1.175,2.0876,1.175,2.1911,0.8025,2.1911],"text":"99243","words":[{"boundingBox":[0.8025,2.0876,1.175,2.0876,1.175,2.1911,0.8025,2.1911],"text":"99243","confidence":1}]},{"boundingBox":[0.5439,2.8733,1.5729,2.8733,1.5729,2.9754,0.5439,2.9754],"text":"Invoice Number","words":[{"boundingBox":[0.5439,2.8733,1.0098,2.8733,1.0098,2.9754,0.5439,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[1.0611,2.8743,1.5729,2.8743,1.5729,2.9754,1.0611,2.9754],"text":"Number","confidence":1}]},{"boundingBox":[1.9491,2.8733,2.7527,2.8733,2.7527,2.9754,1.9491,2.9754],"text":"Invoice Date","words":[{"boundingBox":[1.9491,2.8733,2.415,2.8733,2.415,2.9754,1.9491,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[2.4673,2.8743,2.7527,2.8743,2.7527,2.9754,2.4673,2.9754],"text":"Date","confidence":1}]},{"boundingBox":[3.3495,2.8733,4.4547,2.8733,4.4547,2.9754,3.3495,2.9754],"text":"Invoice Due Date","words":[{"boundingBox":[3.3495,2.8733,3.8155,2.8733,3.8155,2.9754,3.3495,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[3.8677,2.8743,4.1149,2.8743,4.1149,2.9754,3.8677,2.9754],"text":"Due","confidence":1},{"boundingBox":[4.1678,2.8743,4.4547,2.8743,4.4547,2.9754,4.1678,2.9754],"text":"Date","confidence":1}]},{"boundingBox":[4.7468,2.8717,5.289,2.8717,5.289,3.0035,4.7468,3.0035],"text":"Charges","words":[{"boundingBox":[4.7468,2.8717,5.289,2.8717,5.289,3.0035,4.7468,3.0035],"text":"Charges","confidence":1}]},{"boundingBox":[6.141,2.873,6.5875,2.873,6.5875,2.9736,6.141,2.9736],"text":"VAT ID","words":[{"boundingBox":[6.141,2.873,6.4147,2.873,6.4147,2.9736,6.141,2.9736],"text":"VAT","confidence":1},{"boundingBox":[6.4655,2.873,6.5875,2.873,6.5875,2.9736,6.4655,2.9736],"text":"ID","confidence":1}]},{"boundingBox":[0.5397,3.411,1.1457,3.411,1.1457,3.5144,0.5397,3.5144],"text":"34278587","words":[{"boundingBox":[0.5397,3.411,1.1457,3.411,1.1457,3.5144,0.5397,3.5144],"text":"34278587","confidence":1}]},{"boundingBox":[1.9455,3.41,2.551,3.41,2.551,3.5144,1.9455,3.5144],"text":"6/18/2017","words":[{"boundingBox":[1.9455,3.41,2.551,3.41,2.551,3.5144,1.9455,3.5144],"text":"6/18/2017","confidence":1}]},{"boundingBox":[3.346,3.41,3.9514,3.41,3.9514,3.5144,3.346,3.5144],"text":"6/24/2017","words":[{"boundingBox":[3.346,3.41,3.9514,3.41,3.9514,3.5144,3.346,3.5144],"text":"6/24/2017","confidence":1}]},{"boundingBox":[5.3871,3.4047,6.0702,3.4047,6.0702,3.5321,5.3871,3.5321],"text":"$56,651.49","words":[{"boundingBox":[5.3871,3.4047,6.0702,3.4047,6.0702,3.5321,5.3871,3.5321],"text":"$56,651.49","confidence":1}]},{"boundingBox":[6.2285,3.4114,6.3919,3.4114,6.3919,3.5119,6.2285,3.5119],"text":"PT","words":[{"boundingBox":[6.2285,3.4114,6.3919,3.4114,6.3919,3.5119,6.2285,3.5119],"text":"PT","confidence":1}]}]}],"pageResults":[{"page":1,"tables":[{"rows":2,"columns":6,"cells":[{"rowIndex":0,"columnIndex":0,"text":"Invoice Number","boundingBox":[0.5075,2.8088,1.9061,2.8088,1.9061,3.3219,0.5075,3.3219],"elements":["#/readResults/0/lines/8/words/0","#/readResults/0/lines/8/words/1"]},{"rowIndex":0,"columnIndex":1,"text":"Invoice Date","boundingBox":[1.9061,2.8088,3.3074,2.8088,3.3074,3.3219,1.9061,3.3219],"elements":["#/readResults/0/lines/9/words/0","#/readResults/0/lines/9/words/1"]},{"rowIndex":0,"columnIndex":2,"text":"Invoice Due Date","boundingBox":[3.3074,2.8088,4.7074,2.8088,4.7074,3.3219,3.3074,3.3219],"elements":["#/readResults/0/lines/10/words/0","#/readResults/0/lines/10/words/1","#/readResults/0/lines/10/words/2"]},{"rowIndex":0,"columnIndex":3,"text":"Charges","boundingBox":[4.7074,2.8088,5.386,2.8088,5.386,3.3219,4.7074,3.3219],"elements":["#/readResults/0/lines/11/words/0"]},{"rowIndex":0,"columnIndex":5,"text":"VAT ID","boundingBox":[6.1051,2.8088,7.5038,2.8088,7.5038,3.3219,6.1051,3.3219],"elements":["#/readResults/0/lines/12/words/0","#/readResults/0/lines/12/words/1"]},{"rowIndex":1,"columnIndex":0,"text":"34278587","boundingBox":[0.5075,3.3219,1.9061,3.3219,1.9061,3.859,0.5075,3.859],"elements":["#/readResults/0/lines/13/words/0"]},{"rowIndex":1,"columnIndex":1,"text":"6/18/2017","boundingBox":[1.9061,3.3219,3.3074,3.3219,3.3074,3.859,1.9061,3.859],"elements":["#/readResults/0/lines/14/words/0"]},{"rowIndex":1,"columnIndex":2,"text":"6/24/2017","boundingBox":[3.3074,3.3219,4.7074,3.3219,4.7074,3.859,3.3074,3.859],"elements":["#/readResults/0/lines/15/words/0"]},{"rowIndex":1,"columnIndex":3,"columnSpan":2,"text":"$56,651.49","boundingBox":[4.7074,3.3219,6.1051,3.3219,6.1051,3.859,4.7074,3.859],"elements":["#/readResults/0/lines/16/words/0"]},{"rowIndex":1,"columnIndex":5,"text":"PT","boundingBox":[6.1051,3.3219,7.5038,3.3219,7.5038,3.859,6.1051,3.859],"elements":["#/readResults/0/lines/17/words/0"]}]}]}]}}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '20', + '22', 'apim-request-id', - '61410c0c-737e-4980-ba8e-da038ce34f81', + '00882259-fb8b-4823-b9e9-a420ca51a88f', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:28:56 GMT' + 'Thu, 13 Aug 2020 21:55:52 GMT' ]); diff --git a/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_content_from_a_url.js b/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_content_from_a_url.js index bd19a0fae447..3c26128d489b 100644 --- a/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_content_from_a_url.js +++ b/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_content_from_a_url.js @@ -8,7 +8,7 @@ nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ 'Cache-Control', - 'no-cache, no-store', + 'no-store, no-cache', 'Pragma', 'no-cache', 'Content-Type', @@ -19,20 +19,20 @@ nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) 'max-age=31536000; includeSubDomains', 'X-Content-Type-Options', 'nosniff', - 'x-ms-request-id', - '490ab8a2-8415-4ff2-97cb-ba340f191000', - 'x-ms-ests-server', - '2.1.10922.14 - WUS2 ProdSlices', 'P3P', 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '1450b819-f6df-440e-aa6b-c1f68c304101', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', 'Set-Cookie', - 'fpc=AjX_GS4swqREk58g176llxn0CyfMAQAAALg3vdYOAAAA; expires=Fri, 04-Sep-2020 23:28:56 GMT; path=/; secure; HttpOnly; SameSite=None', + 'fpc=Apk3kR8kBL1Iq36P2RNQV-v0CyfMAQAAAOmtx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:53 GMT; path=/; secure; HttpOnly; SameSite=None', 'Set-Cookie', - 'x-ms-gateway-slice=prod; path=/; SameSite=None; secure; HttpOnly', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', 'Set-Cookie', - 'stsservicecookie=ests; path=/; SameSite=None; secure; HttpOnly', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', 'Date', - 'Wed, 05 Aug 2020 23:28:56 GMT', + 'Thu, 13 Aug 2020 21:55:53 GMT', 'Content-Length', '1417' ]); @@ -43,72 +43,171 @@ nock('https://endpoint:443', {"encodedQueryParams":true}) 'Content-Length', '0', 'Operation-Location', - 'https://endpoint/formrecognizer/v2.0/layout/analyzeResults/d2f67879-5572-4380-aadd-82834adbc464', + 'https://endpoint/formrecognizer/v2.0/layout/analyzeResults/2249c664-b329-4e06-996f-690f08355a90', 'x-envoy-upstream-service-time', - '363', + '422', 'apim-request-id', - 'd2f67879-5572-4380-aadd-82834adbc464', + '2249c664-b329-4e06-996f-690f08355a90', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:28:57 GMT' + 'Thu, 13 Aug 2020 21:55:54 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Length', + '1417', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'fafdf7aa-8a83-427b-9c6e-a0ab71ae4801', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=Apk3kR8kBL1Iq36P2RNQV-v0CyfMAgAAAOmtx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:54 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:55:54 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/layout/analyzeResults/d2f67879-5572-4380-aadd-82834adbc464') - .reply(200, {"status":"running","createdDateTime":"2020-08-05T23:28:57Z","lastUpdatedDateTime":"2020-08-05T23:28:57Z"}, [ + .get('/formrecognizer/v2.0/layout/analyzeResults/2249c664-b329-4e06-996f-690f08355a90') + .reply(200, {"status":"running","createdDateTime":"2020-08-13T21:55:54Z","lastUpdatedDateTime":"2020-08-13T21:55:54Z"}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '17', + '10', 'apim-request-id', - '91edaea4-7d6c-4372-99c0-95e6bdd89e5a', + 'ef810506-7932-4e68-85ce-3fa2977520f0', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:28:57 GMT' + 'Thu, 13 Aug 2020 21:55:54 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '3d553101-1dc4-4fd3-affc-43c501665401', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=Apk3kR8kBL1Iq36P2RNQV-v0CyfMAwAAAOmtx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:54 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:55:54 GMT', + 'Content-Length', + '1417' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/layout/analyzeResults/d2f67879-5572-4380-aadd-82834adbc464') - .reply(200, {"status":"running","createdDateTime":"2020-08-05T23:28:57Z","lastUpdatedDateTime":"2020-08-05T23:28:57Z"}, [ + .get('/formrecognizer/v2.0/layout/analyzeResults/2249c664-b329-4e06-996f-690f08355a90') + .reply(200, {"status":"running","createdDateTime":"2020-08-13T21:55:54Z","lastUpdatedDateTime":"2020-08-13T21:55:54Z"}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '14', + '10', 'apim-request-id', - 'b65f4821-ceee-4065-8776-b4ae481197b9', + '4845b795-f154-4e22-83cc-0c9b5dbafe9c', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:28:57 GMT' + 'Thu, 13 Aug 2020 21:55:54 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'ed63f0d1-07f1-426a-9c89-b2549d190601', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=Apk3kR8kBL1Iq36P2RNQV-v0CyfMBAAAAOmtx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:59 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:55:59 GMT', + 'Content-Length', + '1417' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/layout/analyzeResults/d2f67879-5572-4380-aadd-82834adbc464') - .reply(200, {"status":"succeeded","createdDateTime":"2020-08-05T23:28:57Z","lastUpdatedDateTime":"2020-08-05T23:29:02Z","analyzeResult":{"version":"2.0.0","readResults":[{"page":1,"language":"en","angle":0,"width":8.5,"height":11,"unit":"inch","lines":[{"boundingBox":[0.5384,1.1583,1.4466,1.1583,1.4466,1.3534,0.5384,1.3534],"text":"Contoso","words":[{"boundingBox":[0.5384,1.1583,1.4466,1.1583,1.4466,1.3534,0.5384,1.3534],"text":"Contoso","confidence":1}]},{"boundingBox":[0.7994,1.5143,1.3836,1.5143,1.3836,1.6154,0.7994,1.6154],"text":"Address:","words":[{"boundingBox":[0.7994,1.5143,1.3836,1.5143,1.3836,1.6154,0.7994,1.6154],"text":"Address:","confidence":1}]},{"boundingBox":[4.4033,1.5114,5.8155,1.5114,5.8155,1.6155,4.4033,1.6155],"text":"Invoice For: Microsoft","words":[{"boundingBox":[4.4033,1.5143,4.8234,1.5143,4.8234,1.6155,4.4033,1.6155],"text":"Invoice","confidence":1},{"boundingBox":[4.8793,1.5143,5.1013,1.5143,5.1013,1.6154,4.8793,1.6154],"text":"For:","confidence":1},{"boundingBox":[5.2045,1.5114,5.8155,1.5114,5.8155,1.6151,5.2045,1.6151],"text":"Microsoft","confidence":1}]},{"boundingBox":[0.8106,1.7033,2.1445,1.7033,2.1445,1.8342,0.8106,1.8342],"text":"1 Redmond way Suite","words":[{"boundingBox":[0.8106,1.708,0.8463,1.708,0.8463,1.8053,0.8106,1.8053],"text":"1","confidence":1},{"boundingBox":[0.923,1.7047,1.5018,1.7047,1.5018,1.8068,0.923,1.8068],"text":"Redmond","confidence":1},{"boundingBox":[1.5506,1.7309,1.7949,1.7309,1.7949,1.8342,1.5506,1.8342],"text":"way","confidence":1},{"boundingBox":[1.8415,1.7033,2.1445,1.7033,2.1445,1.8078,1.8415,1.8078],"text":"Suite","confidence":1}]},{"boundingBox":[5.2036,1.716,6.5436,1.716,6.5436,1.8459,5.2036,1.8459],"text":"1020 Enterprise Way","words":[{"boundingBox":[5.2036,1.716,5.4935,1.716,5.4935,1.8185,5.2036,1.8185],"text":"1020","confidence":1},{"boundingBox":[5.5488,1.7164,6.2178,1.7164,6.2178,1.8441,5.5488,1.8441],"text":"Enterprise","confidence":1},{"boundingBox":[6.2618,1.7164,6.5436,1.7164,6.5436,1.8459,6.2618,1.8459],"text":"Way","confidence":1}]},{"boundingBox":[0.8019,1.896,2.0384,1.896,2.0384,2.0171,0.8019,2.0171],"text":"6000 Redmond, WA","words":[{"boundingBox":[0.8019,1.896,1.0991,1.896,1.0991,1.9994,0.8019,1.9994],"text":"6000","confidence":1},{"boundingBox":[1.1537,1.8964,1.7689,1.8964,1.7689,2.0171,1.1537,2.0171],"text":"Redmond,","confidence":1},{"boundingBox":[1.8196,1.8976,2.0384,1.8976,2.0384,1.9969,1.8196,1.9969],"text":"WA","confidence":1}]},{"boundingBox":[5.196,1.9047,6.6526,1.9047,6.6526,2.0359,5.196,2.0359],"text":"Sunnayvale, CA 87659","words":[{"boundingBox":[5.196,1.9047,5.9894,1.9047,5.9894,2.0359,5.196,2.0359],"text":"Sunnayvale,","confidence":1},{"boundingBox":[6.0427,1.9047,6.2354,1.9047,6.2354,2.0085,6.0427,2.0085],"text":"CA","confidence":1},{"boundingBox":[6.2801,1.906,6.6526,1.906,6.6526,2.0086,6.2801,2.0086],"text":"87659","confidence":1}]},{"boundingBox":[0.8025,2.0876,1.175,2.0876,1.175,2.1911,0.8025,2.1911],"text":"99243","words":[{"boundingBox":[0.8025,2.0876,1.175,2.0876,1.175,2.1911,0.8025,2.1911],"text":"99243","confidence":1}]},{"boundingBox":[0.5439,2.8733,1.5729,2.8733,1.5729,2.9754,0.5439,2.9754],"text":"Invoice Number","words":[{"boundingBox":[0.5439,2.8733,1.0098,2.8733,1.0098,2.9754,0.5439,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[1.0611,2.8743,1.5729,2.8743,1.5729,2.9754,1.0611,2.9754],"text":"Number","confidence":1}]},{"boundingBox":[1.9491,2.8733,2.7527,2.8733,2.7527,2.9754,1.9491,2.9754],"text":"Invoice Date","words":[{"boundingBox":[1.9491,2.8733,2.415,2.8733,2.415,2.9754,1.9491,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[2.4673,2.8743,2.7527,2.8743,2.7527,2.9754,2.4673,2.9754],"text":"Date","confidence":1}]},{"boundingBox":[3.3495,2.8733,4.4547,2.8733,4.4547,2.9754,3.3495,2.9754],"text":"Invoice Due Date","words":[{"boundingBox":[3.3495,2.8733,3.8155,2.8733,3.8155,2.9754,3.3495,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[3.8677,2.8743,4.1149,2.8743,4.1149,2.9754,3.8677,2.9754],"text":"Due","confidence":1},{"boundingBox":[4.1678,2.8743,4.4547,2.8743,4.4547,2.9754,4.1678,2.9754],"text":"Date","confidence":1}]},{"boundingBox":[4.7468,2.8717,5.289,2.8717,5.289,3.0035,4.7468,3.0035],"text":"Charges","words":[{"boundingBox":[4.7468,2.8717,5.289,2.8717,5.289,3.0035,4.7468,3.0035],"text":"Charges","confidence":1}]},{"boundingBox":[6.141,2.873,6.5875,2.873,6.5875,2.9736,6.141,2.9736],"text":"VAT ID","words":[{"boundingBox":[6.141,2.873,6.4147,2.873,6.4147,2.9736,6.141,2.9736],"text":"VAT","confidence":1},{"boundingBox":[6.4655,2.873,6.5875,2.873,6.5875,2.9736,6.4655,2.9736],"text":"ID","confidence":1}]},{"boundingBox":[0.5397,3.411,1.1457,3.411,1.1457,3.5144,0.5397,3.5144],"text":"34278587","words":[{"boundingBox":[0.5397,3.411,1.1457,3.411,1.1457,3.5144,0.5397,3.5144],"text":"34278587","confidence":1}]},{"boundingBox":[1.9455,3.41,2.551,3.41,2.551,3.5144,1.9455,3.5144],"text":"6/18/2017","words":[{"boundingBox":[1.9455,3.41,2.551,3.41,2.551,3.5144,1.9455,3.5144],"text":"6/18/2017","confidence":1}]},{"boundingBox":[3.346,3.41,3.9514,3.41,3.9514,3.5144,3.346,3.5144],"text":"6/24/2017","words":[{"boundingBox":[3.346,3.41,3.9514,3.41,3.9514,3.5144,3.346,3.5144],"text":"6/24/2017","confidence":1}]},{"boundingBox":[5.3871,3.4047,6.0702,3.4047,6.0702,3.5321,5.3871,3.5321],"text":"$56,651.49","words":[{"boundingBox":[5.3871,3.4047,6.0702,3.4047,6.0702,3.5321,5.3871,3.5321],"text":"$56,651.49","confidence":1}]},{"boundingBox":[6.2285,3.4114,6.3919,3.4114,6.3919,3.5119,6.2285,3.5119],"text":"PT","words":[{"boundingBox":[6.2285,3.4114,6.3919,3.4114,6.3919,3.5119,6.2285,3.5119],"text":"PT","confidence":1}]}]}],"pageResults":[{"page":1,"tables":[{"rows":2,"columns":6,"cells":[{"rowIndex":0,"columnIndex":0,"text":"Invoice Number","boundingBox":[0.5075,2.8088,1.9061,2.8088,1.9061,3.3219,0.5075,3.3219],"elements":["#/readResults/0/lines/8/words/0","#/readResults/0/lines/8/words/1"]},{"rowIndex":0,"columnIndex":1,"text":"Invoice Date","boundingBox":[1.9061,2.8088,3.3074,2.8088,3.3074,3.3219,1.9061,3.3219],"elements":["#/readResults/0/lines/9/words/0","#/readResults/0/lines/9/words/1"]},{"rowIndex":0,"columnIndex":2,"text":"Invoice Due Date","boundingBox":[3.3074,2.8088,4.7074,2.8088,4.7074,3.3219,3.3074,3.3219],"elements":["#/readResults/0/lines/10/words/0","#/readResults/0/lines/10/words/1","#/readResults/0/lines/10/words/2"]},{"rowIndex":0,"columnIndex":3,"text":"Charges","boundingBox":[4.7074,2.8088,5.386,2.8088,5.386,3.3219,4.7074,3.3219],"elements":["#/readResults/0/lines/11/words/0"]},{"rowIndex":0,"columnIndex":5,"text":"VAT ID","boundingBox":[6.1051,2.8088,7.5038,2.8088,7.5038,3.3219,6.1051,3.3219],"elements":["#/readResults/0/lines/12/words/0","#/readResults/0/lines/12/words/1"]},{"rowIndex":1,"columnIndex":0,"text":"34278587","boundingBox":[0.5075,3.3219,1.9061,3.3219,1.9061,3.859,0.5075,3.859],"elements":["#/readResults/0/lines/13/words/0"]},{"rowIndex":1,"columnIndex":1,"text":"6/18/2017","boundingBox":[1.9061,3.3219,3.3074,3.3219,3.3074,3.859,1.9061,3.859],"elements":["#/readResults/0/lines/14/words/0"]},{"rowIndex":1,"columnIndex":2,"text":"6/24/2017","boundingBox":[3.3074,3.3219,4.7074,3.3219,4.7074,3.859,3.3074,3.859],"elements":["#/readResults/0/lines/15/words/0"]},{"rowIndex":1,"columnIndex":3,"columnSpan":2,"text":"$56,651.49","boundingBox":[4.7074,3.3219,6.1051,3.3219,6.1051,3.859,4.7074,3.859],"elements":["#/readResults/0/lines/16/words/0"]},{"rowIndex":1,"columnIndex":5,"text":"PT","boundingBox":[6.1051,3.3219,7.5038,3.3219,7.5038,3.859,6.1051,3.859],"elements":["#/readResults/0/lines/17/words/0"]}]}]}]}}, [ + .get('/formrecognizer/v2.0/layout/analyzeResults/2249c664-b329-4e06-996f-690f08355a90') + .reply(200, {"status":"succeeded","createdDateTime":"2020-08-13T21:55:54Z","lastUpdatedDateTime":"2020-08-13T21:55:59Z","analyzeResult":{"version":"2.0.0","readResults":[{"page":1,"language":"en","angle":0,"width":8.5,"height":11,"unit":"inch","lines":[{"boundingBox":[0.5384,1.1583,1.4466,1.1583,1.4466,1.3534,0.5384,1.3534],"text":"Contoso","words":[{"boundingBox":[0.5384,1.1583,1.4466,1.1583,1.4466,1.3534,0.5384,1.3534],"text":"Contoso","confidence":1}]},{"boundingBox":[0.7994,1.5143,1.3836,1.5143,1.3836,1.6154,0.7994,1.6154],"text":"Address:","words":[{"boundingBox":[0.7994,1.5143,1.3836,1.5143,1.3836,1.6154,0.7994,1.6154],"text":"Address:","confidence":1}]},{"boundingBox":[4.4033,1.5114,5.8155,1.5114,5.8155,1.6155,4.4033,1.6155],"text":"Invoice For: Microsoft","words":[{"boundingBox":[4.4033,1.5143,4.8234,1.5143,4.8234,1.6155,4.4033,1.6155],"text":"Invoice","confidence":1},{"boundingBox":[4.8793,1.5143,5.1013,1.5143,5.1013,1.6154,4.8793,1.6154],"text":"For:","confidence":1},{"boundingBox":[5.2045,1.5114,5.8155,1.5114,5.8155,1.6151,5.2045,1.6151],"text":"Microsoft","confidence":1}]},{"boundingBox":[0.8106,1.7033,2.1445,1.7033,2.1445,1.8342,0.8106,1.8342],"text":"1 Redmond way Suite","words":[{"boundingBox":[0.8106,1.708,0.8463,1.708,0.8463,1.8053,0.8106,1.8053],"text":"1","confidence":1},{"boundingBox":[0.923,1.7047,1.5018,1.7047,1.5018,1.8068,0.923,1.8068],"text":"Redmond","confidence":1},{"boundingBox":[1.5506,1.7309,1.7949,1.7309,1.7949,1.8342,1.5506,1.8342],"text":"way","confidence":1},{"boundingBox":[1.8415,1.7033,2.1445,1.7033,2.1445,1.8078,1.8415,1.8078],"text":"Suite","confidence":1}]},{"boundingBox":[5.2036,1.716,6.5436,1.716,6.5436,1.8459,5.2036,1.8459],"text":"1020 Enterprise Way","words":[{"boundingBox":[5.2036,1.716,5.4935,1.716,5.4935,1.8185,5.2036,1.8185],"text":"1020","confidence":1},{"boundingBox":[5.5488,1.7164,6.2178,1.7164,6.2178,1.8441,5.5488,1.8441],"text":"Enterprise","confidence":1},{"boundingBox":[6.2618,1.7164,6.5436,1.7164,6.5436,1.8459,6.2618,1.8459],"text":"Way","confidence":1}]},{"boundingBox":[0.8019,1.896,2.0384,1.896,2.0384,2.0171,0.8019,2.0171],"text":"6000 Redmond, WA","words":[{"boundingBox":[0.8019,1.896,1.0991,1.896,1.0991,1.9994,0.8019,1.9994],"text":"6000","confidence":1},{"boundingBox":[1.1537,1.8964,1.7689,1.8964,1.7689,2.0171,1.1537,2.0171],"text":"Redmond,","confidence":1},{"boundingBox":[1.8196,1.8976,2.0384,1.8976,2.0384,1.9969,1.8196,1.9969],"text":"WA","confidence":1}]},{"boundingBox":[5.196,1.9047,6.6526,1.9047,6.6526,2.0359,5.196,2.0359],"text":"Sunnayvale, CA 87659","words":[{"boundingBox":[5.196,1.9047,5.9894,1.9047,5.9894,2.0359,5.196,2.0359],"text":"Sunnayvale,","confidence":1},{"boundingBox":[6.0427,1.9047,6.2354,1.9047,6.2354,2.0085,6.0427,2.0085],"text":"CA","confidence":1},{"boundingBox":[6.2801,1.906,6.6526,1.906,6.6526,2.0086,6.2801,2.0086],"text":"87659","confidence":1}]},{"boundingBox":[0.8025,2.0876,1.175,2.0876,1.175,2.1911,0.8025,2.1911],"text":"99243","words":[{"boundingBox":[0.8025,2.0876,1.175,2.0876,1.175,2.1911,0.8025,2.1911],"text":"99243","confidence":1}]},{"boundingBox":[0.5439,2.8733,1.5729,2.8733,1.5729,2.9754,0.5439,2.9754],"text":"Invoice Number","words":[{"boundingBox":[0.5439,2.8733,1.0098,2.8733,1.0098,2.9754,0.5439,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[1.0611,2.8743,1.5729,2.8743,1.5729,2.9754,1.0611,2.9754],"text":"Number","confidence":1}]},{"boundingBox":[1.9491,2.8733,2.7527,2.8733,2.7527,2.9754,1.9491,2.9754],"text":"Invoice Date","words":[{"boundingBox":[1.9491,2.8733,2.415,2.8733,2.415,2.9754,1.9491,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[2.4673,2.8743,2.7527,2.8743,2.7527,2.9754,2.4673,2.9754],"text":"Date","confidence":1}]},{"boundingBox":[3.3495,2.8733,4.4547,2.8733,4.4547,2.9754,3.3495,2.9754],"text":"Invoice Due Date","words":[{"boundingBox":[3.3495,2.8733,3.8155,2.8733,3.8155,2.9754,3.3495,2.9754],"text":"Invoice","confidence":1},{"boundingBox":[3.8677,2.8743,4.1149,2.8743,4.1149,2.9754,3.8677,2.9754],"text":"Due","confidence":1},{"boundingBox":[4.1678,2.8743,4.4547,2.8743,4.4547,2.9754,4.1678,2.9754],"text":"Date","confidence":1}]},{"boundingBox":[4.7468,2.8717,5.289,2.8717,5.289,3.0035,4.7468,3.0035],"text":"Charges","words":[{"boundingBox":[4.7468,2.8717,5.289,2.8717,5.289,3.0035,4.7468,3.0035],"text":"Charges","confidence":1}]},{"boundingBox":[6.141,2.873,6.5875,2.873,6.5875,2.9736,6.141,2.9736],"text":"VAT ID","words":[{"boundingBox":[6.141,2.873,6.4147,2.873,6.4147,2.9736,6.141,2.9736],"text":"VAT","confidence":1},{"boundingBox":[6.4655,2.873,6.5875,2.873,6.5875,2.9736,6.4655,2.9736],"text":"ID","confidence":1}]},{"boundingBox":[0.5397,3.411,1.1457,3.411,1.1457,3.5144,0.5397,3.5144],"text":"34278587","words":[{"boundingBox":[0.5397,3.411,1.1457,3.411,1.1457,3.5144,0.5397,3.5144],"text":"34278587","confidence":1}]},{"boundingBox":[1.9455,3.41,2.551,3.41,2.551,3.5144,1.9455,3.5144],"text":"6/18/2017","words":[{"boundingBox":[1.9455,3.41,2.551,3.41,2.551,3.5144,1.9455,3.5144],"text":"6/18/2017","confidence":1}]},{"boundingBox":[3.346,3.41,3.9514,3.41,3.9514,3.5144,3.346,3.5144],"text":"6/24/2017","words":[{"boundingBox":[3.346,3.41,3.9514,3.41,3.9514,3.5144,3.346,3.5144],"text":"6/24/2017","confidence":1}]},{"boundingBox":[5.3871,3.4047,6.0702,3.4047,6.0702,3.5321,5.3871,3.5321],"text":"$56,651.49","words":[{"boundingBox":[5.3871,3.4047,6.0702,3.4047,6.0702,3.5321,5.3871,3.5321],"text":"$56,651.49","confidence":1}]},{"boundingBox":[6.2285,3.4114,6.3919,3.4114,6.3919,3.5119,6.2285,3.5119],"text":"PT","words":[{"boundingBox":[6.2285,3.4114,6.3919,3.4114,6.3919,3.5119,6.2285,3.5119],"text":"PT","confidence":1}]}]}],"pageResults":[{"page":1,"tables":[{"rows":2,"columns":6,"cells":[{"rowIndex":0,"columnIndex":0,"text":"Invoice Number","boundingBox":[0.5075,2.8088,1.9061,2.8088,1.9061,3.3219,0.5075,3.3219],"elements":["#/readResults/0/lines/8/words/0","#/readResults/0/lines/8/words/1"]},{"rowIndex":0,"columnIndex":1,"text":"Invoice Date","boundingBox":[1.9061,2.8088,3.3074,2.8088,3.3074,3.3219,1.9061,3.3219],"elements":["#/readResults/0/lines/9/words/0","#/readResults/0/lines/9/words/1"]},{"rowIndex":0,"columnIndex":2,"text":"Invoice Due Date","boundingBox":[3.3074,2.8088,4.7074,2.8088,4.7074,3.3219,3.3074,3.3219],"elements":["#/readResults/0/lines/10/words/0","#/readResults/0/lines/10/words/1","#/readResults/0/lines/10/words/2"]},{"rowIndex":0,"columnIndex":3,"text":"Charges","boundingBox":[4.7074,2.8088,5.386,2.8088,5.386,3.3219,4.7074,3.3219],"elements":["#/readResults/0/lines/11/words/0"]},{"rowIndex":0,"columnIndex":5,"text":"VAT ID","boundingBox":[6.1051,2.8088,7.5038,2.8088,7.5038,3.3219,6.1051,3.3219],"elements":["#/readResults/0/lines/12/words/0","#/readResults/0/lines/12/words/1"]},{"rowIndex":1,"columnIndex":0,"text":"34278587","boundingBox":[0.5075,3.3219,1.9061,3.3219,1.9061,3.859,0.5075,3.859],"elements":["#/readResults/0/lines/13/words/0"]},{"rowIndex":1,"columnIndex":1,"text":"6/18/2017","boundingBox":[1.9061,3.3219,3.3074,3.3219,3.3074,3.859,1.9061,3.859],"elements":["#/readResults/0/lines/14/words/0"]},{"rowIndex":1,"columnIndex":2,"text":"6/24/2017","boundingBox":[3.3074,3.3219,4.7074,3.3219,4.7074,3.859,3.3074,3.859],"elements":["#/readResults/0/lines/15/words/0"]},{"rowIndex":1,"columnIndex":3,"columnSpan":2,"text":"$56,651.49","boundingBox":[4.7074,3.3219,6.1051,3.3219,6.1051,3.859,4.7074,3.859],"elements":["#/readResults/0/lines/16/words/0"]},{"rowIndex":1,"columnIndex":5,"text":"PT","boundingBox":[6.1051,3.3219,7.5038,3.3219,7.5038,3.859,6.1051,3.859],"elements":["#/readResults/0/lines/17/words/0"]}]}]}]}}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '27', + '21', 'apim-request-id', - '713fec2f-c4ae-4e7e-9948-305bca968a51', + 'fbbf365d-9d96-4226-95b2-e294c3d221f1', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:29:02 GMT' + 'Thu, 13 Aug 2020 21:55:59 GMT' ]); diff --git a/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_receipt_from_a_url.js b/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_receipt_from_a_url.js index a6f203224150..9a83d54380b0 100644 --- a/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_receipt_from_a_url.js +++ b/sdk/formrecognizer/ai-form-recognizer/recordings/node/aad_formrecognizerclient_nodejs_only/recording_recognizes_receipt_from_a_url.js @@ -11,6 +11,8 @@ nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) 'no-store, no-cache', 'Pragma', 'no-cache', + 'Content-Length', + '1417', 'Content-Type', 'application/json; charset=utf-8', 'Expires', @@ -22,19 +24,17 @@ nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) 'P3P', 'CP="DSP CUR OTPi IND OTRi ONL FIN"', 'x-ms-request-id', - '9d9bb083-1a35-423f-af18-9ec7511d1e00', + '3cb431e7-31ab-437a-a7df-e21da3734001', 'x-ms-ests-server', - '2.1.10922.14 - WUS2 ProdSlices', + '2.1.10922.14 - SAN ProdSlices', 'Set-Cookie', - 'fpc=Aq2N0b5lmWxNh4O31UGv_Br0CyfMAQAAAL43vdYOAAAA; expires=Fri, 04-Sep-2020 23:29:02 GMT; path=/; secure; HttpOnly; SameSite=None', + 'fpc=AoPJ8EoLo1xEg2FbIpX38_P0CyfMAQAAAO-tx9YOAAAA; expires=Sat, 12-Sep-2020 21:55:59 GMT; path=/; secure; HttpOnly; SameSite=None', 'Set-Cookie', 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', 'Set-Cookie', 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', 'Date', - 'Wed, 05 Aug 2020 23:29:02 GMT', - 'Content-Length', - '1417' + 'Thu, 13 Aug 2020 21:55:59 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) @@ -43,72 +43,171 @@ nock('https://endpoint:443', {"encodedQueryParams":true}) 'Content-Length', '0', 'Operation-Location', - 'https://endpoint/formrecognizer/v2.0/prebuilt/receipt/analyzeResults/df67d45f-07f3-48e8-9ed4-580d608e1873', + 'https://endpoint/formrecognizer/v2.0/prebuilt/receipt/analyzeResults/d254705d-a6e6-4dc0-a818-3d777499dd81', 'x-envoy-upstream-service-time', - '162', + '886', 'apim-request-id', - 'df67d45f-07f3-48e8-9ed4-580d608e1873', + 'd254705d-a6e6-4dc0-a818-3d777499dd81', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:29:02 GMT' + 'Thu, 13 Aug 2020 21:56:00 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Length', + '1417', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '662fd98c-66d6-439d-9d72-82df3f894601', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=AoPJ8EoLo1xEg2FbIpX38_P0CyfMAgAAAO-tx9YOAAAA; expires=Sat, 12-Sep-2020 21:56:01 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:56:01 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/prebuilt/receipt/analyzeResults/df67d45f-07f3-48e8-9ed4-580d608e1873') - .reply(200, {"status":"running","createdDateTime":"2020-08-05T23:29:03Z","lastUpdatedDateTime":"2020-08-05T23:29:03Z"}, [ + .get('/formrecognizer/v2.0/prebuilt/receipt/analyzeResults/d254705d-a6e6-4dc0-a818-3d777499dd81') + .reply(200, {"status":"running","createdDateTime":"2020-08-13T21:56:00Z","lastUpdatedDateTime":"2020-08-13T21:56:01Z"}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '17', + '66', 'apim-request-id', - '5191489b-dfac-453b-b435-e3155658da5e', + '35cf59b3-7d71-45ac-9589-3bbb29039dcc', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:29:03 GMT' + 'Thu, 13 Aug 2020 21:56:00 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Length', + '1417', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '1693dbd3-d5f9-4eb2-aef4-894020535301', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=AoPJ8EoLo1xEg2FbIpX38_P0CyfMAwAAAO-tx9YOAAAA; expires=Sat, 12-Sep-2020 21:56:01 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:56:01 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/prebuilt/receipt/analyzeResults/df67d45f-07f3-48e8-9ed4-580d608e1873') - .reply(200, {"status":"running","createdDateTime":"2020-08-05T23:29:03Z","lastUpdatedDateTime":"2020-08-05T23:29:03Z"}, [ + .get('/formrecognizer/v2.0/prebuilt/receipt/analyzeResults/d254705d-a6e6-4dc0-a818-3d777499dd81') + .reply(200, {"status":"running","createdDateTime":"2020-08-13T21:56:00Z","lastUpdatedDateTime":"2020-08-13T21:56:01Z"}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '13', + '131', 'apim-request-id', - 'efad5340-e541-406f-8c36-05b6fa421c67', + '937ac6e9-e131-4ac0-85ca-12f3e56601b2', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:29:03 GMT' + 'Thu, 13 Aug 2020 21:56:00 GMT' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/azure_tenant_id/oauth2/v2.0/token', "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=azure_client_secret&scope=https%3A%2F%2Fcognitiveservices.azure.com%2F.default") + .reply(200, {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Length', + '1417', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '662fd98c-66d6-439d-9d72-82df6e8a4601', + 'x-ms-ests-server', + '2.1.10922.14 - SAN ProdSlices', + 'Set-Cookie', + 'fpc=AoPJ8EoLo1xEg2FbIpX38_P0CyfMBAAAAO-tx9YOAAAA; expires=Sat, 12-Sep-2020 21:56:06 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=prod; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=ests; path=/; secure; samesite=none; httponly', + 'Date', + 'Thu, 13 Aug 2020 21:56:06 GMT' ]); nock('https://endpoint:443', {"encodedQueryParams":true}) - .get('/formrecognizer/v2.0/prebuilt/receipt/analyzeResults/df67d45f-07f3-48e8-9ed4-580d608e1873') - .reply(200, {"status":"succeeded","createdDateTime":"2020-08-05T23:29:03Z","lastUpdatedDateTime":"2020-08-05T23:29:04Z","analyzeResult":{"version":"2.0.0","readResults":[{"page":1,"angle":0.6893,"width":1688,"height":3000,"unit":"pixel","language":"en"}],"documentResults":[{"docType":"prebuilt:receipt","pageRange":[1,1],"fields":{"ReceiptType":{"type":"string","valueString":"Itemized","confidence":0.692},"MerchantName":{"type":"string","valueString":"Contoso Contoso","text":"Contoso Contoso","boundingBox":[378.2,292.4,1117.7,468.3,1035.7,812.7,296.3,636.8],"page":1,"confidence":0.613},"MerchantAddress":{"type":"string","valueString":"123 Main Street Redmond, WA 98052","text":"123 Main Street Redmond, WA 98052","boundingBox":[302,675.8,848.1,793.7,809.9,970.4,263.9,852.5],"page":1,"confidence":0.99},"MerchantPhoneNumber":{"type":"phoneNumber","valuePhoneNumber":"+19876543210","text":"987-654-3210","boundingBox":[278,1004,656.3,1054.7,646.8,1125.3,268.5,1074.7],"page":1,"confidence":0.99},"TransactionDate":{"type":"date","valueDate":"2019-06-10","text":"6/10/2019","boundingBox":[265.1,1228.4,525,1247,518.9,1332.1,259,1313.5],"page":1,"confidence":0.99},"TransactionTime":{"type":"time","valueTime":"13:59:00","text":"13:59","boundingBox":[541,1248,677.3,1261.5,668.9,1346.5,532.6,1333],"page":1,"confidence":0.977},"Items":{"type":"array","valueArray":[{"type":"object","valueObject":{"Quantity":{"type":"number","text":"1","boundingBox":[245.1,1581.5,300.9,1585.1,295,1676,239.2,1672.4],"page":1,"confidence":0.92},"Name":{"type":"string","valueString":"Cappuccino","text":"Cappuccino","boundingBox":[322,1586,654.2,1601.1,650,1693,317.8,1678],"page":1,"confidence":0.923},"TotalPrice":{"type":"number","valueNumber":2.2,"text":"$2.20","boundingBox":[1107.7,1584,1263,1574,1268.3,1656,1113,1666],"page":1,"confidence":0.918}}},{"type":"object","valueObject":{"Quantity":{"type":"number","text":"1","boundingBox":[232,1834,286.6,1835,285,1921,230.4,1920],"page":1,"confidence":0.858},"Name":{"type":"string","valueString":"BACON & EGGS","text":"BACON & EGGS","boundingBox":[308,1836,746,1841.4,745,1925.4,307,1920],"page":1,"confidence":0.916},"TotalPrice":{"type":"number","text":"$9.5","boundingBox":[1133.9,1955,1257,1952,1259.1,2036,1136,2039],"page":1,"confidence":0.916}}}]},"Subtotal":{"type":"number","valueNumber":11.7,"text":"11.70","boundingBox":[1146,2221,1297.3,2223,1296,2319,1144.7,2317],"page":1,"confidence":0.955},"Tax":{"type":"number","valueNumber":1.17,"text":"1.17","boundingBox":[1190,2359,1304,2359,1304,2456,1190,2456],"page":1,"confidence":0.979},"Tip":{"type":"number","valueNumber":1.63,"text":"1.63","boundingBox":[1094,2479,1267.7,2485,1264,2591,1090.3,2585],"page":1,"confidence":0.941},"Total":{"type":"number","valueNumber":14.5,"text":"$14.50","boundingBox":[1034.2,2617,1387.5,2638.2,1380,2763,1026.7,2741.8],"page":1,"confidence":0.985}}}]}}, [ + .get('/formrecognizer/v2.0/prebuilt/receipt/analyzeResults/d254705d-a6e6-4dc0-a818-3d777499dd81') + .reply(200, {"status":"succeeded","createdDateTime":"2020-08-13T21:56:00Z","lastUpdatedDateTime":"2020-08-13T21:56:02Z","analyzeResult":{"version":"2.0.0","readResults":[{"page":1,"angle":0.6893,"width":1688,"height":3000,"unit":"pixel","language":"en"}],"documentResults":[{"docType":"prebuilt:receipt","pageRange":[1,1],"fields":{"ReceiptType":{"type":"string","valueString":"Itemized","confidence":0.692},"MerchantName":{"type":"string","valueString":"Contoso Contoso","text":"Contoso Contoso","boundingBox":[378.2,292.4,1117.7,468.3,1035.7,812.7,296.3,636.8],"page":1,"confidence":0.613},"MerchantAddress":{"type":"string","valueString":"123 Main Street Redmond, WA 98052","text":"123 Main Street Redmond, WA 98052","boundingBox":[302,675.8,848.1,793.7,809.9,970.4,263.9,852.5],"page":1,"confidence":0.99},"MerchantPhoneNumber":{"type":"phoneNumber","valuePhoneNumber":"+19876543210","text":"987-654-3210","boundingBox":[278,1004,656.3,1054.7,646.8,1125.3,268.5,1074.7],"page":1,"confidence":0.99},"TransactionDate":{"type":"date","valueDate":"2019-06-10","text":"6/10/2019","boundingBox":[265.1,1228.4,525,1247,518.9,1332.1,259,1313.5],"page":1,"confidence":0.99},"TransactionTime":{"type":"time","valueTime":"13:59:00","text":"13:59","boundingBox":[541,1248,677.3,1261.5,668.9,1346.5,532.6,1333],"page":1,"confidence":0.977},"Items":{"type":"array","valueArray":[{"type":"object","valueObject":{"Quantity":{"type":"number","text":"1","boundingBox":[245.1,1581.5,300.9,1585.1,295,1676,239.2,1672.4],"page":1,"confidence":0.92},"Name":{"type":"string","valueString":"Cappuccino","text":"Cappuccino","boundingBox":[322,1586,654.2,1601.1,650,1693,317.8,1678],"page":1,"confidence":0.923},"TotalPrice":{"type":"number","valueNumber":2.2,"text":"$2.20","boundingBox":[1107.7,1584,1263,1574,1268.3,1656,1113,1666],"page":1,"confidence":0.918}}},{"type":"object","valueObject":{"Quantity":{"type":"number","text":"1","boundingBox":[232,1834,286.6,1835,285,1921,230.4,1920],"page":1,"confidence":0.858},"Name":{"type":"string","valueString":"BACON & EGGS","text":"BACON & EGGS","boundingBox":[308,1836,746,1841.4,745,1925.4,307,1920],"page":1,"confidence":0.916},"TotalPrice":{"type":"number","text":"$9.5","boundingBox":[1133.9,1955,1257,1952,1259.1,2036,1136,2039],"page":1,"confidence":0.916}}}]},"Subtotal":{"type":"number","valueNumber":11.7,"text":"11.70","boundingBox":[1146,2221,1297.3,2223,1296,2319,1144.7,2317],"page":1,"confidence":0.955},"Tax":{"type":"number","valueNumber":1.17,"text":"1.17","boundingBox":[1190,2359,1304,2359,1304,2456,1190,2456],"page":1,"confidence":0.979},"Tip":{"type":"number","valueNumber":1.63,"text":"1.63","boundingBox":[1094,2479,1267.7,2485,1264,2591,1090.3,2585],"page":1,"confidence":0.941},"Total":{"type":"number","valueNumber":14.5,"text":"$14.50","boundingBox":[1034.2,2617,1387.5,2638.2,1380,2763,1026.7,2741.8],"page":1,"confidence":0.985}}}]}}, [ 'Transfer-Encoding', 'chunked', 'Content-Type', 'application/json; charset=utf-8', 'x-envoy-upstream-service-time', - '24', + '61', 'apim-request-id', - '7f75b652-e40d-46d5-9acf-50fbd1b2a2ca', + '07def35d-b5bd-4f28-b891-a9d627c7e2b5', 'Strict-Transport-Security', 'max-age=31536000; includeSubDomains; preload', 'x-content-type-options', 'nosniff', 'Date', - 'Wed, 05 Aug 2020 23:29:07 GMT' + 'Thu, 13 Aug 2020 21:56:05 GMT' ]);