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());
    });
};
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { expect } from 'chai';
import { PermissionsRequest } from '../../src/interfaces/permissions-request.js';
import { Secp256k1 } from '../../src/utils/secp256k1.js';
import { DwnInterfaceName, DwnMethodName } from '../../src/index.js';
chai.use(chaiAsPromised);
describe('PermissionsRequest', () => {
    if (process.env.TESTSOFF === 'true') {
        return;
    }
    describe('create', () => {
        it('creates a PermissionsRequest message', () => __awaiter(void 0, void 0, void 0, function* () {
            const { privateJwk } = yield Secp256k1.generateKeyPair();
            const authorizationSignatureInput = {
                privateJwk,
                protectedHeader: {
                    alg: privateJwk.alg,
                    kid: 'did:key:bob'
                }
            };
            const { message } = yield PermissionsRequest.create({
                description: 'perms',
                grantedBy: 'did:key:bob',
                grantedTo: 'did:key:alice',
                grantedFor: 'did:key:bob',
                scope: { interface: DwnInterfaceName.Records, method: DwnMethodName.Write },
                authorizationSignatureInput
            });
            expect(message.descriptor.grantedTo).to.equal('did:key:alice');
            expect(message.descriptor.grantedBy).to.equal('did:key:bob');
            expect(message.descriptor.scope).to.eql({ interface: DwnInterfaceName.Records, method: DwnMethodName.Write });
            expect(message.descriptor.conditions).to.be.undefined;
            expect(message.descriptor.description).to.eql('perms');
        }));
    });
});
//# sourceMappingURL=permissions-request.spec.js.map