UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

37 lines (36 loc) 3.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AGENT_IDENTIFIER_NAME_PASSPORT = void 0; exports.createStartParams = createStartParams; const factory = require("../../../../factory"); const AGENT_IDENTIFIER_NAME_PASSPORT = 'passport'; exports.AGENT_IDENTIFIER_NAME_PASSPORT = AGENT_IDENTIFIER_NAME_PASSPORT; function createStartParams(params, expiresInSeconds, passport, seller, broker, customerType, memeberOfPayload) { var _a, _b, _c, _d; let clientUser; let instrument; if (typeof ((_a = params.object.clientUser) === null || _a === void 0 ? void 0 : _a.client_id) === 'string') { const { sub, token_use, iss, exp, iat, version, jti, client_id, username, aud, typ } = params.object.clientUser; clientUser = { sub, token_use, iss, exp, iat, version, jti, client_id, username, aud, typ }; instrument = { id: client_id, typeOf: factory.creativeWorkType.WebApplication }; } const transactionObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (typeof (passport === null || passport === void 0 ? void 0 : passport.scope) === 'string') ? { passport } : undefined), (typeof (clientUser === null || clientUser === void 0 ? void 0 : clientUser.client_id) === 'string') ? { clientUser } : undefined), (typeof ((_b = params.object) === null || _b === void 0 ? void 0 : _b.name) === 'string') ? { name: (_c = params.object) === null || _c === void 0 ? void 0 : _c.name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker: broker } : undefined), (typeof ((_d = params.object.customer) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string') ? { customer: params.object.customer } : undefined), (typeof customerType === 'string') ? { customerType } : undefined); if (typeof seller.id !== 'string') { throw new factory.errors.NotFound('seller.id'); } if (typeof expiresInSeconds !== 'number') { throw new factory.errors.ArgumentNull('expiresInSeconds'); } const agentIdentifier = [ ...(Array.isArray(params.agent.identifier)) ? params.agent.identifier : [], // add passport(2024-07-05~) ...(typeof (passport === null || passport === void 0 ? void 0 : passport.identifier) === 'string') ? [{ name: AGENT_IDENTIFIER_NAME_PASSPORT, value: passport.identifier }] : [] ]; const agent = Object.assign(Object.assign(Object.assign({}, params.agent), (memeberOfPayload !== undefined) ? { memeberOfPayload } : undefined), { identifier: agentIdentifier }); return Object.assign({ project: { typeOf: seller.project.typeOf, id: seller.project.id }, typeOf: factory.transactionType.PlaceOrder, agent, seller: { id: seller.id, name: seller.name, typeOf: seller.typeOf, additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : [] // 追加特性を追加(2023-08-08~) }, object: transactionObject, expiresInSeconds }, (typeof (instrument === null || instrument === void 0 ? void 0 : instrument.id) === 'string') ? { instrument } : undefined); }