"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RefreshToken = exports.refreshToken_ProtectionLevelToJSON = exports.refreshToken_ProtectionLevelFromJSON = exports.RefreshToken_ProtectionLevel = exports.protobufPackage = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_1 = __importDefault(require("protobufjs/minimal"));
const timestamp_1 = require("../../../../google/protobuf/timestamp");
exports.protobufPackage = 'yandex.cloud.iam.v1';
/** Protection level of the refresh token. */
var RefreshToken_ProtectionLevel;
(function (RefreshToken_ProtectionLevel) {
    RefreshToken_ProtectionLevel[RefreshToken_ProtectionLevel["PROTECTION_LEVEL_UNSPECIFIED"] = 0] = "PROTECTION_LEVEL_UNSPECIFIED";
    /** NO_PROTECTION - Refresh token without DPOP */
    RefreshToken_ProtectionLevel[RefreshToken_ProtectionLevel["NO_PROTECTION"] = 1] = "NO_PROTECTION";
    /** INSECURE_KEY_DPOP - Refresh token with dpop. The dpop key is not a YubiKey PIV key with required pin/touch policy and attestation. */
    RefreshToken_ProtectionLevel[RefreshToken_ProtectionLevel["INSECURE_KEY_DPOP"] = 2] = "INSECURE_KEY_DPOP";
    /** SECURE_KEY_DPOP - Refresh token with dpop. The dpop key is a YubiKey PIV key with required pin/touch policy and attestation. */
    RefreshToken_ProtectionLevel[RefreshToken_ProtectionLevel["SECURE_KEY_DPOP"] = 3] = "SECURE_KEY_DPOP";
    RefreshToken_ProtectionLevel[RefreshToken_ProtectionLevel["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(RefreshToken_ProtectionLevel = exports.RefreshToken_ProtectionLevel || (exports.RefreshToken_ProtectionLevel = {}));
function refreshToken_ProtectionLevelFromJSON(object) {
    switch (object) {
        case 0:
        case 'PROTECTION_LEVEL_UNSPECIFIED':
            return RefreshToken_ProtectionLevel.PROTECTION_LEVEL_UNSPECIFIED;
        case 1:
        case 'NO_PROTECTION':
            return RefreshToken_ProtectionLevel.NO_PROTECTION;
        case 2:
        case 'INSECURE_KEY_DPOP':
            return RefreshToken_ProtectionLevel.INSECURE_KEY_DPOP;
        case 3:
        case 'SECURE_KEY_DPOP':
            return RefreshToken_ProtectionLevel.SECURE_KEY_DPOP;
        case -1:
        case 'UNRECOGNIZED':
        default:
            return RefreshToken_ProtectionLevel.UNRECOGNIZED;
    }
}
exports.refreshToken_ProtectionLevelFromJSON = refreshToken_ProtectionLevelFromJSON;
function refreshToken_ProtectionLevelToJSON(object) {
    switch (object) {
        case RefreshToken_ProtectionLevel.PROTECTION_LEVEL_UNSPECIFIED:
            return 'PROTECTION_LEVEL_UNSPECIFIED';
        case RefreshToken_ProtectionLevel.NO_PROTECTION:
            return 'NO_PROTECTION';
        case RefreshToken_ProtectionLevel.INSECURE_KEY_DPOP:
            return 'INSECURE_KEY_DPOP';
        case RefreshToken_ProtectionLevel.SECURE_KEY_DPOP:
            return 'SECURE_KEY_DPOP';
        default:
            return 'UNKNOWN';
    }
}
exports.refreshToken_ProtectionLevelToJSON = refreshToken_ProtectionLevelToJSON;
const baseRefreshToken = {
    id: '',
    clientInstanceInfo: '',
    clientId: '',
    subjectId: '',
    protectionLevel: 0,
};
exports.RefreshToken = {
    encode(message, writer = minimal_1.default.Writer.create()) {
        if (message.id !== '') {
            writer.uint32(10).string(message.id);
        }
        if (message.clientInstanceInfo !== '') {
            writer.uint32(18).string(message.clientInstanceInfo);
        }
        if (message.clientId !== '') {
            writer.uint32(26).string(message.clientId);
        }
        if (message.subjectId !== '') {
            writer.uint32(34).string(message.subjectId);
        }
        if (message.createdAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(42).fork()).ldelim();
        }
        if (message.expiresAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(50).fork()).ldelim();
        }
        if (message.lastUsedAt !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.lastUsedAt), writer.uint32(58).fork()).ldelim();
        }
        if (message.protectionLevel !== 0) {
            writer.uint32(64).int32(message.protectionLevel);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = Object.assign({}, baseRefreshToken);
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.id = reader.string();
                    break;
                case 2:
                    message.clientInstanceInfo = reader.string();
                    break;
                case 3:
                    message.clientId = reader.string();
                    break;
                case 4:
                    message.subjectId = reader.string();
                    break;
                case 5:
                    message.createdAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 6:
                    message.expiresAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 7:
                    message.lastUsedAt = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    break;
                case 8:
                    message.protectionLevel = reader.int32();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        const message = Object.assign({}, baseRefreshToken);
        message.id = object.id !== undefined && object.id !== null ? String(object.id) : '';
        message.clientInstanceInfo =
            object.clientInstanceInfo !== undefined && object.clientInstanceInfo !== null
                ? String(object.clientInstanceInfo)
                : '';
        message.clientId =
            object.clientId !== undefined && object.clientId !== null
                ? String(object.clientId)
                : '';
        message.subjectId =
            object.subjectId !== undefined && object.subjectId !== null
                ? String(object.subjectId)
                : '';
        message.createdAt =
            object.createdAt !== undefined && object.createdAt !== null
                ? fromJsonTimestamp(object.createdAt)
                : undefined;
        message.expiresAt =
            object.expiresAt !== undefined && object.expiresAt !== null
                ? fromJsonTimestamp(object.expiresAt)
                : undefined;
        message.lastUsedAt =
            object.lastUsedAt !== undefined && object.lastUsedAt !== null
                ? fromJsonTimestamp(object.lastUsedAt)
                : undefined;
        message.protectionLevel =
            object.protectionLevel !== undefined && object.protectionLevel !== null
                ? refreshToken_ProtectionLevelFromJSON(object.protectionLevel)
                : 0;
        return message;
    },
    toJSON(message) {
        const obj = {};
        message.id !== undefined && (obj.id = message.id);
        message.clientInstanceInfo !== undefined &&
            (obj.clientInstanceInfo = message.clientInstanceInfo);
        message.clientId !== undefined && (obj.clientId = message.clientId);
        message.subjectId !== undefined && (obj.subjectId = message.subjectId);
        message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString());
        message.expiresAt !== undefined && (obj.expiresAt = message.expiresAt.toISOString());
        message.lastUsedAt !== undefined && (obj.lastUsedAt = message.lastUsedAt.toISOString());
        message.protectionLevel !== undefined &&
            (obj.protectionLevel = refreshToken_ProtectionLevelToJSON(message.protectionLevel));
        return obj;
    },
    fromPartial(object) {
        var _a, _b, _c, _d, _e, _f, _g, _h;
        const message = Object.assign({}, baseRefreshToken);
        message.id = (_a = object.id) !== null && _a !== void 0 ? _a : '';
        message.clientInstanceInfo = (_b = object.clientInstanceInfo) !== null && _b !== void 0 ? _b : '';
        message.clientId = (_c = object.clientId) !== null && _c !== void 0 ? _c : '';
        message.subjectId = (_d = object.subjectId) !== null && _d !== void 0 ? _d : '';
        message.createdAt = (_e = object.createdAt) !== null && _e !== void 0 ? _e : undefined;
        message.expiresAt = (_f = object.expiresAt) !== null && _f !== void 0 ? _f : undefined;
        message.lastUsedAt = (_g = object.lastUsedAt) !== null && _g !== void 0 ? _g : undefined;
        message.protectionLevel = (_h = object.protectionLevel) !== null && _h !== void 0 ? _h : 0;
        return message;
    },
};
function toTimestamp(date) {
    const seconds = date.getTime() / 1000;
    const nanos = (date.getTime() % 1000) * 1000000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = t.seconds * 1000;
    millis += t.nanos / 1000000;
    return new Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof Date) {
        return o;
    }
    else if (typeof o === 'string') {
        return new Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
if (minimal_1.default.util.Long !== long_1.default) {
    minimal_1.default.util.Long = long_1.default;
    minimal_1.default.configure();
}
