// Copyright 2024 Adobe. All rights reserved.
// This file is licensed to you under the Apache License,
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
// or the MIT license (http://opensource.org/licenses/MIT),
// at your option.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// Unless required by applicable law or agreed to in writing,
// this software is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
// specific language governing permissions and limitations under
// each license.
import { getNeonBinary } from "./binary.js";
export class LocalSigner {
    constructor(localSigner) {
        this.localSigner = localSigner;
    }
    static newSigner(certificate, privateKey, algorithm, tsaUrl) {
        const signer = getNeonBinary().localSignerNew(certificate, privateKey, algorithm, tsaUrl);
        return new LocalSigner(signer);
    }
    sign(data) {
        return getNeonBinary().localSignerSign.call(this.localSigner, data);
    }
    alg() {
        return getNeonBinary().localSignerAlg.call(this.localSigner);
    }
    certs() {
        return getNeonBinary().localSignerCerts.call(this.localSigner);
    }
    reserveSize() {
        return getNeonBinary().localSignerReserveSize.call(this.localSigner);
    }
    timeAuthorityUrl() {
        return getNeonBinary().localSignerTimeAuthorityUrl.call(this.localSigner);
    }
    getHandle() {
        return this.localSigner;
    }
}
export class CallbackSigner {
    constructor(callbackSigner) {
        this.callbackSigner = callbackSigner;
    }
    getHandle() {
        return this.callbackSigner;
    }
    static newSigner(config, callback) {
        // Convert the config object to a JsBox<CallbackSignerConfig>
        const configBox = getNeonBinary().callbackSignerConfigFromJs(config);
        const signer = getNeonBinary().callbackSignerFromConfig(configBox, callback);
        return new CallbackSigner(signer);
    }
    sign(data) {
        return __awaiter(this, void 0, void 0, function* () {
            return getNeonBinary().callbackSignerSign.call(this.callbackSigner, data);
        });
    }
    alg() {
        return getNeonBinary().callbackSignerAlg.call(this.callbackSigner);
    }
    certs() {
        return getNeonBinary().callbackSignerCerts.call(this.callbackSigner);
    }
    reserveSize() {
        return getNeonBinary().callbackSignerReserveSize.call(this.callbackSigner);
    }
    timeAuthorityUrl() {
        return getNeonBinary().callbackSignerTimeAuthorityUrl.call(this.callbackSigner);
    }
    directCoseHandling() {
        return getNeonBinary().callbackSignerDirectCoseHandling.call(this.callbackSigner);
    }
}
