"use strict";
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
//   protoc-gen-ts_proto  v2.11.8
//   protoc               v4.25.9
// source: io/restorecommerce/auth.proto
Object.defineProperty(exports, "__esModule", { value: true });
exports.protoMetadata = exports.HierarchicalScopesResponse = exports.HierarchicalScopesRequest = exports.RoleAssociation = exports.HierarchicalScope = exports.Tokens = exports.Subject = exports.protobufPackage = void 0;
/* eslint-disable */
const wire_1 = require("@bufbuild/protobuf/wire");
const timestamp_1 = require("../../google/protobuf/timestamp");
const attribute_1 = require("./attribute");
exports.protobufPackage = "io.restorecommerce.auth";
function createBaseSubject() {
    return {};
}
exports.Subject = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.id !== undefined) {
            writer.uint32(10).string(message.id);
        }
        if (message.scope !== undefined) {
            writer.uint32(18).string(message.scope);
        }
        if (message.unauthenticated !== undefined) {
            writer.uint32(24).bool(message.unauthenticated);
        }
        if (message.token !== undefined) {
            writer.uint32(34).string(message.token);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseSubject();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.scope = reader.string();
                    continue;
                }
                case 3: {
                    if (tag !== 24) {
                        break;
                    }
                    message.unauthenticated = reader.bool();
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.token = reader.string();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : undefined,
            scope: isSet(object.scope) ? globalThis.String(object.scope) : undefined,
            unauthenticated: isSet(object.unauthenticated) ? globalThis.Boolean(object.unauthenticated) : undefined,
            token: isSet(object.token) ? globalThis.String(object.token) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== undefined) {
            obj.id = message.id;
        }
        if (message.scope !== undefined) {
            obj.scope = message.scope;
        }
        if (message.unauthenticated !== undefined) {
            obj.unauthenticated = message.unauthenticated;
        }
        if (message.token !== undefined) {
            obj.token = message.token;
        }
        return obj;
    },
    create(base) {
        return exports.Subject.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseSubject();
        message.id = object.id ?? undefined;
        message.scope = object.scope ?? undefined;
        message.unauthenticated = object.unauthenticated ?? undefined;
        message.token = object.token ?? undefined;
        return message;
    },
};
function createBaseTokens() {
    return {};
}
exports.Tokens = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.name !== undefined) {
            writer.uint32(10).string(message.name);
        }
        if (message.expires_in !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.expires_in), writer.uint32(18).fork()).join();
        }
        if (message.token !== undefined) {
            writer.uint32(26).string(message.token);
        }
        if (message.scopes !== undefined && message.scopes.length !== 0) {
            for (const v of message.scopes) {
                writer.uint32(34).string(v);
            }
        }
        if (message.type !== undefined) {
            writer.uint32(42).string(message.type);
        }
        if (message.interactive !== undefined) {
            writer.uint32(48).bool(message.interactive);
        }
        if (message.last_use !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.last_use), writer.uint32(58).fork()).join();
        }
        if (message.client_id !== undefined) {
            writer.uint32(66).string(message.client_id);
        }
        if (message.impersonated_by !== undefined) {
            writer.uint32(74).string(message.impersonated_by);
        }
        if (message.created_at !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.created_at), writer.uint32(82).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseTokens();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.name = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    message.expires_in = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.token = reader.string();
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    if (message.scopes === undefined) {
                        message.scopes = [];
                    }
                    const el = reader.string();
                    if (el !== undefined) {
                        message.scopes.push(el);
                    }
                    continue;
                }
                case 5: {
                    if (tag !== 42) {
                        break;
                    }
                    message.type = reader.string();
                    continue;
                }
                case 6: {
                    if (tag !== 48) {
                        break;
                    }
                    message.interactive = reader.bool();
                    continue;
                }
                case 7: {
                    if (tag !== 58) {
                        break;
                    }
                    message.last_use = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    continue;
                }
                case 8: {
                    if (tag !== 66) {
                        break;
                    }
                    message.client_id = reader.string();
                    continue;
                }
                case 9: {
                    if (tag !== 74) {
                        break;
                    }
                    message.impersonated_by = reader.string();
                    continue;
                }
                case 10: {
                    if (tag !== 82) {
                        break;
                    }
                    message.created_at = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            name: isSet(object.name) ? globalThis.String(object.name) : undefined,
            expires_in: isSet(object.expiresIn)
                ? fromJsonTimestamp(object.expiresIn)
                : isSet(object.expires_in)
                    ? fromJsonTimestamp(object.expires_in)
                    : undefined,
            token: isSet(object.token) ? globalThis.String(object.token) : undefined,
            scopes: globalThis.Array.isArray(object?.scopes)
                ? object.scopes.map((e) => globalThis.String(e))
                : undefined,
            type: isSet(object.type) ? globalThis.String(object.type) : undefined,
            interactive: isSet(object.interactive) ? globalThis.Boolean(object.interactive) : undefined,
            last_use: isSet(object.lastUse)
                ? fromJsonTimestamp(object.lastUse)
                : isSet(object.last_use)
                    ? fromJsonTimestamp(object.last_use)
                    : undefined,
            client_id: isSet(object.clientId)
                ? globalThis.String(object.clientId)
                : isSet(object.client_id)
                    ? globalThis.String(object.client_id)
                    : undefined,
            impersonated_by: isSet(object.impersonatedBy)
                ? globalThis.String(object.impersonatedBy)
                : isSet(object.impersonated_by)
                    ? globalThis.String(object.impersonated_by)
                    : undefined,
            created_at: isSet(object.createdAt)
                ? fromJsonTimestamp(object.createdAt)
                : isSet(object.created_at)
                    ? fromJsonTimestamp(object.created_at)
                    : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.name !== undefined) {
            obj.name = message.name;
        }
        if (message.expires_in !== undefined) {
            obj.expiresIn = message.expires_in.toISOString();
        }
        if (message.token !== undefined) {
            obj.token = message.token;
        }
        if (message.scopes?.length) {
            obj.scopes = message.scopes;
        }
        if (message.type !== undefined) {
            obj.type = message.type;
        }
        if (message.interactive !== undefined) {
            obj.interactive = message.interactive;
        }
        if (message.last_use !== undefined) {
            obj.lastUse = message.last_use.toISOString();
        }
        if (message.client_id !== undefined) {
            obj.clientId = message.client_id;
        }
        if (message.impersonated_by !== undefined) {
            obj.impersonatedBy = message.impersonated_by;
        }
        if (message.created_at !== undefined) {
            obj.createdAt = message.created_at.toISOString();
        }
        return obj;
    },
    create(base) {
        return exports.Tokens.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseTokens();
        message.name = object.name ?? undefined;
        message.expires_in = object.expires_in ?? undefined;
        message.token = object.token ?? undefined;
        message.scopes = object.scopes?.map((e) => e) || undefined;
        message.type = object.type ?? undefined;
        message.interactive = object.interactive ?? undefined;
        message.last_use = object.last_use ?? undefined;
        message.client_id = object.client_id ?? undefined;
        message.impersonated_by = object.impersonated_by ?? undefined;
        message.created_at = object.created_at ?? undefined;
        return message;
    },
};
function createBaseHierarchicalScope() {
    return {};
}
exports.HierarchicalScope = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.id !== undefined) {
            writer.uint32(10).string(message.id);
        }
        if (message.children !== undefined && message.children.length !== 0) {
            for (const v of message.children) {
                exports.HierarchicalScope.encode(v, writer.uint32(18).fork()).join();
            }
        }
        if (message.role !== undefined) {
            writer.uint32(26).string(message.role);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseHierarchicalScope();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    if (message.children === undefined) {
                        message.children = [];
                    }
                    const el = exports.HierarchicalScope.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.children.push(el);
                    }
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.role = reader.string();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            id: isSet(object.id) ? globalThis.String(object.id) : undefined,
            children: globalThis.Array.isArray(object?.children)
                ? object.children.map((e) => exports.HierarchicalScope.fromJSON(e))
                : undefined,
            role: isSet(object.role) ? globalThis.String(object.role) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.id !== undefined) {
            obj.id = message.id;
        }
        if (message.children?.length) {
            obj.children = message.children.map((e) => exports.HierarchicalScope.toJSON(e));
        }
        if (message.role !== undefined) {
            obj.role = message.role;
        }
        return obj;
    },
    create(base) {
        return exports.HierarchicalScope.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseHierarchicalScope();
        message.id = object.id ?? undefined;
        message.children = object.children?.map((e) => exports.HierarchicalScope.fromPartial(e)) || undefined;
        message.role = object.role ?? undefined;
        return message;
    },
};
function createBaseRoleAssociation() {
    return {};
}
exports.RoleAssociation = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.role !== undefined) {
            writer.uint32(10).string(message.role);
        }
        if (message.attributes !== undefined && message.attributes.length !== 0) {
            for (const v of message.attributes) {
                attribute_1.Attribute.encode(v, writer.uint32(18).fork()).join();
            }
        }
        if (message.id !== undefined) {
            writer.uint32(26).string(message.id);
        }
        if (message.created !== undefined) {
            timestamp_1.Timestamp.encode(toTimestamp(message.created), writer.uint32(34).fork()).join();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseRoleAssociation();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.role = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    if (message.attributes === undefined) {
                        message.attributes = [];
                    }
                    const el = attribute_1.Attribute.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.attributes.push(el);
                    }
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.id = reader.string();
                    continue;
                }
                case 4: {
                    if (tag !== 34) {
                        break;
                    }
                    message.created = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            role: isSet(object.role) ? globalThis.String(object.role) : undefined,
            attributes: globalThis.Array.isArray(object?.attributes)
                ? object.attributes.map((e) => attribute_1.Attribute.fromJSON(e))
                : undefined,
            id: isSet(object.id) ? globalThis.String(object.id) : undefined,
            created: isSet(object.created) ? fromJsonTimestamp(object.created) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.role !== undefined) {
            obj.role = message.role;
        }
        if (message.attributes?.length) {
            obj.attributes = message.attributes.map((e) => attribute_1.Attribute.toJSON(e));
        }
        if (message.id !== undefined) {
            obj.id = message.id;
        }
        if (message.created !== undefined) {
            obj.created = message.created.toISOString();
        }
        return obj;
    },
    create(base) {
        return exports.RoleAssociation.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseRoleAssociation();
        message.role = object.role ?? undefined;
        message.attributes = object.attributes?.map((e) => attribute_1.Attribute.fromPartial(e)) || undefined;
        message.id = object.id ?? undefined;
        message.created = object.created ?? undefined;
        return message;
    },
};
function createBaseHierarchicalScopesRequest() {
    return {};
}
exports.HierarchicalScopesRequest = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.token !== undefined) {
            writer.uint32(10).string(message.token);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseHierarchicalScopesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.token = reader.string();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return { token: isSet(object.token) ? globalThis.String(object.token) : undefined };
    },
    toJSON(message) {
        const obj = {};
        if (message.token !== undefined) {
            obj.token = message.token;
        }
        return obj;
    },
    create(base) {
        return exports.HierarchicalScopesRequest.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseHierarchicalScopesRequest();
        message.token = object.token ?? undefined;
        return message;
    },
};
function createBaseHierarchicalScopesResponse() {
    return {};
}
exports.HierarchicalScopesResponse = {
    encode(message, writer = new wire_1.BinaryWriter()) {
        if (message.subject_id !== undefined) {
            writer.uint32(10).string(message.subject_id);
        }
        if (message.hierarchical_scopes !== undefined && message.hierarchical_scopes.length !== 0) {
            for (const v of message.hierarchical_scopes) {
                exports.HierarchicalScope.encode(v, writer.uint32(18).fork()).join();
            }
        }
        if (message.token !== undefined) {
            writer.uint32(26).string(message.token);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
        const end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseHierarchicalScopesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1: {
                    if (tag !== 10) {
                        break;
                    }
                    message.subject_id = reader.string();
                    continue;
                }
                case 2: {
                    if (tag !== 18) {
                        break;
                    }
                    if (message.hierarchical_scopes === undefined) {
                        message.hierarchical_scopes = [];
                    }
                    const el = exports.HierarchicalScope.decode(reader, reader.uint32());
                    if (el !== undefined) {
                        message.hierarchical_scopes.push(el);
                    }
                    continue;
                }
                case 3: {
                    if (tag !== 26) {
                        break;
                    }
                    message.token = reader.string();
                    continue;
                }
            }
            if ((tag & 7) === 4 || tag === 0) {
                break;
            }
            reader.skip(tag & 7);
        }
        return message;
    },
    fromJSON(object) {
        return {
            subject_id: isSet(object.subjectId)
                ? globalThis.String(object.subjectId)
                : isSet(object.subject_id)
                    ? globalThis.String(object.subject_id)
                    : undefined,
            hierarchical_scopes: globalThis.Array.isArray(object?.hierarchicalScopes)
                ? object.hierarchicalScopes.map((e) => exports.HierarchicalScope.fromJSON(e))
                : globalThis.Array.isArray(object?.hierarchical_scopes)
                    ? object.hierarchical_scopes.map((e) => exports.HierarchicalScope.fromJSON(e))
                    : undefined,
            token: isSet(object.token) ? globalThis.String(object.token) : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        if (message.subject_id !== undefined) {
            obj.subjectId = message.subject_id;
        }
        if (message.hierarchical_scopes?.length) {
            obj.hierarchicalScopes = message.hierarchical_scopes.map((e) => exports.HierarchicalScope.toJSON(e));
        }
        if (message.token !== undefined) {
            obj.token = message.token;
        }
        return obj;
    },
    create(base) {
        return exports.HierarchicalScopesResponse.fromPartial(base ?? {});
    },
    fromPartial(object) {
        const message = createBaseHierarchicalScopesResponse();
        message.subject_id = object.subject_id ?? undefined;
        message.hierarchical_scopes = object.hierarchical_scopes?.map((e) => exports.HierarchicalScope.fromPartial(e)) || undefined;
        message.token = object.token ?? undefined;
        return message;
    },
};
exports.protoMetadata = {
    fileDescriptor: {
        "name": "io/restorecommerce/auth.proto",
        "package": "io.restorecommerce.auth",
        "dependency": ["io/restorecommerce/attribute.proto", "google/protobuf/timestamp.proto"],
        "publicDependency": [],
        "weakDependency": [],
        "optionDependency": [],
        "messageType": [{
                "name": "Subject",
                "field": [{
                        "name": "id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "id",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "scope",
                        "number": 2,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "scope",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "unauthenticated",
                        "number": 3,
                        "label": 1,
                        "type": 8,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "unauthenticated",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "token",
                        "number": 4,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 3,
                        "jsonName": "token",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_id", "options": undefined }, { "name": "_scope", "options": undefined }, {
                        "name": "_unauthenticated",
                        "options": undefined,
                    }, { "name": "_token", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "Tokens",
                "field": [{
                        "name": "name",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "name",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "expires_in",
                        "number": 2,
                        "label": 1,
                        "type": 11,
                        "typeName": ".google.protobuf.Timestamp",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "expiresIn",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "token",
                        "number": 3,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "token",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "scopes",
                        "number": 4,
                        "label": 3,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "scopes",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "type",
                        "number": 5,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 3,
                        "jsonName": "type",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "interactive",
                        "number": 6,
                        "label": 1,
                        "type": 8,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 4,
                        "jsonName": "interactive",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "last_use",
                        "number": 7,
                        "label": 1,
                        "type": 11,
                        "typeName": ".google.protobuf.Timestamp",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 5,
                        "jsonName": "lastUse",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "client_id",
                        "number": 8,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 6,
                        "jsonName": "clientId",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "impersonated_by",
                        "number": 9,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 7,
                        "jsonName": "impersonatedBy",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "created_at",
                        "number": 10,
                        "label": 1,
                        "type": 11,
                        "typeName": ".google.protobuf.Timestamp",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 8,
                        "jsonName": "createdAt",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [
                    { "name": "_name", "options": undefined },
                    { "name": "_expires_in", "options": undefined },
                    { "name": "_token", "options": undefined },
                    { "name": "_type", "options": undefined },
                    { "name": "_interactive", "options": undefined },
                    { "name": "_last_use", "options": undefined },
                    { "name": "_client_id", "options": undefined },
                    { "name": "_impersonated_by", "options": undefined },
                    { "name": "_created_at", "options": undefined },
                ],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "HierarchicalScope",
                "field": [{
                        "name": "id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "id",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "children",
                        "number": 2,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.auth.HierarchicalScope",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "children",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "role",
                        "number": 3,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "role",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_id", "options": undefined }, { "name": "_role", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "RoleAssociation",
                "field": [{
                        "name": "role",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "role",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "attributes",
                        "number": 2,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.attribute.Attribute",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "attributes",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "id",
                        "number": 3,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "id",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "created",
                        "number": 4,
                        "label": 1,
                        "type": 11,
                        "typeName": ".google.protobuf.Timestamp",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 2,
                        "jsonName": "created",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_role", "options": undefined }, { "name": "_id", "options": undefined }, {
                        "name": "_created",
                        "options": undefined,
                    }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "HierarchicalScopesRequest",
                "field": [{
                        "name": "token",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "token",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_token", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }, {
                "name": "HierarchicalScopesResponse",
                "field": [{
                        "name": "subject_id",
                        "number": 1,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "subjectId",
                        "options": undefined,
                        "proto3Optional": true,
                    }, {
                        "name": "hierarchical_scopes",
                        "number": 2,
                        "label": 3,
                        "type": 11,
                        "typeName": ".io.restorecommerce.auth.HierarchicalScope",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 0,
                        "jsonName": "hierarchicalScopes",
                        "options": undefined,
                        "proto3Optional": false,
                    }, {
                        "name": "token",
                        "number": 3,
                        "label": 1,
                        "type": 9,
                        "typeName": "",
                        "extendee": "",
                        "defaultValue": "",
                        "oneofIndex": 1,
                        "jsonName": "token",
                        "options": undefined,
                        "proto3Optional": true,
                    }],
                "extension": [],
                "nestedType": [],
                "enumType": [],
                "extensionRange": [],
                "oneofDecl": [{ "name": "_subject_id", "options": undefined }, { "name": "_token", "options": undefined }],
                "options": undefined,
                "reservedRange": [],
                "reservedName": [],
                "visibility": 0,
            }],
        "enumType": [],
        "service": [],
        "extension": [],
        "options": undefined,
        "sourceCodeInfo": {
            "location": [{
                    "path": [4, 0],
                    "span": [9, 0, 14, 1],
                    "leadingComments": "*\n Subject of creating User\n",
                    "trailingComments": "",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 0],
                    "span": [10, 2, 25],
                    "leadingComments": "",
                    "trailingComments": " user id\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 1],
                    "span": [11, 2, 28],
                    "leadingComments": "",
                    "trailingComments": " target scope (ID of the target scoping entity)\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 0, 2, 2],
                    "span": [12, 2, 36],
                    "leadingComments": "",
                    "trailingComments": " for unauthenticated context\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1, 2, 0],
                    "span": [17, 2, 27],
                    "leadingComments": "",
                    "trailingComments": " token name\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1, 2, 1],
                    "span": [18, 2, 52],
                    "leadingComments": "",
                    "trailingComments": " expiration date for token\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1, 2, 2],
                    "span": [19, 2, 28],
                    "leadingComments": "",
                    "trailingComments": " token\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1, 2, 3],
                    "span": [20, 2, 29],
                    "leadingComments": "",
                    "trailingComments": " identifier for role_association\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1, 2, 4],
                    "span": [21, 2, 27],
                    "leadingComments": "",
                    "trailingComments": " type of token eg: access_token, refresh_token\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 1, 2, 8],
                    "span": [25, 2, 38],
                    "leadingComments": "",
                    "trailingComments": " ID of the impersonator\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 2, 2, 0],
                    "span": [30, 2, 25],
                    "leadingComments": "",
                    "trailingComments": " root node\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 2, 2, 1],
                    "span": [31, 2, 42],
                    "leadingComments": "",
                    "trailingComments": " children nodes\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 2, 2, 2],
                    "span": [32, 2, 27],
                    "leadingComments": "",
                    "trailingComments": " role identifier associated with root node scope\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 3, 2, 0],
                    "span": [36, 2, 27],
                    "leadingComments": "",
                    "trailingComments": " role ID\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 3, 2, 1],
                    "span": [37, 2, 65],
                    "leadingComments": "",
                    "trailingComments": " useful attributes for RBAC/ABAC like organizational scope\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 3, 2, 2],
                    "span": [38, 2, 25],
                    "leadingComments": "",
                    "trailingComments": " identifier for role_association\n",
                    "leadingDetachedComments": [],
                }, {
                    "path": [4, 3, 2, 3],
                    "span": [39, 2, 49],
                    "leadingComments": "",
                    "trailingComments": " timestamp when the role was created\n",
                    "leadingDetachedComments": [],
                }],
        },
        "syntax": "proto3",
        "edition": 0,
    },
    references: {
        ".io.restorecommerce.auth.Subject": exports.Subject,
        ".io.restorecommerce.auth.Tokens": exports.Tokens,
        ".io.restorecommerce.auth.HierarchicalScope": exports.HierarchicalScope,
        ".io.restorecommerce.auth.RoleAssociation": exports.RoleAssociation,
        ".io.restorecommerce.auth.HierarchicalScopesRequest": exports.HierarchicalScopesRequest,
        ".io.restorecommerce.auth.HierarchicalScopesResponse": exports.HierarchicalScopesResponse,
    },
    dependencies: [attribute_1.protoMetadata, timestamp_1.protoMetadata],
};
function toTimestamp(date) {
    const seconds = Math.trunc(date.getTime() / 1_000);
    const nanos = (date.getTime() % 1_000) * 1_000_000;
    return { seconds, nanos };
}
function fromTimestamp(t) {
    let millis = (t.seconds || 0) * 1_000;
    millis += (t.nanos || 0) / 1_000_000;
    return new globalThis.Date(millis);
}
function fromJsonTimestamp(o) {
    if (o instanceof globalThis.Date) {
        return o;
    }
    else if (typeof o === "string") {
        return new globalThis.Date(o);
    }
    else {
        return fromTimestamp(timestamp_1.Timestamp.fromJSON(o));
    }
}
function isSet(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=auth.js.map