247 lines
8.3 KiB
Dart
247 lines
8.3 KiB
Dart
|
|
/* AUTOMATICALLY GENERATED CODE DO NOT MODIFY */
|
||
|
|
/* To generate run: "serverpod generate" */
|
||
|
|
|
||
|
|
// ignore_for_file: implementation_imports
|
||
|
|
// ignore_for_file: library_private_types_in_public_api
|
||
|
|
// ignore_for_file: non_constant_identifier_names
|
||
|
|
// ignore_for_file: public_member_api_docs
|
||
|
|
// ignore_for_file: type_literal_in_constant_pattern
|
||
|
|
// ignore_for_file: use_super_parameters
|
||
|
|
// ignore_for_file: invalid_use_of_internal_member
|
||
|
|
|
||
|
|
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||
|
|
import 'dart:async' as _ida;
|
||
|
|
import 'package:halkyon_base_client/src/protocol/auth/email_code_accepted.dart'
|
||
|
|
as _ioeosfv3;
|
||
|
|
import 'package:halkyon_base_client/src/protocol/auth/sign_in_ways.dart'
|
||
|
|
as _ifld8s4r;
|
||
|
|
import 'package:halkyon_base_client/src/protocol/instance/instance_basics.dart'
|
||
|
|
as _isnyur2i;
|
||
|
|
import 'package:serverpod_auth_core_client/serverpod_auth_core_client.dart'
|
||
|
|
as _iacc;
|
||
|
|
import 'package:serverpod_auth_idp_client/serverpod_auth_idp_client.dart'
|
||
|
|
as _iaic;
|
||
|
|
import 'package:serverpod_client/serverpod_client.dart' as _isc;
|
||
|
|
|
||
|
|
/// The signed-in person's account.
|
||
|
|
/// {@category Endpoint}
|
||
|
|
class EndpointAccount extends _isc.EndpointRef {
|
||
|
|
EndpointAccount(_isc.EndpointCaller caller) : super(caller);
|
||
|
|
|
||
|
|
@override
|
||
|
|
String get name => 'halkyon_base.account';
|
||
|
|
|
||
|
|
/// Deletes the caller with everything they have (see [deletePerson]). The
|
||
|
|
/// app also calls it when an anonymous account is given up (decided
|
||
|
|
/// 2026-09-30). Their other devices learn at once that their sessions
|
||
|
|
/// ended.
|
||
|
|
_ida.Future<void> delete() => caller.callServerEndpoint<void>(
|
||
|
|
'halkyon_base.account',
|
||
|
|
'delete',
|
||
|
|
{},
|
||
|
|
);
|
||
|
|
|
||
|
|
/// How the caller signs in besides their sessions: with GitHub, with an
|
||
|
|
/// email address, both, or neither (anonymous).
|
||
|
|
_ida.Future<_ifld8s4r.SignInWays> signInWays() =>
|
||
|
|
caller.callServerEndpoint<_ifld8s4r.SignInWays>(
|
||
|
|
'halkyon_base.account',
|
||
|
|
'signInWays',
|
||
|
|
{},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Signs people in anonymously; the app calls it on first launch. Creating an
|
||
|
|
/// account is rate-limited per IP address (see `auth_config.dart`).
|
||
|
|
/// {@category Endpoint}
|
||
|
|
class EndpointAnonymousIdp extends _iaic.EndpointAnonymousIdpBase {
|
||
|
|
EndpointAnonymousIdp(_isc.EndpointCaller caller) : super(caller);
|
||
|
|
|
||
|
|
@override
|
||
|
|
String get name => 'halkyon_base.anonymousIdp';
|
||
|
|
|
||
|
|
/// Creates a new anonymous account and returns its session.
|
||
|
|
///
|
||
|
|
/// Invokes the [AnonymousIdp.beforeAnonymousAccount] callback if configured,
|
||
|
|
/// which may prevent account creation if the endpoint is protected.
|
||
|
|
@override
|
||
|
|
_ida.Future<_iacc.AuthSuccess> login({String? token}) =>
|
||
|
|
caller.callServerEndpoint<_iacc.AuthSuccess>(
|
||
|
|
'halkyon_base.anonymousIdp',
|
||
|
|
'login',
|
||
|
|
{'token': token},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Signing in with an email address, by a code mailed to it:
|
||
|
|
/// the way to keep an anonymous account, as linking GitHub is, and a second
|
||
|
|
/// way in for someone who signs in with GitHub. Signed in only, as every
|
||
|
|
/// device is from its first start.
|
||
|
|
/// {@category Endpoint}
|
||
|
|
class EndpointEmailCode extends _isc.EndpointRef {
|
||
|
|
EndpointEmailCode(_isc.EndpointCaller caller) : super(caller);
|
||
|
|
|
||
|
|
@override
|
||
|
|
String get name => 'halkyon_base.emailCode';
|
||
|
|
|
||
|
|
/// Mails a code to [address], worded in [language] (`en`, `de`), and
|
||
|
|
/// returns the request it answers; refusals as in [sendSignInCode].
|
||
|
|
_ida.Future<_isc.UuidValue> sendCode({
|
||
|
|
required String address,
|
||
|
|
required String language,
|
||
|
|
}) => caller.callServerEndpoint<_isc.UuidValue>(
|
||
|
|
'halkyon_base.emailCode',
|
||
|
|
'sendCode',
|
||
|
|
{
|
||
|
|
'address': address,
|
||
|
|
'language': language,
|
||
|
|
},
|
||
|
|
);
|
||
|
|
|
||
|
|
/// Accepts [code] for [request]: the address becomes the caller's unless
|
||
|
|
/// it is another person's, whose token then signs in as them
|
||
|
|
/// (`EmailSignInEndpoint.signIn`); refusals as in [acceptSignInCode].
|
||
|
|
_ida.Future<_ioeosfv3.EmailCodeAccepted> verifyCode({
|
||
|
|
required _isc.UuidValue request,
|
||
|
|
required String code,
|
||
|
|
}) => caller.callServerEndpoint<_ioeosfv3.EmailCodeAccepted>(
|
||
|
|
'halkyon_base.emailCode',
|
||
|
|
'verifyCode',
|
||
|
|
{
|
||
|
|
'request': request,
|
||
|
|
'code': code,
|
||
|
|
},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Signs in the person whose address a mailed code proved, when the device
|
||
|
|
/// switches to them. Called without a session: Serverpod issues no session
|
||
|
|
/// for another person inside a signed-in call.
|
||
|
|
/// {@category Endpoint}
|
||
|
|
class EndpointEmailSignIn extends _isc.EndpointRef {
|
||
|
|
EndpointEmailSignIn(_isc.EndpointCaller caller) : super(caller);
|
||
|
|
|
||
|
|
@override
|
||
|
|
String get name => 'halkyon_base.emailSignIn';
|
||
|
|
|
||
|
|
/// A session for the person [switchToken] names; refusals as in
|
||
|
|
/// [signInWithEmail].
|
||
|
|
_ida.Future<_iacc.AuthSuccess> signIn({required String switchToken}) =>
|
||
|
|
caller.callServerEndpoint<_iacc.AuthSuccess>(
|
||
|
|
'halkyon_base.emailSignIn',
|
||
|
|
'signIn',
|
||
|
|
{'switchToken': switchToken},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Signs in the person who already has a GitHub account, e.g. when they switch
|
||
|
|
/// to it on another device. Called without a session: Serverpod issues no
|
||
|
|
/// session for another person inside a signed-in call.
|
||
|
|
/// {@category Endpoint}
|
||
|
|
class EndpointGitHubSignIn extends _isc.EndpointRef {
|
||
|
|
EndpointGitHubSignIn(_isc.EndpointCaller caller) : super(caller);
|
||
|
|
|
||
|
|
@override
|
||
|
|
String get name => 'halkyon_base.gitHubSignIn';
|
||
|
|
|
||
|
|
/// A session for the person with the GitHub account that [code] proves;
|
||
|
|
/// refusals as in [signInWithGitHubAccount].
|
||
|
|
_ida.Future<_iacc.AuthSuccess> signIn({
|
||
|
|
required String code,
|
||
|
|
required String codeVerifier,
|
||
|
|
required String redirectUri,
|
||
|
|
}) => caller.callServerEndpoint<_iacc.AuthSuccess>(
|
||
|
|
'halkyon_base.gitHubSignIn',
|
||
|
|
'signIn',
|
||
|
|
{
|
||
|
|
'code': code,
|
||
|
|
'codeVerifier': codeVerifier,
|
||
|
|
'redirectUri': redirectUri,
|
||
|
|
},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Links a GitHub account to the signed-in person: the lossless upgrade from
|
||
|
|
/// an anonymous account. The person and everything they have stay
|
||
|
|
/// where they are; only the way they sign in changes.
|
||
|
|
/// {@category Endpoint}
|
||
|
|
class EndpointGitHubUpgrade extends _isc.EndpointRef {
|
||
|
|
EndpointGitHubUpgrade(_isc.EndpointCaller caller) : super(caller);
|
||
|
|
|
||
|
|
@override
|
||
|
|
String get name => 'halkyon_base.gitHubUpgrade';
|
||
|
|
|
||
|
|
/// Links the GitHub account that [code] proves to the caller; refusals as in
|
||
|
|
/// [linkGitHubAccount].
|
||
|
|
_ida.Future<void> upgrade({
|
||
|
|
required String code,
|
||
|
|
required String codeVerifier,
|
||
|
|
required String redirectUri,
|
||
|
|
}) => caller.callServerEndpoint<void>(
|
||
|
|
'halkyon_base.gitHubUpgrade',
|
||
|
|
'upgrade',
|
||
|
|
{
|
||
|
|
'code': code,
|
||
|
|
'codeVerifier': codeVerifier,
|
||
|
|
'redirectUri': redirectUri,
|
||
|
|
},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/// What every Halkyon instance tells its apps. Public: an app asks before
|
||
|
|
/// anyone is signed in.
|
||
|
|
/// {@category Endpoint}
|
||
|
|
class EndpointInstance extends _isc.EndpointRef {
|
||
|
|
EndpointInstance(_isc.EndpointCaller caller) : super(caller);
|
||
|
|
|
||
|
|
@override
|
||
|
|
String get name => 'halkyon_base.instance';
|
||
|
|
|
||
|
|
/// This instance's basics: GitHub sign-in only with the operator's OAuth
|
||
|
|
/// app, email sign-in only where it can mail codes, where its source is,
|
||
|
|
/// the oldest app build it works with, and where it keeps people's data
|
||
|
|
/// and its backups.
|
||
|
|
_ida.Future<_isnyur2i.InstanceBasics> basics() =>
|
||
|
|
caller.callServerEndpoint<_isnyur2i.InstanceBasics>(
|
||
|
|
'halkyon_base.instance',
|
||
|
|
'basics',
|
||
|
|
{},
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
class Caller extends _isc.ModuleEndpointCaller {
|
||
|
|
Caller(_isc.ServerpodClientShared client) : super(client) {
|
||
|
|
account = EndpointAccount(this);
|
||
|
|
anonymousIdp = EndpointAnonymousIdp(this);
|
||
|
|
emailCode = EndpointEmailCode(this);
|
||
|
|
emailSignIn = EndpointEmailSignIn(this);
|
||
|
|
gitHubSignIn = EndpointGitHubSignIn(this);
|
||
|
|
gitHubUpgrade = EndpointGitHubUpgrade(this);
|
||
|
|
instance = EndpointInstance(this);
|
||
|
|
}
|
||
|
|
|
||
|
|
late final EndpointAccount account;
|
||
|
|
|
||
|
|
late final EndpointAnonymousIdp anonymousIdp;
|
||
|
|
|
||
|
|
late final EndpointEmailCode emailCode;
|
||
|
|
|
||
|
|
late final EndpointEmailSignIn emailSignIn;
|
||
|
|
|
||
|
|
late final EndpointGitHubSignIn gitHubSignIn;
|
||
|
|
|
||
|
|
late final EndpointGitHubUpgrade gitHubUpgrade;
|
||
|
|
|
||
|
|
late final EndpointInstance instance;
|
||
|
|
|
||
|
|
@override
|
||
|
|
Map<String, _isc.EndpointRef> get endpointRefLookup => {
|
||
|
|
'halkyon_base.account': account,
|
||
|
|
'halkyon_base.anonymousIdp': anonymousIdp,
|
||
|
|
'halkyon_base.emailCode': emailCode,
|
||
|
|
'halkyon_base.emailSignIn': emailSignIn,
|
||
|
|
'halkyon_base.gitHubSignIn': gitHubSignIn,
|
||
|
|
'halkyon_base.gitHubUpgrade': gitHubUpgrade,
|
||
|
|
'halkyon_base.instance': instance,
|
||
|
|
};
|
||
|
|
}
|