@vtecx/vtecxnext 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vtecxnext.d.ts +26 -1
- package/dist/vtecxnext.js +66 -13
- package/package.json +1 -1
package/dist/vtecxnext.d.ts
CHANGED
|
@@ -130,13 +130,21 @@ export declare const log: (req: IncomingMessage, res: ServerResponse, message: s
|
|
|
130
130
|
*/
|
|
131
131
|
export declare const getEntry: (req: IncomingMessage, res: ServerResponse, uri: string, targetService?: string) => Promise<any>;
|
|
132
132
|
/**
|
|
133
|
-
* get
|
|
133
|
+
* get feed
|
|
134
134
|
* @param req request (for authentication)
|
|
135
135
|
* @param res response (for authentication)
|
|
136
136
|
* @param uri key and conditions
|
|
137
137
|
* @return feed (entry array)
|
|
138
138
|
*/
|
|
139
139
|
export declare const getFeed: (req: IncomingMessage, res: ServerResponse, uri: string, targetService?: string) => Promise<any>;
|
|
140
|
+
/**
|
|
141
|
+
* get feed
|
|
142
|
+
* @param req request (for authentication)
|
|
143
|
+
* @param res response (for authentication)
|
|
144
|
+
* @param uri key and conditions
|
|
145
|
+
* @return feed (entry array). Returns a cursor in the header if more data is available. (x-vtecx-nextpage)
|
|
146
|
+
*/
|
|
147
|
+
export declare const getFeedResponse: (req: IncomingMessage, res: ServerResponse, uri: string, targetService?: string) => Promise<VtecxResponse>;
|
|
140
148
|
/**
|
|
141
149
|
* get count
|
|
142
150
|
* @param req request (for authentication)
|
|
@@ -145,6 +153,14 @@ export declare const getFeed: (req: IncomingMessage, res: ServerResponse, uri: s
|
|
|
145
153
|
* @return count
|
|
146
154
|
*/
|
|
147
155
|
export declare const count: (req: IncomingMessage, res: ServerResponse, uri: string, targetService?: string) => Promise<number | null>;
|
|
156
|
+
/**
|
|
157
|
+
* get count
|
|
158
|
+
* @param req request (for authentication)
|
|
159
|
+
* @param res response (for authentication)
|
|
160
|
+
* @param uri key and conditions
|
|
161
|
+
* @return feed. Returns a cursor in the header if more data is available. (x-vtecx-nextpage)
|
|
162
|
+
*/
|
|
163
|
+
export declare const countResponse: (req: IncomingMessage, res: ServerResponse, uri: string, targetService?: string) => Promise<VtecxResponse>;
|
|
148
164
|
/**
|
|
149
165
|
* register entries
|
|
150
166
|
* @param req request (for authentication)
|
|
@@ -784,6 +800,15 @@ export declare const deleteTotp: (req: IncomingMessage, res: ServerResponse, acc
|
|
|
784
800
|
* @return message
|
|
785
801
|
*/
|
|
786
802
|
export declare const changeTdid: (req: IncomingMessage, res: ServerResponse) => Promise<any>;
|
|
803
|
+
/**
|
|
804
|
+
* response class
|
|
805
|
+
*/
|
|
806
|
+
export declare class VtecxResponse {
|
|
807
|
+
status: number;
|
|
808
|
+
header: any;
|
|
809
|
+
data: any;
|
|
810
|
+
constructor(status: number, header: any, data: any);
|
|
811
|
+
}
|
|
787
812
|
/**
|
|
788
813
|
* Error returned from vte.cx
|
|
789
814
|
*/
|
package/dist/vtecxnext.js
CHANGED
|
@@ -26,8 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
exports.FetchError = exports.VtecxNextError = exports.changeTdid = exports.deleteTotp = exports.createTotp = exports.getTotpLink = exports.buffer = exports.oauthCallbackLine = exports.oauthLine = exports.removealias = exports.addalias = exports.removeacl = exports.addacl = exports.getcontent = exports.deletecontent = exports.putcontent = exports.savefiles = exports.deleteusers = exports.deleteuser = exports.canceluser = exports.activateusers = exports.activateuser = exports.revokeusers = exports.revokeuser = exports.userstatus = exports.changeaccount_verify = exports.changeaccount = exports.changepassByAdmin = exports.changepass = exports.passreset = exports.adduserByAdmin = exports.adduser = exports.isAdmin = exports.isGroupMember = exports.getGroups = exports.noGroupMember = exports.leaveGroup = exports.joinGroup = exports.getMessageQueue = exports.setMessageQueue = exports.setMessageQueueStatus = exports.pushNotification = exports.sendMail = exports.checkSignature = exports.deleteSignature = void 0;
|
|
29
|
+
exports.toPdf = exports.getBQCsv = exports.getBQ = exports.deleteBQ = exports.postBQ = exports.getPage = exports.pagination = exports.getSessionLong = exports.getSessionString = exports.getSessionEntry = exports.getSessionFeed = exports.deleteSessionLong = exports.deleteSessionString = exports.deleteSessionEntry = exports.deleteSessionFeed = exports.incrementSession = exports.setSessionLong = exports.setSessionString = exports.setSessionEntry = exports.setSessionFeed = exports.getRangeids = exports.rangeids = exports.setids = exports.getids = exports.addids = exports.allocids = exports.deleteFolder = exports.deleteEntry = exports.put = exports.post = exports.countResponse = exports.count = exports.getFeedResponse = exports.getFeed = exports.getEntry = exports.log = exports.rxid = exports.service = exports.isLoggedin = exports.whoami = exports.account = exports.uid = exports.now = exports.logout = exports.loginWithTotp = exports.loginWithRxid = exports.login = exports.sendMessage = exports.checkXRequestedWith = exports.hello = void 0;
|
|
30
|
+
exports.FetchError = exports.VtecxNextError = exports.VtecxResponse = exports.changeTdid = exports.deleteTotp = exports.createTotp = exports.getTotpLink = exports.buffer = exports.oauthCallbackLine = exports.oauthLine = exports.removealias = exports.addalias = exports.removeacl = exports.addacl = exports.getcontent = exports.deletecontent = exports.putcontent = exports.savefiles = exports.deleteusers = exports.deleteuser = exports.canceluser = exports.activateusers = exports.activateuser = exports.revokeusers = exports.revokeuser = exports.userstatus = exports.changeaccount_verify = exports.changeaccount = exports.changepassByAdmin = exports.changepass = exports.passreset = exports.adduserByAdmin = exports.adduser = exports.isAdmin = exports.isGroupMember = exports.getGroups = exports.noGroupMember = exports.leaveGroup = exports.joinGroup = exports.getMessageQueue = exports.setMessageQueue = exports.setMessageQueueStatus = exports.pushNotification = exports.sendMail = exports.checkSignature = exports.deleteSignature = exports.putSignatures = exports.putSignature = void 0;
|
|
31
31
|
const sqlstring_1 = __importDefault(require("sqlstring"));
|
|
32
32
|
const formidable_1 = __importDefault(require("formidable"));
|
|
33
33
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -42,6 +42,7 @@ exports.hello = hello;
|
|
|
42
42
|
const SERVLETPATH_DATA = '/d';
|
|
43
43
|
const SERVLETPATH_PROVIDER = '/p';
|
|
44
44
|
const SERVLETPATH_OAUTH = '/o';
|
|
45
|
+
const HEADER_NEXTPAGE = 'x-vtecx-nextpage';
|
|
45
46
|
/**
|
|
46
47
|
* X-Requested-With header check.
|
|
47
48
|
* If not specified, set status 417 to the response.
|
|
@@ -128,7 +129,6 @@ const loginWithRxid = async (req, res, rxid) => {
|
|
|
128
129
|
catch (e) {
|
|
129
130
|
throw newFetchError(e, true);
|
|
130
131
|
}
|
|
131
|
-
const feed = await response.json();
|
|
132
132
|
// vte.cxからのset-cookieを転記
|
|
133
133
|
setCookie(response, res);
|
|
134
134
|
const data = await response.json();
|
|
@@ -444,7 +444,7 @@ const getEntry = async (req, res, uri, targetService) => {
|
|
|
444
444
|
};
|
|
445
445
|
exports.getEntry = getEntry;
|
|
446
446
|
/**
|
|
447
|
-
* get
|
|
447
|
+
* get feed
|
|
448
448
|
* @param req request (for authentication)
|
|
449
449
|
* @param res response (for authentication)
|
|
450
450
|
* @param uri key and conditions
|
|
@@ -452,6 +452,19 @@ exports.getEntry = getEntry;
|
|
|
452
452
|
*/
|
|
453
453
|
const getFeed = async (req, res, uri, targetService) => {
|
|
454
454
|
//console.log('[vtecxnext getFeed] start.')
|
|
455
|
+
const vtecxRes = await (0, exports.getFeedResponse)(req, res, uri, targetService);
|
|
456
|
+
return vtecxRes.data;
|
|
457
|
+
};
|
|
458
|
+
exports.getFeed = getFeed;
|
|
459
|
+
/**
|
|
460
|
+
* get feed
|
|
461
|
+
* @param req request (for authentication)
|
|
462
|
+
* @param res response (for authentication)
|
|
463
|
+
* @param uri key and conditions
|
|
464
|
+
* @return feed (entry array). Returns a cursor in the header if more data is available. (x-vtecx-nextpage)
|
|
465
|
+
*/
|
|
466
|
+
const getFeedResponse = async (req, res, uri, targetService) => {
|
|
467
|
+
//console.log('[vtecxnext getFeedResponse] start.')
|
|
455
468
|
// キー入力値チェック
|
|
456
469
|
checkUri(uri);
|
|
457
470
|
// vte.cxへリクエスト
|
|
@@ -470,9 +483,15 @@ const getFeed = async (req, res, uri, targetService) => {
|
|
|
470
483
|
// レスポンスのエラーチェック
|
|
471
484
|
await checkVtecxResponse(response);
|
|
472
485
|
// 戻り値
|
|
473
|
-
|
|
486
|
+
const data = await getJson(response);
|
|
487
|
+
const header = {};
|
|
488
|
+
const nextpage = response.headers.get(HEADER_NEXTPAGE);
|
|
489
|
+
if (nextpage) {
|
|
490
|
+
header[HEADER_NEXTPAGE] = nextpage;
|
|
491
|
+
}
|
|
492
|
+
return new VtecxResponse(response.status, header, data);
|
|
474
493
|
};
|
|
475
|
-
exports.
|
|
494
|
+
exports.getFeedResponse = getFeedResponse;
|
|
476
495
|
/**
|
|
477
496
|
* get count
|
|
478
497
|
* @param req request (for authentication)
|
|
@@ -482,6 +501,21 @@ exports.getFeed = getFeed;
|
|
|
482
501
|
*/
|
|
483
502
|
const count = async (req, res, uri, targetService) => {
|
|
484
503
|
//console.log('[vtecxnext count] start.')
|
|
504
|
+
const vtecxRes = await (0, exports.countResponse)(req, res, uri, targetService);
|
|
505
|
+
// 戻り値
|
|
506
|
+
const data = vtecxRes.data;
|
|
507
|
+
return vtecxRes.data.feed.title ? Number(data.feed.title) : null;
|
|
508
|
+
};
|
|
509
|
+
exports.count = count;
|
|
510
|
+
/**
|
|
511
|
+
* get count
|
|
512
|
+
* @param req request (for authentication)
|
|
513
|
+
* @param res response (for authentication)
|
|
514
|
+
* @param uri key and conditions
|
|
515
|
+
* @return feed. Returns a cursor in the header if more data is available. (x-vtecx-nextpage)
|
|
516
|
+
*/
|
|
517
|
+
const countResponse = async (req, res, uri, targetService) => {
|
|
518
|
+
//console.log('[vtecxnext countResponse] start.')
|
|
485
519
|
// キー入力値チェック
|
|
486
520
|
checkUri(uri);
|
|
487
521
|
// vte.cxへリクエスト
|
|
@@ -501,9 +535,14 @@ const count = async (req, res, uri, targetService) => {
|
|
|
501
535
|
await checkVtecxResponse(response);
|
|
502
536
|
// 戻り値
|
|
503
537
|
const data = await getJson(response);
|
|
504
|
-
|
|
538
|
+
const header = {};
|
|
539
|
+
const nextpage = response.headers.get(HEADER_NEXTPAGE);
|
|
540
|
+
if (nextpage) {
|
|
541
|
+
header[HEADER_NEXTPAGE] = nextpage;
|
|
542
|
+
}
|
|
543
|
+
return new VtecxResponse(response.status, header, data);
|
|
505
544
|
};
|
|
506
|
-
exports.
|
|
545
|
+
exports.countResponse = countResponse;
|
|
507
546
|
/**
|
|
508
547
|
* register entries
|
|
509
548
|
* @param req request (for authentication)
|
|
@@ -2917,6 +2956,20 @@ const changeTdid = async (req, res) => {
|
|
|
2917
2956
|
};
|
|
2918
2957
|
exports.changeTdid = changeTdid;
|
|
2919
2958
|
//---------------------------------------------
|
|
2959
|
+
/**
|
|
2960
|
+
* response class
|
|
2961
|
+
*/
|
|
2962
|
+
class VtecxResponse {
|
|
2963
|
+
status;
|
|
2964
|
+
header;
|
|
2965
|
+
data;
|
|
2966
|
+
constructor(status, header, data) {
|
|
2967
|
+
this.status = status;
|
|
2968
|
+
this.header = header;
|
|
2969
|
+
this.data = data;
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
exports.VtecxResponse = VtecxResponse;
|
|
2920
2973
|
/**
|
|
2921
2974
|
* Error returned from vte.cx
|
|
2922
2975
|
*/
|
|
@@ -2987,6 +3040,9 @@ const requestVtecx = async (method, url, req, body, additionalHeaders, targetSer
|
|
|
2987
3040
|
const fetchVtecx = async (method, url, headers, body, mode) => {
|
|
2988
3041
|
//console.log(`[vtecxnext fetchVtecx] url=${process.env.VTECX_URL}${url}`)
|
|
2989
3042
|
headers['X-Requested-With'] = 'XMLHttpRequest';
|
|
3043
|
+
if (VTECX_SERVICENAME) {
|
|
3044
|
+
headers['X-SERVICENAME'] = VTECX_SERVICENAME;
|
|
3045
|
+
}
|
|
2990
3046
|
const apiKey = process.env.VTECX_APIKEY;
|
|
2991
3047
|
if (apiKey && !url.startsWith(SERVLETPATH_DATA)) {
|
|
2992
3048
|
//headers['Authorization'] = `APIKey ${apiKey}`
|
|
@@ -3017,6 +3073,7 @@ const fetchVtecx = async (method, url, headers, body, mode) => {
|
|
|
3017
3073
|
};
|
|
3018
3074
|
/** vte.cx URL */
|
|
3019
3075
|
const VTECX_URL = process.env.VTECX_URL ?? '';
|
|
3076
|
+
const VTECX_SERVICENAME = process.env.VTECX_SERVICENAME ?? '';
|
|
3020
3077
|
const newFetchError = (e, isVtecx) => {
|
|
3021
3078
|
let errMsg;
|
|
3022
3079
|
if (e instanceof Error) {
|
|
@@ -3051,12 +3108,8 @@ const setCookie = (response, res) => {
|
|
|
3051
3108
|
//console.log(`[vtecxnext setCookie] value : ${setCookieVal}`)
|
|
3052
3109
|
//res.setHeader('set-cookie', setCookieVal)
|
|
3053
3110
|
const setCookieVals = splitCookieValue(setCookieVal);
|
|
3111
|
+
//console.log(`[vtecxnext setCookie] values : ${setCookieVals}`)
|
|
3054
3112
|
res.setHeader('set-cookie', setCookieVals);
|
|
3055
|
-
/*
|
|
3056
|
-
for (const val of setCookieVals) {
|
|
3057
|
-
res.setHeader('set-cookie', val)
|
|
3058
|
-
}
|
|
3059
|
-
*/
|
|
3060
3113
|
}
|
|
3061
3114
|
};
|
|
3062
3115
|
/**
|