Skip to content

Commit

Permalink
feat: upgrade 1.4.3
Browse files Browse the repository at this point in the history
优化签名逻辑,支持中文字符和+号
  • Loading branch information
yuqiufeng committed Jul 31, 2024
1 parent bea16fe commit d058d24
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.tuya</groupId>
<artifactId>tuya-connector</artifactId>
<packaging>pom</packaging>
<version>1.4.0</version>
<version>1.4.3</version>
<modules>
<module>tuya-api</module>
<module>tuya-messaging</module>
Expand All @@ -17,7 +17,7 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<connector.version>1.3.6</connector.version>
<connector.version>1.4.2</connector.version>
<junit-jupiter.version>5.7.0</junit-jupiter.version>
<lombok.version>1.18.26</lombok.version>
<logback.version>1.2.3</logback.version>
Expand Down
2 changes: 1 addition & 1 deletion tuya-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.tuya</groupId>
<artifactId>tuya-connector</artifactId>
<version>1.4.0</version>
<version>1.4.3</version>
</parent>

<artifactId>tuya-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,18 @@ private String stringToSign(HttpRequest request, Map<String, String> 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<String,String> kvMap = new TreeMap<>();
String[] kvs = query.split("\\&");
Expand All @@ -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("&"));
}

Expand Down
2 changes: 1 addition & 1 deletion tuya-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.tuya</groupId>
<artifactId>tuya-connector</artifactId>
<version>1.4.0</version>
<version>1.4.3</version>
</parent>

<artifactId>tuya-common</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tuya-messaging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.tuya</groupId>
<artifactId>tuya-connector</artifactId>
<version>1.4.0</version>
<version>1.4.3</version>
</parent>

<artifactId>tuya-messaging</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tuya-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>tuya-connector</artifactId>
<groupId>com.tuya</groupId>
<version>1.4.0</version>
<version>1.4.3</version>
</parent>

<artifactId>tuya-spring-boot-starter</artifactId>
Expand Down

0 comments on commit d058d24

Please sign in to comment.