SubtleCrypto
Defined in: packages/core/src/auth-subtlecrypto.ts:31
SubtleCrypto implements AuthProvider using WebCrypto’s Subtle API.
Supports AES-GCM (default, AEAD), AES-CTR, and AES-CBC. For non-AEAD modes (CTR, CBC) an encrypt-then-MAC (HMAC-SHA256) construction is used automatically to provide ciphertext authentication.
The base keytype is CryptoKey.
Implements
Section titled “Implements”AuthProvider<CryptoKey,CryptoKey,CryptoKey>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SubtleCrypto(
signingAlgorithm?,_encryptionAlgorithmName?):SubtleCrypto
Defined in: packages/core/src/auth-subtlecrypto.ts:44
Nonce size follows the configured encryption algorithm: 12 bytes for GCM
and 16 bytes for CTR/CBC, exposed by the nonceBytes getter.
Parameters
Section titled “Parameters”signingAlgorithm?
Section titled “signingAlgorithm?”AlgorithmIdentifier | AesCbcParams | RsaPssParams | EcdsaParams
The type of algorithm used for signature and verification keys.
Remarks
https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/sign
_encryptionAlgorithmName?
Section titled “_encryptionAlgorithmName?”AesAlgorithmName = 'AES-GCM'
The encryption algorithm to use for encrypt/decrypt.
AES-GCM provides built-in AEAD. AES-CTR and AES-CBC use an encrypt-then-MAC (HMAC-SHA256) construction for authentication.
Returns
Section titled “Returns”SubtleCrypto
Properties
Section titled “Properties”_encryptionAlgorithmName
Section titled “_encryptionAlgorithmName”
readonly_encryptionAlgorithmName:AesAlgorithmName='AES-GCM'
Defined in: packages/core/src/auth-subtlecrypto.ts:65
The encryption algorithm to use for encrypt/decrypt.
AES-GCM provides built-in AEAD. AES-CTR and AES-CBC use an encrypt-then-MAC (HMAC-SHA256) construction for authentication.
initialInvitationCapacityProfile
Section titled “initialInvitationCapacityProfile”
readonlyinitialInvitationCapacityProfile:"peerborne-automerge-json-subtle-p384-v1"=INITIAL_INVITATION_CAPACITY_PROFILE
Defined in: packages/core/src/auth-subtlecrypto.ts:34
signingAlgorithm
Section titled “signingAlgorithm”
readonlysigningAlgorithm:AlgorithmIdentifier|AesCbcParams|RsaPssParams|EcdsaParams
Defined in: packages/core/src/auth-subtlecrypto.ts:50
The type of algorithm used for signature and verification keys.
Remarks
Section titled “Remarks”https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/sign
Accessors
Section titled “Accessors”nonceBytes
Section titled “nonceBytes”Get Signature
Section titled “Get Signature”get nonceBytes():
number
Defined in: packages/core/src/auth-subtlecrypto.ts:114
Returns the nonce/IV size in bytes for the configured encryption algorithm.
- AES-GCM: 12 bytes (96-bit IV, standard)
- AES-CTR: 16 bytes (128-bit counter block)
- AES-CBC: 16 bytes (128-bit IV)
Returns
Section titled “Returns”number
Returns the nonce/IV size in bytes for the configured encryption algorithm.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”_encryptionAlgorithmParams()
Section titled “_encryptionAlgorithmParams()”_encryptionAlgorithmParams(
nonce?):AesCtrParams|AesCbcParams|AesGcmParams
Defined in: packages/core/src/auth-subtlecrypto.ts:159
Generate algorithm parameters for the configured encryption algorithm.
Parameters
Section titled “Parameters”nonce?
Section titled “nonce?”Uint8Array<ArrayBufferLike>
If provided, used as the IV/counter. Otherwise a random one is generated.
Returns
Section titled “Returns”AesCtrParams | AesCbcParams | AesGcmParams
decrypt()
Section titled “decrypt()”decrypt(
data,documentKey,nonce?):Promise<Uint8Array<ArrayBufferLike>>
Defined in: packages/core/src/auth-subtlecrypto.ts:352
Decrypt data using the configured encryption algorithm.
For AES-GCM, authentication is built-in (AEAD). For AES-CTR and
AES-CBC, the HMAC-SHA256 tag appended by encrypt() is verified
before decryption to prevent padding oracle attacks (CBC) and
ciphertext tampering (CTR).
Parameters
Section titled “Parameters”Uint8Array
documentKey
Section titled “documentKey”CryptoKey
nonce?
Section titled “nonce?”Uint8Array<ArrayBufferLike>
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
Implementation of
Section titled “Implementation of”deserializePublicKey()
Section titled “deserializePublicKey()”deserializePublicKey(
serialized):Promise<CryptoKey>
Defined in: packages/core/src/auth-subtlecrypto.ts:326
Import a canonical P-384 ECDSA identity encoded by
serializePublicKey. Invitation authentication deliberately pins this
exact algorithm and curve; custom identity schemes must provide their own
AuthProvider.deserializePublicKey implementation.
Parameters
Section titled “Parameters”serialized
Section titled “serialized”string
Returns
Section titled “Returns”Promise<CryptoKey>
Implementation of
Section titled “Implementation of”AuthProvider.deserializePublicKey
encrypt()
Section titled “encrypt()”encrypt(
data,documentKey):Promise<SubtleCryptoEncryptionResult>
Defined in: packages/core/src/auth-subtlecrypto.ts:410
Encrypt data using the configured encryption algorithm.
For AES-CTR and AES-CBC, an HMAC-SHA256 tag over (nonce || ciphertext) is appended to the returned data for authentication. The document layer treats this as opaque ciphertext — the wire format is unchanged.
Parameters
Section titled “Parameters”Uint8Array
documentKey
Section titled “documentKey”CryptoKey
Returns
Section titled “Returns”Promise<SubtleCryptoEncryptionResult>
Implementation of
Section titled “Implementation of”serializePublicKey()
Section titled “serializePublicKey()”serializePublicKey(
publicKey):Promise<string>
Defined in: packages/core/src/auth-subtlecrypto.ts:307
Serialize a public CryptoKey to a stable base64-encoded string.
The encoding matches the one used by ACLs and keychain entries in
the yjs and automerge providers (exportKey('raw', ...) +
Base64), so a welcomeRecipient value attached by one peer is
directly comparable to another peer’s serialized public key.
The key must be extractable; this is satisfied for all keys imported or generated by the SubtleCrypto provider in this codebase.
Parameters
Section titled “Parameters”publicKey
Section titled “publicKey”CryptoKey
Returns
Section titled “Returns”Promise<string>
Implementation of
Section titled “Implementation of”AuthProvider.serializePublicKey
sign()
Section titled “sign()”sign(
data,privateKey):Promise<Uint8Array<ArrayBufferLike>>
Defined in: packages/core/src/auth-subtlecrypto.ts:261
Given data and a private key, returns a signature.
Parameters
Section titled “Parameters”Uint8Array
bytes to be signed
privateKey
Section titled “privateKey”CryptoKey
part of key pair used to sign and verify
Returns
Section titled “Returns”Promise<Uint8Array<ArrayBufferLike>>
signature over the data
Implementation of
Section titled “Implementation of”supportsInitialInvitationCapacity()
Section titled “supportsInitialInvitationCapacity()”supportsInitialInvitationCapacity(
privateKey,publicKey):boolean
Defined in: packages/core/src/auth-subtlecrypto.ts:69
Internal
Confirm the exact bounded identity/crypto invitation profile.
Parameters
Section titled “Parameters”privateKey
Section titled “privateKey”CryptoKey
publicKey
Section titled “publicKey”CryptoKey
Returns
Section titled “Returns”boolean
verify()
Section titled “verify()”verify(
data,publicKey,signature):Promise<boolean>
Defined in: packages/core/src/auth-subtlecrypto.ts:282
Given a signature and the signed data, a Promise that fulfills with true if the signature is valid, false otherwise
Parameters
Section titled “Parameters”Uint8Array
data that was signed
publicKey
Section titled “publicKey”CryptoKey
part of key pair used to sign and verify
signature
Section titled “signature”Uint8Array
signature to verify
Returns
Section titled “Returns”Promise<boolean>
a Promise that fulfills with true if the signature is valid, false otherwise