Skip to content

Functions

All methods are exposed on the cordova.tsauth object, which is available after the deviceready event. Every method except isUserCanceled returns a Promise.

Error handling

Rejections always use { code, platformCode, message }. Branch on code (ERRORS). Log platformCode, which is the native SDK's own name. When a platform error has no mapping, code is the raw platformCode rather than internalError.

initializeSDK

▸ initializeSDK(configurationFile?): Promise<boolean>

Initializes the plugin from TransmitSecurity.plist on iOS or from strings.xml on Android. configurationFile is the iOS plist basename and defaults to TransmitSecurity. Android ignores it.

Parameters

NameTypeDescription
configurationFile?stringiOS plist basename. Defaults to TransmitSecurity.

Returns

Promise<boolean>

Resolves with true.

Example

await cordova.tsauth.initializeSDK();

initialize

▸ initialize(clientId, options?): Promise<boolean>

Initializes the plugin with an explicit client ID. Use this when credentials are not read from the native config file.

Parameters

NameTypeDescription
clientIdstringClient ID from the app in the Admin Portal
options?InitializeOptionsBase URL, relying-party domain, and optional WebAuthn API paths

Returns

Promise<boolean>

Resolves with true.

Example

await cordova.tsauth.initialize('YOUR_CLIENT_ID', {
  baseUrl: 'https://api.transmitsecurity.io/',
  domain: 'your-domain.com',
});

setLoggingEnabled

▸ setLoggingEnabled(enabled): Promise<boolean>

Turns native and JavaScript logging on or off. Logging is off by default.

Parameters

NameTypeDescription
enabledbooleantrue enables logging

Returns

Promise<boolean>

Resolves with true.

Example

await cordova.tsauth.setLoggingEnabled(true);

isWebAuthnSupported

▸ isWebAuthnSupported(): Promise<boolean>

Reports whether this device and OS can use passkeys. Check this before offering passkey registration or authentication.

Returns

Promise<boolean>

Example

if (await cordova.tsauth.isWebAuthnSupported()) {
  await cordova.tsauth.registerWebAuthn('alice@example.com', 'Alice');
}

registerWebAuthn

▸ registerWebAuthn(username, displayName?): Promise<{ result: string }>

Registers a passkey for username. POST result to your backend, or pass it to an Orchestration journey with submitClientResponse.

Parameters

NameTypeDescription
usernamestringUser identifier in your system, such as an email address
displayName?stringDisplay name for the credential

Returns

Promise<{ result: string }>

result is the encoded credential.

Example

const { result } = await cordova.tsauth.registerWebAuthn('alice@example.com', 'Alice');

registerWebAuthnWithData

▸ registerWebAuthnWithData(registrationData): Promise<{ result: string }>

Registers a passkey from a server-provided WebAuthn registration payload, for flows where your backend already called start-registration.

Parameters

NameTypeDescription
registrationDataObject | stringServer WebAuthn payload, as an object or a JSON string

Returns

Promise<{ result: string }>

Example

const { result } = await cordova.tsauth.registerWebAuthnWithData(registrationData);

authenticateWebAuthn

▸ authenticateWebAuthn(username, options?): Promise<{ result: string }>

Authenticates with a passkey. Pass username as '' to let the platform offer any local passkey.

Parameters

NameTypeDescription
usernamestringUsername bound to the passkey, or '' for any local passkey
options?Object{ preferLocalCredentials: true } is iOS only and is ignored on Android

Returns

Promise<{ result: string }>

Example

const { result } = await cordova.tsauth.authenticateWebAuthn('alice@example.com');

authenticateWebAuthnWithData

▸ authenticateWebAuthnWithData(authenticationData, options?): Promise<{ result: string }>

Authenticates from a server-provided WebAuthn authentication payload.

Parameters

NameTypeDescription
authenticationDataObject | stringServer WebAuthn payload, as an object or a JSON string
options?Object{ preferLocalCredentials: true } is iOS only and is ignored on Android

Returns

Promise<{ result: string }>

Example

const { result } = await cordova.tsauth.authenticateWebAuthnWithData(authenticationData);

signWebAuthnTransaction

▸ signWebAuthnTransaction(username, options?): Promise<{ result: string }>

Signs a transaction with a passkey.

Parameters

NameTypeDescription
usernamestringUsername bound to the passkey
options?Object{ preferLocalCredentials: true } is iOS only and is ignored on Android

Returns

Promise<{ result: string }>

Example

const { result } = await cordova.tsauth.signWebAuthnTransaction('alice@example.com');

signWebAuthnTransactionWithData

▸ signWebAuthnTransactionWithData(authenticationData, options?): Promise<{ result: string }>

Signs a transaction from a server-provided WebAuthn authentication payload.

Parameters

NameTypeDescription
authenticationDataObject | stringServer WebAuthn payload, as an object or a JSON string
options?Object{ preferLocalCredentials: true } is iOS only and is ignored on Android

Returns

Promise<{ result: string }>

Example

const { result } = await cordova.tsauth.signWebAuthnTransactionWithData(authenticationData);

approvalWebAuthn

▸ approvalWebAuthn(approvalData, username?, options?): Promise<{ result: string }>

Runs a cross-device approval with a passkey.

Parameters

NameTypeDescription
approvalDataObjectString-to-string map describing what is approved
username?stringUsername bound to the passkey
options?Object{ preferLocalCredentials: true } is iOS only and is ignored on Android

Returns

Promise<{ result: string }>

Example

const { result } = await cordova.tsauth.approvalWebAuthn(approvalData, 'alice@example.com');

approvalWebAuthnWithData

▸ approvalWebAuthnWithData(authenticationData, options?): Promise<{ result: string }>

Runs a cross-device approval from a server-provided WebAuthn authentication payload.

Parameters

NameTypeDescription
authenticationDataObject | stringServer WebAuthn payload, as an object or a JSON string
options?Object{ preferLocalCredentials: true } is iOS only and is ignored on Android

Returns

Promise<{ result: string }>

Example

const { result } = await cordova.tsauth.approvalWebAuthnWithData(authenticationData);

registerNativeBiometrics

▸ registerNativeBiometrics(username): Promise<Object>

Enrolls the device biometric key for username.

Parameters

NameTypeDescription
usernamestringUser to associate with the biometric key

Returns

Promise<{ publicKeyId: string, publicKey: string, keyType: string, attestation: string, os: string }>

Example

const registration = await cordova.tsauth.registerNativeBiometrics('alice@example.com');

authenticateNativeBiometrics

▸ authenticateNativeBiometrics(username, challenge, promptTexts?): Promise<Object>

Signs challenge with the device biometric key and prompts the user. promptTexts applies on Android. iOS uses the system Face ID or Touch ID prompt and ignores promptTexts. The plugin supplies default prompt text.

Parameters

NameTypeDescription
usernamestringUser whose biometric key signs the challenge
challengestringChallenge to sign
promptTexts?PromptTextsAndroid prompt title, subtitle, and negative button

Returns

Promise<{ publicKeyId: string, signature: string }>

Example

const signed = await cordova.tsauth.authenticateNativeBiometrics(
  'alice@example.com',
  challenge
);

approvalNativeBiometrics

▸ approvalNativeBiometrics(username, challenge, promptTexts?): Promise<Object>

Signs challenge for an out-of-band approval. Same parameters and return value as authenticateNativeBiometrics.

Example

const signed = await cordova.tsauth.approvalNativeBiometrics('alice@example.com', challenge);

unregisterNativeBiometrics

▸ unregisterNativeBiometrics(username): Promise<{ publicKeyId: string }>

Removes the device biometric key for username.

Parameters

NameTypeDescription
usernamestringUser whose biometric key is removed

Returns

Promise<{ publicKeyId: string }>

Example

const removed = await cordova.tsauth.unregisterNativeBiometrics('alice@example.com');

getNativeBiometricsStatus

▸ getNativeBiometricsStatus(): Promise<Object>

Reports whether biometrics can be used on this device right now.

Returns

Promise<{ status: string, statusRaw: string, enrolled: boolean, type: string }>

status is one of BIOMETRICS_STATUS. type is faceID, touchID, or opticID on iOS, and biometric on Android. The plugin can also return none.

Example

const bio = await cordova.tsauth.getNativeBiometricsStatus();
if (bio.status !== cordova.tsauth.BIOMETRICS_STATUS.AVAILABLE) {
  // Offer PIN or a passkey instead
}

registerPinCode

▸ registerPinCode(username, pinCode): Promise<Object>

Starts PIN registration. The registration is held in memory and becomes durable only after commitPinRegistration. Commit after your backend has accepted the public key.

If the app restarts before commit, the context identifier is gone and commitPinRegistration rejects with invalidArgs. Start registration again.

Parameters

NameTypeDescription
usernamestringUser who owns the PIN
pinCodestringPIN to register

Returns

Promise<{ publicKeyId: string, publicKey: string, keyType: string, aliasDeviceName: string, contextIdentifier: string }>

Example

const reg = await cordova.tsauth.registerPinCode('alice', '1234');
await myBackend.storePublicKey(reg.publicKey, reg.publicKeyId);
await cordova.tsauth.commitPinRegistration(reg.contextIdentifier);

commitPinRegistration

▸ commitPinRegistration(contextIdentifier): Promise<boolean>

Finalizes a registerPinCode call after the backend has accepted the public key.

Parameters

NameTypeDescription
contextIdentifierstringcontextIdentifier returned by registerPinCode

Returns

Promise<boolean>

Resolves with true.

Example

await cordova.tsauth.commitPinRegistration(reg.contextIdentifier);

authenticatePinCode

▸ authenticatePinCode(username, pinCode, challenge): Promise<Object>

Signs challenge with the registered PIN.

Parameters

NameTypeDescription
usernamestringUser who owns the PIN
pinCodestringPIN to verify
challengestringChallenge to sign

Returns

Promise<{ publicKeyId: string, signature: string, challenge: string }>

Example

const signed = await cordova.tsauth.authenticatePinCode('alice', '1234', challenge);

unregisterPinCode

▸ unregisterPinCode(username): Promise<Object>

Starts PIN removal. Call commitPinUnregistration with the returned contextIdentifier to make the removal durable. The same in-memory rule as registration applies.

Parameters

NameTypeDescription
usernamestringUser whose PIN is removed

Returns

Promise<{ publicKeyId: string, contextIdentifier: string }>

Example

const pending = await cordova.tsauth.unregisterPinCode('alice');
await cordova.tsauth.commitPinUnregistration(pending.contextIdentifier);

commitPinUnregistration

▸ commitPinUnregistration(contextIdentifier): Promise<boolean>

Finalizes unregisterPinCode.

Parameters

NameTypeDescription
contextIdentifierstringcontextIdentifier returned by unregisterPinCode

Returns

Promise<boolean>

Resolves with true.

Example

await cordova.tsauth.commitPinUnregistration(pending.contextIdentifier);

registerTOTP

▸ registerTOTP(uri, securityType?): Promise<Object>

Registers a TOTP authenticator from an otpauth:// URI. Persist uuid. Later code generation uses that id. Any securityType other than none prompts the user when a code is generated.

Parameters

NameTypeDescription
uristringotpauth:// URI
securityType?stringOne of TOTP_SECURITY_TYPE. Defaults to none.

Returns

Promise<{ issuer: string, label: string, uuid: string }>

Example

const totp = await cordova.tsauth.registerTOTP(
  uri,
  cordova.tsauth.TOTP_SECURITY_TYPE.BIOMETRIC
);

generateTOTPCode

▸ generateTOTPCode(uuid): Promise<{ code: string }>

Generates a TOTP code for a registered authenticator.

Parameters

NameTypeDescription
uuidstringuuid returned by registerTOTP

Returns

Promise<{ code: string }>

Example

const { code } = await cordova.tsauth.generateTOTPCode(uuid);

generateTOTPCodeWithChallenge

▸ generateTOTPCodeWithChallenge(uuid, challenge): Promise<{ code: string }>

Generates a TOTP code bound to challenge, for transaction signing.

Parameters

NameTypeDescription
uuidstringuuid returned by registerTOTP
challengestringChallenge to bind to the code

Returns

Promise<{ code: string }>

Example

const { code } = await cordova.tsauth.generateTOTPCodeWithChallenge(uuid, challenge);

getDeviceInfo

▸ getDeviceInfo(): Promise<Object>

Returns the device public key.

Returns

Promise<{ publicKeyId: string, publicKey: string, keyType: string }>

keyType is present on Android.

Example

const device = await cordova.tsauth.getDeviceInfo();

signWithDeviceKey

▸ signWithDeviceKey(challenge): Promise<{ signature: string }>

Signs an arbitrary challenge with the device key.

Parameters

NameTypeDescription
challengestringChallenge to sign

Returns

Promise<{ signature: string }>

Example

const { signature } = await cordova.tsauth.signWithDeviceKey(challenge);

isUserCanceled

▸ isUserCanceled(error): boolean

Returns true when a rejection is the user leaving a prompt. This method is synchronous.

Parameters

NameTypeDescription
errorObjectRejection { code, platformCode, message }

Returns

boolean

Example

try {
  await cordova.tsauth.registerWebAuthn('alice@example.com');
} catch (e) {
  if (cordova.tsauth.isUserCanceled(e)) return;
  console.warn(e.code, e.platformCode, e.message);
}