// 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 IdentityAssertionBuilder {
    constructor(_builder) {
        this._builder = _builder;
    }
    static identityBuilderForCredentialHolder(credentialHolder) {
        return __awaiter(this, void 0, void 0, function* () {
            const builder = getNeonBinary().identityBuilderForCredentialHolder(credentialHolder.getHandle());
            return new IdentityAssertionBuilder(builder);
        });
    }
    addReferencedAssertions(referencedAssertions) {
        getNeonBinary().identityBuilderAddReferencedAssertions.call(this._builder, referencedAssertions);
    }
    addRoles(roles) {
        getNeonBinary().identityBuilderAddRoles.call(this._builder, roles);
    }
    builder() {
        return this._builder;
    }
}
export class IdentityAssertionSigner {
    constructor(_signer) {
        this._signer = _signer;
    }
    static new(signer) {
        const identitySigner = getNeonBinary().identitySignerNew(signer);
        return new IdentityAssertionSigner(identitySigner);
    }
    addIdentityAssertion(identityAssertionBuilder) {
        getNeonBinary().identitySignerAddIdentityAssertion.call(this._signer, identityAssertionBuilder.builder());
    }
    getHandle() {
        return this._signer;
    }
}
export class CallbackCredentialHolder {
    constructor(callbackCredentialHolder) {
        this.callbackCredentialHolder = callbackCredentialHolder;
    }
    getHandle() {
        return this.callbackCredentialHolder;
    }
    static newCallbackCredentialHolder(reserveSize, sigType, callback) {
        const credentialHolder = getNeonBinary().newCallbackCredentialHolder(reserveSize, sigType, callback);
        return new CallbackCredentialHolder(credentialHolder);
    }
    sign(payload) {
        return __awaiter(this, void 0, void 0, function* () {
            return getNeonBinary().callbackSignerSignPayload.call(this.callbackCredentialHolder, payload);
        });
    }
    reserveSize() {
        return getNeonBinary().callbackCredentialHolderReserveSize.call(this.callbackCredentialHolder);
    }
    sigType() {
        return getNeonBinary().callbackCredentialHolderSigType.call(this.callbackCredentialHolder);
    }
}
