@rockcarver/frodo-cli 5.0.0-21 → 5.0.0-22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6944,6 +6944,139 @@ const helpMetadata = [
6944
6944
  }],
6945
6945
  returns: "{Promise<ReconStatusType>} a promise resolving to a recon status object"
6946
6946
  },
6947
+ {
6948
+ typeName: "RemoteProxy",
6949
+ methodName: "getRemoteProxyBaseUrl",
6950
+ signature: "getRemoteProxyBaseUrl(proxyId: string): string",
6951
+ description: "Get the IDM base URL that routes IDM REST calls through a remote proxy to the receiving tenant: `<host>/openidm/external/idm/<proxyId>`. Every IDM REST call (managed objects, config, ...) addressed below it is made on the receiving tenant by the mapped user of the proxy.",
6952
+ params: [{
6953
+ name: "proxyId",
6954
+ type: "string",
6955
+ description: "id/name of the remote proxy without the type prefix",
6956
+ required: true
6957
+ }],
6958
+ returns: "{string} the IDM base URL of the remote proxy"
6959
+ },
6960
+ {
6961
+ typeName: "RemoteProxy",
6962
+ methodName: "createRemoteProxyExportTemplate",
6963
+ signature: "createRemoteProxyExportTemplate(): RemoteProxyExportInterface",
6964
+ description: "Create an empty remote proxy export template",
6965
+ params: [],
6966
+ returns: "{RemoteProxyExportInterface} an empty remote proxy export template"
6967
+ },
6968
+ {
6969
+ typeName: "RemoteProxy",
6970
+ methodName: "readRemoteProxies",
6971
+ signature: "readRemoteProxies(): Promise<RemoteProxySkeleton[]>",
6972
+ description: "Read all remote proxies",
6973
+ params: [],
6974
+ returns: "{Promise<RemoteProxySkeleton[]>} a promise that resolves to an array of remote proxy objects"
6975
+ },
6976
+ {
6977
+ typeName: "RemoteProxy",
6978
+ methodName: "readRemoteProxy",
6979
+ signature: "readRemoteProxy(proxyId: string): Promise<RemoteProxySkeleton>",
6980
+ description: "Read remote proxy",
6981
+ params: [{
6982
+ name: "proxyId",
6983
+ type: "string",
6984
+ description: "id/name of the remote proxy (the name of the receiving tenant) without the type prefix",
6985
+ required: true
6986
+ }],
6987
+ returns: "{Promise<RemoteProxySkeleton>} a promise that resolves to a remote proxy object"
6988
+ },
6989
+ {
6990
+ typeName: "RemoteProxy",
6991
+ methodName: "exportRemoteProxy",
6992
+ signature: "exportRemoteProxy(proxyId: string): Promise<RemoteProxyExportInterface>",
6993
+ description: "Export remote proxy. The response can be saved to file as is.",
6994
+ params: [{
6995
+ name: "proxyId",
6996
+ type: "string",
6997
+ description: "id/name of the remote proxy without the type prefix",
6998
+ required: true
6999
+ }],
7000
+ returns: "{Promise<RemoteProxyExportInterface>} a promise that resolves to a RemoteProxyExportInterface object"
7001
+ },
7002
+ {
7003
+ typeName: "RemoteProxy",
7004
+ methodName: "exportRemoteProxies",
7005
+ signature: "exportRemoteProxies(): Promise<RemoteProxyExportInterface>",
7006
+ description: "Export all remote proxies. The response can be saved to file as is.",
7007
+ params: [],
7008
+ returns: "{Promise<RemoteProxyExportInterface>} a promise that resolves to a RemoteProxyExportInterface object"
7009
+ },
7010
+ {
7011
+ typeName: "RemoteProxy",
7012
+ methodName: "createRemoteProxy",
7013
+ signature: "createRemoteProxy( proxyId: string, proxyData: RemoteProxySkeleton ): Promise<RemoteProxySkeleton>",
7014
+ description: "Create remote proxy. Fails if it already exists.",
7015
+ params: [{
7016
+ name: "proxyId",
7017
+ type: "string",
7018
+ description: "id/name of the remote proxy without the type prefix",
7019
+ required: true
7020
+ }, {
7021
+ name: "proxyData",
7022
+ type: "RemoteProxySkeleton",
7023
+ description: "remote proxy object",
7024
+ required: true
7025
+ }],
7026
+ returns: "{Promise<RemoteProxySkeleton>} a promise that resolves to a remote proxy object"
7027
+ },
7028
+ {
7029
+ typeName: "RemoteProxy",
7030
+ methodName: "updateRemoteProxy",
7031
+ signature: "updateRemoteProxy( proxyId: string, proxyData: RemoteProxySkeleton ): Promise<RemoteProxySkeleton>",
7032
+ description: "Update or create remote proxy",
7033
+ params: [{
7034
+ name: "proxyId",
7035
+ type: "string",
7036
+ description: "id/name of the remote proxy without the type prefix",
7037
+ required: true
7038
+ }, {
7039
+ name: "proxyData",
7040
+ type: "RemoteProxySkeleton",
7041
+ description: "remote proxy object",
7042
+ required: true
7043
+ }],
7044
+ returns: "{Promise<RemoteProxySkeleton>} a promise that resolves to a remote proxy object"
7045
+ },
7046
+ {
7047
+ typeName: "RemoteProxy",
7048
+ methodName: "importRemoteProxies",
7049
+ signature: "importRemoteProxies( importData: RemoteProxyExportInterface ): Promise<RemoteProxySkeleton[]>",
7050
+ description: "Import remote proxies",
7051
+ params: [{
7052
+ name: "importData",
7053
+ type: "RemoteProxyExportInterface",
7054
+ description: "import data",
7055
+ required: true
7056
+ }],
7057
+ returns: "{Promise<RemoteProxySkeleton[]>} a promise that resolves to an array of remote proxy objects"
7058
+ },
7059
+ {
7060
+ typeName: "RemoteProxy",
7061
+ methodName: "deleteRemoteProxies",
7062
+ signature: "deleteRemoteProxies(): Promise<RemoteProxySkeleton[]>",
7063
+ description: "Delete all remote proxies",
7064
+ params: [],
7065
+ returns: "{Promise<RemoteProxySkeleton[]>} a promise that resolves to an array of the deleted remote proxy objects"
7066
+ },
7067
+ {
7068
+ typeName: "RemoteProxy",
7069
+ methodName: "deleteRemoteProxy",
7070
+ signature: "deleteRemoteProxy(proxyId: string): Promise<RemoteProxySkeleton>",
7071
+ description: "Delete remote proxy",
7072
+ params: [{
7073
+ name: "proxyId",
7074
+ type: "string",
7075
+ description: "id/name of the remote proxy without the type prefix",
7076
+ required: true
7077
+ }],
7078
+ returns: "{Promise<RemoteProxySkeleton>} a promise that resolves to the deleted remote proxy object"
7079
+ },
6947
7080
  {
6948
7081
  typeName: "ResourceType",
6949
7082
  methodName: "readResourceType",
@@ -15596,6 +15729,8 @@ const CAPABILITY_META = {
15596
15729
  notes: "Operates on IDM managed objects (openidm/managed/). Only available in cloud and forgeops deployments. Use these methods as the preferred way to manage realm-qualified identity objects (e.g. alpha_user)."
15597
15730
  },
15598
15731
  "idm.managed.schema": { trustTier: "full-trust" },
15732
+ "idm.remoteProxy.createRemoteProxyExportTemplate": { excluded: true },
15733
+ "idm.remoteProxy.getRemoteProxyBaseUrl": { excluded: true },
15599
15734
  "idm.system": {
15600
15735
  deploymentTypes: IDM_DEPLOYMENTS,
15601
15736
  preferredDeploymentTypes: IDM_DEPLOYMENTS,
@@ -16466,7 +16601,8 @@ const DEFAULT_INSTANCE_HELPERS = /* @__PURE__ */ new Set([
16466
16601
  "createInstanceWithServiceAccount",
16467
16602
  "createInstanceWithAmsterAccount",
16468
16603
  "createInstanceWithBrowserLogin",
16469
- "createInstanceWithAccessToken"
16604
+ "createInstanceWithAccessToken",
16605
+ "createRemoteProxyView"
16470
16606
  ]);
16471
16607
  /**
16472
16608
  * Produces a normalized capability inventory by walking the provided Frodo
@@ -17017,6 +17153,7 @@ const SUBJECT_PROFILE_DEFINITIONS = {
17017
17153
  "config",
17018
17154
  "conn",
17019
17155
  "idm.crypto",
17156
+ "idm.remoteProxy",
17020
17157
  "email",
17021
17158
  "info",
17022
17159
  "rawConfig",
@@ -71723,7 +71860,7 @@ function stringify(obj) {
71723
71860
  return JSON.stringify(obj, replacer, 2);
71724
71861
  }
71725
71862
  var name = "@rockcarver/frodo-lib";
71726
- var version$1 = "5.0.0-19";
71863
+ var version$1 = "5.0.0-20";
71727
71864
  const getUserAgent = () => `${name}/${version$1}`;
71728
71865
  const getPackageVersion = () => `v${version$1} [${process.version}]`;
71729
71866
  const getVersionFromPackage = () => version$1;
@@ -71738,7 +71875,7 @@ const getVersionFromPackage = () => version$1;
71738
71875
  * ts-node) rather than a tsup build, since no bundler ever substitutes the
71739
71876
  * identifier there.
71740
71877
  */
71741
- const getLibBuildTimestamp = () => "2026-11-04T05:47:16.600Z";
71878
+ const getLibBuildTimestamp = () => "2026-11-05T06:01:20.296Z";
71742
71879
  var State_default = (initialState) => {
71743
71880
  const state = {
71744
71881
  ...globalState,
@@ -72269,6 +72406,29 @@ const globalState = {
72269
72406
  };
72270
72407
  const getVerbose = () => globalState.verbose;
72271
72408
  const getDebug = () => globalState.debug || process.env.FRODO_DEBUG !== void 0;
72409
+ /**
72410
+ * Derive a state from another state.
72411
+ *
72412
+ * @remarks
72413
+ *
72414
+ * The derived state answers with the methods in `own` and takes everything else
72415
+ * from `parent`, on every call. A token that the parent refreshes, or loses when
72416
+ * it logs out, is the token the derived state sees, and the parent is not changed
72417
+ * by what `own` does. Use it to give one set of operations a setting of its own,
72418
+ * for example the IDM host, while they share the login of the parent.
72419
+ *
72420
+ * Calling any other setter on the derived state sets it on the parent.
72421
+ *
72422
+ * @param {State} parent state to derive from
72423
+ * @param {Partial<State>} own methods the derived state answers itself
72424
+ * @returns {State} the derived state
72425
+ */
72426
+ function deriveState(parent, own) {
72427
+ return new Proxy(parent, { get(target, property, receiver) {
72428
+ if (Object.prototype.hasOwnProperty.call(own, property)) return own[property];
72429
+ return Reflect.get(target, property, receiver);
72430
+ } });
72431
+ }
72272
72432
  var regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
72273
72433
  function validate(uuid) {
72274
72434
  return typeof uuid === "string" && regex_default.test(uuid);
@@ -122670,6 +122830,7 @@ function filterRecording(recording, useDefaultHost = true, state) {
122670
122830
  recording.response.headers.forEach(obfuscateHeader);
122671
122831
  if (useDefaultHost) for (const header of recording.response.headers) header.value = header.name === "host" ? "openam-frodo-dev.forgeblocks.com" : obfuscateHostsString(header.value, "openam-frodo-dev.forgeblocks.com");
122672
122832
  }
122833
+ if (useDefaultHost && recording.response?.redirectURL) recording.response.redirectURL = obfuscateHostsString(recording.response.redirectURL, "openam-frodo-dev.forgeblocks.com");
122673
122834
  if (recording.response?.content?.text) obfuscateData(recording.response.content);
122674
122835
  }
122675
122836
  function obfuscateHeader(header) {
@@ -133468,12 +133629,14 @@ const getApiConfig$40 = () => ({ apiVersion: apiVersion$37 });
133468
133629
  * @param {AxiosRequestConfig<object>} config request config
133469
133630
  * @param {string} realm realm
133470
133631
  * @param {string} service name of authentication service/journey
133632
+ * @param {boolean} anonymous true to send the request without the session cookie or token the state holds (default: false)
133471
133633
  * @returns Promise resolving to the authentication service response
133472
133634
  */
133473
- async function step({ body = {}, config = {}, realm = "/", service = void 0, state }) {
133635
+ async function step({ body = {}, config = {}, realm = "/", service = void 0, anonymous = false, state }) {
133474
133636
  const urlString = service || state.getAuthenticationService() ? util.default.format(authenticateWithServiceUrlTemplate, state.getHost(), getRealmPath(realm), service || state.getAuthenticationService()) : util.default.format(authenticateUrlTemplate, state.getHost(), getRealmPath(realm));
133475
133637
  const { data } = await generateAmAuthApi({
133476
133638
  resource: getApiConfig$40(),
133639
+ anonymous,
133477
133640
  state
133478
133641
  }).post(urlString, body, config);
133479
133642
  return data;
@@ -138420,9 +138583,11 @@ async function getFreshUserSessionToken({ stepHandler, state }) {
138420
138583
  const response = await step({
138421
138584
  body: currentStep || {},
138422
138585
  config: currentStep ? {} : config,
138586
+ anonymous: true,
138423
138587
  state
138424
138588
  });
138425
138589
  if ("tokenId" in response) {
138590
+ if (typeof response.tokenId !== "string" || response.tokenId === "") throw new FrodoError(`AM completed the authentication but returned an empty session token (tokenId). AM does this when the request already carries a valid session and HttpOnly session cookies are enabled for the realm ('Stops sending tokenId').`);
138426
138591
  const { maxIdleExpirationTime, maxSessionExpirationTime } = await getSessionInfo({
138427
138592
  tokenId: response.tokenId,
138428
138593
  state
@@ -139111,7 +139276,15 @@ function scheduleAutoRefresh(forceLoginAsUser, credentialOverride, autoRefresh,
139111
139276
  clearTimeout(timer);
139112
139277
  }
139113
139278
  if (autoRefresh) {
139114
- let timeout = (state.getDeploymentType() === Constants_default.CLASSIC_DEPLOYMENT_TYPE_KEY ? state.getUserSessionTokenMeta()?.expires : state.getUseBearerTokenForAmApis() ? state.getBearerTokenMeta()?.expires : Math.min(state.getBearerTokenMeta()?.expires, state.getUserSessionTokenMeta()?.expires)) - Date.now() - 25e3;
139279
+ const known = (state.getDeploymentType() === Constants_default.CLASSIC_DEPLOYMENT_TYPE_KEY ? [state.getUserSessionTokenMeta()?.expires] : state.getUseBearerTokenForAmApis() ? [state.getBearerTokenMeta()?.expires] : [state.getBearerTokenMeta()?.expires, state.getUserSessionTokenMeta()?.expires]).filter((e) => Number.isFinite(e));
139280
+ if (known.length === 0) {
139281
+ debugMessage$1({
139282
+ message: `AuthenticateOps.scheduleAutoRefresh: no known token expiry, not setting a timer`,
139283
+ state
139284
+ });
139285
+ return;
139286
+ }
139287
+ let timeout = Math.min(...known) - Date.now() - 25e3;
139115
139288
  if (timeout < 3e4) {
139116
139289
  debugMessage$1({
139117
139290
  message: `Timeout below threshold of 30 seconds (${Math.ceil(timeout / 1e3)}), resetting timeout to 10ms.`,
@@ -175412,6 +175585,340 @@ async function cancelRecon({ reconId, state }) {
175412
175585
  state
175413
175586
  });
175414
175587
  }
175588
+ var RemoteProxyOps_default = (state) => {
175589
+ return {
175590
+ REMOTE_PROXY_TYPE,
175591
+ getRemoteProxyBaseUrl(proxyId) {
175592
+ return getRemoteProxyBaseUrl({
175593
+ proxyId,
175594
+ state
175595
+ });
175596
+ },
175597
+ createRemoteProxyExportTemplate() {
175598
+ return createRemoteProxyExportTemplate({ state });
175599
+ },
175600
+ async readRemoteProxies() {
175601
+ return readRemoteProxies({ state });
175602
+ },
175603
+ async readRemoteProxy(proxyId) {
175604
+ return readRemoteProxy({
175605
+ proxyId,
175606
+ state
175607
+ });
175608
+ },
175609
+ async exportRemoteProxy(proxyId) {
175610
+ return exportRemoteProxy({
175611
+ proxyId,
175612
+ state
175613
+ });
175614
+ },
175615
+ async exportRemoteProxies() {
175616
+ return exportRemoteProxies({ state });
175617
+ },
175618
+ async createRemoteProxy(proxyId, proxyData) {
175619
+ return createRemoteProxy({
175620
+ proxyId,
175621
+ proxyData,
175622
+ state
175623
+ });
175624
+ },
175625
+ async updateRemoteProxy(proxyId, proxyData) {
175626
+ return updateRemoteProxy({
175627
+ proxyId,
175628
+ proxyData,
175629
+ state
175630
+ });
175631
+ },
175632
+ async importRemoteProxies(importData) {
175633
+ return importRemoteProxies({
175634
+ importData,
175635
+ state
175636
+ });
175637
+ },
175638
+ async deleteRemoteProxies() {
175639
+ return deleteRemoteProxies({ state });
175640
+ },
175641
+ async deleteRemoteProxy(proxyId) {
175642
+ return deleteRemoteProxy({
175643
+ proxyId,
175644
+ state
175645
+ });
175646
+ }
175647
+ };
175648
+ };
175649
+ /**
175650
+ * Remote proxy type key used to build the IDM id: 'external.idm/<id>'
175651
+ */
175652
+ const REMOTE_PROXY_TYPE = "external.idm";
175653
+ /**
175654
+ * Properties each authentication type needs
175655
+ */
175656
+ const REQUIRED_PROPERTIES = {
175657
+ basic: ["userName", "password"],
175658
+ bearer: [
175659
+ "clientId",
175660
+ "clientSecret",
175661
+ "tokenEndpoint"
175662
+ ]
175663
+ };
175664
+ /**
175665
+ * Check a remote proxy before it is sent to the tenant
175666
+ * @param {string} proxyId id/name of the remote proxy without the type prefix
175667
+ * @param {RemoteProxySkeleton} proxyData remote proxy object
175668
+ */
175669
+ function validateRemoteProxy(proxyId, proxyData) {
175670
+ const authType = proxyData?.authType;
175671
+ if (!Object.keys(REQUIRED_PROPERTIES).includes(authType)) throw new FrodoError(`Remote proxy ${proxyId} has authType '${authType}'; expected 'basic' or 'bearer'`);
175672
+ if (typeof proxyData.instanceUrl !== "string" || !proxyData.instanceUrl.endsWith("/")) throw new FrodoError(`Remote proxy ${proxyId} needs an instanceUrl that ends with a trailing slash`);
175673
+ const missing = REQUIRED_PROPERTIES[authType].filter((property) => !proxyData[property]);
175674
+ if (missing.length > 0) throw new FrodoError(`Remote proxy ${proxyId} with authType '${authType}' is missing ${missing.join(", ")}`);
175675
+ }
175676
+ /**
175677
+ * Get the IDM base URL that routes IDM REST calls through a remote proxy to
175678
+ * the receiving tenant: `<host>/openidm/external/idm/<proxyId>`.
175679
+ * @param {string} proxyId id/name of the remote proxy without the type prefix
175680
+ * @returns {string} the IDM base URL of the remote proxy
175681
+ */
175682
+ function getRemoteProxyBaseUrl({ proxyId, state }) {
175683
+ return `${getHostOnlyUrl(state.getHost())}/openidm/external/idm/${proxyId}`;
175684
+ }
175685
+ function createRemoteProxyExportTemplate({ state }) {
175686
+ return {
175687
+ meta: getMetadata({ state }),
175688
+ remoteProxy: {}
175689
+ };
175690
+ }
175691
+ /**
175692
+ * Read all remote proxies
175693
+ * @returns {Promise<RemoteProxySkeleton[]>} a promise that resolves to an array of remote proxy objects
175694
+ */
175695
+ async function readRemoteProxies({ state }) {
175696
+ try {
175697
+ return await readConfigEntitiesByType({
175698
+ type: `${REMOTE_PROXY_TYPE}/`,
175699
+ state
175700
+ });
175701
+ } catch (error) {
175702
+ throw new FrodoError(`Error reading remote proxies`, error);
175703
+ }
175704
+ }
175705
+ /**
175706
+ * Read remote proxy
175707
+ * @param {string} proxyId id/name of the remote proxy without the type prefix
175708
+ * @returns {Promise<RemoteProxySkeleton>} a promise that resolves to a remote proxy object
175709
+ */
175710
+ async function readRemoteProxy({ proxyId, state }) {
175711
+ try {
175712
+ return await getConfigEntity$1({
175713
+ entityId: `${REMOTE_PROXY_TYPE}/${proxyId}`,
175714
+ state
175715
+ });
175716
+ } catch (error) {
175717
+ throw new FrodoError(`Error reading remote proxy ${proxyId}`, error);
175718
+ }
175719
+ }
175720
+ /**
175721
+ * Export remote proxy. The response can be saved to file as is.
175722
+ * @param {string} proxyId id/name of the remote proxy without the type prefix
175723
+ * @returns {Promise<RemoteProxyExportInterface>} a promise that resolves to a RemoteProxyExportInterface object
175724
+ */
175725
+ async function exportRemoteProxy({ proxyId, state }) {
175726
+ try {
175727
+ debugMessage$1({
175728
+ message: `RemoteProxyOps.exportRemoteProxy: start [proxyId=${proxyId}]`,
175729
+ state
175730
+ });
175731
+ const exportData = createRemoteProxyExportTemplate({ state });
175732
+ exportData.remoteProxy[proxyId] = await readRemoteProxy({
175733
+ proxyId,
175734
+ state
175735
+ });
175736
+ debugMessage$1({
175737
+ message: `RemoteProxyOps.exportRemoteProxy: end`,
175738
+ state
175739
+ });
175740
+ return exportData;
175741
+ } catch (error) {
175742
+ throw new FrodoError(`Error exporting remote proxy ${proxyId}`, error);
175743
+ }
175744
+ }
175745
+ /**
175746
+ * Export all remote proxies. The response can be saved to file as is.
175747
+ * @returns {Promise<RemoteProxyExportInterface>} a promise that resolves to a RemoteProxyExportInterface object
175748
+ */
175749
+ async function exportRemoteProxies({ state }) {
175750
+ try {
175751
+ debugMessage$1({
175752
+ message: `RemoteProxyOps.exportRemoteProxies: start`,
175753
+ state
175754
+ });
175755
+ const exportData = createRemoteProxyExportTemplate({ state });
175756
+ const remoteProxies = await readRemoteProxies({ state });
175757
+ const indicatorId = createProgressIndicator$1({
175758
+ total: remoteProxies.length,
175759
+ message: "Exporting remote proxies...",
175760
+ state
175761
+ });
175762
+ for (const remoteProxy of remoteProxies) {
175763
+ const proxyId = remoteProxy._id.replace(`${REMOTE_PROXY_TYPE}/`, "");
175764
+ updateProgressIndicator$1({
175765
+ id: indicatorId,
175766
+ message: `Exporting remote proxy ${proxyId}`,
175767
+ state
175768
+ });
175769
+ exportData.remoteProxy[proxyId] = remoteProxy;
175770
+ }
175771
+ stopProgressIndicator$1({
175772
+ id: indicatorId,
175773
+ message: `Exported ${remoteProxies.length} remote proxies.`,
175774
+ state
175775
+ });
175776
+ debugMessage$1({
175777
+ message: `RemoteProxyOps.exportRemoteProxies: end`,
175778
+ state
175779
+ });
175780
+ return exportData;
175781
+ } catch (error) {
175782
+ throw new FrodoError(`Error exporting remote proxies`, error);
175783
+ }
175784
+ }
175785
+ /**
175786
+ * Create remote proxy. Fails if it already exists.
175787
+ * @param {string} proxyId id/name of the remote proxy without the type prefix
175788
+ * @param {RemoteProxySkeleton} proxyData remote proxy object
175789
+ * @returns {Promise<RemoteProxySkeleton>} a promise that resolves to a remote proxy object
175790
+ */
175791
+ async function createRemoteProxy({ proxyId, proxyData, state }) {
175792
+ debugMessage$1({
175793
+ message: `RemoteProxyOps.createRemoteProxy: start`,
175794
+ state
175795
+ });
175796
+ validateRemoteProxy(proxyId, proxyData);
175797
+ try {
175798
+ await readRemoteProxy({
175799
+ proxyId,
175800
+ state
175801
+ });
175802
+ } catch (error) {
175803
+ if (!isNotFoundError(error)) throw new FrodoError(`Error checking if remote proxy ${proxyId} already exists`, error);
175804
+ try {
175805
+ const result = await putConfigEntity$1({
175806
+ entityId: `${REMOTE_PROXY_TYPE}/${proxyId}`,
175807
+ entityData: proxyData,
175808
+ state
175809
+ });
175810
+ debugMessage$1({
175811
+ message: `RemoteProxyOps.createRemoteProxy: end`,
175812
+ state
175813
+ });
175814
+ return result;
175815
+ } catch (error) {
175816
+ throw new FrodoError(`Error creating remote proxy ${proxyId}`, error);
175817
+ }
175818
+ }
175819
+ throw new FrodoError(`Remote proxy ${proxyId} already exists!`);
175820
+ }
175821
+ /**
175822
+ * Update or create remote proxy
175823
+ * @param {string} proxyId id/name of the remote proxy without the type prefix
175824
+ * @param {RemoteProxySkeleton} proxyData remote proxy object
175825
+ * @returns {Promise<RemoteProxySkeleton>} a promise that resolves to a remote proxy object
175826
+ */
175827
+ async function updateRemoteProxy({ proxyId, proxyData, state }) {
175828
+ validateRemoteProxy(proxyId, proxyData);
175829
+ try {
175830
+ return await putConfigEntity$1({
175831
+ entityId: `${REMOTE_PROXY_TYPE}/${proxyId}`,
175832
+ entityData: proxyData,
175833
+ state
175834
+ });
175835
+ } catch (error) {
175836
+ throw new FrodoError(`Error updating remote proxy ${proxyId}`, error);
175837
+ }
175838
+ }
175839
+ /**
175840
+ * Import remote proxies
175841
+ * @param {RemoteProxyExportInterface} importData import data
175842
+ * @returns {Promise<RemoteProxySkeleton[]>} a promise that resolves to an array of remote proxy objects
175843
+ */
175844
+ async function importRemoteProxies({ importData, state }) {
175845
+ debugMessage$1({
175846
+ message: `RemoteProxyOps.importRemoteProxies: start`,
175847
+ state
175848
+ });
175849
+ const response = [];
175850
+ const errors = [];
175851
+ for (const proxyId of Object.keys(importData.remoteProxy)) try {
175852
+ debugMessage$1({
175853
+ message: `RemoteProxyOps.importRemoteProxies: ${proxyId}`,
175854
+ state
175855
+ });
175856
+ response.push(await updateRemoteProxy({
175857
+ proxyId,
175858
+ proxyData: importData.remoteProxy[proxyId],
175859
+ state
175860
+ }));
175861
+ } catch (error) {
175862
+ errors.push(error);
175863
+ }
175864
+ if (errors.length > 0) throw new FrodoError(`Error importing remote proxies`, errors);
175865
+ debugMessage$1({
175866
+ message: `RemoteProxyOps.importRemoteProxies: end`,
175867
+ state
175868
+ });
175869
+ return response;
175870
+ }
175871
+ /**
175872
+ * Delete all remote proxies
175873
+ * @returns {Promise<RemoteProxySkeleton[]>} a promise that resolves to an array of the deleted remote proxy objects
175874
+ */
175875
+ async function deleteRemoteProxies({ state }) {
175876
+ const errors = [];
175877
+ try {
175878
+ debugMessage$1({
175879
+ message: `RemoteProxyOps.deleteRemoteProxies: start`,
175880
+ state
175881
+ });
175882
+ const result = [];
175883
+ const remoteProxies = await readRemoteProxies({ state });
175884
+ for (const remoteProxy of remoteProxies) try {
175885
+ debugMessage$1({
175886
+ message: `RemoteProxyOps.deleteRemoteProxies: '${remoteProxy._id}'`,
175887
+ state
175888
+ });
175889
+ result.push(await deleteConfigEntity$1({
175890
+ entityId: remoteProxy._id,
175891
+ state
175892
+ }));
175893
+ } catch (error) {
175894
+ errors.push(error);
175895
+ }
175896
+ if (errors.length > 0) throw new FrodoError(`Error deleting remote proxies`, errors);
175897
+ debugMessage$1({
175898
+ message: `RemoteProxyOps.deleteRemoteProxies: end`,
175899
+ state
175900
+ });
175901
+ return result;
175902
+ } catch (error) {
175903
+ if (errors.length > 0) throw error;
175904
+ throw new FrodoError(`Error deleting remote proxies`, error);
175905
+ }
175906
+ }
175907
+ /**
175908
+ * Delete remote proxy
175909
+ * @param {string} proxyId id/name of the remote proxy without the type prefix
175910
+ * @returns {Promise<RemoteProxySkeleton>} a promise that resolves to the deleted remote proxy object
175911
+ */
175912
+ async function deleteRemoteProxy({ proxyId, state }) {
175913
+ try {
175914
+ return await deleteConfigEntity$1({
175915
+ entityId: `${REMOTE_PROXY_TYPE}/${proxyId}`,
175916
+ state
175917
+ });
175918
+ } catch (error) {
175919
+ throw new FrodoError(`Error deleting remote proxy ${proxyId}`, error);
175920
+ }
175921
+ }
175415
175922
  var VersionUtils_default = (state) => {
175416
175923
  return {
175417
175924
  getVersion() {
@@ -175680,6 +176187,49 @@ var FrodoLib_exports = /* @__PURE__ */ __exportAll({
175680
176187
  state: () => state
175681
176188
  });
175682
176189
  /**
176190
+ * Create the IDM operations that use the given state
176191
+ * @param {State} state state the operations use
176192
+ * @returns {Frodo['idm']} the IDM operations
176193
+ */
176194
+ function createIdmOps(state) {
176195
+ return {
176196
+ config: IdmConfigOps_default(state),
176197
+ connector: ConnectorOps_default(state),
176198
+ crypto: IdmCryptoOps_default(state),
176199
+ managed: {
176200
+ ...ManagedObjectOps_default(state),
176201
+ schema: ManagedObjectSchemaOps_default(state)
176202
+ },
176203
+ managedSystem: {
176204
+ ...ManagedSystemObjectOps_default(state),
176205
+ schema: ManagedSystemObjectSchemaOps_default(state)
176206
+ },
176207
+ mapping: MappingOps_default(state),
176208
+ organization: OrganizationOps_default(state),
176209
+ recon: ReconOps_default(state),
176210
+ remoteProxy: RemoteProxyOps_default(state),
176211
+ script: IdmScriptOps_default(state),
176212
+ system: IdmSystemOps_default(state)
176213
+ };
176214
+ }
176215
+ /**
176216
+ * Create a view of the IDM of the receiving tenant of a remote proxy. The view
176217
+ * uses a state that takes everything from the given state except the IDM host,
176218
+ * which it computes from the current host of the given state on every call.
176219
+ * @param {string} proxyId id/name of the remote proxy
176220
+ * @param {State} state state of the instance the view belongs to
176221
+ * @returns {RemoteProxyView} the view
176222
+ */
176223
+ function createRemoteProxyView(proxyId, state) {
176224
+ return {
176225
+ proxyId,
176226
+ idm: createIdmOps(deriveState(state, { getIdmHost: () => getRemoteProxyBaseUrl({
176227
+ proxyId,
176228
+ state
176229
+ }) }))
176230
+ };
176231
+ }
176232
+ /**
175683
176233
  * Create a new frodo instance
175684
176234
  * @param {StateInterface} config Initial state configuration to use with the new instance
175685
176235
  * @returns {Frodo} frodo instance
@@ -175743,24 +176293,7 @@ const FrodoLib = (config = {}) => {
175743
176293
  cache: TokenCacheOps_default(state),
175744
176294
  email: { template: EmailTemplateOps_default(state) },
175745
176295
  factory: ApiFactoryOps_default(state),
175746
- idm: {
175747
- config: IdmConfigOps_default(state),
175748
- connector: ConnectorOps_default(state),
175749
- crypto: IdmCryptoOps_default(state),
175750
- managed: {
175751
- ...ManagedObjectOps_default(state),
175752
- schema: ManagedObjectSchemaOps_default(state)
175753
- },
175754
- managedSystem: {
175755
- ...ManagedSystemObjectOps_default(state),
175756
- schema: ManagedSystemObjectSchemaOps_default(state)
175757
- },
175758
- mapping: MappingOps_default(state),
175759
- organization: OrganizationOps_default(state),
175760
- recon: ReconOps_default(state),
175761
- script: IdmScriptOps_default(state),
175762
- system: IdmSystemOps_default(state)
175763
- },
176296
+ idm: createIdmOps(state),
175764
176297
  info: InfoOps_default(state),
175765
176298
  login: AuthenticateOps_default(state),
175766
176299
  mcp: McpOps_default(() => instance),
@@ -175802,6 +176335,7 @@ const FrodoLib = (config = {}) => {
175802
176335
  terminal: TerminalUtils_default()
175803
176336
  },
175804
176337
  createInstance,
176338
+ createRemoteProxyView: (proxyId) => createRemoteProxyView(proxyId, state),
175805
176339
  createInstanceWithAdminAccount,
175806
176340
  createInstanceWithServiceAccount,
175807
176341
  createInstanceWithAmsterAccount,
@@ -180821,4 +181355,4 @@ Object.defineProperty(exports, "warnSpinner", {
180821
181355
  }
180822
181356
  });
180823
181357
 
180824
- //# sourceMappingURL=Console-CoAlCJ12.cjs.map
181358
+ //# sourceMappingURL=Console-gqjYb6W3.cjs.map