diff --git a/sdk/bindings/ClientConnectInitEvent.ts b/sdk/bindings/ClientConnectInitEvent.ts deleted file mode 100644 index d1ed7726..00000000 --- a/sdk/bindings/ClientConnectInitEvent.ts +++ /dev/null @@ -1,4 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { SessionType } from "./SessionType"; - -export interface ClientConnectInitEvent { clientId: string, sessionId: string, walletName: string, walletType: string, sessionType: SessionType, } \ No newline at end of file diff --git a/sdk/bindings/CloudApiErrors.ts b/sdk/bindings/CloudApiErrors.ts index 8e1a4cc5..d17d556e 100644 --- a/sdk/bindings/CloudApiErrors.ts +++ b/sdk/bindings/CloudApiErrors.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type CloudApiErrors = "TeamDoesNotExist" | "UserDoesNotExist" | "CloudFeatureDisabled" | "InsufficientPermissions" | "TeamHasNoRegisteredApps" | "DatabaseError" | "MaximumUsersPerTeamReached" | "UserAlreadyBelongsToTheTeam" | "IncorrectPassword" | "AccessTokenFailure" | "RefreshTokenFailure" | "AppAlreadyExists" | "MaximumAppsPerTeamReached" | "TeamAlreadyExists" | "PersonalTeamAlreadyExists" | "EmailAlreadyExists" | "InternalServerError" | "UserDoesNotBelongsToTheTeam" | "InvalidName" | "UnauthorizedOriginError" | "AppDoesNotExist" | "UserAlreadyInvitedToTheTeam" | "MaximumInvitesPerTeamReached" | "InviteNotFound" | "ActionForbiddenForPersonalTeam" | "InviteDoesNotExist" | "InvalidPaginationCursor"; \ No newline at end of file +export type CloudApiErrors = "TeamDoesNotExist" | "UserDoesNotExist" | "CloudFeatureDisabled" | "InsufficientPermissions" | "TeamHasNoRegisteredApps" | "DatabaseError" | "MaximumUsersPerTeamReached" | "UserAlreadyBelongsToTheTeam" | "IncorrectPassword" | "AccessTokenFailure" | "RefreshTokenFailure" | "AppAlreadyExists" | "MaximumAppsPerTeamReached" | "TeamAlreadyExists" | "PersonalTeamAlreadyExists" | "EmailAlreadyExists" | "InternalServerError" | "UserDoesNotBelongsToTheTeam" | "InvalidName" | "UnauthorizedOriginError" | "AppDoesNotExist" | "UserAlreadyInvitedToTheTeam" | "MaximumInvitesPerTeamReached" | "InviteNotFound" | "ActionForbiddenForPersonalTeam" | "InviteDoesNotExist" | "InvalidPaginationCursor" | "InvalidVerificationCode" | "InvalidDomainName" | "DomainAlreadyVerified" | "DomainVerificationFailure" | "DomainNotFound" | "DomainVerificationNotStarted" | "WebAuthnError" | "PasswordNotSet" | "UserDoesNotHavePasskey" | "PasskeyAlreadyExists" | "InvalidPasskeyCredential" | "PasskeyDoesNotExist"; \ No newline at end of file diff --git a/server/bindings/HttpAddUserToTeamResponse.ts b/sdk/bindings/HttpAddPasskeyFinishResponse.ts similarity index 69% rename from server/bindings/HttpAddUserToTeamResponse.ts rename to sdk/bindings/HttpAddPasskeyFinishResponse.ts index f642bfce..0595e675 100644 --- a/server/bindings/HttpAddUserToTeamResponse.ts +++ b/sdk/bindings/HttpAddPasskeyFinishResponse.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type HttpAddUserToTeamResponse = null; \ No newline at end of file +export type HttpAddPasskeyFinishResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpChangeUsersPrivilegesRequest.ts b/sdk/bindings/HttpChangeUsersPrivilegesRequest.ts new file mode 100644 index 00000000..3cf06666 --- /dev/null +++ b/sdk/bindings/HttpChangeUsersPrivilegesRequest.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PrivilegeChange } from "./PrivilegeChange"; + +export interface HttpChangeUsersPrivilegesRequest { teamId: string, privilegesChanges: Array, } \ No newline at end of file diff --git a/server/bindings/HttpRegisterWithPasswordResponse.ts b/sdk/bindings/HttpChangeUsersPrivilegesResponse.ts similarity index 67% rename from server/bindings/HttpRegisterWithPasswordResponse.ts rename to sdk/bindings/HttpChangeUsersPrivilegesResponse.ts index ed75ea00..ecdc7535 100644 --- a/server/bindings/HttpRegisterWithPasswordResponse.ts +++ b/sdk/bindings/HttpChangeUsersPrivilegesResponse.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type HttpRegisterWithPasswordResponse = null; \ No newline at end of file +export type HttpChangeUsersPrivilegesResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpCloudEndpoint.ts b/sdk/bindings/HttpCloudEndpoint.ts index 29dbf9b1..b3b855ef 100644 --- a/sdk/bindings/HttpCloudEndpoint.ts +++ b/sdk/bindings/HttpCloudEndpoint.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type HttpCloudEndpoint = "/register_new_app" | "/register_with_password" | "/login_with_password" | "/login_with_google" | "/register_new_team" | "/remove_user_from_team" | "/get_user_joined_teams" | "/events" | "/invite_user_to_team" | "/accept_team_invite" | "/get_team_user_invites" | "/get_user_team_invites" | "/cancel_team_user_invite" | "/cancel_user_team_invite" | "/get_app_events"; \ No newline at end of file +export type HttpCloudEndpoint = "/register_new_app" | "/register_with_password_start" | "/register_with_password_finish" | "/login_with_password" | "/login_with_google" | "/register_new_team" | "/remove_user_from_team" | "/get_user_joined_teams" | "/events" | "/invite_user_to_team" | "/accept_team_invite" | "/get_team_user_invites" | "/get_user_team_invites" | "/cancel_team_user_invite" | "/cancel_user_team_invite" | "/get_app_events" | "/reset_password_start" | "/reset_password_finish" | "/verify_domain_start" | "/verify_domain_finish" | "/remove_whitelisted_domain" | "/register_with_passkey_start" | "/register_with_passkey_finish" | "/reset_passkey_start" | "/reset_passkey_finish" | "/get_passkey_challenge" | "/delete_passkey" | "/add_passkey_start" | "/add_passkey_finish" | "/get_user_metadata" | "/get_team_metadata" | "/get_team_users_privileges" | "/change_user_privileges" | "/login_with_passkey_start" | "/login_with_passkey_finish"; \ No newline at end of file diff --git a/sdk/bindings/HttpGetAppEventsEventRequest.ts b/sdk/bindings/HttpGetAppEventsEventRequest.ts deleted file mode 100644 index 9d69a36c..00000000 --- a/sdk/bindings/HttpGetAppEventsEventRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { PaginationCursor } from './PaginationCursor' - -export interface HttpGetAppEventsRequest { - appId: string - paginationCursor?: PaginationCursor -} diff --git a/sdk/bindings/HttpGetTeamMetadataRequest.ts b/sdk/bindings/HttpGetTeamMetadataRequest.ts new file mode 100644 index 00000000..3f8711c0 --- /dev/null +++ b/sdk/bindings/HttpGetTeamMetadataRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpGetTeamMetadataRequest { teamId: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpGetTeamMetadataResponse.ts b/sdk/bindings/HttpGetTeamMetadataResponse.ts new file mode 100644 index 00000000..288e1f6c --- /dev/null +++ b/sdk/bindings/HttpGetTeamMetadataResponse.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AppInfo } from "./AppInfo"; +import type { TeamMetadata } from "./TeamMetadata"; + +export interface HttpGetTeamMetadataResponse { teamMetadata: TeamMetadata, teamApps: Array, teamMembers: Array, } \ No newline at end of file diff --git a/sdk/bindings/MessageToSign.ts b/sdk/bindings/HttpGetTeamUsersPrivilegesRequest.ts similarity index 64% rename from sdk/bindings/MessageToSign.ts rename to sdk/bindings/HttpGetTeamUsersPrivilegesRequest.ts index c5933b0b..0c3d35f6 100644 --- a/sdk/bindings/MessageToSign.ts +++ b/sdk/bindings/HttpGetTeamUsersPrivilegesRequest.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface MessageToSign { message: string, metadata?: string, } \ No newline at end of file +export interface HttpGetTeamUsersPrivilegesRequest { teamId: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpGetTeamUsersPrivilegesResponse.ts b/sdk/bindings/HttpGetTeamUsersPrivilegesResponse.ts new file mode 100644 index 00000000..5a2d81d8 --- /dev/null +++ b/sdk/bindings/HttpGetTeamUsersPrivilegesResponse.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { TeamUserPrivilege } from "./TeamUserPrivilege"; + +export interface HttpGetTeamUsersPrivilegesResponse { usersPrivileges: Array, } \ No newline at end of file diff --git a/sdk/bindings/HttpLoginWithPasskeyFinishResponse.ts b/sdk/bindings/HttpLoginWithPasskeyFinishResponse.ts new file mode 100644 index 00000000..e8d95372 --- /dev/null +++ b/sdk/bindings/HttpLoginWithPasskeyFinishResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpLoginWithPasskeyFinishResponse { userId: string, authToken: string, refreshToken: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpLoginWithPasskeyStartRequest.ts b/sdk/bindings/HttpLoginWithPasskeyStartRequest.ts new file mode 100644 index 00000000..397c8102 --- /dev/null +++ b/sdk/bindings/HttpLoginWithPasskeyStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpLoginWithPasskeyStartRequest { email: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpRegisterNewAppRequest.ts b/sdk/bindings/HttpRegisterNewAppRequest.ts index 22db555d..be77a7fe 100644 --- a/sdk/bindings/HttpRegisterNewAppRequest.ts +++ b/sdk/bindings/HttpRegisterNewAppRequest.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface HttpRegisterNewAppRequest { teamId: string, appName: string, whitelistedDomains: Array, ackPublicKeys: Array, } \ No newline at end of file +export interface HttpRegisterNewAppRequest { teamId: string, appName: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpRegisterWithPasskeyFinishResponse.ts b/sdk/bindings/HttpRegisterWithPasskeyFinishResponse.ts new file mode 100644 index 00000000..3e3a4503 --- /dev/null +++ b/sdk/bindings/HttpRegisterWithPasskeyFinishResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpRegisterWithPasskeyFinishResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpRegisterWithPasswordResponse.ts b/sdk/bindings/HttpRegisterWithPasskeyStartRequest.ts similarity index 60% rename from sdk/bindings/HttpRegisterWithPasswordResponse.ts rename to sdk/bindings/HttpRegisterWithPasskeyStartRequest.ts index ac9570c3..2be9179c 100644 --- a/sdk/bindings/HttpRegisterWithPasswordResponse.ts +++ b/sdk/bindings/HttpRegisterWithPasskeyStartRequest.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface HttpRegisterWithPasswordResponse { userId: string, } \ No newline at end of file +export interface HttpRegisterWithPasskeyStartRequest { email: string, } \ No newline at end of file diff --git a/server/bindings/HttpVerifyRegisterWithPasswordRequest.ts b/sdk/bindings/HttpRegisterWithPasswordFinishRequest.ts similarity index 67% rename from server/bindings/HttpVerifyRegisterWithPasswordRequest.ts rename to sdk/bindings/HttpRegisterWithPasswordFinishRequest.ts index 888499e9..1db15198 100644 --- a/server/bindings/HttpVerifyRegisterWithPasswordRequest.ts +++ b/sdk/bindings/HttpRegisterWithPasswordFinishRequest.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface HttpVerifyRegisterWithPasswordRequest { email: string, code: string, } \ No newline at end of file +export interface HttpRegisterWithPasswordFinishRequest { email: string, code: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpRegisterWithPasswordFinishResponse.ts b/sdk/bindings/HttpRegisterWithPasswordFinishResponse.ts new file mode 100644 index 00000000..533558d7 --- /dev/null +++ b/sdk/bindings/HttpRegisterWithPasswordFinishResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpRegisterWithPasswordFinishResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpRegisterWithPasswordStartRequest.ts b/sdk/bindings/HttpRegisterWithPasswordStartRequest.ts new file mode 100644 index 00000000..aa509863 --- /dev/null +++ b/sdk/bindings/HttpRegisterWithPasswordStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpRegisterWithPasswordStartRequest { email: string, password: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpRegisterWithPasswordStartResponse.ts b/sdk/bindings/HttpRegisterWithPasswordStartResponse.ts new file mode 100644 index 00000000..dabf431f --- /dev/null +++ b/sdk/bindings/HttpRegisterWithPasswordStartResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpRegisterWithPasswordStartResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpRemoveWhitelistedDomainRequest.ts b/sdk/bindings/HttpRemoveWhitelistedDomainRequest.ts new file mode 100644 index 00000000..5652a06b --- /dev/null +++ b/sdk/bindings/HttpRemoveWhitelistedDomainRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpRemoveWhitelistedDomainRequest { appId: string, domainName: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpRemoveWhitelistedDomainResponse.ts b/sdk/bindings/HttpRemoveWhitelistedDomainResponse.ts new file mode 100644 index 00000000..f6f2eaf7 --- /dev/null +++ b/sdk/bindings/HttpRemoveWhitelistedDomainResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpRemoveWhitelistedDomainResponse = null; \ No newline at end of file diff --git a/server/bindings/HttpResetPasswordResponse.ts b/sdk/bindings/HttpResetPasskeyFinishResponse.ts similarity index 68% rename from server/bindings/HttpResetPasswordResponse.ts rename to sdk/bindings/HttpResetPasskeyFinishResponse.ts index 5c05af7c..c9174c9d 100644 --- a/server/bindings/HttpResetPasswordResponse.ts +++ b/sdk/bindings/HttpResetPasskeyFinishResponse.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type HttpResetPasswordResponse = null; \ No newline at end of file +export type HttpResetPasskeyFinishResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpResetPasskeyStartRequest.ts b/sdk/bindings/HttpResetPasskeyStartRequest.ts new file mode 100644 index 00000000..d245482a --- /dev/null +++ b/sdk/bindings/HttpResetPasskeyStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpResetPasskeyStartRequest { email: string, } \ No newline at end of file diff --git a/server/bindings/HttpVerifyPasswordResetRequest.ts b/sdk/bindings/HttpResetPasswordFinishRequest.ts similarity index 66% rename from server/bindings/HttpVerifyPasswordResetRequest.ts rename to sdk/bindings/HttpResetPasswordFinishRequest.ts index 16fc8332..3acde685 100644 --- a/server/bindings/HttpVerifyPasswordResetRequest.ts +++ b/sdk/bindings/HttpResetPasswordFinishRequest.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface HttpVerifyPasswordResetRequest { email: string, code: string, } \ No newline at end of file +export interface HttpResetPasswordFinishRequest { email: string, code: string, } \ No newline at end of file diff --git a/server/bindings/HttpVerifyPasswordResetResponse.ts b/sdk/bindings/HttpResetPasswordFinishResponse.ts similarity index 68% rename from server/bindings/HttpVerifyPasswordResetResponse.ts rename to sdk/bindings/HttpResetPasswordFinishResponse.ts index febb1971..941dfe57 100644 --- a/server/bindings/HttpVerifyPasswordResetResponse.ts +++ b/sdk/bindings/HttpResetPasswordFinishResponse.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type HttpVerifyPasswordResetResponse = null; \ No newline at end of file +export type HttpResetPasswordFinishResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpResetPasswordStartRequest.ts b/sdk/bindings/HttpResetPasswordStartRequest.ts new file mode 100644 index 00000000..69bb4744 --- /dev/null +++ b/sdk/bindings/HttpResetPasswordStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpResetPasswordStartRequest { email: string, newPassword: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpResetPasswordStartResponse.ts b/sdk/bindings/HttpResetPasswordStartResponse.ts new file mode 100644 index 00000000..fe2df9e4 --- /dev/null +++ b/sdk/bindings/HttpResetPasswordStartResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpResetPasswordStartResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpUserMetadataResponse.ts b/sdk/bindings/HttpUserMetadataResponse.ts new file mode 100644 index 00000000..53a7c630 --- /dev/null +++ b/sdk/bindings/HttpUserMetadataResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpUserMetadataResponse { userId: string, email: string, passwordSet: boolean, passkeyIds: Array, } \ No newline at end of file diff --git a/sdk/bindings/HttpRegisterWithPasswordRequest.ts b/sdk/bindings/HttpVerifyDomainFinishRequest.ts similarity index 56% rename from sdk/bindings/HttpRegisterWithPasswordRequest.ts rename to sdk/bindings/HttpVerifyDomainFinishRequest.ts index 6671dc07..7f57b548 100644 --- a/sdk/bindings/HttpRegisterWithPasswordRequest.ts +++ b/sdk/bindings/HttpVerifyDomainFinishRequest.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface HttpRegisterWithPasswordRequest { email: string, password: string, } \ No newline at end of file +export interface HttpVerifyDomainFinishRequest { appId: string, domainName: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpVerifyDomainFinishResponse.ts b/sdk/bindings/HttpVerifyDomainFinishResponse.ts new file mode 100644 index 00000000..f8077043 --- /dev/null +++ b/sdk/bindings/HttpVerifyDomainFinishResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpVerifyDomainFinishResponse = null; \ No newline at end of file diff --git a/sdk/bindings/HttpVerifyDomainStartRequest.ts b/sdk/bindings/HttpVerifyDomainStartRequest.ts new file mode 100644 index 00000000..4b1a9cb2 --- /dev/null +++ b/sdk/bindings/HttpVerifyDomainStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpVerifyDomainStartRequest { appId: string, domainName: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpVerifyDomainStartResponse.ts b/sdk/bindings/HttpVerifyDomainStartResponse.ts new file mode 100644 index 00000000..65ec29bb --- /dev/null +++ b/sdk/bindings/HttpVerifyDomainStartResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpVerifyDomainStartResponse { code: string, } \ No newline at end of file diff --git a/sdk/bindings/LoginWithGoogleResponse.ts b/sdk/bindings/LoginWithGoogleResponse.ts deleted file mode 100644 index 718e6d34..00000000 --- a/sdk/bindings/LoginWithGoogleResponse.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface LoginWithGoogleResponse { userId: string, authToken: string, refreshToken: string, } \ No newline at end of file diff --git a/sdk/bindings/NewRequestEvent.ts b/sdk/bindings/NewRequestEvent.ts deleted file mode 100644 index d6917eb3..00000000 --- a/sdk/bindings/NewRequestEvent.ts +++ /dev/null @@ -1,4 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { RequestType } from "./RequestType"; - -export interface NewRequestEvent { sessionId: string, requestId: string, requestType: RequestType, network: string, } \ No newline at end of file diff --git a/sdk/bindings/NewUserPrivilegeLevel.ts b/sdk/bindings/NewUserPrivilegeLevel.ts new file mode 100644 index 00000000..9e04e946 --- /dev/null +++ b/sdk/bindings/NewUserPrivilegeLevel.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type NewUserPrivilegeLevel = "read" | "edit" | "noAccess"; \ No newline at end of file diff --git a/sdk/bindings/PrivilegeChange.ts b/sdk/bindings/PrivilegeChange.ts new file mode 100644 index 00000000..eb306ac2 --- /dev/null +++ b/sdk/bindings/PrivilegeChange.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NewUserPrivilegeLevel } from "./NewUserPrivilegeLevel"; + +export interface PrivilegeChange { appId: string, userEmail: string, newPrivilegeLevel: NewUserPrivilegeLevel, } \ No newline at end of file diff --git a/sdk/bindings/RequestResolvedEvent.ts b/sdk/bindings/RequestResolvedEvent.ts deleted file mode 100644 index 4cdd3a2a..00000000 --- a/sdk/bindings/RequestResolvedEvent.ts +++ /dev/null @@ -1,4 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { RequestFail } from "./RequestFail"; - -export interface RequestResolvedEvent { sessionId: string, requestId: string, failureReason?: RequestFail, } \ No newline at end of file diff --git a/sdk/bindings/TeamMetadata.ts b/sdk/bindings/TeamMetadata.ts new file mode 100644 index 00000000..f03a7acf --- /dev/null +++ b/sdk/bindings/TeamMetadata.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface TeamMetadata { creatorEmail: string, teamId: string, teamName: string, personalTeam: boolean, createdAt: string, } \ No newline at end of file diff --git a/sdk/bindings/TeamUserPrivilege.ts b/sdk/bindings/TeamUserPrivilege.ts new file mode 100644 index 00000000..714a2c9a --- /dev/null +++ b/sdk/bindings/TeamUserPrivilege.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PrivilegeLevel } from "./PrivilegeLevel"; + +export interface TeamUserPrivilege { appId: string, userEmail: string, privilege: PrivilegeLevel, } \ No newline at end of file diff --git a/sdk/bindings/TransactionToSign.ts b/sdk/bindings/TransactionToSign.ts deleted file mode 100644 index c031c34d..00000000 --- a/sdk/bindings/TransactionToSign.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface TransactionToSign { transaction: string, metadata?: string, } \ No newline at end of file diff --git a/sdk/bindings/index.ts b/sdk/bindings/index.ts new file mode 100644 index 00000000..bac234a2 --- /dev/null +++ b/sdk/bindings/index.ts @@ -0,0 +1,149 @@ +// This file was auto-generated by bindings script. Do not edit this file manually. +export * from './AckMessage'; +export * from './AlreadyConnected'; +export * from './AppConnectEvent'; +export * from './AppDisconnectEvent'; +export * from './AppDisconnectedEvent'; +export * from './AppEvent'; +export * from './AppInfo'; +export * from './AppLinks'; +export * from './AppMetadata'; +export * from './AppToServer'; +export * from './ChangeNetworkEvent'; +export * from './ChangeNetworkResolveEvent'; +export * from './ChangeWalletEvent'; +export * from './ChangeWalletResolveEvent'; +export * from './ClientConnectEvent'; +export * from './ClientConnectResolveEvent'; +export * from './ClientDisconnectEvent'; +export * from './ClientInitializeRequest'; +export * from './ClientInitializeResponse'; +export * from './ClientToServer'; +export * from './CloudApiErrors'; +export * from './ConnectRequest'; +export * from './ConnectResponse'; +export * from './Deeplink'; +export * from './Device'; +export * from './DeviceMetadata'; +export * from './DropSessionsRequest'; +export * from './DropSessionsResponse'; +export * from './ErrorMessage'; +export * from './EventData'; +export * from './EventType'; +export * from './GetInfoRequest'; +export * from './GetInfoResponse'; +export * from './GetPendingRequestsRequest'; +export * from './GetPendingRequestsResponse'; +export * from './GetSessionsRequest'; +export * from './GetSessionsResponse'; +export * from './HttpAcceptTeamInviteRequest'; +export * from './HttpAcceptTeamInviteResponse'; +export * from './HttpAddPasskeyFinishResponse'; +export * from './HttpCancelTeamUserInviteRequest'; +export * from './HttpCancelTeamUserInviteResponse'; +export * from './HttpCancelUserTeamInviteRequest'; +export * from './HttpCancelUserTeamInviteResponse'; +export * from './HttpChangeUsersPrivilegesRequest'; +export * from './HttpChangeUsersPrivilegesResponse'; +export * from './HttpCloudEndpoint'; +export * from './HttpConnectSessionRequest'; +export * from './HttpConnectSessionResponse'; +export * from './HttpDropSessionsRequest'; +export * from './HttpDropSessionsResponse'; +export * from './HttpEndpoint'; +export * from './HttpGetAppEventsRequest'; +export * from './HttpGetAppEventsResponse'; +export * from './HttpGetPendingRequestRequest'; +export * from './HttpGetPendingRequestResponse'; +export * from './HttpGetPendingRequestsRequest'; +export * from './HttpGetPendingRequestsResponse'; +export * from './HttpGetSessionInfoRequest'; +export * from './HttpGetSessionInfoResponse'; +export * from './HttpGetSessionsRequest'; +export * from './HttpGetSessionsResponse'; +export * from './HttpGetTeamMetadataRequest'; +export * from './HttpGetTeamMetadataResponse'; +export * from './HttpGetTeamUserInvitesRequest'; +export * from './HttpGetTeamUserInvitesResponse'; +export * from './HttpGetTeamUsersPrivilegesRequest'; +export * from './HttpGetTeamUsersPrivilegesResponse'; +export * from './HttpGetUserJoinedTeamsResponse'; +export * from './HttpGetUserTeamInvitesResponse'; +export * from './HttpInviteUserToTeamRequest'; +export * from './HttpInviteUserToTeamResponse'; +export * from './HttpLoginRequest'; +export * from './HttpLoginResponse'; +export * from './HttpLoginWithGoogleRequest'; +export * from './HttpLoginWithGoogleResponse'; +export * from './HttpLoginWithPasskeyFinishResponse'; +export * from './HttpLoginWithPasskeyStartRequest'; +export * from './HttpNightlyConnectCloudEvent'; +export * from './HttpRegisterNewAppRequest'; +export * from './HttpRegisterNewAppResponse'; +export * from './HttpRegisterNewTeamRequest'; +export * from './HttpRegisterNewTeamResponse'; +export * from './HttpRegisterWithPasskeyFinishResponse'; +export * from './HttpRegisterWithPasskeyStartRequest'; +export * from './HttpRegisterWithPasswordFinishRequest'; +export * from './HttpRegisterWithPasswordFinishResponse'; +export * from './HttpRegisterWithPasswordStartRequest'; +export * from './HttpRegisterWithPasswordStartResponse'; +export * from './HttpRemoveUserFromTeamRequest'; +export * from './HttpRemoveUserFromTeamResponse'; +export * from './HttpRemoveWhitelistedDomainRequest'; +export * from './HttpRemoveWhitelistedDomainResponse'; +export * from './HttpResetPasskeyFinishResponse'; +export * from './HttpResetPasskeyStartRequest'; +export * from './HttpResetPasswordFinishRequest'; +export * from './HttpResetPasswordFinishResponse'; +export * from './HttpResetPasswordStartRequest'; +export * from './HttpResetPasswordStartResponse'; +export * from './HttpResolveRequestRequest'; +export * from './HttpResolveRequestResponse'; +export * from './HttpUserMetadataResponse'; +export * from './HttpVerifyDomainFinishRequest'; +export * from './HttpVerifyDomainFinishResponse'; +export * from './HttpVerifyDomainStartRequest'; +export * from './HttpVerifyDomainStartResponse'; +export * from './Images'; +export * from './InitializeRequest'; +export * from './InitializeResponse'; +export * from './JoinedTeam'; +export * from './MobileMetadata'; +export * from './Network'; +export * from './NewPayloadEvent'; +export * from './NewPayloadEventReply'; +export * from './NewUserPrivilegeLevel'; +export * from './NightlyError'; +export * from './Notification'; +export * from './NotificationPayload'; +export * from './PaginationCursor'; +export * from './PendingRequest'; +export * from './Platform'; +export * from './PrivilegeChange'; +export * from './PrivilegeLevel'; +export * from './RequestFail'; +export * from './RequestPayload'; +export * from './RequestType'; +export * from './ResponsePayload'; +export * from './ServerToApp'; +export * from './ServerToClient'; +export * from './SessionStatus'; +export * from './SessionType'; +export * from './SignAndSendTransactionEvent'; +export * from './SignAndSendTransactionResolveEvent'; +export * from './SignMessageEvent'; +export * from './SignMessageResolveEvent'; +export * from './SignTransactionEvent'; +export * from './SignTransactionResolveEvent'; +export * from './Subscription'; +export * from './TeamInvite'; +export * from './TeamMetadata'; +export * from './TeamUserPrivilege'; +export * from './UserConnectedEvent'; +export * from './UserDisconnectedEvent'; +export * from './UserPrivilege'; +export * from './Version'; +export * from './WalletMetadata'; +export * from './WalletType'; +export * from './WebMetadata'; diff --git a/sdk/package.json b/sdk/package.json index 264417e9..15b1eec0 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,7 +1,8 @@ { "name": "sdk", "scripts": { - "bindings": "rm -rf ./bindings && mkdir ./bindings && cp -r ../server/bindings/* ./bindings/ && cp -r ../database/bindings/* ./bindings/", + "copy-bindings": "rm -rf ./bindings && mkdir ./bindings && cp -r ../server/bindings/* ./bindings/ && cp -r ../database/bindings/* ./bindings/", + "bindings": "sh ./rebuild-bindings.sh", "build": "turbo run build", "dev": "turbo run dev", "lint": "turbo run lint", diff --git a/sdk/packages/cloud/src/app.ts b/sdk/packages/cloud/src/app.ts index feb36978..efe4afec 100644 --- a/sdk/packages/cloud/src/app.ts +++ b/sdk/packages/cloud/src/app.ts @@ -1,30 +1,65 @@ -import { HttpAcceptTeamInviteRequest } from '../../../bindings/HttpAcceptTeamInviteRequest' -import { HttpAcceptTeamInviteResponse } from '../../../bindings/HttpAcceptTeamInviteResponse' -import { HttpCancelTeamUserInviteRequest } from '../../../bindings/HttpCancelTeamUserInviteRequest' -import { HttpCancelTeamUserInviteResponse } from '../../../bindings/HttpCancelTeamUserInviteResponse' -import { HttpCancelUserTeamInviteRequest } from '../../../bindings/HttpCancelUserTeamInviteRequest' -import { HttpCancelUserTeamInviteResponse } from '../../../bindings/HttpCancelUserTeamInviteResponse' -import { HttpCloudEndpoint } from '../../../bindings/HttpCloudEndpoint' -import { HttpGetAppEventsRequest } from '../../../bindings/HttpGetAppEventsRequest' -import { HttpGetAppEventsResponse } from '../../../bindings/HttpGetAppEventsResponse' -import { HttpGetTeamUserInvitesRequest } from '../../../bindings/HttpGetTeamUserInvitesRequest' -import { HttpGetTeamUserInvitesResponse } from '../../../bindings/HttpGetTeamUserInvitesResponse' -import { HttpGetUserJoinedTeamsResponse } from '../../../bindings/HttpGetUserJoinedTeamsResponse' -import { HttpGetUserTeamInvitesResponse } from '../../../bindings/HttpGetUserTeamInvitesResponse' -import { HttpInviteUserToTeamRequest } from '../../../bindings/HttpInviteUserToTeamRequest' -import { HttpInviteUserToTeamResponse } from '../../../bindings/HttpInviteUserToTeamResponse' -import { HttpLoginRequest } from '../../../bindings/HttpLoginRequest' -import { HttpLoginResponse } from '../../../bindings/HttpLoginResponse' -import { HttpLoginWithGoogleRequest } from '../../../bindings/HttpLoginWithGoogleRequest' -import { HttpLoginWithGoogleResponse } from '../../../bindings/HttpLoginWithGoogleResponse' -import { HttpRegisterNewAppRequest } from '../../../bindings/HttpRegisterNewAppRequest' -import { HttpRegisterNewAppResponse } from '../../../bindings/HttpRegisterNewAppResponse' -import { HttpRegisterNewTeamRequest } from '../../../bindings/HttpRegisterNewTeamRequest' -import { HttpRegisterNewTeamResponse } from '../../../bindings/HttpRegisterNewTeamResponse' -import { HttpRegisterWithPasswordRequest } from '../../../bindings/HttpRegisterWithPasswordRequest' -import { HttpRegisterWithPasswordResponse } from '../../../bindings/HttpRegisterWithPasswordResponse' -import { HttpRemoveUserFromTeamRequest } from '../../../bindings/HttpRemoveUserFromTeamRequest' -import { HttpRemoveUserFromTeamResponse } from '../../../bindings/HttpRemoveUserFromTeamResponse' +import { + HttpAcceptTeamInviteRequest, + HttpAcceptTeamInviteResponse, + HttpCancelTeamUserInviteRequest, + HttpCancelTeamUserInviteResponse, + HttpCancelUserTeamInviteRequest, + HttpCancelUserTeamInviteResponse, + HttpChangeUsersPrivilegesRequest, + HttpChangeUsersPrivilegesResponse, + HttpCloudEndpoint, + HttpGetAppEventsRequest, + HttpGetAppEventsResponse, + HttpGetTeamMetadataRequest, + HttpGetTeamMetadataResponse, + HttpGetTeamUserInvitesRequest, + HttpGetTeamUserInvitesResponse, + HttpGetTeamUsersPrivilegesRequest, + HttpGetTeamUsersPrivilegesResponse, + HttpGetUserJoinedTeamsResponse, + HttpGetUserTeamInvitesResponse, + HttpInviteUserToTeamRequest, + HttpInviteUserToTeamResponse, + HttpLoginRequest, + HttpLoginResponse, + HttpLoginWithGoogleRequest, + HttpLoginWithGoogleResponse, + HttpLoginWithPasskeyFinishResponse, + HttpLoginWithPasskeyStartRequest, + HttpRegisterNewAppRequest, + HttpRegisterNewAppResponse, + HttpRegisterNewTeamRequest, + HttpRegisterNewTeamResponse, + HttpRegisterWithPasskeyStartRequest, + HttpRegisterWithPasswordFinishRequest, + HttpRegisterWithPasswordFinishResponse, + HttpRegisterWithPasswordStartRequest, + HttpRegisterWithPasswordStartResponse, + HttpRemoveUserFromTeamRequest, + HttpRemoveUserFromTeamResponse, + HttpRemoveWhitelistedDomainRequest, + HttpRemoveWhitelistedDomainResponse, + HttpResetPasskeyFinishResponse, + HttpResetPasskeyStartRequest, + HttpResetPasswordFinishRequest, + HttpResetPasswordFinishResponse, + HttpResetPasswordStartRequest, + HttpResetPasswordStartResponse, + HttpUserMetadataResponse, + HttpVerifyDomainFinishRequest, + HttpVerifyDomainFinishResponse, + HttpVerifyDomainStartRequest, + HttpVerifyDomainStartResponse +} from '../../../bindings' +import { + HttpDeletePasskeyRequest, + HttpGetPasskeyChallengeResponse, + HttpLoginWithPasskeyFinishRequest, + HttpLoginWithPasskeyStartResponse, + HttpRegisterWithPasskeyFinishRequest, + HttpResetPasskeyFinishRequest, + HttpResetPasskeyStartResponse +} from './passkeyTypes' import { DEFAULT_CLOUD_URL, EndpointType, Method } from './utils' import { fetch } from 'cross-fetch' @@ -125,18 +160,58 @@ export class NightlyCloud { } } - registerWithPassword = async ( - request: HttpRegisterWithPasswordRequest - ): Promise => { + ///////////////////////////////////////////////////// Register + + registerWithPasswordStart = async ( + request: HttpRegisterWithPasswordStartRequest + ): Promise => { + const response = (await this.sendPostJson( + '/register_with_password_start', + EndpointType.Public, + request + )) as HttpRegisterWithPasswordStartResponse + + return response + } + + registerWithPasswordFinish = async ( + request: HttpRegisterWithPasswordFinishRequest + ): Promise => { + const response = (await this.sendPostJson( + '/register_with_password_finish', + EndpointType.Public, + request + )) as HttpRegisterWithPasswordFinishResponse + + return response + } + + registerWithPasskeyStart = async ( + request: HttpRegisterWithPasskeyStartRequest + ): Promise => { + const response = (await this.sendPostJson( + '/register_with_passkey_start', + EndpointType.Public, + request + )) as HttpRegisterWithPasswordStartResponse + + return response + } + + registerWithPasskeyFinish = async ( + request: HttpRegisterWithPasskeyFinishRequest + ): Promise => { const response = (await this.sendPostJson( - '/register_with_password', + '/register_with_passkey_finish', EndpointType.Public, request - )) as HttpRegisterWithPasswordResponse + )) as HttpRegisterWithPasswordFinishResponse return response } + ///////////////////////////////////////////////////// Login + loginWithPassword = async (request: HttpLoginRequest): Promise => { const response = (await this.sendPostJson( '/login_with_password', @@ -165,6 +240,89 @@ export class NightlyCloud { return response } + loginWithPasskeyStart = async ( + request: HttpLoginWithPasskeyStartRequest + ): Promise => { + const response = (await this.sendPostJson( + '/login_with_passkey_start', + EndpointType.Public, + request + )) as HttpLoginWithPasskeyStartResponse + + return response + } + + loginWithPasskeyFinish = async ( + request: HttpLoginWithPasskeyFinishRequest + ): Promise => { + const response = (await this.sendPostJson( + '/login_with_passkey_finish', + EndpointType.Public, + request + )) as HttpLoginWithPasskeyFinishResponse + + this.authToken = response.authToken + this.refreshToken = response.refreshToken + + return response + } + + ///////////////////////////////////////////////////// Credentials + + resetPasswordStart = async ( + request: HttpResetPasswordStartRequest + ): Promise => { + const response = (await this.sendPostJson( + '/reset_password_start', + EndpointType.Public, + request + )) as HttpResetPasswordStartResponse + + return response + } + + resetPasswordFinish = async ( + request: HttpResetPasswordFinishRequest + ): Promise => { + const response = (await this.sendPostJson( + '/reset_password_finish', + EndpointType.Public, + request + )) as HttpResetPasswordFinishResponse + + return response + } + + resetPasskeyStart = async ( + request: HttpResetPasskeyStartRequest + ): Promise => { + const response = (await this.sendPostJson( + '/reset_passkey_start', + EndpointType.Public, + request + )) as HttpResetPasskeyStartResponse + + return response + } + + resetPasskeyFinish = async ( + request: HttpResetPasskeyFinishRequest + ): Promise => { + const response = (await this.sendPostJson( + '/reset_passkey_finish', + EndpointType.Public, + request + )) as HttpResetPasskeyFinishResponse + + return response + } + + deletePasskey = async (request: HttpDeletePasskeyRequest): Promise => { + await this.sendPostJson('/reset_passkey_finish', EndpointType.Public, request) + } + + ///////////////////////////////////////////////////// Teams actions + registerNewTeam = async ( request: HttpRegisterNewTeamRequest ): Promise => { @@ -249,7 +407,57 @@ export class NightlyCloud { return response } - ////////////////////////// GETTERS + changeUserPrivileges = async ( + request: HttpChangeUsersPrivilegesRequest + ): Promise => { + const response = (await this.sendPostJson( + '/change_user_privileges', + EndpointType.Private, + request + )) as HttpChangeUsersPrivilegesResponse + + return response + } + + ///////////////////////////////////////////////////// App actions + + verifyDomainStart = async ( + request: HttpVerifyDomainStartRequest + ): Promise => { + const response = (await this.sendPostJson( + '/verify_domain_start', + EndpointType.Private, + request + )) as HttpVerifyDomainStartResponse + + return response + } + + verifyDomainFinish = async ( + request: HttpVerifyDomainFinishRequest + ): Promise => { + const response = (await this.sendPostJson( + '/verify_domain_finish', + EndpointType.Private, + request + )) as HttpVerifyDomainFinishResponse + + return response + } + + removeDomain = async ( + request: HttpRemoveWhitelistedDomainRequest + ): Promise => { + const response = (await this.sendPostJson( + '/remove_whitelisted_domain', + EndpointType.Private, + request + )) as HttpRemoveWhitelistedDomainResponse + + return response + } + + ///////////////////////////////////////////////////// Getters getUserTeamInvites = async (): Promise => { const response = (await this.sendGetJson( @@ -290,4 +498,46 @@ export class NightlyCloud { return response } + + getPasskeyChallenge = async (): Promise => { + const response = (await this.sendGetJson( + '/get_passkey_challenge', + EndpointType.Private + )) as HttpGetPasskeyChallengeResponse + + return response + } + + getTeamUsersPrivileges = async ( + request: HttpGetTeamUsersPrivilegesRequest + ): Promise => { + const response = (await this.sendGetJson( + '/get_team_users_privileges', + EndpointType.Private, + request + )) as HttpGetTeamUsersPrivilegesResponse + + return response + } + + getUserMetadata = async (): Promise => { + const response = (await this.sendGetJson( + '/get_user_metadata', + EndpointType.Private + )) as HttpUserMetadataResponse + + return response + } + + getTeamMetadata = async ( + request: HttpGetTeamMetadataRequest + ): Promise => { + const response = (await this.sendGetJson( + '/get_team_metadata', + EndpointType.Private, + request + )) as HttpGetTeamMetadataResponse + + return response + } } diff --git a/sdk/packages/cloud/src/e2e.test.ts b/sdk/packages/cloud/src/e2e.test.ts index 6398b2a7..59d10ef3 100644 --- a/sdk/packages/cloud/src/e2e.test.ts +++ b/sdk/packages/cloud/src/e2e.test.ts @@ -1,14 +1,16 @@ import { assert, describe, expect, test } from 'vitest' import { NightlyCloud } from './app' -import { HttpRegisterWithPasswordRequest } from '../../../bindings/HttpRegisterWithPasswordRequest' import { addUserToTeam, basicTeamSetup, createUser, randomEmail } from './testUtils' -import { HttpLoginRequest } from '../../../bindings/HttpLoginRequest' -import { HttpRegisterNewTeamRequest } from '../../../bindings/HttpRegisterNewTeamRequest' -import { HttpRegisterNewAppRequest } from '../../../bindings/HttpRegisterNewAppRequest' -import { HttpInviteUserToTeamRequest } from '../../../bindings/HttpInviteUserToTeamRequest' -import { HttpRemoveUserFromTeamRequest } from '../../../bindings/HttpRemoveUserFromTeamRequest' -import { HttpCancelUserTeamInviteRequest } from '../../../bindings/HttpCancelUserTeamInviteRequest' -import { HttpGetAppEventsRequest } from '../../../bindings/HttpGetAppEventsRequest' +import { + HttpCancelUserTeamInviteRequest, + HttpGetAppEventsRequest, + HttpInviteUserToTeamRequest, + HttpLoginRequest, + HttpRegisterNewAppRequest, + HttpRegisterNewTeamRequest, + HttpRegisterWithPasswordStartRequest, + HttpRemoveUserFromTeamRequest +} from '../../../bindings' const TEST_ENDPOINT = 'http://127.0.0.1:6969/cloud' @@ -23,11 +25,9 @@ describe('Base Client tests', () => { const registerPayload = { email, password: 'Password123' - } as HttpRegisterWithPasswordRequest + } as HttpRegisterWithPasswordStartRequest - const response = await (await cloudClient.registerWithPassword(registerPayload)).userId - - assert(response.length > 0) + await cloudClient.registerWithPasswordStart(registerPayload) }) test('#loginWithPassword()', async () => { @@ -37,9 +37,10 @@ describe('Base Client tests', () => { const registerPayload = { email, password - } as HttpRegisterWithPasswordRequest + } as HttpRegisterWithPasswordStartRequest - const registerResponse = await await cloudClient.registerWithPassword(registerPayload) + await cloudClient.registerWithPasswordStart(registerPayload) + await cloudClient.registerWithPasswordFinish({ code: '123456', email }) const loginPayload = { email, @@ -49,7 +50,30 @@ describe('Base Client tests', () => { const loginResponse = await cloudClient.loginWithPassword(loginPayload) - assert(registerResponse.userId === loginResponse.userId) + assert(loginResponse.userId.length > 0) + }) + + test('#resetPassword()', async () => { + // create user + const { userId, email } = await createUser(cloudClient) + + // Send reset password request + const newPassword = 'NewPassword123124123' + await cloudClient.resetPasswordStart({ email, newPassword }) + + // Finish reset password, the code doesn't matter + await cloudClient.resetPasswordFinish({ code: '123456', email }) + + // Login once again with new password + const loginPayload = { + email, + password: newPassword, + enforceIp: false + } as HttpLoginRequest + + const loginResponse = await cloudClient.loginWithPassword(loginPayload) + + assert(loginResponse.userId == userId) }) test('#registerNewTeam()', async () => { @@ -379,4 +403,96 @@ describe('Base Client tests', () => { expect(response.events).toHaveLength(0) }) + + test('#changeUserPrivileges()', async () => { + // create user + const { userId: adminUserId, email: adminEmail } = await createUser(cloudClient) + + // create basic team setup + const { teamId, appId } = await basicTeamSetup(cloudClient) + + // register new user + const newClient = new NightlyCloud({ + url: TEST_ENDPOINT + }) + const { userId, email } = await createUser(newClient) + + // Add user to team + await addUserToTeam(cloudClient, newClient, teamId, email) + + // Check user privileges + const firstResponse = await cloudClient.getTeamUsersPrivileges({ teamId }) + + assert(firstResponse.usersPrivileges.length === 2) + assert(firstResponse.usersPrivileges[0].userEmail === adminEmail) + assert(firstResponse.usersPrivileges[0].appId === appId) + assert(firstResponse.usersPrivileges[0].privilege === 'Admin') + assert(firstResponse.usersPrivileges[1].userEmail === email) + assert(firstResponse.usersPrivileges[1].appId === appId) + assert(firstResponse.usersPrivileges[1].privilege === 'Read') + + await cloudClient.changeUserPrivileges({ + teamId: teamId, + privilegesChanges: [{ appId, userEmail: email, newPrivilegeLevel: 'edit' }] + }) + + // Get privileges + const secondResponse = await cloudClient.getTeamUsersPrivileges({ teamId }) + + assert(secondResponse.usersPrivileges.length === 2) + assert(secondResponse.usersPrivileges[0].userEmail === adminEmail) + assert(secondResponse.usersPrivileges[0].appId === appId) + assert(secondResponse.usersPrivileges[0].privilege === 'Admin') + assert(secondResponse.usersPrivileges[1].userEmail === email) + assert(secondResponse.usersPrivileges[1].appId === appId) + assert(secondResponse.usersPrivileges[1].privilege === 'Edit') + }) + + test('#getUserMetadata()', async () => { + // create user + const { userId, email } = await createUser(cloudClient) + + // Get user metadata + const response = await cloudClient.getUserMetadata() + + assert(response.userId === userId) + assert(response.email === email) + assert(response.passwordSet === true) + assert(response.passkeyIds.length === 0) + }) + + test('#getTeamMetadata()', async () => { + // create user + const { userId: adminUserId, email: adminEmail } = await createUser(cloudClient) + + // create basic team setup + const { teamId, appId } = await basicTeamSetup(cloudClient) + + // register new user + const newClient = new NightlyCloud({ + url: TEST_ENDPOINT + }) + const { userId, email } = await createUser(newClient) + + // Add user to team + await addUserToTeam(cloudClient, newClient, teamId, email) + + // Get team metadata + const response = await cloudClient.getTeamMetadata({ teamId }) + + assert(response.teamMetadata.teamId === teamId) + assert(response.teamMetadata.teamName === 'Test_Team') + assert(response.teamMetadata.creatorEmail === adminEmail) + assert(response.teamMetadata.personalTeam === false) + + assert(response.teamApps.length === 1) + assert(response.teamApps[0].appId === appId) + assert(response.teamApps[0].appName === 'Test_App') + assert(response.teamApps[0].ackPublicKeys.length === 0) + assert(response.teamApps[0].whitelistedDomains.length === 0) + + assert(response.teamMembers.length === 2) + assert(response.teamMembers.find((member) => member === adminEmail)) + assert(response.teamMembers.find((member) => member === email)) + }) }) diff --git a/sdk/packages/cloud/src/index.ts b/sdk/packages/cloud/src/index.ts index 2a8de0c9..b0159ff3 100644 --- a/sdk/packages/cloud/src/index.ts +++ b/sdk/packages/cloud/src/index.ts @@ -1,2 +1,3 @@ export * from './app' export * from './utils' +export * from './passkeyTypes' diff --git a/sdk/packages/cloud/src/passkeyTypes.ts b/sdk/packages/cloud/src/passkeyTypes.ts new file mode 100644 index 00000000..c29e70b2 --- /dev/null +++ b/sdk/packages/cloud/src/passkeyTypes.ts @@ -0,0 +1,69 @@ +/// REFERENCE https://github.com/kanidm/webauthn-rs/blob/master/tutorial/server/axum/assets/auth.js + +// Register +export type HttpRegisterWithPasskeyStartResponse = { publicKey: PublicKeyCredentialCreationOptions } +export type HttpRegisterWithPasskeyFinishRequest = { + email: string + credential: { + id: string + rawId: string + type: string + response: { clientDataJSON: string; attestationObject: string } + } +} + +// Login +export type HttpLoginWithPasskeyStartResponse = { publicKey: PublicKeyCredentialRequestOptions } +export type HttpLoginWithPasskeyFinishRequest = { + email: string + credential: { + id: string + rawId: string + type: string + response: { + clientDataJSON: string + authenticatorData: string + signature: string + userHandle: string + } + } + enforceIp: boolean +} + +// Add passkey +export type HttpAddNewPasskeyStartResponse = { publicKey: PublicKeyCredentialCreationOptions } +export type HttpAddNewPasskeyFinishRequest = { + credential: { + id: string + rawId: string + type: string + response: { clientDataJSON: string; attestationObject: string } + } +} + +// Reset passkey +export type HttpResetPasskeyStartResponse = { publicKey: PublicKeyCredentialCreationOptions } +export type HttpResetPasskeyFinishRequest = { + email: string + credential: { + id: string + rawId: string + type: string + response: { clientDataJSON: string; attestationObject: string } + } + code: string +} + +// Passkey 2FA +export type HttpGetPasskeyChallengeResponse = { publicKey: PublicKeyCredentialRequestOptions } + +// 2FA actions +export type HttpDeletePasskeyRequest = { + passkeyId: string + credential: { + id: string + rawId: string + type: string + response: { clientDataJSON: string; attestationObject: string } + } +} diff --git a/sdk/packages/cloud/src/testUtils.ts b/sdk/packages/cloud/src/testUtils.ts index b0cf1893..db17ddeb 100644 --- a/sdk/packages/cloud/src/testUtils.ts +++ b/sdk/packages/cloud/src/testUtils.ts @@ -1,8 +1,10 @@ -import { HttpInviteUserToTeamRequest } from '../../../bindings/HttpInviteUserToTeamRequest' -import { HttpLoginRequest } from '../../../bindings/HttpLoginRequest' -import { HttpRegisterNewAppRequest } from '../../../bindings/HttpRegisterNewAppRequest' -import { HttpRegisterNewTeamRequest } from '../../../bindings/HttpRegisterNewTeamRequest' -import { HttpRegisterWithPasswordRequest } from '../../../bindings/HttpRegisterWithPasswordRequest' +import { + HttpInviteUserToTeamRequest, + HttpLoginRequest, + HttpRegisterNewAppRequest, + HttpRegisterNewTeamRequest, + HttpRegisterWithPasswordStartRequest +} from '../../../bindings' import { NightlyCloud } from './app' export async function createUser( @@ -14,9 +16,10 @@ export async function createUser( const registerPayload = { email, password - } as HttpRegisterWithPasswordRequest + } as HttpRegisterWithPasswordStartRequest - await await cloudClient.registerWithPassword(registerPayload) + await cloudClient.registerWithPasswordStart(registerPayload) + await cloudClient.registerWithPasswordFinish({ code: '123456', email }) const loginPayload = { email, diff --git a/sdk/rebuild-bindings.sh b/sdk/rebuild-bindings.sh new file mode 100644 index 00000000..f601d983 --- /dev/null +++ b/sdk/rebuild-bindings.sh @@ -0,0 +1,34 @@ +echo 'Navigating to project root...' +cd .. + +echo 'Deleting existing bindings directories...' +rm -rf server/bindings +rm -rf database/bindings +rm -rf sdk/bindings + +echo 'Running cargo tests to recreate bindings...' +cargo test + +echo 'Creating new bindings directory in sdk...' +mkdir -p sdk/bindings + +echo 'Copying bindings from server and database to sdk...' +cp -r server/bindings/* sdk/bindings/ +cp -r database/bindings/* sdk/bindings/ + +echo 'Generating index.ts for bindings...' +cd sdk/bindings + +rm -f index.ts + +echo "// This file was auto-generated by bindings script. Do not edit this file manually." > index.ts + +for file in *.ts; do + if [ "$file" != "index.ts" ]; then + echo "export * from './${file%.*}';" >> index.ts + fi +done + +cd ../.. + +echo 'Operation completed successfully.' \ No newline at end of file diff --git a/server/bindings/ClientConnectInitEvent.ts b/server/bindings/ClientConnectInitEvent.ts deleted file mode 100644 index d1ed7726..00000000 --- a/server/bindings/ClientConnectInitEvent.ts +++ /dev/null @@ -1,4 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { SessionType } from "./SessionType"; - -export interface ClientConnectInitEvent { clientId: string, sessionId: string, walletName: string, walletType: string, sessionType: SessionType, } \ No newline at end of file diff --git a/server/bindings/CloudApiErrors.ts b/server/bindings/CloudApiErrors.ts index 6937c645..d17d556e 100644 --- a/server/bindings/CloudApiErrors.ts +++ b/server/bindings/CloudApiErrors.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type CloudApiErrors = "TeamDoesNotExist" | "UserDoesNotExist" | "CloudFeatureDisabled" | "InsufficientPermissions" | "TeamHasNoRegisteredApps" | "DatabaseError" | "MaximumUsersPerTeamReached" | "UserAlreadyBelongsToTheTeam" | "IncorrectPassword" | "AccessTokenFailure" | "RefreshTokenFailure" | "AppAlreadyExists" | "MaximumAppsPerTeamReached" | "TeamAlreadyExists" | "PersonalTeamAlreadyExists" | "EmailAlreadyExists" | "InternalServerError" | "UserDoesNotBelongsToTheTeam" | "InvalidName" | "UnauthorizedOriginError" | "AppDoesNotExist" | "UserAlreadyInvitedToTheTeam" | "MaximumInvitesPerTeamReached" | "InviteNotFound" | "ActionForbiddenForPersonalTeam" | "InviteDoesNotExist" | "InvalidPaginationCursor" | "InvalidVerificationCode" | "InvalidDomainName" | "DomainAlreadyVerified" | "DomainVerificationFailure" | "DomainNotFound" | "DomainVerificationNotStarted" | "WebAuthnError" | "PasswordNotSet"; \ No newline at end of file +export type CloudApiErrors = "TeamDoesNotExist" | "UserDoesNotExist" | "CloudFeatureDisabled" | "InsufficientPermissions" | "TeamHasNoRegisteredApps" | "DatabaseError" | "MaximumUsersPerTeamReached" | "UserAlreadyBelongsToTheTeam" | "IncorrectPassword" | "AccessTokenFailure" | "RefreshTokenFailure" | "AppAlreadyExists" | "MaximumAppsPerTeamReached" | "TeamAlreadyExists" | "PersonalTeamAlreadyExists" | "EmailAlreadyExists" | "InternalServerError" | "UserDoesNotBelongsToTheTeam" | "InvalidName" | "UnauthorizedOriginError" | "AppDoesNotExist" | "UserAlreadyInvitedToTheTeam" | "MaximumInvitesPerTeamReached" | "InviteNotFound" | "ActionForbiddenForPersonalTeam" | "InviteDoesNotExist" | "InvalidPaginationCursor" | "InvalidVerificationCode" | "InvalidDomainName" | "DomainAlreadyVerified" | "DomainVerificationFailure" | "DomainNotFound" | "DomainVerificationNotStarted" | "WebAuthnError" | "PasswordNotSet" | "UserDoesNotHavePasskey" | "PasskeyAlreadyExists" | "InvalidPasskeyCredential" | "PasskeyDoesNotExist"; \ No newline at end of file diff --git a/sdk/bindings/HttpAddUserToTeamResponse.ts b/server/bindings/HttpAddPasskeyFinishResponse.ts similarity index 69% rename from sdk/bindings/HttpAddUserToTeamResponse.ts rename to server/bindings/HttpAddPasskeyFinishResponse.ts index f642bfce..0595e675 100644 --- a/sdk/bindings/HttpAddUserToTeamResponse.ts +++ b/server/bindings/HttpAddPasskeyFinishResponse.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type HttpAddUserToTeamResponse = null; \ No newline at end of file +export type HttpAddPasskeyFinishResponse = null; \ No newline at end of file diff --git a/server/bindings/HttpAddUserToTeamRequest.ts b/server/bindings/HttpAddUserToTeamRequest.ts deleted file mode 100644 index 37c710e6..00000000 --- a/server/bindings/HttpAddUserToTeamRequest.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface HttpAddUserToTeamRequest { teamId: string, userEmail: string, } \ No newline at end of file diff --git a/server/bindings/HttpChangeUsersPrivilegesRequest.ts b/server/bindings/HttpChangeUsersPrivilegesRequest.ts new file mode 100644 index 00000000..3cf06666 --- /dev/null +++ b/server/bindings/HttpChangeUsersPrivilegesRequest.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PrivilegeChange } from "./PrivilegeChange"; + +export interface HttpChangeUsersPrivilegesRequest { teamId: string, privilegesChanges: Array, } \ No newline at end of file diff --git a/server/bindings/HttpChangeUsersPrivilegesResponse.ts b/server/bindings/HttpChangeUsersPrivilegesResponse.ts new file mode 100644 index 00000000..ecdc7535 --- /dev/null +++ b/server/bindings/HttpChangeUsersPrivilegesResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpChangeUsersPrivilegesResponse = null; \ No newline at end of file diff --git a/server/bindings/HttpCloudEndpoint.ts b/server/bindings/HttpCloudEndpoint.ts index 4086edb1..b3b855ef 100644 --- a/server/bindings/HttpCloudEndpoint.ts +++ b/server/bindings/HttpCloudEndpoint.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type HttpCloudEndpoint = "/register_new_app" | "/register_with_password" | "/login_with_password_start" | "/login_with_password_finish" | "/login_with_google" | "/register_new_team" | "/remove_user_from_team" | "/get_user_joined_teams" | "/events" | "/invite_user_to_team" | "/accept_team_invite" | "/get_team_user_invites" | "/get_user_team_invites" | "/cancel_team_user_invite" | "/cancel_user_team_invite" | "/get_app_events" | "/reset_password_start" | "/reset_password_finish" | "/verify_domain_start" | "/verify_domain_finish" | "/remove_whitelisted_domain" | "/register_with_passkey_start" | "/register_with_passkey_finish"; \ No newline at end of file +export type HttpCloudEndpoint = "/register_new_app" | "/register_with_password_start" | "/register_with_password_finish" | "/login_with_password" | "/login_with_google" | "/register_new_team" | "/remove_user_from_team" | "/get_user_joined_teams" | "/events" | "/invite_user_to_team" | "/accept_team_invite" | "/get_team_user_invites" | "/get_user_team_invites" | "/cancel_team_user_invite" | "/cancel_user_team_invite" | "/get_app_events" | "/reset_password_start" | "/reset_password_finish" | "/verify_domain_start" | "/verify_domain_finish" | "/remove_whitelisted_domain" | "/register_with_passkey_start" | "/register_with_passkey_finish" | "/reset_passkey_start" | "/reset_passkey_finish" | "/get_passkey_challenge" | "/delete_passkey" | "/add_passkey_start" | "/add_passkey_finish" | "/get_user_metadata" | "/get_team_metadata" | "/get_team_users_privileges" | "/change_user_privileges" | "/login_with_passkey_start" | "/login_with_passkey_finish"; \ No newline at end of file diff --git a/server/bindings/HttpGetAppEventsEventRequest.ts b/server/bindings/HttpGetAppEventsEventRequest.ts deleted file mode 100644 index 9d69a36c..00000000 --- a/server/bindings/HttpGetAppEventsEventRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { PaginationCursor } from './PaginationCursor' - -export interface HttpGetAppEventsRequest { - appId: string - paginationCursor?: PaginationCursor -} diff --git a/server/bindings/HttpGetTeamMetadataRequest.ts b/server/bindings/HttpGetTeamMetadataRequest.ts new file mode 100644 index 00000000..3f8711c0 --- /dev/null +++ b/server/bindings/HttpGetTeamMetadataRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpGetTeamMetadataRequest { teamId: string, } \ No newline at end of file diff --git a/server/bindings/HttpGetTeamMetadataResponse.ts b/server/bindings/HttpGetTeamMetadataResponse.ts new file mode 100644 index 00000000..288e1f6c --- /dev/null +++ b/server/bindings/HttpGetTeamMetadataResponse.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AppInfo } from "./AppInfo"; +import type { TeamMetadata } from "./TeamMetadata"; + +export interface HttpGetTeamMetadataResponse { teamMetadata: TeamMetadata, teamApps: Array, teamMembers: Array, } \ No newline at end of file diff --git a/server/bindings/MessageToSign.ts b/server/bindings/HttpGetTeamUsersPrivilegesRequest.ts similarity index 64% rename from server/bindings/MessageToSign.ts rename to server/bindings/HttpGetTeamUsersPrivilegesRequest.ts index c5933b0b..0c3d35f6 100644 --- a/server/bindings/MessageToSign.ts +++ b/server/bindings/HttpGetTeamUsersPrivilegesRequest.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface MessageToSign { message: string, metadata?: string, } \ No newline at end of file +export interface HttpGetTeamUsersPrivilegesRequest { teamId: string, } \ No newline at end of file diff --git a/server/bindings/HttpGetTeamUsersPrivilegesResponse.ts b/server/bindings/HttpGetTeamUsersPrivilegesResponse.ts new file mode 100644 index 00000000..5a2d81d8 --- /dev/null +++ b/server/bindings/HttpGetTeamUsersPrivilegesResponse.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { TeamUserPrivilege } from "./TeamUserPrivilege"; + +export interface HttpGetTeamUsersPrivilegesResponse { usersPrivileges: Array, } \ No newline at end of file diff --git a/server/bindings/HttpLoginWithPasskeyFinishResponse.ts b/server/bindings/HttpLoginWithPasskeyFinishResponse.ts new file mode 100644 index 00000000..e8d95372 --- /dev/null +++ b/server/bindings/HttpLoginWithPasskeyFinishResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpLoginWithPasskeyFinishResponse { userId: string, authToken: string, refreshToken: string, } \ No newline at end of file diff --git a/server/bindings/HttpLoginWithPasskeyStartRequest.ts b/server/bindings/HttpLoginWithPasskeyStartRequest.ts new file mode 100644 index 00000000..397c8102 --- /dev/null +++ b/server/bindings/HttpLoginWithPasskeyStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpLoginWithPasskeyStartRequest { email: string, } \ No newline at end of file diff --git a/server/bindings/HttpRegisterWithPasswordFinishRequest.ts b/server/bindings/HttpRegisterWithPasswordFinishRequest.ts new file mode 100644 index 00000000..1db15198 --- /dev/null +++ b/server/bindings/HttpRegisterWithPasswordFinishRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpRegisterWithPasswordFinishRequest { email: string, code: string, } \ No newline at end of file diff --git a/server/bindings/HttpRegisterWithPasswordFinishResponse.ts b/server/bindings/HttpRegisterWithPasswordFinishResponse.ts new file mode 100644 index 00000000..533558d7 --- /dev/null +++ b/server/bindings/HttpRegisterWithPasswordFinishResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpRegisterWithPasswordFinishResponse = null; \ No newline at end of file diff --git a/server/bindings/HttpRegisterWithPasswordRequest.ts b/server/bindings/HttpRegisterWithPasswordRequest.ts deleted file mode 100644 index 6671dc07..00000000 --- a/server/bindings/HttpRegisterWithPasswordRequest.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface HttpRegisterWithPasswordRequest { email: string, password: string, } \ No newline at end of file diff --git a/server/bindings/HttpRegisterWithPasswordStartRequest.ts b/server/bindings/HttpRegisterWithPasswordStartRequest.ts new file mode 100644 index 00000000..aa509863 --- /dev/null +++ b/server/bindings/HttpRegisterWithPasswordStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpRegisterWithPasswordStartRequest { email: string, password: string, } \ No newline at end of file diff --git a/server/bindings/HttpRegisterWithPasswordStartResponse.ts b/server/bindings/HttpRegisterWithPasswordStartResponse.ts new file mode 100644 index 00000000..dabf431f --- /dev/null +++ b/server/bindings/HttpRegisterWithPasswordStartResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpRegisterWithPasswordStartResponse = null; \ No newline at end of file diff --git a/server/bindings/HttpResetPasskeyFinishResponse.ts b/server/bindings/HttpResetPasskeyFinishResponse.ts new file mode 100644 index 00000000..c9174c9d --- /dev/null +++ b/server/bindings/HttpResetPasskeyFinishResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpResetPasskeyFinishResponse = null; \ No newline at end of file diff --git a/server/bindings/HttpResetPasskeyStartRequest.ts b/server/bindings/HttpResetPasskeyStartRequest.ts new file mode 100644 index 00000000..d245482a --- /dev/null +++ b/server/bindings/HttpResetPasskeyStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpResetPasskeyStartRequest { email: string, } \ No newline at end of file diff --git a/sdk/bindings/HttpAddUserToTeamRequest.ts b/server/bindings/HttpResetPasswordFinishRequest.ts similarity index 57% rename from sdk/bindings/HttpAddUserToTeamRequest.ts rename to server/bindings/HttpResetPasswordFinishRequest.ts index 37c710e6..3acde685 100644 --- a/sdk/bindings/HttpAddUserToTeamRequest.ts +++ b/server/bindings/HttpResetPasswordFinishRequest.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface HttpAddUserToTeamRequest { teamId: string, userEmail: string, } \ No newline at end of file +export interface HttpResetPasswordFinishRequest { email: string, code: string, } \ No newline at end of file diff --git a/server/bindings/HttpResetPasswordFinishResponse.ts b/server/bindings/HttpResetPasswordFinishResponse.ts new file mode 100644 index 00000000..941dfe57 --- /dev/null +++ b/server/bindings/HttpResetPasswordFinishResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpResetPasswordFinishResponse = null; \ No newline at end of file diff --git a/server/bindings/HttpResetPasswordRequest.ts b/server/bindings/HttpResetPasswordRequest.ts deleted file mode 100644 index 0703a1ba..00000000 --- a/server/bindings/HttpResetPasswordRequest.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface HttpResetPasswordRequest { email: string, newPassword: string, } \ No newline at end of file diff --git a/server/bindings/HttpResetPasswordStartRequest.ts b/server/bindings/HttpResetPasswordStartRequest.ts new file mode 100644 index 00000000..69bb4744 --- /dev/null +++ b/server/bindings/HttpResetPasswordStartRequest.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpResetPasswordStartRequest { email: string, newPassword: string, } \ No newline at end of file diff --git a/server/bindings/HttpResetPasswordStartResponse.ts b/server/bindings/HttpResetPasswordStartResponse.ts new file mode 100644 index 00000000..fe2df9e4 --- /dev/null +++ b/server/bindings/HttpResetPasswordStartResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type HttpResetPasswordStartResponse = null; \ No newline at end of file diff --git a/server/bindings/HttpUserMetadataResponse.ts b/server/bindings/HttpUserMetadataResponse.ts new file mode 100644 index 00000000..53a7c630 --- /dev/null +++ b/server/bindings/HttpUserMetadataResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface HttpUserMetadataResponse { userId: string, email: string, passwordSet: boolean, passkeyIds: Array, } \ No newline at end of file diff --git a/server/bindings/HttpVerifyRegisterWithPasswordResponse.ts b/server/bindings/HttpVerifyRegisterWithPasswordResponse.ts deleted file mode 100644 index db915b5e..00000000 --- a/server/bindings/HttpVerifyRegisterWithPasswordResponse.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export type HttpVerifyRegisterWithPasswordResponse = null; \ No newline at end of file diff --git a/server/bindings/LoginWithGoogleResponse.ts b/server/bindings/LoginWithGoogleResponse.ts deleted file mode 100644 index 718e6d34..00000000 --- a/server/bindings/LoginWithGoogleResponse.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface LoginWithGoogleResponse { userId: string, authToken: string, refreshToken: string, } \ No newline at end of file diff --git a/server/bindings/NewRequestEvent.ts b/server/bindings/NewRequestEvent.ts deleted file mode 100644 index d6917eb3..00000000 --- a/server/bindings/NewRequestEvent.ts +++ /dev/null @@ -1,4 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { RequestType } from "./RequestType"; - -export interface NewRequestEvent { sessionId: string, requestId: string, requestType: RequestType, network: string, } \ No newline at end of file diff --git a/server/bindings/NewUserPrivilegeLevel.ts b/server/bindings/NewUserPrivilegeLevel.ts new file mode 100644 index 00000000..9e04e946 --- /dev/null +++ b/server/bindings/NewUserPrivilegeLevel.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type NewUserPrivilegeLevel = "read" | "edit" | "noAccess"; \ No newline at end of file diff --git a/server/bindings/PrivilegeChange.ts b/server/bindings/PrivilegeChange.ts new file mode 100644 index 00000000..eb306ac2 --- /dev/null +++ b/server/bindings/PrivilegeChange.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NewUserPrivilegeLevel } from "./NewUserPrivilegeLevel"; + +export interface PrivilegeChange { appId: string, userEmail: string, newPrivilegeLevel: NewUserPrivilegeLevel, } \ No newline at end of file diff --git a/server/bindings/RequestResolvedEvent.ts b/server/bindings/RequestResolvedEvent.ts deleted file mode 100644 index 4cdd3a2a..00000000 --- a/server/bindings/RequestResolvedEvent.ts +++ /dev/null @@ -1,4 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { RequestFail } from "./RequestFail"; - -export interface RequestResolvedEvent { sessionId: string, requestId: string, failureReason?: RequestFail, } \ No newline at end of file diff --git a/server/bindings/RequestType.ts b/server/bindings/RequestType.ts deleted file mode 100644 index 1477f1d3..00000000 --- a/server/bindings/RequestType.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export type RequestType = "signMessage" | "signTransaction" | "signAndSendTransaction" | "changeWallet" | "changeNetwork"; \ No newline at end of file diff --git a/server/bindings/TeamMetadata.ts b/server/bindings/TeamMetadata.ts new file mode 100644 index 00000000..f03a7acf --- /dev/null +++ b/server/bindings/TeamMetadata.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface TeamMetadata { creatorEmail: string, teamId: string, teamName: string, personalTeam: boolean, createdAt: string, } \ No newline at end of file diff --git a/server/bindings/TeamUserPrivilege.ts b/server/bindings/TeamUserPrivilege.ts new file mode 100644 index 00000000..714a2c9a --- /dev/null +++ b/server/bindings/TeamUserPrivilege.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PrivilegeLevel } from "./PrivilegeLevel"; + +export interface TeamUserPrivilege { appId: string, userEmail: string, privilege: PrivilegeLevel, } \ No newline at end of file diff --git a/server/bindings/TransactionToSign.ts b/server/bindings/TransactionToSign.ts deleted file mode 100644 index c031c34d..00000000 --- a/server/bindings/TransactionToSign.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. - -export interface TransactionToSign { transaction: string, metadata?: string, } \ No newline at end of file diff --git a/server/src/http/cloud/change_user_privileges.rs b/server/src/http/cloud/change_user_privileges.rs index 154c6b29..e3a2c751 100644 --- a/server/src/http/cloud/change_user_privileges.rs +++ b/server/src/http/cloud/change_user_privileges.rs @@ -193,7 +193,7 @@ pub async fn change_user_privileges( } }; } - NewUserPrivilegeLevel::Write => { + NewUserPrivilegeLevel::Edit => { // check current privilege level match current_privilege { Some(privileges) => { @@ -380,7 +380,7 @@ mod tests { let privilege = if i % 2 == 0 { NewUserPrivilegeLevel::Read } else { - NewUserPrivilegeLevel::Write + NewUserPrivilegeLevel::Edit }; let change = PrivilegeChange { diff --git a/server/src/http/cloud/reset_credentials/reset_password_finish.rs b/server/src/http/cloud/reset_credentials/reset_password_finish.rs index 66a9200d..b3cf166e 100644 --- a/server/src/http/cloud/reset_credentials/reset_password_finish.rs +++ b/server/src/http/cloud/reset_credentials/reset_password_finish.rs @@ -17,7 +17,7 @@ use ts_rs::TS; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS, Validate)] #[ts(export)] #[serde(rename_all = "camelCase")] -pub struct HttpVerifyPasswordResetRequest { +pub struct HttpResetPasswordFinishRequest { #[garde(email)] pub email: String, #[garde(custom(custom_validate_verification_code))] @@ -26,13 +26,13 @@ pub struct HttpVerifyPasswordResetRequest { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)] #[ts(export)] -pub struct HttpVerifyPasswordResetResponse {} +pub struct HttpResetPasswordFinishResponse {} pub async fn reset_password_finish( State(db): State>, State(sessions_cache): State>, - Json(request): Json, -) -> Result, (StatusCode, String)> { + Json(request): Json, +) -> Result, (StatusCode, String)> { // Validate request validate_request(&request, &())?; @@ -75,7 +75,7 @@ pub async fn reset_password_finish( )); } - return Ok(Json(HttpVerifyPasswordResetResponse {})); + return Ok(Json(HttpResetPasswordFinishResponse {})); } #[cfg(feature = "cloud_db_tests")] @@ -86,7 +86,7 @@ mod tests { http::cloud::{ login::login_with_password::{HttpLoginRequest, HttpLoginResponse}, reset_credentials::reset_password_start::{ - HttpResetPasswordRequest, HttpResetPasswordResponse, + HttpResetPasswordStartRequest, HttpResetPasswordStartResponse, }, }, structs::cloud::cloud_http_endpoints::HttpCloudEndpoint, @@ -112,7 +112,7 @@ mod tests { // Start password reset let new_password = "NewValidPassword123".to_string(); - let password_reset_start_payload = HttpResetPasswordRequest { + let password_reset_start_payload = HttpResetPasswordStartRequest { email: email.to_string(), new_password: new_password.to_string(), }; @@ -134,12 +134,12 @@ mod tests { // Send request let register_response = test_app.clone().oneshot(req).await.unwrap(); // Validate response - convert_response::(register_response) + convert_response::(register_response) .await .unwrap(); // Validate new password change - let verify_register_payload = HttpVerifyPasswordResetRequest { + let verify_register_payload = HttpResetPasswordFinishRequest { email: email.to_string(), // Random valid code for testing code: "123456".to_string(), diff --git a/server/src/http/cloud/reset_credentials/reset_password_start.rs b/server/src/http/cloud/reset_credentials/reset_password_start.rs index 62af4161..e0cd4afc 100644 --- a/server/src/http/cloud/reset_credentials/reset_password_start.rs +++ b/server/src/http/cloud/reset_credentials/reset_password_start.rs @@ -27,7 +27,7 @@ use ts_rs::TS; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS, Validate)] #[ts(export)] #[serde(rename_all = "camelCase")] -pub struct HttpResetPasswordRequest { +pub struct HttpResetPasswordStartRequest { #[garde(email)] pub email: String, #[garde(custom(custom_validate_new_password))] @@ -36,14 +36,14 @@ pub struct HttpResetPasswordRequest { #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)] #[ts(export)] -pub struct HttpResetPasswordResponse {} +pub struct HttpResetPasswordStartResponse {} pub async fn reset_password_start( State(db): State>, State(sessions_cache): State>, State(mailer): State>, - Json(request): Json, -) -> Result, (StatusCode, String)> { + Json(request): Json, +) -> Result, (StatusCode, String)> { // Validate request validate_request(&request, &())?; @@ -111,10 +111,10 @@ pub async fn reset_password_start( )); } None => { - return Ok(Json(HttpResetPasswordResponse {})); + return Ok(Json(HttpResetPasswordStartResponse {})); } } } - Ok(Json(HttpResetPasswordResponse {})) + Ok(Json(HttpResetPasswordStartResponse {})) } diff --git a/server/src/routes/cloud_router.rs b/server/src/routes/cloud_router.rs index bdf8c042..05decc6b 100644 --- a/server/src/routes/cloud_router.rs +++ b/server/src/routes/cloud_router.rs @@ -21,7 +21,12 @@ use crate::{ get_user_metadata::get_user_metadata, get_user_team_invites::get_user_team_invites, invite_user_to_team::invite_user_to_team, - login::{login_with_google::login_with_google, login_with_password::login_with_password}, + login::{ + login_with_google::login_with_google, + login_with_passkey_finish::login_with_passkey_finish, + login_with_passkey_start::login_with_passkey_start, + login_with_password::login_with_password, + }, register::{ register_with_passkey_finish::register_with_passkey_finish, register_with_passkey_start::register_with_passkey_start, @@ -70,6 +75,14 @@ pub fn public_router(state: ServerState) -> Router { &HttpCloudEndpoint::LoginWithGoogle.to_string(), post(login_with_google), ) + .route( + &HttpCloudEndpoint::LoginWithPasskeyStart.to_string(), + post(login_with_passkey_start), + ) + .route( + &HttpCloudEndpoint::LoginWithPasskeyFinish.to_string(), + post(login_with_passkey_finish), + ) .route( &HttpCloudEndpoint::RegisterWithPasswordStart.to_string(), post(register_with_password_start), diff --git a/server/src/structs/cloud/cloud_http_endpoints.rs b/server/src/structs/cloud/cloud_http_endpoints.rs index d7abad4c..1c6087f0 100644 --- a/server/src/structs/cloud/cloud_http_endpoints.rs +++ b/server/src/structs/cloud/cloud_http_endpoints.rs @@ -6,11 +6,11 @@ use ts_rs::TS; pub enum HttpCloudEndpoint { #[serde(rename = "/register_new_app")] RegisterNewApp, - #[serde(rename = "/register_with_password")] + #[serde(rename = "/register_with_password_start")] RegisterWithPasswordStart, - #[serde(rename = "/login_with_password_start")] + #[serde(rename = "/register_with_password_finish")] RegisterWithPasswordFinish, - #[serde(rename = "/login_with_password_finish")] + #[serde(rename = "/login_with_password")] LoginWithPassword, #[serde(rename = "/login_with_google")] LoginWithGoogle, @@ -66,10 +66,14 @@ pub enum HttpCloudEndpoint { GetUserMetadata, #[serde(rename = "/get_team_metadata")] GetTeamMetadata, - #[serde(rename = "/get_team_user_privileges")] + #[serde(rename = "/get_team_users_privileges")] GetTeamUserPrivileges, #[serde(rename = "/change_user_privileges")] ChangeUserPrivileges, + #[serde(rename = "/login_with_passkey_start")] + LoginWithPasskeyStart, + #[serde(rename = "/login_with_passkey_finish")] + LoginWithPasskeyFinish, } impl HttpCloudEndpoint { @@ -80,7 +84,7 @@ impl HttpCloudEndpoint { "/register_with_password_start".to_string() } HttpCloudEndpoint::RegisterWithPasswordFinish => { - "/login_with_password_finish".to_string() + "/register_with_password_finish".to_string() } HttpCloudEndpoint::LoginWithPassword => "/login_with_password".to_string(), HttpCloudEndpoint::LoginWithGoogle => "/login_with_google".to_string(), @@ -114,8 +118,10 @@ impl HttpCloudEndpoint { HttpCloudEndpoint::AddPasskeyFinish => "/add_passkey_finish".to_string(), HttpCloudEndpoint::GetUserMetadata => "/get_user_metadata".to_string(), HttpCloudEndpoint::GetTeamMetadata => "/get_team_metadata".to_string(), - HttpCloudEndpoint::GetTeamUserPrivileges => "/get_team_user_privileges".to_string(), + HttpCloudEndpoint::GetTeamUserPrivileges => "/get_team_users_privileges".to_string(), HttpCloudEndpoint::ChangeUserPrivileges => "/change_user_privileges".to_string(), + HttpCloudEndpoint::LoginWithPasskeyStart => "/login_with_passkey_start".to_string(), + HttpCloudEndpoint::LoginWithPasskeyFinish => "/login_with_passkey_finish".to_string(), } } } diff --git a/server/src/structs/cloud/new_user_privilege_level.rs b/server/src/structs/cloud/new_user_privilege_level.rs index 4f27d2a2..1a62ca0f 100644 --- a/server/src/structs/cloud/new_user_privilege_level.rs +++ b/server/src/structs/cloud/new_user_privilege_level.rs @@ -7,7 +7,7 @@ use ts_rs::TS; #[serde(rename_all = "camelCase")] pub enum NewUserPrivilegeLevel { Read, - Write, + Edit, NoAccess, } @@ -15,7 +15,7 @@ impl NewUserPrivilegeLevel { pub fn to_privilege_level(&self) -> Option { match self { NewUserPrivilegeLevel::Read => Some(PrivilegeLevel::Read), - NewUserPrivilegeLevel::Write => Some(PrivilegeLevel::Edit), + NewUserPrivilegeLevel::Edit => Some(PrivilegeLevel::Edit), NewUserPrivilegeLevel::NoAccess => None, } }