@chevre/domain 22.7.0-alpha.13 → 22.7.0-alpha.15

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.
Files changed (31) hide show
  1. package/example/src/chevre/deleteDiscontinuedPeople.ts +114 -0
  2. package/example/src/chevre/findJWTSetting.ts +19 -0
  3. package/lib/chevre/credentials.d.ts +0 -5
  4. package/lib/chevre/credentials.js +0 -13
  5. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +13 -0
  6. package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
  7. package/lib/chevre/repo/setting/jwt.d.ts +10 -0
  8. package/lib/chevre/repo/setting/jwt.js +56 -0
  9. package/lib/chevre/repository.d.ts +7 -0
  10. package/lib/chevre/repository.js +17 -1
  11. package/lib/chevre/service/assetTransaction/pay.d.ts +1 -1
  12. package/lib/chevre/service/assetTransaction/pay.js +12 -17
  13. package/lib/chevre/service/code.d.ts +3 -9
  14. package/lib/chevre/service/code.js +18 -25
  15. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.d.ts +2 -3
  16. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +6 -2
  17. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +3 -4
  18. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +12 -4
  19. package/lib/chevre/service/offer/event/authorize.d.ts +3 -4
  20. package/lib/chevre/service/offer/event/authorize.js +6 -2
  21. package/lib/chevre/service/payment/any/factory.d.ts +1 -1
  22. package/lib/chevre/service/payment/any.d.ts +3 -4
  23. package/lib/chevre/service/payment/any.js +12 -4
  24. package/lib/chevre/service/task/authorizePayment.js +9 -5
  25. package/lib/chevre/service/task.d.ts +0 -2
  26. package/lib/chevre/service/transaction/moneyTransfer.d.ts +4 -6
  27. package/lib/chevre/service/transaction/moneyTransfer.js +30 -10
  28. package/package.json +2 -2
  29. package/example/src/chevre/findValidAuthorization.ts +0 -56
  30. package/lib/chevre/credentials/jwt.d.ts +0 -23
  31. package/lib/chevre/credentials/jwt.js +0 -18
@@ -0,0 +1,114 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+ import { call as deletePerson } from '../../../lib/chevre/service/task/deletePerson';
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
11
+ const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdNew']);
12
+ if (typeof setting?.userPoolIdNew !== 'string') {
13
+ throw new chevre.factory.errors.NotFound('setting.userPoolIdNew');
14
+ }
15
+
16
+ const DISCONTINUE_PEOPLE_PROJECT = process.env.USE_DISCONTINUE_PEOPLE_PROJECT;
17
+
18
+ /**
19
+ * 1リクエストで生成するタスク数
20
+ */
21
+ const NUM_TASKS = 1;
22
+
23
+ if (typeof DISCONTINUE_PEOPLE_PROJECT === 'string' && DISCONTINUE_PEOPLE_PROJECT.length > 0) {
24
+ const ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
25
+ const deletingOwnershipInfos = (await ownershipInfoRepo.projectFields({
26
+ limit: NUM_TASKS,
27
+ page: 1,
28
+ sort: { ownedFrom: chevre.factory.sortType.Ascending },
29
+ project: { id: { $eq: DISCONTINUE_PEOPLE_PROJECT } },
30
+ typeOfGood: {
31
+ // typeOf: { $eq: chevre.factory.permit.PermitType.Permit },
32
+ issuedThrough: {
33
+ typeOf: {
34
+ // $eq: chevre.factory.product.ProductType.PaymentCard
35
+ $eq: chevre.factory.product.ProductType.EventService
36
+ }
37
+ }
38
+ }
39
+ }));
40
+ console.log(deletingOwnershipInfos.length, 'deletingOwnershipInfos found');
41
+
42
+ if (deletingOwnershipInfos.length > 0) {
43
+ const runsAt: Date = new Date();
44
+ const userPoolId: string = setting.userPoolIdNew;
45
+
46
+ for (const deletingOwnershipInfo of deletingOwnershipInfos) {
47
+ const personId: string = (Array.isArray(deletingOwnershipInfo.ownedBy))
48
+ ? deletingOwnershipInfo.ownedBy[0]?.id
49
+ : deletingOwnershipInfo.ownedBy.id;
50
+
51
+ console.log(
52
+ 'deleting person...',
53
+ personId, deletingOwnershipInfo.id, deletingOwnershipInfo.ownedFrom
54
+ );
55
+ await deletePerson({
56
+ id: '',
57
+ project: { typeOf: chevre.factory.organizationType.Project, id: DISCONTINUE_PEOPLE_PROJECT },
58
+ name: chevre.factory.taskName.DeletePerson,
59
+ status: chevre.factory.taskStatus.Ready,
60
+ runsAt,
61
+ remainingNumberOfTries: 10,
62
+ numberOfTried: 0,
63
+ data: {
64
+ id: personId,
65
+ agent: {
66
+ id: DISCONTINUE_PEOPLE_PROJECT,
67
+ typeOf: chevre.factory.organizationType.Project,
68
+ name: 'example'
69
+ },
70
+ physically: true,
71
+ userPoolId,
72
+ project: { id: DISCONTINUE_PEOPLE_PROJECT },
73
+ migrate: false,
74
+ useUsernameAsGMOMemberId: true,
75
+ executeBackground: true
76
+ }
77
+ })(
78
+ {
79
+ connection: mongoose.connection,
80
+ settings: new chevre.settings.Settings({
81
+ abortedTasksWithoutReport: [],
82
+ numTryConfirmReserveTransaction: 10,
83
+ deliverOrderLimit: 1,
84
+ coa: {
85
+ timeout: 20000
86
+ },
87
+ gmo: {
88
+ timeout: 5000,
89
+ timeoutBackground: 5000,
90
+ useFetch: true
91
+ },
92
+ movieticketReserve: {
93
+ timeout: 1000,
94
+ timeoutCheck: 1000,
95
+ minIntervalBetweenPayAndRefund: 1000,
96
+ credentialsExpireInSeconds: 1000
97
+ },
98
+ useExperimentalFeature: false
99
+ }),
100
+ credentials: <any>{}
101
+ },
102
+ {
103
+ executeById: false,
104
+ executeByName: true
105
+ }
106
+ );
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ main()
113
+ .then(console.log)
114
+ .catch(console.error);
@@ -0,0 +1,19 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const jwtSettingRepo = await chevre.repository.setting.JWT.createInstance(mongoose.connection);
11
+
12
+ const result = await jwtSettingRepo.findDefault();
13
+ // tslint:disable-next-line:no-null-keyword
14
+ console.dir(result, { depth: null });
15
+ }
16
+
17
+ main()
18
+ .then(console.log)
19
+ .catch(console.error);
@@ -1,5 +1,4 @@
1
1
  import type { CustomSearchCredentials } from './credentials/customSearch';
2
- import type { JWTCredentials } from './credentials/jwt';
3
2
  import type { LINENotifyCredentials } from './credentials/lineNotify';
4
3
  import type { SendGridCredentials } from './credentials/sendGrid';
5
4
  /**
@@ -10,10 +9,6 @@ export declare namespace credentials {
10
9
  namespace CustomSearch {
11
10
  function createInstance(...params: ConstructorParameters<typeof CustomSearchCredentials>): Promise<CustomSearchCredentials>;
12
11
  }
13
- type JWT = JWTCredentials;
14
- namespace JWT {
15
- function createInstance(...params: ConstructorParameters<typeof JWTCredentials>): Promise<JWTCredentials>;
16
- }
17
12
  type LINENotify = LINENotifyCredentials;
18
13
  namespace LINENotify {
19
14
  function createInstance(...params: ConstructorParameters<typeof LINENotifyCredentials>): Promise<LINENotifyCredentials>;
@@ -28,19 +28,6 @@ var credentials;
28
28
  }
29
29
  CustomSearch.createInstance = createInstance;
30
30
  })(CustomSearch = credentials.CustomSearch || (credentials.CustomSearch = {}));
31
- let JWT;
32
- (function (JWT) {
33
- let cred;
34
- function createInstance(...params) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- if (cred === undefined) {
37
- cred = (yield Promise.resolve().then(() => require('./credentials/jwt'))).JWTCredentials;
38
- }
39
- return new cred(...params);
40
- });
41
- }
42
- JWT.createInstance = createInstance;
43
- })(JWT = credentials.JWT || (credentials.JWT = {}));
44
31
  let LINENotify;
45
32
  (function (LINENotify) {
46
33
  let cred;
@@ -71,8 +71,21 @@ interface IWaiterSettings {
71
71
  passportIssuers: string[];
72
72
  secret: string;
73
73
  }
74
+ export interface IJWTSetting {
75
+ /**
76
+ * トークン生成鍵
77
+ */
78
+ secret: string;
79
+ /**
80
+ * トークン検証時の発行者リスト
81
+ */
82
+ issuers: string[];
83
+ version: string;
84
+ payloadTypPrefix: string;
85
+ }
74
86
  export interface ISetting {
75
87
  defaultSenderEmail?: string;
88
+ jwt?: IJWTSetting;
76
89
  onEventChanged?: IOnEventChanged;
77
90
  onOrderStatusChanged: IOnOrderStatusChanged;
78
91
  onReservationStatusChanged?: IOnReservationStatusChanged;
@@ -8,6 +8,7 @@ const modelName = 'Setting';
8
8
  exports.modelName = modelName;
9
9
  const schemaDefinition = {
10
10
  defaultSenderEmail: String,
11
+ jwt: mongoose_1.SchemaTypes.Mixed,
11
12
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
13
  onEventChanged: mongoose_1.SchemaTypes.Mixed,
13
14
  onOrderStatusChanged: mongoose_1.SchemaTypes.Mixed,
@@ -0,0 +1,10 @@
1
+ import type { Connection } from 'mongoose';
2
+ import { IJWTSetting } from '../mongoose/schemas/setting';
3
+ /**
4
+ * JWT設定リポジトリ
5
+ */
6
+ export declare class JWTSettingRepo {
7
+ private readonly settingModel;
8
+ constructor(connection: Connection);
9
+ findDefault(): Promise<IJWTSetting>;
10
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.JWTSettingRepo = void 0;
13
+ const factory = require("../../factory");
14
+ const setting_1 = require("../mongoose/schemas/setting");
15
+ /**
16
+ * JWT設定リポジトリ
17
+ */
18
+ class JWTSettingRepo {
19
+ constructor(connection) {
20
+ this.settingModel = connection.model(setting_1.modelName, (0, setting_1.createSchema)());
21
+ }
22
+ findDefault() {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const andQuery = [{ 'project.id': { $eq: '*' } }];
25
+ const filterQuery = { $and: andQuery };
26
+ const projection = {
27
+ _id: 0,
28
+ // id: { $toString: '$_id' },
29
+ jwt: 1
30
+ };
31
+ const jwtSetting = yield this.settingModel.findOne(filterQuery, projection)
32
+ .lean()
33
+ .exec();
34
+ if (jwtSetting === null || jwtSetting.jwt === undefined) {
35
+ throw new factory.errors.NotFound('setting.jwt');
36
+ }
37
+ const { secret, version, payloadTypPrefix, issuers } = jwtSetting.jwt;
38
+ if (typeof secret !== 'string' || secret.length === 0) {
39
+ throw new factory.errors.NotFound('setting.jwt.secret');
40
+ }
41
+ if (typeof version !== 'string' || version.length === 0) {
42
+ throw new factory.errors.NotFound('setting.jwt.version');
43
+ }
44
+ if (typeof payloadTypPrefix !== 'string' || payloadTypPrefix.length === 0) {
45
+ throw new factory.errors.NotFound('setting.jwt.payloadTypPrefix');
46
+ }
47
+ if (!Array.isArray(issuers)) {
48
+ throw new factory.errors.NotFound('setting.jwt.issuers');
49
+ }
50
+ return {
51
+ secret, version, payloadTypPrefix, issuers
52
+ };
53
+ });
54
+ }
55
+ }
56
+ exports.JWTSettingRepo = JWTSettingRepo;
@@ -60,6 +60,7 @@ import type { SellerPaymentAcceptedRepo } from './repo/sellerPaymentAccepted';
60
60
  import type { ServiceOutputRepo } from './repo/serviceOutput';
61
61
  import type { ServiceOutputIdentifierRepo } from './repo/serviceOutputIdentifier';
62
62
  import type { SettingRepo } from './repo/setting';
63
+ import type { JWTSettingRepo } from './repo/setting/jwt';
63
64
  import type { StockHolderRepo } from './repo/stockHolder';
64
65
  import type { TaskRepo } from './repo/task';
65
66
  import type { TelemetryRepo } from './repo/telemetry';
@@ -345,6 +346,12 @@ export type Setting = SettingRepo;
345
346
  export declare namespace Setting {
346
347
  function createInstance(...params: ConstructorParameters<typeof SettingRepo>): Promise<SettingRepo>;
347
348
  }
349
+ export declare namespace setting {
350
+ type JWT = JWTSettingRepo;
351
+ namespace JWT {
352
+ function createInstance(...params: ConstructorParameters<typeof JWTSettingRepo>): Promise<JWTSettingRepo>;
353
+ }
354
+ }
348
355
  export type StockHolder = StockHolderRepo;
349
356
  export declare namespace StockHolder {
350
357
  function createInstance(...params: ConstructorParameters<typeof StockHolderRepo>): Promise<StockHolderRepo>;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.Member = exports.Interface = exports.EventSeries = exports.EventSellerMakesOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
- exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = void 0;
13
+ exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = void 0;
14
14
  var AcceptedOffer;
15
15
  (function (AcceptedOffer) {
16
16
  let repo;
@@ -841,6 +841,22 @@ var Setting;
841
841
  }
842
842
  Setting.createInstance = createInstance;
843
843
  })(Setting = exports.Setting || (exports.Setting = {}));
844
+ var setting;
845
+ (function (setting) {
846
+ let JWT;
847
+ (function (JWT) {
848
+ let repo;
849
+ function createInstance(...params) {
850
+ return __awaiter(this, void 0, void 0, function* () {
851
+ if (repo === undefined) {
852
+ repo = (yield Promise.resolve().then(() => require('./repo/setting/jwt'))).JWTSettingRepo;
853
+ }
854
+ return new repo(...params);
855
+ });
856
+ }
857
+ JWT.createInstance = createInstance;
858
+ })(JWT = setting.JWT || (setting.JWT = {}));
859
+ })(setting = exports.setting || (exports.setting = {}));
844
860
  var StockHolder;
845
861
  (function (StockHolder) {
846
862
  let repo;
@@ -134,7 +134,7 @@ export declare function start(params: factory.assetTransaction.pay.IStartParamsW
134
134
  checkedAction: {
135
135
  id: string;
136
136
  };
137
- }): IStartOperation<factory.assetTransaction.pay.ITransaction>;
137
+ }): IStartOperation<Pick<factory.assetTransaction.pay.ITransaction, 'id' | 'object'>>;
138
138
  /**
139
139
  * 取引確定
140
140
  */
@@ -408,23 +408,18 @@ function processAuthorizeMovieTicket(params, transaction, paymentServiceId,
408
408
  // useCheckByIdentifierIfNotYet: boolean,
409
409
  options) {
410
410
  return (repos, settings) => __awaiter(this, void 0, void 0, function* () {
411
- const { accountsReceivablesByServiceType } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId, options)(repos, settings);
412
- // const payActionInObject: factory.assetTransaction.pay.IPayActionInObject = {
413
- // actionStatus: payAction.actionStatus,
414
- // id: payAction.id,
415
- // typeOf: payAction.typeOf
416
- // };
417
- return saveAuthorizeResult({
418
- id: transaction.id,
419
- update: {
420
- // ↓discontinue(2024-06-14~)
421
- // 'object.accountId': accountId,
422
- // 'object.paymentMethod.accountId': accountId,
423
- // 'object.payAction': payActionInObject, // 最適化(2024-04-09~)
424
- // 認証レスポンスより計上金額を保管(2023-05-15~)
425
- 'object.accountsReceivablesByServiceType': accountsReceivablesByServiceType
426
- }
427
- })(repos);
411
+ // const { accountsReceivablesByServiceType } = await MovieTicketPayment.authorize(
412
+ // params, transaction, paymentServiceId, options
413
+ // )(repos, settings);
414
+ yield MovieTicketPayment.authorize(params, transaction, paymentServiceId, options)(repos, settings);
415
+ return transaction;
416
+ // discontinue(2024-12-17~)
417
+ // return saveAuthorizeResult({
418
+ // id: transaction.id,
419
+ // update: {
420
+ // 'object.accountsReceivablesByServiceType': accountsReceivablesByServiceType // 認証レスポンスより計上金額を保管(2023-05-15~)
421
+ // }
422
+ // })(repos);
428
423
  });
429
424
  }
430
425
  function saveAuthorizeResult(params) {
@@ -1,11 +1,7 @@
1
- /**
2
- * 承認サービス
3
- */
4
- import * as jwt from 'jsonwebtoken';
5
1
  import type { ActionRepo } from '../repo/action';
6
2
  import type { AuthorizationRepo } from '../repo/authorization';
3
+ import type { JWTSettingRepo } from '../repo/setting/jwt';
7
4
  import type { TicketRepo } from '../repo/ticket';
8
- import { JWTCredentials } from '../credentials/jwt';
9
5
  import * as factory from '../factory';
10
6
  type IToken = string;
11
7
  interface IPayload extends Pick<factory.clientUser.IClientUser, 'aud' | 'exp' | 'iat' | 'iss' | 'sub' | 'token_use' | 'typ' | 'version'> {
@@ -37,9 +33,8 @@ declare function getToken(params: {
37
33
  audience: string;
38
34
  }): (repos: {
39
35
  authorization: AuthorizationRepo;
36
+ jwtSetting: JWTSettingRepo;
40
37
  ticket: TicketRepo;
41
- }, credentials: {
42
- jwt: JWTCredentials;
43
38
  }) => Promise<{
44
39
  token: IToken;
45
40
  }>;
@@ -53,9 +48,8 @@ declare function verifyToken(params: {
53
48
  }): (repos: {
54
49
  action?: ActionRepo;
55
50
  authorization: AuthorizationRepo;
51
+ jwtSetting: JWTSettingRepo;
56
52
  ticket: TicketRepo;
57
- }, credentials: {
58
- jwt: JWTCredentials;
59
53
  }) => Promise<{
60
54
  authorizedObject: IAuthorizedObject;
61
55
  }>;
@@ -14,18 +14,22 @@ exports.verifyToken = exports.getToken = void 0;
14
14
  * 承認サービス
15
15
  */
16
16
  const jwt = require("jsonwebtoken");
17
+ // import { JWTCredentials } from '../credentials/jwt';
17
18
  const factory = require("../factory");
18
- // type IPayloadWithNoVersion = factory.authorization.IObject & {
19
- // version?: never;
20
- // typ?: never;
21
- // };
22
19
  const ALGORITHM = 'HS256';
23
20
  /**
24
21
  * コードをトークンに変換する
25
22
  */
26
23
  function getToken(params) {
27
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
24
+ return (repos
25
+ // credentials: {
26
+ // jwt: JWTCredentials;
27
+ // }
28
+ ) => __awaiter(this, void 0, void 0, function* () {
28
29
  var _a;
30
+ const credentials = {
31
+ jwt: yield repos.jwtSetting.findDefault()
32
+ };
29
33
  if (typeof params.project.id !== 'string' || params.project.id.length === 0) {
30
34
  throw new factory.errors.ArgumentNull('project.id');
31
35
  }
@@ -46,8 +50,6 @@ function getToken(params) {
46
50
  // let typ: string = `${credentials.jwt.payloadTypPrefix}:${authorization.typeOf}`;
47
51
  // jti必須化(2024-08-22~)
48
52
  // let jti: string | undefined;
49
- // if (params.useJti) {
50
- // }
51
53
  const { id } = yield repos.ticket.issueByTicketToken(Object.assign({ project: { id: params.project.id }, ticketToken: params.code }, (typeof ((_a = authorization.issuedBy) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { issuedBy: authorization.issuedBy } : undefined));
52
54
  jti = id;
53
55
  // ロール承認の場合、subjectはメンバーID,typはメンバータイプ
@@ -68,9 +70,7 @@ function getToken(params) {
68
70
  };
69
71
  const token = yield new Promise((resolve, reject) => {
70
72
  // 所有権を暗号化する
71
- jwt.sign(payload, credentials.jwt.secret, Object.assign(Object.assign({ algorithm: ALGORITHM,
72
- // issuer: credentials.jwt.issuer,
73
- issuer: params.issuer, expiresIn: params.expiresIn, subject }, (typeof params.audience === 'string') ? { audience: params.audience } : undefined), (typeof jti === 'string') ? { jwtid: jti } : undefined // 拡張(2024-05-08~)
73
+ jwt.sign(payload, credentials.jwt.secret, Object.assign(Object.assign({ algorithm: ALGORITHM, issuer: params.issuer, expiresIn: params.expiresIn, subject }, (typeof params.audience === 'string') ? { audience: params.audience } : undefined), (typeof jti === 'string') ? { jwtid: jti } : undefined // 拡張(2024-05-08~)
74
74
  ), (err, encoded) => {
75
75
  if (err instanceof Error) {
76
76
  reject(err);
@@ -98,20 +98,6 @@ function payload2authorizeObject(params) {
98
98
  if (typeof payload.sub !== 'string' || payload.sub.length === 0) {
99
99
  throw new factory.errors.Unauthorized(`invalid token [sub:${payload.sub}]`);
100
100
  }
101
- // discontinue purposeTokenに対応(2024-07-10~)
102
- // sskts.purposeTokenに対応
103
- // let resourceTypeByPayload: string | undefined;
104
- // if (typeof payload.typ === 'string') {
105
- // resourceTypeByPayload = payload.typ.split(`${credentials.jwt.payloadTypPrefix}:`)
106
- // .at(1);
107
- // }
108
- // if (resourceTypeByPayload === factory.transactionType.PlaceOrder) {
109
- // result = {
110
- // id: payload.sub,
111
- // typeOf: resourceTypeByPayload
112
- // };
113
- // } else {
114
- // }
115
101
  if (typeof payload.jti === 'string') {
116
102
  // jtiに対応(2024-05-08~)
117
103
  const ticket = (yield repos.ticket.projectFields({
@@ -147,7 +133,11 @@ function payload2authorizeObject(params) {
147
133
  });
148
134
  }
149
135
  function verifyToken(params) {
150
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
136
+ return (repos
137
+ // credentials: {
138
+ // jwt: JWTCredentials;
139
+ // }
140
+ ) => __awaiter(this, void 0, void 0, function* () {
151
141
  let payload;
152
142
  let action;
153
143
  if (repos.action !== undefined) {
@@ -163,6 +153,9 @@ function verifyToken(params) {
163
153
  action = yield repos.action.start(actionAttributes);
164
154
  }
165
155
  try {
156
+ const credentials = {
157
+ jwt: yield repos.jwtSetting.findDefault()
158
+ };
166
159
  // payload = await new Promise<IPayloadWithNoVersion | IPayload>((resolve, reject) => {
167
160
  payload = yield new Promise((resolve, reject) => {
168
161
  jwt.verify(params.token, credentials.jwt.secret, Object.assign({ algorithms: [ALGORITHM],
@@ -1,7 +1,7 @@
1
1
  import * as factory from '../../../../../factory';
2
- import type { JWTCredentials } from '../../../../../credentials/jwt';
3
2
  import type { ActionRepo } from '../../../../../repo/action';
4
3
  import type { AuthorizationRepo } from '../../../../../repo/authorization';
4
+ import type { JWTSettingRepo } from '../../../../../repo/setting/jwt';
5
5
  import type { TicketRepo } from '../../../../../repo/ticket';
6
6
  /**
7
7
  * チケット化された適用メンバーシップをPermitに変換する
@@ -17,8 +17,7 @@ declare function requestedProgramMembershipUsed2permit(params: {
17
17
  }): (repos: {
18
18
  action: ActionRepo;
19
19
  authorization: AuthorizationRepo;
20
+ jwtSetting: JWTSettingRepo;
20
21
  ticket: TicketRepo;
21
- }, credentials: {
22
- jwt: JWTCredentials;
23
22
  }) => Promise<factory.assetTransaction.reserve.IPermitIssuedThroughFaceToFace | factory.assetTransaction.reserve.IPermitIssuedThroughMembershipService | undefined>;
24
23
  export { requestedProgramMembershipUsed2permit };
@@ -17,7 +17,11 @@ const CodeService = require("../../../../code");
17
17
  */
18
18
  function requestedProgramMembershipUsed2permit(params) {
19
19
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
20
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
20
+ return (repos
21
+ // credentials: {
22
+ // jwt: JWTCredentials;
23
+ // }
24
+ ) => __awaiter(this, void 0, void 0, function* () {
21
25
  var _a, _b, _c, _d;
22
26
  let programMembershipUsedAsPermit;
23
27
  const { programMembershipUsed, placeOrder } = params;
@@ -27,7 +31,7 @@ function requestedProgramMembershipUsed2permit(params) {
27
31
  project: { id: params.project.id },
28
32
  agent: { id: params.project.id, typeOf: factory.organizationType.Project },
29
33
  token: String(programMembershipUsed)
30
- })(repos, credentials);
34
+ })(repos);
31
35
  const permitOwnershipInfo = authorizedObject;
32
36
  if (Array.isArray(permitOwnershipInfo)) {
33
37
  throw new factory.errors.NotImplemented('programMembershipUsed as an array not implemented');
@@ -1,6 +1,5 @@
1
1
  import * as factory from '../../../../factory';
2
2
  import { Settings } from '../../../../settings';
3
- import type { JWTCredentials } from '../../../../credentials/jwt';
4
3
  import type { ActionRepo } from '../../../../repo/action';
5
4
  import type { AssetTransactionRepo } from '../../../../repo/assetTransaction';
6
5
  import type { AuthorizationRepo } from '../../../../repo/authorization';
@@ -17,6 +16,7 @@ import type { ProductOfferRepo } from '../../../../repo/productOffer';
17
16
  import type { ProjectRepo } from '../../../../repo/project';
18
17
  import type { OfferRateLimitRepo } from '../../../../repo/rateLimit/offer';
19
18
  import type { SettingRepo } from '../../../../repo/setting';
19
+ import type { JWTSettingRepo } from '../../../../repo/setting/jwt';
20
20
  import type { StockHolderRepo } from '../../../../repo/stockHolder';
21
21
  import type { TaskRepo } from '../../../../repo/task';
22
22
  import type { TicketRepo } from '../../../../repo/ticket';
@@ -45,6 +45,7 @@ declare function processStartReserve4chevre(params: {
45
45
  stockHolder: StockHolderRepo;
46
46
  event: EventRepo;
47
47
  eventSeries: EventSeriesRepo;
48
+ jwtSetting: JWTSettingRepo;
48
49
  offer: OfferRepo;
49
50
  offerCatalog: OfferCatalogRepo;
50
51
  offerCatalogItem: OfferCatalogItemRepo;
@@ -59,9 +60,7 @@ declare function processStartReserve4chevre(params: {
59
60
  task: TaskRepo;
60
61
  ticket: TicketRepo;
61
62
  assetTransaction: AssetTransactionRepo;
62
- }, settings: Settings, credentials: {
63
- jwt: JWTCredentials;
64
- }) => Promise<{
63
+ }, settings: Settings) => Promise<{
65
64
  acceptedOffers4result: IResultAcceptedOffer[];
66
65
  }>;
67
66
  export { processStartReserve4chevre };
@@ -15,7 +15,11 @@ const ReserveTransactionService = require("../../../assetTransaction/reserve");
15
15
  const factory_1 = require("./factory");
16
16
  const requestedProgramMembershipUsed2permit_1 = require("./processStartReserve4chevre/requestedProgramMembershipUsed2permit");
17
17
  function processStartReserve4chevre(params, options) {
18
- return (repos, settings, credentials) => __awaiter(this, void 0, void 0, function* () {
18
+ return (repos, settings
19
+ // credentials: {
20
+ // jwt: JWTCredentials;
21
+ // }
22
+ ) => __awaiter(this, void 0, void 0, function* () {
19
23
  const { event, transaction, transactionNumber } = params;
20
24
  let acceptedOffers4result = [];
21
25
  // 予約取引開始
@@ -23,7 +27,7 @@ function processStartReserve4chevre(params, options) {
23
27
  // object: <IObjectWithDetail>action.object,
24
28
  acceptedOffers: params.acceptedOffers, event: { id: event.id }, transaction,
25
29
  transactionNumber }, (params.broker !== undefined) ? { broker: params.broker } : undefined));
26
- const startParamObject = yield validateObjectWithoutDetail(startParams, { id: params.transaction.id })(repos, credentials);
30
+ const startParamObject = yield validateObjectWithoutDetail(startParams, { id: params.transaction.id })(repos);
27
31
  const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject,
28
32
  // discontinue preSearchedEvent(2024-07-17~)
29
33
  // preSearchedEvent: event,
@@ -43,7 +47,11 @@ function processStartReserve4chevre(params, options) {
43
47
  }
44
48
  exports.processStartReserve4chevre = processStartReserve4chevre;
45
49
  function validateObjectWithoutDetail(params, placeOrder) {
46
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
50
+ return (repos
51
+ // credentials: {
52
+ // jwt: JWTCredentials;
53
+ // }
54
+ ) => __awaiter(this, void 0, void 0, function* () {
47
55
  var _a, _b, _c;
48
56
  const objectWithoutDetail = params.object;
49
57
  if (Array.isArray(objectWithoutDetail.acceptedOffer)) {
@@ -53,7 +61,7 @@ function validateObjectWithoutDetail(params, placeOrder) {
53
61
  project: { id: params.project.id },
54
62
  programMembershipUsed: (_b = (_a = acceptedOffer.itemOffered) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.programMembershipUsed,
55
63
  placeOrder: { id: placeOrder.id }
56
- })(repos, credentials);
64
+ })(repos);
57
65
  // 適用メンバーシップがあればacceptedOfferを強制的に上書き
58
66
  if (programMembershipUsedAsPermit !== undefined) {
59
67
  acceptedOffer = Object.assign(Object.assign({}, acceptedOffer), { itemOffered: Object.assign(Object.assign({}, acceptedOffer.itemOffered), { serviceOutput: Object.assign(Object.assign({}, (_c = acceptedOffer.itemOffered) === null || _c === void 0 ? void 0 : _c.serviceOutput), { typeOf: factory.reservationType.EventReservation, programMembershipUsed: programMembershipUsedAsPermit }) }) });
@@ -1,6 +1,5 @@
1
1
  import * as factory from '../../../factory';
2
2
  import { Settings } from '../../../settings';
3
- import type { JWTCredentials } from '../../../credentials/jwt';
4
3
  import type { ActionRepo } from '../../../repo/action';
5
4
  import type { AssetTransactionRepo } from '../../../repo/assetTransaction';
6
5
  import type { AuthorizationRepo } from '../../../repo/authorization';
@@ -19,6 +18,7 @@ import type { ProductOfferRepo } from '../../../repo/productOffer';
19
18
  import type { ProjectRepo } from '../../../repo/project';
20
19
  import type { OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
21
20
  import type { SettingRepo } from '../../../repo/setting';
21
+ import type { JWTSettingRepo } from '../../../repo/setting/jwt';
22
22
  import type { StockHolderRepo } from '../../../repo/stockHolder';
23
23
  import type { TaskRepo } from '../../../repo/task';
24
24
  import type { TicketRepo } from '../../../repo/ticket';
@@ -30,6 +30,7 @@ interface IAuthorizeRepos {
30
30
  authorization: AuthorizationRepo;
31
31
  event: EventRepo;
32
32
  eventSeries: EventSeriesRepo;
33
+ jwtSetting: JWTSettingRepo;
33
34
  stockHolder: StockHolderRepo;
34
35
  offer: OfferRepo;
35
36
  offerCatalog: OfferCatalogRepo;
@@ -49,9 +50,7 @@ interface IAuthorizeRepos {
49
50
  transaction: TransactionRepo;
50
51
  transactionNumber: TransactionNumberRepo;
51
52
  }
52
- type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, settings: Settings, credentials: {
53
- jwt: JWTCredentials;
54
- }) => Promise<T>;
53
+ type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, settings: Settings) => Promise<T>;
55
54
  type IAuthorizeOfferAction = factory.action.authorize.offer.eventService.IAction<factory.service.webAPI.Identifier>;
56
55
  type IObjectWithoutDetail = factory.action.authorize.offer.eventService.IObjectWithoutDetail;
57
56
  interface IAuthorizeOptions {
@@ -20,7 +20,11 @@ const searchOffersByIds_1 = require("./searchOffersByIds");
20
20
  * 興行オファー承認
21
21
  */
22
22
  function authorize(params, options) {
23
- return (repos, settings, credentials) => __awaiter(this, void 0, void 0, function* () {
23
+ return (repos, settings
24
+ // credentials: {
25
+ // jwt: JWTCredentials;
26
+ // }
27
+ ) => __awaiter(this, void 0, void 0, function* () {
24
28
  var _a;
25
29
  const { noOfferSpecified } = options;
26
30
  const { transaction, event } = yield validateCreateRequest(params)(repos);
@@ -42,7 +46,7 @@ function authorize(params, options) {
42
46
  const action = yield repos.action.start(actionAttributes);
43
47
  try {
44
48
  const processStartReserveResult = yield (0, processStartReserve4chevre_1.processStartReserve4chevre)(Object.assign({ acceptedOffers, event,
45
- transactionNumber, transaction, availableAtOrFrom: { id: params.store.id }, ticketOffers, unitPriceOffers, validateEvent: params.validateEvent === true, validateEventOfferPeriod: params.validateEventOfferPeriod === true }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined), options)(repos, settings, credentials);
49
+ transactionNumber, transaction, availableAtOrFrom: { id: params.store.id }, ticketOffers, unitPriceOffers, validateEvent: params.validateEvent === true, validateEventOfferPeriod: params.validateEventOfferPeriod === true }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined), options)(repos, settings);
46
50
  acceptedOffers4result = processStartReserveResult.acceptedOffers4result;
47
51
  // add orderInTransaction(2024-01-15~)
48
52
  if (!noOfferSpecified) {
@@ -27,7 +27,7 @@ export declare function creatPayTransactionStartParams(params: {
27
27
  export declare function createMovieTicket(params: factory.action.trade.pay.IMovieTicket): factory.action.trade.pay.IMovieTicket;
28
28
  export declare function createAuthorizeResult(params: {
29
29
  object: factory.action.authorize.paymentMethod.any.IObjectIncludingPaymentMethodDetails;
30
- payTransaction: factory.assetTransaction.pay.ITransaction;
30
+ payTransaction: Pick<factory.assetTransaction.pay.ITransaction, 'object'>;
31
31
  permit?: Pick<factory.ownershipInfo.IPermitAsGood, 'identifier'>;
32
32
  }): factory.action.authorize.paymentMethod.any.IResult;
33
33
  /**
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import * as factory from '../../factory';
5
5
  import { Settings } from '../../settings';
6
- import type { JWTCredentials } from '../../credentials/jwt';
7
6
  import type { AccountingReportRepo } from '../../repo/accountingReport';
8
7
  import type { ActionRepo, IMinimizedPurchaseNumberAuthResult } from '../../repo/action';
9
8
  import type { AssetTransactionRepo } from '../../repo/assetTransaction';
@@ -15,6 +14,7 @@ import type { PaymentServiceRepo } from '../../repo/paymentService';
15
14
  import type { PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
16
15
  import type { ProductRepo } from '../../repo/product';
17
16
  import type { SellerPaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
17
+ import type { JWTSettingRepo } from '../../repo/setting/jwt';
18
18
  import type { TaskRepo } from '../../repo/task';
19
19
  import type { TicketRepo } from '../../repo/ticket';
20
20
  import type { TransactionRepo } from '../../repo/transaction';
@@ -81,6 +81,7 @@ interface IAuthorizeRepos {
81
81
  confirmationNumber: ConfirmationNumberRepo;
82
82
  credentials: CredentialsRepo;
83
83
  event: EventRepo;
84
+ jwtSetting: JWTSettingRepo;
84
85
  paymentAccepted: SellerPaymentAcceptedRepo;
85
86
  paymentService: PaymentServiceRepo;
86
87
  paymentServiceProvider: PaymentServiceProviderRepo;
@@ -91,9 +92,7 @@ interface IAuthorizeRepos {
91
92
  transactionNumber: TransactionNumberRepo;
92
93
  transactionProcess: TransactionProcessRepo;
93
94
  }
94
- type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, settings: Settings, credentials: {
95
- jwt: JWTCredentials;
96
- }) => Promise<T>;
95
+ type IAuthorizeOperation<T> = (repos: IAuthorizeRepos, settings: Settings) => Promise<T>;
97
96
  interface IPublishPaymentUrlRepos {
98
97
  action: ActionRepo;
99
98
  assetTransaction: AssetTransactionRepo;
@@ -313,7 +313,11 @@ function minimizeObjectIncludingPaymentMethodDetails(authorizeObjectIncludingPay
313
313
  */
314
314
  function authorize(params) {
315
315
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
316
- return (repos, settings, credentials) => __awaiter(this, void 0, void 0, function* () {
316
+ return (repos, settings
317
+ // credentials: {
318
+ // jwt: JWTCredentials;
319
+ // }
320
+ ) => __awaiter(this, void 0, void 0, function* () {
317
321
  var _a, _b;
318
322
  const { paymentServiceType, purpose, project } = params;
319
323
  if (purpose.typeOf !== factory.transactionType.PlaceOrder) {
@@ -380,7 +384,7 @@ function authorize(params) {
380
384
  const movieTickets = (Array.isArray(params.object.movieTickets)) ? params.object.movieTickets.map(factory_1.createMovieTicket) : undefined;
381
385
  const { accountId } = yield fixAccountIdIfPossible({
382
386
  object: params.object, project: { id: transaction.project.id }
383
- })(repos, credentials);
387
+ })(repos);
384
388
  const authorizeObjectIncludingPaymentMethodDetails = Object.assign(Object.assign(Object.assign(Object.assign({}, params.object), { accountId, paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }), (creditCard !== undefined) ? { creditCard } : undefined), (Array.isArray(movieTickets)) ? { movieTickets } : undefined);
385
389
  const { authorizeObject } = minimizeObjectIncludingPaymentMethodDetails(authorizeObjectIncludingPaymentMethodDetails);
386
390
  // 承認アクションを開始する
@@ -458,7 +462,11 @@ exports.authorize = authorize;
458
462
  * 承認しようとしているobjectからaccountIdを決定する
459
463
  */
460
464
  function fixAccountIdIfPossible(params) {
461
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
465
+ return (repos
466
+ // credentials: {
467
+ // jwt: JWTCredentials;
468
+ // }
469
+ ) => __awaiter(this, void 0, void 0, function* () {
462
470
  var _a, _b;
463
471
  // let accountId = params.object?.accountId;
464
472
  let accountId = '';
@@ -470,7 +478,7 @@ function fixAccountIdIfPossible(params) {
470
478
  project: { id: params.project.id },
471
479
  agent: { id: params.project.id, typeOf: factory.organizationType.Project },
472
480
  token: fromLocation
473
- })(repos, credentials);
481
+ })(repos);
474
482
  const paymentCardOwnershipInfo = authorizedObject;
475
483
  if (Array.isArray(paymentCardOwnershipInfo)) {
476
484
  throw new factory.errors.NotImplemented('fromLocation as an array not implemented');
@@ -22,6 +22,7 @@ const paymentService_1 = require("../../repo/paymentService");
22
22
  const paymentServiceProvider_1 = require("../../repo/paymentServiceProvider");
23
23
  const product_1 = require("../../repo/product");
24
24
  const sellerPaymentAccepted_1 = require("../../repo/sellerPaymentAccepted");
25
+ const jwt_1 = require("../../repo/setting/jwt");
25
26
  const task_1 = require("../../repo/task");
26
27
  const ticket_1 = require("../../repo/ticket");
27
28
  const transaction_1 = require("../../repo/transaction");
@@ -32,13 +33,13 @@ const any_1 = require("../payment/any");
32
33
  * タスク実行関数
33
34
  */
34
35
  function call(params) {
35
- return ({ connection, redisClient, credentials, settings }, options) => __awaiter(this, void 0, void 0, function* () {
36
+ return ({ connection, redisClient, settings }, options) => __awaiter(this, void 0, void 0, function* () {
36
37
  if (redisClient === undefined) {
37
38
  throw new factory.errors.Argument('settings', 'redisClient required');
38
39
  }
39
- if (credentials.jwt === undefined) {
40
- throw new factory.errors.Argument('settings', 'jwtCredentials required');
41
- }
40
+ // if (credentials.jwt === undefined) {
41
+ // throw new factory.errors.Argument('settings', 'jwtCredentials required');
42
+ // }
42
43
  // 遅延実行(executeByName)には対応しない
43
44
  if (!options.executeById) {
44
45
  return;
@@ -63,6 +64,7 @@ function call(params) {
63
64
  expireInSeconds: (useCredentialsRepo) ? credentialsExpireInSeconds : 0
64
65
  }),
65
66
  event: new event_1.EventRepo(connection),
67
+ jwtSetting: new jwt_1.JWTSettingRepo(connection),
66
68
  paymentAccepted: new sellerPaymentAccepted_1.SellerPaymentAcceptedRepo(connection),
67
69
  paymentService: new paymentService_1.PaymentServiceRepo(connection),
68
70
  paymentServiceProvider: new paymentServiceProvider_1.PaymentServiceProviderRepo(connection),
@@ -72,7 +74,9 @@ function call(params) {
72
74
  transaction: new transaction_1.TransactionRepo(connection),
73
75
  transactionNumber: new transactionNumber_1.TransactionNumberRepo(redisClient),
74
76
  transactionProcess: transactionProcessRepo
75
- }, settings, { jwt: credentials.jwt });
77
+ }, settings
78
+ // { jwt: credentials.jwt }
79
+ );
76
80
  }
77
81
  catch (error) {
78
82
  let throwsError = true;
@@ -1,6 +1,5 @@
1
1
  import type { Connection } from 'mongoose';
2
2
  import type { RedisClientType } from 'redis';
3
- import { JWTCredentials } from '../credentials/jwt';
4
3
  import { LINENotifyCredentials } from '../credentials/lineNotify';
5
4
  import { SendGridCredentials } from '../credentials/sendGrid';
6
5
  import * as factory from '../factory';
@@ -9,7 +8,6 @@ import type { IExecutableTask, IExecutableTaskKeys, TaskRepo } from '../repo/tas
9
8
  import { Settings } from '../settings';
10
9
  import { AggregationSettings } from '../settings/aggregation';
11
10
  interface ICredentialSettings {
12
- jwt?: JWTCredentials;
13
11
  sendGrid: SendGridCredentials;
14
12
  }
15
13
  interface IExecuteSettings {
@@ -1,4 +1,3 @@
1
- import { JWTCredentials } from '../../credentials/jwt';
2
1
  import type { ActionRepo } from '../../repo/action';
3
2
  import type { AssetTransactionRepo } from '../../repo/assetTransaction';
4
3
  import type { AuthorizationRepo } from '../../repo/authorization';
@@ -8,6 +7,7 @@ import type { ProductRepo } from '../../repo/product';
8
7
  import type { ProjectRepo } from '../../repo/project';
9
8
  import type { SellerRepo } from '../../repo/seller';
10
9
  import type { SettingRepo } from '../../repo/setting';
10
+ import type { JWTSettingRepo } from '../../repo/setting/jwt';
11
11
  import type { TaskRepo } from '../../repo/task';
12
12
  import type { TicketRepo } from '../../repo/ticket';
13
13
  import type { IStartedTransaction, TransactionRepo } from '../../repo/transaction';
@@ -16,6 +16,7 @@ import { moneyTransfer as MoneyTransferFactory } from '../../factory/transaction
16
16
  export interface IStartOperationRepos {
17
17
  action: ActionRepo;
18
18
  authorization: AuthorizationRepo;
19
+ jwtSetting: JWTSettingRepo;
19
20
  order: OrderRepo;
20
21
  passport: PassportRepo;
21
22
  product: ProductRepo;
@@ -26,9 +27,7 @@ export interface IStartOperationRepos {
26
27
  transactionNumber: TransactionNumberRepo;
27
28
  assetTransaction: AssetTransactionRepo;
28
29
  }
29
- export type IStartOperation<T> = (repos: IStartOperationRepos, credentials: {
30
- jwt: JWTCredentials;
31
- }) => Promise<T>;
30
+ export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
32
31
  export type ITaskAndTransactionOperation<T> = (repos: {
33
32
  setting: SettingRepo;
34
33
  task: TaskRepo;
@@ -47,14 +46,13 @@ export declare function start(params: IStartParams): IStartOperation<IStartedTra
47
46
  export type IAuthorizeOperation<T> = (repos: {
48
47
  action: ActionRepo;
49
48
  authorization: AuthorizationRepo;
49
+ jwtSetting: JWTSettingRepo;
50
50
  order: OrderRepo;
51
51
  product: ProductRepo;
52
52
  project: ProjectRepo;
53
53
  ticket: TicketRepo;
54
54
  transaction: TransactionRepo;
55
55
  assetTransaction: AssetTransactionRepo;
56
- }, credentials: {
57
- jwt: JWTCredentials;
58
56
  }) => Promise<T>;
59
57
  /**
60
58
  * 取引確定
@@ -27,7 +27,11 @@ const CodeService = require("../code");
27
27
  * 通貨転送資産取引サービスを利用して転送取引を開始する
28
28
  */
29
29
  function start(params) {
30
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
30
+ return (repos
31
+ // credentials: {
32
+ // jwt: JWTCredentials;
33
+ // }
34
+ ) => __awaiter(this, void 0, void 0, function* () {
31
35
  const { passport } = yield repos.passport.validatePassportTokenIfExist(params);
32
36
  const sellers = yield repos.seller.projectFields({
33
37
  limit: 1,
@@ -55,7 +59,7 @@ function start(params) {
55
59
  transaction = yield repos.transaction.start(startParams);
56
60
  yield authorizePaymentCard({
57
61
  transaction: Object.assign(Object.assign({}, transaction), { object: startParams.object, seller: startParams.seller, agent: startParams.agent, project: startParams.project, typeOf: startParams.typeOf })
58
- })(repos, credentials);
62
+ })(repos);
59
63
  }
60
64
  catch (error) {
61
65
  throw error;
@@ -65,7 +69,11 @@ function start(params) {
65
69
  }
66
70
  exports.start = start;
67
71
  function authorizePaymentCard(params) {
68
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
72
+ return (repos
73
+ // credentials: {
74
+ // jwt: JWTCredentials;
75
+ // }
76
+ ) => __awaiter(this, void 0, void 0, function* () {
69
77
  var _a;
70
78
  const transaction = params.transaction;
71
79
  const fromLocation = transaction.object.fromLocation;
@@ -96,7 +104,7 @@ function authorizePaymentCard(params) {
96
104
  : String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
97
105
  }, price: 0, priceCurrency: factory.priceCurrency.JPY }, (typeof transaction.object.description === 'string') ? { description: transaction.object.description } : undefined),
98
106
  purpose: { typeOf: transaction.typeOf, id: transaction.id }
99
- })(repos, credentials);
107
+ })(repos);
100
108
  }
101
109
  else {
102
110
  throw new factory.errors.NotImplemented('Withdraw transaction not implemented');
@@ -161,7 +169,11 @@ function fixToLocation(params) {
161
169
  * 口座取引は、出金取引あるいは転送取引のどちらかを選択できます
162
170
  */
163
171
  function processAuthorizePaymentCard(params) {
164
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
172
+ return (repos
173
+ // credentials: {
174
+ // jwt: JWTCredentials;
175
+ // }
176
+ ) => __awaiter(this, void 0, void 0, function* () {
165
177
  var _a;
166
178
  const transaction = yield repos.transaction.projectFieldsInProgressById({
167
179
  typeOf: factory.transactionType.MoneyTransfer,
@@ -196,7 +208,7 @@ function processAuthorizePaymentCard(params) {
196
208
  recipient: recipient,
197
209
  transaction: transaction,
198
210
  transactionNumber
199
- })(repos, credentials);
211
+ })(repos);
200
212
  // アクションにchevre取引情報を保管
201
213
  yield repos.action.findByIdAndUpdate({
202
214
  id: action.id,
@@ -277,7 +289,11 @@ function createAuthorizeMoneyTransferOfferActionAttributes(params) {
277
289
  }
278
290
  function processMoneyTransferTransaction(params) {
279
291
  // tslint:disable-next-line:max-func-body-length
280
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
292
+ return (repos
293
+ // credentials: {
294
+ // jwt: JWTCredentials;
295
+ // }
296
+ ) => __awaiter(this, void 0, void 0, function* () {
281
297
  var _a, _b;
282
298
  let pendingTransaction;
283
299
  const transaction = params.transaction;
@@ -305,7 +321,7 @@ function processMoneyTransferTransaction(params) {
305
321
  throw new factory.errors.NotImplemented('Withdraw transaction not implemented');
306
322
  }
307
323
  else if (params.object.fromLocation !== undefined && params.object.itemOffered.toLocation !== undefined) {
308
- const { fromLocation } = yield validateFromLocation({ id: params.project.id }, params.object.fromLocation, { id: issuedThroughId })(repos, credentials);
324
+ const { fromLocation } = yield validateFromLocation({ id: params.project.id }, params.object.fromLocation, { id: issuedThroughId })(repos);
309
325
  const { toLocation } = yield validateToLocation({ id: params.project.id }, {
310
326
  typeOf: factory.permit.PermitType.Permit,
311
327
  identifier: params.object.itemOffered.toLocation.identifier,
@@ -371,7 +387,11 @@ function processMoneyTransferTransaction(params) {
371
387
  }
372
388
  // tslint:disable-next-line:max-func-body-length
373
389
  function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
374
- return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
390
+ return (repos
391
+ // credentials: {
392
+ // jwt: JWTCredentials;
393
+ // }
394
+ ) => __awaiter(this, void 0, void 0, function* () {
375
395
  var _a, _b, _c;
376
396
  let fromLocation = fromLocationBeforeStart;
377
397
  // トークン化されたペイメントカード情報でリクエストされた場合、実ペイメントカード情報へ変換する
@@ -380,7 +400,7 @@ function validateFromLocation(project, fromLocationBeforeStart, issuedThrough) {
380
400
  project: { id: project.id },
381
401
  agent: { id: project.id, typeOf: factory.organizationType.Project },
382
402
  token: fromLocation
383
- })(repos, credentials);
403
+ })(repos);
384
404
  const paymentCardOwnershipInfo = authorizedObject;
385
405
  if (Array.isArray(paymentCardOwnershipInfo)) {
386
406
  throw new factory.errors.NotImplemented('fromLocation as an array not implemented');
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "4.391.0-alpha.2",
14
+ "@chevre/factory": "4.391.0-alpha.3",
15
15
  "@cinerino/sdk": "10.19.0-alpha.1",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.3.0",
@@ -112,5 +112,5 @@
112
112
  "postversion": "git push origin --tags",
113
113
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
114
114
  },
115
- "version": "22.7.0-alpha.13"
115
+ "version": "22.7.0-alpha.15"
116
116
  }
@@ -1,56 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- const project = { id: String(process.env.PROJECT_ID) };
7
- const CODE = '85de7dc1-3761-4317-80d6-b36bf0b2788f';
8
- // const ID = '6631d754c20be0772c217b90';
9
-
10
- async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
-
13
- const authorizationRepo = await chevre.repository.Authorization.createInstance(mongoose.connection);
14
- const ticketRepo = await chevre.repository.Ticket.createInstance(mongoose.connection);
15
-
16
- const result = await authorizationRepo.findValidOneByCode({
17
- project,
18
- code: CODE
19
- });
20
- console.log('result:', result);
21
-
22
- // const result = await authorizationRepo.findValidOneById({
23
- // project,
24
- // id: ID
25
- // });
26
- // console.log('result:', result);
27
-
28
- const token = await (await chevre.service.code.createService()).getToken({
29
- agent: { id: 'xxx', typeOf: chevre.factory.personType.Person },
30
- project,
31
- code: CODE,
32
- expiresIn: 18000,
33
- issuer: 'https://example.com',
34
- audience: 'https://example.com'
35
- })(
36
- {
37
- authorization: authorizationRepo,
38
- ticket: ticketRepo
39
- },
40
- {
41
- jwt: await chevre.credentials.JWT.createInstance({
42
- secret: <string>process.env.TOKEN_SECRET,
43
- issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
44
- ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
45
- : [],
46
- version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
47
- payloadTypPrefix: (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
48
- })
49
- }
50
- );
51
- console.log('token:', token);
52
- }
53
-
54
- main()
55
- .then(console.log)
56
- .catch(console.error);
@@ -1,23 +0,0 @@
1
- interface IOptions {
2
- secret: string;
3
- /**
4
- * トークン検証時の発行者リスト
5
- */
6
- issuers: string[];
7
- version: string;
8
- payloadTypPrefix: string;
9
- }
10
- /**
11
- * トークン認証情報
12
- */
13
- declare class JWTCredentials {
14
- readonly secret: string;
15
- /**
16
- * トークン検証時の発行者リスト
17
- */
18
- readonly issuers: string[];
19
- readonly version: string;
20
- readonly payloadTypPrefix: string;
21
- constructor(options: IOptions);
22
- }
23
- export { JWTCredentials };
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JWTCredentials = void 0;
4
- /**
5
- * トークン認証情報
6
- */
7
- class JWTCredentials {
8
- constructor(options) {
9
- this.version = '2024-05-02'; // 追加(2024-05-02~)
10
- this.payloadTypPrefix = 'chevre';
11
- const { secret, issuers, version, payloadTypPrefix } = options;
12
- this.issuers = issuers;
13
- this.payloadTypPrefix = payloadTypPrefix;
14
- this.secret = secret;
15
- this.version = version;
16
- }
17
- }
18
- exports.JWTCredentials = JWTCredentials;