Skip to content

Commit

Permalink
Merge pull request #66 from cornerman/begin-oauth-url
Browse files Browse the repository at this point in the history
add method to get beginOAuthUrl
  • Loading branch information
cainlevy authored Feb 9, 2024
2 parents 8d4b1ff + a284aa6 commit a221fcb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ KeratinAuthN.confirmTOTP(obj: {otp: string}): Promise<boolean>
KeratinAuthN.deleteTOTP(): Promise<boolean>
```

```javascript
// Get the begin oauth url for a specified provider.
KeratinAuthN.beginOAuthUrl(providerName: string, redirectUri: string): string
```

## Development

Embrace the TypeScript!
Expand Down
5 changes: 5 additions & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ export function deleteTOTP(): Promise<boolean> {
.catch(() => false);
}

export function beginOAuthUrl(providerName: string, redirectUri: string): string {
let redirectUriParam = encodeURIComponent(redirectUri);
return url(`/oauth/${providerName}?redirect_uri=${redirectUriParam}`);
}

function url(path: string): string {
if (!ISSUER.length) {
throw "ISSUER not set";
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ export {
newTOTP,
confirmTOTP,
deleteTOTP,
beginOAuthUrl,
} from "./api";

0 comments on commit a221fcb

Please sign in to comment.