File tree Expand file tree Collapse file tree 7 files changed +100
-414
lines changed Expand file tree Collapse file tree 7 files changed +100
-414
lines changed Original file line number Diff line number Diff line change 2626 "lint" : " ./scripts/lint" ,
2727 "fix" : " ./scripts/format"
2828 },
29- "dependencies" : {},
29+ "dependencies" : {
30+ "@noble/hashes" : " ^2.0.1"
31+ },
3032 "devDependencies" : {
3133 "@arethetypeswrong/cli" : " ^0.17.0" ,
3234 "@swc/core" : " ^1.3.102" ,
Original file line number Diff line number Diff line change @@ -845,6 +845,41 @@ export class Finch {
845845 sandbox : API . Sandbox = new API . Sandbox ( this ) ;
846846 payroll : API . Payroll = new API . Payroll ( this ) ;
847847 connect : API . Connect = new API . Connect ( this ) ;
848+
849+ /**
850+ * Returns the authorization url which can be visited in order to obtain an
851+ * authorization code from Finch. The authorization code can then be exchanged for
852+ * an access token for the Finch api by calling get_access_token().
853+ */
854+ getAuthURL ( {
855+ products,
856+ redirectUri,
857+ sandbox,
858+ } : {
859+ products : string ;
860+ redirectUri : string ;
861+ sandbox : boolean ;
862+ } ) : string {
863+ if ( ! this . clientID ) {
864+ throw new Error ( 'Expected `clientID` to be set in order to call getAuthUrl' ) ;
865+ }
866+ const url = new URL ( '/authorize' , 'https://connect.tryfinch.com/authorize' ) ;
867+ url . search = this . stringifyQuery ( {
868+ client_id : this . clientID ,
869+ products,
870+ redirect_uri : redirectUri ,
871+ sandbox,
872+ } ) ;
873+ return url . toString ( ) ;
874+ }
875+
876+ /**
877+ * Returns a copy of the current Finch client with the given access token for
878+ * authentication.
879+ */
880+ withAccessToken ( accessToken : string ) : Finch {
881+ return new Finch ( { ...this . _options , accessToken } ) ;
882+ }
848883}
849884
850885Finch . AccessTokens = AccessTokens ;
You can’t perform that action at this time.
0 commit comments