@crowdin/crowdin-apps-functions
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -0,1 +1,5 @@ | ||
export interface AppToken { | ||
accessToken: string; | ||
expiresIn: number; | ||
} | ||
export interface Token { | ||
@@ -21,2 +25,3 @@ accessToken: string; | ||
appId: string; | ||
appSecret: string; | ||
clientId: string; | ||
@@ -23,0 +28,0 @@ userId: number; |
@@ -1,6 +0,17 @@ | ||
import { JwtPayload, Token } from './models'; | ||
import { AppToken, JwtPayload, Token } from './models'; | ||
/** | ||
* | ||
* @param appId Crowdin app identifier | ||
* @param appSecret Crowdin app secret received from install event | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param domain Crowdin organization domain | ||
* @param userId The user who installed the application | ||
* @returns token object which is needed to establish communication between app and Crowdin API | ||
*/ | ||
export declare function fetchAppToken(appId: string, appSecret: string, clientId: string, clientSecret: string, domain: string, userId: number): Promise<AppToken>; | ||
/** | ||
* | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param code code used for authorization of your Crowdin app (returned in install event payload) | ||
@@ -7,0 +18,0 @@ * @returns token object which is needed to establish communication between app and Crowdin API |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateJwtToken = exports.getProjectId = exports.constructCrowdinIdFromJwtPayload = exports.refreshOAuthToken = exports.generateOAuthToken = void 0; | ||
exports.validateJwtToken = exports.getProjectId = exports.constructCrowdinIdFromJwtPayload = exports.refreshOAuthToken = exports.generateOAuthToken = exports.fetchAppToken = void 0; | ||
const axios_1 = require("axios"); | ||
@@ -19,4 +19,32 @@ const jwt = require("jsonwebtoken"); | ||
* | ||
* @param appId Crowdin app identifier | ||
* @param appSecret Crowdin app secret received from install event | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param domain Crowdin organization domain | ||
* @param userId The user who installed the application | ||
* @returns token object which is needed to establish communication between app and Crowdin API | ||
*/ | ||
function fetchAppToken(appId, appSecret, clientId, clientSecret, domain, userId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const token = yield axios_1.default.post(crowdinAuthUrl, { | ||
grant_type: 'crowdin_app', | ||
client_id: clientId, | ||
client_secret: clientSecret, | ||
app_id: appId, | ||
app_secret: appSecret, | ||
domain: domain, | ||
userId: userId, | ||
}); | ||
return { | ||
accessToken: token.data.access_token, | ||
expiresIn: +token.data.expires_in, | ||
}; | ||
}); | ||
} | ||
exports.fetchAppToken = fetchAppToken; | ||
/** | ||
* | ||
* @param clientId OAuth client id of the app | ||
* @param clientSecret OAuth client secret of the app | ||
* @param code code used for authorization of your Crowdin app (returned in install event payload) | ||
@@ -23,0 +51,0 @@ * @returns token object which is needed to establish communication between app and Crowdin API |
{ | ||
"name": "@crowdin/crowdin-apps-functions", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Utility library to easily and quickly develop Crowdin App", | ||
@@ -5,0 +5,0 @@ "main": "out/index.js", |
@@ -84,2 +84,3 @@ [<p align='center'><img src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' data-canonical-src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' width='200' height='200' align='center'/></p>](https://crowdin.com) | ||
|------------------------------------|-----------------------------------------------------------------| | ||
| `fetchAppToken` | fetch API token for communication with Crowdin API | | ||
| `generateOAuthToken` | generates OAuth token for communication with Crowdin API | | ||
@@ -86,0 +87,0 @@ | `refreshOAuthToken` | refresh OAuth token in case if it was expired | |
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
42584
536
118