@cinerino/sdk 11.0.0-alpha.9 → 11.1.0-alpha.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.
- package/example/playground/public/lib/bundle.js +4 -2
- package/example/src/auth/authAsAdmin.ts +6 -3
- package/example/src/cloud/transaction/processPlaceOrderByCreditCard3DS.ts +17 -4
- package/lib/abstract/chevrePay/payment/factory.d.ts +1 -1
- package/lib/abstract/chevrePay/payment.js +4 -2
- package/lib/auth/clientCredentialsClient.d.ts +1 -1
- package/lib/auth/credentials.d.ts +1 -1
- package/lib/auth/oAuth2client.d.ts +12 -1
- package/lib/auth/oAuth2client.js +54 -14
- package/lib/bundle.js +58 -16
- package/package.json +1 -1
|
@@ -15831,16 +15831,18 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
15831
15831
|
*/
|
|
15832
15832
|
PaymentService.prototype.publishCreditCardPaymentUrlAsync = function (params) {
|
|
15833
15833
|
return __awaiter(this, void 0, void 0, function () {
|
|
15834
|
+
var object, purpose;
|
|
15834
15835
|
var _this = this;
|
|
15835
15836
|
return __generator(this, function (_a) {
|
|
15837
|
+
object = params.object, purpose = params.purpose;
|
|
15836
15838
|
return [2 /*return*/, this.fetch({
|
|
15837
15839
|
uri: "/payment/" + factory.service.paymentService.PaymentServiceType.CreditCard + "/publishPaymentUrl",
|
|
15838
15840
|
method: 'POST',
|
|
15839
15841
|
expectedStatusCodes: [http_status_1.ACCEPTED],
|
|
15840
|
-
body:
|
|
15842
|
+
body: { object: object, purpose: purpose },
|
|
15841
15843
|
qs: {
|
|
15842
15844
|
async: true,
|
|
15843
|
-
purpose: { id:
|
|
15845
|
+
purpose: { id: purpose.id } // 追加(2024-04-01~)
|
|
15844
15846
|
}
|
|
15845
15847
|
})
|
|
15846
15848
|
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
@@ -15,6 +15,9 @@ export async function login() {
|
|
|
15
15
|
redirectUri: 'https://localhost/signIn',
|
|
16
16
|
logoutUri: 'https://localhost/signOut'
|
|
17
17
|
});
|
|
18
|
+
auth.onTokenRefreshed(async (params) => {
|
|
19
|
+
console.log('onTokenRefreshed called.', params);
|
|
20
|
+
});
|
|
18
21
|
|
|
19
22
|
const scopes: string[] = [];
|
|
20
23
|
const state = '12345';
|
|
@@ -48,13 +51,13 @@ export async function login() {
|
|
|
48
51
|
return;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
const credentials = await auth.getToken(code, codeVerifier);
|
|
52
55
|
// console.log('credentials published', credentials);
|
|
53
56
|
|
|
54
57
|
auth.setCredentials(credentials);
|
|
55
58
|
|
|
56
|
-
credentials = await auth.refreshAccessToken();
|
|
57
|
-
console.log('credentials refreshed', credentials);
|
|
59
|
+
// credentials = await auth.refreshAccessToken();
|
|
60
|
+
// console.log('credentials refreshed', credentials);
|
|
58
61
|
|
|
59
62
|
// rl.close();
|
|
60
63
|
resolve();
|
|
@@ -113,6 +113,17 @@ async function main() {
|
|
|
113
113
|
authorizeSeatReservationResults.push(authorizeSeatReservationResult);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// 出力メンバーシップ対応の場合チケット発行
|
|
117
|
+
const { ticketToken } = await paymentService.issueTicketThroughCreditCard({
|
|
118
|
+
ticketedPermit: {
|
|
119
|
+
issuedThrough: {
|
|
120
|
+
id: paymentServiceId
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
124
|
+
});
|
|
125
|
+
console.log('ticketToken issued.', ticketToken);
|
|
126
|
+
|
|
116
127
|
// 決済URL発行
|
|
117
128
|
const { paymentMethodId, paymentUrl } = await publishPaymentUrlAsyncForcibly({
|
|
118
129
|
object: {
|
|
@@ -123,7 +134,8 @@ async function main() {
|
|
|
123
134
|
...creditCard,
|
|
124
135
|
retUrl: String(process.env.SECURE_TRAN_RET_URL) // callbackを指定すると3DSとして処理される
|
|
125
136
|
},
|
|
126
|
-
issuedThrough: { id: paymentServiceId }
|
|
137
|
+
issuedThrough: { id: paymentServiceId },
|
|
138
|
+
ticketToken
|
|
127
139
|
},
|
|
128
140
|
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
129
141
|
})({ paymentService });
|
|
@@ -172,7 +184,8 @@ async function main() {
|
|
|
172
184
|
paymentMethodId, // URL発行時のpaymentMethodIdを指定
|
|
173
185
|
method: '1',
|
|
174
186
|
creditCard,
|
|
175
|
-
issuedThrough: { id: paymentServiceId }
|
|
187
|
+
issuedThrough: { id: paymentServiceId },
|
|
188
|
+
ticketToken
|
|
176
189
|
},
|
|
177
190
|
purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
|
|
178
191
|
})({ paymentService });
|
|
@@ -385,7 +398,7 @@ async function wait(waitInMilliseconds: number) {
|
|
|
385
398
|
const USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_GIVE_UP_SECONDS = 10;
|
|
386
399
|
const USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_CHECK_INTERVAL_MS = 1000;
|
|
387
400
|
function publishPaymentUrlAsyncForcibly(params: {
|
|
388
|
-
object: Pick<client.factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'creditCard' | 'issuedThrough' | 'paymentMethod' | 'method'>;
|
|
401
|
+
object: Pick<client.factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'creditCard' | 'issuedThrough' | 'paymentMethod' | 'method' | 'ticketToken'>;
|
|
389
402
|
purpose: {
|
|
390
403
|
typeOf: client.factory.transactionType.PlaceOrder;
|
|
391
404
|
id: string;
|
|
@@ -443,7 +456,7 @@ function publishPaymentUrlAsyncForcibly(params: {
|
|
|
443
456
|
function authorizeCreditCardAsyncForcibly(params: {
|
|
444
457
|
object: Pick<
|
|
445
458
|
client.factory.action.authorize.paymentMethod.any.IObjectWithoutDetail,
|
|
446
|
-
'amount' | 'issuedThrough' | 'paymentMethod' | 'creditCard' | 'method' | 'paymentMethodId' | 'name' | 'additionalProperty'
|
|
459
|
+
'amount' | 'issuedThrough' | 'paymentMethod' | 'creditCard' | 'method' | 'paymentMethodId' | 'name' | 'additionalProperty' | 'ticketToken'
|
|
447
460
|
>;
|
|
448
461
|
purpose: {
|
|
449
462
|
typeOf: client.factory.transactionType.PlaceOrder;
|
|
@@ -37,7 +37,7 @@ export declare type IAuthorizeMovieTicketObject = Pick<factory.action.authorize.
|
|
|
37
37
|
export declare type IAuthorizePaymentCardObject = Pick<factory.action.authorize.paymentMethod.any.IAuthorizePaymentCardObject, 'amount' | 'issuedThrough' | 'paymentMethod' | 'fromLocation' | 'name' | 'additionalProperty'> & {
|
|
38
38
|
description?: string;
|
|
39
39
|
};
|
|
40
|
-
export declare type IPublishPaymentUrlObject = Pick<factory.action.authorize.paymentMethod.any.IAuthorizeCreditCardObject, 'amount' | 'creditCard' | 'issuedThrough' | 'paymentMethod' | 'method'>;
|
|
40
|
+
export declare type IPublishPaymentUrlObject = Pick<factory.action.authorize.paymentMethod.any.IAuthorizeCreditCardObject, 'amount' | 'creditCard' | 'issuedThrough' | 'paymentMethod' | 'method' | 'ticketToken'>;
|
|
41
41
|
export declare type IPublishPaymentUrlResult = Pick<factory.action.accept.pay.IResult, 'paymentMethodId' | 'paymentUrl'>;
|
|
42
42
|
export interface IFindAuthorizeActionResult {
|
|
43
43
|
/**
|
|
@@ -221,16 +221,18 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
221
221
|
*/
|
|
222
222
|
PaymentService.prototype.publishCreditCardPaymentUrlAsync = function (params) {
|
|
223
223
|
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
+
var object, purpose;
|
|
224
225
|
var _this = this;
|
|
225
226
|
return __generator(this, function (_a) {
|
|
227
|
+
object = params.object, purpose = params.purpose;
|
|
226
228
|
return [2 /*return*/, this.fetch({
|
|
227
229
|
uri: "/payment/" + factory.service.paymentService.PaymentServiceType.CreditCard + "/publishPaymentUrl",
|
|
228
230
|
method: 'POST',
|
|
229
231
|
expectedStatusCodes: [http_status_1.ACCEPTED],
|
|
230
|
-
body:
|
|
232
|
+
body: { object: object, purpose: purpose },
|
|
231
233
|
qs: {
|
|
232
234
|
async: true,
|
|
233
|
-
purpose: { id:
|
|
235
|
+
purpose: { id: purpose.id } // 追加(2024-04-01~)
|
|
234
236
|
}
|
|
235
237
|
})
|
|
236
238
|
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { AuthClient } from '../abstract/auth/authClient';
|
|
3
|
-
import
|
|
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 {};
|
package/lib/auth/oAuth2client.js
CHANGED
|
@@ -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 (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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,
|
|
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:
|
|
451
|
+
case 5:
|
|
452
|
+
result = void 0;
|
|
453
|
+
return [4 /*yield*/, response.json()];
|
|
424
454
|
case 6:
|
|
425
|
-
|
|
455
|
+
refreshTokenResponse = _a.sent();
|
|
426
456
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
427
457
|
/* istanbul ignore else */
|
|
428
|
-
if (
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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
|
-
|
|
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
|
});
|
package/lib/bundle.js
CHANGED
|
@@ -17193,16 +17193,18 @@ var PaymentService = /** @class */ (function (_super) {
|
|
|
17193
17193
|
*/
|
|
17194
17194
|
PaymentService.prototype.publishCreditCardPaymentUrlAsync = function (params) {
|
|
17195
17195
|
return __awaiter(this, void 0, void 0, function () {
|
|
17196
|
+
var object, purpose;
|
|
17196
17197
|
var _this = this;
|
|
17197
17198
|
return __generator(this, function (_a) {
|
|
17199
|
+
object = params.object, purpose = params.purpose;
|
|
17198
17200
|
return [2 /*return*/, this.fetch({
|
|
17199
17201
|
uri: "/payment/" + factory.service.paymentService.PaymentServiceType.CreditCard + "/publishPaymentUrl",
|
|
17200
17202
|
method: 'POST',
|
|
17201
17203
|
expectedStatusCodes: [http_status_1.ACCEPTED],
|
|
17202
|
-
body:
|
|
17204
|
+
body: { object: object, purpose: purpose },
|
|
17203
17205
|
qs: {
|
|
17204
17206
|
async: true,
|
|
17205
|
-
purpose: { id:
|
|
17207
|
+
purpose: { id: purpose.id } // 追加(2024-04-01~)
|
|
17206
17208
|
}
|
|
17207
17209
|
})
|
|
17208
17210
|
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
@@ -27224,6 +27226,17 @@ exports.LoginTicket = LoginTicket;
|
|
|
27224
27226
|
},{}],173:[function(require,module,exports){
|
|
27225
27227
|
(function (Buffer){
|
|
27226
27228
|
"use strict";
|
|
27229
|
+
var __assign = (this && this.__assign) || function () {
|
|
27230
|
+
__assign = Object.assign || function(t) {
|
|
27231
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
27232
|
+
s = arguments[i];
|
|
27233
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
27234
|
+
t[p] = s[p];
|
|
27235
|
+
}
|
|
27236
|
+
return t;
|
|
27237
|
+
};
|
|
27238
|
+
return __assign.apply(this, arguments);
|
|
27239
|
+
};
|
|
27227
27240
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27228
27241
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27229
27242
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -27295,6 +27308,7 @@ var OAuth2client = /** @class */ (function () {
|
|
|
27295
27308
|
// TODO add minimum validation
|
|
27296
27309
|
this.options = options;
|
|
27297
27310
|
this.credentials = {};
|
|
27311
|
+
this.events = {};
|
|
27298
27312
|
}
|
|
27299
27313
|
OAuth2client.BASE64URLENCODE = function (str) {
|
|
27300
27314
|
return str.toString('base64')
|
|
@@ -27413,12 +27427,22 @@ var OAuth2client = /** @class */ (function () {
|
|
|
27413
27427
|
throw new Error('No refresh token is set.');
|
|
27414
27428
|
}
|
|
27415
27429
|
return [2 /*return*/, this.refreshToken(this.credentials.refresh_token)
|
|
27416
|
-
.then(function (
|
|
27417
|
-
|
|
27418
|
-
|
|
27419
|
-
|
|
27420
|
-
|
|
27421
|
-
|
|
27430
|
+
.then(function (refreshTokenResult) { return __awaiter(_this, void 0, void 0, function () {
|
|
27431
|
+
return __generator(this, function (_a) {
|
|
27432
|
+
switch (_a.label) {
|
|
27433
|
+
case 0:
|
|
27434
|
+
// tokens.refresh_token = this.credentials.refresh_token;
|
|
27435
|
+
debug('setting credentials...', refreshTokenResult);
|
|
27436
|
+
this.credentials = __assign(__assign({}, refreshTokenResult), { refresh_token: this.credentials.refresh_token });
|
|
27437
|
+
if (!(typeof this.events.onTokenRefreshed === 'function')) return [3 /*break*/, 2];
|
|
27438
|
+
return [4 /*yield*/, this.events.onTokenRefreshed(this.credentials)];
|
|
27439
|
+
case 1:
|
|
27440
|
+
_a.sent();
|
|
27441
|
+
_a.label = 2;
|
|
27442
|
+
case 2: return [2 /*return*/, this.credentials];
|
|
27443
|
+
}
|
|
27444
|
+
});
|
|
27445
|
+
}); })];
|
|
27422
27446
|
});
|
|
27423
27447
|
});
|
|
27424
27448
|
};
|
|
@@ -27564,6 +27588,12 @@ var OAuth2client = /** @class */ (function () {
|
|
|
27564
27588
|
// return this.verifySignedJwt(options.idToken, options.audience, OAuth2Client.ISSUERS_);
|
|
27565
27589
|
return this.verifySignedJwt(this.credentials.id_token, options.audience);
|
|
27566
27590
|
};
|
|
27591
|
+
/**
|
|
27592
|
+
* トークン更新イベントハンドラを登録する
|
|
27593
|
+
*/
|
|
27594
|
+
OAuth2client.prototype.onTokenRefreshed = function (params) {
|
|
27595
|
+
this.events.onTokenRefreshed = params;
|
|
27596
|
+
};
|
|
27567
27597
|
/**
|
|
27568
27598
|
* Provides a request implementation with OAuth 2.0 flow.
|
|
27569
27599
|
* If credentials have a refresh_token, in cases of HTTP
|
|
@@ -27629,7 +27659,7 @@ var OAuth2client = /** @class */ (function () {
|
|
|
27629
27659
|
debug('fetching...', options);
|
|
27630
27660
|
return [2 /*return*/, fetch("https://" + this.options.domain + OAuth2client.OAUTH2_TOKEN_URI, options)
|
|
27631
27661
|
.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
27632
|
-
var body, body,
|
|
27662
|
+
var body, body, result, refreshTokenResponse, access_token, id_token, expires_in, token_type;
|
|
27633
27663
|
return __generator(this, function (_a) {
|
|
27634
27664
|
switch (_a.label) {
|
|
27635
27665
|
case 0:
|
|
@@ -27645,17 +27675,29 @@ var OAuth2client = /** @class */ (function () {
|
|
|
27645
27675
|
body = _a.sent();
|
|
27646
27676
|
throw new Error(body);
|
|
27647
27677
|
case 4: return [3 /*break*/, 7];
|
|
27648
|
-
case 5:
|
|
27678
|
+
case 5:
|
|
27679
|
+
result = void 0;
|
|
27680
|
+
return [4 /*yield*/, response.json()];
|
|
27649
27681
|
case 6:
|
|
27650
|
-
|
|
27682
|
+
refreshTokenResponse = _a.sent();
|
|
27651
27683
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
27652
27684
|
/* istanbul ignore else */
|
|
27653
|
-
if (
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
|
|
27685
|
+
if (refreshTokenResponse !== undefined && typeof refreshTokenResponse.expires_in === 'number') {
|
|
27686
|
+
access_token = refreshTokenResponse.access_token, id_token = refreshTokenResponse.id_token, expires_in = refreshTokenResponse.expires_in, token_type = refreshTokenResponse.token_type;
|
|
27687
|
+
result = {
|
|
27688
|
+
access_token: access_token, id_token: id_token, token_type: token_type,
|
|
27689
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
27690
|
+
expiry_date: ((new Date()).getTime() + (expires_in * 1000))
|
|
27691
|
+
};
|
|
27692
|
+
// delete tokens.expires_in;
|
|
27657
27693
|
}
|
|
27658
|
-
|
|
27694
|
+
else {
|
|
27695
|
+
// 想定していないリフレッシュトークンレスポンスはログ出力
|
|
27696
|
+
// tslint:disable-next-line:no-console
|
|
27697
|
+
console.error('unexpected refreshToken response:', refreshTokenResponse);
|
|
27698
|
+
throw new Error('unexpected refreshToken response.');
|
|
27699
|
+
}
|
|
27700
|
+
return [2 /*return*/, result];
|
|
27659
27701
|
case 7: return [2 /*return*/];
|
|
27660
27702
|
}
|
|
27661
27703
|
});
|