# @seald-io/sdk

SealdSDK allows you to use the full power of Seald encryption, directly in your application, whether a web-application in the browser, a Node.js server, a react-native mobile app, ...

You can create and retrieve Seald identities for your app's users, encrypt and decrypt files, create encryption sessions, add or revoke recipients ...

You can find the full changelog at https://www.seald.io/changelog#sdk (opens new window).

Example:

import SealdSDK from '@seald-io/sdk'

const seald = SealdSDK({
  appId,
  apiURL
})
await seald.initialize()

// Creating a Seald identity
await seald.initiateIdentity({ userId, userLicenseToken })

// Encrypting / Decrypting data
const encryptedFile = await seald.encryptFile('Secret file content', 'SecretFile.txt', { sealdIds: ['Other-User'] })
const decryptedFile = await seald.decryptFile(encryptedFile)

# Table of contents

# SDK Interfaces

# Helpers Interfaces

# SDK Constructor Type aliases

# Helpers Type aliases

# Other Type aliases

# SDK Constructor Type aliases

# SDKConstructor

Ƭ SDKConstructor: (args: { apiURL?: string ; appId: string ; databaseKey?: string ; databasePath?: string ; databaseRawKey?: string ; encryptionSessionCacheTTL?: number ; hairlessURL?: string ; keySize?: 1024 | 2048 | 4096 ; libPhoneNumber?: LibPhoneNumber ; nedbClient?: NedbClient ; plugins?: SDKPlugin[] ; shouldWaterfallApi?: boolean ; createEncryptionSessionCache?: (args: { appId: string ; databasePath?: string ; dbKey?: InstanceType<SSCrypto["SymKey"]> ; encryptionSessionCacheTTL: number ; scrypt: SCrypt ; sscrypto: SSCrypto }) => EncryptionSessionCache | Promise<EncryptionSessionCache> }) => SealdSDK

# Type declaration

▸ (args): SealdSDK

# Parameters
Name Type Description
args Object -
args.apiURL? string The Seald server URL to use. Only change it if asked to by the Seald team.
args.appId string The appId given to you by Seald. It is the unique identifier of your application for Seald's servers.
args.databaseKey? string If you are using a persistent database, the key to encrypt it with. A random string of at least 32 alphanumeric characters, stored by your back-end and given after authentication, is recommended. This will be derived into the actual encryption key.
args.databasePath? string If you want to have a persistent database, use this argument. On Node, takes a directory path. On the browser, takes an arbitrary string that will be a localStorage key. If not given, defaults to a memory-only non-persistent database.
args.databaseRawKey? string If you are using a persistent database, the raw key to encrypt it with. This MUST be the Base64 string encoding of a cryptographically random buffer of 64 bytes. This avoids deriving the databaseKey with scrypt. If you have any doubt, use databaseKey instead.
args.encryptionSessionCacheTTL? number Duration of cache lifetime in milliseconds. -1 to cache for lifetime. Default to 0 (no cache).
args.hairlessURL? string The Seald URL to use for documents for non-Seald users. Only change it if asked to by the Seald team.
args.keySize? 1024 | 2048 | 4096 Change the Asymmetric key size for newly generated keys. Defaults to 4096. Warning: for security, it is extremely not recommended to lower this value. For advanced use only.
args.libPhoneNumber? LibPhoneNumber Pass the import from 'google-libphonenumber' npm package if you want to use SMS-related features for entrusted recipients.
args.nedbClient? NedbClient To manually pass a follicle database client instance to the SDK. For advanced use only.
args.plugins? SDKPlugin[] Array of plugins to add to this SDK instance.
args.shouldWaterfallApi? boolean Should all requests to Seald's servers be serialized. Safer, but may be a bit slower. Defaults to false.
args.createEncryptionSessionCache? (args: { appId: string ; databasePath?: string ; dbKey?: InstanceType<SSCrypto["SymKey"]> ; encryptionSessionCacheTTL: number ; scrypt: SCrypt ; sscrypto: SSCrypto }) => EncryptionSessionCache | Promise<EncryptionSessionCache> -
# Returns

SealdSDK


# Helpers Type aliases

# AuthorizeRecipientResult

Ƭ AuthorizeRecipientResult: Object

# Type declaration

Name Type
addedHairlessRecipients { [key: string]: { already_recipient: boolean ; already_seald: boolean ; error: { code: string ; id: string } ; status: number }; }
addedRecipients { [key: string]: { error: null | { code: string ; id: string } ; status: number }; }

# Recipients

Ƭ Recipients: Object

# Type declaration

Name Type Description
sealdIds? string[] Internal Seald IDs. Returned for users with sdk.getCurrentAccountInfo, for groups when creating them.
userIds? string[] The IDs of users inside your app. First specified when you create an identity

# RevokeResult

Ƭ RevokeResult: Object

# Type declaration

Name Type Description
entrustedEmails { [email: string]: "ok" | "ko"; } Of the form { 'email@domain.com': 'ok'|'ko' }
revokeAll { entrustedEmails: { [email: string]: "ok" | "ko"; } ; userIDs: { [sealdId: string]: "ok" | "ko"; } } When revoking everyone. Contains subvalues of the same form as the other properties.
revokeAll.entrustedEmails { [email: string]: "ok" | "ko"; } -
revokeAll.userIDs { [sealdId: string]: "ok" | "ko"; } -
userIDs { [sealdId: string]: "ok" | "ko"; } Of the form { 'sealdId': 'ok'|'ko' }

# SCrypt

Ƭ SCrypt: (password: Buffer, salt: Buffer) => Promise<Buffer>

# Type declaration

▸ (password, salt): Promise<Buffer>

# Parameters
Name Type
password Buffer
salt Buffer
# Returns

Promise<Buffer>


# Other Type aliases

# EncryptionSessionCache

Ƭ EncryptionSessionCache: Object

# Type declaration

Name Type
get (id: string) => { serializationDate: number ; sessionSymKey: string } | Promise<{ serializationDate: number ; sessionSymKey: string }> | Promise<null>
set (id: string, value: { serializationDate: number ; sessionSymKey: string }) => void | Promise<void>

# PreGeneratedIdentityKey

Ƭ PreGeneratedIdentityKey: Object

# Type declaration

Name Type
privateEncryptingKeyPromise Promise<string>
privateSigningKeyPromise Promise<string>
rand string
ready boolean

# SerializationHook

Ƭ SerializationHook: (s: string) => string

# Type declaration

▸ (s): string

# Parameters
Name Type
s string
# Returns

string


# SerializationHooks

Ƭ SerializationHooks: Object

# Type declaration

Name Type
afterSerialization SerializationHook
beforeDeserialization SerializationHook