UNPKG

@itwin/access-control-client

Version:

Access control client for the iTwin platform

77 lines 3.74 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module AccessControlClient */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ITwinSharesClient = void 0; const BaseClient_1 = require("./BaseClient"); /** Client API to perform iTwin share operations. * @beta */ class ITwinSharesClient extends BaseClient_1.BaseClient { /** Create a new ITwinSharesClient instance * @param url Optional base URL for the access control service. If not provided, defaults to base url. */ constructor(url) { super(url); } /** Create a new iTwin share * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param iTwinShare The details of the iTwin share to be created * @remarks * #### Create * Creating an iTwin Share allows your iTwin to be publicly accessible, enabling anyone with the `shareKey` to view its data without needing to sign in. To use a share, take the value of the `shareKey` property and prepend it with the `Basic` prefix in the authorization header of your request. * * #### Share Contract * Each share is governed by a share contract that specifies the APIs available for the share and its associated iTwin. * Only an iTwin admin can create iTwin Shares, and only a maximum of 10 shares can be active at a time per application that created it. * The share contract expires after 90 days unless a shorter expiration is specified in the request body, with 90 days being the maximum duration. If the expiration property in the request body is left empty, it will default to the maximum duration from the moment of creation. * A share can be revoked at any time using the Revoke iTwin Share endpoint. * @returns ITwin Share * @beta */ async createITwinShare(accessToken, iTwinId, iTwinShare) { const url = `${this._baseUrl}/${iTwinId}/shares`; return this.sendGenericAPIRequest(accessToken, "POST", url, iTwinShare); } /** Get iTwin share * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param sharedId The id of the iTwin share to be retrieved * @returns The iTwin share details * @beta */ async getITwinShare(accessToken, iTwinId, sharedId) { const url = `${this._baseUrl}/${iTwinId}/shares/${sharedId}`; return this.sendGenericAPIRequest(accessToken, "GET", url); } /** Get iTwin shares * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param sharedId The id of the iTwin share to be retrieved * @returns The iTwin share details * @beta */ async getITwinShares(accessToken, iTwinId) { const url = `${this._baseUrl}/${iTwinId}/shares`; return this.sendGenericAPIRequest(accessToken, "GET", url); } /** Revoke iTwin share * @param accessToken The client access token string * @param iTwinId The id of the iTwin * @param sharedId The id of the iTwin share to be revoked * @returns No Content * @beta */ async revokeITwinShare(accessToken, iTwinId, sharedId) { const url = `${this._baseUrl}/${iTwinId}/shares/${sharedId}`; return this.sendGenericAPIRequest(accessToken, "DELETE", url); } } exports.ITwinSharesClient = ITwinSharesClient; //# sourceMappingURL=ItwinShares.js.map