@cinerino/sdk 11.0.0 → 11.1.0

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.
@@ -61,17 +61,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
62
  }
63
63
  };
64
- var __rest = (this && this.__rest) || function (s, e) {
65
- var t = {};
66
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
- t[p] = s[p];
68
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
- t[p[i]] = s[p[i]];
72
- }
73
- return t;
74
- };
75
64
  Object.defineProperty(exports, "__esModule", { value: true });
76
65
  exports.PaymentService = void 0;
77
66
  var http_status_1 = require("http-status");
@@ -90,15 +79,17 @@ var PaymentService = /** @class */ (function (_super) {
90
79
  */
91
80
  PaymentService.prototype.checkMovieTicket = function (params) {
92
81
  return __awaiter(this, void 0, void 0, function () {
82
+ var object, purpose;
93
83
  var _this = this;
94
84
  return __generator(this, function (_a) {
85
+ object = params.object, purpose = params.purpose;
95
86
  return [2 /*return*/, this.fetch({
96
87
  uri: "/payment/" + factory.service.paymentService.PaymentServiceType.MovieTicket + "/check",
97
88
  method: 'POST',
98
89
  expectedStatusCodes: [http_status_1.CREATED],
99
- body: params,
90
+ body: { object: object, purpose: purpose },
100
91
  qs: {
101
- purpose: { id: params.purpose.id } // 追加(2024-04-01~)
92
+ purpose: { id: purpose.id } // 追加(2024-04-01~)
102
93
  }
103
94
  })
104
95
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -112,16 +103,18 @@ var PaymentService = /** @class */ (function (_super) {
112
103
  */
113
104
  PaymentService.prototype.checkMovieTicketAsync = function (params) {
114
105
  return __awaiter(this, void 0, void 0, function () {
106
+ var object, purpose;
115
107
  var _this = this;
116
108
  return __generator(this, function (_a) {
109
+ object = params.object, purpose = params.purpose;
117
110
  return [2 /*return*/, this.fetch({
118
111
  uri: "/payment/" + factory.service.paymentService.PaymentServiceType.MovieTicket + "/check",
119
112
  method: 'POST',
120
113
  expectedStatusCodes: [http_status_1.ACCEPTED],
121
- body: params,
114
+ body: { object: object, purpose: purpose },
122
115
  qs: {
123
116
  async: true,
124
- purpose: { id: params.purpose.id } // 追加(2024-04-01~)
117
+ purpose: { id: purpose.id } // 追加(2024-04-01~)
125
118
  }
126
119
  })
127
120
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -135,15 +128,21 @@ var PaymentService = /** @class */ (function (_super) {
135
128
  */
136
129
  PaymentService.prototype.authorizeAnyPayment = function (params) {
137
130
  return __awaiter(this, void 0, void 0, function () {
131
+ var object, purpose, amount, issuedThrough, paymentMethod, name, additionalProperty, ticketToken;
138
132
  var _this = this;
139
133
  return __generator(this, function (_a) {
134
+ object = params.object, purpose = params.purpose;
135
+ amount = object.amount, issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, name = object.name, additionalProperty = object.additionalProperty, ticketToken = object.ticketToken;
140
136
  return [2 /*return*/, this.fetch({
141
137
  uri: "/payment/" + factory.service.paymentService.PaymentServiceType.FaceToFace + "/authorize",
142
138
  method: 'POST',
143
139
  expectedStatusCodes: [http_status_1.CREATED],
144
- body: params,
140
+ body: {
141
+ object: __assign(__assign(__assign({ amount: amount, issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (typeof name === 'string') ? { name: name } : undefined), (typeof ticketToken === 'string') ? { ticketToken: ticketToken } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty: additionalProperty } : undefined),
142
+ purpose: purpose
143
+ },
145
144
  qs: {
146
- purpose: { id: params.purpose.id } // 追加(2024-04-01~)
145
+ purpose: { id: purpose.id } // 追加(2024-04-01~)
147
146
  }
148
147
  })
149
148
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -157,14 +156,20 @@ var PaymentService = /** @class */ (function (_super) {
157
156
  */
158
157
  PaymentService.prototype.authorizeCreditCard = function (params, options) {
159
158
  return __awaiter(this, void 0, void 0, function () {
159
+ var object, purpose, amount, issuedThrough, paymentMethod, creditCard, method, paymentMethodId, name, additionalProperty, ticketToken;
160
160
  var _this = this;
161
161
  return __generator(this, function (_a) {
162
+ object = params.object, purpose = params.purpose;
163
+ amount = object.amount, issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, creditCard = object.creditCard, method = object.method, paymentMethodId = object.paymentMethodId, name = object.name, additionalProperty = object.additionalProperty, ticketToken = object.ticketToken;
162
164
  return [2 /*return*/, this.fetch({
163
165
  uri: "/payment/" + factory.service.paymentService.PaymentServiceType.CreditCard + "/authorize",
164
166
  method: 'POST',
165
167
  expectedStatusCodes: [http_status_1.ACCEPTED, http_status_1.CREATED],
166
- body: params,
167
- qs: __assign(__assign({}, options), { purpose: { id: params.purpose.id } // 追加(2024-04-01~)
168
+ body: {
169
+ object: __assign(__assign(__assign(__assign(__assign(__assign({ amount: amount, issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (creditCard !== undefined && creditCard !== null) ? { creditCard: creditCard } : undefined), (typeof name === 'string') ? { name: name } : undefined), (typeof method === 'string') ? { method: method } : undefined), (typeof paymentMethodId === 'string') ? { paymentMethodId: paymentMethodId } : undefined), (typeof ticketToken === 'string') ? { ticketToken: ticketToken } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty: additionalProperty } : undefined),
170
+ purpose: purpose
171
+ },
172
+ qs: __assign(__assign({}, options), { purpose: { id: purpose.id } // 追加(2024-04-01~)
168
173
  })
169
174
  })
170
175
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -178,14 +183,20 @@ var PaymentService = /** @class */ (function (_super) {
178
183
  */
179
184
  PaymentService.prototype.authorizeMovieTicket = function (params, options) {
180
185
  return __awaiter(this, void 0, void 0, function () {
186
+ var object, purpose, issuedThrough, paymentMethod, movieTickets, name, additionalProperty, ticketToken;
181
187
  var _this = this;
182
188
  return __generator(this, function (_a) {
189
+ object = params.object, purpose = params.purpose;
190
+ issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, movieTickets = object.movieTickets, name = object.name, additionalProperty = object.additionalProperty, ticketToken = object.ticketToken;
183
191
  return [2 /*return*/, this.fetch({
184
192
  uri: "/payment/" + factory.service.paymentService.PaymentServiceType.MovieTicket + "/authorize",
185
193
  method: 'POST',
186
194
  expectedStatusCodes: [http_status_1.ACCEPTED, http_status_1.CREATED],
187
- body: params,
188
- qs: __assign(__assign({}, options), { purpose: { id: params.purpose.id } // 追加(2024-04-01~)
195
+ body: {
196
+ object: __assign(__assign(__assign(__assign({ issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (Array.isArray(movieTickets)) ? { movieTickets: movieTickets } : undefined), (typeof name === 'string') ? { name: name } : undefined), (typeof ticketToken === 'string') ? { ticketToken: ticketToken } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty: additionalProperty } : undefined),
197
+ purpose: purpose
198
+ },
199
+ qs: __assign(__assign({}, options), { purpose: { id: purpose.id } // 追加(2024-04-01~)
189
200
  })
190
201
  })
191
202
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -199,15 +210,21 @@ var PaymentService = /** @class */ (function (_super) {
199
210
  */
200
211
  PaymentService.prototype.authorizePaymentCard = function (params) {
201
212
  return __awaiter(this, void 0, void 0, function () {
213
+ var object, purpose, amount, issuedThrough, paymentMethod, name, additionalProperty, fromLocation, description;
202
214
  var _this = this;
203
215
  return __generator(this, function (_a) {
216
+ object = params.object, purpose = params.purpose;
217
+ amount = object.amount, issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, name = object.name, additionalProperty = object.additionalProperty, fromLocation = object.fromLocation, description = object.description;
204
218
  return [2 /*return*/, this.fetch({
205
219
  uri: "/payment/" + factory.product.ProductType.PaymentCard + "/authorize",
206
220
  method: 'POST',
207
221
  expectedStatusCodes: [http_status_1.CREATED],
208
- body: params,
222
+ body: {
223
+ object: __assign(__assign(__assign(__assign({ amount: amount, issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (typeof fromLocation === 'string') ? { fromLocation: fromLocation } : undefined), (typeof name === 'string') ? { name: name } : undefined), (typeof description === 'string') ? { description: description } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty: additionalProperty } : undefined),
224
+ purpose: purpose
225
+ },
209
226
  qs: {
210
- purpose: { id: params.purpose.id } // 追加(2024-04-01~)
227
+ purpose: { id: purpose.id } // 追加(2024-04-01~)
211
228
  }
212
229
  })
213
230
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -221,15 +238,19 @@ var PaymentService = /** @class */ (function (_super) {
221
238
  */
222
239
  PaymentService.prototype.publishCreditCardPaymentUrlAsync = function (params) {
223
240
  return __awaiter(this, void 0, void 0, function () {
224
- var object, purpose;
241
+ var object, purpose, amount, creditCard, issuedThrough, paymentMethod, method, ticketToken;
225
242
  var _this = this;
226
243
  return __generator(this, function (_a) {
227
244
  object = params.object, purpose = params.purpose;
245
+ amount = object.amount, creditCard = object.creditCard, issuedThrough = object.issuedThrough, paymentMethod = object.paymentMethod, method = object.method, ticketToken = object.ticketToken;
228
246
  return [2 /*return*/, this.fetch({
229
247
  uri: "/payment/" + factory.service.paymentService.PaymentServiceType.CreditCard + "/publishPaymentUrl",
230
248
  method: 'POST',
231
249
  expectedStatusCodes: [http_status_1.ACCEPTED],
232
- body: { object: object, purpose: purpose },
250
+ body: {
251
+ object: __assign(__assign(__assign({ amount: amount, issuedThrough: issuedThrough, paymentMethod: paymentMethod }, (creditCard !== undefined && creditCard !== null) ? { creditCard: creditCard } : undefined), (typeof method === 'string') ? { method: method } : undefined), (typeof ticketToken === 'string') ? { ticketToken: ticketToken } : undefined),
252
+ purpose: purpose
253
+ },
233
254
  qs: {
234
255
  async: true,
235
256
  purpose: { id: purpose.id } // 追加(2024-04-01~)
@@ -246,18 +267,18 @@ var PaymentService = /** @class */ (function (_super) {
246
267
  */
247
268
  PaymentService.prototype.voidAnyPayment = function (params) {
248
269
  return __awaiter(this, void 0, void 0, function () {
249
- var id, body;
270
+ var id, purpose;
250
271
  return __generator(this, function (_a) {
251
272
  switch (_a.label) {
252
273
  case 0:
253
- id = params.id, body = __rest(params, ["id"]);
274
+ id = params.id, purpose = params.purpose;
254
275
  return [4 /*yield*/, this.fetch({
255
276
  uri: "/payment/" + factory.service.paymentService.PaymentServiceType.FaceToFace + "/authorize/" + id + "/void",
256
277
  method: 'PUT',
257
278
  expectedStatusCodes: [http_status_1.NO_CONTENT],
258
- body: body,
279
+ body: { purpose: purpose },
259
280
  qs: {
260
- purpose: { id: params.purpose.id } // 追加(2024-04-01~)
281
+ purpose: { id: purpose.id } // 追加(2024-04-01~)
261
282
  }
262
283
  })];
263
284
  case 1:
@@ -272,18 +293,18 @@ var PaymentService = /** @class */ (function (_super) {
272
293
  */
273
294
  PaymentService.prototype.voidTransaction = function (params) {
274
295
  return __awaiter(this, void 0, void 0, function () {
275
- var id, object, body;
296
+ var id, object, purpose;
276
297
  return __generator(this, function (_a) {
277
298
  switch (_a.label) {
278
299
  case 0:
279
- id = params.id, object = params.object, body = __rest(params, ["id", "object"]);
300
+ id = params.id, object = params.object, purpose = params.purpose;
280
301
  return [4 /*yield*/, this.fetch({
281
302
  uri: "/payment/" + object.typeOf + "/authorize/" + id + "/void",
282
303
  method: 'PUT',
283
304
  expectedStatusCodes: [http_status_1.NO_CONTENT],
284
- body: body,
305
+ body: { purpose: purpose },
285
306
  qs: {
286
- purpose: { id: params.purpose.id } // 追加(2024-04-01~)
307
+ purpose: { id: purpose.id } // 追加(2024-04-01~)
287
308
  }
288
309
  })];
289
310
  case 1:
@@ -413,7 +434,7 @@ var PaymentService = /** @class */ (function (_super) {
413
434
  expectedStatusCodes: [http_status_1.CREATED],
414
435
  body: { purpose: purpose },
415
436
  qs: {
416
- purpose: { id: params.purpose.id }
437
+ purpose: { id: purpose.id }
417
438
  }
418
439
  })
419
440
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -434,7 +455,7 @@ var PaymentService = /** @class */ (function (_super) {
434
455
  expectedStatusCodes: [http_status_1.CREATED],
435
456
  body: { purpose: purpose, ticketedPermit: ticketedPermit },
436
457
  qs: {
437
- purpose: { id: params.purpose.id }
458
+ purpose: { id: purpose.id }
438
459
  }
439
460
  })
440
461
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -455,7 +476,7 @@ var PaymentService = /** @class */ (function (_super) {
455
476
  expectedStatusCodes: [http_status_1.CREATED],
456
477
  body: { purpose: purpose, ticketedInvoice: ticketedInvoice },
457
478
  qs: {
458
- purpose: { id: params.purpose.id }
479
+ purpose: { id: purpose.id }
459
480
  }
460
481
  })
461
482
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
@@ -1,20 +1,21 @@
1
- import * as factory from '../../factory';
1
+ import type { IFindMyProjectConditions, IFindMySellerConditions, IMyProject, IMySeller } from '../../chevreAdmin/me';
2
2
  import { IOptions, Service } from '../../service';
3
- export interface ISearchProjectConditions {
4
- limit?: number;
5
- page?: number;
6
- id?: {
7
- $eq?: string;
8
- $regex?: string;
9
- };
10
- }
11
3
  /**
12
- * 管理者サービス
4
+ * 管理者(自分自身)サービス
13
5
  */
14
6
  export declare class MeService extends Service<IOptions> {
15
7
  constructor(options: Pick<IOptions, 'auth' | 'endpoint' | 'transporter' | 'defaultPath'>);
16
8
  /**
17
9
  * マイプロジェクト検索
18
10
  */
19
- searchProjects(params: ISearchProjectConditions): Promise<Pick<factory.project.IProject, 'id' | 'logo' | 'name'>[]>;
11
+ searchProjects(params: IFindMyProjectConditions): Promise<IMyProject[]>;
12
+ /**
13
+ * マイ販売者検索
14
+ */
15
+ findMySellers(params: {
16
+ project: {
17
+ id: string;
18
+ };
19
+ conditions: IFindMySellerConditions;
20
+ }): Promise<IMySeller[]>;
20
21
  }
@@ -66,7 +66,7 @@ exports.MeService = void 0;
66
66
  var index_1 = require("../../index");
67
67
  var service_1 = require("../../service");
68
68
  /**
69
- * 管理者サービス
69
+ * 管理者(自分自身)サービス
70
70
  */
71
71
  var MeService = /** @class */ (function (_super) {
72
72
  __extends(MeService, _super);
@@ -94,6 +94,27 @@ var MeService = /** @class */ (function (_super) {
94
94
  });
95
95
  });
96
96
  };
97
+ /**
98
+ * マイ販売者検索
99
+ */
100
+ MeService.prototype.findMySellers = function (params) {
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ var _a, auth, endpoint, chevreAdmin, meService;
103
+ return __generator(this, function (_b) {
104
+ switch (_b.label) {
105
+ case 0:
106
+ _a = this.options, auth = _a.auth, endpoint = _a.endpoint;
107
+ return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint })];
108
+ case 1:
109
+ chevreAdmin = _b.sent();
110
+ return [4 /*yield*/, chevreAdmin.createMeInstance()];
111
+ case 2:
112
+ meService = _b.sent();
113
+ return [2 /*return*/, meService.findMySellers(params)];
114
+ }
115
+ });
116
+ });
117
+ };
97
118
  return MeService;
98
119
  }(service_1.Service));
99
120
  exports.MeService = MeService;
@@ -1,4 +1,4 @@
1
- import ICredentials from './credentials';
1
+ import { ICredentials } from './credentials';
2
2
  import OAuth2client from './oAuth2client';
3
3
  export interface IOptions {
4
4
  domain: string;
@@ -31,4 +31,4 @@ interface ICredentials {
31
31
  idTokenPayload?: any;
32
32
  state?: string;
33
33
  }
34
- export default ICredentials;
34
+ export { ICredentials };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type { AuthClient } from '../abstract/auth/authClient';
3
- import type ICredentials from './credentials';
3
+ import { ICredentials } from './credentials';
4
4
  import { LoginTicket } from './loginTicket';
5
5
  export declare const MAX_RETRY_NUM = 2;
6
6
  export interface IGenerateAuthUrlOpts {
@@ -8,6 +8,8 @@ export interface IGenerateAuthUrlOpts {
8
8
  state: string;
9
9
  codeVerifier?: string;
10
10
  }
11
+ declare type IOnTokenRefreshedParams = Pick<ICredentials, 'access_token' | 'expiry_date' | 'id_token' | 'token_type' | 'refresh_token'>;
12
+ declare type IOnTokenRefreshed = (params: IOnTokenRefreshedParams) => Promise<void>;
11
13
  export interface IOptions {
12
14
  domain: string;
13
15
  clientId?: string;
@@ -47,6 +49,10 @@ export default class OAuth2client implements AuthClient {
47
49
  */
48
50
  credentials: ICredentials;
49
51
  options: IOptions;
52
+ /**
53
+ * 認証クライアントインスタンス内で発生するイベント
54
+ */
55
+ private readonly events;
50
56
  constructor(options: IOptions);
51
57
  static BASE64URLENCODE(str: Buffer): string;
52
58
  static SHA256(buffer: any): Buffer;
@@ -89,6 +95,10 @@ export default class OAuth2client implements AuthClient {
89
95
  * 結果にはIDトークンの付加情報が含まれます。
90
96
  */
91
97
  verifyIdToken(options: IVerifyIdTokenOptions): LoginTicket;
98
+ /**
99
+ * トークン更新イベントハンドラを登録する
100
+ */
101
+ onTokenRefreshed(params: IOnTokenRefreshed): void;
92
102
  /**
93
103
  * Provides a request implementation with OAuth 2.0 flow.
94
104
  * If credentials have a refresh_token, in cases of HTTP
@@ -120,3 +130,4 @@ export default class OAuth2client implements AuthClient {
120
130
  */
121
131
  private verifySignedJwt;
122
132
  }
133
+ export {};
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -70,6 +81,7 @@ var OAuth2client = /** @class */ (function () {
70
81
  // TODO add minimum validation
71
82
  this.options = options;
72
83
  this.credentials = {};
84
+ this.events = {};
73
85
  }
74
86
  OAuth2client.BASE64URLENCODE = function (str) {
75
87
  return str.toString('base64')
@@ -188,12 +200,22 @@ var OAuth2client = /** @class */ (function () {
188
200
  throw new Error('No refresh token is set.');
189
201
  }
190
202
  return [2 /*return*/, this.refreshToken(this.credentials.refresh_token)
191
- .then(function (tokens) {
192
- tokens.refresh_token = _this.credentials.refresh_token;
193
- debug('setting credentials...', tokens);
194
- _this.credentials = tokens;
195
- return _this.credentials;
196
- })];
203
+ .then(function (refreshTokenResult) { return __awaiter(_this, void 0, void 0, function () {
204
+ return __generator(this, function (_a) {
205
+ switch (_a.label) {
206
+ case 0:
207
+ // tokens.refresh_token = this.credentials.refresh_token;
208
+ debug('setting credentials...', refreshTokenResult);
209
+ this.credentials = __assign(__assign({}, refreshTokenResult), { refresh_token: this.credentials.refresh_token });
210
+ if (!(typeof this.events.onTokenRefreshed === 'function')) return [3 /*break*/, 2];
211
+ return [4 /*yield*/, this.events.onTokenRefreshed(this.credentials)];
212
+ case 1:
213
+ _a.sent();
214
+ _a.label = 2;
215
+ case 2: return [2 /*return*/, this.credentials];
216
+ }
217
+ });
218
+ }); })];
197
219
  });
198
220
  });
199
221
  };
@@ -339,6 +361,12 @@ var OAuth2client = /** @class */ (function () {
339
361
  // return this.verifySignedJwt(options.idToken, options.audience, OAuth2Client.ISSUERS_);
340
362
  return this.verifySignedJwt(this.credentials.id_token, options.audience);
341
363
  };
364
+ /**
365
+ * トークン更新イベントハンドラを登録する
366
+ */
367
+ OAuth2client.prototype.onTokenRefreshed = function (params) {
368
+ this.events.onTokenRefreshed = params;
369
+ };
342
370
  /**
343
371
  * Provides a request implementation with OAuth 2.0 flow.
344
372
  * If credentials have a refresh_token, in cases of HTTP
@@ -404,7 +432,7 @@ var OAuth2client = /** @class */ (function () {
404
432
  debug('fetching...', options);
405
433
  return [2 /*return*/, fetch("https://" + this.options.domain + OAuth2client.OAUTH2_TOKEN_URI, options)
406
434
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
407
- var body, body, tokens;
435
+ var body, body, result, refreshTokenResponse, access_token, id_token, expires_in, token_type;
408
436
  return __generator(this, function (_a) {
409
437
  switch (_a.label) {
410
438
  case 0:
@@ -420,17 +448,29 @@ var OAuth2client = /** @class */ (function () {
420
448
  body = _a.sent();
421
449
  throw new Error(body);
422
450
  case 4: return [3 /*break*/, 7];
423
- case 5: return [4 /*yield*/, response.json()];
451
+ case 5:
452
+ result = void 0;
453
+ return [4 /*yield*/, response.json()];
424
454
  case 6:
425
- tokens = _a.sent();
455
+ refreshTokenResponse = _a.sent();
426
456
  // tslint:disable-next-line:no-single-line-block-comment
427
457
  /* istanbul ignore else */
428
- if (tokens && tokens.expires_in) {
429
- // tslint:disable-next-line:no-magic-numbers
430
- tokens.expiry_date = ((new Date()).getTime() + (tokens.expires_in * 1000));
431
- delete tokens.expires_in;
458
+ if (refreshTokenResponse !== undefined && typeof refreshTokenResponse.expires_in === 'number') {
459
+ access_token = refreshTokenResponse.access_token, id_token = refreshTokenResponse.id_token, expires_in = refreshTokenResponse.expires_in, token_type = refreshTokenResponse.token_type;
460
+ result = {
461
+ access_token: access_token, id_token: id_token, token_type: token_type,
462
+ // tslint:disable-next-line:no-magic-numbers
463
+ expiry_date: ((new Date()).getTime() + (expires_in * 1000))
464
+ };
465
+ // delete tokens.expires_in;
432
466
  }
433
- return [2 /*return*/, tokens];
467
+ else {
468
+ // 想定していないリフレッシュトークンレスポンスはログ出力
469
+ // tslint:disable-next-line:no-console
470
+ console.error('unexpected refreshToken response:', refreshTokenResponse);
471
+ throw new Error('unexpected refreshToken response.');
472
+ }
473
+ return [2 /*return*/, result];
434
474
  case 7: return [2 /*return*/];
435
475
  }
436
476
  });