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 { DwnErrorCode } from '../../src/core/dwn-error.js';
import { ed25519 } from '../../src/jose/algorithms/signing/ed25519.js';
import { expect } from 'chai';
import { DwnInterfaceName, DwnMethodName, KeyDerivationScheme, Records } from '../../src/index.js';
describe('Records', () => {
    if (process.env.TESTSOFF === 'true') {
        return;
    }
    describe('deriveLeafPrivateKey()', () => {
        it('should throw if given private key is not supported', () => __awaiter(void 0, void 0, void 0, function* () {
            const derivedKey = {
                rootKeyId: 'unused',
                derivationScheme: KeyDerivationScheme.ProtocolPath,
                derivedPrivateKey: (yield ed25519.generateKeyPair()).privateJwk
            };
            yield expect(Records.derivePrivateKey(derivedKey, ['a'])).to.be.rejectedWith(DwnErrorCode.RecordsDerivePrivateKeyUnSupportedCurve);
        }));
    });
    describe('constructKeyDerivationPathUsingProtocolPathScheme()', () => {
        it('should throw if given a flat-space descriptor', () => __awaiter(void 0, void 0, void 0, function* () {
            const descriptor = {
                interface: DwnInterfaceName.Records,
                method: DwnMethodName.Write,
                dataCid: 'anyCid',
                dataFormat: 'application/json',
                dataSize: 123,
                dateCreated: '2022-12-19T10:20:30.123456Z',
                messageTimestamp: '2022-12-19T10:20:30.123456Z',
            };
            expect(() => Records.constructKeyDerivationPathUsingProtocolPathScheme(descriptor))
                .to.throw(DwnErrorCode.RecordsProtocolPathDerivationSchemeMissingProtocol);
        }));
    });
    describe('constructKeyDerivationPathUsingProtocolContextScheme()', () => {
        it('should throw if not given contextId', () => __awaiter(void 0, void 0, void 0, function* () {
            expect(() => Records.constructKeyDerivationPathUsingProtocolContextScheme(undefined))
                .to.throw(DwnErrorCode.RecordsProtocolContextDerivationSchemeMissingContextId);
        }));
    });
    describe('constructKeyDerivationPathUsingSchemasScheme()', () => {
        it('should throw if not given schema', () => __awaiter(void 0, void 0, void 0, function* () {
            expect(() => Records.constructKeyDerivationPathUsingSchemasScheme(undefined))
                .to.throw(DwnErrorCode.RecordsSchemasDerivationSchemeMissingSchema);
        }));
    });
});
//# sourceMappingURL=records.spec.js.map