Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@abip/sp-common

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abip/sp-common - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

dist/domains/core/survey-evasys-template-question/api.d.ts

2

dist/domains/auth/permission/constants.d.ts

@@ -9,2 +9,3 @@ import { PermissionID as AuthPermissionID } from '@authelion/common';

SURVEY_MANAGE = "survey_manage",
SURVEY_APPLICATION_MANAGE = "survey_application_manage",
SURVEY_EVENT_MANAGE = "survey_event_manage",

@@ -51,2 +52,3 @@ SURVEY_EVENT_RESPONSE_MANAGE = "survey_event_response_manage"

SURVEY_MANAGE: LocalPermissionID.SURVEY_MANAGE;
SURVEY_APPLICATION_MANAGE: LocalPermissionID.SURVEY_APPLICATION_MANAGE;
SURVEY_EVENT_MANAGE: LocalPermissionID.SURVEY_EVENT_MANAGE;

@@ -53,0 +55,0 @@ SURVEY_EVENT_RESPONSE_MANAGE: LocalPermissionID.SURVEY_EVENT_RESPONSE_MANAGE;

@@ -19,2 +19,3 @@ "use strict";

LocalPermissionID["SURVEY_MANAGE"] = "survey_manage";
LocalPermissionID["SURVEY_APPLICATION_MANAGE"] = "survey_application_manage";
LocalPermissionID["SURVEY_EVENT_MANAGE"] = "survey_event_manage";

@@ -21,0 +22,0 @@ LocalPermissionID["SURVEY_EVENT_RESPONSE_MANAGE"] = "survey_event_response_manage";

4

dist/domains/core/course/entity.d.ts

@@ -1,8 +0,6 @@

import { SurveyTemplate } from '../survey-template';
export interface Course {
id: string;
pseudo_id: string | null;
evasys_user_id: number | null;
name: string;
survey_template_id: SurveyTemplate['id'] | null;
survey_template: SurveyTemplate | null;
created_at: Date;

@@ -9,0 +7,0 @@ updated_at: Date;

export * from './course';
export * from './survey-evasys-template';
export * from './survey-evasys-template-question';
export * from './ip-address';

@@ -8,11 +10,9 @@ export * from './lecturer';

export * from './survey-answer';
export * from './survey-course-template';
export * from './survey-event';
export * from './survey-event-lecturer';
export * from './survey-event-response';
export * from './survey-event-question';
export * from './survey-group';
export * from './survey-question';
export * from './survey-question-answer';
export * from './survey-template';
export * from './survey-template-group';
//# sourceMappingURL=index.d.ts.map

@@ -24,2 +24,4 @@ "use strict";

__exportStar(require("./course"), exports);
__exportStar(require("./survey-evasys-template"), exports);
__exportStar(require("./survey-evasys-template-question"), exports);
__exportStar(require("./ip-address"), exports);

@@ -31,11 +33,9 @@ __exportStar(require("./lecturer"), exports);

__exportStar(require("./survey-answer"), exports);
__exportStar(require("./survey-course-template"), exports);
__exportStar(require("./survey-event"), exports);
__exportStar(require("./survey-event-lecturer"), exports);
__exportStar(require("./survey-event-response"), exports);
__exportStar(require("./survey-event-question"), exports);
__exportStar(require("./survey-group"), exports);
__exportStar(require("./survey-question"), exports);
__exportStar(require("./survey-question-answer"), exports);
__exportStar(require("./survey-template"), exports);
__exportStar(require("./survey-template-group"), exports);
//# sourceMappingURL=index.js.map

@@ -5,2 +5,3 @@ import { BuildInput } from '@trapi/query';

import { CollectionResourceResponse, SingleResourceResponse } from '../../type';
import { SurveyEventCommand } from './constants';
export declare class SurveyEventAPI {

@@ -18,3 +19,4 @@ protected client: ClientDriverInstance;

update(id: SurveyEvent['id'], data: Partial<SurveyEvent>): Promise<SingleResourceResponse<SurveyEvent>>;
runCommand(id: SurveyEvent['id'], command: `${SurveyEventCommand}` | SurveyEventCommand, data?: Record<string, any>): Promise<SingleResourceResponse<SurveyEvent>>;
}
//# sourceMappingURL=api.d.ts.map

@@ -65,4 +65,12 @@ "use strict";

}
runCommand(id, command, data = {}) {
return __awaiter(this, void 0, void 0, function* () {
const actionData = Object.assign({ command }, data);
const { data: response } = yield this.client
.post(`survey-events/${id}/command`, actionData);
return response;
});
}
}
exports.SurveyEventAPI = SurveyEventAPI;
//# sourceMappingURL=api.js.map

@@ -0,1 +1,5 @@

export declare enum SurveyEventCommand {
START = "start",
STOP = "stop"
}
export declare enum SurveyEventExecutionStatus {

@@ -7,2 +11,3 @@ STARTING = "starting",

STOPPED = "stopped",
FINISHED = "finished",
FAILED = "failed"

@@ -12,5 +17,7 @@ }

BASE = 0,
EXTRA = 1,
SECURITY = 2,
FINISH = 3
META = 1,
LOCATION = 2,
SPECIAL = 3,
SECURITY = 4,
FINISH = 5
}

@@ -17,0 +24,0 @@ export declare enum SurveyEventAccess {

@@ -9,3 +9,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.SurveyEventAccessRestriction = exports.SurveyEventAccess = exports.SurveyEventConfigurationStep = exports.SurveyEventExecutionStatus = void 0;
exports.SurveyEventAccessRestriction = exports.SurveyEventAccess = exports.SurveyEventConfigurationStep = exports.SurveyEventExecutionStatus = exports.SurveyEventCommand = void 0;
var SurveyEventCommand;
(function (SurveyEventCommand) {
SurveyEventCommand["START"] = "start";
SurveyEventCommand["STOP"] = "stop";
})(SurveyEventCommand = exports.SurveyEventCommand || (exports.SurveyEventCommand = {}));
var SurveyEventExecutionStatus;

@@ -18,2 +23,3 @@ (function (SurveyEventExecutionStatus) {

SurveyEventExecutionStatus["STOPPED"] = "stopped";
SurveyEventExecutionStatus["FINISHED"] = "finished";
SurveyEventExecutionStatus["FAILED"] = "failed";

@@ -25,7 +31,11 @@ })(SurveyEventExecutionStatus = exports.SurveyEventExecutionStatus || (exports.SurveyEventExecutionStatus = {}));

// name, course, template
SurveyEventConfigurationStep[SurveyEventConfigurationStep["EXTRA"] = 1] = "EXTRA";
SurveyEventConfigurationStep[SurveyEventConfigurationStep["META"] = 1] = "META";
// location
SurveyEventConfigurationStep[SurveyEventConfigurationStep["LOCATION"] = 2] = "LOCATION";
// questions
SurveyEventConfigurationStep[SurveyEventConfigurationStep["SPECIAL"] = 3] = "SPECIAL";
// start, end, lecturer
SurveyEventConfigurationStep[SurveyEventConfigurationStep["SECURITY"] = 2] = "SECURITY";
// access, token, location
SurveyEventConfigurationStep[SurveyEventConfigurationStep["FINISH"] = 3] = "FINISH";
SurveyEventConfigurationStep[SurveyEventConfigurationStep["SECURITY"] = 4] = "SECURITY";
// access, token,
SurveyEventConfigurationStep[SurveyEventConfigurationStep["FINISH"] = 5] = "FINISH";
})(SurveyEventConfigurationStep = exports.SurveyEventConfigurationStep || (exports.SurveyEventConfigurationStep = {}));

@@ -32,0 +42,0 @@ var SurveyEventAccess;

import { Realm } from '@authelion/common';
import { Course, Location, LocationRoom, SurveyEventAccessRestriction, SurveyEventConfigurationStep } from '../index';
import { Course, Location, LocationRoom, SurveyApplication, SurveyEvasysTemplate, SurveyEventAccessRestriction, SurveyEventConfigurationStep } from '../index';
import { SurveyEventAccess, SurveyEventExecutionStatus } from './constants';
import { SurveyTemplate } from '../survey-template';
export interface SurveyEvent {
id: string;
name: string;
application: SurveyApplication;
access: SurveyEventAccess;

@@ -16,4 +16,4 @@ access_restriction: SurveyEventAccessRestriction;

external_id: string | null;
template_id: SurveyTemplate['id'] | null;
template: SurveyTemplate | null;
evasys_template_id: SurveyEvasysTemplate['id'] | null;
evasys_template: SurveyEvasysTemplate | null;
course_id: Course['id'] | null;

@@ -20,0 +20,0 @@ course: Course | null;

import { SurveyGroup } from '../survey-group';
import { SurveyQuestionTarget } from './constants';
export interface SurveyQuestion {
id: string;
parent_id: string | null;
target: SurveyQuestionTarget | null;
special: boolean;
order: number | null;
mandatory: boolean;
type: string;
name: string | null;
content: string | null;
group_id: SurveyGroup['id'];
group: SurveyGroup;
group_id: SurveyGroup['id'] | null;
group: SurveyGroup | null;
created_at: Date;

@@ -15,0 +13,0 @@ updated_at: Date;

@@ -1,3 +0,3 @@

export * from './constants';
export * from './api';
export * from './entity';
//# sourceMappingURL=index.d.ts.map

@@ -23,4 +23,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./constants"), exports);
__exportStar(require("./api"), exports);
__exportStar(require("./entity"), exports);
//# sourceMappingURL=index.js.map
import { HTTPClient } from '../http';
export declare function useDomainAPI(client: HTTPClient, name: string): import("./core").SurveyTemplateAPI | import("./core").CourseAPI | import("./core").LocationAPI | import("./core").LocationRoomAPI | import("./core").IpAddressAPI | import("./core").LecturerAPI | import("./core").SurveyCourseTemplateAPI | import("./core").SurveyEventAPI | import("./core").SurveyEventLecturerAPI;
export declare function useDomainAPI(client: HTTPClient, name: string): import("./core").CourseAPI | import("./core").SurveyEvasysTemplateAPI | import("./core").SurveyEvasysTemplateQuestionAPI | import("./core").LocationAPI | import("./core").LocationRoomAPI | import("./core").IpAddressAPI | import("./core").LecturerAPI | import("./core").SurveyEventAPI | import("./core").SurveyEventLecturerAPI | import("./core").SurveyEventQuestionAPI;
//# sourceMappingURL=utils.d.ts.map

@@ -22,4 +22,6 @@ "use strict";

return client.locationRoom;
case 'surveyCourseTemplate':
return client.surveyCourseTemplate;
case 'surveyEvasysTemplate':
return client.surveyEvasysTemplate;
case 'surveyEvasysTemplateQuestion':
return client.surveyEvasysTemplateQuestion;
case 'surveyEvent':

@@ -29,4 +31,4 @@ return client.surveyEvent;

return client.surveyEventLecturer;
case 'surveyTemplate':
return client.surveyTemplate;
case 'surveyEventQuestion':
return client.surveyEventQuestion;
}

@@ -33,0 +35,0 @@ return undefined;

import { Client, Config } from '@trapi/client';
import { CourseAPI, IpAddressAPI, LecturerAPI, LocationAPI, LocationRoomAPI, SurveyCourseTemplateAPI, SurveyEventAPI, SurveyEventLecturerAPI, SurveyTemplateAPI } from '../../domains';
import { CourseAPI, IpAddressAPI, LecturerAPI, LocationAPI, LocationRoomAPI, SurveyEvasysTemplateAPI, SurveyEvasysTemplateQuestionAPI, SurveyEventAPI, SurveyEventLecturerAPI, SurveyEventQuestionAPI, SurveyQuestionAPI } from '../../domains';
export declare class HTTPClient extends Client {

@@ -9,8 +9,10 @@ readonly course: CourseAPI;

readonly locationRoom: LocationRoomAPI;
readonly surveyCourseTemplate: SurveyCourseTemplateAPI;
readonly surveyEvasysTemplate: SurveyEvasysTemplateAPI;
readonly surveyEvasysTemplateQuestion: SurveyEvasysTemplateQuestionAPI;
readonly surveyEvent: SurveyEventAPI;
readonly surveyEventLecturer: SurveyEventLecturerAPI;
readonly surveyTemplate: SurveyTemplateAPI;
readonly surveyEventQuestion: SurveyEventQuestionAPI;
readonly surveyQuestion: SurveyQuestionAPI;
constructor(config: Config);
}
//# sourceMappingURL=module.d.ts.map

@@ -15,2 +15,4 @@ "use strict";

super(config);
this.surveyEvasysTemplate = new domains_1.SurveyEvasysTemplateAPI(this.driver);
this.surveyEvasysTemplateQuestion = new domains_1.SurveyEvasysTemplateQuestionAPI(this.driver);
this.course = new domains_1.CourseAPI(this.driver);

@@ -21,6 +23,6 @@ this.ipAddress = new domains_1.IpAddressAPI(this.driver);

this.locationRoom = new domains_1.LocationRoomAPI(this.driver);
this.surveyCourseTemplate = new domains_1.SurveyCourseTemplateAPI(this.driver);
this.surveyEvent = new domains_1.SurveyEventAPI(this.driver);
this.surveyEventLecturer = new domains_1.SurveyEventLecturerAPI(this.driver);
this.surveyTemplate = new domains_1.SurveyTemplateAPI(this.driver);
this.surveyEventQuestion = new domains_1.SurveyEventQuestionAPI(this.driver);
this.surveyQuestion = new domains_1.SurveyQuestionAPI(this.driver);
}

@@ -27,0 +29,0 @@ }

export * from './client';
export * from './error';
export * from './interceptors';
export * from './vault-client';
//# sourceMappingURL=index.d.ts.map

@@ -26,3 +26,2 @@ "use strict";

__exportStar(require("./interceptors"), exports);
__exportStar(require("./vault-client"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,7 @@

export declare function refreshAuthRobotTokenOnResponseError(err?: any): Promise<import("@trapi/client").ClientResponse<unknown>>;
import { Robot } from '@authelion/common';
import { HTTPClient } from '../../client';
export declare function createRefreshRobotTokenOnResponseErrorHandler(context: {
httpClient: HTTPClient;
load: () => Promise<Pick<Robot, 'id' | 'secret'>>;
}): (err?: any) => Promise<import("@trapi/client").ClientResponse<unknown>>;
//# sourceMappingURL=auth-robot-token.d.ts.map

@@ -9,3 +9,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.refreshAuthRobotTokenOnResponseError = void 0;
exports.createRefreshRobotTokenOnResponseErrorHandler = void 0;
/*

@@ -17,5 +17,3 @@ * Copyright (c) 2022.

*/
const client_1 = require("@trapi/client");
const common_1 = require("@authelion/common");
const domains_1 = require("../../../domains");
let lastChecked;

@@ -25,42 +23,43 @@ function canVerifyCredentials() {

}
function refreshAuthRobotTokenOnResponseError(err) {
var _a, _b;
const { config } = err;
if (err.response && (err.response.status === 401 || // Unauthorized
err.response.status === 403 || // Forbidden
((_a = err.response.data) === null || _a === void 0 ? void 0 : _a.code) === common_1.ErrorCode.CREDENTIALS_INVALID ||
((_b = err.response.data) === null || _b === void 0 ? void 0 : _b.code) === common_1.ErrorCode.TOKEN_EXPIRED)) {
if (canVerifyCredentials()) {
lastChecked = Date.now();
return (0, client_1.useClient)('vault').keyValue
.find(domains_1.ROBOT_SECRET_ENGINE_KEY, domains_1.ServiceID.SYSTEM)
.then((response) => {
const tokenApi = new common_1.TokenAPI((0, client_1.useClient)().driver);
return tokenApi.create({
id: response.data.id,
secret: response.data.secret,
grant_type: common_1.OAuth2TokenGrant.ROBOT_CREDENTIALS,
})
.then((token) => {
(0, client_1.useClient)()
.setAuthorizationHeader({
type: 'Bearer',
token: token.access_token,
function createRefreshRobotTokenOnResponseErrorHandler(context) {
return (err) => {
var _a, _b;
const { config } = err;
if (err.response && (err.response.status === 401 || // Unauthorized
err.response.status === 403 || // Forbidden
((_a = err.response.data) === null || _a === void 0 ? void 0 : _a.code) === common_1.ErrorCode.CREDENTIALS_INVALID ||
((_b = err.response.data) === null || _b === void 0 ? void 0 : _b.code) === common_1.ErrorCode.TOKEN_EXPIRED)) {
if (canVerifyCredentials()) {
lastChecked = Date.now();
return context.load()
.then((response) => {
const tokenApi = new common_1.TokenAPI(context.httpClient.driver);
return tokenApi.create({
id: response.id,
secret: response.secret,
grant_type: common_1.OAuth2TokenGrant.ROBOT_CREDENTIALS,
})
.then((token) => {
context.httpClient
.setAuthorizationHeader({
type: 'Bearer',
token: token.access_token,
});
return context.httpClient.request(config);
})
.catch((e) => {
context.httpClient.unsetAuthorizationHeader();
return Promise.reject(e);
});
return (0, client_1.useClient)().request(config);
})
.catch((e) => {
(0, client_1.useClient)().unsetAuthorizationHeader();
context.httpClient.unsetAuthorizationHeader();
return Promise.reject(e);
});
})
.catch((e) => {
(0, client_1.useClient)().unsetAuthorizationHeader();
return Promise.reject(e);
});
}
}
}
return Promise.reject(err);
return Promise.reject(err);
};
}
exports.refreshAuthRobotTokenOnResponseError = refreshAuthRobotTokenOnResponseError;
exports.createRefreshRobotTokenOnResponseErrorHandler = createRefreshRobotTokenOnResponseErrorHandler;
//# sourceMappingURL=auth-robot-token.js.map

@@ -0,1 +1,2 @@

export * from './connection-string';
export * from './has-own-property';

@@ -2,0 +3,0 @@ export * from './ip-address';

@@ -23,2 +23,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./connection-string"), exports);
__exportStar(require("./has-own-property"), exports);

@@ -25,0 +26,0 @@ __exportStar(require("./ip-address"), exports);

{
"name": "@abip/sp-common",
"version": "0.0.3",
"version": "0.1.0",
"description": "",

@@ -26,6 +26,6 @@ "main": "./dist/index",

"devDependencies": {
"@authelion/common": "^0.0.2",
"@trapi/client": "^2.0.5",
"@trapi/query": "^2.1.1",
"@types/lodash": "^4.14.180",
"@authelion/common": "^0.0.3",
"@trapi/client": "^2.0.6",
"@trapi/query": "^2.1.2",
"@types/lodash": "^4.14.181",
"rimraf": "^3.0.2"

@@ -35,3 +35,3 @@ },

"lodash.template": "^4.5.0",
"nanoid": "^3.3.1"
"nanoid": "^3.3.2"
},

@@ -46,3 +46,3 @@ "peerDependencies": {

},
"gitHead": "b2dfb08d26a2c4cc35d465569dde99f62a86b790"
"gitHead": "715f8bbcf22941b198d5711eb5cb2c6e0441c06d"
}

@@ -20,2 +20,3 @@ /*

SURVEY_MANAGE = 'survey_manage',
SURVEY_APPLICATION_MANAGE = 'survey_application_manage',
SURVEY_EVENT_MANAGE = 'survey_event_manage',

@@ -22,0 +23,0 @@ SURVEY_EVENT_RESPONSE_MANAGE = 'survey_event_response_manage',

@@ -8,4 +8,2 @@ /*

import { SurveyTemplate } from '../survey-template';
export interface Course {

@@ -16,2 +14,4 @@ id: string;

evasys_user_id: number | null;
name: string;

@@ -21,8 +21,2 @@

survey_template_id: SurveyTemplate['id'] | null;
survey_template: SurveyTemplate | null;
// ------------------------------------------------------------------
created_at: Date;

@@ -29,0 +23,0 @@

@@ -9,2 +9,4 @@ /*

export * from './course';
export * from './survey-evasys-template';
export * from './survey-evasys-template-question';
export * from './ip-address';

@@ -16,10 +18,8 @@ export * from './lecturer';

export * from './survey-answer';
export * from './survey-course-template';
export * from './survey-event';
export * from './survey-event-lecturer';
export * from './survey-event-response';
export * from './survey-event-question';
export * from './survey-group';
export * from './survey-question';
export * from './survey-question-answer';
export * from './survey-template';
export * from './survey-template-group';

@@ -13,2 +13,3 @@ /*

import { CollectionResourceResponse, SingleResourceResponse } from '../../type';
import { SurveyEventCommand } from './constants';

@@ -69,2 +70,18 @@ export class SurveyEventAPI {

}
async runCommand(
id: SurveyEvent['id'],
command: `${SurveyEventCommand}` | SurveyEventCommand,
data: Record<string, any> = {},
): Promise<SingleResourceResponse<SurveyEvent>> {
const actionData = {
command,
...data,
};
const { data: response } = await this.client
.post(`survey-events/${id}/command`, actionData);
return response;
}
}

@@ -8,2 +8,7 @@ /*

export enum SurveyEventCommand {
START = 'start',
STOP = 'stop',
}
export enum SurveyEventExecutionStatus {

@@ -15,2 +20,3 @@ STARTING = 'starting',

STOPPED = 'stopped',
FINISHED = 'finished',
FAILED = 'failed',

@@ -22,6 +28,10 @@ }

// name, course, template
EXTRA,
META,
// location
LOCATION,
// questions
SPECIAL,
// start, end, lecturer
SECURITY,
// access, token, location
// access, token,
FINISH,

@@ -28,0 +38,0 @@ }

@@ -10,6 +10,11 @@ /*

import {
Course, Location, LocationRoom, SurveyEventAccessRestriction, SurveyEventConfigurationStep,
Course,
Location,
LocationRoom,
SurveyApplication,
SurveyEvasysTemplate,
SurveyEventAccessRestriction,
SurveyEventConfigurationStep,
} from '../index';
import { SurveyEventAccess, SurveyEventExecutionStatus } from './constants';
import { SurveyTemplate } from '../survey-template';

@@ -21,2 +26,4 @@ export interface SurveyEvent {

application: SurveyApplication;
access: SurveyEventAccess;

@@ -42,6 +49,8 @@

template_id: SurveyTemplate['id'] | null;
evasys_template_id: SurveyEvasysTemplate['id'] | null;
template: SurveyTemplate | null;
evasys_template: SurveyEvasysTemplate | null;
// ------------------------------------------------------------------
course_id: Course['id'] | null;

@@ -48,0 +57,0 @@

@@ -9,3 +9,2 @@ /*

import { SurveyGroup } from '../survey-group';
import { SurveyQuestionTarget } from './constants';

@@ -17,3 +16,3 @@ export interface SurveyQuestion {

target: SurveyQuestionTarget | null;
special: boolean;

@@ -24,4 +23,2 @@ order: number | null;

type: string;
name: string | null;

@@ -33,5 +30,5 @@

group_id: SurveyGroup['id'];
group_id: SurveyGroup['id'] | null;
group: SurveyGroup;
group: SurveyGroup | null;

@@ -38,0 +35,0 @@ // ------------------------------------------------------------------

@@ -8,3 +8,3 @@ /*

export * from './constants';
export * from './api';
export * from './entity';

@@ -22,4 +22,6 @@ /*

return client.locationRoom;
case 'surveyCourseTemplate':
return client.surveyCourseTemplate;
case 'surveyEvasysTemplate':
return client.surveyEvasysTemplate;
case 'surveyEvasysTemplateQuestion':
return client.surveyEvasysTemplateQuestion;
case 'surveyEvent':

@@ -29,4 +31,4 @@ return client.surveyEvent;

return client.surveyEventLecturer;
case 'surveyTemplate':
return client.surveyTemplate;
case 'surveyEventQuestion':
return client.surveyEventQuestion;
}

@@ -33,0 +35,0 @@

@@ -10,10 +10,10 @@ /*

import {
CourseAPI,
IpAddressAPI,
LecturerAPI,
LocationAPI,
CourseAPI, IpAddressAPI, LecturerAPI, LocationAPI,
LocationRoomAPI,
SurveyCourseTemplateAPI,
SurveyEventAPI, SurveyEventLecturerAPI,
SurveyTemplateAPI,
SurveyEvasysTemplateAPI,
SurveyEvasysTemplateQuestionAPI,
SurveyEventAPI,
SurveyEventLecturerAPI,
SurveyEventQuestionAPI,
SurveyQuestionAPI,
} from '../../domains';

@@ -32,4 +32,6 @@

public readonly surveyCourseTemplate : SurveyCourseTemplateAPI;
public readonly surveyEvasysTemplate: SurveyEvasysTemplateAPI;
public readonly surveyEvasysTemplateQuestion: SurveyEvasysTemplateQuestionAPI;
public readonly surveyEvent : SurveyEventAPI;

@@ -39,7 +41,11 @@

public readonly surveyTemplate : SurveyTemplateAPI;
public readonly surveyEventQuestion : SurveyEventQuestionAPI;
public readonly surveyQuestion: SurveyQuestionAPI;
constructor(config: Config) {
super(config);
this.surveyEvasysTemplate = new SurveyEvasysTemplateAPI(this.driver);
this.surveyEvasysTemplateQuestion = new SurveyEvasysTemplateQuestionAPI(this.driver);
this.course = new CourseAPI(this.driver);

@@ -50,7 +56,7 @@ this.ipAddress = new IpAddressAPI(this.driver);

this.locationRoom = new LocationRoomAPI(this.driver);
this.surveyCourseTemplate = new SurveyCourseTemplateAPI(this.driver);
this.surveyEvent = new SurveyEventAPI(this.driver);
this.surveyEventLecturer = new SurveyEventLecturerAPI(this.driver);
this.surveyTemplate = new SurveyTemplateAPI(this.driver);
this.surveyEventQuestion = new SurveyEventQuestionAPI(this.driver);
this.surveyQuestion = new SurveyQuestionAPI(this.driver);
}
}

@@ -11,2 +11,1 @@ /*

export * from './interceptors';
export * from './vault-client';

@@ -15,6 +15,6 @@ /*

import { useClient } from '@trapi/client';
import { ErrorCode, OAuth2TokenGrant, TokenAPI } from '@authelion/common';
import { ROBOT_SECRET_ENGINE_KEY, ServiceID } from '../../../domains';
import { VaultAPI } from '../../vault-client';
import {
ErrorCode, OAuth2TokenGrant, Robot, TokenAPI,
} from '@authelion/common';
import { HTTPClient } from '../../client';

@@ -27,50 +27,54 @@ let lastChecked : number | undefined;

export function refreshAuthRobotTokenOnResponseError(err?: any) {
const { config } = err;
export function createRefreshRobotTokenOnResponseErrorHandler(context: {
httpClient: HTTPClient,
load: () => Promise<Pick<Robot, 'id' | 'secret'>>
}) {
return (err?: any) => {
const { config } = err;
if (
err.response && (
err.response.status === 401 || // Unauthorized
err.response.status === 403 || // Forbidden
err.response.data?.code === ErrorCode.CREDENTIALS_INVALID ||
err.response.data?.code === ErrorCode.TOKEN_EXPIRED
)
) {
if (canVerifyCredentials()) {
lastChecked = Date.now();
if (
err.response && (
err.response.status === 401 || // Unauthorized
err.response.status === 403 || // Forbidden
err.response.data?.code === ErrorCode.CREDENTIALS_INVALID ||
err.response.data?.code === ErrorCode.TOKEN_EXPIRED
)
) {
if (canVerifyCredentials()) {
lastChecked = Date.now();
return useClient<VaultAPI>('vault').keyValue
.find(ROBOT_SECRET_ENGINE_KEY, ServiceID.SYSTEM)
.then((response) => {
const tokenApi = new TokenAPI(useClient().driver);
return context.load()
.then((response) => {
const tokenApi = new TokenAPI(context.httpClient.driver);
return tokenApi.create({
id: response.data.id,
secret: response.data.secret,
grant_type: OAuth2TokenGrant.ROBOT_CREDENTIALS,
})
.then((token) => {
useClient()
.setAuthorizationHeader({
type: 'Bearer',
token: token.access_token,
});
return useClient().request(config);
return tokenApi.create({
id: response.id,
secret: response.secret,
grant_type: OAuth2TokenGrant.ROBOT_CREDENTIALS,
})
.catch((e) => {
useClient().unsetAuthorizationHeader();
.then((token) => {
context.httpClient
.setAuthorizationHeader({
type: 'Bearer',
token: token.access_token,
});
return Promise.reject(e);
});
})
.catch((e) => {
useClient().unsetAuthorizationHeader();
return context.httpClient.request(config);
})
.catch((e) => {
context.httpClient.unsetAuthorizationHeader();
return Promise.reject(e);
});
return Promise.reject(e);
});
})
.catch((e) => {
context.httpClient.unsetAuthorizationHeader();
return Promise.reject(e);
});
}
}
}
return Promise.reject(err);
return Promise.reject(err);
};
}

@@ -8,2 +8,3 @@ /*

export * from './connection-string';
export * from './has-own-property';

@@ -10,0 +11,0 @@ export * from './ip-address';

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc