submit abstract method

Future<AtEnrollmentResponse> submit(
  1. EnrollmentRequest enrollmentRequest,
  2. AtLookUp atLookUp
)

Submits an enrollment request.

The BaseEnrollmentRequest is an abstract class and serves as the entity responsible for submitting the enrollment request. This class contains fields that are shared between the FirstEnrollmentRequest and EnrollmentRequest which are subclasses of BaseEnrollmentRequest.

Use the FirstEnrollmentRequest when onboarding (activating) an @ sign for the initial time. Upon submitting the FirstEnrollmentRequest, an APKAM key pair and an encryption key pair are generated, and an enrollment request is sent to the server. The server assigns the "__manage" namespace, which has access to all namespaces and serves as the administrator app responsible for approving subsequent enrollment requests.

The enrollment request is auto-approved. When an @ sign is initially onboarded and the enableEnrollment flag is set to true in AtClientPreferences, the enrollment is sent to the server. In this scenario, because there's no app available for approval yet, the initial enrollment (submitted over a CRAM authenticated connection) is automatically approved. Conversely, if enableEnrollment is set to false, the enrollment isn't submitted, which means subsequent enrollment requests cannot be approved by the app.

Example on submitting FirstEnrollmentRequest
  FirstEnrollmentRequest firstEnrollmentRequest = FirstEnrollmentRequest(
              appName: 'wavi',
              deviceName: 'iphone',
              apkamPublicKey: 'dummy-apkam-public key', // Generated by the system
              encryptedDefaultEncryptionPrivateKey: 'dummy-encrypted-private-key', // Generated by the system and encrypted by the APKAM symmetric key
              encryptedDefaultSelfEncryptionKey: 'dummy-self-encryption-key'); // Generated by the system and encrypted by the APKAM symmetric key);

    AtEnrollmentResponse? atEnrollmentResponse =
        await atEnrollmentBase?.submit(initialEnrollmentRequest, atLookUp!);

Use AtEnrollmentRequest to submit subsequent enrollment requests to generate APKAM key-pair with limited access to the specified namespaces. The AtEnrollmentRequest accepts a AtAuthSession (the source of the atSign, rootDomain and the atKeysIo the new keys are persisted into) plus the enrollment-specific appName, deviceName, namespaces and otp.

Example on submitting AtEnrollmentRequest
  AtEnrollmentRequest enrollmentRequest = AtEnrollmentRequest(
                    session: session, // atSign + rootDomain + atKeysIo destination
                    appName: 'wavi',
                    deviceName: 'my-device',
                    namespaces: {'wavi': 'rw'},
                    otp: '123',
                    signingAlgo: SigningAlgoType.mldsa65); // the APKAM keypair's algorithm

    AtEnrollmentResponse atEnrollmentResponse =
        await atEnrollmentBase.submit(enrollmentRequest, atLookUp);
    await atEnrollmentBase.waitForApproval(atEnrollmentResponse,
        atLookup: atLookUp);
    // atEnrollmentResponse.session.atKeysIo now holds the keys; open a
    // client on it with at_client's Atsign.open.

The atLookUp parameter is used to perform lookups to secondary server to submit an enrollment request.

Returns a Future containing an AtEnrollmentResponse representing the result of the enrollment.

Implementation

Future<AtEnrollmentResponse> submit(
    EnrollmentRequest enrollmentRequest, AtLookUp atLookUp);