From d058d246b033ab0fdf9b3c41665f4891b9915e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E9=A3=8E?= <15088601208@163.com> Date: Wed, 31 Jul 2024 20:08:45 +0800 Subject: [PATCH] feat: upgrade 1.4.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化签名逻辑,支持中文字符和+号 --- pom.xml | 4 ++-- tuya-api/pom.xml | 2 +- .../open/api/header/TuyaHeaderProcessor.java | 11 ++++++----- tuya-common/pom.xml | 2 +- tuya-messaging/pom.xml | 2 +- tuya-spring-boot-starter/pom.xml | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index f5e7148..7da17b0 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.tuya tuya-connector pom - 1.4.0 + 1.4.3 tuya-api tuya-messaging @@ -17,7 +17,7 @@ 1.8 1.8 - 1.3.6 + 1.4.2 5.7.0 1.18.26 1.2.3 diff --git a/tuya-api/pom.xml b/tuya-api/pom.xml index 65b2cca..e5ab591 100644 --- a/tuya-api/pom.xml +++ b/tuya-api/pom.xml @@ -6,7 +6,7 @@ com.tuya tuya-connector - 1.4.0 + 1.4.3 tuya-api diff --git a/tuya-api/src/main/java/com/tuya/connector/open/api/header/TuyaHeaderProcessor.java b/tuya-api/src/main/java/com/tuya/connector/open/api/header/TuyaHeaderProcessor.java index c09cba3..4243a99 100644 --- a/tuya-api/src/main/java/com/tuya/connector/open/api/header/TuyaHeaderProcessor.java +++ b/tuya-api/src/main/java/com/tuya/connector/open/api/header/TuyaHeaderProcessor.java @@ -107,17 +107,18 @@ private String stringToSign(HttpRequest request, Map headers) { lines.add(bodyHash); lines.add(headerLine); URL url = request.getUrl(); - String paramSortedPath = getPathAndSortParam(url); + String paramSortedPath = getPathAndSortParam(request); lines.add(paramSortedPath); return String.join("\n", lines); } @SneakyThrows - private String getPathAndSortParam(URL url) { + private String getPathAndSortParam(HttpRequest request) { + String originalPath = request.originalPath(); + URL url = request.getUrl(); String query = url.getQuery(); - String path = url.getPath(); if(!StringUtils.hasText(query)){ - return decode(path); + return originalPath; } Map kvMap = new TreeMap<>(); String[] kvs = query.split("\\&"); @@ -129,7 +130,7 @@ private String getPathAndSortParam(URL url) { kvMap.put(kvArr[0],""); } } - return decode(path) + "?" + kvMap.entrySet().stream().map(it->it.getKey()+"="+ encode(it.getValue())) + return originalPath + "?" + kvMap.entrySet().stream().map(it->it.getKey()+"="+ encode(it.getValue())) .collect(Collectors.joining("&")); } diff --git a/tuya-common/pom.xml b/tuya-common/pom.xml index 66a24be..ad97363 100644 --- a/tuya-common/pom.xml +++ b/tuya-common/pom.xml @@ -6,7 +6,7 @@ com.tuya tuya-connector - 1.4.0 + 1.4.3 tuya-common diff --git a/tuya-messaging/pom.xml b/tuya-messaging/pom.xml index e971519..f4765aa 100644 --- a/tuya-messaging/pom.xml +++ b/tuya-messaging/pom.xml @@ -6,7 +6,7 @@ com.tuya tuya-connector - 1.4.0 + 1.4.3 tuya-messaging diff --git a/tuya-spring-boot-starter/pom.xml b/tuya-spring-boot-starter/pom.xml index 7929fb9..140145c 100644 --- a/tuya-spring-boot-starter/pom.xml +++ b/tuya-spring-boot-starter/pom.xml @@ -6,7 +6,7 @@ tuya-connector com.tuya - 1.4.0 + 1.4.3 tuya-spring-boot-starter