import { PowerAuthConfigurationType } from './model/PowerAuthConfiguration'; import { PowerAuthClientConfigurationType } from './model/PowerAuthClientConfiguration'; import { PowerAuthBiometryConfigurationType } from './model/PowerAuthBiometryConfiguration'; import { PowerAuthKeychainConfigurationType } from './model/PowerAuthKeychainConfiguration'; import { PowerAuthAuthorizationHttpHeader } from './model/PowerAuthAuthorizationHttpHeader'; import { PowerAuthActivationStatus } from './model/PowerAuthActivationStatus'; import { PowerAuthAuthentication, PowerAuthBiometricPrompt } from './model/PowerAuthAuthentication'; import { PowerAuthCreateActivationResult } from './model/PowerAuthCreateActivationResult'; import { PowerAuthActivation } from './model/PowerAuthActivation'; import { PowerAuthBiometryInfo } from './model/PowerAuthBiometryInfo'; import { PowerAuthRecoveryActivationData } from './model/PowerAuthRecoveryActivationData'; import { PowerAuthConfirmRecoveryCodeDataResult } from './model/PowerAuthConfirmRecoveryCodeDataResult'; import { PowerAuthTokenStore } from "./PowerAuthTokenStore"; import { PowerAuthEncryptor } from './model/PowerAuthEncryptor'; import { PowerAuthUserInfo } from "./model/PowerAuthUserInfo"; import { PasswordType, PowerAuthPassword } from './model/PowerAuthPassword'; import { PowerAuthSharingConfigurationType } from './model/PowerAuthSharingConfiguration'; import { PowerAuthExternalPendingOperation } from './model/PowerAuthExternalPendingOperation'; import { PowerAuthDataFormat } from "./model/PowerAuthDataFormat"; import { PowerAuthTimeSynchronizationService } from './PowerAuthTimeSynchronizationService'; /** * Class used for the main interaction with the PowerAuth SDK components. */ export declare class PowerAuth { readonly instanceId: string; /** Configuration used to configure this instance of class. */ get configuration(): PowerAuthConfigurationType | undefined; /** Client configuration used to configure this instance of class. */ get clientConfiguration(): PowerAuthClientConfigurationType | undefined; /** Biometry configuration used to configure this instance of class. */ get biometryConfiguration(): PowerAuthBiometryConfigurationType | undefined; /** Keychain configuration used to configure this instance of class. */ get keychainConfiguration(): PowerAuthKeychainConfigurationType | undefined; /** Sharing configuration used to configure this instance of class. */ get sharingConfiguration(): PowerAuthSharingConfigurationType | undefined; /** Object for managing access tokens. */ readonly tokenStore: PowerAuthTokenStore; /** Object providing functions to synchronize time with the server. */ readonly timeSynchronizationService: PowerAuthTimeSynchronizationService; /** * Prepares the PowerAuth instance. * * 2 instances with the same instanceId will be internaly the same object! * * @param instanceId Identifier of the PowerAuthSDK instance. The bundle identifier/packagename is recommended. */ constructor(instanceId: string); /** If this PowerAuth instance was configured. */ isConfigured(): Promise; /** * Prepares the PowerAuth instance with an advanced configuration. The method needs to be called before before any other method. * * @param configuration Configuration object with basic parameters for `PowerAuth` class. * @param clientConfiguration Configuration for internal HTTP client. If `undefined`, then the default configuration is used. * @param biometryConfiguration Biometry configuration. If `undefined`, then the default configuration is used. * @param keychainConfiguration Configuration for internal keychain storage. If `undefined`, then the default configuration is used. * @param sharingConfiguration Configuration for iOS activation data sharing. If `undefined`, then no sharing configuration is applied. */ configure(configuration: PowerAuthConfigurationType, clientConfiguration?: PowerAuthClientConfigurationType, biometryConfiguration?: PowerAuthBiometryConfigurationType, keychainConfiguration?: PowerAuthKeychainConfigurationType, sharingConfiguration?: PowerAuthSharingConfigurationType): Promise; /** * Prepares the PowerAuth instance with a basic configuration. The method needs to be called before before any other method. * If you have to tweak more configuration properties, then use method variant with the configuration objects as parameters. * * @param configuration String with the cryptographic configuration. * @param baseEndpointUrl Base URL to the PowerAuth Standard RESTful API (the URL part before "/pa/..."). * @param enableUnsecureTraffic If HTTP and invalid HTTPS communication should be enabled * @returns Promise that with result of the configuration (can by rejected if already configured). */ configure(configuration: string, baseEndpointUrl: string, enableUnsecureTraffic: boolean): Promise; /** Deconfigures the instance */ deconfigure(): Promise; /** * Checks if there is a valid activation. * * @returns true if there is a valid activation, false otherwise. */ hasValidActivation(): Promise; /** * Check if it is possible to start an activation process. * * @returns true if activation process can be started, false otherwise. */ canStartActivation(): Promise; /** * Checks if there is a pending activation (activation in progress). * * @returns true if there is a pending activation, false otherwise. */ hasPendingActivation(): Promise; /** * Check if there's an external pending operation started in another application. * * @returns A promise with information about external pending operation. */ getExternalPendingOperation(): Promise; /** * Fetch the activation status for current activation. * * The following calls to PowerAuth Standard RESTful API endpoints are performed on the background: * - `/pa/activation/status` - to get the activation status * - `/pa/upgrade/start` - (optional) in case that protocol upgrade is required. * - `/pa/upgrade/commit` - (optional) in case that protocol upgrade is required. * - `/pa/signature/validate` - (optional) as a prevention to local counter desynchronization. * * @returns A promise with activation status result - it contains status information in case of success and error in case of failure. */ fetchActivationStatus(): Promise; /** * Create a new activation by calling a PowerAuth Standard RESTful API endpoint `/pa/activation/create`. * * @param activation A PowerAuthActivation object containg all information required for the activation creation. */ createActivation(activation: PowerAuthActivation): Promise; /** * Persists activation that was created and store related data using provided authentication instance. * * @param authentication An authentication instance specifying what factors should be stored. */ persistActivation(authentication: PowerAuthAuthentication): Promise; /** Activation identifier or undefined if object has no valid activation. */ getActivationIdentifier(): Promise; /** Fingerprint calculated from device's public key or undefined if object has no valid activation. */ getActivationFingerprint(): Promise; /** * Remove current activation by calling a PowerAuth Standard RESTful API endpoint `/pa/activation/remove`. The user can authenticate with password * or with biometry, if biometric factor is configured in the current activation. In case of biometry, the system biometric authentication dialog * is displayed, so the operation may take an undefined amount of time to complete. * * @param authentication An authentication instance specifying what factors should be used to sign the request. */ removeActivationWithAuthentication(authentication: PowerAuthAuthentication): Promise; /** * This method removes the activation session state and biometry factor key. Cached possession related key remains intact. * Unlike the `removeActivationWithAuthentication()`, this method doesn't inform server about activation removal. In this case * user has to remove the activation by using another channel (typically internet banking, or similar web management console) */ removeActivationLocal(): Promise; /** * Compute the HTTP signature header for GET HTTP method, URI identifier and HTTP query parameters using provided authentication information. * Be aware that if `PowerAuthAuthentication.useBiometry` is true, then the system biometric authentication dialog is displayed, so the operation * may take an undefined amount of time to complete. * * @param authentication An authentication instance specifying what factors should be used to sign the request. * @param uriId URI identifier. * @param params HTTP query params. * @returns HTTP header with PowerAuth authorization signature */ requestGetSignature(authentication: PowerAuthAuthentication, uriId: string, params?: any): Promise; /** * Compute the HTTP signature header for given HTTP method, URI identifier and HTTP request body using provided authentication information. * Be aware that if `PowerAuthAuthentication.useBiometry` is true, then the system biometric authentication dialog is displayed, so the operation * may take an undefined amount of time to complete. * * @param authentication An authentication instance specifying what factors should be used to sign the request. * @param method HTTP method used for the signature computation. * @param uriId URI identifier. * @param body HTTP request body. * @returns HTTP header with PowerAuth authorization signature. */ requestSignature(authentication: PowerAuthAuthentication, method: string, uriId: string, body?: string): Promise; /** * Compute the offline signature for given HTTP method, URI identifier and HTTP request body using provided authentication information. Be aware that if * `PowerAuthAuthentication.useBiometry` is true, then the system biometric authentication dialog is displayed, so the operation may take an undefined * amount of time to complete. * * @param authentication An authentication instance specifying what factors should be used to sign the request. The possession and knowledge is recommended. * @param uriId URI identifier. * @param body HTTP request body. * @param nonce NONCE in Base64 format. * @returns String representing a calculated signature for all involved factors. */ offlineSignature(authentication: PowerAuthAuthentication, uriId: string, nonce: string, body?: string): Promise; /** * Validates whether the data has been signed with master server private key or personalized server's private key. * * @param data An arbitrary data * @param signature A signature calculated for data, in Base64 format * @param masterKey If `true`, then master server public key is used for validation, otherwise personalized server's public key. */ verifyServerSignedData(data: string, signature: string, masterKey: boolean): Promise; /** * Change the password, validate old password by calling a PowerAuth Standard RESTful API endpoint `/pa/signature/validate`. * * @param oldPassword Old password, currently set to store the data. * @param newPassword New password, to be set in case authentication with old password passes. */ changePassword(oldPassword: PasswordType, newPassword: PasswordType): Promise; /** * Change the password using local re-encryption, do not validate old password by calling any endpoint. * * You are responsible for validating the old password against some server endpoint yourself before using it in this method. * If you do not validate the old password to make sure it is correct, calling this method will corrupt the local data, since * existing data will be decrypted using invalid PIN code and re-encrypted with a new one. @param oldPassword Old password, currently set to store the data. @param newPassword New password, to be set in case authentication with old password passes. @returns Returns true in case password was changed without error, false otherwise. */ unsafeChangePassword(oldPassword: PasswordType, newPassword: PasswordType): Promise; /** * Regenerate a biometry related factor key. This variant of method is useful only on iOS platform or on Android, if `authenticateOnBiometricKeySetup` is `false`. * This method calls PowerAuth Standard RESTful API endpoint `/pa/vault/unlock` to obtain the vault encryption key used for original private key decryption. * * @param password Password used for authentication during vault unlocking call. */ addBiometryFactor(password: PasswordType): Promise; /** * Regenerate a biometry related factor key. * This method calls PowerAuth Standard RESTful API endpoint `/pa/vault/unlock` to obtain the vault encryption key used for original private key decryption. * * @param password Password used for authentication during vault unlocking call. * @param prompt Prompt to be displayed. Parameter is required on Android platform if `authenticateOnBiometricKeySetup` is `true`. */ addBiometryFactor(password: PasswordType, prompt: PowerAuthBiometricPrompt | undefined): Promise; /** * Regenerate a biometry related factor key. * This method calls PowerAuth Standard RESTful API endpoint `/pa/vault/unlock` to obtain the vault encryption key used for original private key decryption. * * @param password Password used for authentication during vault unlocking call. * @param title Title for biometry dialog. Parameter is required on Android platform if `authenticateOnBiometricKeySetup` is `true`. * @param description Description for biometry dialog. Parameter is required on Android platform if `authenticateOnBiometricKeySetup` is `true`. */ addBiometryFactor(password: PasswordType, title: string, description: string): Promise; /** * Checks if a biometry related factor is present. * This method returns the information about the key value being present in keychain. */ hasBiometryFactor(): Promise; /** * Remove the biometry related factor key. */ removeBiometryFactor(): Promise; /** * Returns biometry info data. * * @returns object with information data about biometry */ getBiometryInfo(): Promise; /** * Generate a derived encryption key with given index. The key is returned in form of base64 encoded string. * * This method calls PowerAuth Standard RESTful API endpoint `/pa/vault/unlock` to obtain the vault encryption key used * for subsequent key derivation using given index. * * @param authentication Authentication used for vault unlocking call. * @param index Index of the derived key using KDF. */ fetchEncryptionKey(authentication: PowerAuthAuthentication, index: number): Promise; /** * Sign given data with the original device private key (asymetric signature). * * This method calls PowerAuth Standard RESTful API endpoint `/pa/vault/unlock` to obtain the vault encryption key * used for private key decryption. Data is then signed using ECDSA algorithm with this key and can be validated on the server side. * * @param authentication Authentication used for vault unlocking call. * @param data Data to be signed with the private key. * @param dataFormat Data format of the input data. */ signDataWithDevicePrivateKey(authentication: PowerAuthAuthentication, data: string, dataFormat: PowerAuthDataFormat): Promise; /** * Validate a user password. * * This method calls PowerAuth Standard RESTful API endpoint `/pa/signature/validate` to validate the signature value. * * @param password Password to be verified. */ validatePassword(password: PasswordType): Promise; /** * Returns YES if underlying session contains an activation recovery data. */ hasActivationRecoveryData(): Promise; /** * Get an activation recovery data. * * This method calls PowerAuth Standard RESTful API endpoint `/pa/vault/unlock` to obtain the vault encryption key used for private recovery data decryption. * * @param authentication Authentication used for vault unlocking call. */ activationRecoveryData(authentication: PowerAuthAuthentication): Promise; /** * Confirm given recovery code on the server by calling a PowerAuth Standard RESTful API endpoint `/pa/recovery/confirm`. * * The method is useful for situations when user receives a recovery information via OOB channel (for example via postcard). * Such recovery codes cannot be used without a proper confirmation on the server. To confirm codes, user has to authenticate himself * with a knowledge factor. * * Note that the provided recovery code can contain a `"R:"` prefix, if it's scanned from QR code. * * @param recoveryCode Recovery code to confirm * @param authentication Authentication used for recovery code confirmation * * @returns Result of the confirmation */ confirmRecoveryCode(recoveryCode: string, authentication: PowerAuthAuthentication): Promise; /** * Function verify activation code scanned from QR code whethner it's formally valid and is issued by * the PowerAuth Server. * @param activationCode Activation code to scan. * @returns true if activation code is valid and is issued by PowerAuth Server. */ verifyScannedActivationCode(activationCode: string): Promise; /** * Helper method for grouping biometric authentications. * * With this method, you can use 1 biometric authentication (dialog) for several operations. * Just use the `reusableAuthentication` variable inside the `groupedAuthenticationCalls` callback. * * Be aware, that you must not execute the next HTTP request signed with the same credentials when the previous one * fails with the 401 HTTP status code. If you do, then you risk blocking the user's activation on the server. * * @param authentication authentication object * @param groupedAuthenticationCalls call that will use reusable authentication object */ groupedBiometricAuthentication(authentication: PowerAuthAuthentication, groupedAuthenticationCalls: (reusableAuthentication: PowerAuthAuthentication) => Promise): Promise; /** * Create a new PowerAuthPassword object that will be destroyed automatically when this PowerAuth instance is deconfigured. * @param destroyOnUse If `true` then the underlying native password is destroyed immediately after it's used for a cryptographic operation. * @param onAutomaticCleanup If provided, then the closure is called when the native password is restored and the previous content is lost. * @returns new instance of PowerAuthPassword class that's owned by this PowerAuth instance. */ createPassword(destroyOnUse?: boolean, onAutomaticCleanup?: (() => void) | undefined): PowerAuthPassword; /** * Fetch information about the user from the server. * If the operation succeeds, then the user information object is also * internally stored and available in the [getLastFetchedUserInfo] method. */ fetchUserInfo(): Promise; /** * Returns the last fetched user info or undefined when there's no cached user info available. * * Notes: * - On iOS native SDK, `PowerAuthSDK.lastFetchedUserInfo` is nullable and may be `nil` until user info is fetched. * - This bridge returns `undefined` when the native value is `nil`, or when the claims are missing/empty. */ getLastFetchedUserInfo(): Promise; /** * Creates a new instance of encryptor suited for general end-to-end encryption purposes. The returned * encryptor is cryptographically bounded to the PowerAuth configuration, so it can be used with or * without a valid activation. */ getEncryptorForApplicationScope(): PowerAuthEncryptor; /** * Creates a new instance of encryptor suited for general end-to-end encryption purposes. The returned * encryptor is cryptographically bounded to a device's activation, so it can be used only when this * instance has a valid activation. */ getEncryptorForActivationScope(): PowerAuthEncryptor; /** * Method will process `PowerAuthAuthentication` object are will return object according to the platform. * * @param authentication authentication configuration * @returns configured authorization object */ private authenticate; }