@vtecx/vtecxnext 1.0.4 → 1.0.6

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.
@@ -1,4 +1,6 @@
1
+ /// <reference types="node" />
1
2
  import { IncomingMessage, ServerResponse } from 'http';
3
+ import type { Readable } from 'node:stream';
2
4
  /**
3
5
  * Hello world.
4
6
  */
@@ -695,6 +697,24 @@ export declare const addalias: (req: IncomingMessage, res: ServerResponse, feed:
695
697
  * @return message
696
698
  */
697
699
  export declare const removealias: (req: IncomingMessage, res: ServerResponse, feed: any) => Promise<any>;
700
+ /**
701
+ * OAuth authorization request to LINE
702
+ * @param req request (for authentication)
703
+ * @param res response (for authentication)
704
+ */
705
+ export declare const oauthLine: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
706
+ /**
707
+ * OAuth authorization request to LINE
708
+ * @param req request (for authentication)
709
+ * @param res response (for authentication)
710
+ */
711
+ export declare const oauthCallbackLine: (req: IncomingMessage, res: ServerResponse) => Promise<boolean>;
712
+ /**
713
+ * get binary data from stream
714
+ * @param readable Readable
715
+ * @returns buffer
716
+ */
717
+ export declare const buffer: (readable: Readable) => Promise<Buffer>;
698
718
  /**
699
719
  * Error returned from vte.cx
700
720
  */
package/dist/vtecxnext.js CHANGED
@@ -1,13 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.deleteSignature = exports.putSignatures = exports.putSignature = 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.count = exports.getFeed = exports.getEntry = exports.log = exports.rxid = exports.service = exports.isLoggedin = exports.whoami = exports.account = exports.uid = exports.now = exports.logout = exports.loginWithRxid = exports.login = exports.sendMessage = exports.checkXRequestedWith = exports.hello = void 0;
7
- exports.VtecxNextError = 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.noGroupMember = exports.leaveGroup = exports.joinGroup = exports.getMessageQueue = exports.setMessageQueue = exports.setMessageQueueStatus = exports.pushNotification = exports.sendMail = exports.checkSignature = void 0;
30
+ exports.VtecxNextError = 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.noGroupMember = exports.leaveGroup = exports.joinGroup = exports.getMessageQueue = exports.setMessageQueue = exports.setMessageQueueStatus = exports.pushNotification = exports.sendMail = exports.checkSignature = void 0;
8
31
  const sqlstring_1 = __importDefault(require("sqlstring"));
9
32
  const formidable_1 = __importDefault(require("formidable"));
10
33
  const fs_1 = __importDefault(require("fs"));
34
+ const url_1 = __importStar(require("url"));
11
35
  /**
12
36
  * Hello world.
13
37
  */
@@ -66,7 +90,7 @@ const login = async (req, res, wsse, reCaptchaToken) => {
66
90
  const url = `/d/?_login${param}`;
67
91
  const headers = { 'X-WSSE': `${wsse}` };
68
92
  const response = await fetchVtecx(method, url, headers);
69
- const feed = await response.json();
93
+ //const feed = await response.json()
70
94
  // vte.cxからのset-cookieを転記
71
95
  setCookie(response, res);
72
96
  // レスポンスのエラーチェック
@@ -2019,7 +2043,7 @@ const putcontent = async (req, res, uri) => {
2019
2043
  const url = `/p${uri}?_content`;
2020
2044
  //const headers = {'Content-Type' : req.headers['content-type'], 'Content-Length' : req.headers['content-length']}
2021
2045
  const headers = { 'Content-Type': req.headers['content-type'] };
2022
- const buf = await buffer(req);
2046
+ const buf = await (0, exports.buffer)(req);
2023
2047
  const response = await requestVtecx(method, url, req, buf, headers);
2024
2048
  //console.log(`[vtecxnext putcontent] response. status=${response.status}`)
2025
2049
  // vte.cxからのset-cookieを転記
@@ -2185,6 +2209,47 @@ const removealias = async (req, res, feed) => {
2185
2209
  return await getJson(response);
2186
2210
  };
2187
2211
  exports.removealias = removealias;
2212
+ /**
2213
+ * OAuth authorization request to LINE
2214
+ * @param req request (for authentication)
2215
+ * @param res response (for authentication)
2216
+ */
2217
+ const oauthLine = async (req, res) => {
2218
+ const provider = 'line';
2219
+ const oauthUrl = 'https://access.line.me/oauth2/v2.1/authorize';
2220
+ return await oauth(req, res, provider, oauthUrl);
2221
+ };
2222
+ exports.oauthLine = oauthLine;
2223
+ /**
2224
+ * OAuth authorization request to LINE
2225
+ * @param req request (for authentication)
2226
+ * @param res response (for authentication)
2227
+ */
2228
+ const oauthCallbackLine = async (req, res) => {
2229
+ // OAuthアクセストークン、OAuth情報を取得
2230
+ const provider = 'line';
2231
+ const accesstokenUrl = 'https://api.line.me/oauth2/v2.1/token';
2232
+ const oauthInfo = await oauthGetAccesstoken(req, res, provider, accesstokenUrl);
2233
+ // ユーザ識別情報を取得
2234
+ const userInfo = await oauthGetUserinfoLine(req, res, oauthInfo);
2235
+ // vte.cxユーザと連携・ログイン
2236
+ await oauthLink(req, res, provider, userInfo);
2237
+ return true;
2238
+ };
2239
+ exports.oauthCallbackLine = oauthCallbackLine;
2240
+ /**
2241
+ * get binary data from stream
2242
+ * @param readable Readable
2243
+ * @returns buffer
2244
+ */
2245
+ const buffer = async (readable) => {
2246
+ const chunks = [];
2247
+ for await (const chunk of readable) {
2248
+ chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);
2249
+ }
2250
+ return Buffer.concat(chunks);
2251
+ };
2252
+ exports.buffer = buffer;
2188
2253
  //---------------------------------------------
2189
2254
  /**
2190
2255
  * Error returned from vte.cx
@@ -2205,10 +2270,12 @@ exports.VtecxNextError = VtecxNextError;
2205
2270
  * @param url サーブレットパス以降のURL
2206
2271
  * @param req リクエスト。認証情報設定に使用。
2207
2272
  * @param body リクエストデータ
2273
+ * @param additionalHeaders リクエストヘッダ追加分
2208
2274
  * @param targetService 連携サービス名
2275
+ * @param mode RequestMode ("cors" | "navigate" | "no-cors" | "same-origin")
2209
2276
  * @returns promise
2210
2277
  */
2211
- const requestVtecx = async (method, url, req, body, additionalHeaders, targetService) => {
2278
+ const requestVtecx = async (method, url, req, body, additionalHeaders, targetService, mode) => {
2212
2279
  // cookieの値をvte.cxへのリクエストヘッダに設定
2213
2280
  const cookie = req ? req.headers['cookie'] : undefined;
2214
2281
  const headers = cookie ? { 'Cookie': cookie } : {};
@@ -2226,7 +2293,7 @@ const requestVtecx = async (method, url, req, body, additionalHeaders, targetSer
2226
2293
  headers['X-SERVICEKEY'] = servicekey;
2227
2294
  }
2228
2295
  }
2229
- return fetchVtecx(method, url, headers, body);
2296
+ return fetchVtecx(method, url, headers, body, mode);
2230
2297
  };
2231
2298
  /**
2232
2299
  * vte.cxへリクエスト
@@ -2234,9 +2301,10 @@ const requestVtecx = async (method, url, req, body, additionalHeaders, targetSer
2234
2301
  * @param url サーブレットパス以降のURL
2235
2302
  * @param headers リクエストヘッダ。連想配列で指定。
2236
2303
  * @param body リクエストデータ
2304
+ * @param mode RequestMode ("cors" | "navigate" | "no-cors" | "same-origin")
2237
2305
  * @returns promise
2238
2306
  */
2239
- const fetchVtecx = async (method, url, headers, body) => {
2307
+ const fetchVtecx = async (method, url, headers, body, mode) => {
2240
2308
  //console.log(`[vtecxnext fetchVtecx] url=${process.env.VTECX_URL}${url}`)
2241
2309
  headers['X-Requested-With'] = 'XMLHttpRequest';
2242
2310
  const apiKey = process.env.VTECX_APIKEY;
@@ -2248,6 +2316,9 @@ const fetchVtecx = async (method, url, headers, body) => {
2248
2316
  method: method,
2249
2317
  headers: headers
2250
2318
  };
2319
+ if (mode) {
2320
+ requestInit['mode'] = mode;
2321
+ }
2251
2322
  return fetch(`${process.env.VTECX_URL}${url}`, requestInit);
2252
2323
  };
2253
2324
  /**
@@ -2261,6 +2332,21 @@ const setCookie = (response, res) => {
2261
2332
  res.setHeader('set-cookie', setCookieVal);
2262
2333
  }
2263
2334
  };
2335
+ /**
2336
+ * vte.cxからのallow-originを、ブラウザへレスポンスする。
2337
+ * @param response vte.cxからのレスポンス
2338
+ * @param res ブラウザへのレスポンス
2339
+ */
2340
+ const setAllowOrigin = (response, res) => {
2341
+ let val = response.headers.get('access-control-allow-origin');
2342
+ val ? res.setHeader('access-control-allow-origin', val) : '';
2343
+ val = response.headers.get('access-control-allow-methods');
2344
+ val ? res.setHeader('access-control-allow-methods', val) : '';
2345
+ val = response.headers.get('access-control-allow-headers');
2346
+ val ? res.setHeader('access-control-allow-headers', val) : '';
2347
+ val = response.headers.get('access-control-allow-credentials');
2348
+ val ? res.setHeader('access-control-allow-credentials', val) : '';
2349
+ };
2264
2350
  /**
2265
2351
  * vte.cxからのレスポンスヘッダを、ブラウザへレスポンスする。
2266
2352
  * コンテンツの戻し時に使用。
@@ -2418,14 +2504,216 @@ const getLinks = (rel, hrefs) => {
2418
2504
  return links;
2419
2505
  };
2420
2506
  /**
2421
- * ストリームからバイナリデータを取得
2422
- * @param readable Readable
2423
- * @returns バイナリデータ
2507
+ * OAuth authorization request
2508
+ * @param req request (for authentication)
2509
+ * @param res response (for authentication)
2510
+ * @param provider OAuth provider name
2511
+ * @param oauthUrl OAuth authorization request url
2512
+ * @return true
2424
2513
  */
2425
- const buffer = async (readable) => {
2426
- const chunks = [];
2427
- for await (const chunk of readable) {
2428
- chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);
2514
+ const oauth = async (req, res, provider, oauthUrl) => {
2515
+ //console.log(`[vtecxnext oauth] start. provider=${provider} oauthUrl=${oauthUrl}`)
2516
+ // TODO reCAPTCHAを必須とすべき。
2517
+ // 入力チェック
2518
+ checkNotNull(provider, 'OAuth provider');
2519
+ // vte.cxへリクエスト (state取得)
2520
+ const method = 'POST';
2521
+ const url = `/o/${provider}/create_state`;
2522
+ const response = await requestVtecx(method, url, req);
2523
+ // レスポンスのエラーチェック
2524
+ await checkVtecxResponse(response);
2525
+ // 戻り値
2526
+ const data = await getJson(response);
2527
+ // state生成
2528
+ if (!data || !data.feed || !data.feed.title) {
2529
+ throw new VtecxNextError(401, `Could not generate state.`);
2429
2530
  }
2430
- return Buffer.concat(chunks);
2531
+ //console.log(`[vtecxnext oauth] response data=${JSON.stringify(data)}`)
2532
+ const state = data.feed.title;
2533
+ const client_id = data.feed.subtitle;
2534
+ const redirect_uri = data.feed.link[0].___href;
2535
+ //const origin = getOrigin(oauthUrl)
2536
+ // 認可リクエストリダイレクトURL生成
2537
+ //console.log(`[vtecxnext oauth] redirect_uri=${redirect_uri}`)
2538
+ //console.log(`[vtecxnext oauth] origin=${origin}`)
2539
+ const authorizationUrl = `${oauthUrl}?response_type=code&client_id=${client_id}&redirect_uri=${encodeURI(redirect_uri)}&state=${state}&scope=profile`;
2540
+ //console.log(`[vtecxnext oauth] authorizationUrl=${authorizationUrl}`)
2541
+ res.setHeader('Location', authorizationUrl);
2542
+ //res.setHeader('Access-Control-Allow-Origin', origin)
2543
+ //res.setHeader('Access-Control-Allow-Method', 'GET, OPTIONS')
2544
+ //console.log(`[vtecxnext oauth] response headers=${JSON.stringify(res.getHeaders())}`)
2545
+ res.writeHead(302);
2546
+ res.end();
2547
+ return true;
2548
+ };
2549
+ /**
2550
+ * OAuth authorization request
2551
+ * @param req request (for authentication)
2552
+ * @param res response (for authentication)
2553
+ * @param provider OAuth provider name
2554
+ * @param oauthUrl OAuth get accesstoken request url
2555
+ * @return {'client_id', 'client_secret', 'redirect_uri', 'state', 'access_token'}
2556
+ */
2557
+ const oauthGetAccesstoken = async (req, res, provider, accesstokenUrl) => {
2558
+ //console.log(`[vtecxnext oauthGetAccesstoken] start. provider=${provider} oauthUrl=${accesstokenUrl}`)
2559
+ // stateチェック
2560
+ const parseUrl = url_1.default.parse(req.url ? req.url : '', true);
2561
+ const state = parseUrl.query.state;
2562
+ const code = parseUrl.query.code;
2563
+ if (!state) {
2564
+ throw new VtecxNextError(401, `Could not get state on redirect.`);
2565
+ }
2566
+ if (!code) {
2567
+ throw new VtecxNextError(401, `Could not get code on redirect.`);
2568
+ }
2569
+ // vte.cxへリクエスト (stateチェック)
2570
+ const vtecxMethod = 'POST';
2571
+ const vtecxUrl = `/o/${provider}/check_state?state=${state}`;
2572
+ //console.log(`[vtecxnext oauthGetAccesstoken] vtecxUrl=${vtecxUrl}`)
2573
+ const vtecxResponse = await requestVtecx(vtecxMethod, vtecxUrl, req);
2574
+ //console.log(`[vtecxnext oauthGetAccesstoken] check_state response status=${vtecxResponse.status}`)
2575
+ // vte.cxからのset-cookieを転記
2576
+ setCookie(vtecxResponse, res);
2577
+ // レスポンスのエラーチェック
2578
+ await checkVtecxResponse(vtecxResponse);
2579
+ // 戻り値
2580
+ const data = await getJson(vtecxResponse);
2581
+ // stateチェック
2582
+ if (!data || !data.feed || !data.feed.title) {
2583
+ throw new VtecxNextError(401, `Invalid state.`);
2584
+ }
2585
+ const client_id = data.feed.subtitle;
2586
+ const client_secret = data.feed.rights;
2587
+ const redirect_uri = data.feed.link[0].___href;
2588
+ //console.log(`[vtecxnext oauthGetAccesstoken] client_id=${client_id}`)
2589
+ //console.log(`[vtecxnext oauthGetAccesstoken] client_secret=${client_secret}`)
2590
+ //console.log(`[vtecxnext oauthGetAccesstoken] redirect_uri=${redirect_uri}`)
2591
+ const encodeRedirect_uri = encodeURIComponent(redirect_uri);
2592
+ //console.log(`[vtecxnext oauthGetAccesstoken] encode redirect_uri=${encodeRedirect_uri}`)
2593
+ // アクセストークン取得URL生成
2594
+ const accesstokenMethod = 'POST';
2595
+ const accessTokenData = {
2596
+ 'grant_type': 'authorization_code',
2597
+ 'code': code,
2598
+ 'redirect_uri': redirect_uri,
2599
+ 'client_id': client_id,
2600
+ 'client_secret': client_secret
2601
+ };
2602
+ const accesstokenBody = createURLSearchParams(accessTokenData);
2603
+ //const accesstokenBodyStr = `grant_type=authorization_code&code=${code}&redirect_uri=${encodeRedirect_uri}&client_id=${client_id}&client_secret=${client_secret}`
2604
+ //console.log(`[vtecxnext oauthGetAccesstoken] accesstokenUrl=${accesstokenUrl}`)
2605
+ //console.log(`[vtecxnext oauthGetAccesstoken] accesstokenBodyStr=${accesstokenBodyStr}`)
2606
+ //const accesstokenBody = Buffer.from(accesstokenBodyStr, 'utf-8')
2607
+ const requestInit = {
2608
+ body: accesstokenBody,
2609
+ method: accesstokenMethod
2610
+ };
2611
+ const accesstokenResponse = await fetch(accesstokenUrl, requestInit);
2612
+ if (accesstokenResponse.status !== 200) {
2613
+ const errorInfo = await accesstokenResponse.json();
2614
+ //console.log(`[vtecxnext oauthGetAccesstoken] Get accesstoken failed. ${JSON.stringify(errorInfo)}`)
2615
+ const errMsg = `${'error' in errorInfo ? errorInfo.error + '. ' : ''} ${'error_description' in errorInfo ? errorInfo.error_description : ''}`;
2616
+ throw new VtecxNextError(401, `Get accesstoken failed. status=${accesstokenResponse.status} ${errMsg}`);
2617
+ }
2618
+ const accesstokenInfo = await accesstokenResponse.json();
2619
+ const access_token = accesstokenInfo.access_token;
2620
+ if (!access_token) {
2621
+ throw new VtecxNextError(401, `Get accesstoken failed.`);
2622
+ }
2623
+ return {
2624
+ 'client_id': client_id,
2625
+ 'client_secret': client_secret,
2626
+ 'redirect_uri': redirect_uri,
2627
+ 'state': state,
2628
+ 'access_token': access_token
2629
+ };
2630
+ };
2631
+ /**
2632
+ * OAuth get userinfo request
2633
+ * @param req request (for authentication)
2634
+ * @param res response (for authentication)
2635
+ * @param oauthInfo OAuth info {'client_id', 'client_secret', 'redirect_uri', 'state', 'access_token'}
2636
+ * @return userinfo {'guid', 'nickname', 'state'}
2637
+ */
2638
+ const oauthGetUserinfoLine = async (req, res, oauthInfo) => {
2639
+ //console.log(`[vtecxnext oauthGetUserinfoLine] start. oauthInfo=${JSON.stringify(oauthInfo)}`)
2640
+ // LINEユーザ識別情報取得リクエスト
2641
+ const url = 'https://api.line.me/v2/profile';
2642
+ const method = 'GET';
2643
+ const headers = { 'Authorization': `Bearer ${oauthInfo.access_token}` };
2644
+ //console.log(`[vtecxnext oauthGetUserinfoLine] url=${url}`)
2645
+ const requestInit = {
2646
+ headers: headers,
2647
+ method: method
2648
+ };
2649
+ const response = await fetch(url, requestInit);
2650
+ if (response.status !== 200) {
2651
+ throw new VtecxNextError(401, `Get user information failed. status=${response.status}`);
2652
+ }
2653
+ const userInfo = await response.json();
2654
+ const guid = 'userId' in userInfo ? userInfo.userId : undefined;
2655
+ const nickname = 'displayName' in userInfo ? userInfo.displayName : '';
2656
+ if (!guid) {
2657
+ throw new VtecxNextError(401, `Get user information failed. `);
2658
+ }
2659
+ return {
2660
+ 'guid': guid,
2661
+ 'nickname': nickname,
2662
+ 'state': oauthInfo.state
2663
+ };
2664
+ };
2665
+ /**
2666
+ * OAuth user link.
2667
+ * @param req request
2668
+ * @param res response
2669
+ * @param provider OAuth provider name
2670
+ * @param userInfo user info
2671
+ * @return true if log in has been successful.
2672
+ */
2673
+ const oauthLink = async (req, res, provider, userInfo) => {
2674
+ //console.log(`[vtecxnext oauthLink] start. userInfo=${JSON.stringify(userInfo)}`)
2675
+ // OAuthリンク・ログイン
2676
+ // reCAPTCHA tokenは任意
2677
+ //const param = reCaptchaToken ? `&g-recaptcha-token=${reCaptchaToken}` : ''
2678
+ const param = '';
2679
+ const method = 'POST';
2680
+ const url = `/o/${provider}/link?state=${userInfo.state}${param}`;
2681
+ const reqFeed = [{ 'title': userInfo.guid, 'subtitle': userInfo.nickname }];
2682
+ const response = await fetchVtecx(method, url, {}, JSON.stringify(reqFeed));
2683
+ const feed = await response.json();
2684
+ // vte.cxからのset-cookieを転記
2685
+ setCookie(response, res);
2686
+ // レスポンスのエラーチェック
2687
+ let isLoggedin;
2688
+ if (response.status < 400) {
2689
+ isLoggedin = true;
2690
+ }
2691
+ else {
2692
+ isLoggedin = false;
2693
+ }
2694
+ //console.log(`[vtecxnext oauthLink] end. status=${response.status} message=${feed.feed.title}`)
2695
+ return isLoggedin;
2696
+ };
2697
+ /**
2698
+ * URLからOriginを取得
2699
+ * @param oauthUrl URL
2700
+ * @returns Origin
2701
+ */
2702
+ const getOrigin = (oauthUrl) => {
2703
+ const tmpIdx = oauthUrl.indexOf('://') + 3;
2704
+ let idx = oauthUrl.indexOf('/', tmpIdx);
2705
+ if (idx < 0) {
2706
+ idx = oauthUrl.length;
2707
+ }
2708
+ return oauthUrl.substring(0, idx);
2709
+ };
2710
+ /**
2711
+ * URLSearchParamsを生成.
2712
+ * @param data JSON
2713
+ * @returns URLSearchParams
2714
+ */
2715
+ const createURLSearchParams = (data) => {
2716
+ const params = new url_1.URLSearchParams();
2717
+ Object.keys(data).forEach(key => params.append(key, data[key]));
2718
+ return params;
2431
2719
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtecx/vtecxnext",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "vte.cx Next.js api",
5
5
  "main": "dist/index.js",
6
6
  "files": [