diff --git a/docs/openapi.yaml b/docs/openapi.yaml
index 6f95e20..f2c0b35 100644
--- a/docs/openapi.yaml
+++ b/docs/openapi.yaml
@@ -5,7 +5,7 @@ info:
license:
name: MIT
url: https://github.com/tiki/l0-storage/blob/main/LICENSE
- version: 0.0.14
+ version: 0.0.15
servers:
- url: https://storage.l0.mytiki.com
paths:
@@ -23,7 +23,7 @@ paths:
properties:
key:
type: string
- block:
+ content:
type: string
responses:
"201":
diff --git a/pom.xml b/pom.xml
index f61b56b..98c86cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
com.mytiki
l0_storage
- 0.0.14
+ 0.0.15
jar
L0 Storage
diff --git a/src/main/java/com/mytiki/l0_storage/features/latest/token/TokenService.java b/src/main/java/com/mytiki/l0_storage/features/latest/token/TokenService.java
index 61b170e..0a3a18d 100644
--- a/src/main/java/com/mytiki/l0_storage/features/latest/token/TokenService.java
+++ b/src/main/java/com/mytiki/l0_storage/features/latest/token/TokenService.java
@@ -12,7 +12,6 @@
import com.mytiki.l0_storage.utilities.SHAFacade;
import com.mytiki.spring_rest_api.ApiExceptionBuilder;
import com.nimbusds.jose.*;
-import com.nimbusds.jose.util.Base64URL;
import com.nimbusds.jwt.JWTClaimsSet;
import org.bouncycastle.asn1.pkcs.RSAPublicKey;
import org.springframework.http.HttpStatus;
@@ -96,9 +95,15 @@ private void guardForSignature(TokenAOReq req){
private String buildPrefix(String uid, String pubKey) {
try {
- String hashedCustomerId = Base64URL.encode(SHAFacade.sha3_256(uid)).toString();
+ String hashedCustomerId = Base64
+ .getUrlEncoder()
+ .withoutPadding()
+ .encodeToString(SHAFacade.sha3_256(uid));
byte[] pubKeyBytes = Base64.getDecoder().decode(pubKey);
- String hashedPubKey = Base64URL.encode(SHAFacade.sha3_256(pubKeyBytes)).toString();
+ String hashedPubKey = Base64
+ .getUrlEncoder()
+ .withoutPadding()
+ .encodeToString(SHAFacade.sha3_256(pubKeyBytes));
return hashedCustomerId + "/" + hashedPubKey + "/";
} catch (NoSuchAlgorithmException e) {
throw new ApiExceptionBuilder(HttpStatus.EXPECTATION_FAILED)
diff --git a/src/main/java/com/mytiki/l0_storage/main/AppConfig.java b/src/main/java/com/mytiki/l0_storage/main/AppConfig.java
index cee204d..1b6e291 100644
--- a/src/main/java/com/mytiki/l0_storage/main/AppConfig.java
+++ b/src/main/java/com/mytiki/l0_storage/main/AppConfig.java
@@ -89,7 +89,7 @@ public OpenAPI oenAPI(@Value("${springdoc.version}") String appVersion) {
.schema(new JsonSchema()
.type("object")
.addProperty("key", new StringSchema())
- .addProperty("block", new StringSchema())
+ .addProperty("content", new StringSchema())
))))
.responses(new ApiResponses()
.addApiResponse("201",
diff --git a/worker/upload/package.json b/worker/upload/package.json
index 384c159..613f59a 100644
--- a/worker/upload/package.json
+++ b/worker/upload/package.json
@@ -1,6 +1,6 @@
{
"name": "l0-storage-upload",
- "version": "0.0.14",
+ "version": "0.0.15",
"type": "module",
"devDependencies": {
"@babel/core": "^7.20.2",
diff --git a/worker/upload/src/index.js b/worker/upload/src/index.js
index fa8db43..111376d 100644
--- a/worker/upload/src/index.js
+++ b/worker/upload/src/index.js
@@ -13,8 +13,8 @@ export default {
const body = await handleBody(request, env)
await handleAuth(request, env, body)
- const blockBytes = new TextEncoder().encode(atob(body.block))
- const wasabiRsp = await put(env.WASABI_ID, env.WASABI_SECRET, body.key, blockBytes)
+ const contentBytes = new TextEncoder().encode(atob(body.content))
+ const wasabiRsp = await put(env.WASABI_ID, env.WASABI_SECRET, body.key, contentBytes)
if (wasabiRsp.status !== 200) {
return Response.json({
message: 'Bucket upload failed',
@@ -22,7 +22,7 @@ export default {
}, { status: 424 })
}
- const l0Rsp = await report(env.REMOTE_ID, env.REMOTE_SECRET, body.key, blockBytes.length)
+ const l0Rsp = await report(env.REMOTE_ID, env.REMOTE_SECRET, body.key, contentBytes.length)
if (l0Rsp.status !== 204) {
console.log('WARNING. Failed to report usage')
console.log(l0Rsp)
@@ -51,16 +51,16 @@ async function handleBody (request, env) {
} catch (error) {
throw Response.json({ message: 'Malformed body' }, { status: 400 })
}
- if (body.key == null || body.block == null) {
+ if (body.key == null || body.content == null) {
throw Response.json({
message: 'Missing required parameter',
- detail: 'Both key & block are required'
+ detail: 'Both key & content are required'
}, { status: 400 })
}
- if (body.block.length > env.MAX_BYTES) {
+ if (body.content.length > env.MAX_BYTES) {
throw Response.json({
message: 'Request too large',
- detail: 'Max block size is 1MB'
+ detail: 'Max content size is 1MB'
}, { status: 413 })
}
return body