ebay-api 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -17
- package/dist/api/apiFactory.d.ts +27 -27
- package/dist/api/apiFactory.js +94 -94
- package/dist/api/base.d.ts +10 -10
- package/dist/api/base.js +10 -10
- package/dist/api/digitalSignature.d.ts +43 -43
- package/dist/api/digitalSignature.js +105 -105
- package/dist/api/index.d.ts +13 -13
- package/dist/api/index.js +29 -29
- package/dist/api/restful/buy/browse/index.d.ts +84 -84
- package/dist/api/restful/buy/browse/index.js +132 -135
- package/dist/api/restful/buy/deal/index.d.ts +56 -55
- package/dist/api/restful/buy/deal/index.js +74 -73
- package/dist/api/restful/buy/feed/index.d.ts +44 -43
- package/dist/api/restful/buy/feed/index.js +79 -78
- package/dist/api/restful/buy/index.d.ts +17 -17
- package/dist/api/restful/buy/index.js +8 -8
- package/dist/api/restful/buy/marketing/index.d.ts +28 -27
- package/dist/api/restful/buy/marketing/index.js +45 -44
- package/dist/api/restful/buy/marketplaceInsights/index.d.ts +29 -28
- package/dist/api/restful/buy/marketplaceInsights/index.js +45 -44
- package/dist/api/restful/buy/offer/index.d.ts +24 -23
- package/dist/api/restful/buy/offer/index.js +31 -30
- package/dist/api/restful/buy/order/index.d.ts +265 -264
- package/dist/api/restful/buy/order/index.js +363 -362
- package/dist/api/restful/commerce/catalog/index.d.ts +74 -73
- package/dist/api/restful/commerce/catalog/index.js +100 -101
- package/dist/api/restful/commerce/charity/index.d.ts +35 -34
- package/dist/api/restful/commerce/charity/index.js +50 -49
- package/dist/api/restful/commerce/identity/index.d.ts +15 -14
- package/dist/api/restful/commerce/identity/index.js +21 -20
- package/dist/api/restful/commerce/index.d.ts +15 -15
- package/dist/api/restful/commerce/index.js +7 -7
- package/dist/api/restful/commerce/notification/index.d.ts +118 -117
- package/dist/api/restful/commerce/notification/index.js +181 -180
- package/dist/api/restful/commerce/taxonomy/index.d.ts +79 -78
- package/dist/api/restful/commerce/taxonomy/index.js +129 -128
- package/dist/api/restful/commerce/translation/index.d.ts +16 -15
- package/dist/api/restful/commerce/translation/index.js +19 -18
- package/dist/api/restful/developer/analytics/index.d.ts +23 -22
- package/dist/api/restful/developer/analytics/index.js +39 -38
- package/dist/api/restful/developer/index.d.ts +7 -7
- package/dist/api/restful/developer/index.js +3 -3
- package/dist/api/restful/developer/keyManagement/index.d.ts +25 -24
- package/dist/api/restful/developer/keyManagement/index.js +37 -36
- package/dist/api/restful/index.d.ts +70 -67
- package/dist/api/restful/index.js +180 -177
- package/dist/api/restful/postOrder/cancellation/index.d.ts +57 -57
- package/dist/api/restful/postOrder/cancellation/index.js +89 -88
- package/dist/api/restful/postOrder/case/index.d.ts +63 -63
- package/dist/api/restful/postOrder/case/index.js +89 -88
- package/dist/api/restful/postOrder/index.d.ts +11 -11
- package/dist/api/restful/postOrder/index.js +5 -5
- package/dist/api/restful/postOrder/inquiry/index.d.ts +82 -82
- package/dist/api/restful/postOrder/inquiry/index.js +125 -124
- package/dist/api/restful/postOrder/return/index.d.ts +231 -231
- package/dist/api/restful/postOrder/return/index.js +355 -354
- package/dist/api/restful/sell/account/index.d.ts +299 -298
- package/dist/api/restful/sell/account/index.js +461 -460
- package/dist/api/restful/sell/analytics/index.d.ts +42 -41
- package/dist/api/restful/sell/analytics/index.js +55 -54
- package/dist/api/restful/sell/compliance/index.d.ts +38 -37
- package/dist/api/restful/sell/compliance/index.js +51 -50
- package/dist/api/restful/sell/feed/index.d.ts +172 -171
- package/dist/api/restful/sell/feed/index.js +278 -277
- package/dist/api/restful/sell/finances/index.d.ts +79 -78
- package/dist/api/restful/sell/finances/index.js +103 -102
- package/dist/api/restful/sell/fulfillment/index.d.ts +138 -137
- package/dist/api/restful/sell/fulfillment/index.js +193 -192
- package/dist/api/restful/sell/index.d.ts +29 -29
- package/dist/api/restful/sell/index.js +14 -14
- package/dist/api/restful/sell/inventory/index.d.ts +249 -248
- package/dist/api/restful/sell/inventory/index.js +340 -339
- package/dist/api/restful/sell/listing/index.d.ts +15 -14
- package/dist/api/restful/sell/listing/index.js +19 -18
- package/dist/api/restful/sell/logistics/index.d.ts +45 -44
- package/dist/api/restful/sell/logistics/index.js +60 -59
- package/dist/api/restful/sell/marketing/index.d.ts +627 -626
- package/dist/api/restful/sell/marketing/index.js +863 -862
- package/dist/api/restful/sell/metadata/index.d.ts +78 -77
- package/dist/api/restful/sell/metadata/index.js +125 -124
- package/dist/api/restful/sell/negotiation/index.d.ts +25 -24
- package/dist/api/restful/sell/negotiation/index.js +33 -32
- package/dist/api/restful/sell/recommendation/index.d.ts +27 -26
- package/dist/api/restful/sell/recommendation/index.js +33 -32
- package/dist/api/traditional/XMLRequest.d.ts +109 -109
- package/dist/api/traditional/XMLRequest.js +176 -175
- package/dist/api/traditional/clientAlerts/index.d.ts +9 -9
- package/dist/api/traditional/clientAlerts/index.js +11 -11
- package/dist/api/traditional/clientAlerts/types.d.ts +31 -31
- package/dist/api/traditional/clientAlerts/types.js +32 -32
- package/dist/api/traditional/fields.d.ts +1948 -1948
- package/dist/api/traditional/fields.js +1946 -1946
- package/dist/api/traditional/finding/index.d.ts +12 -12
- package/dist/api/traditional/finding/index.js +13 -13
- package/dist/api/traditional/index.d.ts +17 -17
- package/dist/api/traditional/index.js +191 -191
- package/dist/api/traditional/merchandising/index.d.ts +7 -7
- package/dist/api/traditional/merchandising/index.js +8 -8
- package/dist/api/traditional/shopping/index.d.ts +11 -11
- package/dist/api/traditional/shopping/index.js +13 -13
- package/dist/api/traditional/trading/index.d.ts +142 -142
- package/dist/api/traditional/trading/index.js +143 -143
- package/dist/auth/authNAuth.d.ts +49 -49
- package/dist/auth/authNAuth.js +117 -116
- package/dist/auth/index.d.ts +17 -17
- package/dist/auth/index.js +25 -25
- package/dist/auth/oAuth2.d.ts +95 -95
- package/dist/auth/oAuth2.js +260 -259
- package/dist/eBayApi.d.ts +59 -59
- package/dist/eBayApi.js +105 -104
- package/dist/ebay-api.min.mjs +1 -1
- package/dist/enums/apiEnums.d.ts +49 -49
- package/dist/enums/apiEnums.js +51 -51
- package/dist/enums/index.d.ts +2 -2
- package/dist/enums/index.js +2 -2
- package/dist/enums/restfulEnums.d.ts +970 -970
- package/dist/enums/restfulEnums.js +1013 -1013
- package/dist/errors/index.d.ts +66 -66
- package/dist/errors/index.js +189 -189
- package/dist/nanoevents.d.ts +6 -6
- package/dist/nanoevents.js +20 -20
- package/dist/request.d.ts +26 -26
- package/dist/request.js +43 -43
- package/dist/types/apiTypes.d.ts +40 -40
- package/dist/types/apiTypes.js +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +3 -3
- package/dist/types/restful/specs/buy_browse_v1_oas3.d.ts +1531 -0
- package/dist/types/restful/specs/buy_browse_v1_oas3.js +5 -0
- package/dist/types/restful/specs/buy_deal_v1_oas3.d.ts +434 -0
- package/dist/types/restful/specs/buy_deal_v1_oas3.js +5 -0
- package/dist/types/restful/specs/buy_feed_v1_beta_oas3.d.ts +561 -0
- package/dist/types/restful/specs/buy_feed_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/buy_marketing_v1_beta_oas3.d.ts +288 -0
- package/dist/types/restful/specs/buy_marketing_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/buy_marketplace_insights_v1_beta_oas3.d.ts +304 -0
- package/dist/types/restful/specs/buy_marketplace_insights_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/buy_offer_v1_beta_oas3.d.ts +173 -0
- package/dist/types/restful/specs/buy_offer_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/buy_order_v1_beta_oas3.d.ts +1701 -0
- package/dist/types/restful/specs/buy_order_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/cancellation_oas3.d.ts +112 -0
- package/dist/types/restful/specs/cancellation_oas3.js +5 -0
- package/dist/types/restful/specs/case_oas3.d.ts +124 -0
- package/dist/types/restful/specs/case_oas3.js +5 -0
- package/dist/types/restful/specs/commerce_catalog_v1_beta_oas3.d.ts +758 -0
- package/dist/types/restful/specs/commerce_catalog_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/commerce_charity_v1_oas3.d.ts +224 -0
- package/dist/types/restful/specs/commerce_charity_v1_oas3.js +5 -0
- package/dist/types/restful/specs/commerce_identity_v1_oas3.d.ts +152 -0
- package/dist/types/restful/specs/commerce_identity_v1_oas3.js +5 -0
- package/dist/types/restful/specs/commerce_notification_v1_oas3.d.ts +677 -0
- package/dist/types/restful/specs/commerce_notification_v1_oas3.js +5 -0
- package/dist/types/restful/specs/commerce_taxonomy_v1_oas3.d.ts +530 -0
- package/dist/types/restful/specs/commerce_taxonomy_v1_oas3.js +5 -0
- package/dist/types/restful/specs/commerce_translation_v1_beta_oas3.d.ts +100 -0
- package/dist/types/restful/specs/commerce_translation_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/developer_analytics_v1_beta_oas3.d.ts +158 -0
- package/dist/types/restful/specs/developer_analytics_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/developer_key_management_v1_oas3.d.ts +162 -0
- package/dist/types/restful/specs/developer_key_management_v1_oas3.js +5 -0
- package/dist/types/restful/specs/inquiry_oas3.d.ts +180 -0
- package/dist/types/restful/specs/inquiry_oas3.js +5 -0
- package/dist/types/restful/specs/return_oas3.d.ts +528 -0
- package/dist/types/restful/specs/return_oas3.js +5 -0
- package/dist/types/restful/specs/sell_account_v1_oas3.d.ts +2061 -0
- package/dist/types/restful/specs/sell_account_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_analytics_v1_oas3.d.ts +340 -0
- package/dist/types/restful/specs/sell_analytics_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_compliance_v1_oas3.d.ts +253 -0
- package/dist/types/restful/specs/sell_compliance_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_feed_v1_oas3.d.ts +1191 -0
- package/dist/types/restful/specs/sell_feed_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_finances_v1_oas3.d.ts +572 -0
- package/dist/types/restful/specs/sell_finances_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_fulfillment_v1_oas3.d.ts +1386 -0
- package/dist/types/restful/specs/sell_fulfillment_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_inventory_v1_oas3.d.ts +2175 -0
- package/dist/types/restful/specs/sell_inventory_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_listing_v1_beta_oas3.d.ts +150 -0
- package/dist/types/restful/specs/sell_listing_v1_beta_oas3.js +5 -0
- package/dist/types/restful/specs/sell_logistics_v1_oas3.d.ts +451 -0
- package/dist/types/restful/specs/sell_logistics_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_marketing_v1_oas3.d.ts +3728 -0
- package/dist/types/restful/specs/sell_marketing_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_metadata_v1_oas3.d.ts +429 -0
- package/dist/types/restful/specs/sell_metadata_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_negotiation_v1_oas3.d.ts +225 -0
- package/dist/types/restful/specs/sell_negotiation_v1_oas3.js +5 -0
- package/dist/types/restful/specs/sell_recommendation_v1_oas3.d.ts +148 -0
- package/dist/types/restful/specs/sell_recommendation_v1_oas3.js +5 -0
- package/dist/types/restfulTypes.d.ts +439 -1179
- package/dist/types/restfulTypes.js +1 -1
- package/dist/types/traditonalTypes.d.ts +35 -35
- package/dist/types/traditonalTypes.js +1 -1
- package/lib/api/apiFactory.d.ts +27 -27
- package/lib/api/apiFactory.js +100 -100
- package/lib/api/base.d.ts +10 -10
- package/lib/api/base.js +13 -13
- package/lib/api/digitalSignature.d.ts +43 -43
- package/lib/api/digitalSignature.js +112 -112
- package/lib/api/index.d.ts +13 -13
- package/lib/api/index.js +35 -35
- package/lib/api/restful/buy/browse/index.d.ts +84 -84
- package/lib/api/restful/buy/browse/index.js +137 -141
- package/lib/api/restful/buy/deal/index.d.ts +56 -55
- package/lib/api/restful/buy/deal/index.js +79 -79
- package/lib/api/restful/buy/feed/index.d.ts +44 -43
- package/lib/api/restful/buy/feed/index.js +84 -84
- package/lib/api/restful/buy/index.d.ts +17 -17
- package/lib/api/restful/buy/index.js +20 -20
- package/lib/api/restful/buy/marketing/index.d.ts +28 -27
- package/lib/api/restful/buy/marketing/index.js +50 -50
- package/lib/api/restful/buy/marketplaceInsights/index.d.ts +29 -28
- package/lib/api/restful/buy/marketplaceInsights/index.js +50 -50
- package/lib/api/restful/buy/offer/index.d.ts +24 -23
- package/lib/api/restful/buy/offer/index.js +36 -36
- package/lib/api/restful/buy/order/index.d.ts +265 -264
- package/lib/api/restful/buy/order/index.js +368 -368
- package/lib/api/restful/commerce/catalog/index.d.ts +74 -73
- package/lib/api/restful/commerce/catalog/index.js +105 -107
- package/lib/api/restful/commerce/charity/index.d.ts +35 -34
- package/lib/api/restful/commerce/charity/index.js +55 -55
- package/lib/api/restful/commerce/identity/index.d.ts +15 -14
- package/lib/api/restful/commerce/identity/index.js +26 -26
- package/lib/api/restful/commerce/index.d.ts +15 -15
- package/lib/api/restful/commerce/index.js +18 -18
- package/lib/api/restful/commerce/notification/index.d.ts +118 -117
- package/lib/api/restful/commerce/notification/index.js +186 -186
- package/lib/api/restful/commerce/taxonomy/index.d.ts +79 -78
- package/lib/api/restful/commerce/taxonomy/index.js +134 -134
- package/lib/api/restful/commerce/translation/index.d.ts +16 -15
- package/lib/api/restful/commerce/translation/index.js +24 -24
- package/lib/api/restful/developer/analytics/index.d.ts +23 -22
- package/lib/api/restful/developer/analytics/index.js +44 -44
- package/lib/api/restful/developer/index.d.ts +7 -7
- package/lib/api/restful/developer/index.js +10 -10
- package/lib/api/restful/developer/keyManagement/index.d.ts +25 -24
- package/lib/api/restful/developer/keyManagement/index.js +42 -42
- package/lib/api/restful/index.d.ts +70 -67
- package/lib/api/restful/index.js +187 -184
- package/lib/api/restful/postOrder/cancellation/index.d.ts +57 -57
- package/lib/api/restful/postOrder/cancellation/index.js +94 -94
- package/lib/api/restful/postOrder/case/index.d.ts +63 -63
- package/lib/api/restful/postOrder/case/index.js +94 -94
- package/lib/api/restful/postOrder/index.d.ts +11 -11
- package/lib/api/restful/postOrder/index.js +14 -14
- package/lib/api/restful/postOrder/inquiry/index.d.ts +82 -82
- package/lib/api/restful/postOrder/inquiry/index.js +130 -130
- package/lib/api/restful/postOrder/return/index.d.ts +231 -231
- package/lib/api/restful/postOrder/return/index.js +360 -360
- package/lib/api/restful/sell/account/index.d.ts +299 -298
- package/lib/api/restful/sell/account/index.js +466 -466
- package/lib/api/restful/sell/analytics/index.d.ts +42 -41
- package/lib/api/restful/sell/analytics/index.js +60 -60
- package/lib/api/restful/sell/compliance/index.d.ts +38 -37
- package/lib/api/restful/sell/compliance/index.js +56 -56
- package/lib/api/restful/sell/feed/index.d.ts +172 -171
- package/lib/api/restful/sell/feed/index.js +283 -283
- package/lib/api/restful/sell/finances/index.d.ts +79 -78
- package/lib/api/restful/sell/finances/index.js +108 -108
- package/lib/api/restful/sell/fulfillment/index.d.ts +138 -137
- package/lib/api/restful/sell/fulfillment/index.js +198 -198
- package/lib/api/restful/sell/index.d.ts +29 -29
- package/lib/api/restful/sell/index.js +32 -32
- package/lib/api/restful/sell/inventory/index.d.ts +249 -248
- package/lib/api/restful/sell/inventory/index.js +345 -345
- package/lib/api/restful/sell/listing/index.d.ts +15 -14
- package/lib/api/restful/sell/listing/index.js +24 -24
- package/lib/api/restful/sell/logistics/index.d.ts +45 -44
- package/lib/api/restful/sell/logistics/index.js +65 -65
- package/lib/api/restful/sell/marketing/index.d.ts +627 -626
- package/lib/api/restful/sell/marketing/index.js +868 -868
- package/lib/api/restful/sell/metadata/index.d.ts +78 -77
- package/lib/api/restful/sell/metadata/index.js +130 -130
- package/lib/api/restful/sell/negotiation/index.d.ts +25 -24
- package/lib/api/restful/sell/negotiation/index.js +38 -38
- package/lib/api/restful/sell/recommendation/index.d.ts +27 -26
- package/lib/api/restful/sell/recommendation/index.js +38 -38
- package/lib/api/traditional/XMLRequest.d.ts +109 -109
- package/lib/api/traditional/XMLRequest.js +182 -182
- package/lib/api/traditional/clientAlerts/index.d.ts +9 -9
- package/lib/api/traditional/clientAlerts/index.js +14 -14
- package/lib/api/traditional/clientAlerts/types.d.ts +31 -31
- package/lib/api/traditional/clientAlerts/types.js +34 -35
- package/lib/api/traditional/fields.d.ts +1948 -1948
- package/lib/api/traditional/fields.js +1948 -1948
- package/lib/api/traditional/finding/index.d.ts +12 -12
- package/lib/api/traditional/finding/index.js +15 -15
- package/lib/api/traditional/index.d.ts +17 -17
- package/lib/api/traditional/index.js +220 -220
- package/lib/api/traditional/merchandising/index.d.ts +7 -7
- package/lib/api/traditional/merchandising/index.js +10 -10
- package/lib/api/traditional/shopping/index.d.ts +11 -11
- package/lib/api/traditional/shopping/index.js +15 -15
- package/lib/api/traditional/trading/index.d.ts +142 -142
- package/lib/api/traditional/trading/index.js +145 -145
- package/lib/auth/authNAuth.d.ts +49 -49
- package/lib/auth/authNAuth.js +122 -122
- package/lib/auth/index.d.ts +17 -17
- package/lib/auth/index.js +31 -31
- package/lib/auth/oAuth2.d.ts +95 -95
- package/lib/auth/oAuth2.js +265 -265
- package/lib/eBayApi.d.ts +59 -59
- package/lib/eBayApi.js +141 -141
- package/lib/ebay-api.min.js +1 -1
- package/lib/enums/apiEnums.d.ts +49 -49
- package/lib/enums/apiEnums.js +54 -54
- package/lib/enums/index.d.ts +2 -2
- package/lib/enums/index.js +18 -18
- package/lib/enums/restfulEnums.d.ts +970 -970
- package/lib/enums/restfulEnums.js +1016 -1016
- package/lib/errors/index.d.ts +66 -66
- package/lib/errors/index.js +212 -212
- package/lib/index.d.ts +2 -2
- package/lib/index.js +6 -6
- package/lib/nanoevents.d.ts +6 -6
- package/lib/nanoevents.js +24 -24
- package/lib/request.d.ts +26 -26
- package/lib/request.js +50 -50
- package/lib/types/apiTypes.d.ts +40 -40
- package/lib/types/apiTypes.js +2 -2
- package/lib/types/index.d.ts +3 -3
- package/lib/types/index.js +19 -19
- package/lib/types/restful/specs/buy_browse_v1_oas3.d.ts +1531 -0
- package/lib/types/restful/specs/buy_browse_v1_oas3.js +6 -0
- package/lib/types/restful/specs/buy_deal_v1_oas3.d.ts +434 -0
- package/lib/types/restful/specs/buy_deal_v1_oas3.js +6 -0
- package/lib/types/restful/specs/buy_feed_v1_beta_oas3.d.ts +561 -0
- package/lib/types/restful/specs/buy_feed_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/buy_marketing_v1_beta_oas3.d.ts +288 -0
- package/lib/types/restful/specs/buy_marketing_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/buy_marketplace_insights_v1_beta_oas3.d.ts +304 -0
- package/lib/types/restful/specs/buy_marketplace_insights_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/buy_offer_v1_beta_oas3.d.ts +173 -0
- package/lib/types/restful/specs/buy_offer_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/buy_order_v1_beta_oas3.d.ts +1701 -0
- package/lib/types/restful/specs/buy_order_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/cancellation_oas3.d.ts +112 -0
- package/lib/types/restful/specs/cancellation_oas3.js +6 -0
- package/lib/types/restful/specs/case_oas3.d.ts +124 -0
- package/lib/types/restful/specs/case_oas3.js +6 -0
- package/lib/types/restful/specs/commerce_catalog_v1_beta_oas3.d.ts +758 -0
- package/lib/types/restful/specs/commerce_catalog_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/commerce_charity_v1_oas3.d.ts +224 -0
- package/lib/types/restful/specs/commerce_charity_v1_oas3.js +6 -0
- package/lib/types/restful/specs/commerce_identity_v1_oas3.d.ts +152 -0
- package/lib/types/restful/specs/commerce_identity_v1_oas3.js +6 -0
- package/lib/types/restful/specs/commerce_notification_v1_oas3.d.ts +677 -0
- package/lib/types/restful/specs/commerce_notification_v1_oas3.js +6 -0
- package/lib/types/restful/specs/commerce_taxonomy_v1_oas3.d.ts +530 -0
- package/lib/types/restful/specs/commerce_taxonomy_v1_oas3.js +6 -0
- package/lib/types/restful/specs/commerce_translation_v1_beta_oas3.d.ts +100 -0
- package/lib/types/restful/specs/commerce_translation_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/developer_analytics_v1_beta_oas3.d.ts +158 -0
- package/lib/types/restful/specs/developer_analytics_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/developer_key_management_v1_oas3.d.ts +162 -0
- package/lib/types/restful/specs/developer_key_management_v1_oas3.js +6 -0
- package/lib/types/restful/specs/inquiry_oas3.d.ts +180 -0
- package/lib/types/restful/specs/inquiry_oas3.js +6 -0
- package/lib/types/restful/specs/return_oas3.d.ts +528 -0
- package/lib/types/restful/specs/return_oas3.js +6 -0
- package/lib/types/restful/specs/sell_account_v1_oas3.d.ts +2061 -0
- package/lib/types/restful/specs/sell_account_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_analytics_v1_oas3.d.ts +340 -0
- package/lib/types/restful/specs/sell_analytics_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_compliance_v1_oas3.d.ts +253 -0
- package/lib/types/restful/specs/sell_compliance_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_feed_v1_oas3.d.ts +1191 -0
- package/lib/types/restful/specs/sell_feed_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_finances_v1_oas3.d.ts +572 -0
- package/lib/types/restful/specs/sell_finances_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_fulfillment_v1_oas3.d.ts +1386 -0
- package/lib/types/restful/specs/sell_fulfillment_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_inventory_v1_oas3.d.ts +2175 -0
- package/lib/types/restful/specs/sell_inventory_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_listing_v1_beta_oas3.d.ts +150 -0
- package/lib/types/restful/specs/sell_listing_v1_beta_oas3.js +6 -0
- package/lib/types/restful/specs/sell_logistics_v1_oas3.d.ts +451 -0
- package/lib/types/restful/specs/sell_logistics_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_marketing_v1_oas3.d.ts +3728 -0
- package/lib/types/restful/specs/sell_marketing_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_metadata_v1_oas3.d.ts +429 -0
- package/lib/types/restful/specs/sell_metadata_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_negotiation_v1_oas3.d.ts +225 -0
- package/lib/types/restful/specs/sell_negotiation_v1_oas3.js +6 -0
- package/lib/types/restful/specs/sell_recommendation_v1_oas3.d.ts +148 -0
- package/lib/types/restful/specs/sell_recommendation_v1_oas3.js +6 -0
- package/lib/types/restfulTypes.d.ts +439 -1179
- package/lib/types/restfulTypes.js +2 -2
- package/lib/types/traditonalTypes.d.ts +35 -35
- package/lib/types/traditonalTypes.js +2 -2
- package/package.json +6 -4
package/dist/auth/oAuth2.js
CHANGED
|
@@ -1,259 +1,260 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
import { createNanoEvents } from '../nanoevents.js';
|
|
3
|
-
import Base from '../api/base.js';
|
|
4
|
-
const log = debug('ebay:oauth2');
|
|
5
|
-
/**
|
|
6
|
-
* https://developer.ebay.com/api-docs/static/oauth-tokens.html
|
|
7
|
-
*
|
|
8
|
-
* Client credentials grant flow mints a new Application access token that you can use to access the resources owned by the application.
|
|
9
|
-
* Authorization code grant flow mints a new User access token that you can use to access the resources owned by the user.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
constructor(config, req) {
|
|
13
|
-
super(config, req);
|
|
14
|
-
this.emitter = createNanoEvents();
|
|
15
|
-
this.scope = this.config.scope || OAuth2.defaultScopes;
|
|
16
|
-
}
|
|
17
|
-
on(event, callback) {
|
|
18
|
-
return this.emitter.on(event, callback);
|
|
19
|
-
}
|
|
20
|
-
static generateAuthUrl(sandbox, appId, ruName, scope, state = '') {
|
|
21
|
-
return [
|
|
22
|
-
sandbox ? OAuth2.AUTHORIZE_ENDPOINT.sandbox : OAuth2.AUTHORIZE_ENDPOINT.production,
|
|
23
|
-
'?client_id=', encodeURIComponent(appId),
|
|
24
|
-
'&redirect_uri=', encodeURIComponent(ruName),
|
|
25
|
-
'&response_type=code',
|
|
26
|
-
'&state=', encodeURIComponent(state),
|
|
27
|
-
'&scope=', encodeURIComponent(scope.join(' '))
|
|
28
|
-
].join('');
|
|
29
|
-
}
|
|
30
|
-
get identityEndpoint() {
|
|
31
|
-
return this.config.sandbox ? OAuth2.IDENTITY_ENDPOINT.sandbox : OAuth2.IDENTITY_ENDPOINT.production;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Return the access token.
|
|
35
|
-
* First return user access token, if not set Application Access Token.
|
|
36
|
-
*/
|
|
37
|
-
async getAccessToken() {
|
|
38
|
-
return this.getUserAccessToken() || this.getApplicationAccessToken();
|
|
39
|
-
}
|
|
40
|
-
getUserAccessToken() {
|
|
41
|
-
return this._authToken?.access_token ?? null;
|
|
42
|
-
}
|
|
43
|
-
async getApplicationAccessToken() {
|
|
44
|
-
if (this._clientToken) {
|
|
45
|
-
log('Return existing application access token: ', this._clientToken);
|
|
46
|
-
return this._clientToken.access_token;
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
const token = await this.obtainApplicationAccessToken();
|
|
50
|
-
return token.access_token;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
setClientToken(clientToken) {
|
|
57
|
-
this._clientToken = clientToken;
|
|
58
|
-
}
|
|
59
|
-
setScope(scope) {
|
|
60
|
-
this.scope = scope;
|
|
61
|
-
}
|
|
62
|
-
getScope() {
|
|
63
|
-
return [...this.scope];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Client credentials grant flow.
|
|
67
|
-
*/
|
|
68
|
-
async mintApplicationAccessToken() {
|
|
69
|
-
if (!this.config.appId) {
|
|
70
|
-
throw new Error('Missing App ID (Client Id)');
|
|
71
|
-
}
|
|
72
|
-
if (!this.config.certId) {
|
|
73
|
-
throw new Error('Missing Cert Id (Client Secret)');
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
const response = await this.req.postForm(this.identityEndpoint, {
|
|
77
|
-
scope: this.scope.join(' '),
|
|
78
|
-
grant_type: 'client_credentials'
|
|
79
|
-
}, {
|
|
80
|
-
auth: {
|
|
81
|
-
username: this.config.appId,
|
|
82
|
-
password: this.config.certId
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
return response.data;
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
log('Failed to mint application token', error);
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Client credentials grant flow.
|
|
94
|
-
*/
|
|
95
|
-
async obtainApplicationAccessToken() {
|
|
96
|
-
log('Obtain a new application access token with scope: ', this.scope.join(','));
|
|
97
|
-
try {
|
|
98
|
-
const token = await this.mintApplicationAccessToken();
|
|
99
|
-
log('Obtained a new application access token:', token);
|
|
100
|
-
this.setClientToken(token);
|
|
101
|
-
this.emitter.emit('refreshClientToken', token);
|
|
102
|
-
return token;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
log('Failed to obtain application token', error);
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Generates URL for consent page landing.
|
|
111
|
-
*
|
|
112
|
-
* @param ruName RuName
|
|
113
|
-
* @param scope the scopes
|
|
114
|
-
* @param state state parameter returned in the redirect URL
|
|
115
|
-
*/
|
|
116
|
-
generateAuthUrl(ruName, scope = this.scope, state = '') {
|
|
117
|
-
ruName = ruName || this.config.ruName;
|
|
118
|
-
if (!ruName) {
|
|
119
|
-
throw new Error('RuName is required.');
|
|
120
|
-
}
|
|
121
|
-
return OAuth2.generateAuthUrl(this.config.sandbox, this.config.appId, ruName, scope, state);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Authorization code grant flow.
|
|
125
|
-
*
|
|
126
|
-
* Mint the user access token for the given code.
|
|
127
|
-
*
|
|
128
|
-
* @param code the code
|
|
129
|
-
* @param ruName the redirectUri
|
|
130
|
-
*/
|
|
131
|
-
async mintUserAccessToken(code, ruName = this.config.ruName) {
|
|
132
|
-
try {
|
|
133
|
-
const response = await this.req.postForm(this.identityEndpoint, {
|
|
134
|
-
grant_type: 'authorization_code',
|
|
135
|
-
code,
|
|
136
|
-
redirect_uri: ruName
|
|
137
|
-
}, {
|
|
138
|
-
auth: {
|
|
139
|
-
username: this.config.appId,
|
|
140
|
-
password: this.config.certId
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
const token = response.data;
|
|
144
|
-
log('User Access Token', token);
|
|
145
|
-
return token;
|
|
146
|
-
}
|
|
147
|
-
catch (error) {
|
|
148
|
-
log('Failed to get the token', error);
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Authorization code grant flow.
|
|
154
|
-
*
|
|
155
|
-
* Mint the access token for the given code.
|
|
156
|
-
*
|
|
157
|
-
* @param code the code
|
|
158
|
-
* @param ruName the redirectUri
|
|
159
|
-
*/
|
|
160
|
-
async getToken(code, ruName = this.config.ruName) {
|
|
161
|
-
return await this.mintUserAccessToken(code, ruName);
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Authorization code grant flow.
|
|
165
|
-
*/
|
|
166
|
-
async refreshUserAccessToken() {
|
|
167
|
-
if (!this._authToken || !this._authToken.refresh_token) {
|
|
168
|
-
log('Tried to refresh user access token before it was set.');
|
|
169
|
-
throw new Error('Failed to refresh the user access token. Token or refresh_token is not set.');
|
|
170
|
-
}
|
|
171
|
-
try {
|
|
172
|
-
const response = await this.req.postForm(this.identityEndpoint, {
|
|
173
|
-
grant_type: 'refresh_token',
|
|
174
|
-
refresh_token: this._authToken.refresh_token,
|
|
175
|
-
scope: this.scope.join(' ')
|
|
176
|
-
}, {
|
|
177
|
-
auth: {
|
|
178
|
-
username: this.config.appId,
|
|
179
|
-
password: this.config.certId
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
const token = response.data;
|
|
183
|
-
log('Successfully refreshed token', token);
|
|
184
|
-
const refreshedToken = {
|
|
185
|
-
...this._authToken,
|
|
186
|
-
...token
|
|
187
|
-
};
|
|
188
|
-
this.setCredentials(refreshedToken);
|
|
189
|
-
this.emitter.emit('refreshAuthToken', refreshedToken);
|
|
190
|
-
return refreshedToken;
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
log('Failed to refresh the token', error);
|
|
194
|
-
throw error;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Gets and sets the user access token for the given code.
|
|
199
|
-
*
|
|
200
|
-
* Authorization code grant flow.
|
|
201
|
-
*
|
|
202
|
-
* @param code the code
|
|
203
|
-
*/
|
|
204
|
-
async obtainToken(code) {
|
|
205
|
-
const token = await this.getToken(code);
|
|
206
|
-
log('Obtain user access token', token);
|
|
207
|
-
this.setCredentials(token);
|
|
208
|
-
return token;
|
|
209
|
-
}
|
|
210
|
-
getCredentials() {
|
|
211
|
-
if (this._authToken) {
|
|
212
|
-
return {
|
|
213
|
-
...this._authToken
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
else if (this._clientToken) {
|
|
217
|
-
return {
|
|
218
|
-
...this._clientToken
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
setCredentials(authToken) {
|
|
224
|
-
if (typeof authToken === 'string') {
|
|
225
|
-
this._authToken = {
|
|
226
|
-
refresh_token: '',
|
|
227
|
-
expires_in: 7200,
|
|
228
|
-
refresh_token_expires_in: 47304000,
|
|
229
|
-
token_type: 'User Access Token',
|
|
230
|
-
access_token: authToken
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
this._authToken = authToken;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Refresh the user access token if set or application access token
|
|
239
|
-
*/
|
|
240
|
-
async refreshToken() {
|
|
241
|
-
if (this._authToken) {
|
|
242
|
-
return await this.refreshUserAccessToken();
|
|
243
|
-
}
|
|
244
|
-
else if (this._clientToken) {
|
|
245
|
-
return await this.obtainApplicationAccessToken();
|
|
246
|
-
}
|
|
247
|
-
throw new Error('Missing credentials. To refresh a token an application access token or user access token must be already set.');
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
// If all the calls in our application require just an Application access token we can use this endpoint
|
|
251
|
-
OAuth2.IDENTITY_ENDPOINT = {
|
|
252
|
-
production: 'https://api.ebay.com/identity/v1/oauth2/token',
|
|
253
|
-
sandbox: 'https://api.sandbox.ebay.com/identity/v1/oauth2/token'
|
|
254
|
-
};
|
|
255
|
-
OAuth2.AUTHORIZE_ENDPOINT = {
|
|
256
|
-
production: 'https://auth.ebay.com/oauth2/authorize',
|
|
257
|
-
sandbox: 'https://auth.sandbox.ebay.com/oauth2/authorize'
|
|
258
|
-
};
|
|
259
|
-
OAuth2.defaultScopes = ['https://api.ebay.com/oauth/api_scope'];
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import { createNanoEvents } from '../nanoevents.js';
|
|
3
|
+
import Base from '../api/base.js';
|
|
4
|
+
const log = debug('ebay:oauth2');
|
|
5
|
+
/**
|
|
6
|
+
* https://developer.ebay.com/api-docs/static/oauth-tokens.html
|
|
7
|
+
*
|
|
8
|
+
* Client credentials grant flow mints a new Application access token that you can use to access the resources owned by the application.
|
|
9
|
+
* Authorization code grant flow mints a new User access token that you can use to access the resources owned by the user.
|
|
10
|
+
*/
|
|
11
|
+
class OAuth2 extends Base {
|
|
12
|
+
constructor(config, req) {
|
|
13
|
+
super(config, req);
|
|
14
|
+
this.emitter = createNanoEvents();
|
|
15
|
+
this.scope = this.config.scope || OAuth2.defaultScopes;
|
|
16
|
+
}
|
|
17
|
+
on(event, callback) {
|
|
18
|
+
return this.emitter.on(event, callback);
|
|
19
|
+
}
|
|
20
|
+
static generateAuthUrl(sandbox, appId, ruName, scope, state = '') {
|
|
21
|
+
return [
|
|
22
|
+
sandbox ? OAuth2.AUTHORIZE_ENDPOINT.sandbox : OAuth2.AUTHORIZE_ENDPOINT.production,
|
|
23
|
+
'?client_id=', encodeURIComponent(appId),
|
|
24
|
+
'&redirect_uri=', encodeURIComponent(ruName),
|
|
25
|
+
'&response_type=code',
|
|
26
|
+
'&state=', encodeURIComponent(state),
|
|
27
|
+
'&scope=', encodeURIComponent(scope.join(' '))
|
|
28
|
+
].join('');
|
|
29
|
+
}
|
|
30
|
+
get identityEndpoint() {
|
|
31
|
+
return this.config.sandbox ? OAuth2.IDENTITY_ENDPOINT.sandbox : OAuth2.IDENTITY_ENDPOINT.production;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Return the access token.
|
|
35
|
+
* First return user access token, if not set Application Access Token.
|
|
36
|
+
*/
|
|
37
|
+
async getAccessToken() {
|
|
38
|
+
return this.getUserAccessToken() || this.getApplicationAccessToken();
|
|
39
|
+
}
|
|
40
|
+
getUserAccessToken() {
|
|
41
|
+
return this._authToken?.access_token ?? null;
|
|
42
|
+
}
|
|
43
|
+
async getApplicationAccessToken() {
|
|
44
|
+
if (this._clientToken) {
|
|
45
|
+
log('Return existing application access token: ', this._clientToken);
|
|
46
|
+
return this._clientToken.access_token;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const token = await this.obtainApplicationAccessToken();
|
|
50
|
+
return token.access_token;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
setClientToken(clientToken) {
|
|
57
|
+
this._clientToken = clientToken;
|
|
58
|
+
}
|
|
59
|
+
setScope(scope) {
|
|
60
|
+
this.scope = scope;
|
|
61
|
+
}
|
|
62
|
+
getScope() {
|
|
63
|
+
return [...this.scope];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Client credentials grant flow.
|
|
67
|
+
*/
|
|
68
|
+
async mintApplicationAccessToken() {
|
|
69
|
+
if (!this.config.appId) {
|
|
70
|
+
throw new Error('Missing App ID (Client Id)');
|
|
71
|
+
}
|
|
72
|
+
if (!this.config.certId) {
|
|
73
|
+
throw new Error('Missing Cert Id (Client Secret)');
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const response = await this.req.postForm(this.identityEndpoint, {
|
|
77
|
+
scope: this.scope.join(' '),
|
|
78
|
+
grant_type: 'client_credentials'
|
|
79
|
+
}, {
|
|
80
|
+
auth: {
|
|
81
|
+
username: this.config.appId,
|
|
82
|
+
password: this.config.certId
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return response.data;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
log('Failed to mint application token', error);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Client credentials grant flow.
|
|
94
|
+
*/
|
|
95
|
+
async obtainApplicationAccessToken() {
|
|
96
|
+
log('Obtain a new application access token with scope: ', this.scope.join(','));
|
|
97
|
+
try {
|
|
98
|
+
const token = await this.mintApplicationAccessToken();
|
|
99
|
+
log('Obtained a new application access token:', token);
|
|
100
|
+
this.setClientToken(token);
|
|
101
|
+
this.emitter.emit('refreshClientToken', token);
|
|
102
|
+
return token;
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
log('Failed to obtain application token', error);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Generates URL for consent page landing.
|
|
111
|
+
*
|
|
112
|
+
* @param ruName RuName
|
|
113
|
+
* @param scope the scopes
|
|
114
|
+
* @param state state parameter returned in the redirect URL
|
|
115
|
+
*/
|
|
116
|
+
generateAuthUrl(ruName, scope = this.scope, state = '') {
|
|
117
|
+
ruName = ruName || this.config.ruName;
|
|
118
|
+
if (!ruName) {
|
|
119
|
+
throw new Error('RuName is required.');
|
|
120
|
+
}
|
|
121
|
+
return OAuth2.generateAuthUrl(this.config.sandbox, this.config.appId, ruName, scope, state);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Authorization code grant flow.
|
|
125
|
+
*
|
|
126
|
+
* Mint the user access token for the given code.
|
|
127
|
+
*
|
|
128
|
+
* @param code the code
|
|
129
|
+
* @param ruName the redirectUri
|
|
130
|
+
*/
|
|
131
|
+
async mintUserAccessToken(code, ruName = this.config.ruName) {
|
|
132
|
+
try {
|
|
133
|
+
const response = await this.req.postForm(this.identityEndpoint, {
|
|
134
|
+
grant_type: 'authorization_code',
|
|
135
|
+
code,
|
|
136
|
+
redirect_uri: ruName
|
|
137
|
+
}, {
|
|
138
|
+
auth: {
|
|
139
|
+
username: this.config.appId,
|
|
140
|
+
password: this.config.certId
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
const token = response.data;
|
|
144
|
+
log('User Access Token', token);
|
|
145
|
+
return token;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
log('Failed to get the token', error);
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Authorization code grant flow.
|
|
154
|
+
*
|
|
155
|
+
* Mint the access token for the given code.
|
|
156
|
+
*
|
|
157
|
+
* @param code the code
|
|
158
|
+
* @param ruName the redirectUri
|
|
159
|
+
*/
|
|
160
|
+
async getToken(code, ruName = this.config.ruName) {
|
|
161
|
+
return await this.mintUserAccessToken(code, ruName);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Authorization code grant flow.
|
|
165
|
+
*/
|
|
166
|
+
async refreshUserAccessToken() {
|
|
167
|
+
if (!this._authToken || !this._authToken.refresh_token) {
|
|
168
|
+
log('Tried to refresh user access token before it was set.');
|
|
169
|
+
throw new Error('Failed to refresh the user access token. Token or refresh_token is not set.');
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
const response = await this.req.postForm(this.identityEndpoint, {
|
|
173
|
+
grant_type: 'refresh_token',
|
|
174
|
+
refresh_token: this._authToken.refresh_token,
|
|
175
|
+
scope: this.scope.join(' ')
|
|
176
|
+
}, {
|
|
177
|
+
auth: {
|
|
178
|
+
username: this.config.appId,
|
|
179
|
+
password: this.config.certId
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
const token = response.data;
|
|
183
|
+
log('Successfully refreshed token', token);
|
|
184
|
+
const refreshedToken = {
|
|
185
|
+
...this._authToken,
|
|
186
|
+
...token
|
|
187
|
+
};
|
|
188
|
+
this.setCredentials(refreshedToken);
|
|
189
|
+
this.emitter.emit('refreshAuthToken', refreshedToken);
|
|
190
|
+
return refreshedToken;
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
log('Failed to refresh the token', error);
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Gets and sets the user access token for the given code.
|
|
199
|
+
*
|
|
200
|
+
* Authorization code grant flow.
|
|
201
|
+
*
|
|
202
|
+
* @param code the code
|
|
203
|
+
*/
|
|
204
|
+
async obtainToken(code) {
|
|
205
|
+
const token = await this.getToken(code);
|
|
206
|
+
log('Obtain user access token', token);
|
|
207
|
+
this.setCredentials(token);
|
|
208
|
+
return token;
|
|
209
|
+
}
|
|
210
|
+
getCredentials() {
|
|
211
|
+
if (this._authToken) {
|
|
212
|
+
return {
|
|
213
|
+
...this._authToken
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
else if (this._clientToken) {
|
|
217
|
+
return {
|
|
218
|
+
...this._clientToken
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
setCredentials(authToken) {
|
|
224
|
+
if (typeof authToken === 'string') {
|
|
225
|
+
this._authToken = {
|
|
226
|
+
refresh_token: '',
|
|
227
|
+
expires_in: 7200,
|
|
228
|
+
refresh_token_expires_in: 47304000,
|
|
229
|
+
token_type: 'User Access Token',
|
|
230
|
+
access_token: authToken
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
this._authToken = authToken;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Refresh the user access token if set or application access token
|
|
239
|
+
*/
|
|
240
|
+
async refreshToken() {
|
|
241
|
+
if (this._authToken) {
|
|
242
|
+
return await this.refreshUserAccessToken();
|
|
243
|
+
}
|
|
244
|
+
else if (this._clientToken) {
|
|
245
|
+
return await this.obtainApplicationAccessToken();
|
|
246
|
+
}
|
|
247
|
+
throw new Error('Missing credentials. To refresh a token an application access token or user access token must be already set.');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// If all the calls in our application require just an Application access token we can use this endpoint
|
|
251
|
+
OAuth2.IDENTITY_ENDPOINT = {
|
|
252
|
+
production: 'https://api.ebay.com/identity/v1/oauth2/token',
|
|
253
|
+
sandbox: 'https://api.sandbox.ebay.com/identity/v1/oauth2/token'
|
|
254
|
+
};
|
|
255
|
+
OAuth2.AUTHORIZE_ENDPOINT = {
|
|
256
|
+
production: 'https://auth.ebay.com/oauth2/authorize',
|
|
257
|
+
sandbox: 'https://auth.sandbox.ebay.com/oauth2/authorize'
|
|
258
|
+
};
|
|
259
|
+
OAuth2.defaultScopes = ['https://api.ebay.com/oauth/api_scope'];
|
|
260
|
+
export default OAuth2;
|
package/dist/eBayApi.d.ts
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import Api from './api/index.js';
|
|
2
|
-
import { Buy } from './api/restful/buy/index.js';
|
|
3
|
-
import { Commerce } from './api/restful/commerce/index.js';
|
|
4
|
-
import { Developer } from './api/restful/developer/index.js';
|
|
5
|
-
import { PostOrder } from './api/restful/postOrder/index.js';
|
|
6
|
-
import { Sell } from './api/restful/sell/index.js';
|
|
7
|
-
import AuthNAuth from './auth/authNAuth.js';
|
|
8
|
-
import OAuth2 from './auth/oAuth2.js';
|
|
9
|
-
import * as enums from './enums/index.js';
|
|
10
|
-
import { ContentLanguage, Locale, MarketplaceId, SiteId } from './enums/index.js';
|
|
11
|
-
import * as errors from './errors/index.js';
|
|
12
|
-
import { IEBayApiRequest } from './request.js';
|
|
13
|
-
import * as types from './types/index.js';
|
|
14
|
-
import { AppConfig, ClientAlerts, Finding, Merchandising, Shopping, Signature, Trading } from './types/index.js';
|
|
15
|
-
export default class eBayApi extends Api {
|
|
16
|
-
static readonly SiteId: typeof enums.SiteId;
|
|
17
|
-
static readonly MarketplaceId: typeof enums.MarketplaceId;
|
|
18
|
-
static readonly ContentLanguage: typeof enums.ContentLanguage;
|
|
19
|
-
static readonly Locale: typeof enums.Locale;
|
|
20
|
-
/**
|
|
21
|
-
* Loads config from `process.env`
|
|
22
|
-
*
|
|
23
|
-
* @return {eBayApi} a new eBayApi instance
|
|
24
|
-
* @param {request} req request
|
|
25
|
-
* @throws {ApiEnvError}
|
|
26
|
-
*/
|
|
27
|
-
static fromEnv(req?: IEBayApiRequest): eBayApi;
|
|
28
|
-
readonly authNAuth: AuthNAuth;
|
|
29
|
-
readonly oAuth2: OAuth2;
|
|
30
|
-
readonly OAuth2: OAuth2;
|
|
31
|
-
private readonly factory;
|
|
32
|
-
private _buy?;
|
|
33
|
-
private _commerce?;
|
|
34
|
-
private _developer?;
|
|
35
|
-
private _postOrder?;
|
|
36
|
-
private _sell?;
|
|
37
|
-
private _trading?;
|
|
38
|
-
private _finding?;
|
|
39
|
-
private _shopping?;
|
|
40
|
-
private _merchandising?;
|
|
41
|
-
private _clientAlerts?;
|
|
42
|
-
/**
|
|
43
|
-
* @param {AppConfig} config the app config
|
|
44
|
-
* @param {IEBayApiRequest} req the request
|
|
45
|
-
*/
|
|
46
|
-
constructor(config: AppConfig, req?: IEBayApiRequest);
|
|
47
|
-
get buy(): Buy;
|
|
48
|
-
get commerce(): Commerce;
|
|
49
|
-
get developer(): Developer;
|
|
50
|
-
get postOrder(): PostOrder;
|
|
51
|
-
get sell(): Sell;
|
|
52
|
-
get trading(): Trading;
|
|
53
|
-
get finding(): Finding;
|
|
54
|
-
get shopping(): Shopping;
|
|
55
|
-
get merchandising(): Merchandising;
|
|
56
|
-
get clientAlerts(): ClientAlerts;
|
|
57
|
-
setSignature(signature: Signature): void;
|
|
58
|
-
}
|
|
59
|
-
export { eBayApi, SiteId, MarketplaceId, ContentLanguage, Locale, enums, errors, types };
|
|
1
|
+
import Api from './api/index.js';
|
|
2
|
+
import { Buy } from './api/restful/buy/index.js';
|
|
3
|
+
import { Commerce } from './api/restful/commerce/index.js';
|
|
4
|
+
import { Developer } from './api/restful/developer/index.js';
|
|
5
|
+
import { PostOrder } from './api/restful/postOrder/index.js';
|
|
6
|
+
import { Sell } from './api/restful/sell/index.js';
|
|
7
|
+
import AuthNAuth from './auth/authNAuth.js';
|
|
8
|
+
import OAuth2 from './auth/oAuth2.js';
|
|
9
|
+
import * as enums from './enums/index.js';
|
|
10
|
+
import { ContentLanguage, Locale, MarketplaceId, SiteId } from './enums/index.js';
|
|
11
|
+
import * as errors from './errors/index.js';
|
|
12
|
+
import { IEBayApiRequest } from './request.js';
|
|
13
|
+
import * as types from './types/index.js';
|
|
14
|
+
import { AppConfig, ClientAlerts, Finding, Merchandising, Shopping, Signature, Trading } from './types/index.js';
|
|
15
|
+
export default class eBayApi extends Api {
|
|
16
|
+
static readonly SiteId: typeof enums.SiteId;
|
|
17
|
+
static readonly MarketplaceId: typeof enums.MarketplaceId;
|
|
18
|
+
static readonly ContentLanguage: typeof enums.ContentLanguage;
|
|
19
|
+
static readonly Locale: typeof enums.Locale;
|
|
20
|
+
/**
|
|
21
|
+
* Loads config from `process.env`
|
|
22
|
+
*
|
|
23
|
+
* @return {eBayApi} a new eBayApi instance
|
|
24
|
+
* @param {request} req request
|
|
25
|
+
* @throws {ApiEnvError}
|
|
26
|
+
*/
|
|
27
|
+
static fromEnv(req?: IEBayApiRequest): eBayApi;
|
|
28
|
+
readonly authNAuth: AuthNAuth;
|
|
29
|
+
readonly oAuth2: OAuth2;
|
|
30
|
+
readonly OAuth2: OAuth2;
|
|
31
|
+
private readonly factory;
|
|
32
|
+
private _buy?;
|
|
33
|
+
private _commerce?;
|
|
34
|
+
private _developer?;
|
|
35
|
+
private _postOrder?;
|
|
36
|
+
private _sell?;
|
|
37
|
+
private _trading?;
|
|
38
|
+
private _finding?;
|
|
39
|
+
private _shopping?;
|
|
40
|
+
private _merchandising?;
|
|
41
|
+
private _clientAlerts?;
|
|
42
|
+
/**
|
|
43
|
+
* @param {AppConfig} config the app config
|
|
44
|
+
* @param {IEBayApiRequest} req the request
|
|
45
|
+
*/
|
|
46
|
+
constructor(config: AppConfig, req?: IEBayApiRequest);
|
|
47
|
+
get buy(): Buy;
|
|
48
|
+
get commerce(): Commerce;
|
|
49
|
+
get developer(): Developer;
|
|
50
|
+
get postOrder(): PostOrder;
|
|
51
|
+
get sell(): Sell;
|
|
52
|
+
get trading(): Trading;
|
|
53
|
+
get finding(): Finding;
|
|
54
|
+
get shopping(): Shopping;
|
|
55
|
+
get merchandising(): Merchandising;
|
|
56
|
+
get clientAlerts(): ClientAlerts;
|
|
57
|
+
setSignature(signature: Signature): void;
|
|
58
|
+
}
|
|
59
|
+
export { eBayApi, SiteId, MarketplaceId, ContentLanguage, Locale, enums, errors, types };
|