UNPKG

fake-iamport-server

Version:
829 lines (788 loc) 465 kB
import { NestFactory } from "@nestjs/core"; import { FastifyAdapter } from "@nestjs/platform-fastify"; import core from "@nestia/core"; import { NotFoundException, ConflictException, UnprocessableEntityException, InternalServerErrorException, createParamDecorator, ForbiddenException, Controller, Module } from "@nestjs/common"; import { OutOfRange, InvalidArgument, DomainError, HashMap, TreeMap, hash, equal_to, Singleton, randint } from "tstl"; import * as __nestia_core_transform_assertGuard from "typia/lib/internal/_assertGuard.js"; import * as __nestia_core_transform_jsonStringifyString from "typia/lib/internal/_jsonStringifyString.js"; import * as __nestia_core_transform_httpParameterReadString from "typia/lib/internal/_httpParameterReadString.js"; import * as __nestia_core_transform_validateReport from "typia/lib/internal/_validateReport.js"; import { v4 } from "uuid"; import * as __nestia_core_transform_isTypeUint32 from "typia/lib/internal/_isTypeUint32.js"; import * as __nestia_core_transform_isFormatUri from "typia/lib/internal/_isFormatUri.js"; import * as __nestia_core_transform_isFormatEmail from "typia/lib/internal/_isFormatEmail.js"; import * as __nestia_core_transform_throwTypeGuardError from "typia/lib/internal/_throwTypeGuardError.js"; import * as __nestia_core_transform_httpQueryParseURLSearchParams from "typia/lib/internal/_httpQueryParseURLSearchParams.js"; import * as __nestia_core_transform_httpQueryReadBoolean from "typia/lib/internal/_httpQueryReadBoolean.js"; import { RandomGenerator } from "@nestia/e2e"; const EXTENSION = __filename.substring(__filename.length - 2); if (EXTENSION === "js") require("source-map-support").install(); var FakeIamportConfiguration; (function(FakeIamportConfiguration) { FakeIamportConfiguration.ASSETS = __dirname + "/../assets"; FakeIamportConfiguration.USER_EXPIRATION_TIME = -3 * 60 * 1e3; FakeIamportConfiguration.STORAGE_EXPIRATION = { time: 3 * 60 * 1e3, capacity: 1e3 }; FakeIamportConfiguration.API_PORT = 10851; FakeIamportConfiguration.WEBHOOK_URL = `http://127.0.0.1:${FakeIamportConfiguration.API_PORT}/internal/webhook`; FakeIamportConfiguration.authorize = accessor => accessor.imp_key === "test_imp_key" && accessor.imp_secret === "test_imp_secret"; })(FakeIamportConfiguration || (FakeIamportConfiguration = {})); core.ExceptionManager.insert(OutOfRange, (exp => new NotFoundException(exp.message))); core.ExceptionManager.insert(InvalidArgument, (exp => new ConflictException(exp.message))); core.ExceptionManager.insert(DomainError, (exp => new UnprocessableEntityException(exp.message))); core.ExceptionManager.insert(Error, (exp => new InternalServerErrorException({ message: exp.message, name: exp.name, stack: exp.stack }))); function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function(target, key) { decorator(target, key, paramIndex); }; } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; class VolatileMap { constructor(expiration, hasher = hash, pred = equal_to) { this.expiration = expiration; this.dict_ = new HashMap(hasher, pred); this.timepoints_ = new TreeMap; } clear() { this.dict_.clear(); this.timepoints_.clear(); } size() { return this.dict_.size(); } get(key) { return this.dict_.get(key); } has(key) { return this.dict_.has(key); } back() { if (this.size() === 0) throw new OutOfRange("No element exists."); return this.dict_.rbegin().second; } set(key, value) { this._Clean_up(); this.dict_.set(key, value); this.timepoints_.set(Date.now(), key); } _Clean_up() { const bound = Date.now() - this.expiration.time; const last = this.timepoints_.upper_bound(bound); for (let it = this.timepoints_.begin(); it.equals(last) === false; ) { this.dict_.erase(it.second); it = this.timepoints_.erase(it); } if (this.timepoints_.size() < this.expiration.capacity) return; let left = this.timepoints_.size() - this.expiration.capacity; while (left-- === 0) { const it = this.timepoints_.begin(); this.dict_.erase(it.second); this.timepoints_.erase(it); } } erase(key) { return this.dict_.erase(key); } } var FakeIamportStorage; (function(FakeIamportStorage) { FakeIamportStorage.certifications = new VolatileMap(FakeIamportConfiguration.STORAGE_EXPIRATION); FakeIamportStorage.payments = new VolatileMap(FakeIamportConfiguration.STORAGE_EXPIRATION); FakeIamportStorage.receipts = new VolatileMap(FakeIamportConfiguration.STORAGE_EXPIRATION); FakeIamportStorage.subscriptions = new VolatileMap(FakeIamportConfiguration.STORAGE_EXPIRATION); FakeIamportStorage.users = new VolatileMap(FakeIamportConfiguration.STORAGE_EXPIRATION); FakeIamportStorage.webhooks = new VolatileMap(FakeIamportConfiguration.STORAGE_EXPIRATION); })(FakeIamportStorage || (FakeIamportStorage = {})); function FakeIamportUserAuth() { return singleton.get()(); } (function(FakeIamportUserAuth) { function issue(accessor) { if (FakeIamportConfiguration.authorize(accessor) === false) throw new ForbiddenException("Wrong authorization key values."); const user = { now: Date.now() / 1e3, expired_at: (Date.now() + FakeIamportConfiguration.USER_EXPIRATION_TIME) / 1e3, access_token: v4() }; FakeIamportStorage.users.set(user.access_token, user); return user; } FakeIamportUserAuth.issue = issue; function authorize(request) { const token = request.headers.authorization; if (token === undefined) throw new ForbiddenException("No authorization token exists."); const user = FakeIamportStorage.users.get(token); if (new Date(user.expired_at * 1e3).getTime() > Date.now()) throw new ForbiddenException("The token has been expired."); return user; } FakeIamportUserAuth.authorize = authorize; })(FakeIamportUserAuth || (FakeIamportUserAuth = {})); const singleton = new Singleton((() => createParamDecorator((async (_0, ctx) => { const request = ctx.switchToHttp().getRequest(); return FakeIamportUserAuth.authorize(request); })))); var FakeIamportResponseProvider; (function(FakeIamportResponseProvider) { function success(response) { return { code: 0, message: "success", response }; } FakeIamportResponseProvider.success = success; })(FakeIamportResponseProvider || (FakeIamportResponseProvider = {})); let FakeIamportCertificationsController = class FakeIamportCertificationsController { at(_user, imp_uid) { const certification = FakeIamportStorage.certifications.get(imp_uid); return FakeIamportResponseProvider.success(certification); } request(_user, input) { const birth = new Date(`${input.birth.substr(0, 4)}-${input.birth.substr(4, 2)}-${input.birth.substr(6, 2)}`); const certication = { imp_uid: v4(), merchant_uid: input.merchant_uid || null, name: input.name, gender: String(Number(input.gender_digit) % 2), birth: birth.getTime() / 1e3, birthday: input.birth, foreigner: false, phone: input.phone.split("-").join(""), carrier: input.carrier, certified: false, certified_at: 0, unique_key: v4(), unique_in_site: v4(), pg_tid: v4(), pg_provider: "some-provider", origin: "fake-iamport", __otp: randint(0, 9999).toString().padStart(4, "0") }; FakeIamportStorage.certifications.set(certication.imp_uid, certication); return FakeIamportResponseProvider.success({ imp_uid: certication.imp_uid }); } confirm(_user, imp_uid, input) { const certification = FakeIamportStorage.certifications.get(imp_uid); if (certification.certified === true) throw new UnprocessableEntityException("Already certified."); else if (certification.__otp !== input.otp) throw new ForbiddenException("Wrong OTP value."); certification.certified = true; certification.certified_at = Date.now() / 1e3; return FakeIamportResponseProvider.success(certification); } erase(_user, imp_uid) { const certification = FakeIamportStorage.certifications.get(imp_uid); FakeIamportStorage.certifications.erase(imp_uid); return FakeIamportResponseProvider.success(certification); } }; __decorate([ core.TypedRoute.Get(":imp_uid", { type: "assert", assert: (() => { const _io0 = input => "number" === typeof input.code && !Number.isNaN(input.code) && "string" === typeof input.message && ("object" === typeof input.response && null !== input.response && _io1(input.response)); const _io1 = input => "string" === typeof input.imp_uid && (null === input.merchant_uid || "string" === typeof input.merchant_uid) && "string" === typeof input.name && "string" === typeof input.gender && ("number" === typeof input.birth && !Number.isNaN(input.birth)) && ("string" === typeof input.birthday && RegExp("^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.birthday)) && "boolean" === typeof input.foreigner && "string" === typeof input.phone && ("SKT" === input.carrier || "KT" === input.carrier || "LGT" === input.carrier) && "boolean" === typeof input.certified && ("number" === typeof input.certified_at && !Number.isNaN(input.certified_at)) && "string" === typeof input.unique_key && "string" === typeof input.unique_in_site && "string" === typeof input.pg_tid && "string" === typeof input.pg_provider && "string" === typeof input.origin && (undefined === input.__otp || "string" === typeof input.__otp); const _ao0 = (input, _path, _exceptionable = true) => ("number" === typeof input.code && !Number.isNaN(input.code) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".code", expected: "number", value: input.code }, _errorFactory)) && ("string" === typeof input.message || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".message", expected: "string", value: input.message }, _errorFactory)) && (("object" === typeof input.response && null !== input.response || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".response", expected: "IIamportCertification", value: input.response }, _errorFactory)) && _ao1(input.response, _path + ".response", _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".response", expected: "IIamportCertification", value: input.response }, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.imp_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".imp_uid", expected: "string", value: input.imp_uid }, _errorFactory)) && (null === input.merchant_uid || "string" === typeof input.merchant_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".merchant_uid", expected: "(null | string)", value: input.merchant_uid }, _errorFactory)) && ("string" === typeof input.name || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".name", expected: "string", value: input.name }, _errorFactory)) && ("string" === typeof input.gender || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".gender", expected: "string", value: input.gender }, _errorFactory)) && ("number" === typeof input.birth && !Number.isNaN(input.birth) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".birth", expected: "number", value: input.birth }, _errorFactory)) && ("string" === typeof input.birthday && (RegExp("^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.birthday) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".birthday", expected: 'string & Pattern<"^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">', value: input.birthday }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".birthday", expected: '(string & Pattern<"^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">)', value: input.birthday }, _errorFactory)) && ("boolean" === typeof input.foreigner || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".foreigner", expected: "boolean", value: input.foreigner }, _errorFactory)) && ("string" === typeof input.phone || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".phone", expected: "string", value: input.phone }, _errorFactory)) && ("SKT" === input.carrier || "KT" === input.carrier || "LGT" === input.carrier || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".carrier", expected: '("KT" | "LGT" | "SKT")', value: input.carrier }, _errorFactory)) && ("boolean" === typeof input.certified || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".certified", expected: "boolean", value: input.certified }, _errorFactory)) && ("number" === typeof input.certified_at && !Number.isNaN(input.certified_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".certified_at", expected: "number", value: input.certified_at }, _errorFactory)) && ("string" === typeof input.unique_key || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".unique_key", expected: "string", value: input.unique_key }, _errorFactory)) && ("string" === typeof input.unique_in_site || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".unique_in_site", expected: "string", value: input.unique_in_site }, _errorFactory)) && ("string" === typeof input.pg_tid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".pg_tid", expected: "string", value: input.pg_tid }, _errorFactory)) && ("string" === typeof input.pg_provider || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".pg_provider", expected: "string", value: input.pg_provider }, _errorFactory)) && ("string" === typeof input.origin || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".origin", expected: "string", value: input.origin }, _errorFactory)) && (undefined === input.__otp || "string" === typeof input.__otp || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Get", path: _path + ".__otp", expected: "(string | undefined)", value: input.__otp }, _errorFactory)); const _so0 = input => `{"code":${input.code},"message":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.message)},"response":${_so1(input.response)}}`; const _so1 = input => `{${undefined === input.__otp ? "" : `"__otp":${undefined !== input.__otp ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.__otp) : undefined},`}"imp_uid":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.imp_uid)},"merchant_uid":${null !== input.merchant_uid ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.merchant_uid) : "null"},"name":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.name)},"gender":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.gender)},"birth":${input.birth},"birthday":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.birthday)},"foreigner":${input.foreigner},"phone":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.phone)},"carrier":${'"' + input.carrier + '"'},"certified":${input.certified},"certified_at":${input.certified_at},"unique_key":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.unique_key)},"unique_in_site":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.unique_in_site)},"pg_tid":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_tid)},"pg_provider":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_provider)},"origin":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.origin)}}`; const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; const __assert = (input, errorFactory) => { if (false === __is(input)) { _errorFactory = errorFactory; ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Get", path: _path + "", expected: "IIamportResponse<IIamportCertification>", value: input }, _errorFactory)) && _ao0(input, _path + "", true) || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Get", path: _path + "", expected: "IIamportResponse<IIamportCertification>", value: input }, _errorFactory))(input, "$input", true); } return input; }; const __stringify = input => _so0(input); return (input, errorFactory) => { __assert(input, errorFactory); return __stringify(input); }; })() }), __param(0, FakeIamportUserAuth()), __param(1, core.TypedParam("imp_uid", (input => { const assert = (() => { const __is = input => "string" === typeof input; let _errorFactory; return (input, errorFactory) => { if (false === __is(input)) { _errorFactory = errorFactory; ((input, _path, _exceptionable = true) => "string" === typeof input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedParam", path: _path + "", expected: "string", value: input }, _errorFactory))(input, "$input", true); } return input; }; })(); const value = __nestia_core_transform_httpParameterReadString._httpParameterReadString(input); return assert(value); }))), __metadata("design:type", Function), __metadata("design:paramtypes", [ Object, String ]), __metadata("design:returntype", Object) ], FakeIamportCertificationsController.prototype, "at", null); __decorate([ core.TypedRoute.Post("otp/request", { type: "assert", assert: (() => { const _io0 = input => "number" === typeof input.code && !Number.isNaN(input.code) && "string" === typeof input.message && ("object" === typeof input.response && null !== input.response && _io1(input.response)); const _io1 = input => "string" === typeof input.imp_uid; const _ao0 = (input, _path, _exceptionable = true) => ("number" === typeof input.code && !Number.isNaN(input.code) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".code", expected: "number", value: input.code }, _errorFactory)) && ("string" === typeof input.message || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".message", expected: "string", value: input.message }, _errorFactory)) && (("object" === typeof input.response && null !== input.response || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".response", expected: "IIamportCertification.IAccessor", value: input.response }, _errorFactory)) && _ao1(input.response, _path + ".response", _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".response", expected: "IIamportCertification.IAccessor", value: input.response }, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => "string" === typeof input.imp_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".imp_uid", expected: "string", value: input.imp_uid }, _errorFactory); const _so0 = input => `{"code":${input.code},"message":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.message)},"response":${_so1(input.response)}}`; const _so1 = input => `{"imp_uid":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.imp_uid)}}`; const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; const __assert = (input, errorFactory) => { if (false === __is(input)) { _errorFactory = errorFactory; ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "IIamportResponse<IIamportCertification.IAccessor>", value: input }, _errorFactory)) && _ao0(input, _path + "", true) || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "IIamportResponse<IIamportCertification.IAccessor>", value: input }, _errorFactory))(input, "$input", true); } return input; }; const __stringify = input => _so0(input); return (input, errorFactory) => { __assert(input, errorFactory); return __stringify(input); }; })() }), __param(0, FakeIamportUserAuth()), __param(1, core.TypedBody({ type: "validate", validate: (() => { const _io0 = input => "string" === typeof input.name && "string" === typeof input.phone && ("string" === typeof input.birth && RegExp("^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.birth)) && "string" === typeof input.gender_digit && ("SKT" === input.carrier || "KT" === input.carrier || "LGT" === input.carrier) && (undefined === input.is_mvno || "boolean" === typeof input.is_mvno) && (undefined === input.commpany || "string" === typeof input.commpany) && (undefined === input.merchant_uid || "string" === typeof input.merchant_uid) && (undefined === input.pg || "string" === typeof input.pg); const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.name || _report(_exceptionable, { path: _path + ".name", expected: "string", value: input.name }), "string" === typeof input.phone || _report(_exceptionable, { path: _path + ".phone", expected: "string", value: input.phone }), "string" === typeof input.birth && (RegExp("^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.birth) || _report(_exceptionable, { path: _path + ".birth", expected: 'string & Pattern<"^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">', value: input.birth })) || _report(_exceptionable, { path: _path + ".birth", expected: '(string & Pattern<"^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">)', value: input.birth }), "string" === typeof input.gender_digit || _report(_exceptionable, { path: _path + ".gender_digit", expected: "string", value: input.gender_digit }), "SKT" === input.carrier || "KT" === input.carrier || "LGT" === input.carrier || _report(_exceptionable, { path: _path + ".carrier", expected: '("KT" | "LGT" | "SKT")', value: input.carrier }), undefined === input.is_mvno || "boolean" === typeof input.is_mvno || _report(_exceptionable, { path: _path + ".is_mvno", expected: "(boolean | undefined)", value: input.is_mvno }), undefined === input.commpany || "string" === typeof input.commpany || _report(_exceptionable, { path: _path + ".commpany", expected: "(string | undefined)", value: input.commpany }), undefined === input.merchant_uid || "string" === typeof input.merchant_uid || _report(_exceptionable, { path: _path + ".merchant_uid", expected: "(string | undefined)", value: input.merchant_uid }), undefined === input.pg || "string" === typeof input.pg || _report(_exceptionable, { path: _path + ".pg", expected: "(string | undefined)", value: input.pg }) ].every((flag => flag)); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => { if (false === __is(input)) { errors = []; _report = __nestia_core_transform_validateReport._validateReport(errors); ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, { path: _path + "", expected: "IIamportCertification.ICreate", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IIamportCertification.ICreate", value: input }))(input, "$input", true); const success = 0 === errors.length; return success ? { success, data: input } : { success, errors, data: input }; } return { success: true, data: input }; }; })() })), __metadata("design:type", Function), __metadata("design:paramtypes", [ Object, Object ]), __metadata("design:returntype", Object) ], FakeIamportCertificationsController.prototype, "request", null); __decorate([ core.TypedRoute.Post("otp/confirm/:imp_uid", { type: "assert", assert: (() => { const _io0 = input => "number" === typeof input.code && !Number.isNaN(input.code) && "string" === typeof input.message && ("object" === typeof input.response && null !== input.response && _io1(input.response)); const _io1 = input => "string" === typeof input.imp_uid && (null === input.merchant_uid || "string" === typeof input.merchant_uid) && "string" === typeof input.name && "string" === typeof input.gender && ("number" === typeof input.birth && !Number.isNaN(input.birth)) && ("string" === typeof input.birthday && RegExp("^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.birthday)) && "boolean" === typeof input.foreigner && "string" === typeof input.phone && ("SKT" === input.carrier || "KT" === input.carrier || "LGT" === input.carrier) && "boolean" === typeof input.certified && ("number" === typeof input.certified_at && !Number.isNaN(input.certified_at)) && "string" === typeof input.unique_key && "string" === typeof input.unique_in_site && "string" === typeof input.pg_tid && "string" === typeof input.pg_provider && "string" === typeof input.origin && (undefined === input.__otp || "string" === typeof input.__otp); const _ao0 = (input, _path, _exceptionable = true) => ("number" === typeof input.code && !Number.isNaN(input.code) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".code", expected: "number", value: input.code }, _errorFactory)) && ("string" === typeof input.message || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".message", expected: "string", value: input.message }, _errorFactory)) && (("object" === typeof input.response && null !== input.response || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".response", expected: "IIamportCertification", value: input.response }, _errorFactory)) && _ao1(input.response, _path + ".response", _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".response", expected: "IIamportCertification", value: input.response }, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.imp_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".imp_uid", expected: "string", value: input.imp_uid }, _errorFactory)) && (null === input.merchant_uid || "string" === typeof input.merchant_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".merchant_uid", expected: "(null | string)", value: input.merchant_uid }, _errorFactory)) && ("string" === typeof input.name || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".name", expected: "string", value: input.name }, _errorFactory)) && ("string" === typeof input.gender || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".gender", expected: "string", value: input.gender }, _errorFactory)) && ("number" === typeof input.birth && !Number.isNaN(input.birth) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".birth", expected: "number", value: input.birth }, _errorFactory)) && ("string" === typeof input.birthday && (RegExp("^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.birthday) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".birthday", expected: 'string & Pattern<"^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">', value: input.birthday }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".birthday", expected: '(string & Pattern<"^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">)', value: input.birthday }, _errorFactory)) && ("boolean" === typeof input.foreigner || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".foreigner", expected: "boolean", value: input.foreigner }, _errorFactory)) && ("string" === typeof input.phone || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".phone", expected: "string", value: input.phone }, _errorFactory)) && ("SKT" === input.carrier || "KT" === input.carrier || "LGT" === input.carrier || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".carrier", expected: '("KT" | "LGT" | "SKT")', value: input.carrier }, _errorFactory)) && ("boolean" === typeof input.certified || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".certified", expected: "boolean", value: input.certified }, _errorFactory)) && ("number" === typeof input.certified_at && !Number.isNaN(input.certified_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".certified_at", expected: "number", value: input.certified_at }, _errorFactory)) && ("string" === typeof input.unique_key || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".unique_key", expected: "string", value: input.unique_key }, _errorFactory)) && ("string" === typeof input.unique_in_site || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".unique_in_site", expected: "string", value: input.unique_in_site }, _errorFactory)) && ("string" === typeof input.pg_tid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".pg_tid", expected: "string", value: input.pg_tid }, _errorFactory)) && ("string" === typeof input.pg_provider || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".pg_provider", expected: "string", value: input.pg_provider }, _errorFactory)) && ("string" === typeof input.origin || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".origin", expected: "string", value: input.origin }, _errorFactory)) && (undefined === input.__otp || "string" === typeof input.__otp || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Post", path: _path + ".__otp", expected: "(string | undefined)", value: input.__otp }, _errorFactory)); const _so0 = input => `{"code":${input.code},"message":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.message)},"response":${_so1(input.response)}}`; const _so1 = input => `{${undefined === input.__otp ? "" : `"__otp":${undefined !== input.__otp ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.__otp) : undefined},`}"imp_uid":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.imp_uid)},"merchant_uid":${null !== input.merchant_uid ? __nestia_core_transform_jsonStringifyString._jsonStringifyString(input.merchant_uid) : "null"},"name":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.name)},"gender":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.gender)},"birth":${input.birth},"birthday":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.birthday)},"foreigner":${input.foreigner},"phone":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.phone)},"carrier":${'"' + input.carrier + '"'},"certified":${input.certified},"certified_at":${input.certified_at},"unique_key":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.unique_key)},"unique_in_site":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.unique_in_site)},"pg_tid":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_tid)},"pg_provider":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.pg_provider)},"origin":${__nestia_core_transform_jsonStringifyString._jsonStringifyString(input.origin)}}`; const __is = input => "object" === typeof input && null !== input && _io0(input); let _errorFactory; const __assert = (input, errorFactory) => { if (false === __is(input)) { _errorFactory = errorFactory; ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "IIamportResponse<IIamportCertification>", value: input }, _errorFactory)) && _ao0(input, _path + "", true) || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedRoute.Post", path: _path + "", expected: "IIamportResponse<IIamportCertification>", value: input }, _errorFactory))(input, "$input", true); } return input; }; const __stringify = input => _so0(input); return (input, errorFactory) => { __assert(input, errorFactory); return __stringify(input); }; })() }), __param(0, FakeIamportUserAuth()), __param(1, core.TypedParam("imp_uid", (input => { const assert = (() => { const __is = input => "string" === typeof input; let _errorFactory; return (input, errorFactory) => { if (false === __is(input)) { _errorFactory = errorFactory; ((input, _path, _exceptionable = true) => "string" === typeof input || __nestia_core_transform_assertGuard._assertGuard(true, { method: "core.TypedParam", path: _path + "", expected: "string", value: input }, _errorFactory))(input, "$input", true); } return input; }; })(); const value = __nestia_core_transform_httpParameterReadString._httpParameterReadString(input); return assert(value); }))), __param(2, core.TypedBody({ type: "validate", validate: (() => { const _io0 = input => "string" === typeof input.otp; const _vo0 = (input, _path, _exceptionable = true) => [ "string" === typeof input.otp || _report(_exceptionable, { path: _path + ".otp", expected: "string", value: input.otp }) ].every((flag => flag)); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => { if (false === __is(input)) { errors = []; _report = __nestia_core_transform_validateReport._validateReport(errors); ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, { path: _path + "", expected: "IIamportCertification.IConfirm", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IIamportCertification.IConfirm", value: input }))(input, "$input", true); const success = 0 === errors.length; return success ? { success, data: input } : { success, errors, data: input }; } return { success: true, data: input }; }; })() })), __metadata("design:type", Function), __metadata("design:paramtypes", [ Object, String, Object ]), __metadata("design:returntype", Object) ], FakeIamportCertificationsController.prototype, "confirm", null); __decorate([ core.TypedRoute.Delete(":imp_uid", { type: "assert", assert: (() => { const _io0 = input => "number" === typeof input.code && !Number.isNaN(input.code) && "string" === typeof input.message && ("object" === typeof input.response && null !== input.response && _io1(input.response)); const _io1 = input => "string" === typeof input.imp_uid && (null === input.merchant_uid || "string" === typeof input.merchant_uid) && "string" === typeof input.name && "string" === typeof input.gender && ("number" === typeof input.birth && !Number.isNaN(input.birth)) && ("string" === typeof input.birthday && RegExp("^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.birthday)) && "boolean" === typeof input.foreigner && "string" === typeof input.phone && ("SKT" === input.carrier || "KT" === input.carrier || "LGT" === input.carrier) && "boolean" === typeof input.certified && ("number" === typeof input.certified_at && !Number.isNaN(input.certified_at)) && "string" === typeof input.unique_key && "string" === typeof input.unique_in_site && "string" === typeof input.pg_tid && "string" === typeof input.pg_provider && "string" === typeof input.origin && (undefined === input.__otp || "string" === typeof input.__otp); const _ao0 = (input, _path, _exceptionable = true) => ("number" === typeof input.code && !Number.isNaN(input.code) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".code", expected: "number", value: input.code }, _errorFactory)) && ("string" === typeof input.message || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".message", expected: "string", value: input.message }, _errorFactory)) && (("object" === typeof input.response && null !== input.response || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".response", expected: "IIamportCertification", value: input.response }, _errorFactory)) && _ao1(input.response, _path + ".response", _exceptionable) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".response", expected: "IIamportCertification", value: input.response }, _errorFactory)); const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.imp_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".imp_uid", expected: "string", value: input.imp_uid }, _errorFactory)) && (null === input.merchant_uid || "string" === typeof input.merchant_uid || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".merchant_uid", expected: "(null | string)", value: input.merchant_uid }, _errorFactory)) && ("string" === typeof input.name || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".name", expected: "string", value: input.name }, _errorFactory)) && ("string" === typeof input.gender || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".gender", expected: "string", value: input.gender }, _errorFactory)) && ("number" === typeof input.birth && !Number.isNaN(input.birth) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".birth", expected: "number", value: input.birth }, _errorFactory)) && ("string" === typeof input.birthday && (RegExp("^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$").test(input.birthday) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".birthday", expected: 'string & Pattern<"^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">', value: input.birthday }, _errorFactory)) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".birthday", expected: '(string & Pattern<"^([0-9]{4})(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])$">)', value: input.birthday }, _errorFactory)) && ("boolean" === typeof input.foreigner || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".foreigner", expected: "boolean", value: input.foreigner }, _errorFactory)) && ("string" === typeof input.phone || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".phone", expected: "string", value: input.phone }, _errorFactory)) && ("SKT" === input.carrier || "KT" === input.carrier || "LGT" === input.carrier || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".carrier", expected: '("KT" | "LGT" | "SKT")', value: input.carrier }, _errorFactory)) && ("boolean" === typeof input.certified || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".certified", expected: "boolean", value: input.certified }, _errorFactory)) && ("number" === typeof input.certified_at && !Number.isNaN(input.certified_at) || __nestia_core_transform_assertGuard._assertGuard(_exceptionable, { method: "core.TypedRoute.Delete", path: _path + ".certified_at", expected: "number", value: input.certified_at }, _errorFactory)) && ("string" === typeof input.unique_key || __nestia_core_transform_assertGuard._assertGuard(_exceptionable,