@zitadel/node
Version:
Library for API access to ZITADEL. Provides compiled gRPC service clients and helpers for applications and service accounts.
538 lines (537 loc) • 18.5 kB
JavaScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.7.5
// protoc unknown
// source: zitadel/webkey/v2beta/key.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import Long from "long";
import { Timestamp } from "../../../google/protobuf/timestamp.js";
export const protobufPackage = "zitadel.webkey.v2beta";
export var State;
(function (State) {
State[State["STATE_UNSPECIFIED"] = 0] = "STATE_UNSPECIFIED";
/** STATE_INITIAL - A newly created key is in the initial state and published to the public key endpoint. */
State[State["STATE_INITIAL"] = 1] = "STATE_INITIAL";
/** STATE_ACTIVE - The active key is used to sign tokens. Only one key can be active at a time. */
State[State["STATE_ACTIVE"] = 2] = "STATE_ACTIVE";
/** STATE_INACTIVE - The inactive key is not used to sign tokens anymore, but still published to the public key endpoint. */
State[State["STATE_INACTIVE"] = 3] = "STATE_INACTIVE";
/** STATE_REMOVED - The removed key is not used to sign tokens anymore and not published to the public key endpoint. */
State[State["STATE_REMOVED"] = 4] = "STATE_REMOVED";
State[State["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(State || (State = {}));
export function stateFromJSON(object) {
switch (object) {
case 0:
case "STATE_UNSPECIFIED":
return State.STATE_UNSPECIFIED;
case 1:
case "STATE_INITIAL":
return State.STATE_INITIAL;
case 2:
case "STATE_ACTIVE":
return State.STATE_ACTIVE;
case 3:
case "STATE_INACTIVE":
return State.STATE_INACTIVE;
case 4:
case "STATE_REMOVED":
return State.STATE_REMOVED;
case -1:
case "UNRECOGNIZED":
default:
return State.UNRECOGNIZED;
}
}
export function stateToJSON(object) {
switch (object) {
case State.STATE_UNSPECIFIED:
return "STATE_UNSPECIFIED";
case State.STATE_INITIAL:
return "STATE_INITIAL";
case State.STATE_ACTIVE:
return "STATE_ACTIVE";
case State.STATE_INACTIVE:
return "STATE_INACTIVE";
case State.STATE_REMOVED:
return "STATE_REMOVED";
case State.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export var RSABits;
(function (RSABits) {
RSABits[RSABits["RSA_BITS_UNSPECIFIED"] = 0] = "RSA_BITS_UNSPECIFIED";
/** RSA_BITS_2048 - 2048 bit RSA key */
RSABits[RSABits["RSA_BITS_2048"] = 1] = "RSA_BITS_2048";
/** RSA_BITS_3072 - 3072 bit RSA key */
RSABits[RSABits["RSA_BITS_3072"] = 2] = "RSA_BITS_3072";
/** RSA_BITS_4096 - 4096 bit RSA key */
RSABits[RSABits["RSA_BITS_4096"] = 3] = "RSA_BITS_4096";
RSABits[RSABits["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(RSABits || (RSABits = {}));
export function rSABitsFromJSON(object) {
switch (object) {
case 0:
case "RSA_BITS_UNSPECIFIED":
return RSABits.RSA_BITS_UNSPECIFIED;
case 1:
case "RSA_BITS_2048":
return RSABits.RSA_BITS_2048;
case 2:
case "RSA_BITS_3072":
return RSABits.RSA_BITS_3072;
case 3:
case "RSA_BITS_4096":
return RSABits.RSA_BITS_4096;
case -1:
case "UNRECOGNIZED":
default:
return RSABits.UNRECOGNIZED;
}
}
export function rSABitsToJSON(object) {
switch (object) {
case RSABits.RSA_BITS_UNSPECIFIED:
return "RSA_BITS_UNSPECIFIED";
case RSABits.RSA_BITS_2048:
return "RSA_BITS_2048";
case RSABits.RSA_BITS_3072:
return "RSA_BITS_3072";
case RSABits.RSA_BITS_4096:
return "RSA_BITS_4096";
case RSABits.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export var RSAHasher;
(function (RSAHasher) {
RSAHasher[RSAHasher["RSA_HASHER_UNSPECIFIED"] = 0] = "RSA_HASHER_UNSPECIFIED";
/** RSA_HASHER_SHA256 - SHA256 hashing algorithm resulting in the RS256 algorithm header */
RSAHasher[RSAHasher["RSA_HASHER_SHA256"] = 1] = "RSA_HASHER_SHA256";
/** RSA_HASHER_SHA384 - SHA384 hashing algorithm resulting in the RS384 algorithm header */
RSAHasher[RSAHasher["RSA_HASHER_SHA384"] = 2] = "RSA_HASHER_SHA384";
/** RSA_HASHER_SHA512 - SHA512 hashing algorithm resulting in the RS512 algorithm header */
RSAHasher[RSAHasher["RSA_HASHER_SHA512"] = 3] = "RSA_HASHER_SHA512";
RSAHasher[RSAHasher["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(RSAHasher || (RSAHasher = {}));
export function rSAHasherFromJSON(object) {
switch (object) {
case 0:
case "RSA_HASHER_UNSPECIFIED":
return RSAHasher.RSA_HASHER_UNSPECIFIED;
case 1:
case "RSA_HASHER_SHA256":
return RSAHasher.RSA_HASHER_SHA256;
case 2:
case "RSA_HASHER_SHA384":
return RSAHasher.RSA_HASHER_SHA384;
case 3:
case "RSA_HASHER_SHA512":
return RSAHasher.RSA_HASHER_SHA512;
case -1:
case "UNRECOGNIZED":
default:
return RSAHasher.UNRECOGNIZED;
}
}
export function rSAHasherToJSON(object) {
switch (object) {
case RSAHasher.RSA_HASHER_UNSPECIFIED:
return "RSA_HASHER_UNSPECIFIED";
case RSAHasher.RSA_HASHER_SHA256:
return "RSA_HASHER_SHA256";
case RSAHasher.RSA_HASHER_SHA384:
return "RSA_HASHER_SHA384";
case RSAHasher.RSA_HASHER_SHA512:
return "RSA_HASHER_SHA512";
case RSAHasher.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
export var ECDSACurve;
(function (ECDSACurve) {
ECDSACurve[ECDSACurve["ECDSA_CURVE_UNSPECIFIED"] = 0] = "ECDSA_CURVE_UNSPECIFIED";
/** ECDSA_CURVE_P256 - NIST P-256 curve resulting in the ES256 algorithm header */
ECDSACurve[ECDSACurve["ECDSA_CURVE_P256"] = 1] = "ECDSA_CURVE_P256";
/** ECDSA_CURVE_P384 - NIST P-384 curve resulting in the ES384 algorithm header */
ECDSACurve[ECDSACurve["ECDSA_CURVE_P384"] = 2] = "ECDSA_CURVE_P384";
/** ECDSA_CURVE_P512 - NIST P-512 curve resulting in the ES512 algorithm header */
ECDSACurve[ECDSACurve["ECDSA_CURVE_P512"] = 3] = "ECDSA_CURVE_P512";
ECDSACurve[ECDSACurve["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(ECDSACurve || (ECDSACurve = {}));
export function eCDSACurveFromJSON(object) {
switch (object) {
case 0:
case "ECDSA_CURVE_UNSPECIFIED":
return ECDSACurve.ECDSA_CURVE_UNSPECIFIED;
case 1:
case "ECDSA_CURVE_P256":
return ECDSACurve.ECDSA_CURVE_P256;
case 2:
case "ECDSA_CURVE_P384":
return ECDSACurve.ECDSA_CURVE_P384;
case 3:
case "ECDSA_CURVE_P512":
return ECDSACurve.ECDSA_CURVE_P512;
case -1:
case "UNRECOGNIZED":
default:
return ECDSACurve.UNRECOGNIZED;
}
}
export function eCDSACurveToJSON(object) {
switch (object) {
case ECDSACurve.ECDSA_CURVE_UNSPECIFIED:
return "ECDSA_CURVE_UNSPECIFIED";
case ECDSACurve.ECDSA_CURVE_P256:
return "ECDSA_CURVE_P256";
case ECDSACurve.ECDSA_CURVE_P384:
return "ECDSA_CURVE_P384";
case ECDSACurve.ECDSA_CURVE_P512:
return "ECDSA_CURVE_P512";
case ECDSACurve.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
function createBaseWebKey() {
return {
id: "",
creationDate: undefined,
changeDate: undefined,
state: 0,
rsa: undefined,
ecdsa: undefined,
ed25519: undefined,
};
}
export const WebKey = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.creationDate !== undefined) {
Timestamp.encode(toTimestamp(message.creationDate), writer.uint32(18).fork()).join();
}
if (message.changeDate !== undefined) {
Timestamp.encode(toTimestamp(message.changeDate), writer.uint32(26).fork()).join();
}
if (message.state !== 0) {
writer.uint32(32).int32(message.state);
}
if (message.rsa !== undefined) {
RSA.encode(message.rsa, writer.uint32(42).fork()).join();
}
if (message.ecdsa !== undefined) {
ECDSA.encode(message.ecdsa, writer.uint32(50).fork()).join();
}
if (message.ed25519 !== undefined) {
ED25519.encode(message.ed25519, writer.uint32(58).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseWebKey();
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.creationDate = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.changeDate = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
}
case 4: {
if (tag !== 32) {
break;
}
message.state = reader.int32();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.rsa = RSA.decode(reader, reader.uint32());
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.ecdsa = ECDSA.decode(reader, reader.uint32());
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.ed25519 = ED25519.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) : "",
creationDate: isSet(object.creationDate) ? fromJsonTimestamp(object.creationDate) : undefined,
changeDate: isSet(object.changeDate) ? fromJsonTimestamp(object.changeDate) : undefined,
state: isSet(object.state) ? stateFromJSON(object.state) : 0,
rsa: isSet(object.rsa) ? RSA.fromJSON(object.rsa) : undefined,
ecdsa: isSet(object.ecdsa) ? ECDSA.fromJSON(object.ecdsa) : undefined,
ed25519: isSet(object.ed25519) ? ED25519.fromJSON(object.ed25519) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.creationDate !== undefined) {
obj.creationDate = message.creationDate.toISOString();
}
if (message.changeDate !== undefined) {
obj.changeDate = message.changeDate.toISOString();
}
if (message.state !== 0) {
obj.state = stateToJSON(message.state);
}
if (message.rsa !== undefined) {
obj.rsa = RSA.toJSON(message.rsa);
}
if (message.ecdsa !== undefined) {
obj.ecdsa = ECDSA.toJSON(message.ecdsa);
}
if (message.ed25519 !== undefined) {
obj.ed25519 = ED25519.toJSON(message.ed25519);
}
return obj;
},
create(base) {
return WebKey.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseWebKey();
message.id = object.id ?? "";
message.creationDate = object.creationDate ?? undefined;
message.changeDate = object.changeDate ?? undefined;
message.state = object.state ?? 0;
message.rsa = (object.rsa !== undefined && object.rsa !== null) ? RSA.fromPartial(object.rsa) : undefined;
message.ecdsa = (object.ecdsa !== undefined && object.ecdsa !== null) ? ECDSA.fromPartial(object.ecdsa) : undefined;
message.ed25519 = (object.ed25519 !== undefined && object.ed25519 !== null)
? ED25519.fromPartial(object.ed25519)
: undefined;
return message;
},
};
function createBaseRSA() {
return { bits: 0, hasher: 0 };
}
export const RSA = {
encode(message, writer = new BinaryWriter()) {
if (message.bits !== 0) {
writer.uint32(8).int32(message.bits);
}
if (message.hasher !== 0) {
writer.uint32(16).int32(message.hasher);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRSA();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.bits = reader.int32();
continue;
}
case 2: {
if (tag !== 16) {
break;
}
message.hasher = reader.int32();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
bits: isSet(object.bits) ? rSABitsFromJSON(object.bits) : 0,
hasher: isSet(object.hasher) ? rSAHasherFromJSON(object.hasher) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.bits !== 0) {
obj.bits = rSABitsToJSON(message.bits);
}
if (message.hasher !== 0) {
obj.hasher = rSAHasherToJSON(message.hasher);
}
return obj;
},
create(base) {
return RSA.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseRSA();
message.bits = object.bits ?? 0;
message.hasher = object.hasher ?? 0;
return message;
},
};
function createBaseECDSA() {
return { curve: 0 };
}
export const ECDSA = {
encode(message, writer = new BinaryWriter()) {
if (message.curve !== 0) {
writer.uint32(8).int32(message.curve);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseECDSA();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.curve = reader.int32();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return { curve: isSet(object.curve) ? eCDSACurveFromJSON(object.curve) : 0 };
},
toJSON(message) {
const obj = {};
if (message.curve !== 0) {
obj.curve = eCDSACurveToJSON(message.curve);
}
return obj;
},
create(base) {
return ECDSA.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseECDSA();
message.curve = object.curve ?? 0;
return message;
},
};
function createBaseED25519() {
return {};
}
export const ED25519 = {
encode(_, writer = new BinaryWriter()) {
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseED25519();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(_) {
return {};
},
toJSON(_) {
const obj = {};
return obj;
},
create(base) {
return ED25519.fromPartial(base ?? {});
},
fromPartial(_) {
const message = createBaseED25519();
return message;
},
};
function toTimestamp(date) {
const seconds = numberToLong(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.toNumber() || 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.fromJSON(o));
}
}
function numberToLong(number) {
return Long.fromNumber(number);
}
function isSet(value) {
return value !== null && value !== undefined;
}