@mondaycom/apps-sdk
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -50,2 +50,4 @@ "use strict"; | ||
var env_1 = require("../utils/env.js"); | ||
var logger_1 = require("../utils/logger.js"); | ||
var logger = new logger_1.Logger('SecureStorage', { mondayInternal: true }); | ||
var generateJwtSigningUrl = function (serviceAccountEmail) { return "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/".concat(serviceAccountEmail, ":signJwt"); }; | ||
@@ -93,2 +95,8 @@ var generateGcpIdentityToken = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
exports.getGcpIdentityToken = getGcpIdentityToken; | ||
var validateGcpResponse = function (response) { | ||
if (response.error) { | ||
logger.error(JSON.stringify(response.error)); | ||
throw new apps_sdk_error_1.InternalServerError('some thing went wrong when when communicating with secure storage'); | ||
} | ||
}; | ||
var getGcpConnectionData = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -133,2 +141,3 @@ var auth, projectId, serviceAccountEmail, accessToken, issueTimeInSeconds, expirationInSeconds, payload, jwtSigningUrl, response, responseJson, signedToken; | ||
responseJson = _a.sent(); | ||
validateGcpResponse(responseJson); | ||
signedToken = responseJson.signedJwt; | ||
@@ -135,0 +144,0 @@ return [2 /*return*/, { token: signedToken, projectId: projectId, serviceAccountEmail: serviceAccountEmail }]; |
{ | ||
"name": "@mondaycom/apps-sdk", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "monday apps SDK for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
@@ -58,3 +58,3 @@ "use strict"; | ||
var time_enum_1 = require("../utils/time-enum.js"); | ||
var logger = new logger_1.Logger('SecureStorage', { passThrough: false }); | ||
var logger = new logger_1.Logger('SecureStorage', { mondayInternal: true }); | ||
var MIN_TOKEN_EXPIRE_TTL_HOURS = 0.5; | ||
@@ -72,3 +72,3 @@ var secureStorageFetch = function (path, connectionData, options) { return __awaiter(void 0, void 0, void 0, function () { | ||
fetchObj = { | ||
headers: __assign(__assign({}, (token && { 'X-Vault-Token': token })), (identityToken && { 'Authorization': "Bearer ".concat(identityToken) })), | ||
headers: __assign(__assign({ 'Content-Type': 'application/json' }, (token && { 'X-Vault-Token': token })), (identityToken && { 'Authorization': "Bearer ".concat(identityToken) })), | ||
method: method, | ||
@@ -223,3 +223,3 @@ body: body ? JSON.stringify(body) : undefined | ||
_b.sent(); | ||
logger.info("[SecureStorage] Deleted data for key from secure storage\nkey: ".concat(key), { passThrough: true }); | ||
logger.info("[SecureStorage] Deleted data for key from secure storage\nkey: ".concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, true]; | ||
@@ -244,3 +244,3 @@ } | ||
result = _b.sent(); | ||
logger.info("[SecureStorage] Got data for key from secure storage\nkey: ".concat(key), { passThrough: true }); | ||
logger.info("[SecureStorage] Got data for key from secure storage\nkey: ".concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data]; | ||
@@ -253,3 +253,3 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, fullPath; | ||
var _a, fullPath, formalizedValue; | ||
return __generator(this, function (_b) { | ||
@@ -263,9 +263,10 @@ switch (_b.label) { | ||
fullPath = generateCrudPath(key, this.connectionData.id); | ||
formalizedValue = { value: value }; | ||
return [4 /*yield*/, secureStorageFetch(fullPath, this.connectionData, { | ||
method: 'PUT', | ||
body: { data: value } | ||
body: { data: formalizedValue } | ||
})]; | ||
case 2: | ||
_b.sent(); | ||
logger.info("[SecureStorage] Set data for key in secure storage\nkey: ".concat(key), { passThrough: true }); | ||
logger.info("[SecureStorage] Set data for key in secure storage\nkey: ".concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, true]; | ||
@@ -272,0 +273,0 @@ } |
@@ -56,3 +56,3 @@ "use strict"; | ||
var logger_1 = require("../utils/logger.js"); | ||
var logger = new logger_1.Logger('Storage', { passThrough: false }); | ||
var logger = new logger_1.Logger('Storage', { mondayInternal: true }); | ||
var LOGGER_TAG = 'Storage'; | ||
@@ -118,3 +118,3 @@ var getStorageUrl = function () { | ||
_a.sent(); | ||
logger.info("[".concat(LOGGER_TAG, "] Deleted data for key from storage\nkey: ").concat(key), { passThrough: true }); | ||
logger.info("[".concat(LOGGER_TAG, "] Deleted data for key from storage\nkey: ").concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, true]; | ||
@@ -134,3 +134,3 @@ } | ||
result = _a.sent(); | ||
logger.info("[".concat(LOGGER_TAG, "] Got data for key from storage\nkey: ").concat(key), { passThrough: true }); | ||
logger.info("[".concat(LOGGER_TAG, "] Got data for key from storage\nkey: ").concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, result]; | ||
@@ -157,3 +157,3 @@ } | ||
result = _a.sent(); | ||
logger.info("[".concat(LOGGER_TAG, "] Set data for key in storage\nkey: ").concat(key), { passThrough: true }); | ||
logger.info("[".concat(LOGGER_TAG, "] Set data for key in storage\nkey: ").concat(key), { mondayInternal: false }); | ||
version = result.version; | ||
@@ -160,0 +160,0 @@ return [2 /*return*/, { version: version }]; |
@@ -51,3 +51,3 @@ "use strict"; | ||
var DEFAULT_DB_NAME = 'storage'; | ||
var logger = new logger_1.Logger('LocalDb', { passThrough: true }); | ||
var logger = new logger_1.Logger('LocalDb', { mondayInternal: false }); | ||
var getDbPath = function (dbName) { return (0, node_path_1.join)(app_root_path_1["default"].toString(), "".concat(dbName, ".json")); }; | ||
@@ -54,0 +54,0 @@ var hasDiskWriteAccess = function () { |
@@ -17,3 +17,3 @@ "use strict"; | ||
var defaultOptions = { | ||
passThrough: false | ||
mondayInternal: true | ||
}; | ||
@@ -20,0 +20,0 @@ var Logger = /** @class */ (function () { |
@@ -44,2 +44,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import { getMondayCodeContext, validateEnvironment } from '../utils/env.js'; | ||
import { Logger } from '../utils/logger.js'; | ||
var logger = new Logger('SecureStorage', { mondayInternal: true }); | ||
var generateJwtSigningUrl = function (serviceAccountEmail) { return "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/".concat(serviceAccountEmail, ":signJwt"); }; | ||
@@ -86,2 +88,8 @@ var generateGcpIdentityToken = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
}); }; | ||
var validateGcpResponse = function (response) { | ||
if (response.error) { | ||
logger.error(JSON.stringify(response.error)); | ||
throw new InternalServerError('some thing went wrong when when communicating with secure storage'); | ||
} | ||
}; | ||
export var getGcpConnectionData = function () { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -126,2 +134,3 @@ var auth, projectId, serviceAccountEmail, accessToken, issueTimeInSeconds, expirationInSeconds, payload, jwtSigningUrl, response, responseJson, signedToken; | ||
responseJson = _a.sent(); | ||
validateGcpResponse(responseJson); | ||
signedToken = responseJson.signedJwt; | ||
@@ -128,0 +137,0 @@ return [2 /*return*/, { token: signedToken, projectId: projectId, serviceAccountEmail: serviceAccountEmail }]; |
{ | ||
"name": "@mondaycom/apps-sdk", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "monday apps SDK for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
@@ -55,3 +55,3 @@ var __assign = (this && this.__assign) || function () { | ||
import { TIME_IN_MILLISECOND } from '../utils/time-enum.js'; | ||
var logger = new Logger('SecureStorage', { passThrough: false }); | ||
var logger = new Logger('SecureStorage', { mondayInternal: true }); | ||
var MIN_TOKEN_EXPIRE_TTL_HOURS = 0.5; | ||
@@ -69,3 +69,3 @@ var secureStorageFetch = function (path, connectionData, options) { return __awaiter(void 0, void 0, void 0, function () { | ||
fetchObj = { | ||
headers: __assign(__assign({}, (token && { 'X-Vault-Token': token })), (identityToken && { 'Authorization': "Bearer ".concat(identityToken) })), | ||
headers: __assign(__assign({ 'Content-Type': 'application/json' }, (token && { 'X-Vault-Token': token })), (identityToken && { 'Authorization': "Bearer ".concat(identityToken) })), | ||
method: method, | ||
@@ -220,3 +220,3 @@ body: body ? JSON.stringify(body) : undefined | ||
_b.sent(); | ||
logger.info("[SecureStorage] Deleted data for key from secure storage\nkey: ".concat(key), { passThrough: true }); | ||
logger.info("[SecureStorage] Deleted data for key from secure storage\nkey: ".concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, true]; | ||
@@ -241,3 +241,3 @@ } | ||
result = _b.sent(); | ||
logger.info("[SecureStorage] Got data for key from secure storage\nkey: ".concat(key), { passThrough: true }); | ||
logger.info("[SecureStorage] Got data for key from secure storage\nkey: ".concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data]; | ||
@@ -250,3 +250,3 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, fullPath; | ||
var _a, fullPath, formalizedValue; | ||
return __generator(this, function (_b) { | ||
@@ -260,9 +260,10 @@ switch (_b.label) { | ||
fullPath = generateCrudPath(key, this.connectionData.id); | ||
formalizedValue = { value: value }; | ||
return [4 /*yield*/, secureStorageFetch(fullPath, this.connectionData, { | ||
method: 'PUT', | ||
body: { data: value } | ||
body: { data: formalizedValue } | ||
})]; | ||
case 2: | ||
_b.sent(); | ||
logger.info("[SecureStorage] Set data for key in secure storage\nkey: ".concat(key), { passThrough: true }); | ||
logger.info("[SecureStorage] Set data for key in secure storage\nkey: ".concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, true]; | ||
@@ -269,0 +270,0 @@ } |
@@ -53,3 +53,3 @@ var __assign = (this && this.__assign) || function () { | ||
import { Logger } from '../utils/logger.js'; | ||
var logger = new Logger('Storage', { passThrough: false }); | ||
var logger = new Logger('Storage', { mondayInternal: true }); | ||
var LOGGER_TAG = 'Storage'; | ||
@@ -115,3 +115,3 @@ var getStorageUrl = function () { | ||
_a.sent(); | ||
logger.info("[".concat(LOGGER_TAG, "] Deleted data for key from storage\nkey: ").concat(key), { passThrough: true }); | ||
logger.info("[".concat(LOGGER_TAG, "] Deleted data for key from storage\nkey: ").concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, true]; | ||
@@ -131,3 +131,3 @@ } | ||
result = _a.sent(); | ||
logger.info("[".concat(LOGGER_TAG, "] Got data for key from storage\nkey: ").concat(key), { passThrough: true }); | ||
logger.info("[".concat(LOGGER_TAG, "] Got data for key from storage\nkey: ").concat(key), { mondayInternal: false }); | ||
return [2 /*return*/, result]; | ||
@@ -154,3 +154,3 @@ } | ||
result = _a.sent(); | ||
logger.info("[".concat(LOGGER_TAG, "] Set data for key in storage\nkey: ").concat(key), { passThrough: true }); | ||
logger.info("[".concat(LOGGER_TAG, "] Set data for key in storage\nkey: ").concat(key), { mondayInternal: false }); | ||
version = result.version; | ||
@@ -157,0 +157,0 @@ return [2 /*return*/, { version: version }]; |
@@ -45,3 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
var DEFAULT_DB_NAME = 'storage'; | ||
var logger = new Logger('LocalDb', { passThrough: true }); | ||
var logger = new Logger('LocalDb', { mondayInternal: false }); | ||
var getDbPath = function (dbName) { return join(appRoot.toString(), "".concat(dbName, ".json")); }; | ||
@@ -48,0 +48,0 @@ var hasDiskWriteAccess = function () { |
@@ -14,3 +14,3 @@ var __assign = (this && this.__assign) || function () { | ||
var defaultOptions = { | ||
passThrough: false | ||
mondayInternal: true | ||
}; | ||
@@ -17,0 +17,0 @@ var Logger = /** @class */ (function () { |
import { Token } from './secure-storage'; | ||
export type SignJwtResponse = { | ||
signedJwt: Token; | ||
error?: { | ||
code: number; | ||
message: string; | ||
status: string; | ||
}; | ||
}; | ||
@@ -5,0 +10,0 @@ export type GcpConnectionData = { |
export type Options = { | ||
/** determines if the log should get streamed to a monday-code developer */ | ||
passThrough?: boolean; | ||
mondayInternal?: boolean; | ||
}; | ||
@@ -5,0 +5,0 @@ export declare enum LogMethods { |
{ | ||
"name": "@mondaycom/apps-sdk", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "monday apps SDK for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
186210
2572