awesome-wechat-sdk
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -85,4 +85,5 @@ import { AxiosRequestConfig } from 'axios'; | ||
getAuthUser(openid: string, lang?: 'zh_CN' | 'zh_TW' | 'en'): Promise<UserInfo>; | ||
getOpenidByCode(code: string): Promise<string>; | ||
getAuthUserByCode(code: string, lang?: 'zh_CN' | 'zh_TW' | 'en'): Promise<UserInfo>; | ||
private verifyToken(openid, accessToken); | ||
} |
@@ -92,3 +92,3 @@ "use strict"; | ||
}; | ||
this.axiosInstance = axios_1.default.create({ responseType: 'json' }); | ||
this.axiosInstance = axios_1.default.create(); | ||
this.appid = appid; | ||
@@ -125,3 +125,5 @@ this.appsecret = appsecret; | ||
setOpts(opts) { | ||
this.axiosInstance.defaults = opts; | ||
Object.keys(opts).forEach((key) => { | ||
this.axiosInstance.defaults[key] = opts[key]; | ||
}); | ||
} | ||
@@ -245,2 +247,7 @@ getAccessToken() { | ||
} | ||
getOpenidByCode(code) { | ||
return this.getAuthAccessToken(code).then((token) => { | ||
return token.openid; | ||
}); | ||
} | ||
getAuthUserByCode(code, lang = 'zh_CN') { | ||
@@ -247,0 +254,0 @@ return this.getAuthAccessToken(code).then((token) => { |
{ | ||
"name": "awesome-wechat-sdk", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "an awesome sdk for wechat oauth and api", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -165,6 +165,8 @@ import axios, {AxiosRequestConfig, AxiosInstance, AxiosPromise} from 'axios'; | ||
private axiosInstance: AxiosInstance = axios.create({responseType: 'json'}); | ||
private axiosInstance: AxiosInstance = axios.create(); | ||
setOpts(opts: AxiosRequestConfig) { | ||
this.axiosInstance.defaults = opts; | ||
Object.keys(opts).forEach((key) => { | ||
this.axiosInstance.defaults[key] = opts[key]; | ||
}); | ||
} | ||
@@ -297,2 +299,8 @@ | ||
getOpenidByCode(code: string): Promise<string> { | ||
return this.getAuthAccessToken(code).then((token) => { | ||
return token.openid; | ||
}); | ||
} | ||
getAuthUserByCode(code: string, lang: 'zh_CN' | 'zh_TW' | 'en' = 'zh_CN'): Promise<UserInfo> { | ||
@@ -299,0 +307,0 @@ return this.getAuthAccessToken(code).then((token) => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44672
649