UNPKG

@ragnaraven/zitadel-node-dual

Version:

Library for API access to ZITADEL with modern ES import syntax. Works everywhere - NestJS, Node.js, any TypeScript environment. No more require()!

205 lines 6.79 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var auth_n_key_exports = {}; __export(auth_n_key_exports, { Key: () => Key, KeyType: () => KeyType, keyTypeFromJSON: () => keyTypeFromJSON, keyTypeToJSON: () => keyTypeToJSON, protobufPackage: () => protobufPackage }); module.exports = __toCommonJS(auth_n_key_exports); var import_wire = require("@bufbuild/protobuf/wire"); var import_long = __toESM(require("long")); var import_timestamp = require("../google/protobuf/timestamp.js"); var import_object = require("./object.js"); const protobufPackage = "zitadel.authn.v1"; var KeyType = /* @__PURE__ */ ((KeyType2) => { KeyType2[KeyType2["KEY_TYPE_UNSPECIFIED"] = 0] = "KEY_TYPE_UNSPECIFIED"; KeyType2[KeyType2["KEY_TYPE_JSON"] = 1] = "KEY_TYPE_JSON"; KeyType2[KeyType2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED"; return KeyType2; })(KeyType || {}); function keyTypeFromJSON(object) { switch (object) { case 0: case "KEY_TYPE_UNSPECIFIED": return 0 /* KEY_TYPE_UNSPECIFIED */; case 1: case "KEY_TYPE_JSON": return 1 /* KEY_TYPE_JSON */; case -1: case "UNRECOGNIZED": default: return -1 /* UNRECOGNIZED */; } } function keyTypeToJSON(object) { switch (object) { case 0 /* KEY_TYPE_UNSPECIFIED */: return "KEY_TYPE_UNSPECIFIED"; case 1 /* KEY_TYPE_JSON */: return "KEY_TYPE_JSON"; case -1 /* UNRECOGNIZED */: default: return "UNRECOGNIZED"; } } function createBaseKey() { return { id: "", details: void 0, type: 0, expirationDate: void 0 }; } const Key = { encode(message, writer = new import_wire.BinaryWriter()) { if (message.id !== "") { writer.uint32(10).string(message.id); } if (message.details !== void 0) { import_object.ObjectDetails.encode(message.details, writer.uint32(18).fork()).join(); } if (message.type !== 0) { writer.uint32(24).int32(message.type); } if (message.expirationDate !== void 0) { import_timestamp.Timestamp.encode(toTimestamp(message.expirationDate), writer.uint32(34).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof import_wire.BinaryReader ? input : new import_wire.BinaryReader(input); const end = length === void 0 ? reader.len : reader.pos + length; const message = createBaseKey(); 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.details = import_object.ObjectDetails.decode(reader, reader.uint32()); continue; } case 3: { if (tag !== 24) { break; } message.type = reader.int32(); continue; } case 4: { if (tag !== 34) { break; } message.expirationDate = fromTimestamp(import_timestamp.Timestamp.decode(reader, reader.uint32())); 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) : "", details: isSet(object.details) ? import_object.ObjectDetails.fromJSON(object.details) : void 0, type: isSet(object.type) ? keyTypeFromJSON(object.type) : 0, expirationDate: isSet(object.expirationDate) ? fromJsonTimestamp(object.expirationDate) : void 0 }; }, toJSON(message) { const obj = {}; if (message.id !== "") { obj.id = message.id; } if (message.details !== void 0) { obj.details = import_object.ObjectDetails.toJSON(message.details); } if (message.type !== 0) { obj.type = keyTypeToJSON(message.type); } if (message.expirationDate !== void 0) { obj.expirationDate = message.expirationDate.toISOString(); } return obj; }, create(base) { return Key.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseKey(); message.id = object.id ?? ""; message.details = object.details !== void 0 && object.details !== null ? import_object.ObjectDetails.fromPartial(object.details) : void 0; message.type = object.type ?? 0; message.expirationDate = object.expirationDate ?? void 0; return message; } }; function toTimestamp(date) { const seconds = numberToLong(Math.trunc(date.getTime() / 1e3)); const nanos = date.getTime() % 1e3 * 1e6; return { seconds, nanos }; } function fromTimestamp(t) { let millis = (t.seconds.toNumber() || 0) * 1e3; millis += (t.nanos || 0) / 1e6; 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(import_timestamp.Timestamp.fromJSON(o)); } } function numberToLong(number) { return import_long.default.fromNumber(number); } function isSet(value) { return value !== null && value !== void 0; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Key, KeyType, keyTypeFromJSON, keyTypeToJSON, protobufPackage }); //# sourceMappingURL=auth_n_key.js.map