@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()!
839 lines • 24.7 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var idp_exports = {};
__export(idp_exports, {
FormData: () => FormData,
FormData_FieldsEntry: () => FormData_FieldsEntry,
IDPInformation: () => IDPInformation,
IDPIntent: () => IDPIntent,
IDPLDAPAccessInformation: () => IDPLDAPAccessInformation,
IDPLink: () => IDPLink,
IDPOAuthAccessInformation: () => IDPOAuthAccessInformation,
IDPSAMLAccessInformation: () => IDPSAMLAccessInformation,
LDAPCredentials: () => LDAPCredentials,
RedirectURLs: () => RedirectURLs,
protobufPackage: () => protobufPackage
});
module.exports = __toCommonJS(idp_exports);
var import_wire = require("@bufbuild/protobuf/wire");
var import_struct = require("../../../google/protobuf/struct.js");
const protobufPackage = "zitadel.user.v2beta";
function createBaseLDAPCredentials() {
return { username: "", password: "" };
}
const LDAPCredentials = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.username !== "") {
writer.uint32(10).string(message.username);
}
if (message.password !== "") {
writer.uint32(18).string(message.password);
}
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 = createBaseLDAPCredentials();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.username = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.password = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
username: isSet(object.username) ? globalThis.String(object.username) : "",
password: isSet(object.password) ? globalThis.String(object.password) : ""
};
},
toJSON(message) {
const obj = {};
if (message.username !== "") {
obj.username = message.username;
}
if (message.password !== "") {
obj.password = message.password;
}
return obj;
},
create(base) {
return LDAPCredentials.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseLDAPCredentials();
message.username = object.username ?? "";
message.password = object.password ?? "";
return message;
}
};
function createBaseRedirectURLs() {
return { successUrl: "", failureUrl: "" };
}
const RedirectURLs = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.successUrl !== "") {
writer.uint32(10).string(message.successUrl);
}
if (message.failureUrl !== "") {
writer.uint32(18).string(message.failureUrl);
}
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 = createBaseRedirectURLs();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.successUrl = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.failureUrl = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
successUrl: isSet(object.successUrl) ? globalThis.String(object.successUrl) : "",
failureUrl: isSet(object.failureUrl) ? globalThis.String(object.failureUrl) : ""
};
},
toJSON(message) {
const obj = {};
if (message.successUrl !== "") {
obj.successUrl = message.successUrl;
}
if (message.failureUrl !== "") {
obj.failureUrl = message.failureUrl;
}
return obj;
},
create(base) {
return RedirectURLs.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseRedirectURLs();
message.successUrl = object.successUrl ?? "";
message.failureUrl = object.failureUrl ?? "";
return message;
}
};
function createBaseIDPIntent() {
return { idpIntentId: "", idpIntentToken: "", userId: "" };
}
const IDPIntent = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.idpIntentId !== "") {
writer.uint32(10).string(message.idpIntentId);
}
if (message.idpIntentToken !== "") {
writer.uint32(18).string(message.idpIntentToken);
}
if (message.userId !== "") {
writer.uint32(26).string(message.userId);
}
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 = createBaseIDPIntent();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.idpIntentId = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.idpIntentToken = reader.string();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.userId = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
idpIntentId: isSet(object.idpIntentId) ? globalThis.String(object.idpIntentId) : "",
idpIntentToken: isSet(object.idpIntentToken) ? globalThis.String(object.idpIntentToken) : "",
userId: isSet(object.userId) ? globalThis.String(object.userId) : ""
};
},
toJSON(message) {
const obj = {};
if (message.idpIntentId !== "") {
obj.idpIntentId = message.idpIntentId;
}
if (message.idpIntentToken !== "") {
obj.idpIntentToken = message.idpIntentToken;
}
if (message.userId !== "") {
obj.userId = message.userId;
}
return obj;
},
create(base) {
return IDPIntent.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseIDPIntent();
message.idpIntentId = object.idpIntentId ?? "";
message.idpIntentToken = object.idpIntentToken ?? "";
message.userId = object.userId ?? "";
return message;
}
};
function createBaseIDPInformation() {
return {
oauth: void 0,
ldap: void 0,
saml: void 0,
idpId: "",
userId: "",
userName: "",
rawInformation: void 0
};
}
const IDPInformation = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.oauth !== void 0) {
IDPOAuthAccessInformation.encode(message.oauth, writer.uint32(10).fork()).join();
}
if (message.ldap !== void 0) {
IDPLDAPAccessInformation.encode(message.ldap, writer.uint32(50).fork()).join();
}
if (message.saml !== void 0) {
IDPSAMLAccessInformation.encode(message.saml, writer.uint32(58).fork()).join();
}
if (message.idpId !== "") {
writer.uint32(18).string(message.idpId);
}
if (message.userId !== "") {
writer.uint32(26).string(message.userId);
}
if (message.userName !== "") {
writer.uint32(34).string(message.userName);
}
if (message.rawInformation !== void 0) {
import_struct.Struct.encode(import_struct.Struct.wrap(message.rawInformation), writer.uint32(42).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 = createBaseIDPInformation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.oauth = IDPOAuthAccessInformation.decode(reader, reader.uint32());
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.ldap = IDPLDAPAccessInformation.decode(reader, reader.uint32());
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.saml = IDPSAMLAccessInformation.decode(reader, reader.uint32());
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.idpId = reader.string();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.userId = reader.string();
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.userName = reader.string();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.rawInformation = import_struct.Struct.unwrap(import_struct.Struct.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
oauth: isSet(object.oauth) ? IDPOAuthAccessInformation.fromJSON(object.oauth) : void 0,
ldap: isSet(object.ldap) ? IDPLDAPAccessInformation.fromJSON(object.ldap) : void 0,
saml: isSet(object.saml) ? IDPSAMLAccessInformation.fromJSON(object.saml) : void 0,
idpId: isSet(object.idpId) ? globalThis.String(object.idpId) : "",
userId: isSet(object.userId) ? globalThis.String(object.userId) : "",
userName: isSet(object.userName) ? globalThis.String(object.userName) : "",
rawInformation: isObject(object.rawInformation) ? object.rawInformation : void 0
};
},
toJSON(message) {
const obj = {};
if (message.oauth !== void 0) {
obj.oauth = IDPOAuthAccessInformation.toJSON(message.oauth);
}
if (message.ldap !== void 0) {
obj.ldap = IDPLDAPAccessInformation.toJSON(message.ldap);
}
if (message.saml !== void 0) {
obj.saml = IDPSAMLAccessInformation.toJSON(message.saml);
}
if (message.idpId !== "") {
obj.idpId = message.idpId;
}
if (message.userId !== "") {
obj.userId = message.userId;
}
if (message.userName !== "") {
obj.userName = message.userName;
}
if (message.rawInformation !== void 0) {
obj.rawInformation = message.rawInformation;
}
return obj;
},
create(base) {
return IDPInformation.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseIDPInformation();
message.oauth = object.oauth !== void 0 && object.oauth !== null ? IDPOAuthAccessInformation.fromPartial(object.oauth) : void 0;
message.ldap = object.ldap !== void 0 && object.ldap !== null ? IDPLDAPAccessInformation.fromPartial(object.ldap) : void 0;
message.saml = object.saml !== void 0 && object.saml !== null ? IDPSAMLAccessInformation.fromPartial(object.saml) : void 0;
message.idpId = object.idpId ?? "";
message.userId = object.userId ?? "";
message.userName = object.userName ?? "";
message.rawInformation = object.rawInformation ?? void 0;
return message;
}
};
function createBaseIDPOAuthAccessInformation() {
return { accessToken: "", idToken: void 0 };
}
const IDPOAuthAccessInformation = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.accessToken !== "") {
writer.uint32(10).string(message.accessToken);
}
if (message.idToken !== void 0) {
writer.uint32(18).string(message.idToken);
}
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 = createBaseIDPOAuthAccessInformation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.accessToken = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.idToken = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
accessToken: isSet(object.accessToken) ? globalThis.String(object.accessToken) : "",
idToken: isSet(object.idToken) ? globalThis.String(object.idToken) : void 0
};
},
toJSON(message) {
const obj = {};
if (message.accessToken !== "") {
obj.accessToken = message.accessToken;
}
if (message.idToken !== void 0) {
obj.idToken = message.idToken;
}
return obj;
},
create(base) {
return IDPOAuthAccessInformation.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseIDPOAuthAccessInformation();
message.accessToken = object.accessToken ?? "";
message.idToken = object.idToken ?? void 0;
return message;
}
};
function createBaseIDPLDAPAccessInformation() {
return { attributes: void 0 };
}
const IDPLDAPAccessInformation = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.attributes !== void 0) {
import_struct.Struct.encode(import_struct.Struct.wrap(message.attributes), writer.uint32(10).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 = createBaseIDPLDAPAccessInformation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.attributes = import_struct.Struct.unwrap(import_struct.Struct.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return { attributes: isObject(object.attributes) ? object.attributes : void 0 };
},
toJSON(message) {
const obj = {};
if (message.attributes !== void 0) {
obj.attributes = message.attributes;
}
return obj;
},
create(base) {
return IDPLDAPAccessInformation.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseIDPLDAPAccessInformation();
message.attributes = object.attributes ?? void 0;
return message;
}
};
function createBaseIDPSAMLAccessInformation() {
return { assertion: Buffer.alloc(0) };
}
const IDPSAMLAccessInformation = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.assertion.length !== 0) {
writer.uint32(10).bytes(message.assertion);
}
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 = createBaseIDPSAMLAccessInformation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.assertion = Buffer.from(reader.bytes());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return { assertion: isSet(object.assertion) ? Buffer.from(bytesFromBase64(object.assertion)) : Buffer.alloc(0) };
},
toJSON(message) {
const obj = {};
if (message.assertion.length !== 0) {
obj.assertion = base64FromBytes(message.assertion);
}
return obj;
},
create(base) {
return IDPSAMLAccessInformation.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseIDPSAMLAccessInformation();
message.assertion = object.assertion ?? Buffer.alloc(0);
return message;
}
};
function createBaseIDPLink() {
return { idpId: "", userId: "", userName: "" };
}
const IDPLink = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.idpId !== "") {
writer.uint32(10).string(message.idpId);
}
if (message.userId !== "") {
writer.uint32(18).string(message.userId);
}
if (message.userName !== "") {
writer.uint32(26).string(message.userName);
}
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 = createBaseIDPLink();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.idpId = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.userId = reader.string();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.userName = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
idpId: isSet(object.idpId) ? globalThis.String(object.idpId) : "",
userId: isSet(object.userId) ? globalThis.String(object.userId) : "",
userName: isSet(object.userName) ? globalThis.String(object.userName) : ""
};
},
toJSON(message) {
const obj = {};
if (message.idpId !== "") {
obj.idpId = message.idpId;
}
if (message.userId !== "") {
obj.userId = message.userId;
}
if (message.userName !== "") {
obj.userName = message.userName;
}
return obj;
},
create(base) {
return IDPLink.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseIDPLink();
message.idpId = object.idpId ?? "";
message.userId = object.userId ?? "";
message.userName = object.userName ?? "";
return message;
}
};
function createBaseFormData() {
return { url: "", fields: {} };
}
const FormData = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.url !== "") {
writer.uint32(10).string(message.url);
}
Object.entries(message.fields).forEach(([key, value]) => {
FormData_FieldsEntry.encode({ key, value }, writer.uint32(18).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 = createBaseFormData();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.url = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
const entry2 = FormData_FieldsEntry.decode(reader, reader.uint32());
if (entry2.value !== void 0) {
message.fields[entry2.key] = entry2.value;
}
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
url: isSet(object.url) ? globalThis.String(object.url) : "",
fields: isObject(object.fields) ? Object.entries(object.fields).reduce((acc, [key, value]) => {
acc[key] = String(value);
return acc;
}, {}) : {}
};
},
toJSON(message) {
const obj = {};
if (message.url !== "") {
obj.url = message.url;
}
if (message.fields) {
const entries = Object.entries(message.fields);
if (entries.length > 0) {
obj.fields = {};
entries.forEach(([k, v]) => {
obj.fields[k] = v;
});
}
}
return obj;
},
create(base) {
return FormData.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseFormData();
message.url = object.url ?? "";
message.fields = Object.entries(object.fields ?? {}).reduce((acc, [key, value]) => {
if (value !== void 0) {
acc[key] = globalThis.String(value);
}
return acc;
}, {});
return message;
}
};
function createBaseFormData_FieldsEntry() {
return { key: "", value: "" };
}
const FormData_FieldsEntry = {
encode(message, writer = new import_wire.BinaryWriter()) {
if (message.key !== "") {
writer.uint32(10).string(message.key);
}
if (message.value !== "") {
writer.uint32(18).string(message.value);
}
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 = createBaseFormData_FieldsEntry();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.key = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.value = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
key: isSet(object.key) ? globalThis.String(object.key) : "",
value: isSet(object.value) ? globalThis.String(object.value) : ""
};
},
toJSON(message) {
const obj = {};
if (message.key !== "") {
obj.key = message.key;
}
if (message.value !== "") {
obj.value = message.value;
}
return obj;
},
create(base) {
return FormData_FieldsEntry.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseFormData_FieldsEntry();
message.key = object.key ?? "";
message.value = object.value ?? "";
return message;
}
};
function bytesFromBase64(b64) {
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
}
function base64FromBytes(arr) {
return globalThis.Buffer.from(arr).toString("base64");
}
function isObject(value) {
return typeof value === "object" && value !== null;
}
function isSet(value) {
return value !== null && value !== void 0;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
FormData,
FormData_FieldsEntry,
IDPInformation,
IDPIntent,
IDPLDAPAccessInformation,
IDPLink,
IDPOAuthAccessInformation,
IDPSAMLAccessInformation,
LDAPCredentials,
RedirectURLs,
protobufPackage
});
//# sourceMappingURL=idp.js.map