Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ae_sdk

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ae_sdk - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

6

CHANGELOG.md
# ae_sdk
## 0.3.0
### Minor Changes
- Add system tool API and fix method signature
## 0.2.0

@@ -4,0 +10,0 @@

159

dist/index.d.ts

@@ -1,9 +0,30 @@

type AE_API_NAMES = DS_API_NAMES | AFFILIATE_API_NAMES | TOP_AUTH_API_NAMES;
/**
* ALIEXPRESS SERVICES
*/
type AE_DROPSHIPPING_SERVICE = "ds";
type AE_AFFILIATE_SERVICE = "affiliate";
type AE_SYSTEM_SERVICE = "system";
type AE_SERVICE = AE_AFFILIATE_SERVICE | AE_DROPSHIPPING_SERVICE | AE_SYSTEM_SERVICE;
/**
* ALIEXPRESS API NAMES
*/
type AE_API_NAMES = DS_API_NAMES | AFFILIATE_API_NAMES | SYSTEM_API_NAMES;
type DS_API_NAMES = "aliexpress.ds.recommend.feed.get" | "aliexpress.ds.product.get" | "aliexpress.postproduct.redefining.findaeproductbyidfordropshipper" | "aliexpress.trade.buy.placeorder" | "aliexpress.ds.trade.order.get" | "aliexpress.logistics.buyer.freight.calculate" | "aliexpress.logistics.ds.trackinginfo.query";
type AFFILIATE_API_NAMES = "aliexpress.affiliate.productdetail.get" | "aliexpress.affiliate.product.query" | "aliexpress.affiliate.hotproduct.query" | "aliexpress.affiliate.featuredpromo.products.get" | "aliexpress.affiliate.category.get";
type TOP_AUTH_API_NAMES = "taobao.top.auth.token.refresh";
type SYSTEM_API_NAMES = "/auth/token/security/create" | "/auth/token/create" | "/auth/token/security/refresh" | "/auth/token/refresh";
type AE_EXECUTE_FN_METHODS<T extends AE_SERVICE> = T extends AE_DROPSHIPPING_SERVICE ? DS_API_NAMES : T extends AE_SYSTEM_SERVICE ? SYSTEM_API_NAMES : AFFILIATE_API_NAMES;
/**
* METHODS PARAMETERS
*/
type AE_SYSTEM_EXECUTE_FN_PARAMS<T extends SYSTEM_API_NAMES> = T extends "/auth/token/security/create" ? AES_Generate_Security_Token_Params : T extends "/auth/token/create" ? AES_Generate_Token_Params : T extends "/auth/token/security/refresh" ? AES_Refresh_Security_Token_Params : T extends "/auth/token/refresh" ? AES_Refresh_Token_Params : unknown;
type AE_DS_EXECUTE_FN_PARAMS<T extends DS_API_NAMES> = T extends "aliexpress.ds.recommend.feed.get" ? DS_ProductAPI_Recommended_Products_Params : T extends "aliexpress.ds.product.get" ? DS_ProductAPI_Product_Params : T extends "aliexpress.postproduct.redefining.findaeproductbyidfordropshipper" ? DS_ProductAPI_Product_Detail_Params : T extends "aliexpress.trade.buy.placeorder" ? DS_OrderAPI_Place_Order_Params : T extends "aliexpress.ds.trade.order.get" ? DS_OrderAPI_Get_Order_Params : T extends "aliexpress.logistics.buyer.freight.calculate" ? DS_ShippingAPI_Shipping_Info_Params : T extends "aliexpress.logistics.ds.trackinginfo.query" ? DS_ShippingAPI_Tracking_Info_Params : unknown;
type AE_AFFILIATE_EXECUTE_FN_PARAMS<T extends AFFILIATE_API_NAMES> = T extends "aliexpress.affiliate.productdetail.get" ? Affiliate_Product_Details_Params : T extends "aliexpress.affiliate.product.query" ? Affiliate_Products_Params : T extends "aliexpress.affiliate.hotproduct.query" ? Affiliate_Hotproducts_Params : T extends "aliexpress.affiliate.featuredpromo.products.get" ? Affiliate_Featured_Promo_Products_Params : T extends "aliexpress.affiliate.category.get" ? null : unknown;
type AE_EXECUTE_FN_PARAMS<T extends AE_API_NAMES> = T extends DS_API_NAMES ? AE_DS_EXECUTE_FN_PARAMS<T> : T extends AFFILIATE_API_NAMES ? AE_AFFILIATE_EXECUTE_FN_PARAMS<T> : T extends SYSTEM_API_NAMES ? AE_SYSTEM_EXECUTE_FN_PARAMS<T> : unknown;
/**
* METHODS RESULTS
*/
type AE_SYSTEM_EXECUTE_FN_RESULT<T extends SYSTEM_API_NAMES> = T extends "/auth/token/security/create" ? AES_Generate_Security_Token_Result : T extends "/auth/token/create" ? AES_Generate_Token_Result : T extends "/auth/token/security/refresh" ? AES_Refresh_Security_Token_Result : T extends "/auth/token/refresh" ? AES_Refresh_Token_Result : unknown;
type AE_DS_EXECUTE_FN_RESULT<T extends DS_API_NAMES> = T extends "aliexpress.ds.recommend.feed.get" ? DS_ProductAPI_Recommended_Products_Result : T extends "aliexpress.ds.product.get" ? DS_ProductAPI_Product_Result : T extends "aliexpress.postproduct.redefining.findaeproductbyidfordropshipper" ? DS_ProductAPI_Product_Detail_Result : T extends "aliexpress.trade.buy.placeorder" ? DS_OrderAPI_Place_Order_Result : T extends "aliexpress.ds.trade.order.get" ? DS_OrderAPI_Get_Order_Result : T extends "aliexpress.logistics.buyer.freight.calculate" ? DS_ShippingAPI_Shipping_Info_Result : T extends "aliexpress.logistics.ds.trackinginfo.query" ? DS_ShippingAPI_Tracking_Info_Result : unknown;
type AE_AFFILIATE_EXECUTE_FN_RESULT<T extends AFFILIATE_API_NAMES> = T extends "aliexpress.affiliate.productdetail.get" ? Affiliate_Product_Details_Result : T extends "aliexpress.affiliate.product.query" ? Affiliate_Products_Result : T extends "aliexpress.affiliate.hotproduct.query" ? Affiliate_Hotproducts_Result : T extends "aliexpress.affiliate.featuredpromo.products.get" ? Affiliate_Featured_Promo_Products_Result : T extends "aliexpress.affiliate.category.get" ? Affiliate_Categories_Result : unknown;
type AE_EXECUTE_FN_RESULT<T extends AE_API_NAMES> = T extends DS_API_NAMES ? AE_DS_EXECUTE_FN_RESULT<T> : T extends AFFILIATE_API_NAMES ? AE_AFFILIATE_EXECUTE_FN_RESULT<T> : T extends SYSTEM_API_NAMES ? AE_SYSTEM_EXECUTE_FN_RESULT<T> : unknown;
/**

@@ -24,5 +45,6 @@ * Public parameters

app_key: string;
access_token?: string;
timestamp: string;
session: string;
timestamp: number;
sign_method: "hmac" | "md5" | "sha256";
method: AE_API_NAMES;
sign?: string;

@@ -34,7 +56,68 @@ simplify?: boolean;

app_secret: string;
session: string;
url?: string;
format?: AE_Response_Format;
}
interface AE_Error_Response {
msg?: string;
code?: number;
sub_msg?: string;
sub_code?: string;
}
type AE_Response_Format = "xml" | "json";
/**
* SYSTEM SERVICES
* GENERATE SECURITY TOKEN
*/
interface AES_Base_Access_Token_Result {
account_id: string;
seller_id: string;
user_id: string;
sp: string;
access_token: string;
refresh_token: string;
expires_in: number;
expire_time: number;
refresh_token_valid_time: number;
refresh_expires_in: number;
locale: string;
}
interface AES_Access_Token_Result extends AES_Base_Access_Token_Result {
havana_id: string;
user_nick: string;
account: string;
account_platform: string;
}
interface AES_Generate_Security_Token_Params {
code: string;
uuid?: string;
}
interface AES_Generate_Security_Token_Result extends AES_Base_Access_Token_Result {
}
/**
* SYSTEM SERVICES
* GENERATE ACCESS TOKEN
*/
interface AES_Generate_Token_Params extends AES_Generate_Security_Token_Params {
}
interface AES_Generate_Token_Result extends AES_Access_Token_Result {
}
/**
* SYSTEM SERVICES
* REFRESH SECURITY TOKEN
*/
interface AES_Refresh_Security_Token_Params extends AES_Refresh_Token_Params {
}
interface AES_Refresh_Security_Token_Result extends AES_Access_Token_Result {
}
/**
* SYSTEM SERVICES
* REFRESH ACCESS TOKEN
*/
interface AES_Refresh_Token_Params {
refresh_token: string;
}
interface AES_Refresh_Token_Result extends AES_Access_Token_Result {
}
/**
*

@@ -334,2 +417,20 @@ * PRODUCT API

}
interface AE_Product_Item {
logistics_service_name?: string;
order_memo?: string;
product_count: number;
product_id: number;
sku_attr?: string;
}
interface AE_Logistics_Address {
address: string;
city?: string;
contact_person?: string;
country?: string;
full_name?: string;
mobile_no?: string;
phone_country?: string;
province?: string;
zip?: string;
}
interface DS_OrderAPI_Place_Order_Result {

@@ -632,33 +733,13 @@ result: {

type Timestamp = string | number | Date;
interface AENOProductItem {
logistics_service_name?: string;
order_memo?: string;
product_count: number;
product_id: number;
sku_attr?: string;
}
interface AENOLogisticsAddress {
address: string;
city?: string;
contact_person?: string;
country?: string;
full_name?: string;
mobile_no?: string;
phone_country?: string;
province?: string;
zip?: string;
}
declare class AEBaseClient implements AE_Base_Client {
readonly app_key: string;
readonly app_secret: string;
readonly session: string;
readonly url: string;
readonly format: AE_Response_Format;
protected readonly v = "2.0";
protected readonly sign_method = "sha256";
constructor(init: AE_Base_Client);
protected sign(method: AE_API_NAMES, params: any): string;
protected call<T extends PublicParams, K>(method: AE_API_NAMES, params: T): Promise<K | undefined>;
protected get_timestamp(d?: Timestamp): string;
protected sign(params: any): string;
protected call<T extends PublicParams, K>(params: T): Promise<K | undefined>;
protected execute<K extends AE_API_NAMES>(method: K, params: AE_EXECUTE_FN_PARAMS<K>): Promise<AE_EXECUTE_FN_RESULT<K> | undefined>;
}

@@ -668,3 +749,2 @@

constructor(init: AE_Base_Client);
protected execute<K extends AFFILIATE_API_NAMES>(method: K, params: AE_AFFILIATE_EXECUTE_FN_PARAMS<K>): Promise<AE_AFFILIATE_EXECUTE_FN_RESULT<K> | undefined>;
queryProducts(args: Affiliate_Products_Params): Promise<Affiliate_Products_Result | undefined>;

@@ -677,9 +757,12 @@ queryHotProducts(args: Affiliate_Products_Params): Promise<Affiliate_Products_Result | undefined>;

interface IAEDSClientSession extends AE_Base_Client {
session: string;
declare class AESystemClient extends AEBaseClient {
constructor(init: AE_Base_Client);
generateSecurityToken(args: AES_Generate_Security_Token_Params): Promise<AES_Generate_Security_Token_Result | undefined>;
generateToken(args: AES_Generate_Token_Params): Promise<AES_Generate_Token_Result | undefined>;
refreshSecurityToken(args: AES_Refresh_Security_Token_Params): Promise<AES_Refresh_Security_Token_Result | undefined>;
refreshToken(args: AES_Refresh_Token_Params): Promise<AES_Refresh_Token_Result | undefined>;
}
declare class AEDSClient extends AEBaseClient implements IAEDSClientSession {
readonly session: string;
constructor(init: IAEDSClientSession);
protected execute<K extends DS_API_NAMES>(method: K, params: AE_DS_EXECUTE_FN_PARAMS<K>): Promise<AE_DS_EXECUTE_FN_RESULT<K> | undefined>;
declare class AEDSClient extends AESystemClient {
constructor(init: AE_Base_Client);
queryProducts(args: DS_ProductAPI_Recommended_Products_Params): Promise<DS_ProductAPI_Recommended_Products_Result | undefined>;

@@ -690,4 +773,4 @@ productDetails(args: DS_ProductAPI_Product_Params): Promise<DS_ProductAPI_Product_Result | undefined>;

createOrder({ logistics_address, product_items, }: {
logistics_address: AENOLogisticsAddress;
product_items: AENOProductItem[];
logistics_address: AE_Logistics_Address;
product_items: AE_Product_Item[];
}): Promise<DS_OrderAPI_Place_Order_Result | undefined>;

@@ -697,2 +780,2 @@ orderDetails(args: DS_OrderAPI_Get_Order_Params): Promise<DS_OrderAPI_Get_Order_Result | undefined>;

export { AEAffiliateClient, AEDSClient };
export { AEAffiliateClient, AEDSClient, AES_Access_Token_Result, AES_Base_Access_Token_Result, AES_Generate_Security_Token_Params, AES_Generate_Security_Token_Result, AES_Generate_Token_Params, AES_Generate_Token_Result, AES_Refresh_Security_Token_Params, AES_Refresh_Security_Token_Result, AES_Refresh_Token_Params, AES_Refresh_Token_Result, AE_AFFILIATE_EXECUTE_FN_PARAMS, AE_AFFILIATE_EXECUTE_FN_RESULT, AE_AFFILIATE_SERVICE, AE_API_NAMES, AE_Base_Client, AE_DROPSHIPPING_SERVICE, AE_DS_EXECUTE_FN_PARAMS, AE_DS_EXECUTE_FN_RESULT, AE_EXECUTE_FN_METHODS, AE_EXECUTE_FN_PARAMS, AE_EXECUTE_FN_RESULT, AE_Error_Response, AE_Logistics_Address, AE_Platform_Type, AE_Product_Item, AE_Response_Format, AE_SERVICE, AE_SYSTEM_EXECUTE_FN_PARAMS, AE_SYSTEM_EXECUTE_FN_RESULT, AE_SYSTEM_SERVICE, AFFILIATE_API_NAMES, Affiliate_Base_Product_Details, Affiliate_Base_Product_Params, Affiliate_Categories, Affiliate_Categories_Result, Affiliate_Category_Details, Affiliate_Featured_Promo_Product, Affiliate_Featured_Promo_Products_Params, Affiliate_Featured_Promo_Products_Result, Affiliate_Hotproducts, Affiliate_Hotproducts_Params, Affiliate_Hotproducts_Result, Affiliate_Product_Details, Affiliate_Product_Details_Params, Affiliate_Product_Details_Result, Affiliate_Product_Promo_Code_Info, Affiliate_Products, Affiliate_Products_Params, Affiliate_Products_Result, DS_API_NAMES, DS_OrderAPI_Get_Order, DS_OrderAPI_Get_Order_Params, DS_OrderAPI_Get_Order_Result, DS_OrderAPI_Logistics_Info, DS_OrderAPI_Place_Order_Params, DS_OrderAPI_Place_Order_Result, DS_OrderAPI_Price, DS_OrderAPI_Product_Info, DS_OrderAPI_Store_Info, DS_ProductAPI_Product, DS_ProductAPI_Product_Attributes, DS_ProductAPI_Product_Base_Info, DS_ProductAPI_Product_Detail_Params, DS_ProductAPI_Product_Detail_Result, DS_ProductAPI_Product_Details, DS_ProductAPI_Product_Id_Converter, DS_ProductAPI_Product_Multimedia, DS_ProductAPI_Product_Multimedia_Videos, DS_ProductAPI_Product_Package_Info, DS_ProductAPI_Product_Params, DS_ProductAPI_Product_Result, DS_ProductAPI_Product_SKU_Properties, DS_ProductAPI_Product_SKU_Variation, DS_ProductAPI_Product_Shipping_Info, DS_ProductAPI_Product_Store_Info, DS_ProductAPI_Recommended_Product, DS_ProductAPI_Recommended_Products, DS_ProductAPI_Recommended_Products_Params, DS_ProductAPI_Recommended_Products_Result, DS_ProductAPI_Store_Info, DS_ShippingAPI_Freight_Info, DS_ShippingAPI_Shipping_Details, DS_ShippingAPI_Shipping_Info_Params, DS_ShippingAPI_Shipping_Info_Result, DS_ShippingAPI_Tracking_Event, DS_ShippingAPI_Tracking_Info_Params, DS_ShippingAPI_Tracking_Info_Result, PublicParams, SYSTEM_API_NAMES };

@@ -69,3 +69,2 @@ "use strict";

constructor(init) {
this.v = "2.0";
this.sign_method = "sha256";

@@ -75,19 +74,8 @@ var _a, _b;

this.app_secret = init.app_secret;
this.session = init.session;
this.url = (_a = init.url) != null ? _a : "https://api-sg.aliexpress.com/sync";
this.format = (_b = init.format) != null ? _b : "json";
}
// protected sign(params: any): string {
// let sorted = Object.keys(params).sort();
// let basestring = this.app_secret;
// for (let i = 0; i < sorted.length; i++) {
// basestring += sorted[i] + params[sorted[i] as keyof typeof params];
// }
// basestring += this.app_secret;
// return createHash("md5")
// .update(basestring, "utf-8")
// .digest("hex")
// .toUpperCase();
// }
sign(method, params) {
let basestring = method;
sign(params) {
let basestring = "";
let sorted = Object.keys(params).sort();

@@ -97,37 +85,13 @@ for (let i = 0; i < sorted.length; i++) {

}
return (0, import_crypto.createHmac)("sha256", this.app_secret, { encoding: "utf-8" }).update(basestring).digest("hex");
return (0, import_crypto.createHmac)("sha256", this.app_secret, { encoding: "utf-8" }).update(basestring).digest("hex").toUpperCase();
}
// protected async call<T extends PublicParams, K>(params: T) {
// try {
// let basestring = this.url;
// let sorted = Object.keys(params).sort();
// for (let i = 0; i < sorted.length; i++) {
// let symbol = i === 0 ? "?" : "&";
// if (params[sorted[i] as keyof typeof params])
// basestring +=
// symbol +
// sorted[i] +
// "=" +
// encodeURIComponent(
// params[sorted[i] as keyof typeof params] as
// | number
// | string
// | boolean,
// );
// }
// const res = await fetch(basestring, { method: "POST" });
// return (await res.json()) as K;
// } catch (error) {
// console.error(error);
// return;
// }
// }
call(method, params) {
call(params) {
return __async(this, null, function* () {
try {
let basestring = this.url + "?method=" + method;
let basestring = this.url;
let sorted = Object.keys(params).sort();
for (let i = 0; i < sorted.length; i++) {
let symbol = i === 0 ? "?" : "&";
if (params[sorted[i]])
basestring += "&" + sorted[i] + "=" + encodeURIComponent(
basestring += symbol + sorted[i] + "=" + encodeURIComponent(
params[sorted[i]]

@@ -144,50 +108,23 @@ );

}
get_timestamp(d) {
d = d || /* @__PURE__ */ new Date();
if (!(d instanceof Date)) {
d = new Date(d);
}
let dateSep = "-";
let timeSep = ":";
let date = d.getDate();
if (date < 10) {
date = "0" + date;
}
let month = d.getMonth() + 1;
if (month < 10) {
month = "0" + month;
}
let hours = d.getHours();
if (hours < 10) {
hours = "0" + hours;
}
let mintues = d.getMinutes();
if (mintues < 10) {
mintues = "0" + mintues;
}
let seconds = d.getSeconds();
if (seconds < 10) {
seconds = "0" + seconds;
}
return d.getFullYear() + dateSep + month + dateSep + date + " " + hours + timeSep + mintues + timeSep + seconds;
}
};
// src/utils/affiliate_client.ts
var AEAffiliateClient = class extends AEBaseClient {
constructor(init) {
super(init);
}
execute(method, params) {
return __async(this, null, function* () {
const parameters = __spreadProps(__spreadValues({}, params), {
method,
session: this.session,
app_key: this.app_key,
simplify: true,
sign_method: this.sign_method,
timestamp: this.get_timestamp()
timestamp: Date.now()
});
parameters.sign = this.sign(method, parameters);
return yield this.call(method, parameters);
parameters.sign = this.sign(parameters);
return yield this.call(parameters);
});
}
};
// src/utils/affiliate_client.ts
var AEAffiliateClient = class extends AEBaseClient {
constructor(init) {
super(init);
}
queryProducts(args) {

@@ -223,21 +160,34 @@ return __async(this, null, function* () {

// src/utils/ds_client.ts
var AEDSClient = class extends AEBaseClient {
// src/utils/system_client.ts
var AESystemClient = class extends AEBaseClient {
constructor(init) {
super(__spreadValues({}, init));
this.session = init.session;
super(init);
}
execute(method, params) {
generateSecurityToken(args) {
return __async(this, null, function* () {
const parameters = __spreadProps(__spreadValues({}, params), {
app_key: this.app_key,
access_token: this.session,
simplify: true,
sign_method: this.sign_method,
timestamp: Date.now().toString()
});
parameters.sign = this.sign(method, parameters);
return yield this.call(method, parameters);
return yield this.execute("/auth/token/security/create", args);
});
}
generateToken(args) {
return __async(this, null, function* () {
return yield this.execute("/auth/token/create", args);
});
}
refreshSecurityToken(args) {
return __async(this, null, function* () {
return yield this.execute("/auth/token/security/refresh", args);
});
}
refreshToken(args) {
return __async(this, null, function* () {
return yield this.execute("/auth/token/refresh", args);
});
}
};
// src/utils/ds_client.ts
var AEDSClient = class extends AESystemClient {
constructor(init) {
super(init);
}
queryProducts(args) {

@@ -244,0 +194,0 @@ return __async(this, null, function* () {

{
"name": "ae_sdk",
"version": "0.2.0",
"version": "0.3.0",
"description": "A simple SDK for Aliexpress (dropshipping and affiliate) APIs.",

@@ -5,0 +5,0 @@ "private": false,

# AE_SDK
A simple SDK for Aliexpress (dropshipping and affiliate) APIs.
A simple SDK for Aliexpress (system tools, dropshipping and affiliate) APIs.
## Todo
- Update affiliate and ds APIs according to [aliexpress official website](https://open.aliexpress.com/doc/api.htm#/api);
- Add in code documentation using `jsdoc`;
- Add unit tests;
## Installation

@@ -6,0 +12,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc