invite
UserService::InviteNs::Invite
struct UserService::InviteNs::Invite {
const psibase::AccountNumber service; // "invite"
const psibase::AccountNumber payerAccount; // "invited-sys"
Invite(...); // Constructor prevents actions from being called until after init() has been called
init(...); // Called once during chain initialization
createInvite(...); // Creates and stores an invite object with the specified public key
accept(...); // Called by existing Psibase accounts to accept an invite without creating a new Psibase account
acceptCreate(...); // Called by the system account "invited-sys" to accept an invite and simultaneously create the new account 'acceptedBy', which is authenticated by the provided 'newAccountKey' public key
reject(...); // Called by existing accounts or the system account "invited-sys" to reject an invite. Once an invite is rejected, it cannot be accepted or used to create a new account
delInvite(...); // Used by the creator of an invite to delete it. Deleted invites are removed from the database. An invite can be deleted regardless of whether it has been accepted, rejected, or is still pending
delExpired(...); // Used by anyone to garbage collect expired invites. Up to 'maxDeleted' invites can be deleted by calling this action
setWhitelist(...); // Called by this service itself to restrict the accounts that are able to create invites. Only whitelisted accounts may create invites
setBlacklist(...); // Called by this service itself to restruct the accounts that are able to create invites. Blacklisted accounts may not create invites
getInvite(...); // Called synchronously by other services to retrieve the invite record corresponding to the provided 'pubkey' public key
isExpired(...); // Called synchronously by other services to query whether the invite record corresponding to the provided `pubkey` public key is expired
checkClaim(...); // Called synchronously by other services to query whether the specified actor should be allowed to claim the invite specified by the `pubkey` public key.
serveSys(...); // Called by the http-server system service when an HttpRequest is directed at this invite service
storeSys(...); // Used to store UI files and other `content` at the specified `path`.
};
This service facilitates the creation and redemption of invites.
Invites are generic and their acceptance can, but does not always, result in the creation of a new Psibase account. This service can be used by third party applications to streamline their user onboarding.
Only this system service and Accounts are permitted to create new accounts.
UserService::InviteNs::Invite::Invite
UserService::InviteNs::Invite::Invite(
psio::shared_view_ptr<psibase::Action> action
);
Constructor prevents actions from being called until after init() has been called.
UserService::InviteNs::Invite::init
void UserService::InviteNs::Invite::init();
Called once during chain initialization.
- Registers this service as an RPC/gql query handler
- Configures itself for manual debiting
- Creates the "invites-sys" system account used to create new accounts
UserService::InviteNs::Invite::createInvite
void UserService::InviteNs::Invite::createInvite(
psibase::PublicKey inviteKey
);
Creates and stores an invite object with the specified public key.
UserService::InviteNs::Invite::accept
void UserService::InviteNs::Invite::accept(
psibase::PublicKey inviteKey
);
Called by existing Psibase accounts to accept an invite without creating a new Psibase account.
UserService::InviteNs::Invite::acceptCreate
void UserService::InviteNs::Invite::acceptCreate(
psibase::PublicKey inviteKey,
psibase::AccountNumber acceptedBy,
psibase::PublicKey newAccountKey
);
Called by the system account "invited-sys" to accept an invite and simultaneously create the new account 'acceptedBy', which is authenticated by the provided 'newAccountKey' public key.
Each invite may be used to redeem a maximum of one new account.
UserService::InviteNs::Invite::reject
void UserService::InviteNs::Invite::reject(
psibase::PublicKey inviteKey
);
Called by existing accounts or the system account "invited-sys" to reject an invite. Once an invite is rejected, it cannot be accepted or used to create a new account.
UserService::InviteNs::Invite::delInvite
void UserService::InviteNs::Invite::delInvite(
psibase::PublicKey inviteKey
);
Used by the creator of an invite to delete it. Deleted invites are removed from the database. An invite can be deleted regardless of whether it has been accepted, rejected, or is still pending.
UserService::InviteNs::Invite::delExpired
void UserService::InviteNs::Invite::delExpired(
uint32_t maxDeleted
);
Used by anyone to garbage collect expired invites. Up to 'maxDeleted' invites can be deleted by calling this action.
UserService::InviteNs::Invite::setWhitelist
void UserService::InviteNs::Invite::setWhitelist(
std::vector<psibase::AccountNumber> accounts
);
Called by this service itself to restrict the accounts that are able to create invites. Only whitelisted accounts may create invites.
UserService::InviteNs::Invite::setBlacklist
void UserService::InviteNs::Invite::setBlacklist(
std::vector<psibase::AccountNumber> accounts
);
Called by this service itself to restruct the accounts that are able to create invites. Blacklisted accounts may not create invites.
UserService::InviteNs::Invite::getInvite
std::optional<InviteRecord> UserService::InviteNs::Invite::getInvite(
psibase::PublicKey pubkey
);
Called synchronously by other services to retrieve the invite record corresponding to the provided 'pubkey' public key.
UserService::InviteNs::Invite::isExpired
bool UserService::InviteNs::Invite::isExpired(
psibase::PublicKey pubkey
);
Called synchronously by other services to query whether the invite
record corresponding to the provided pubkey
public key is expired.
UserService::InviteNs::Invite::checkClaim
void UserService::InviteNs::Invite::checkClaim(
psibase::AccountNumber actor,
psibase::PublicKey pubkey
);
Called synchronously by other services to query whether the specified
actor should be allowed to claim the invite specified by the pubkey
public key..
To be considered a valid interaction, the following criteria must be met:
- The invite must exist
- The invite must be in the accepted state
- The invite actor must be the same as the specified
actor
parameter - The invite must not be expired
UserService::InviteNs::Invite::serveSys
std::optional<psibase::HttpReply> UserService::InviteNs::Invite::serveSys(
psibase::HttpRequest request
);
Called by the http-server system service when an HttpRequest is directed at this invite service.
UserService::InviteNs::Invite::storeSys
void UserService::InviteNs::Invite::storeSys(
std::string path,
std::string contentType,
std::vector<char> content
);
Used to store UI files and other content
at the specified path
..
UserService::InviteNs::InviteSettingsRecord
struct UserService::InviteNs::InviteSettingsRecord {
psibase::SingletonKey key;
std::vector<psibase::AccountNumber> whitelist;
std::vector<psibase::AccountNumber> blacklist;
};
Table to track the contents of the invite creation whitelist and blacklist.
UserService::InviteNs::InviteRecord
struct UserService::InviteNs::InviteRecord {
psibase::PublicKey pubkey;
psibase::AccountNumber inviter;
psibase::AccountNumber actor;
uint32_t expiry;
bool newAccountToken;
uint8_t state;
secondary(...);
};
Table to track the contents of an invite.
pubkey
: The public key of the invite. This uniquely identifies an invite and is also used to authenticate transactions by users without an existing Psibase account.inviter
: The creator of the invite objectactor
: The last account to accept or reject the inviteexpiry
: The time in seconds at which this invite expiresnewAccountToken
: A flag that represents whether a new account may still be created by redeeming this invitestate
: An integer representing whether the invite is pending (0), accepted (1), or rejected (2)
UserService::InviteNs::InviteRecord::secondary
tuple<const AccountNumber &, const PublicKey &> UserService::InviteNs::InviteRecord::secondary() const;