createAccountAsync method

Future<SealdAccountInfo> createAccountAsync(
  1. String signupJwt, {
  2. String displayName = "User",
  3. String deviceName = "Device",
  4. SealdGeneratedPrivateKeys? privateKeys,
  5. Duration expireAfter = Duration.zero,
})

Creates 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.

signupJwt - The JWT to allow this SDK instance to create an account. displayName - A name for the user to create. This is metadata, useful on the Seald Dashboard for recognizing this user. Defaults to "User". deviceName - A name for the device to create. This is metadata, useful on the Seald Dashboard for recognizing this device. Defaults to "Device". privateKeys - Optional. Pre-generated private keys, returned by a call to SealdSdk.generatePrivateKeysAsync. expireAfter - The duration during which the created device key will be valid without renewal. Optional, defaults to 5 years.

Returns a SealdAccountInfo instance containing the Seald ID of the newly created Seald user, and the device ID.

Implementation

Future<SealdAccountInfo> createAccountAsync(String signupJwt,
    {String displayName = "User",
    String deviceName = "Device",
    SealdGeneratedPrivateKeys? privateKeys,
    Duration expireAfter = Duration.zero}) {
  return compute((Map<String, dynamic> args) async {
    privateKeys ??= await generatePrivateKeysAsync();
    return createAccount(args["signupJwt"],
        displayName: args["displayName"],
        deviceName: args["deviceName"],
        expireAfter: args["expireAfter"],
        privateKeys: privateKeys);
  }, {
    "signupJwt": signupJwt,
    "displayName": displayName,
    "deviceName": deviceName,
    "expireAfter": expireAfter
  });
}