Skip to content

Commit 3655089

Browse files
committed
refactor: rename JWTBuilder yield method to build and update file write signatures to include length
1 parent 88c34f0 commit 3655089

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

examples/libjwt.hoshi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use console "console"
55
func main() : int {
66
let token = jwt.JWTBuilder(jwt.HMACSHA256("secret"))
77
.add_claim("name", str.Str("Jerry Chou"))
8-
.yield()
8+
.build()()
99

1010
console.print(token, "\n")
1111

examples/net-http-server.hoshi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func jwt_cookie_set(req: kiana.request.Request, params: hashMap.HashMap<str.Str,
6969
let session = jwt.JWTBuilder(jwt.HMACSHA256("kiana"))
7070
.add_claim("valkeryie", str.Str("Kiana Kaslana"))
7171
.add_claim("host_time", str.Stringable(time.Date.now() + time.Duration.timezone()).to_string())
72-
.yield()
72+
.build()()
7373
let cookie = kiana.cookie.Cookie()
7474
.put("session_token", str.Stringable(session).to_string())
7575
.path("/")

src/jwt.hoshi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct JWTBuilder {
101101
constructor(alg : JWTHashAlgorithm),
102102
add_claim(name : str.Str, value : json.JSONValue) : JWTBuilder,
103103
set_claim(claims: json.JSONDict) : JWTBuilder,
104-
yield() : JWT
104+
build() : JWT
105105
}
106106

107107
impl JWTBuilder {
@@ -123,7 +123,7 @@ impl JWTBuilder {
123123
this.payload[name] = value
124124
return this
125125
},
126-
yield() : JWT {
126+
build() : JWT {
127127
let headers = json.JSONDict().put("typ", this.typ).put("alg", this.alg.algName())
128128
let headers_str = base64.encodeURI(json.JSONValue(headers).to_string())
129129
let payload_str = base64.encodeURI(json.JSONValue(this.payload).to_string())

src/tsuki/pm/management.hoshi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl ProjectLocalPackageManager {
226226
if (f.is_err()) {
227227
return lang.Result<bool, str.Str>.err("Failed to open tsuki.json for writing")
228228
}
229-
f.unwrap().write(manifest_str.data)
229+
f.unwrap().write(manifest_str.data, manifest_str.length)
230230
f.unwrap().close()
231231
return lang.Result<bool, str.Str>.ok(true)
232232
},
@@ -237,7 +237,7 @@ impl ProjectLocalPackageManager {
237237
if (f.is_err()) {
238238
return lang.Result<bool, str.Str>.err("Failed to open build.json for writing")
239239
}
240-
f.unwrap().write(manifest_str.data)
240+
f.unwrap().write(manifest_str.data, manifest_str.length)
241241
f.unwrap().close()
242242
return lang.Result<bool, str.Str>.ok(true)
243243
},

tsuki-server/main.hoshi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func route_login(req: kiana.request.Request, params: hashMap.HashMap<str.Str, st
265265

266266
let session = jwt.JWTBuilder(jwt.HMACSHA256(pcontext.config.secret_key))
267267
.set_claim(types.TsukiJWTClaims(user_id, 0).to_json())
268-
.yield()
268+
.build()
269269

270270
let cookie = kiana.cookie.Cookie()
271271
.put("tsuki_session", str.Stringable(session).to_string())

0 commit comments

Comments
 (0)