Everything on this page is exported from @ave-id/sdk. The fragment helpers are also available from @ave-id/sdk/app-key, and the lookup and encryption helpers from @ave-id/sdk/app-encryption. For concepts and a walkthrough, see End-to-end encryption.
Scopes
Add one mode scope to every sign-in. Add E2EE_RESET_SCOPE only when you intend to rotate keys.
Reading keys from the callback
completeOAuthCallback, finishPkceLogin, completeExpoOAuthCallback, and the embed’s onTokens already merge the keys into the token response. Use these helpers when you exchange the code yourself.
mergeAppEncryptionFromUrl(url, tokens)
Returns a copy of tokens with every key found in the URL fragment: app_key, app_public_key, app_private_key, their _old counterparts, and app_key_reset.
mergeAppKeyFromUrl does the same for app_key only.
stripSensitiveFragmentParams(url?)
Removes key parameters from the current URL with history.replaceState, leaving other fragment parameters in place. Call it as soon as the keys are read.
Each returns the base64 value, or null when absent. Values are already normalized with normalizeAppKeyBase64, which restores + characters that URLSearchParams decodes as spaces.
stripSensitiveHashFromUrlString(url) and stripOAuthQueryParamsFromUrlString(url)
Return a copy of a URL string without key fragment parameters, or without OAuth query parameters. Use them before logging or displaying a callback URL.
Keys in AveSession
After a rotation, session.getState().snapshot also holds appKeyBase64Old, appPublicKeyBase64Old, appPrivateKeyBase64Old, and appEncryptionWasReset.
Public-key lookup
Lookups need no user token and return only data for identities that authorized your client ID with e2ee:asymmetric.
lookupAppPublicKeyByHandle(config, handle)
lookupAppUserByPublicKey(config, publicKey)
Both throw AppEncryptionLookupError on failure. Its status is 404 when the identity does not exist, has not authorized your app, or has no public key yet.
Encrypting for another user
encryptForAppUser(payload, recipientPublicKey)
Encrypts payload for the holder of recipientPublicKey. It generates an ephemeral P-256 key, derives an AES-256-GCM key with ECDH, and encrypts with a random 12-byte IV.
encryptForAppHandle(payload, params)
Looks up the recipient by handle, then calls encryptForAppUser.
decryptFromAppSender(envelope, privateKeyBase64)
Decrypts an AppEncryptedPayload with the recipient’s app_private_key.
importAppPrivateKey(privateKeyBase64)
Imports app_private_key as a non-extractable ECDH CryptoKey for your own key agreement code.
Example
Last modified on September 28, 2026