download
raw
1.13 kB
import { OAuth2Client, CodeChallengeMethod } from "../client.js";
const authorizationEndpoint = "https://polar.sh/oauth2/authorize";
const tokenEndpoint = "https://api.polar.sh/v1/oauth2/token";
const tokenRevocationEndpoint = "https://api.polar.sh/v1/oauth2/revoke";
export class Polar {
client;
constructor(clientId, clientSecret, redirectURI) {
this.client = new OAuth2Client(clientId, clientSecret, redirectURI);
}
createAuthorizationURL(state, codeVerifier, scopes) {
const url = this.client.createAuthorizationURLWithPKCE(authorizationEndpoint, state, CodeChallengeMethod.S256, codeVerifier, scopes);
return url;
}
async validateAuthorizationCode(code, codeVerifier) {
const tokens = await this.client.validateAuthorizationCode(tokenEndpoint, code, codeVerifier);
return tokens;
}
async refreshAccessToken(refreshToken) {
const tokens = await this.client.refreshAccessToken(tokenEndpoint, refreshToken, []);
return tokens;
}
async revokeToken(token) {
await this.client.revokeToken(tokenRevocationEndpoint, token);
}
}

Xet Storage Details

Size:
1.13 kB
·
Xet hash:
974108366f897ced2df773a02c495387f4d4a1392a61347e96606e541b34ddad

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.