atKey Reference

AtKey

Please note that any reference to the word "AtKey" in this document is not associated with cryptographic keys. The atKey is the "key" of the key-value pair that makes up an atRecord.

This article explains how to create an atKey in the atClient SDK.

If you are unfamiliar with atKeys please read this first.

The at_commons package contains common elements used in a number of Atsign's Flutter and Dart packages. This package needs to be included in the application in order to create atKeys.

Installation

First add the package to your project:

flutter pub add at_commons

Or add the package to your pubspec.yaml manually:

pubspec.yaml
dependencies:
  flutter:
    sdk: flutter
  at_client_mobile: ^3.2.9
  at_onboarding_flutter: ^6.0.3
  at_commons: ^3.0.45

Usage

See below for how to create the various types of atKeys.

Public atKey

To create a public atKey, first use the AtKey.public builder to configure it, then call .build to create it.

AtKey.public signature
static PublicKeyBuilder public(String key,
    {String? namespace, String sharedBy = ''})

The build method on PublicKeyBuilder takes no parameters.

Example

public:phone.wavi@alice

AtKey myPublicID = AtKey.public('phone', namespace: 'wavi', sharedBy: '@alice').build();

Self atKey

To create a self atkeyD, first use the AtKey.self builder to configure it, then call .build to create it.

AtKey.self signature
static SelfKeyBuilder self(String key,
    {String? namespace, String sharedBy = ''})

The build method on SelfKeyBuilder takes no parameters.

Example

phone.wavi@alice

AtKey mySelfID = AtKey.self('phone', namespace: 'wavi', sharedBy: '@alice').build();

Private atKey

To create a private atKey, first use the AtKey.private builder to configure it, then call .build to create it.

The difference between a private and a self atkey is that the private atKey is hidden by default when using the atProtocol scan verb.

AtKey.private signature
static PrivateKeyBuilder private(String key, {String? namespace})

The build method on PrivateKeyBuilder takes no parameters.

Example

privatekey:phone.wavi@alice

AtKey myPrivateID = AtKey.private('phone', namespace: 'wavi').build();

Shared atKey

To create a shared atKey, first use the AtKey.shared builder to configure it, then call .build to create it.

AtKey.shared signature
static SharedKeyBuilder shared(String key,
    {String? namespace, String sharedBy = ''})

The build method on SharedKeyBuilder takes no parameters.

Example

@bob:phone.wavi@alice

AtKey sharedKey = (AtKey.shared('phone', 'wavi')
    ..sharedWith('@bob')).build();

Caching shared atKeys

To cache a shared atKey, you can do a cascade call on SharedKeyBuilder.cache.

Caching example
AtKey atKey = (AtKey.shared('phone', namespace: 'wavi', sharedBy: '@alice')
 ..sharedWith('@bob')
 ..cache(1000, true))
 .build();

API Docs

You can find the API reference for the entire package available on pub.

The AtKey class API reference is available here.

Last updated

© 2023 Atsign