@cinerino/sdk 14.0.0-alpha.8 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/README.md +0 -3
  2. package/lib/abstract/auth/authClient.js +10 -60
  3. package/lib/abstract/chevre/categoryCode.d.ts +1 -1
  4. package/lib/abstract/chevre/categoryCode.js +16 -84
  5. package/lib/abstract/chevre/creativeWork.d.ts +1 -1
  6. package/lib/abstract/chevre/creativeWork.js +16 -84
  7. package/lib/abstract/chevre/emailMessage.d.ts +1 -1
  8. package/lib/abstract/chevre/emailMessage.js +16 -84
  9. package/lib/abstract/chevre/event/factory.d.ts +1 -1
  10. package/lib/abstract/chevre/event.d.ts +1 -1
  11. package/lib/abstract/chevre/event.js +102 -270
  12. package/lib/abstract/chevre/eventOffer.d.ts +1 -1
  13. package/lib/abstract/chevre/eventOffer.js +13 -76
  14. package/lib/abstract/chevre/eventSeries.d.ts +1 -1
  15. package/lib/abstract/chevre/eventSeries.js +12 -75
  16. package/lib/abstract/chevre/note.d.ts +1 -1
  17. package/lib/abstract/chevre/note.js +14 -77
  18. package/lib/abstract/chevre/paymentService.d.ts +1 -1
  19. package/lib/abstract/chevre/paymentService.js +14 -78
  20. package/lib/abstract/chevre/place/hasPOS.d.ts +1 -1
  21. package/lib/abstract/chevre/place/hasPOS.js +13 -99
  22. package/lib/abstract/chevre/place.d.ts +1 -1
  23. package/lib/abstract/chevre/place.js +82 -232
  24. package/lib/abstract/chevre/product.d.ts +1 -1
  25. package/lib/abstract/chevre/product.js +34 -124
  26. package/lib/abstract/chevre/productOffer.d.ts +1 -1
  27. package/lib/abstract/chevre/productOffer.js +13 -76
  28. package/lib/abstract/chevre/seatOffer.d.ts +1 -1
  29. package/lib/abstract/chevre/seatOffer.js +15 -79
  30. package/lib/abstract/chevre/seller/factory.d.ts +1 -1
  31. package/lib/abstract/chevre/seller.d.ts +1 -1
  32. package/lib/abstract/chevre/seller.js +42 -128
  33. package/lib/abstract/chevre/trip.d.ts +1 -1
  34. package/lib/abstract/chevre/trip.js +16 -84
  35. package/lib/abstract/chevre.js +127 -329
  36. package/lib/abstract/chevreAdmic/sync.js +24 -94
  37. package/lib/abstract/chevreAdmic.js +28 -76
  38. package/lib/abstract/chevreAdmin/assetTransaction/cancelReservation.d.ts +1 -1
  39. package/lib/abstract/chevreAdmin/assetTransaction/cancelReservation.js +11 -76
  40. package/lib/abstract/chevreAdmin/authorization.d.ts +1 -1
  41. package/lib/abstract/chevreAdmin/authorization.js +13 -76
  42. package/lib/abstract/chevreAdmin/customer.d.ts +1 -1
  43. package/lib/abstract/chevreAdmin/customer.js +13 -76
  44. package/lib/abstract/chevreAdmin/event.d.ts +1 -1
  45. package/lib/abstract/chevreAdmin/event.js +56 -162
  46. package/lib/abstract/chevreAdmin/eventOffer.d.ts +1 -1
  47. package/lib/abstract/chevreAdmin/eventOffer.js +41 -134
  48. package/lib/abstract/chevreAdmin/eventSeries.d.ts +1 -1
  49. package/lib/abstract/chevreAdmin/eventSeries.js +30 -104
  50. package/lib/abstract/chevreAdmin/me.d.ts +1 -1
  51. package/lib/abstract/chevreAdmin/me.js +25 -104
  52. package/lib/abstract/chevreAdmin/member.d.ts +1 -1
  53. package/lib/abstract/chevreAdmin/member.js +14 -100
  54. package/lib/abstract/chevreAdmin/movie.d.ts +1 -1
  55. package/lib/abstract/chevreAdmin/movie.js +21 -93
  56. package/lib/abstract/chevreAdmin/movieTheater.d.ts +1 -1
  57. package/lib/abstract/chevreAdmin/movieTheater.js +56 -162
  58. package/lib/abstract/chevreAdmin/note.d.ts +1 -1
  59. package/lib/abstract/chevreAdmin/note.js +32 -117
  60. package/lib/abstract/chevreAdmin/noteAboutOrder.d.ts +1 -1
  61. package/lib/abstract/chevreAdmin/noteAboutOrder.js +29 -112
  62. package/lib/abstract/chevreAdmin/offer.d.ts +1 -1
  63. package/lib/abstract/chevreAdmin/offer.js +24 -98
  64. package/lib/abstract/chevreAdmin/offerCatalog.d.ts +1 -1
  65. package/lib/abstract/chevreAdmin/offerCatalog.js +18 -85
  66. package/lib/abstract/chevreAdmin/offerCatalogItem.d.ts +1 -1
  67. package/lib/abstract/chevreAdmin/offerCatalogItem.js +25 -99
  68. package/lib/abstract/chevreAdmin/order.d.ts +1 -1
  69. package/lib/abstract/chevreAdmin/order.js +50 -161
  70. package/lib/abstract/chevreAdmin/paymentMethod.d.ts +1 -1
  71. package/lib/abstract/chevreAdmin/paymentMethod.js +15 -78
  72. package/lib/abstract/chevreAdmin/product.d.ts +1 -1
  73. package/lib/abstract/chevreAdmin/product.js +31 -110
  74. package/lib/abstract/chevreAdmin/productOffer.d.ts +1 -1
  75. package/lib/abstract/chevreAdmin/productOffer.js +41 -134
  76. package/lib/abstract/chevreAdmin/reservation.d.ts +1 -1
  77. package/lib/abstract/chevreAdmin/reservation.js +31 -125
  78. package/lib/abstract/chevreAdmin/room.d.ts +1 -1
  79. package/lib/abstract/chevreAdmin/room.js +25 -99
  80. package/lib/abstract/chevreAdmin/seat.d.ts +1 -1
  81. package/lib/abstract/chevreAdmin/seat.js +38 -129
  82. package/lib/abstract/chevreAdmin/seatSection.d.ts +1 -1
  83. package/lib/abstract/chevreAdmin/seatSection.js +25 -99
  84. package/lib/abstract/chevreAdmin/seller.d.ts +1 -1
  85. package/lib/abstract/chevreAdmin/seller.js +13 -76
  86. package/lib/abstract/chevreAdmin.js +191 -492
  87. package/lib/abstract/chevreAsset/order/factory.d.ts +1 -1
  88. package/lib/abstract/chevreAsset/order.js +77 -231
  89. package/lib/abstract/chevreAsset/permit.d.ts +1 -1
  90. package/lib/abstract/chevreAsset/permit.js +22 -92
  91. package/lib/abstract/chevreAsset/reservation/factory.d.ts +1 -1
  92. package/lib/abstract/chevreAsset/reservation.d.ts +1 -1
  93. package/lib/abstract/chevreAsset/reservation.js +23 -93
  94. package/lib/abstract/chevreAsset/token.js +4 -24
  95. package/lib/abstract/chevreAsset.js +65 -135
  96. package/lib/abstract/chevreConsole/account.d.ts +1 -1
  97. package/lib/abstract/chevreConsole/account.js +32 -116
  98. package/lib/abstract/chevreConsole/accountTitle.d.ts +1 -1
  99. package/lib/abstract/chevreConsole/accountTitle.js +113 -303
  100. package/lib/abstract/chevreConsole/accountTransaction.d.ts +3 -3
  101. package/lib/abstract/chevreConsole/accountTransaction.js +16 -84
  102. package/lib/abstract/chevreConsole/accountingReport.d.ts +1 -1
  103. package/lib/abstract/chevreConsole/accountingReport.js +16 -84
  104. package/lib/abstract/chevreConsole/action.d.ts +1 -1
  105. package/lib/abstract/chevreConsole/action.js +33 -115
  106. package/lib/abstract/chevreConsole/additionalProperty.d.ts +1 -1
  107. package/lib/abstract/chevreConsole/additionalProperty.js +46 -146
  108. package/lib/abstract/chevreConsole/advanceBookingRequirement.d.ts +1 -1
  109. package/lib/abstract/chevreConsole/advanceBookingRequirement.js +36 -139
  110. package/lib/abstract/chevreConsole/aggregateOffer.d.ts +1 -1
  111. package/lib/abstract/chevreConsole/aggregateOffer.js +22 -99
  112. package/lib/abstract/chevreConsole/aggregateReservation.d.ts +1 -1
  113. package/lib/abstract/chevreConsole/aggregateReservation.js +12 -75
  114. package/lib/abstract/chevreConsole/aggregation.d.ts +1 -1
  115. package/lib/abstract/chevreConsole/aggregation.js +15 -86
  116. package/lib/abstract/chevreConsole/assetTransaction/moneyTransfer.d.ts +1 -1
  117. package/lib/abstract/chevreConsole/assetTransaction/moneyTransfer.js +33 -139
  118. package/lib/abstract/chevreConsole/assetTransaction/pay.d.ts +1 -1
  119. package/lib/abstract/chevreConsole/assetTransaction/pay.js +44 -168
  120. package/lib/abstract/chevreConsole/assetTransaction/registerService.d.ts +1 -1
  121. package/lib/abstract/chevreConsole/assetTransaction/registerService.js +33 -150
  122. package/lib/abstract/chevreConsole/assetTransaction/reserve.d.ts +1 -1
  123. package/lib/abstract/chevreConsole/assetTransaction/reserve.js +40 -143
  124. package/lib/abstract/chevreConsole/assetTransaction.d.ts +1 -1
  125. package/lib/abstract/chevreConsole/assetTransaction.js +16 -84
  126. package/lib/abstract/chevreConsole/authorization.d.ts +1 -1
  127. package/lib/abstract/chevreConsole/authorization.js +13 -76
  128. package/lib/abstract/chevreConsole/categoryCode.d.ts +1 -1
  129. package/lib/abstract/chevreConsole/categoryCode.js +40 -137
  130. package/lib/abstract/chevreConsole/comment.d.ts +1 -1
  131. package/lib/abstract/chevreConsole/comment.js +25 -100
  132. package/lib/abstract/chevreConsole/creativeWork.js +15 -80
  133. package/lib/abstract/chevreConsole/customer.d.ts +1 -1
  134. package/lib/abstract/chevreConsole/customer.js +26 -107
  135. package/lib/abstract/chevreConsole/customerType.d.ts +1 -1
  136. package/lib/abstract/chevreConsole/customerType.js +13 -76
  137. package/lib/abstract/chevreConsole/emailMessage.d.ts +1 -1
  138. package/lib/abstract/chevreConsole/emailMessage.js +47 -147
  139. package/lib/abstract/chevreConsole/event/factory.d.ts +1 -1
  140. package/lib/abstract/chevreConsole/event.d.ts +1 -1
  141. package/lib/abstract/chevreConsole/event.js +60 -184
  142. package/lib/abstract/chevreConsole/eventSeries.js +23 -118
  143. package/lib/abstract/chevreConsole/hasMerchantReturnPolicy.d.ts +1 -1
  144. package/lib/abstract/chevreConsole/hasMerchantReturnPolicy.js +11 -74
  145. package/lib/abstract/chevreConsole/iam.d.ts +1 -1
  146. package/lib/abstract/chevreConsole/iam.js +116 -301
  147. package/lib/abstract/chevreConsole/identity.d.ts +1 -1
  148. package/lib/abstract/chevreConsole/identity.js +36 -139
  149. package/lib/abstract/chevreConsole/identityProvider.d.ts +1 -1
  150. package/lib/abstract/chevreConsole/identityProvider.js +36 -139
  151. package/lib/abstract/chevreConsole/issuer.d.ts +1 -1
  152. package/lib/abstract/chevreConsole/issuer.js +44 -152
  153. package/lib/abstract/chevreConsole/me.d.ts +1 -1
  154. package/lib/abstract/chevreConsole/me.js +26 -109
  155. package/lib/abstract/chevreConsole/member.d.ts +1 -1
  156. package/lib/abstract/chevreConsole/member.js +63 -210
  157. package/lib/abstract/chevreConsole/memberProgram.js +47 -156
  158. package/lib/abstract/chevreConsole/merchantReturnPolicy.d.ts +1 -1
  159. package/lib/abstract/chevreConsole/merchantReturnPolicy.js +45 -145
  160. package/lib/abstract/chevreConsole/message.d.ts +1 -1
  161. package/lib/abstract/chevreConsole/message.js +12 -75
  162. package/lib/abstract/chevreConsole/movieTicketType.d.ts +1 -1
  163. package/lib/abstract/chevreConsole/movieTicketType.js +36 -124
  164. package/lib/abstract/chevreConsole/offer.d.ts +1 -1
  165. package/lib/abstract/chevreConsole/offer.js +29 -108
  166. package/lib/abstract/chevreConsole/offerCatalog.d.ts +1 -1
  167. package/lib/abstract/chevreConsole/offerCatalog.js +38 -138
  168. package/lib/abstract/chevreConsole/offerCatalogItem.d.ts +1 -1
  169. package/lib/abstract/chevreConsole/offerCatalogItem.js +51 -167
  170. package/lib/abstract/chevreConsole/offerItemCondition.d.ts +1 -1
  171. package/lib/abstract/chevreConsole/offerItemCondition.js +38 -131
  172. package/lib/abstract/chevreConsole/order/factory.d.ts +1 -1
  173. package/lib/abstract/chevreConsole/order.d.ts +1 -1
  174. package/lib/abstract/chevreConsole/order.js +45 -144
  175. package/lib/abstract/chevreConsole/ownershipInfo.d.ts +1 -1
  176. package/lib/abstract/chevreConsole/ownershipInfo.js +16 -84
  177. package/lib/abstract/chevreConsole/paymentService.d.ts +1 -1
  178. package/lib/abstract/chevreConsole/paymentService.js +55 -169
  179. package/lib/abstract/chevreConsole/paymentServiceChannel.d.ts +1 -1
  180. package/lib/abstract/chevreConsole/paymentServiceChannel.js +36 -139
  181. package/lib/abstract/chevreConsole/pendingReservation.d.ts +1 -1
  182. package/lib/abstract/chevreConsole/pendingReservation.js +23 -94
  183. package/lib/abstract/chevreConsole/permission.js +22 -93
  184. package/lib/abstract/chevreConsole/permit.d.ts +1 -1
  185. package/lib/abstract/chevreConsole/permit.js +34 -116
  186. package/lib/abstract/chevreConsole/person.d.ts +1 -1
  187. package/lib/abstract/chevreConsole/person.js +67 -186
  188. package/lib/abstract/chevreConsole/place/hasPOS.d.ts +1 -1
  189. package/lib/abstract/chevreConsole/place/hasPOS.js +33 -146
  190. package/lib/abstract/chevreConsole/place.d.ts +1 -1
  191. package/lib/abstract/chevreConsole/place.js +97 -260
  192. package/lib/abstract/chevreConsole/priceSpecification.d.ts +1 -1
  193. package/lib/abstract/chevreConsole/priceSpecification.js +37 -130
  194. package/lib/abstract/chevreConsole/product.d.ts +1 -1
  195. package/lib/abstract/chevreConsole/product.js +48 -155
  196. package/lib/abstract/chevreConsole/productModel.d.ts +1 -1
  197. package/lib/abstract/chevreConsole/productModel.js +34 -122
  198. package/lib/abstract/chevreConsole/project.d.ts +1 -1
  199. package/lib/abstract/chevreConsole/project.js +38 -147
  200. package/lib/abstract/chevreConsole/projectMakesOffer.d.ts +1 -1
  201. package/lib/abstract/chevreConsole/projectMakesOffer.js +32 -122
  202. package/lib/abstract/chevreConsole/reservation/factory.d.ts +1 -1
  203. package/lib/abstract/chevreConsole/reservation.js +11 -76
  204. package/lib/abstract/chevreConsole/seller/factory.d.ts +1 -1
  205. package/lib/abstract/chevreConsole/seller.d.ts +1 -1
  206. package/lib/abstract/chevreConsole/seller.js +139 -362
  207. package/lib/abstract/chevreConsole/sellerMakesOffer.d.ts +1 -1
  208. package/lib/abstract/chevreConsole/sellerMakesOffer.js +26 -107
  209. package/lib/abstract/chevreConsole/sellerReturnPolicy.d.ts +1 -1
  210. package/lib/abstract/chevreConsole/sellerReturnPolicy.js +45 -156
  211. package/lib/abstract/chevreConsole/task.d.ts +1 -1
  212. package/lib/abstract/chevreConsole/task.js +29 -108
  213. package/lib/abstract/chevreConsole/ticket.d.ts +1 -1
  214. package/lib/abstract/chevreConsole/ticket.js +12 -75
  215. package/lib/abstract/chevreConsole/token.js +4 -24
  216. package/lib/abstract/chevreConsole/transaction/placeOrder.d.ts +2 -3
  217. package/lib/abstract/chevreConsole/transaction/placeOrder.js +28 -139
  218. package/lib/abstract/chevreConsole/transaction/returnOrder.d.ts +2 -3
  219. package/lib/abstract/chevreConsole/transaction/returnOrder.js +18 -110
  220. package/lib/abstract/chevreConsole/transactionNumber.js +13 -76
  221. package/lib/abstract/chevreConsole/trip.d.ts +1 -1
  222. package/lib/abstract/chevreConsole/trip.js +46 -146
  223. package/lib/abstract/chevreConsole/userPool.d.ts +1 -1
  224. package/lib/abstract/chevreConsole/userPool.js +32 -114
  225. package/lib/abstract/chevreConsole/webSite.d.ts +1 -1
  226. package/lib/abstract/chevreConsole/webSite.js +36 -128
  227. package/lib/abstract/chevreConsole.js +496 -1270
  228. package/lib/abstract/chevrePay/payment/factory.d.ts +1 -1
  229. package/lib/abstract/chevrePay/payment.d.ts +1 -1
  230. package/lib/abstract/chevrePay/payment.js +300 -498
  231. package/lib/abstract/chevrePay.js +33 -84
  232. package/lib/abstract/chevreTxc/offer/factory.d.ts +1 -1
  233. package/lib/abstract/chevreTxc/offer.d.ts +1 -1
  234. package/lib/abstract/chevreTxc/offer.js +69 -195
  235. package/lib/abstract/chevreTxc.js +33 -84
  236. package/lib/abstract/chevreTxn/offer.d.ts +1 -1
  237. package/lib/abstract/chevreTxn/offer.js +57 -183
  238. package/lib/abstract/chevreTxn/transaction/placeOrder/factory.d.ts +1 -1
  239. package/lib/abstract/chevreTxn/transaction/placeOrder.d.ts +3 -3
  240. package/lib/abstract/chevreTxn/transaction/placeOrder.js +53 -197
  241. package/lib/abstract/chevreTxn/transaction/returnOrder/factory.d.ts +1 -1
  242. package/lib/abstract/chevreTxn/transaction/returnOrder.d.ts +3 -3
  243. package/lib/abstract/chevreTxn/transaction/returnOrder.js +38 -165
  244. package/lib/abstract/chevreTxn/transaction.d.ts +1 -11
  245. package/lib/abstract/chevreTxn/transaction.js +0 -10
  246. package/lib/abstract/chevreTxn.js +58 -119
  247. package/lib/abstract/cinerino/default.d.ts +0 -12
  248. package/lib/abstract/cinerino/default.js +19 -103
  249. package/lib/abstract/cinerino/service/categoryCode.d.ts +1 -1
  250. package/lib/abstract/cinerino/service/categoryCode.js +18 -94
  251. package/lib/abstract/cinerino/service/emailMessage.d.ts +1 -1
  252. package/lib/abstract/cinerino/service/emailMessage.js +18 -94
  253. package/lib/abstract/cinerino/service/event.d.ts +1 -1
  254. package/lib/abstract/cinerino/service/event.js +165 -351
  255. package/lib/abstract/cinerino/service/place/hasPOS.d.ts +1 -1
  256. package/lib/abstract/cinerino/service/place/hasPOS.js +16 -110
  257. package/lib/abstract/cinerino/service/place.d.ts +1 -1
  258. package/lib/abstract/cinerino/service/place.js +31 -142
  259. package/lib/abstract/cinerino/service/seller.d.ts +1 -1
  260. package/lib/abstract/cinerino/service/seller.js +54 -165
  261. package/lib/abstract/cloud/admin/creativeWork.d.ts +1 -1
  262. package/lib/abstract/cloud/admin/creativeWork.js +12 -83
  263. package/lib/abstract/cloud/admin/customer.d.ts +1 -1
  264. package/lib/abstract/cloud/admin/customer.js +20 -81
  265. package/lib/abstract/cloud/admin/event.d.ts +1 -1
  266. package/lib/abstract/cloud/admin/event.js +66 -210
  267. package/lib/abstract/cloud/admin/eventOffer.js +24 -119
  268. package/lib/abstract/cloud/admin/eventSeries.d.ts +1 -1
  269. package/lib/abstract/cloud/admin/eventSeries.js +12 -94
  270. package/lib/abstract/cloud/admin/me.js +18 -106
  271. package/lib/abstract/cloud/admin/noteAboutOrder.d.ts +1 -1
  272. package/lib/abstract/cloud/admin/noteAboutOrder.js +33 -138
  273. package/lib/abstract/cloud/admin/offer.d.ts +1 -1
  274. package/lib/abstract/cloud/admin/offer.js +88 -186
  275. package/lib/abstract/cloud/admin/offerCatalog.d.ts +1 -1
  276. package/lib/abstract/cloud/admin/offerCatalog.js +20 -126
  277. package/lib/abstract/cloud/admin/offerCatalogItem.d.ts +1 -1
  278. package/lib/abstract/cloud/admin/offerCatalogItem.js +25 -117
  279. package/lib/abstract/cloud/admin/order.d.ts +1 -1
  280. package/lib/abstract/cloud/admin/order.js +108 -219
  281. package/lib/abstract/cloud/admin/paymentMethod.js +12 -80
  282. package/lib/abstract/cloud/admin/product.d.ts +1 -1
  283. package/lib/abstract/cloud/admin/product.js +25 -114
  284. package/lib/abstract/cloud/admin/productOffer.d.ts +1 -1
  285. package/lib/abstract/cloud/admin/productOffer.js +28 -126
  286. package/lib/abstract/cloud/admin/reservation.d.ts +41 -8
  287. package/lib/abstract/cloud/admin/reservation.js +89 -226
  288. package/lib/abstract/cloud/admin/seller.d.ts +1 -1
  289. package/lib/abstract/cloud/admin/seller.js +12 -79
  290. package/lib/abstract/cloud/admin.js +135 -348
  291. package/lib/abstract/cloud/asset/delivery.js +23 -94
  292. package/lib/abstract/cloud/asset/order.js +180 -251
  293. package/lib/abstract/cloud/asset/reservation.d.ts +1 -1
  294. package/lib/abstract/cloud/asset/reservation.js +28 -113
  295. package/lib/abstract/cloud/asset/token.js +3 -23
  296. package/lib/abstract/cloud/asset.d.ts +0 -4
  297. package/lib/abstract/cloud/asset.js +60 -134
  298. package/lib/abstract/cloud/pay/payment.d.ts +1 -1
  299. package/lib/abstract/cloud/pay/payment.js +387 -689
  300. package/lib/abstract/cloud/pay.d.ts +0 -4
  301. package/lib/abstract/cloud/pay.js +33 -83
  302. package/lib/abstract/cloud/search/creativeWork.js +13 -76
  303. package/lib/abstract/cloud/search/eventOffer.js +15 -79
  304. package/lib/abstract/cloud/search/paymentService.js +14 -78
  305. package/lib/abstract/cloud/search/place.d.ts +1 -1
  306. package/lib/abstract/cloud/search/place.js +24 -96
  307. package/lib/abstract/cloud/search/product.d.ts +1 -1
  308. package/lib/abstract/cloud/search/product.js +34 -114
  309. package/lib/abstract/cloud/search/productOffer.js +15 -79
  310. package/lib/abstract/cloud/search/seatOffer.js +15 -79
  311. package/lib/abstract/cloud/search.js +86 -179
  312. package/lib/abstract/cloud/txc/transaction/forceAsync.d.ts +1 -1
  313. package/lib/abstract/cloud/txc/transaction/forceAsync.js +113 -206
  314. package/lib/abstract/cloud/txc/transaction/placeOrder.d.ts +1 -1
  315. package/lib/abstract/cloud/txc/transaction/placeOrder.js +146 -242
  316. package/lib/abstract/cloud/txc.js +34 -79
  317. package/lib/abstract/cloud/txn/offer.d.ts +1 -1
  318. package/lib/abstract/cloud/txn/offer.js +72 -172
  319. package/lib/abstract/cloud/txn/transaction/placeOrder.d.ts +1 -1
  320. package/lib/abstract/cloud/txn/transaction/placeOrder.js +145 -234
  321. package/lib/abstract/cloud/txn/transaction/returnOrder.d.ts +1 -1
  322. package/lib/abstract/cloud/txn/transaction/returnOrder.js +60 -141
  323. package/lib/abstract/cloud/txn.d.ts +0 -4
  324. package/lib/abstract/cloud/txn.js +52 -118
  325. package/lib/abstract/factory.d.ts +1 -1
  326. package/lib/abstract/factory.js +3 -15
  327. package/lib/abstract/index.d.ts +1 -1
  328. package/lib/abstract/index.js +107 -355
  329. package/lib/abstract/pecorino/accountTransaction.d.ts +3 -3
  330. package/lib/abstract/pecorino/accountTransaction.js +45 -146
  331. package/lib/abstract/pecorino/permit.d.ts +1 -1
  332. package/lib/abstract/pecorino/permit.js +24 -102
  333. package/lib/abstract/pecorino.d.ts +1 -1
  334. package/lib/abstract/pecorino.js +8 -56
  335. package/lib/abstract/service.d.ts +0 -1
  336. package/lib/abstract/service.js +65 -137
  337. package/lib/abstract/transporters.d.ts +2 -2
  338. package/lib/abstract/transporters.js +67 -143
  339. package/lib/abstract/waiterAdmin/rule.d.ts +1 -1
  340. package/lib/abstract/waiterAdmin/rule.js +13 -76
  341. package/lib/abstract/waiterAdmin/ruleSet.d.ts +1 -1
  342. package/lib/abstract/waiterAdmin/ruleSet.js +20 -92
  343. package/lib/abstract/waiterAdmin.js +35 -94
  344. package/lib/auth/clientCredentialsClient.d.ts +2 -4
  345. package/lib/auth/clientCredentialsClient.js +77 -158
  346. package/lib/auth/implicitGrantClient/credentials.d.ts +1 -2
  347. package/lib/auth/implicitGrantClient/error.d.ts +3 -3
  348. package/lib/auth/implicitGrantClient/error.js +5 -22
  349. package/lib/auth/implicitGrantClient/iframeHandler.d.ts +1 -1
  350. package/lib/auth/implicitGrantClient/iframeHandler.js +37 -27
  351. package/lib/auth/implicitGrantClient/popupAuthenticationHandler.d.ts +1 -1
  352. package/lib/auth/implicitGrantClient/popupAuthenticationHandler.js +35 -99
  353. package/lib/auth/implicitGrantClient/popupHandler.d.ts +1 -1
  354. package/lib/auth/implicitGrantClient/popupHandler.js +37 -27
  355. package/lib/auth/implicitGrantClient/silentAuthenticationHandler.d.ts +1 -1
  356. package/lib/auth/implicitGrantClient/silentAuthenticationHandler.js +35 -99
  357. package/lib/auth/implicitGrantClient/silentLogoutHandler.d.ts +1 -1
  358. package/lib/auth/implicitGrantClient/silentLogoutHandler.js +35 -99
  359. package/lib/auth/implicitGrantClient.d.ts +2 -2
  360. package/lib/auth/implicitGrantClient.js +153 -304
  361. package/lib/auth/loginTicket.js +7 -6
  362. package/lib/auth/oAuth2client.d.ts +2 -2
  363. package/lib/auth/oAuth2client.js +314 -390
  364. package/lib/browser.js +2 -2
  365. package/lib/bundle.js +6 -41699
  366. package/lib/bundle.js.map +7 -0
  367. package/lib/index.d.ts +2 -2
  368. package/lib/index.js +36 -106
  369. package/package.json +18 -21
  370. package/lib/abstract/chevreConsole/transaction.d.ts +0 -7
  371. package/lib/abstract/chevreConsole/transaction.js +0 -12
@@ -1,273 +1,232 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
47
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
- function verb(n) { return function (v) { return step([n, v]); }; }
49
- function step(op) {
50
- if (f) throw new TypeError("Generator is already executing.");
51
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
- if (y = 0, t) op = [op[0] & 2, t.value];
54
- switch (op[0]) {
55
- case 0: case 1: t = op; break;
56
- case 4: _.label++; return { value: op[1], done: false };
57
- case 5: _.label++; y = op[1]; op = [0]; continue;
58
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
- default:
60
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
- if (t[2]) _.ops.pop();
65
- _.trys.pop(); continue;
66
- }
67
- op = body.call(thisArg, _);
68
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
- }
71
- };
72
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
73
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
74
4
  };
75
5
  Object.defineProperty(exports, "__esModule", { value: true });
76
- exports.MAX_RETRY_NUM = void 0;
6
+ exports.OAuth2client = exports.MAX_RETRY_NUM = void 0;
77
7
  /**
78
8
  * OAuth2クライアント
79
9
  */
80
- var crypto = __importStar(require("crypto"));
81
- var debug_1 = __importDefault(require("debug"));
82
- var http_status_1 = require("http-status");
83
- // import fetch from 'isomorphic-fetch';
84
- var querystring = __importStar(require("querystring"));
85
- var transporters_1 = require("../abstract/transporters");
86
- var loginTicket_1 = require("./loginTicket");
87
- var debug = (0, debug_1.default)('cinerino-sdk:auth:oAuth2client');
88
- var WAIT_BEFORE_RETRY_MS = 1000;
10
+ const crypto_1 = require("crypto");
11
+ const debug_1 = __importDefault(require("debug"));
12
+ const http_status_1 = require("http-status");
13
+ const transporters_1 = require("../abstract/transporters");
14
+ const loginTicket_1 = require("./loginTicket");
15
+ const debug = (0, debug_1.default)('cinerino-sdk:auth:oAuth2client');
16
+ const WAIT_BEFORE_RETRY_MS = 1000;
89
17
  exports.MAX_RETRY_NUM = 2;
90
- function sleep(waitTime) {
91
- return __awaiter(this, void 0, void 0, function () {
92
- return __generator(this, function (_a) {
93
- return [2 /*return*/, new Promise(function (resolve) {
94
- setTimeout(function () {
95
- resolve();
96
- }, waitTime);
97
- })];
98
- });
18
+ async function sleep(waitTime) {
19
+ return new Promise((resolve) => {
20
+ setTimeout(() => {
21
+ resolve();
22
+ }, waitTime);
99
23
  });
100
24
  }
101
25
  /**
102
26
  * OAuth2 client
103
27
  */
104
- var OAuth2client = /** @class */ (function () {
105
- function OAuth2client(options) {
28
+ class OAuth2client {
29
+ /**
30
+ * The base URL for auth endpoints.
31
+ */
32
+ static OAUTH2_AUTH_BASE_URI = '/oauth2/authorize';
33
+ /**
34
+ * The base endpoint for token retrieval.
35
+ */
36
+ static OAUTH2_TOKEN_URI = '/oauth2/token';
37
+ /**
38
+ * The base endpoint to revoke tokens.
39
+ */
40
+ static OAUTH2_LOGOUT_URI = '/logout';
41
+ /**
42
+ * certificates.
43
+ */
44
+ // protected static readonly OAUTH2_FEDERATED_SIGNON_CERTS_URL = 'https://www.example.com/oauth2/v1/certs';
45
+ credentials;
46
+ options;
47
+ /**
48
+ * 認証クライアントインスタンス内で発生するイベント
49
+ */
50
+ events;
51
+ constructor(options) {
106
52
  // TODO add minimum validation
107
53
  this.options = options;
108
54
  this.credentials = {};
109
55
  this.events = {};
110
56
  }
111
- OAuth2client.BASE64URLENCODE = function (str) {
57
+ static BASE64URLENCODE(str) {
112
58
  return str.toString('base64')
113
59
  .replace(/\+/g, '-')
114
60
  .replace(/\//g, '_')
115
61
  .replace(/=/g, '');
116
- };
117
- OAuth2client.SHA256 = function (buffer) {
118
- return crypto.createHash('sha256')
62
+ }
63
+ static SHA256(buffer) {
64
+ return (0, crypto_1.createHash)('sha256')
119
65
  .update(buffer)
120
66
  .digest();
121
- };
67
+ }
122
68
  /**
123
69
  * Generates URL for consent page landing.
124
70
  */
125
- OAuth2client.prototype.generateAuthUrl = function (optOpts) {
126
- var options = {
71
+ generateAuthUrl(optOpts) {
72
+ // const options: querystring.ParsedUrlQueryInput = {
73
+ // response_type: 'code',
74
+ // client_id: this.options.clientId,
75
+ // redirect_uri: this.options.redirectUri,
76
+ // scope: optOpts.scopes.join(' '),
77
+ // state: optOpts.state
78
+ // };
79
+ // if (optOpts.codeVerifier !== undefined) {
80
+ // options.code_challenge_method = 'S256';
81
+ // options.code_challenge = OAuth2client.BASE64URLENCODE(OAuth2client.SHA256(optOpts.codeVerifier));
82
+ // }
83
+ // const rootUrl = `https://${this.options.domain}${OAuth2client.OAUTH2_AUTH_BASE_URI}`;
84
+ // return `${rootUrl}?${querystring.stringify(options)}`;
85
+ const queryParams = {
127
86
  response_type: 'code',
128
87
  client_id: this.options.clientId,
129
88
  redirect_uri: this.options.redirectUri,
130
89
  scope: optOpts.scopes.join(' '),
131
- state: optOpts.state
132
90
  };
91
+ // state がある場合のみ追加(undefined を避けるため)
92
+ /* istanbul ignore else -- @preserve */
93
+ if (typeof optOpts.state === 'string' && optOpts.state.length > 0) {
94
+ queryParams.state = optOpts.state;
95
+ }
96
+ // PKCE (code_challenge) の追加
133
97
  if (optOpts.codeVerifier !== undefined) {
134
- options.code_challenge_method = 'S256';
135
- options.code_challenge = OAuth2client.BASE64URLENCODE(OAuth2client.SHA256(optOpts.codeVerifier));
98
+ queryParams.code_challenge_method = 'S256';
99
+ queryParams.code_challenge = OAuth2client.BASE64URLENCODE(OAuth2client.SHA256(optOpts.codeVerifier));
136
100
  }
137
- var rootUrl = "https://".concat(this.options.domain).concat(OAuth2client.OAUTH2_AUTH_BASE_URI);
138
- return "".concat(rootUrl, "?").concat(querystring.stringify(options));
139
- };
101
+ const params = new URLSearchParams(queryParams);
102
+ const rootUrl = `https://${this.options.domain}${OAuth2client.OAUTH2_AUTH_BASE_URI}`;
103
+ return `${rootUrl}?${params.toString()}`;
104
+ }
140
105
  /**
141
106
  * Generates URL for logout.
142
107
  */
143
- OAuth2client.prototype.generateLogoutUrl = function () {
144
- var options = {
108
+ generateLogoutUrl() {
109
+ // const options: querystring.ParsedUrlQueryInput = {
110
+ // client_id: this.options.clientId,
111
+ // logout_uri: this.options.logoutUri
112
+ // };
113
+ // const rootUrl = `https://${this.options.domain}${OAuth2client.OAUTH2_LOGOUT_URI}`;
114
+ // return `${rootUrl}?${querystring.stringify(options)}`;
115
+ const queryParams = {
145
116
  client_id: this.options.clientId,
146
117
  logout_uri: this.options.logoutUri
147
118
  };
148
- var rootUrl = "https://".concat(this.options.domain).concat(OAuth2client.OAUTH2_LOGOUT_URI);
149
- return "".concat(rootUrl, "?").concat(querystring.stringify(options));
150
- };
119
+ const rootUrl = `https://${this.options.domain}${OAuth2client.OAUTH2_LOGOUT_URI}`;
120
+ return `${rootUrl}?${new URLSearchParams(queryParams).toString()}`;
121
+ }
151
122
  /**
152
123
  * Gets the access token for the given code.
153
124
  * @param code The authorization code.
154
125
  */
155
- OAuth2client.prototype.getToken = function (code, codeVerifier) {
156
- return __awaiter(this, void 0, void 0, function () {
157
- var form, secret, options;
158
- var _this = this;
159
- return __generator(this, function (_a) {
160
- form = {
161
- code: code,
162
- client_id: this.options.clientId,
163
- redirect_uri: this.options.redirectUri,
164
- grant_type: 'authorization_code',
165
- code_verifier: codeVerifier
166
- };
167
- secret = Buffer.from("".concat(this.options.clientId, ":").concat(this.options.clientSecret), 'utf8')
168
- .toString('base64');
169
- options = {
170
- body: querystring.stringify(form),
171
- method: 'POST',
172
- headers: {
173
- Authorization: "Basic ".concat(secret),
174
- 'Content-Type': 'application/x-www-form-urlencoded'
175
- }
176
- };
177
- debug('fetching...', options);
178
- return [2 /*return*/, fetch("https://".concat(this.options.domain).concat(OAuth2client.OAUTH2_TOKEN_URI), options)
179
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
180
- var body, body, tokens;
181
- return __generator(this, function (_a) {
182
- switch (_a.label) {
183
- case 0:
184
- debug('response:', response.status);
185
- if (!(response.status !== http_status_1.OK)) return [3 /*break*/, 5];
186
- if (!(response.status === http_status_1.BAD_REQUEST)) return [3 /*break*/, 2];
187
- return [4 /*yield*/, response.json()];
188
- case 1:
189
- body = _a.sent();
190
- throw new Error(body.error);
191
- case 2: return [4 /*yield*/, response.text()];
192
- case 3:
193
- body = _a.sent();
194
- throw new Error(body);
195
- case 4: return [3 /*break*/, 7];
196
- case 5: return [4 /*yield*/, response.json()];
197
- case 6:
198
- tokens = _a.sent();
199
- /* istanbul ignore else */
200
- if (tokens && tokens.expires_in) {
201
- tokens.expiry_date = ((new Date()).getTime() + (tokens.expires_in * 1000));
202
- delete tokens.expires_in;
203
- }
204
- return [2 /*return*/, tokens];
205
- case 7: return [2 /*return*/];
206
- }
207
- });
208
- }); })];
209
- });
126
+ async getToken(code, codeVerifier) {
127
+ // const form = {
128
+ // code: code,
129
+ // client_id: this.options.clientId,
130
+ // redirect_uri: this.options.redirectUri,
131
+ // grant_type: 'authorization_code',
132
+ // code_verifier: codeVerifier
133
+ // };
134
+ // const secret = Buffer.from(`${this.options.clientId}:${this.options.clientSecret}`, 'utf8')
135
+ // .toString('base64');
136
+ // const options: RequestInit = {
137
+ // body: querystring.stringify(form),
138
+ // method: 'POST',
139
+ // headers: {
140
+ // Authorization: `Basic ${secret}`,
141
+ // 'Content-Type': 'application/x-www-form-urlencoded'
142
+ // }
143
+ // };
144
+ const form = {
145
+ code: code,
146
+ client_id: this.options.clientId,
147
+ redirect_uri: this.options.redirectUri,
148
+ grant_type: 'authorization_code',
149
+ ...((typeof codeVerifier === 'string') && { code_verifier: codeVerifier })
150
+ };
151
+ const secretSource = `${this.options.clientId}:${this.options.clientSecret}`;
152
+ const secret = btoa(secretSource);
153
+ const options = {
154
+ body: new URLSearchParams(form).toString(),
155
+ method: 'POST',
156
+ headers: {
157
+ Authorization: `Basic ${secret}`,
158
+ 'Content-Type': 'application/x-www-form-urlencoded'
159
+ }
160
+ };
161
+ debug('fetching...', options);
162
+ return fetch(`https://${this.options.domain}${OAuth2client.OAUTH2_TOKEN_URI}`, options)
163
+ .then(async (response) => {
164
+ debug('response:', response.status);
165
+ if (response.status !== http_status_1.status.OK) {
166
+ if (response.status === http_status_1.status.BAD_REQUEST) {
167
+ const body = await response.json();
168
+ throw new Error(body.error);
169
+ }
170
+ else {
171
+ const body = await response.text();
172
+ throw new Error(body);
173
+ }
174
+ }
175
+ else {
176
+ const tokens = await response.json();
177
+ /* istanbul ignore else */
178
+ if (tokens && tokens.expires_in) {
179
+ tokens.expiry_date = ((new Date()).getTime() + (tokens.expires_in * 1000));
180
+ delete tokens.expires_in;
181
+ }
182
+ return tokens;
183
+ }
210
184
  });
211
- };
185
+ }
212
186
  /**
213
187
  * OAuthクライアントに認証情報をセットします。
214
188
  */
215
- OAuth2client.prototype.setCredentials = function (credentials) {
189
+ setCredentials(credentials) {
216
190
  this.credentials = credentials;
217
- };
218
- OAuth2client.prototype.refreshAccessToken = function () {
219
- return __awaiter(this, void 0, void 0, function () {
220
- var _this = this;
221
- return __generator(this, function (_a) {
222
- if (this.credentials.refresh_token === undefined) {
223
- throw new Error('No refresh token is set.');
224
- }
225
- return [2 /*return*/, this.refreshToken(this.credentials.refresh_token)
226
- .then(function (refreshTokenResult) { return __awaiter(_this, void 0, void 0, function () {
227
- return __generator(this, function (_a) {
228
- switch (_a.label) {
229
- case 0:
230
- // tokens.refresh_token = this.credentials.refresh_token;
231
- debug('setting credentials...', refreshTokenResult);
232
- this.credentials = __assign(__assign({}, refreshTokenResult), { refresh_token: this.credentials.refresh_token });
233
- if (!(typeof this.events.onTokenRefreshed === 'function')) return [3 /*break*/, 2];
234
- return [4 /*yield*/, this.events.onTokenRefreshed(this.credentials)];
235
- case 1:
236
- _a.sent();
237
- _a.label = 2;
238
- case 2: return [2 /*return*/, this.credentials];
239
- }
240
- });
241
- }); })];
242
- });
191
+ }
192
+ async refreshAccessToken() {
193
+ if (this.credentials.refresh_token === undefined) {
194
+ throw new Error('No refresh token is set.');
195
+ }
196
+ return this.refreshToken(this.credentials.refresh_token)
197
+ .then(async (refreshTokenResult) => {
198
+ // tokens.refresh_token = this.credentials.refresh_token;
199
+ debug('setting credentials...', refreshTokenResult);
200
+ this.credentials = {
201
+ ...refreshTokenResult,
202
+ refresh_token: this.credentials.refresh_token
203
+ };
204
+ // support onTokenRefreshed(2025-07-24~)
205
+ if (typeof this.events.onTokenRefreshed === 'function') {
206
+ await this.events.onTokenRefreshed(this.credentials);
207
+ }
208
+ return this.credentials;
243
209
  });
244
- };
210
+ }
245
211
  /**
246
212
  * 期限の切れていないアクセストークンを取得します。
247
213
  * 必要であれば更新してから取得します。
248
214
  */
249
- OAuth2client.prototype.getAccessToken = function () {
250
- return __awaiter(this, void 0, void 0, function () {
251
- var expiryDate, isTokenExpired, shouldRefresh;
252
- return __generator(this, function (_a) {
253
- switch (_a.label) {
254
- case 0:
255
- expiryDate = this.credentials.expiry_date;
256
- isTokenExpired = (expiryDate !== undefined) ? (expiryDate <= (new Date()).getTime()) : false;
257
- if (this.credentials.access_token === undefined && this.credentials.refresh_token === undefined) {
258
- throw new Error('No access or refresh token is set.');
259
- }
260
- shouldRefresh = (this.credentials.access_token === undefined) || isTokenExpired;
261
- if (!(shouldRefresh && typeof this.credentials.refresh_token === 'string' && this.credentials.refresh_token.length > 0)) return [3 /*break*/, 2];
262
- return [4 /*yield*/, this.refreshAccessToken()];
263
- case 1:
264
- _a.sent();
265
- _a.label = 2;
266
- case 2: return [2 /*return*/, this.credentials.access_token];
267
- }
268
- });
269
- });
270
- };
215
+ async getAccessToken() {
216
+ const expiryDate = this.credentials.expiry_date;
217
+ // if no expiry time, assume it's not expired
218
+ const isTokenExpired = (expiryDate !== undefined) ? (expiryDate <= (new Date()).getTime()) : false;
219
+ if (this.credentials.access_token === undefined && this.credentials.refresh_token === undefined) {
220
+ throw new Error('No access or refresh token is set.');
221
+ }
222
+ const shouldRefresh = (this.credentials.access_token === undefined) || isTokenExpired;
223
+ // refreshTokenが存在すればrefreshAccessToken
224
+ /* istanbul ignore else */
225
+ if (shouldRefresh && typeof this.credentials.refresh_token === 'string' && this.credentials.refresh_token.length > 0) {
226
+ await this.refreshAccessToken();
227
+ }
228
+ return this.credentials.access_token;
229
+ }
271
230
  /**
272
231
  * Revokes the access given to token.
273
232
  * @param token The existing token to be revoked.
@@ -280,83 +239,72 @@ var OAuth2client = /** @class */ (function () {
280
239
  * 401 and 403 responses, it automatically asks for a new
281
240
  * access token and replays the unsuccessful request.
282
241
  */
283
- OAuth2client.prototype.fetch = function (url, options, expectedStatusCodes, retryableStatusCodes // リトライ有無をコントロール(2024-03-31~)
242
+ async fetch(url, options, expectedStatusCodes, retryableStatusCodes // リトライ有無をコントロール(2024-03-31~)
284
243
  ) {
285
- return __awaiter(this, void 0, void 0, function () {
286
- var retry, result, numberOfTry, _a, _b, error_1, statusCode;
287
- return __generator(this, function (_c) {
288
- switch (_c.label) {
289
- case 0:
290
- retry = true;
291
- options.headers = (options.headers === undefined || options.headers === null) ? {} : options.headers;
292
- numberOfTry = 0;
293
- _c.label = 1;
294
- case 1:
295
- if (!(result === undefined)) return [3 /*break*/, 11];
296
- _c.label = 2;
297
- case 2:
298
- _c.trys.push([2, 5, , 10]);
299
- numberOfTry += 1;
300
- if (numberOfTry > exports.MAX_RETRY_NUM) {
301
- retry = false;
244
+ // Callbacks will close over this to ensure that we only retry once
245
+ let retry = true;
246
+ options.headers = (options.headers === undefined || options.headers === null) ? {} : options.headers;
247
+ let result;
248
+ let numberOfTry = 0;
249
+ while (result === undefined) {
250
+ try {
251
+ numberOfTry += 1;
252
+ if (numberOfTry > exports.MAX_RETRY_NUM) {
253
+ retry = false;
254
+ }
255
+ options.headers.Authorization = `Bearer ${await this.getAccessToken()}`;
256
+ result = await this.makeFetch(url, options, expectedStatusCodes);
257
+ break;
258
+ }
259
+ catch (error) {
260
+ /* istanbul ignore else */
261
+ if (error instanceof Error) {
262
+ const statusCode = error.code;
263
+ debug('retry? numberOfTry:', numberOfTry, 'statusCode: ', statusCode, 'retry: ', retry, 'retryableStatusCodes: ', retryableStatusCodes);
264
+ if (retry && typeof statusCode === 'number' && retryableStatusCodes.includes(statusCode)) {
265
+ /* It only makes sense to retry once, because the retry is intended
266
+ * to handle expiration-related failures. If refreshing the token
267
+ * does not fix the failure, then refreshing again probably won't
268
+ * help */
269
+ // Force token refresh
270
+ // refreshTokenが存在すれば強制的にrefreshAccessToken
271
+ /* istanbul ignore else */
272
+ if (typeof this.credentials.refresh_token === 'string' && this.credentials.refresh_token.length > 0) {
273
+ await this.refreshAccessToken();
302
274
  }
303
- _a = options.headers;
304
- _b = "Bearer ".concat;
305
- return [4 /*yield*/, this.getAccessToken()];
306
- case 3:
307
- _a.Authorization = _b.apply("Bearer ", [_c.sent()]);
308
- return [4 /*yield*/, this.makeFetch(url, options, expectedStatusCodes)];
309
- case 4:
310
- result = _c.sent();
311
- return [3 /*break*/, 11];
312
- case 5:
313
- error_1 = _c.sent();
314
- if (!(error_1 instanceof Error)) return [3 /*break*/, 9];
315
- statusCode = error_1.code;
316
- debug('retry? numberOfTry:', numberOfTry, 'statusCode: ', statusCode, 'retry: ', retry, 'retryableStatusCodes: ', retryableStatusCodes);
317
- if (!(retry && retryableStatusCodes.includes(statusCode))) return [3 /*break*/, 9];
318
- if (!(typeof this.credentials.refresh_token === 'string' && this.credentials.refresh_token.length > 0)) return [3 /*break*/, 7];
319
- return [4 /*yield*/, this.refreshAccessToken()];
320
- case 6:
321
- _c.sent();
322
- _c.label = 7;
323
- case 7:
324
- // wait seconds(2024-04-01~)
325
- return [4 /*yield*/, sleep(WAIT_BEFORE_RETRY_MS * numberOfTry)];
326
- case 8:
327
275
  // wait seconds(2024-04-01~)
328
- _c.sent();
329
- return [3 /*break*/, 1];
330
- case 9: throw error_1;
331
- case 10: return [3 /*break*/, 1];
332
- case 11: return [2 /*return*/, result];
276
+ await sleep(WAIT_BEFORE_RETRY_MS * numberOfTry);
277
+ continue;
278
+ }
333
279
  }
334
- });
335
- });
336
- };
280
+ throw error;
281
+ }
282
+ }
283
+ return result;
284
+ }
337
285
  /**
338
286
  * IDトークンを検証する
339
287
  * 結果にはIDトークンの付加情報が含まれます。
340
288
  */
341
- OAuth2client.prototype.verifyIdToken = function (options) {
289
+ verifyIdToken(options) {
342
290
  if (this.credentials.id_token === undefined) {
343
291
  throw new Error('The verifyIdToken method requires an ID Token');
344
292
  }
345
293
  // return this.verifySignedJwt(options.idToken, options.audience, OAuth2Client.ISSUERS_);
346
294
  return this.verifySignedJwt(this.credentials.id_token, options.audience);
347
- };
295
+ }
348
296
  /**
349
297
  * トークン更新イベントハンドラを登録する
350
298
  */
351
- OAuth2client.prototype.onTokenRefreshed = function (params) {
299
+ onTokenRefreshed(params) {
352
300
  this.events.onTokenRefreshed = params;
353
- };
301
+ }
354
302
  /**
355
303
  * リクエスト送信前イベントハンドラを登録する
356
304
  */
357
- OAuth2client.prototype.preFetch = function (params) {
305
+ preFetch(params) {
358
306
  this.events.preFetch = params;
359
- };
307
+ }
360
308
  /**
361
309
  * Provides a request implementation with OAuth 2.0 flow.
362
310
  * If credentials have a refresh_token, in cases of HTTP
@@ -383,100 +331,89 @@ var OAuth2client = /** @class */ (function () {
383
331
  * Makes a request without paying attention to refreshing or anything
384
332
  * Assumes that all credentials are set correctly.
385
333
  */
386
- OAuth2client.prototype.makeFetch = function (url, options, expectedStatusCodes) {
387
- return __awaiter(this, void 0, void 0, function () {
388
- var transporter, fetchOptions, preFetchResult;
389
- return __generator(this, function (_a) {
390
- switch (_a.label) {
391
- case 0:
392
- transporter = new transporters_1.DefaultTransporter(expectedStatusCodes);
393
- if (!(typeof this.events.preFetch === 'function')) return [3 /*break*/, 2];
394
- return [4 /*yield*/, this.events.preFetch({ url: url, options: options })];
395
- case 1:
396
- preFetchResult = _a.sent();
397
- fetchOptions = preFetchResult.options;
398
- return [3 /*break*/, 3];
399
- case 2:
400
- fetchOptions = options;
401
- _a.label = 3;
402
- case 3: return [2 /*return*/, transporter.fetch(url, fetchOptions)];
403
- }
404
- });
405
- });
406
- };
334
+ async makeFetch(url, options, expectedStatusCodes) {
335
+ const transporter = new transporters_1.DefaultTransporter(expectedStatusCodes);
336
+ let fetchOptions;
337
+ if (typeof this.events.preFetch === 'function') {
338
+ const preFetchResult = await this.events.preFetch({ url, options });
339
+ fetchOptions = preFetchResult.options;
340
+ }
341
+ else {
342
+ fetchOptions = options;
343
+ }
344
+ return transporter.fetch(url, fetchOptions);
345
+ }
407
346
  /**
408
347
  * Refreshes the access token.
409
348
  */
410
- OAuth2client.prototype.refreshToken = function (refreshToken) {
411
- return __awaiter(this, void 0, void 0, function () {
412
- var form, secret, options;
413
- var _this = this;
414
- return __generator(this, function (_a) {
415
- // request for new token
416
- debug('refreshing access token...', this.credentials, refreshToken);
417
- form = {
418
- client_id: this.options.clientId,
419
- refresh_token: refreshToken,
420
- grant_type: 'refresh_token'
421
- };
422
- secret = Buffer.from("".concat(this.options.clientId, ":").concat(this.options.clientSecret), 'utf8')
423
- .toString('base64');
424
- options = {
425
- body: querystring.stringify(form),
426
- method: 'POST',
427
- headers: {
428
- Authorization: "Basic ".concat(secret),
429
- 'Content-Type': 'application/x-www-form-urlencoded'
430
- }
431
- };
432
- debug('fetching...', options);
433
- return [2 /*return*/, fetch("https://".concat(this.options.domain).concat(OAuth2client.OAUTH2_TOKEN_URI), options)
434
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
435
- var body, body, result, refreshTokenResponse, access_token, id_token, expires_in, token_type;
436
- return __generator(this, function (_a) {
437
- switch (_a.label) {
438
- case 0:
439
- debug('response:', response.status);
440
- if (!(response.status !== http_status_1.OK)) return [3 /*break*/, 5];
441
- if (!(response.status === http_status_1.BAD_REQUEST)) return [3 /*break*/, 2];
442
- return [4 /*yield*/, response.json()];
443
- case 1:
444
- body = _a.sent();
445
- throw new Error(body.error);
446
- case 2: return [4 /*yield*/, response.text()];
447
- case 3:
448
- body = _a.sent();
449
- throw new Error(body);
450
- case 4: return [3 /*break*/, 7];
451
- case 5:
452
- result = void 0;
453
- return [4 /*yield*/, response.json()];
454
- case 6:
455
- refreshTokenResponse = _a.sent();
456
- /* istanbul ignore else */
457
- if (refreshTokenResponse !== undefined && typeof refreshTokenResponse.expires_in === 'number') {
458
- access_token = refreshTokenResponse.access_token, id_token = refreshTokenResponse.id_token, expires_in = refreshTokenResponse.expires_in, token_type = refreshTokenResponse.token_type;
459
- result = {
460
- access_token: access_token,
461
- id_token: id_token,
462
- token_type: token_type,
463
- expiry_date: ((new Date()).getTime() + (expires_in * 1000))
464
- };
465
- // delete tokens.expires_in;
466
- }
467
- else {
468
- // 想定していないリフレッシュトークンレスポンスはログ出力
469
- console.error('unexpected refreshToken response:', refreshTokenResponse);
470
- throw new Error('unexpected refreshToken response.');
471
- }
472
- return [2 /*return*/, result];
473
- case 7: return [2 /*return*/];
474
- }
475
- });
476
- }); })];
477
- });
349
+ async refreshToken(refreshToken) {
350
+ // request for new token
351
+ debug('refreshing access token...', this.credentials, refreshToken);
352
+ // const form = {
353
+ // client_id: this.options.clientId,
354
+ // refresh_token: refreshToken,
355
+ // grant_type: 'refresh_token'
356
+ // };
357
+ // const secret = Buffer.from(`${this.options.clientId}:${this.options.clientSecret}`, 'utf8')
358
+ // .toString('base64');
359
+ // const options: RequestInit = {
360
+ // body: querystring.stringify(form),
361
+ // method: 'POST',
362
+ // headers: {
363
+ // Authorization: `Basic ${secret}`,
364
+ // 'Content-Type': 'application/x-www-form-urlencoded'
365
+ // }
366
+ // };
367
+ const form = {
368
+ client_id: this.options.clientId,
369
+ refresh_token: refreshToken,
370
+ grant_type: 'refresh_token'
371
+ };
372
+ const secretSource = `${this.options.clientId}:${this.options.clientSecret}`;
373
+ const secret = btoa(secretSource);
374
+ const options = {
375
+ body: new URLSearchParams(form).toString(),
376
+ method: 'POST',
377
+ headers: {
378
+ Authorization: `Basic ${secret}`,
379
+ 'Content-Type': 'application/x-www-form-urlencoded'
380
+ }
381
+ };
382
+ debug('fetching...', options);
383
+ return fetch(`https://${this.options.domain}${OAuth2client.OAUTH2_TOKEN_URI}`, options)
384
+ .then(async (response) => {
385
+ debug('response:', response.status);
386
+ if (response.status !== http_status_1.status.OK) {
387
+ if (response.status === http_status_1.status.BAD_REQUEST) {
388
+ const body = await response.json();
389
+ throw new Error(body.error);
390
+ }
391
+ else {
392
+ const body = await response.text();
393
+ throw new Error(body);
394
+ }
395
+ }
396
+ else {
397
+ let result;
398
+ const refreshTokenResponse = await response.json();
399
+ /* istanbul ignore else */
400
+ if (refreshTokenResponse !== undefined && typeof refreshTokenResponse.expires_in === 'number') {
401
+ const { access_token, id_token, expires_in, token_type } = refreshTokenResponse;
402
+ result = {
403
+ access_token, id_token, token_type,
404
+ expiry_date: ((new Date()).getTime() + (expires_in * 1000))
405
+ };
406
+ // delete tokens.expires_in;
407
+ }
408
+ else {
409
+ // 想定していないリフレッシュトークンレスポンスはログ出力
410
+ console.error('unexpected refreshToken response:', refreshTokenResponse);
411
+ throw new Error('unexpected refreshToken response.');
412
+ }
413
+ return result;
414
+ }
478
415
  });
479
- };
416
+ }
480
417
  /**
481
418
  * Verify the id token is signed with the correct certificate
482
419
  * and is from the correct audience.
@@ -484,35 +421,35 @@ var OAuth2client = /** @class */ (function () {
484
421
  * @param requiredAudience The audience to test the jwt against.
485
422
  * @param issuers The allowed issuers of the jwt (Optional).
486
423
  */
487
- OAuth2client.prototype.verifySignedJwt = function (jwt, requiredAudience) {
424
+ verifySignedJwt(jwt, requiredAudience) {
488
425
  // private verifySignedJwt(jwt: string, requiredAudience: string | string[], issuers?: string[]) {
489
- var segments = jwt.split('.');
426
+ const segments = jwt.split('.');
490
427
  if (segments.length !== 3) {
491
- throw new Error("Wrong number of segments in token: ".concat(jwt));
428
+ throw new Error(`Wrong number of segments in token: ${jwt}`);
492
429
  }
493
430
  // const signed = `${segments[0]}.${segments[1]}`;
494
431
  // const signature = segments[2];
495
- var envelope;
496
- var payload;
432
+ let envelope;
433
+ let payload;
497
434
  try {
498
435
  envelope = JSON.parse(Buffer.from(segments[0], 'base64')
499
436
  .toString('utf8'));
500
437
  }
501
- catch (_a) {
502
- throw new Error("Can't parse token envelope: ".concat(segments[0]));
438
+ catch {
439
+ throw new Error(`Can't parse token envelope: ${segments[0]}`);
503
440
  }
504
441
  try {
505
442
  payload = JSON.parse(Buffer.from(segments[1], 'base64')
506
443
  .toString('utf8'));
507
444
  }
508
- catch (_b) {
509
- throw new Error("Can't parse token payload: ".concat(segments[0]));
445
+ catch {
446
+ throw new Error(`Can't parse token payload: ${segments[0]}`);
510
447
  }
511
448
  if (payload.iat === undefined) {
512
- throw new Error("No issue time in token: ".concat(JSON.stringify(payload)));
449
+ throw new Error(`No issue time in token: ${JSON.stringify(payload)}`);
513
450
  }
514
451
  if (payload.exp === undefined) {
515
- throw new Error("No expiration time in token: ".concat(JSON.stringify(payload)));
452
+ throw new Error(`No expiration time in token: ${JSON.stringify(payload)}`);
516
453
  }
517
454
  if (isNaN(payload.iat)) {
518
455
  throw new Error('iat field using invalid format');
@@ -526,8 +463,8 @@ var OAuth2client = /** @class */ (function () {
526
463
  // Check the audience matches if we have one
527
464
  /* istanbul ignore else */
528
465
  if (requiredAudience !== undefined) {
529
- var aud = payload.aud;
530
- var audVerified = false;
466
+ const aud = payload.aud;
467
+ let audVerified = false;
531
468
  // If the requiredAudience is an array, check if it contains token
532
469
  if (Array.isArray(requiredAudience)) {
533
470
  audVerified = (requiredAudience.indexOf(aud) > -1);
@@ -543,19 +480,6 @@ var OAuth2client = /** @class */ (function () {
543
480
  envelope: envelope,
544
481
  payload: payload
545
482
  });
546
- };
547
- /**
548
- * The base URL for auth endpoints.
549
- */
550
- OAuth2client.OAUTH2_AUTH_BASE_URI = '/oauth2/authorize';
551
- /**
552
- * The base endpoint for token retrieval.
553
- */
554
- OAuth2client.OAUTH2_TOKEN_URI = '/oauth2/token';
555
- /**
556
- * The base endpoint to revoke tokens.
557
- */
558
- OAuth2client.OAUTH2_LOGOUT_URI = '/logout';
559
- return OAuth2client;
560
- }());
561
- exports.default = OAuth2client;
483
+ }
484
+ }
485
+ exports.OAuth2client = OAuth2client;