UNPKG

@koex/passport-doreamon

Version:

koex passport-doreamon

62 lines 2.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DoreamonStrategy = void 0; const passport_oauth2_config_1 = require("@koex/passport-oauth2-config"); class DoreamonStrategy extends passport_oauth2_config_1.Strategy { constructor(_options, verify) { super({ ..._options, response_type: 'code', grant_type: 'authorization_code', authorize_url: 'https://login.zcorky.com/authorize', token_url: 'https://login.zcorky.com/token', user_profile_url: 'https://login.zcorky.com/user', scope: 'todo', state: 'todo', }, verify); this._options = _options; this.verify = verify; this.config = { callback: { code: { name: 'code', }, access_token: { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', Accept: 'application/json', }, // query: {}, // body: {}, }, user_profile: { // method: 'GET', // headers: {}, // query: {}, // body: {}, profile: { id: '{_id}', username: '{username}', nickname: '{nickname}', email: '{email}', avatar: '{avatar}', }, }, }, }; } async refreshToken(ctx, refreshTokenString) { const { token_url, client_id, client_secret, } = this.oauthStrategyOptions; const refreshTokenData = { client_id, client_secret, grant_type: 'refresh_token', refresh_token: refreshTokenString, }; const token = await this.getAccessToken(token_url, refreshTokenData); return token; } } exports.DoreamonStrategy = DoreamonStrategy; //# sourceMappingURL=strategy.js.map