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

tiktok-shop

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiktok-shop - npm Package Compare versions

Comparing version 1.0.9 to 1.1.0

10

common/common.js

@@ -93,3 +93,3 @@ const crypto = require('crypto');

}
static signatureByAppSecret(params = {}, path = '', appSecret = '') {
static signatureByAppSecret(params = {}, path = '', appSecret = '', body = {}) {
let input = '';

@@ -105,3 +105,5 @@ let timestamp = this.timestamp();

};
const plainText = appSecret+path+input+appSecret;
input=path+input;
input=input+JSON.stringify(body);
const plainText = appSecret+input+appSecret;
const signature = this.sha256Decoded(plainText, appSecret);

@@ -113,6 +115,6 @@ return {

}
static signByUrl(url = '', appSecret = '') {
static signByUrl(url = '', appSecret = '', body = {}) {
const { path, query } = this.getPathQueryFromUrl(decodeURIComponent(url));
const params = this.parseQueryString(query);
return this.signatureByAppSecret(params, path, appSecret);
return this.signatureByAppSecret(params, path, appSecret, body);
}

@@ -119,0 +121,0 @@ static getPathQueryFromUrl(url = '') {

10

index.js

@@ -60,3 +60,3 @@ const axios = require('axios');

}
function signByUrl(url = '', appSecret = '') {
function signByUrl(url = '', appSecret = '', body = {}) {
const error = Common.checkUrl(url, appSecret);

@@ -66,6 +66,10 @@ if (error) {

}
return Common.signByUrl(url, appSecret);
if (typeof body === "string") {
return Common.signByUrl(url, appSecret, JSON.parse(body));
}
return Common.signByUrl(url, appSecret, body);
}
module.exports = {
signature,
// signature,
authCodeToken,

@@ -72,0 +76,0 @@ generateToken,

{
"name": "tiktok-shop",
"version": "1.0.9",
"version": "1.1.0",
"description": "Generate \"signature\" and \"token\" for Tiktok Shop.",

@@ -5,0 +5,0 @@ "main": "index.js",

[![Tiktok-shop Logo](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWnWWI1yW_T2VRAYVgkByltWqH41X-Qfslgr2qHM3j64VVksDjz9CxzwbQ8M1vYlaB7QIN5pg0BUcxGP05kIcfXSNusvmeCkxVIQYkYyC12bHwuW__r9krtMPXN8yPhaXrcapdhDD70RE5vzjLb26D3d60STB5GFypF3OsNTnYhIrAtowx7eC54qJsrKGk/s1600/Untitled-2.png)](https://github.com/tudinhacoustic/tiktok-shop)
Generate "signature" and "token" for [Tiktok Shop](https://partner.tiktokshop.com/doc).
Ver1.1.0 Announcement:
* Closed "Generate Signature using Config" Function
* Applied "the API request body" in signByUrl. [Quick Access](#generate-signature-using-url)

@@ -18,5 +23,4 @@ [![NPM Version][npm-version-image]][npm-url]

4. [Generate Signature using Url](#generate-signature-using-url)
5. [Generate Signature using Config](#generate-signature-using-config)
6. [Generate Token using Auth Code](#generate-token-using-auth-code)
7. [Generate Token using Refresh Token](#generate-token-using-refresh-token)
5. [Generate Token using Auth Code](#generate-token-using-auth-code)
6. [Generate Token using Refresh Token](#generate-token-using-refresh-token)

@@ -58,3 +62,6 @@ ## Installation

const signature = tiktokShop.signByUrl(url, appSecret);
// You can apply both string or JSON type, for Example
const body = {"order_id":"5766XXX","shipping_service_id":"7208XXX"};
const signature = tiktokShop.signByUrl(url, appSecret, body);
console.info(signature);

@@ -71,28 +78,2 @@ ```

## Generate Signature using Config
```js
const tiktokShop = require('tiktok-shop')
// Extract all query param EXCEPT ' sign ', ' access_token ', You do not need to reorder the params based on alphabetical order.
const config = {
app_key: 'yourAppKey', // Required
app_secret: 'yourAppSecret', // Required
shop_id: 'yourShopId', // Optional
shop_cipher: 'yourShopCipher', // Optional
version: '202306', // Default: 202212
}
// Tiktok API name, more detail: https://partner.tiktokshop.com/dev/api-testing-tool
const path = '/api/orders/search';
const signature = tiktokShop.signature(config, path);
console.info(signature);
```
Response Data
```console
{
signature: '96f15922fbacd220cea0d8370ba7dff2273674f2a2856868b7e32f7d98da0efe',
timestamp: 1697540200
}
```
[Back](#content)
## Generate Token using Auth Code

@@ -99,0 +80,0 @@ ```js

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