download
raw
2.11 kB
import { createS256CodeChallenge } from "../oauth2.js";
import { createOAuth2Request, sendTokenRequest } from "../request.js";
const authorizationEndpoint = "https://access.line.me/oauth2/v2.1/authorize";
const tokenEndpoint = "https://api.line.me/oauth2/v2.1/token";
export class Line {
clientId;
clientSecret;
redirectURI;
constructor(clientId, clientSecret, redirectURI) {
this.clientId = clientId;
this.clientSecret = clientSecret;
this.redirectURI = redirectURI;
}
createAuthorizationURL(state, codeVerifier, scopes) {
const url = new URL(authorizationEndpoint);
url.searchParams.set("response_type", "code");
url.searchParams.set("client_id", this.clientId);
url.searchParams.set("state", state);
url.searchParams.set("scope", scopes.join(" "));
url.searchParams.set("redirect_uri", this.redirectURI);
const codeChallenge = createS256CodeChallenge(codeVerifier);
url.searchParams.set("code_challenge_method", "S256");
url.searchParams.set("code_challenge", codeChallenge);
return url;
}
async validateAuthorizationCode(code, codeVerifier) {
const body = new URLSearchParams();
body.set("grant_type", "authorization_code");
body.set("code", code);
body.set("code_verifier", codeVerifier);
body.set("redirect_uri", this.redirectURI);
body.set("client_id", this.clientId);
body.set("client_secret", this.clientSecret);
const request = createOAuth2Request(tokenEndpoint, body);
const tokens = await sendTokenRequest(request);
return tokens;
}
async refreshAccessToken(refreshToken) {
const body = new URLSearchParams();
body.set("grant_type", "refresh_token");
body.set("refresh_token", refreshToken);
body.set("client_id", this.clientId);
body.set("client_secret", this.clientSecret);
const request = createOAuth2Request(tokenEndpoint, body);
const tokens = await sendTokenRequest(request);
return tokens;
}
}

Xet Storage Details

Size:
2.11 kB
·
Xet hash:
3b8f4485020a83010e492344c4d794389766125ae2ab9b69d948e01bafb64ca5

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