Skip to content

Commit

Permalink
Merge branch 'main' into feat-add-phone-password
Browse files Browse the repository at this point in the history
  • Loading branch information
coratgerl committed Jan 28, 2025
2 parents 2789dfd + 97867f1 commit e6c0978
Show file tree
Hide file tree
Showing 14 changed files with 665 additions and 21 deletions.
4 changes: 2 additions & 2 deletions packages/wabe/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const run = async () => {
cookieSession: true,
},
roles: ['Admin', 'Client'],
successRedirectPath: 'http://localhost:3000/auth/oauth?provider=google',
failureRedirectPath: 'http://localhost:3000/auth/oauth?provider=google',
successRedirectPath: 'http://shipmysaas.com',
failureRedirectPath: 'https://shipmysaas.com',
customAuthenticationMethods: [
{
name: 'otp',
Expand Down
55 changes: 50 additions & 5 deletions packages/wabe/generated/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ enum RoleEnum {
}

enum AuthenticationProvider {
github
google
emailPassword
phonePassword
Expand Down Expand Up @@ -58,6 +59,7 @@ type UserAuthentication {
phonePassword: UserAuthenticationPhonePassword
emailPassword: UserAuthenticationEmailPassword
google: UserAuthenticationGoogle
github: UserAuthenticationGithub
}

type UserAuthenticationPhonePassword {
Expand All @@ -76,7 +78,12 @@ type UserAuthenticationEmailPassword {
type UserAuthenticationGoogle {
email: Email!
verifiedEmail: Boolean!
idToken: String!
}

type UserAuthenticationGithub {
email: Email!
avatarUrl: String!
username: String!
}

type _SessionConnection {
Expand Down Expand Up @@ -126,6 +133,7 @@ input UserAuthenticationInput {
phonePassword: UserAuthenticationPhonePasswordInput
emailPassword: UserAuthenticationEmailPasswordInput
google: UserAuthenticationGoogleInput
github: UserAuthenticationGithubInput
}

input UserAuthenticationPhonePasswordInput {
Expand All @@ -141,7 +149,12 @@ input UserAuthenticationEmailPasswordInput {
input UserAuthenticationGoogleInput {
email: Email!
verifiedEmail: Boolean!
idToken: String!
}

input UserAuthenticationGithubInput {
email: Email!
avatarUrl: String!
username: String!
}

"""Input to link an object to a pointer User"""
Expand Down Expand Up @@ -189,6 +202,7 @@ input UserAuthenticationCreateFieldsInput {
phonePassword: UserAuthenticationPhonePasswordCreateFieldsInput
emailPassword: UserAuthenticationEmailPasswordCreateFieldsInput
google: UserAuthenticationGoogleCreateFieldsInput
github: UserAuthenticationGithubCreateFieldsInput
}

input UserAuthenticationPhonePasswordCreateFieldsInput {
Expand All @@ -204,7 +218,12 @@ input UserAuthenticationEmailPasswordCreateFieldsInput {
input UserAuthenticationGoogleCreateFieldsInput {
email: Email
verifiedEmail: Boolean
idToken: String
}

input UserAuthenticationGithubCreateFieldsInput {
email: Email
avatarUrl: String
username: String
}

"""Input to add a relation to the class User"""
Expand Down Expand Up @@ -737,6 +756,7 @@ input UserAuthenticationWhereInput {
phonePassword: UserAuthenticationPhonePasswordWhereInput
emailPassword: UserAuthenticationEmailPasswordWhereInput
google: UserAuthenticationGoogleWhereInput
github: UserAuthenticationGithubWhereInput
OR: [UserAuthenticationWhereInput]
AND: [UserAuthenticationWhereInput]
}
Expand Down Expand Up @@ -765,11 +785,18 @@ input UserAuthenticationEmailPasswordWhereInput {
input UserAuthenticationGoogleWhereInput {
email: EmailWhereInput
verifiedEmail: BooleanWhereInput
idToken: StringWhereInput
OR: [UserAuthenticationGoogleWhereInput]
AND: [UserAuthenticationGoogleWhereInput]
}

input UserAuthenticationGithubWhereInput {
email: EmailWhereInput
avatarUrl: StringWhereInput
username: StringWhereInput
OR: [UserAuthenticationGithubWhereInput]
AND: [UserAuthenticationGithubWhereInput]
}

input AnyWhereInput {
equalTo: Any
notEqualTo: Any
Expand Down Expand Up @@ -1187,6 +1214,7 @@ input UserAuthenticationUpdateFieldsInput {
phonePassword: UserAuthenticationPhonePasswordUpdateFieldsInput
emailPassword: UserAuthenticationEmailPasswordUpdateFieldsInput
google: UserAuthenticationGoogleUpdateFieldsInput
github: UserAuthenticationGithubUpdateFieldsInput
}

input UserAuthenticationPhonePasswordUpdateFieldsInput {
Expand All @@ -1202,7 +1230,12 @@ input UserAuthenticationEmailPasswordUpdateFieldsInput {
input UserAuthenticationGoogleUpdateFieldsInput {
email: Email
verifiedEmail: Boolean
idToken: String
}

input UserAuthenticationGithubUpdateFieldsInput {
email: Email
avatarUrl: String
username: String
}

input UpdateUsersInput {
Expand Down Expand Up @@ -1579,6 +1612,7 @@ input SignInWithAuthenticationInput {
phonePassword: SignInWithAuthenticationPhonePasswordInput
emailPassword: SignInWithAuthenticationEmailPasswordInput
google: SignInWithAuthenticationGoogleInput
github: SignInWithAuthenticationGithubInput
otp: SignInWithAuthenticationOtpInput
secondaryFactor: SecondaryFactor
}
Expand All @@ -1598,6 +1632,11 @@ input SignInWithAuthenticationGoogleInput {
codeVerifier: String!
}

input SignInWithAuthenticationGithubInput {
authorizationCode: String!
codeVerifier: String!
}

input SignInWithAuthenticationOtpInput {
code: String
}
Expand All @@ -1616,6 +1655,7 @@ input SignUpWithAuthenticationInput {
phonePassword: SignUpWithAuthenticationPhonePasswordInput
emailPassword: SignUpWithAuthenticationEmailPasswordInput
google: SignUpWithAuthenticationGoogleInput
github: SignUpWithAuthenticationGithubInput
otp: SignUpWithAuthenticationOtpInput
secondaryFactor: SecondaryFactor
}
Expand All @@ -1635,6 +1675,11 @@ input SignUpWithAuthenticationGoogleInput {
codeVerifier: String!
}

input SignUpWithAuthenticationGithubInput {
authorizationCode: String!
codeVerifier: String!
}

input SignUpWithAuthenticationOtpInput {
code: String
}
Expand Down
55 changes: 50 additions & 5 deletions packages/wabe/generated/wabe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum RoleEnum {
}

export enum AuthenticationProvider {
github = "github",
google = "google",
emailPassword = "emailPassword",
phonePassword = "phonePassword",
Expand Down Expand Up @@ -66,6 +67,7 @@ export type UserAuthentication = {
phonePassword?: UserAuthenticationPhonePassword;
emailPassword?: UserAuthenticationEmailPassword;
google?: UserAuthenticationGoogle;
github?: UserAuthenticationGithub;
};

export type UserAuthenticationPhonePassword = {
Expand All @@ -81,7 +83,12 @@ export type UserAuthenticationEmailPassword = {
export type UserAuthenticationGoogle = {
email: Scalars['Email']['output'];
verifiedEmail: Scalars['Boolean']['output'];
idToken: Scalars['String']['output'];
};

export type UserAuthenticationGithub = {
email: Scalars['Email']['output'];
avatarUrl: Scalars['String']['output'];
username: Scalars['String']['output'];
};

export type _SessionConnection = {
Expand Down Expand Up @@ -130,6 +137,7 @@ export type UserAuthenticationInput = {
phonePassword?: UserAuthenticationPhonePasswordInput;
emailPassword?: UserAuthenticationEmailPasswordInput;
google?: UserAuthenticationGoogleInput;
github?: UserAuthenticationGithubInput;
};

export type UserAuthenticationPhonePasswordInput = {
Expand All @@ -145,7 +153,12 @@ export type UserAuthenticationEmailPasswordInput = {
export type UserAuthenticationGoogleInput = {
email: Scalars['Email']['input'];
verifiedEmail: Scalars['Boolean']['input'];
idToken: Scalars['String']['input'];
};

export type UserAuthenticationGithubInput = {
email: Scalars['Email']['input'];
avatarUrl: Scalars['String']['input'];
username: Scalars['String']['input'];
};

export type UserPointerInput = {
Expand Down Expand Up @@ -191,6 +204,7 @@ export type UserAuthenticationCreateFieldsInput = {
phonePassword?: UserAuthenticationPhonePasswordCreateFieldsInput;
emailPassword?: UserAuthenticationEmailPasswordCreateFieldsInput;
google?: UserAuthenticationGoogleCreateFieldsInput;
github?: UserAuthenticationGithubCreateFieldsInput;
};

export type UserAuthenticationPhonePasswordCreateFieldsInput = {
Expand All @@ -206,7 +220,12 @@ export type UserAuthenticationEmailPasswordCreateFieldsInput = {
export type UserAuthenticationGoogleCreateFieldsInput = {
email?: Scalars['Email']['input'];
verifiedEmail?: Scalars['Boolean']['input'];
idToken?: Scalars['String']['input'];
};

export type UserAuthenticationGithubCreateFieldsInput = {
email?: Scalars['Email']['input'];
avatarUrl?: Scalars['String']['input'];
username?: Scalars['String']['input'];
};

export type UserRelationInput = {
Expand Down Expand Up @@ -777,6 +796,7 @@ export type UserAuthenticationWhereInput = {
phonePassword?: UserAuthenticationPhonePasswordWhereInput;
emailPassword?: UserAuthenticationEmailPasswordWhereInput;
google?: UserAuthenticationGoogleWhereInput;
github?: UserAuthenticationGithubWhereInput;
OR?: UserAuthenticationWhereInput[];
AND?: UserAuthenticationWhereInput[];
};
Expand Down Expand Up @@ -805,11 +825,18 @@ export type UserAuthenticationEmailPasswordWhereInput = {
export type UserAuthenticationGoogleWhereInput = {
email?: EmailWhereInput;
verifiedEmail?: BooleanWhereInput;
idToken?: StringWhereInput;
OR?: UserAuthenticationGoogleWhereInput[];
AND?: UserAuthenticationGoogleWhereInput[];
};

export type UserAuthenticationGithubWhereInput = {
email?: EmailWhereInput;
avatarUrl?: StringWhereInput;
username?: StringWhereInput;
OR?: UserAuthenticationGithubWhereInput[];
AND?: UserAuthenticationGithubWhereInput[];
};

export type AnyWhereInput = {
equalTo?: Scalars['Any']['input'];
notEqualTo?: Scalars['Any']['input'];
Expand Down Expand Up @@ -1364,6 +1391,7 @@ export type UserAuthenticationUpdateFieldsInput = {
phonePassword?: UserAuthenticationPhonePasswordUpdateFieldsInput;
emailPassword?: UserAuthenticationEmailPasswordUpdateFieldsInput;
google?: UserAuthenticationGoogleUpdateFieldsInput;
github?: UserAuthenticationGithubUpdateFieldsInput;
};

export type UserAuthenticationPhonePasswordUpdateFieldsInput = {
Expand All @@ -1379,7 +1407,12 @@ export type UserAuthenticationEmailPasswordUpdateFieldsInput = {
export type UserAuthenticationGoogleUpdateFieldsInput = {
email?: Scalars['Email']['input'];
verifiedEmail?: Scalars['Boolean']['input'];
idToken?: Scalars['String']['input'];
};

export type UserAuthenticationGithubUpdateFieldsInput = {
email?: Scalars['Email']['input'];
avatarUrl?: Scalars['String']['input'];
username?: Scalars['String']['input'];
};

export type UpdateUsersInput = {
Expand Down Expand Up @@ -1756,6 +1789,7 @@ export type SignInWithAuthenticationInput = {
phonePassword?: SignInWithAuthenticationPhonePasswordInput;
emailPassword?: SignInWithAuthenticationEmailPasswordInput;
google?: SignInWithAuthenticationGoogleInput;
github?: SignInWithAuthenticationGithubInput;
otp?: SignInWithAuthenticationOtpInput;
secondaryFactor?: SecondaryFactor;
};
Expand All @@ -1775,6 +1809,11 @@ export type SignInWithAuthenticationGoogleInput = {
codeVerifier: Scalars['String']['input'];
};

export type SignInWithAuthenticationGithubInput = {
authorizationCode: Scalars['String']['input'];
codeVerifier: Scalars['String']['input'];
};

export type SignInWithAuthenticationOtpInput = {
code?: Scalars['String']['input'];
};
Expand All @@ -1793,6 +1832,7 @@ export type SignUpWithAuthenticationInput = {
phonePassword?: SignUpWithAuthenticationPhonePasswordInput;
emailPassword?: SignUpWithAuthenticationEmailPasswordInput;
google?: SignUpWithAuthenticationGoogleInput;
github?: SignUpWithAuthenticationGithubInput;
otp?: SignUpWithAuthenticationOtpInput;
secondaryFactor?: SecondaryFactor;
};
Expand All @@ -1812,6 +1852,11 @@ export type SignUpWithAuthenticationGoogleInput = {
codeVerifier: Scalars['String']['input'];
};

export type SignUpWithAuthenticationGithubInput = {
authorizationCode: Scalars['String']['input'];
codeVerifier: Scalars['String']['input'];
};

export type SignUpWithAuthenticationOtpInput = {
code?: Scalars['String']['input'];
};
Expand Down
31 changes: 29 additions & 2 deletions packages/wabe/src/authentication/defaultAuthentication.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { WabeTypes } from '..'
import type { CustomAuthenticationMethods } from './interface'
import { GitHub } from './providers'
import { Google } from './providers'
import { EmailPassword } from './providers/EmailPassword'
import { PhonePassword } from './providers/PhonePassword'
Expand Down Expand Up @@ -76,13 +77,39 @@ export const defaultAuthenticationMethods = <
type: 'Boolean',
required: true,
},
idToken: {
},
// There is no signUp method for Google provider
// @ts-expect-error
provider: new Google(),
},
{
name: 'github',
input: {
authorizationCode: {
type: 'String',
required: true,
},
codeVerifier: {
type: 'String',
required: true,
},
},
dataToStore: {
email: {
type: 'Email',
required: true,
},
avatarUrl: {
type: 'String',
required: true,
},
username: {
type: 'String',
required: true,
},
},
// There is no signUp method for Google provider
// @ts-expect-error
provider: new Google(),
provider: new GitHub(),
},
]
Loading

0 comments on commit e6c0978

Please sign in to comment.