-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7df5b22
commit cbec7c6
Showing
5 changed files
with
244 additions
and
30 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import API, { INormalizeError } from "./types/api" | ||
|
||
declare namespace OAuthTokenClient { | ||
|
||
interface OAuthTokenBaseRequestBody { | ||
/** | ||
* Unique client identifier. | ||
*/ | ||
client_id: string; | ||
/** | ||
* Client secret string. | ||
*/ | ||
client_secret: string; | ||
} | ||
|
||
interface InitiateAuthorisationRequest extends Pick<OAuthTokenBaseRequestBody, 'client_id'>{ | ||
/** | ||
* Specifies that the application is requesting an | ||
* authorisation code grant. possible value is `code`. | ||
*/ | ||
response_type: string; | ||
/** | ||
* Callback URL used by Razorpay to redirect after the user approves or denies the authorisation request. | ||
* The client should whitelist the `redirect_uri`. | ||
*/ | ||
redirect_uri: string; | ||
/** | ||
* Defines what access your application is requesting from the user. You can request multiple scopes | ||
* by separating with a space. | ||
* possible values is `read_only` or `read_write`. | ||
*/ | ||
scope: string; | ||
/** | ||
* Check [doc](https://razorpay.com/docs/partners/technology-partners/onboard-businesses/integrate-oauth/integration-steps/#query-parameters) for required params | ||
*/ | ||
state: string; | ||
} | ||
|
||
interface OAuthTokenTokenRequest extends OAuthTokenBaseRequestBody { | ||
/** | ||
* Defines the grant type for the request. possible value is `authorization_code` | ||
*/ | ||
grant_type: string; | ||
/** | ||
* Specifies the same `redirect_uri` used in the authorisation request. | ||
*/ | ||
redirect_uri?: string; | ||
/** | ||
* Decoded authorisation code received in the last step. | ||
*/ | ||
code?: string; | ||
/** | ||
* The type of mode. possible values is `test` or `live`. | ||
*/ | ||
mode?: string; | ||
/** | ||
* Used to refresh the access token when it expires. | ||
*/ | ||
refresh_token?: string; | ||
/** | ||
* The type of token for the request. possible value is `access_token` or `access_token`. | ||
*/ | ||
token_type_hint?: string; | ||
/** | ||
* The token whose access should be revoked. | ||
*/ | ||
token?: string; | ||
} | ||
|
||
interface OAuthTokenTokenResponse { | ||
/** | ||
* A public key is used only for public routes such as Checkout or Payments. | ||
*/ | ||
public_token: string; | ||
/** | ||
* Defines the type of access token. possible value is `Bearer` | ||
*/ | ||
token_type: string; | ||
/** | ||
* Integer representing the TTL of the access token in seconds. | ||
*/ | ||
expires_in: number; | ||
/** | ||
* A private key used to access sub-merchant resources on Razorpay. | ||
* used for server-to-server calls only. | ||
*/ | ||
access_token: string; | ||
/** | ||
* Used to refresh the access token when it expires. | ||
*/ | ||
refresh_token:string; | ||
/** | ||
* Identifies the sub-merchant ID who granted the authorisation. | ||
*/ | ||
razorpay_account_id: string; | ||
} | ||
} | ||
|
||
declare class OAuthTokenClient extends API{ | ||
constructor() | ||
|
||
getEntityUrl(): string; | ||
/** | ||
* Initiate Authorisation Using URL | ||
* @param param - Check [doc](https://razorpay.com/docs/partners/technology-partners/onboard-businesses/integrate-oauth/integration-steps/#query-parameters) for required params | ||
*/ | ||
generateAuthUrl(param: OAuthTokenClient.InitiateAuthorisationRequest): string; | ||
|
||
/** | ||
* Get access token | ||
* @param param - Check [doc](https://razorpay.com/docs/partners/technology-partners/onboard-businesses/integrate-oauth/integration-steps/#request-parameters) for required params | ||
*/ | ||
getAccessToken(param: OAuthTokenClient.OAuthTokenTokenRequest): Promise<OAuthTokenClient.OAuthTokenTokenResponse>; | ||
getAccessToken(param: OAuthTokenClient.OAuthTokenTokenRequest, callback: (err: INormalizeError | null, data: OAuthTokenClient.OAuthTokenTokenResponse) => void): void | ||
|
||
/** | ||
* Get refresh token | ||
* @param param - Check [doc](https://razorpay.com/docs/partners/technology-partners/onboard-businesses/integrate-oauth/integration-steps/#refresh-token-api) for required params | ||
*/ | ||
refreshToken(param: OAuthTokenClient.OAuthTokenTokenRequest): Promise<OAuthTokenClient.OAuthTokenTokenResponse>; | ||
refreshToken(param: OAuthTokenClient.OAuthTokenTokenRequest, callback: (err: INormalizeError | null, data: OAuthTokenClient.OAuthTokenTokenResponse) => void): void | ||
|
||
/** | ||
* Revoke token | ||
* @param param - Check [doc](https://razorpay.com/docs/partners/technology-partners/onboard-businesses/integrate-oauth/integration-steps/#revoke-token-api) for required params | ||
*/ | ||
revokeToken(param: OAuthTokenClient.OAuthTokenTokenRequest): Promise<{ message: string;}>; | ||
revokeToken(param: OAuthTokenClient.OAuthTokenTokenRequest, callback: (err: INormalizeError | null, data: { message: string;}) => void): void | ||
} | ||
|
||
export = OAuthTokenClient |
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
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