-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: WebAuthN Sign In, Sign Up and Options methods support - NEW #952
Merged
victorbojica
merged 26 commits into
feat/webauthn/base
from
feat/webauthn/basic-methods
Nov 25, 2024
Merged
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c57b645
add initial passkey types
niftyvictor 56422f3
passkey types cleanup
niftyvictor f102128
added untested support for options, sign in and sign up methods
niftyvictor de9fb88
Merge branch 'feat/webauthn/base' into feat/webauthn/basic-methods
niftyvictor 40bd6e9
updated types based on pr changes
niftyvictor e150fc2
pr changes. removed incorrect errors and added missing ones
niftyvictor 8c8d711
added missing user type
niftyvictor ced57b1
added webauthn details to user object
niftyvictor fbbed56
pr fixes. centralized error types and added crud for credentials
niftyvictor 64a4a6b
pr fixes
niftyvictor 3186aa5
pr fixes and added decode method
niftyvictor 3fa31ce
added types implementation and minor fixes
niftyvictor 177b580
pr fixes
niftyvictor 5d1363e
pr fixes and cleanup
niftyvictor 57e210d
pr fixes
niftyvictor ea42bd1
updated initial recipe implementation
niftyvictor b8cffc1
fixed implementation
niftyvictor bf9e00f
added basic build
niftyvictor b44752f
added basic build exports
niftyvictor dba5cda
pr fixes
niftyvictor c84a76a
pr fixes
niftyvictor 3649b45
pr fixes
niftyvictor 3bb7234
pr fixes
niftyvictor ce371d1
pr fixes
niftyvictor d356701
added missing default email delivery implementation
niftyvictor e743046
added basic tests and mock
niftyvictor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. | ||
porcellus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* This software is licensed under the Apache License, Version 2.0 (the | ||
* "License") as published by the Apache Software Foundation. | ||
* | ||
* You may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { send200Response } from "../../../utils"; | ||
import STError from "../error"; | ||
import { APIInterface, APIOptions } from "../"; | ||
import { UserContext } from "../../../types"; | ||
|
||
export default async function emailExists( | ||
apiImplementation: APIInterface, | ||
tenantId: string, | ||
options: APIOptions, | ||
userContext: UserContext | ||
): Promise<boolean> { | ||
// Logic as per https://github.com/supertokens/supertokens-node/issues/47#issue-751571692 | ||
|
||
if (apiImplementation.emailExistsGET === undefined) { | ||
return false; | ||
} | ||
|
||
let email = options.req.getKeyValueFromQuery("email"); | ||
|
||
if (email === undefined || typeof email !== "string") { | ||
throw new STError({ | ||
type: STError.BAD_INPUT_ERROR, | ||
message: "Please provide the email as a GET param", | ||
}); | ||
} | ||
|
||
let result = await apiImplementation.emailExistsGET({ | ||
email, | ||
tenantId, | ||
options, | ||
userContext, | ||
}); | ||
|
||
send200Response(options.res, result); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* Copyright (c) 2021, VRAI Labs and/or its affiliates. All rights reserved. | ||
* | ||
* This software is licensed under the Apache License, Version 2.0 (the | ||
* "License") as published by the Apache Software Foundation. | ||
* | ||
* You may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { send200Response } from "../../../utils"; | ||
import { APIInterface, APIOptions } from "../"; | ||
import { UserContext } from "../../../types"; | ||
import STError from "../error"; | ||
|
||
export default async function generateRecoverAccountToken( | ||
apiImplementation: APIInterface, | ||
tenantId: string, | ||
options: APIOptions, | ||
userContext: UserContext | ||
): Promise<boolean> { | ||
if (apiImplementation.generateRecoverAccountTokenPOST === undefined) { | ||
return false; | ||
} | ||
|
||
const requestBody = await options.req.getJSONBody(); | ||
const email = requestBody.email; | ||
|
||
if (email === undefined || typeof email !== "string") { | ||
throw new STError({ | ||
type: STError.BAD_INPUT_ERROR, | ||
message: "Please provide the email", | ||
}); | ||
} | ||
|
||
let result = await apiImplementation.generateRecoverAccountTokenPOST({ | ||
email, | ||
tenantId, | ||
options, | ||
userContext, | ||
}); | ||
|
||
send200Response(options.res, result); | ||
return true; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also used by listUsersByAccount info. We may have to split types, or are there any cases where we'd want to search by multiple credentialIds? How does that function, do we only get a match if all credentialIds are present? Is there a use-case for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't taken that into consideration. But as far as ai can tell, no. there is no use like that. There might the possibllity to search by one of the credentialIds. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think searching by a single credentialId makes sense.