@vtecx/vtecxnext 2.2.9 → 2.2.11

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;
@@ -913,6 +913,12 @@ export declare class VtecxNext {
913
913
  * @return message feed
914
914
  */
915
915
  deleteGroupadmin: (groupNames: string[], async?: boolean) => Promise<any>;
916
+ /**
917
+ * get property
918
+ * @param name property name
919
+ * @return property value
920
+ */
921
+ property: (name: string) => Promise<string | null>;
916
922
  /**
917
923
  * vte.cxへリクエスト
918
924
  * @param method メソッド
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
  };
@@ -3646,6 +3646,37 @@ class VtecxNext {
3646
3646
  await checkVtecxResponse(response);
3647
3647
  return await getJson(response);
3648
3648
  };
3649
+ /**
3650
+ * get property
3651
+ * @param name property name
3652
+ * @return property value
3653
+ */
3654
+ property = async (name) => {
3655
+ //console.log('[vtecxnext property] start.')
3656
+ // 入力チェック
3657
+ checkNotNull(name, 'Name');
3658
+ // vte.cxへリクエスト
3659
+ const method = 'GET';
3660
+ const url = `${SERVLETPATH_PROVIDER}/?_property=${name}`;
3661
+ let response;
3662
+ try {
3663
+ response = await this.requestVtecx(method, url);
3664
+ }
3665
+ catch (e) {
3666
+ throw newFetchError(e, true);
3667
+ }
3668
+ //console.log(`[vtecxnext property] response=${response}`)
3669
+ // vte.cxからのset-cookieを転記
3670
+ this.setCookie(response);
3671
+ // レスポンスのエラーチェック
3672
+ await checkVtecxResponse(response);
3673
+ // 戻り値
3674
+ if (response.status === 204) {
3675
+ return null;
3676
+ }
3677
+ const data = await getJson(response);
3678
+ return data.feed.title;
3679
+ };
3649
3680
  //----------------------
3650
3681
  /**
3651
3682
  * vte.cxへリクエスト
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtecx/vtecxnext",
3
- "version": "2.2.9",
3
+ "version": "2.2.11",
4
4
  "description": "vte.cx Next.js api",
5
5
  "main": "dist/index.js",
6
6
  "files": [