Class SealdSDK

  • All Implemented Interfaces:

    
    public final class SealdSDK
    
                        

    This is the main class for the Seald SDK. It represents an instance of the Seald SDK.

    • Constructor Detail

      • SealdSDK

        SealdSDK(String apiURL, String appId, String dbPath, String dbb64SymKey, String instanceName, Byte logLevel, Boolean logNoColor, Duration encryptionSessionCacheTTL, Integer keySize)
        Parameters:
        apiURL - The Seald server for this instance to use.
        appId - The ID given by the Seald server to your app.
        dbPath - The path where to store the local Seald database.
        dbb64SymKey - The encryption key with which to encrypt the local Seald database.
        instanceName - An arbitrary name to give to this Seald instance.
        logLevel - The minimum level of logs you want.
        logNoColor - Should be set to false if you want to enable colors in the log output.
        encryptionSessionCacheTTL - The duration of cache lifetime.
        keySize - The Asymmetric key size for newly generated keys.
      • SealdSDK

        SealdSDK(String apiURL, String appId, String dbPath, String dbb64SymKey, String instanceName, Byte logLevel, Boolean logNoColor, Duration encryptionSessionCacheTTL)
        Parameters:
        apiURL - The Seald server for this instance to use.
        appId - The ID given by the Seald server to your app.
        dbPath - The path where to store the local Seald database.
        dbb64SymKey - The encryption key with which to encrypt the local Seald database.
        instanceName - An arbitrary name to give to this Seald instance.
        logLevel - The minimum level of logs you want.
        logNoColor - Should be set to false if you want to enable colors in the log output.
        encryptionSessionCacheTTL - The duration of cache lifetime.
      • SealdSDK

        SealdSDK(String apiURL, String appId, String dbPath, String dbb64SymKey, String instanceName, Byte logLevel, Boolean logNoColor)
        Parameters:
        apiURL - The Seald server for this instance to use.
        appId - The ID given by the Seald server to your app.
        dbPath - The path where to store the local Seald database.
        dbb64SymKey - The encryption key with which to encrypt the local Seald database.
        instanceName - An arbitrary name to give to this Seald instance.
        logLevel - The minimum level of logs you want.
        logNoColor - Should be set to false if you want to enable colors in the log output.
      • SealdSDK

        SealdSDK(String apiURL, String appId, String dbPath, String dbb64SymKey, String instanceName, Byte logLevel)
        Parameters:
        apiURL - The Seald server for this instance to use.
        appId - The ID given by the Seald server to your app.
        dbPath - The path where to store the local Seald database.
        dbb64SymKey - The encryption key with which to encrypt the local Seald database.
        instanceName - An arbitrary name to give to this Seald instance.
        logLevel - The minimum level of logs you want.
      • SealdSDK

        SealdSDK(String apiURL, String appId, String dbPath, String dbb64SymKey, String instanceName)
        Parameters:
        apiURL - The Seald server for this instance to use.
        appId - The ID given by the Seald server to your app.
        dbPath - The path where to store the local Seald database.
        dbb64SymKey - The encryption key with which to encrypt the local Seald database.
        instanceName - An arbitrary name to give to this Seald instance.
      • SealdSDK

        SealdSDK(String apiURL, String appId, String dbPath, String dbb64SymKey)
        Parameters:
        apiURL - The Seald server for this instance to use.
        appId - The ID given by the Seald server to your app.
        dbPath - The path where to store the local Seald database.
        dbb64SymKey - The encryption key with which to encrypt the local Seald database.
      • SealdSDK

        SealdSDK(String apiURL, String appId, String dbPath)
        Parameters:
        apiURL - The Seald server for this instance to use.
        appId - The ID given by the Seald server to your app.
        dbPath - The path where to store the local Seald database.
      • SealdSDK

        SealdSDK(String apiURL, String appId)
        Parameters:
        apiURL - The Seald server for this instance to use.
        appId - The ID given by the Seald server to your app.
    • Method Detail

      • close

         final Unit close()

        Close the current SDK instance. This frees any lock on the current database. After calling close, the instance cannot be used anymore.

      • closeAsync

         final Unit closeAsync()

        Close the current SDK instance. This frees any lock on the current database. After calling close, the instance cannot be used anymore.

      • createAccount

        @JvmOverloads() final AccountInfo createAccount(String signupJWT, String displayName, String deviceName, Duration expireAfter)

        Create a new Seald SDK account for this Seald SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        signupJWT - The JWT to allow this SDK instance to create an account.
        displayName - An optional name for the user to create.
        deviceName - An optional name for the device to create.
        expireAfter - The duration during which the created device key will be valid without renewal.
      • createAccount

        @JvmOverloads() final AccountInfo createAccount(String signupJWT, String displayName, String deviceName)

        Create a new Seald SDK account for this Seald SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        signupJWT - The JWT to allow this SDK instance to create an account.
        displayName - An optional name for the user to create.
        deviceName - An optional name for the device to create.
      • createAccount

        @JvmOverloads() final AccountInfo createAccount(String signupJWT, String displayName)

        Create a new Seald SDK account for this Seald SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        signupJWT - The JWT to allow this SDK instance to create an account.
        displayName - An optional name for the user to create.
      • createAccount

        @JvmOverloads() final AccountInfo createAccount(String signupJWT)

        Create a new Seald SDK account for this Seald SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        signupJWT - The JWT to allow this SDK instance to create an account.
      • createAccountAsync

        @JvmOverloads() final AccountInfo createAccountAsync(String signupJWT, String displayName, String deviceName, Duration expireAfter)

        Create a new Seald SDK account for this Seald SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        signupJWT - The JWT to allow this SDK instance to create an account.
        displayName - An optional name for the user to create.
        deviceName - An optional name for the device to create.
        expireAfter - The duration during which the created device key will be valid without renewal.
      • createAccountAsync

        @JvmOverloads() final AccountInfo createAccountAsync(String signupJWT, String displayName, String deviceName)

        Create a new Seald SDK account for this Seald SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        signupJWT - The JWT to allow this SDK instance to create an account.
        displayName - An optional name for the user to create.
        deviceName - An optional name for the device to create.
      • createAccountAsync

        @JvmOverloads() final AccountInfo createAccountAsync(String signupJWT, String displayName)

        Create a new Seald SDK account for this Seald SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        signupJWT - The JWT to allow this SDK instance to create an account.
        displayName - An optional name for the user to create.
      • createAccountAsync

        @JvmOverloads() final AccountInfo createAccountAsync(String signupJWT)

        Create a new Seald SDK account for this Seald SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        signupJWT - The JWT to allow this SDK instance to create an account.
      • updateCurrentDevice

         final Unit updateCurrentDevice()

        Updates the locally known information about the current device. You should never have to call this manually, except if you getting null in AccountInfo.deviceExpires, which can happen if migrating from an older version of the SDK, or if the internal call to updateCurrentDevice failed when calling SealdSdk.importIdentity.

      • updateCurrentDeviceAsync

         final Unit updateCurrentDeviceAsync()

        Updates the locally known information about the current device. You should never have to call this manually, except if you getting null in AccountInfo.deviceExpires, which can happen if migrating from an older version of the SDK, or if the internal call to updateCurrentDevice failed when calling SealdSdk.importIdentity.

      • renewKeys

        @JvmOverloads() final Unit renewKeys(Duration expireAfter)

        Renew the keys of the current device, extending their validity. If the current device has expired, you will need to call renewKeys before you are able to do anything else. Warning: if the identity of the current device is stored externally, for example on SSKS, you will want to re-export it and store it again, otherwise the previously stored identity will not be recognized anymore.

        Parameters:
        expireAfter - The duration during which the renewed device key will be valid without further renewal.
      • renewKeys

        @JvmOverloads() final Unit renewKeys()

        Renew the keys of the current device, extending their validity. If the current device has expired, you will need to call renewKeys before you are able to do anything else. Warning: if the identity of the current device is stored externally, for example on SSKS, you will want to re-export it and store it again, otherwise the previously stored identity will not be recognized anymore.

      • renewKeysAsync

        @JvmOverloads() final Unit renewKeysAsync(Duration expireAfter)

        Renew the keys of the current device, extending their validity. If the current device has expired, you will need to call renewKeys before you are able to do anything else. Warning: if the identity of the current device is stored externally, for example on SSKS, you will want to re-export it and store it again, otherwise the previously stored identity will not be recognized anymore.

        Parameters:
        expireAfter - The duration during which the renewed device key will be valid without further renewal.
      • renewKeysAsync

        @JvmOverloads() final Unit renewKeysAsync()

        Renew the keys of the current device, extending their validity. If the current device has expired, you will need to call renewKeys before you are able to do anything else. Warning: if the identity of the current device is stored externally, for example on SSKS, you will want to re-export it and store it again, otherwise the previously stored identity will not be recognized anymore.

      • createSubIdentity

        @JvmOverloads() final CreateSubIdentityResponse createSubIdentity(String deviceName, Duration expireAfter)

        Create a new sub-identity, or new device, for the current user account. After creating this new device, you will probably want to call SealdSDK.massReencrypt, so that the newly created device will be able to decrypt EncryptionSessions previously created for this account.

        Parameters:
        deviceName - An optional name for the device to create.
        expireAfter - The duration during which the device key for the device to create will be valid without renewal.
      • createSubIdentityAsync

        @JvmOverloads() final CreateSubIdentityResponse createSubIdentityAsync(String deviceName, Duration expireAfter)

        Create a new sub-identity, or new device, for the current user account. After creating this new device, you will probably want to call SealdSDK.massReencrypt, so that the newly created device will be able to decrypt EncryptionSessions previously created for this account.

        Parameters:
        deviceName - An optional name for the device to create.
        expireAfter - The duration during which the device key for the device to create will be valid without renewal.
      • importIdentity

         final Unit importIdentity(ByteArray identity)

        Load an identity export into the current SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        identity - The identity export that this SDK instance should import.
      • importIdentityAsync

         final Unit importIdentityAsync(ByteArray identity)

        Load an identity export into the current SDK instance. This function can only be called if the current SDK instance does not have an account yet.

        Parameters:
        identity - The identity export that this SDK instance should import.
      • pushJWT

         final Unit pushJWT(String jwt)

        Push a given JWT to the Seald server, for example to add a connector to the current account.

        Parameters:
        jwt - The JWT to push
      • pushJWTAsync

         final Unit pushJWTAsync(String jwt)

        Push a given JWT to the Seald server, for example to add a connector to the current account.

        Parameters:
        jwt - The JWT to push
      • heartbeat

         final Unit heartbeat()

        Just call the Seald server, without doing anything. This may be used for example to verify that the current instance has a valid identity.

      • heartbeatAsync

         final Unit heartbeatAsync()

        Just call the Seald server, without doing anything. This may be used for example to verify that the current instance has a valid identity.

      • createGroup

         final String createGroup(String groupName, Array<String> members, Array<String> admins)

        Create a group, and returns the created group's ID. admins must also be members. admins must include yourself.

        Parameters:
        groupName - A name for the group.
        members - The Seald IDs of the members to add to the group.
        admins - The Seald IDs of the members to also add as group admins.
      • createGroupAsync

         final String createGroupAsync(String groupName, Array<String> members, Array<String> admins)

        Create a group, and returns the created group's ID. admins must also be members. admins must include yourself.

        Parameters:
        groupName - A name for the group.
        members - The Seald IDs of the members to add to the group.
        admins - The Seald IDs of the members to also add as group admins.
      • addGroupMembers

        @JvmOverloads() final Unit addGroupMembers(String groupId, Array<String> membersToAdd, Array<String> adminsToSet)

        Add members to a group. Can only be done by a group administrator. Can also specify which of these newly added group members should also be admins.

        Parameters:
        groupId - The group in which to add members.
        membersToAdd - The Seald IDs of the members to add to the group.
        adminsToSet - The Seald IDs of the newly added members to also set as group admins.
      • addGroupMembers

        @JvmOverloads() final Unit addGroupMembers(String groupId, Array<String> membersToAdd)

        Add members to a group. Can only be done by a group administrator. Can also specify which of these newly added group members should also be admins.

        Parameters:
        groupId - The group in which to add members.
        membersToAdd - The Seald IDs of the members to add to the group.
      • addGroupMembersAsync

        @JvmOverloads() final Unit addGroupMembersAsync(String groupId, Array<String> membersToAdd, Array<String> adminsToSet)

        Add members to a group. Can only be done by a group administrator. Can also specify which of these newly added group members should also be admins.

        Parameters:
        groupId - The group in which to add members.
        membersToAdd - The Seald IDs of the members to add to the group.
        adminsToSet - The Seald IDs of the newly added members to also set as group admins.
      • addGroupMembersAsync

        @JvmOverloads() final Unit addGroupMembersAsync(String groupId, Array<String> membersToAdd)

        Add members to a group. Can only be done by a group administrator. Can also specify which of these newly added group members should also be admins.

        Parameters:
        groupId - The group in which to add members.
        membersToAdd - The Seald IDs of the members to add to the group.
      • removeGroupMembers

         final Unit removeGroupMembers(String groupId, Array<String> membersToRemove)

        Remove members from the group. Can only be done by a group administrator. You should call renewGroupKey after this.

        Parameters:
        groupId - The group from which to remove members.
        membersToRemove - The Seald IDs of the members to remove from the group.
      • removeGroupMembersAsync

         final Unit removeGroupMembersAsync(String groupId, Array<String> membersToRemove)

        Remove members from the group. Can only be done by a group administrator. You should call renewGroupKey after this.

        Parameters:
        groupId - The group from which to remove members.
        membersToRemove - The Seald IDs of the members to remove from the group.
      • renewGroupKey

         final Unit renewGroupKey(String groupId)

        Renew the group's private key. Can only be done by a group administrator. Should be called after removing members from the group.

        Parameters:
        groupId - The group for which to renew the private key.
      • renewGroupKeyAsync

         final Unit renewGroupKeyAsync(String groupId)

        Renew the group's private key. Can only be done by a group administrator. Should be called after removing members from the group.

        Parameters:
        groupId - The group for which to renew the private key.
      • setGroupAdmins

         final Unit setGroupAdmins(String groupId, Array<String> addToAdmins, Array<String> removeFromAdmins)

        Add some existing group members to the group admins, and/or removes admin status from some existing group admins. Can only be done by a group administrator.

        Parameters:
        groupId - The group for which to set admins.
        addToAdmins - The Seald IDs of existing group members to add as group admins.
        removeFromAdmins - The Seald IDs of existing group members to remove from group admins.
      • setGroupAdminsAsync

         final Unit setGroupAdminsAsync(String groupId, Array<String> addToAdmins, Array<String> removeFromAdmins)

        Add some existing group members to the group admins, and/or removes admin status from some existing group admins. Can only be done by a group administrator.

        Parameters:
        groupId - The group for which to set admins.
        addToAdmins - The Seald IDs of existing group members to add as group admins.
        removeFromAdmins - The Seald IDs of existing group members to remove from group admins.
      • createEncryptionSession

        @JvmOverloads() final EncryptionSession createEncryptionSession(Array<String> recipients, Boolean useCache)

        Create an encryption session, and returns the associated EncryptionSession instance, with which you can then encrypt / decrypt multiple messages. Warning : if you want to be able to retrieve the session later, you must put your own UserId in the recipients argument.

        Parameters:
        recipients - The Seald IDs of users who should be able to retrieve this session.
        useCache - Whether or not to use the cache (if enabled globally).
      • createEncryptionSession

        @JvmOverloads() final EncryptionSession createEncryptionSession(Array<String> recipients)

        Create an encryption session, and returns the associated EncryptionSession instance, with which you can then encrypt / decrypt multiple messages. Warning : if you want to be able to retrieve the session later, you must put your own UserId in the recipients argument.

        Parameters:
        recipients - The Seald IDs of users who should be able to retrieve this session.
      • createEncryptionSessionAsync

        @JvmOverloads() final EncryptionSession createEncryptionSessionAsync(Array<String> recipients, Boolean useCache)

        Create an encryption session, and returns the associated EncryptionSession instance, with which you can then encrypt / decrypt multiple messages. Warning : if you want to be able to retrieve the session later, you must put your own UserId in the recipients argument.

        Parameters:
        recipients - The Seald IDs of users who should be able to retrieve this session.
        useCache - Whether or not to use the cache (if enabled globally).
      • createEncryptionSessionAsync

        @JvmOverloads() final EncryptionSession createEncryptionSessionAsync(Array<String> recipients)

        Create an encryption session, and returns the associated EncryptionSession instance, with which you can then encrypt / decrypt multiple messages. Warning : if you want to be able to retrieve the session later, you must put your own UserId in the recipients argument.

        Parameters:
        recipients - The Seald IDs of users who should be able to retrieve this session.
      • getSealdIdsFromConnectors

         final Array<String> getSealdIdsFromConnectors(Array<ConnectorTypeValue> connectorTypeValues)

        Get all the info for the given connectors to look for, updates the local cache of connectors, and returns a slice with the corresponding SealdIds. SealdIds are not de-duped and can appear for multiple connector values. If one of the connectors is not assigned to a Seald user, this will return a ErrorGetSealdIdsUnknownConnector error, with the details of the missing connector.

        Parameters:
        connectorTypeValues - An Array of ConnectorTypeValue instances.
      • getSealdIdsFromConnectorsAsync

         final Array<String> getSealdIdsFromConnectorsAsync(Array<ConnectorTypeValue> connectorTypeValues)

        Get all the info for the given connectors to look for, updates the local cache of connectors, and returns a slice with the corresponding SealdIds. SealdIds are not de-duped and can appear for multiple connector values. If one of the connectors is not assigned to a Seald user, this will return a ErrorGetSealdIdsUnknownConnector error, with the details of the missing connector.

        Parameters:
        connectorTypeValues - An Array of ConnectorTypeValue instances.
      • addConnector

        @JvmOverloads() final Connector addConnector(String value, ConnectorType connectorType, PreValidationToken preValidationToken)

        Add a connector to the current identity. If no preValidationToken is given, the connector will need to be validated before use.

        Parameters:
        value - The value of the connector to add.
        connectorType - The type of the connector.
        preValidationToken - Given by your server to authorize the adding of a connector.
      • addConnector

        @JvmOverloads() final Connector addConnector(String value, ConnectorType connectorType)

        Add a connector to the current identity. If no preValidationToken is given, the connector will need to be validated before use.

        Parameters:
        value - The value of the connector to add.
        connectorType - The type of the connector.
      • addConnectorAsync

        @JvmOverloads() final Connector addConnectorAsync(String value, ConnectorType connectorType, PreValidationToken preValidationToken)

        Add a connector to the current identity. If no preValidationToken is given, the connector will need to be validated before use.

        Parameters:
        value - The value of the connector to add.
        connectorType - The type of the connector.
        preValidationToken - Given by your server to authorize the adding of a connector.
      • addConnectorAsync

        @JvmOverloads() final Connector addConnectorAsync(String value, ConnectorType connectorType)

        Add a connector to the current identity. If no preValidationToken is given, the connector will need to be validated before use.

        Parameters:
        value - The value of the connector to add.
        connectorType - The type of the connector.
      • validateConnector

         final Connector validateConnector(String connectorId, String challenge)

        Validate an added connector that was added without a preValidationToken.

        Parameters:
        connectorId - The ID of the connector to validate.
        challenge - The challenge.
      • validateConnectorAsync

         final Connector validateConnectorAsync(String connectorId, String challenge)

        Validate an added connector that was added without a preValidationToken.

        Parameters:
        connectorId - The ID of the connector to validate.
        challenge - The challenge.
      • removeConnector

         final Connector removeConnector(String connectorId)

        Remove a connector belonging to the current account.

        Parameters:
        connectorId - The ID of the connector to remove.
      • removeConnectorAsync

         final Connector removeConnectorAsync(String connectorId)

        Remove a connector belonging to the current account.

        Parameters:
        connectorId - The ID of the connector to remove.
      • retrieveConnector

         final Connector retrieveConnector(String connectorId)

        Retrieve a connector by its connectorId, then updates the local cache of connectors.

        Parameters:
        connectorId - The ID of the connector to retrieve.
      • retrieveConnectorAsync

         final Connector retrieveConnectorAsync(String connectorId)

        Retrieve a connector by its connectorId, then updates the local cache of connectors.

        Parameters:
        connectorId - The ID of the connector to retrieve.