{"version":3,"file":"InteractionRequiredAuthError.js","sources":["../../src/error/InteractionRequiredAuthError.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { AuthError } from \"./AuthError\";\r\n\r\n/**\r\n * InteractionRequiredServerErrorMessage contains string constants used by error codes and messages returned by the server indicating interaction is required\r\n */\r\nexport const InteractionRequiredServerErrorMessage = [\r\n \"interaction_required\",\r\n \"consent_required\",\r\n \"login_required\"\r\n];\r\n\r\nexport const InteractionRequiredAuthSubErrorMessage = [\r\n \"message_only\",\r\n \"additional_action\",\r\n \"basic_action\",\r\n \"user_password_expired\",\r\n \"consent_required\"\r\n];\r\n\r\n/**\r\n * Interaction required errors defined by the SDK\r\n */\r\nexport const InteractionRequiredAuthErrorMessage = {\r\n noTokensFoundError: {\r\n code: \"no_tokens_found\",\r\n desc: \"No refresh token found in the cache. Please sign-in.\"\r\n },\r\n native_account_unavailable: {\r\n code: \"native_account_unavailable\",\r\n desc: \"The requested account is not available in the native broker. It may have been deleted or logged out. Please sign-in again using an interactive API.\"\r\n }\r\n};\r\n\r\n/**\r\n * Error thrown when user interaction is required.\r\n */\r\nexport class InteractionRequiredAuthError extends AuthError {\r\n\r\n constructor(errorCode?: string, errorMessage?: string, subError?: string) {\r\n super(errorCode, errorMessage, subError);\r\n this.name = \"InteractionRequiredAuthError\";\r\n\r\n Object.setPrototypeOf(this, InteractionRequiredAuthError.prototype);\r\n }\r\n\r\n /**\r\n * Helper function used to determine if an error thrown by the server requires interaction to resolve\r\n * @param errorCode \r\n * @param errorString \r\n * @param subError \r\n */\r\n static isInteractionRequiredError(errorCode?: string, errorString?: string, subError?: string): boolean {\r\n const isInteractionRequiredErrorCode = !!errorCode && InteractionRequiredServerErrorMessage.indexOf(errorCode) > -1;\r\n const isInteractionRequiredSubError = !!subError && InteractionRequiredAuthSubErrorMessage.indexOf(subError) > -1;\r\n const isInteractionRequiredErrorDesc = !!errorString && InteractionRequiredServerErrorMessage.some((irErrorCode) => {\r\n return errorString.indexOf(irErrorCode) > -1;\r\n });\r\n\r\n return isInteractionRequiredErrorCode || isInteractionRequiredErrorDesc || isInteractionRequiredSubError;\r\n }\r\n\r\n /**\r\n * Creates an error thrown when the authorization code required for a token request is null or empty.\r\n */\r\n static createNoTokensFoundError(): InteractionRequiredAuthError {\r\n return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.noTokensFoundError.code, InteractionRequiredAuthErrorMessage.noTokensFoundError.desc);\r\n }\r\n\r\n /**\r\n * Creates an error thrown when the native broker returns ACCOUNT_UNAVAILABLE status, indicating that the account was removed and interactive sign-in is required\r\n * @returns \r\n */\r\n static createNativeAccountUnavailableError(): InteractionRequiredAuthError {\r\n return new InteractionRequiredAuthError(InteractionRequiredAuthErrorMessage.native_account_unavailable.code, InteractionRequiredAuthErrorMessage.native_account_unavailable.desc);\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;AAAA;;;AAGG;AAIH;;AAEG;AACU,IAAA,qCAAqC,GAAG;IACjD,sBAAsB;IACtB,kBAAkB;IAClB,gBAAgB;EAClB;AAEW,IAAA,sCAAsC,GAAG;IAClD,cAAc;IACd,mBAAmB;IACnB,cAAc;IACd,uBAAuB;IACvB,kBAAkB;EACpB;AAEF;;AAEG;AACU,IAAA,mCAAmC,GAAG;AAC/C,IAAA,kBAAkB,EAAE;AAChB,QAAA,IAAI,EAAE,iBAAiB;AACvB,QAAA,IAAI,EAAE,sDAAsD;AAC/D,KAAA;AACD,IAAA,0BAA0B,EAAE;AACxB,QAAA,IAAI,EAAE,4BAA4B;AAClC,QAAA,IAAI,EAAE,qJAAqJ;AAC9J,KAAA;EACH;AAEF;;AAEG;AACH,IAAA,4BAAA,kBAAA,UAAA,MAAA,EAAA;IAAkD,SAAS,CAAA,4BAAA,EAAA,MAAA,CAAA,CAAA;AAEvD,IAAA,SAAA,4BAAA,CAAY,SAAkB,EAAE,YAAqB,EAAE,QAAiB,EAAA;AAA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