@vtecx/vtecxnext 2.2.10 → 2.2.12

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.
@@ -81,7 +81,7 @@ export declare class VtecxNext {
81
81
  null2blank: (val: string | undefined | null) => string;
82
82
  /**
83
83
  * X-Requested-With header check.
84
- * If not specified, set status 417 to the response.
84
+ * If not specified, set status 401 to the response.
85
85
  * @return Response if no X-Requested-With header is specified
86
86
  */
87
87
  checkXRequestedWith: () => Response | undefined;
@@ -618,6 +618,13 @@ export declare class VtecxNext {
618
618
  * @return feed
619
619
  */
620
620
  leaveGroup: (group: string) => Promise<boolean>;
621
+ /**
622
+ * leave group by admin
623
+ * @param uids uid list
624
+ * @param group group
625
+ * @return feed
626
+ */
627
+ leaveGroupByAdmin: (uids: string[], group: string) => Promise<any>;
621
628
  /**
622
629
  * Get entries that have entries in a group, but are not in the group.
623
630
  * (for entries with no signature or with an incorrect signature, if the user group requires a signature)
package/dist/vtecxnext.js CHANGED
@@ -143,7 +143,7 @@ class VtecxNext {
143
143
  };
144
144
  /**
145
145
  * X-Requested-With header check.
146
- * If not specified, set status 417 to the response.
146
+ * If not specified, set status 401 to the response.
147
147
  * @return Response if no X-Requested-With header is specified
148
148
  */
149
149
  checkXRequestedWith = () => {
@@ -155,9 +155,9 @@ class VtecxNext {
155
155
  this.req.headers.forEach((value, key, parent) => {
156
156
  //console.log(`[vtecxnext checkXRequestedWith] key=${key} value=${value}`)
157
157
  if (!hasX) {
158
- if ((key.startsWith('x-') || key.startsWith('X-')) &&
159
- key.indexOf('invoke') === -1 &&
160
- value !== undefined && value !== '') {
158
+ const keyLower = key.toLocaleLowerCase();
159
+ if ((keyLower.startsWith('x-') && !keyLower.startsWith('x-forwarded')) ||
160
+ keyLower === 'authorization') {
161
161
  //console.log(`[vtecxnext checkXRequestedWith] key=${key} value=${value}`)
162
162
  hasX = true;
163
163
  }
@@ -166,7 +166,7 @@ class VtecxNext {
166
166
  //console.log(`[vtecxnext checkXRequestedWith] end.`)
167
167
  if (!hasX) {
168
168
  return new Response('', {
169
- status: 417
169
+ status: 401
170
170
  });
171
171
  }
172
172
  };
@@ -2358,7 +2358,7 @@ class VtecxNext {
2358
2358
  // 入力チェック
2359
2359
  checkUri(group);
2360
2360
  // vte.cxへリクエスト
2361
- const method = 'DELETE';
2361
+ const method = 'PUT';
2362
2362
  const url = `${SERVLETPATH_PROVIDER}${group}?_leavegroup`;
2363
2363
  let response;
2364
2364
  try {
@@ -2375,6 +2375,41 @@ class VtecxNext {
2375
2375
  // 戻り値
2376
2376
  return true;
2377
2377
  };
2378
+ /**
2379
+ * leave group by admin
2380
+ * @param uids uid list
2381
+ * @param group group
2382
+ * @return feed
2383
+ */
2384
+ leaveGroupByAdmin = async (uids, group) => {
2385
+ //console.log(`[vtecxnext leaveGroupByAdmin] start. group=${group} uids=${uids}`)
2386
+ // 入力チェック
2387
+ checkUri(group, 'group key');
2388
+ checkNotNull(uids, 'uid');
2389
+ // vte.cxへリクエスト
2390
+ const method = 'PUT';
2391
+ const url = `${SERVLETPATH_PROVIDER}${group}?_leavegroupByAdmin`;
2392
+ const feed = [];
2393
+ for (const uid of uids) {
2394
+ const entry = { 'link': [{ '___rel': 'self', '___href': `/_user/${uid}` }] };
2395
+ feed.push(entry);
2396
+ }
2397
+ const value = JSON.stringify(feed);
2398
+ let response;
2399
+ try {
2400
+ response = await this.requestVtecx(method, url, value);
2401
+ }
2402
+ catch (e) {
2403
+ throw newFetchError(e, true);
2404
+ }
2405
+ //console.log(`[vtecxnext leaveGroupByAdmin] response. status=${response.status}`)
2406
+ // vte.cxからのset-cookieを転記
2407
+ this.setCookie(response);
2408
+ // レスポンスのエラーチェック
2409
+ await checkVtecxResponse(response);
2410
+ // 戻り値
2411
+ return await getJson(response);
2412
+ };
2378
2413
  /**
2379
2414
  * Get entries that have entries in a group, but are not in the group.
2380
2415
  * (for entries with no signature or with an incorrect signature, if the user group requires a signature)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtecx/vtecxnext",
3
- "version": "2.2.10",
3
+ "version": "2.2.12",
4
4
  "description": "vte.cx Next.js api",
5
5
  "main": "dist/index.js",
6
6
  "files": [