mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
WIP
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -111,4 +111,26 @@ export default [
|
||||
},
|
||||
},
|
||||
}),
|
||||
define({
|
||||
name: "Sign",
|
||||
construct: true,
|
||||
finalize: true,
|
||||
JSType: "0b11101110",
|
||||
klass: {
|
||||
sign: {
|
||||
fn: "signOneShot",
|
||||
length: 2,
|
||||
},
|
||||
},
|
||||
proto: {
|
||||
update: {
|
||||
fn: "update",
|
||||
length: 8,
|
||||
},
|
||||
sign: {
|
||||
fn: "finalSign",
|
||||
length: 8,
|
||||
},
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
1922
src/bun.js/api/crypto.zig
Normal file
1922
src/bun.js/api/crypto.zig
Normal file
File diff suppressed because it is too large
Load Diff
68
src/bun.js/api/crypto/sign.zig
Normal file
68
src/bun.js/api/crypto/sign.zig
Normal file
@@ -0,0 +1,68 @@
|
||||
const bun = @import("root").bun;
|
||||
const JSC = bun.JSC;
|
||||
const VirutalMachine = JSC.VirtualMachine;
|
||||
const JSValue = JSC.JSValue;
|
||||
const Async = bun.Async;
|
||||
const JSGlobalObject = JSC.JSGlobalObject;
|
||||
const std = @import("std");
|
||||
const ZigString = bun.JSC.ZigString;
|
||||
const Crypto = @import("../crypto.zig");
|
||||
const BoringSSL = bun.BoringSSL;
|
||||
const EVP = Crypto.EVP;
|
||||
|
||||
pub const Sign = struct {
|
||||
this_value: JSC.JSValue = .zero,
|
||||
ref: Async.KeepAlive = .{},
|
||||
evp: EVP,
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
ref_count: std.atomic.Value(u32) = std.atomic.Value(u32).init(1),
|
||||
|
||||
pub usingnamespace JSC.Codegen.JSSign;
|
||||
pub usingnamespace bun.NewThreadSafeRefCounted(@This(), deinitFn);
|
||||
|
||||
fn deinitFn(this: *Sign) void {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
pub fn signOneShot(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) JSC.JSValue {
|
||||
_ = globalObject;
|
||||
_ = callFrame;
|
||||
return .zero;
|
||||
}
|
||||
|
||||
pub fn constructor(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) ?*Sign {
|
||||
const arguments = callFrame.arguments(2).slice();
|
||||
if (arguments.len < 1 or !arguments[0].isString()) {
|
||||
globalObject.throwNotEnoughArguments("Sign", 1, 0);
|
||||
return null;
|
||||
}
|
||||
const evp = EVP.byName(arguments[0].getZigString(globalObject), globalObject) orelse {
|
||||
return null;
|
||||
};
|
||||
|
||||
return Sign.new(.{
|
||||
.evp = evp,
|
||||
.globalObject = globalObject,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn update(this: *Sign, globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
_ = this; // autofix
|
||||
_ = globalThis; // autofix
|
||||
|
||||
return callframe.this();
|
||||
|
||||
}
|
||||
|
||||
pub fn finalSign(this: *Sign, globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
_ = this; // autofix
|
||||
|
||||
_ = globalThis; // autofix
|
||||
|
||||
return callframe.this();
|
||||
}
|
||||
|
||||
pub fn finalize(this: *Sign) void {
|
||||
this.deref();
|
||||
}
|
||||
};
|
||||
@@ -75,4 +75,5 @@ pub const Classes = struct {
|
||||
pub const PostgresSQLQuery = JSC.Postgres.PostgresSQLQuery;
|
||||
pub const BrotliEncoder = JSC.API.BrotliEncoder;
|
||||
pub const BrotliDecoder = JSC.API.BrotliDecoder;
|
||||
pub const Sign = JSC.API.Crypto.Sign;
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@ pub const C = @import("./bun.js/javascript_core_c_api.zig");
|
||||
pub const WebCore = @import("./bun.js/webcore.zig");
|
||||
pub const BuildMessage = @import("./bun.js/BuildMessage.zig").BuildMessage;
|
||||
pub const ResolveMessage = @import("./bun.js/ResolveMessage.zig").ResolveMessage;
|
||||
|
||||
pub const Cloudflare = struct {
|
||||
pub const HTMLRewriter = @import("./bun.js/api/html_rewriter.zig").HTMLRewriter;
|
||||
pub const ContentOptions = @import("./bun.js/api/html_rewriter.zig").ContentOptions;
|
||||
@@ -51,6 +52,7 @@ pub const API = struct {
|
||||
pub const H2FrameParser = @import("./bun.js/api/bun/h2_frame_parser.zig").H2FrameParser;
|
||||
pub const BrotliEncoder = @import("./bun.js/api/js_brotli.zig").BrotliEncoder;
|
||||
pub const BrotliDecoder = @import("./bun.js/api/js_brotli.zig").BrotliDecoder;
|
||||
pub const Crypto = Bun.Crypto;
|
||||
};
|
||||
pub const Postgres = @import("./sql/postgres.zig");
|
||||
pub const DNS = @import("./bun.js/api/bun/dns_resolver.zig");
|
||||
|
||||
Reference in New Issue
Block a user