@zitadel/node
Version:
Library for API access to ZITADEL. Provides compiled gRPC service clients and helpers for applications and service accounts.
1,240 lines (1,239 loc) • 40.8 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/webkey_service.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import Long from "long";
import { Timestamp } from "../../../google/protobuf/timestamp.js";
import { ECDSA, ED25519, RSA, WebKey } from "./key.js";
export const protobufPackage = "zitadel.webkey.v2beta";
function createBaseCreateWebKeyRequest() {
return { rsa: undefined, ecdsa: undefined, ed25519: undefined };
}
export const CreateWebKeyRequest = {
encode(message, writer = new BinaryWriter()) {
if (message.rsa !== undefined) {
RSA.encode(message.rsa, writer.uint32(10).fork()).join();
}
if (message.ecdsa !== undefined) {
ECDSA.encode(message.ecdsa, writer.uint32(18).fork()).join();
}
if (message.ed25519 !== undefined) {
ED25519.encode(message.ed25519, writer.uint32(26).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 = createBaseCreateWebKeyRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.rsa = RSA.decode(reader, reader.uint32());
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.ecdsa = ECDSA.decode(reader, reader.uint32());
continue;
}
case 3: {
if (tag !== 26) {
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 {
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.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 CreateWebKeyRequest.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseCreateWebKeyRequest();
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 createBaseCreateWebKeyResponse() {
return { id: "", creationDate: undefined };
}
export const CreateWebKeyResponse = {
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();
}
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 = createBaseCreateWebKeyResponse();
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;
}
}
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,
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.creationDate !== undefined) {
obj.creationDate = message.creationDate.toISOString();
}
return obj;
},
create(base) {
return CreateWebKeyResponse.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseCreateWebKeyResponse();
message.id = object.id ?? "";
message.creationDate = object.creationDate ?? undefined;
return message;
},
};
function createBaseActivateWebKeyRequest() {
return { id: "" };
}
export const ActivateWebKeyRequest = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
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 = createBaseActivateWebKeyRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id = 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) : "" };
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
return obj;
},
create(base) {
return ActivateWebKeyRequest.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseActivateWebKeyRequest();
message.id = object.id ?? "";
return message;
},
};
function createBaseActivateWebKeyResponse() {
return { changeDate: undefined };
}
export const ActivateWebKeyResponse = {
encode(message, writer = new BinaryWriter()) {
if (message.changeDate !== undefined) {
Timestamp.encode(toTimestamp(message.changeDate), writer.uint32(26).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 = createBaseActivateWebKeyResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 3: {
if (tag !== 26) {
break;
}
message.changeDate = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return { changeDate: isSet(object.changeDate) ? fromJsonTimestamp(object.changeDate) : undefined };
},
toJSON(message) {
const obj = {};
if (message.changeDate !== undefined) {
obj.changeDate = message.changeDate.toISOString();
}
return obj;
},
create(base) {
return ActivateWebKeyResponse.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseActivateWebKeyResponse();
message.changeDate = object.changeDate ?? undefined;
return message;
},
};
function createBaseDeleteWebKeyRequest() {
return { id: "" };
}
export const DeleteWebKeyRequest = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
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 = createBaseDeleteWebKeyRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id = 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) : "" };
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
return obj;
},
create(base) {
return DeleteWebKeyRequest.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseDeleteWebKeyRequest();
message.id = object.id ?? "";
return message;
},
};
function createBaseDeleteWebKeyResponse() {
return { deletionDate: undefined };
}
export const DeleteWebKeyResponse = {
encode(message, writer = new BinaryWriter()) {
if (message.deletionDate !== undefined) {
Timestamp.encode(toTimestamp(message.deletionDate), writer.uint32(26).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 = createBaseDeleteWebKeyResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 3: {
if (tag !== 26) {
break;
}
message.deletionDate = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return { deletionDate: isSet(object.deletionDate) ? fromJsonTimestamp(object.deletionDate) : undefined };
},
toJSON(message) {
const obj = {};
if (message.deletionDate !== undefined) {
obj.deletionDate = message.deletionDate.toISOString();
}
return obj;
},
create(base) {
return DeleteWebKeyResponse.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseDeleteWebKeyResponse();
message.deletionDate = object.deletionDate ?? undefined;
return message;
},
};
function createBaseListWebKeysRequest() {
return {};
}
export const ListWebKeysRequest = {
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 = createBaseListWebKeysRequest();
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 ListWebKeysRequest.fromPartial(base ?? {});
},
fromPartial(_) {
const message = createBaseListWebKeysRequest();
return message;
},
};
function createBaseListWebKeysResponse() {
return { webKeys: [] };
}
export const ListWebKeysResponse = {
encode(message, writer = new BinaryWriter()) {
for (const v of message.webKeys) {
WebKey.encode(v, writer.uint32(10).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 = createBaseListWebKeysResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.webKeys.push(WebKey.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
webKeys: globalThis.Array.isArray(object?.webKeys) ? object.webKeys.map((e) => WebKey.fromJSON(e)) : [],
};
},
toJSON(message) {
const obj = {};
if (message.webKeys?.length) {
obj.webKeys = message.webKeys.map((e) => WebKey.toJSON(e));
}
return obj;
},
create(base) {
return ListWebKeysResponse.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseListWebKeysResponse();
message.webKeys = object.webKeys?.map((e) => WebKey.fromPartial(e)) || [];
return message;
},
};
export const WebKeyServiceDefinition = {
name: "WebKeyService",
fullName: "zitadel.webkey.v2beta.WebKeyService",
methods: {
/**
* Create Web Key
*
* Generate a private and public key pair. The private key can be used to sign OIDC tokens after activation.
* The public key can be used to validate OIDC tokens.
* The newly created key will have the state `STATE_INITIAL` and is published to the public key endpoint.
* Note that the JWKs OIDC endpoint returns a cacheable response.
*
* If no key type is provided, a RSA key pair with 2048 bits and SHA256 hashing will be created.
*
* Required permission:
* - `iam.web_key.write`
*
* Required feature flag:
* - `web_key`
*/
createWebKey: {
name: "CreateWebKey",
requestType: CreateWebKeyRequest,
requestStream: false,
responseType: CreateWebKeyResponse,
responseStream: false,
options: {
_unknownFields: {
8338: [
Buffer.from([
93,
74,
38,
10,
3,
50,
48,
48,
18,
31,
10,
29,
87,
101,
98,
32,
107,
101,
121,
32,
99,
114,
101,
97,
116,
101,
100,
32,
115,
117,
99,
99,
101,
115,
115,
102,
117,
108,
108,
121,
46,
74,
51,
10,
3,
52,
48,
48,
18,
44,
10,
42,
84,
104,
101,
32,
102,
101,
97,
116,
117,
114,
101,
32,
102,
108,
97,
103,
32,
96,
119,
101,
98,
95,
107,
101,
121,
96,
32,
105,
115,
32,
110,
111,
116,
32,
101,
110,
97,
98,
108,
101,
100,
46,
]),
],
400010: [
Buffer.from([
21,
10,
19,
10,
17,
105,
97,
109,
46,
119,
101,
98,
95,
107,
101,
121,
46,
119,
114,
105,
116,
101,
]),
],
578365826: [
Buffer.from([
21,
58,
1,
42,
34,
16,
47,
118,
50,
98,
101,
116,
97,
47,
119,
101,
98,
95,
107,
101,
121,
115,
]),
],
},
},
},
/**
* Activate Web Key
*
* Switch the active signing web key. The previously active key will be deactivated.
* Note that the JWKs OIDC endpoint returns a cacheable response.
* Therefore it is not advised to activate a key that has been created within the cache duration (default is 5min),
* as the public key may not have been propagated to caches and clients yet.
*
* Required permission:
* - `iam.web_key.write`
*
* Required feature flag:
* - `web_key`
*/
activateWebKey: {
name: "ActivateWebKey",
requestType: ActivateWebKeyRequest,
requestStream: false,
responseType: ActivateWebKeyResponse,
responseStream: false,
options: {
_unknownFields: {
8338: [
Buffer.from([
143,
1,
74,
40,
10,
3,
50,
48,
48,
18,
33,
10,
31,
87,
101,
98,
32,
107,
101,
121,
32,
97,
99,
116,
105,
118,
97,
116,
101,
100,
32,
115,
117,
99,
99,
101,
115,
115,
102,
117,
108,
108,
121,
46,
74,
51,
10,
3,
52,
48,
48,
18,
44,
10,
42,
84,
104,
101,
32,
102,
101,
97,
116,
117,
114,
101,
32,
102,
108,
97,
103,
32,
96,
119,
101,
98,
95,
107,
101,
121,
96,
32,
105,
115,
32,
110,
111,
116,
32,
101,
110,
97,
98,
108,
101,
100,
46,
74,
46,
10,
3,
52,
48,
52,
18,
39,
10,
37,
84,
104,
101,
32,
119,
101,
98,
32,
107,
101,
121,
32,
116,
111,
32,
97,
99,
116,
105,
118,
101,
32,
100,
111,
101,
115,
32,
110,
111,
116,
32,
101,
120,
105,
115,
116,
46,
]),
],
400010: [
Buffer.from([
21,
10,
19,
10,
17,
105,
97,
109,
46,
119,
101,
98,
95,
107,
101,
121,
46,
119,
114,
105,
116,
101,
]),
],
578365826: [
Buffer.from([
32,
34,
30,
47,
118,
50,
98,
101,
116,
97,
47,
119,
101,
98,
95,
107,
101,
121,
115,
47,
123,
105,
100,
125,
47,
97,
99,
116,
105,
118,
97,
116,
101,
]),
],
},
},
},
/**
* Delete Web Key
*
* Delete a web key pair. Only inactive keys can be deleted. Once a key is deleted,
* any tokens signed by this key will be invalid.
* Note that the JWKs OIDC endpoint returns a cacheable response.
* In case the web key is not found, the request will return a successful response as
* the desired state is already achieved.
* You can check the change date in the response to verify if the web key was deleted during the request.
*
* Required permission:
* - `iam.web_key.delete`
*
* Required feature flag:
* - `web_key`
*/
deleteWebKey: {
name: "DeleteWebKey",
requestType: DeleteWebKeyRequest,
requestStream: false,
responseType: DeleteWebKeyResponse,
responseStream: false,
options: {
_unknownFields: {
8338: [
Buffer.from([
128,
1,
74,
38,
10,
3,
50,
48,
48,
18,
31,
10,
29,
87,
101,
98,
32,
107,
101,
121,
32,
100,
101,
108,
101,
116,
101,
100,
32,
115,
117,
99,
99,
101,
115,
115,
102,
117,
108,
108,
121,
46,
74,
86,
10,
3,
52,
48,
48,
18,
79,
10,
77,
84,
104,
101,
32,
102,
101,
97,
116,
117,
114,
101,
32,
102,
108,
97,
103,
32,
96,
119,
101,
98,
95,
107,
101,
121,
96,
32,
105,
115,
32,
110,
111,
116,
32,
101,
110,
97,
98,
108,
101,
100,
32,
111,
114,
32,
116,
104,
101,
32,
119,
101,
98,
32,
107,
101,
121,
32,
105,
115,
32,
99,
117,
114,
114,
101,
110,
116,
108,
121,
32,
97,
99,
116,
105,
118,
101,
46,
]),
],
400010: [
Buffer.from([
22,
10,
20,
10,
18,
105,
97,
109,
46,
119,
101,
98,
95,
107,
101,
121,
46,
100,
101,
108,
101,
116,
101,
]),
],
578365826: [
Buffer.from([
23,
42,
21,
47,
118,
50,
98,
101,
116,
97,
47,
119,
101,
98,
95,
107,
101,
121,
115,
47,
123,
105,
100,
125,
]),
],
},
},
},
/**
* List Web Keys
*
* List all web keys and their states.
*
* Required permission:
* - `iam.web_key.read`
*
* Required feature flag:
* - `web_key`
*/
listWebKeys: {
name: "ListWebKeys",
requestType: ListWebKeysRequest,
requestStream: false,
responseType: ListWebKeysResponse,
responseStream: false,
options: {
_unknownFields: {
8338: [
Buffer.from([
85,
74,
30,
10,
3,
50,
48,
48,
18,
23,
10,
21,
76,
105,
115,
116,
32,
111,
102,
32,
97,
108,
108,
32,
119,
101,
98,
32,
107,
101,
121,
115,
46,
74,
51,
10,
3,
52,
48,
48,
18,
44,
10,
42,
84,
104,
101,
32,
102,
101,
97,
116,
117,
114,
101,
32,
102,
108,
97,
103,
32,
96,
119,
101,
98,
95,
107,
101,
121,
96,
32,
105,
115,
32,
110,
111,
116,
32,
101,
110,
97,
98,
108,
101,
100,
46,
]),
],
400010: [
Buffer.from([20, 10, 18, 10, 16, 105, 97, 109, 46, 119, 101, 98, 95, 107, 101, 121, 46, 114, 101, 97, 100]),
],
578365826: [
Buffer.from([18, 18, 16, 47, 118, 50, 98, 101, 116, 97, 47, 119, 101, 98, 95, 107, 101, 121, 115]),
],
},
},
},
},
};
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;
}