Update build.zig; use @tagName instead std.meta.tagName
parent
6623561a2e
commit
eeed72622e
22
build.zig
22
build.zig
|
@ -3,14 +3,24 @@ const std = @import("std");
|
||||||
pub fn build(b: *std.build.Builder) void {
|
pub fn build(b: *std.build.Builder) void {
|
||||||
// Standard release options allow the person running `zig build` to select
|
// Standard release options allow the person running `zig build` to select
|
||||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||||
const mode = b.standardReleaseOptions();
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
const lib = b.addStaticLibrary("zig-jwt", "jwt.zig");
|
const target = b.standardTargetOptions(.{});
|
||||||
lib.setBuildMode(mode);
|
_ = b.addModule("jwt", .{
|
||||||
lib.install();
|
.source_file = .{ .path = "jwt.zig" },
|
||||||
|
});
|
||||||
|
|
||||||
var main_tests = b.addTest("jwt.zig");
|
const lib = b.addStaticLibrary(.{
|
||||||
main_tests.setBuildMode(mode);
|
.name = "zig-jwt",
|
||||||
|
.root_source_file = .{ .path = "jwt.zig" },
|
||||||
|
.optimize = optimize,
|
||||||
|
.target = target,
|
||||||
|
});
|
||||||
|
b.installArtifact(lib);
|
||||||
|
|
||||||
|
var main_tests = b.addTest(.{
|
||||||
|
.root_source_file = .{ .path = "jwt.zig" },
|
||||||
|
});
|
||||||
|
|
||||||
const test_step = b.step("test", "Run library tests");
|
const test_step = b.step("test", "Run library tests");
|
||||||
test_step.dependOn(&main_tests.step);
|
test_step.dependOn(&main_tests.step);
|
||||||
|
|
2
jwt.zig
2
jwt.zig
|
@ -46,7 +46,7 @@ pub fn encode(allocator: std.mem.Allocator, comptime alg: Algorithm, payload: an
|
||||||
pub fn encodeMessage(allocator: std.mem.Allocator, comptime alg: Algorithm, message: []const u8, signatureOptions: SignatureOptions) ![]const u8 {
|
pub fn encodeMessage(allocator: std.mem.Allocator, comptime alg: Algorithm, message: []const u8, signatureOptions: SignatureOptions) ![]const u8 {
|
||||||
var protected_header = std.json.ObjectMap.init(allocator);
|
var protected_header = std.json.ObjectMap.init(allocator);
|
||||||
defer protected_header.deinit();
|
defer protected_header.deinit();
|
||||||
try protected_header.put("alg", .{ .string = std.meta.tagName(alg) });
|
try protected_header.put("alg", .{ .string = @tagName(alg) });
|
||||||
try protected_header.put("typ", .{ .string = "JWT" });
|
try protected_header.put("typ", .{ .string = "JWT" });
|
||||||
if (signatureOptions.kid) |kid| {
|
if (signatureOptions.kid) |kid| {
|
||||||
try protected_header.put("kid", .{ .string = kid });
|
try protected_header.put("kid", .{ .string = kid });
|
||||||
|
|
Loading…
Reference in New Issue