UNPKG

@microsoft/teams-js

Version:

Microsoft Client SDK for building app for Microsoft hosts

2 lines (1 loc) 2.38 kB
import{__awaiter as n}from"../../../../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.24.4_tslib@2.6.3_typescript@4.9.5/node_modules/tslib/tslib.es6.js";import{Communication as r,callFunctionInHostAndHandleResponse as t}from"../internal/communication.js";import{GlobalVars as i}from"../internal/globalVars.js";import{ensureInitialized as e,isCurrentSDKVersionAtLeast as o}from"../internal/internalAPIs.js";import{getApiVersionTag as s}from"../internal/telemetry.js";import{HostClientType as a,errorNotSupportedOnPlatform as p}from"./constants.js";import{runtime as u,legacyTeamsMobileVersionForDeeplyNestedAuth as l}from"./runtime.js";const c="v2",d={validate:n=>Array.isArray(n)||"object"==typeof n,deserialize:n=>n};var m;function h(){var n;return null!==(n=e(u)&&(u.isNAAChannelRecommended||!!(e(u)&&y()&&u.isLegacyTeams&&u.supports.nestedAppAuth)))&&void 0!==n&&n}function f(){return e(u),r.parentOrigin}function A(){var n;return null!==(n=e(u)&&u.canParentManageNAATrustedOrigins)&&void 0!==n&&n}function v(){var n;return null!==(n=e(u)&&(u.isDeeplyNestedAuthSupported||!!(e(u)&&y()&&u.isLegacyTeams&&o(l))))&&void 0!==n&&n}function y(){return i.hostClientType===a.android||i.hostClientType===a.ios||i.hostClientType===a.ipados||i.hostClientType===a.visionOS}function g(r){return n(this,void 0,void 0,(function*(){if(!A())throw p;const n=r.map(E);return T(m.ADD,n)}))}function w(r){return n(this,void 0,void 0,(function*(){if(!A())throw p;const n=r.map(E);return T(m.DELETE,n)}))}function T(r,i){return n(this,void 0,void 0,(function*(){if(window.parent!==window.top)throw new Error("This API is only available in the top-level parent.");if(!Array.isArray(i)||0===i.length)throw new Error(`The '${i}' parameter is required and must be a non-empty array.`);const n=[new D(r,i)];return t("nestedAppAuth.manageNAATrustedOrigins",n,d,s(c,"nestedAppAuth.manageNAATrustedOrigins"))}))}function E(n){try{return new URL(n).origin.toLowerCase()}catch(r){throw new Error(`Invalid origin provided: ${n}`)}}!function(n){n.ADD="ADD",n.DELETE="DELETE"}(m||(m={}));class D{constructor(n,r){this.action=n,this.appOrigins=r}serialize(){return{action:this.action,appOrigins:this.appOrigins}}}export{g as addNAATrustedOrigins,A as canParentManageNAATrustedOrigins,w as deleteNAATrustedOrigins,f as getParentOrigin,v as isDeeplyNestedAuthSupported,h as isNAAChannelRecommended};