Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/teamsfx

Package Overview
Dependencies
Maintainers
4
Versions
1255
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/teamsfx - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3-alpha.8541594.0

10

dist-esm/src/bot/teamsBotSsoPrompt.js
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { __awaiter } from "tslib";
import { ActivityTypes, CardFactory, Channels, MessageFactory, ActionTypes, verifyStateOperationName, StatusCodes, tokenExchangeOperationName, } from "botbuilder-core";
import { ActivityTypes, CardFactory, Channels, MessageFactory, ActionTypes, verifyStateOperationName, StatusCodes, tokenExchangeOperationName, TeamsInfo, } from "botbuilder";
import { Dialog, } from "botbuilder-dialogs";

@@ -217,3 +217,5 @@ import { config } from "../core/configurationProvider";

internalLogger.verbose("Send OAuth card to get SSO token");
const signInResource = this.getSignInResource();
const account = yield TeamsInfo.getMember(context, context.activity.from.id);
internalLogger.verbose("Get Teams member account user principal name: " + account.userPrincipalName);
const signInResource = this.getSignInResource(account.userPrincipalName);
const card = CardFactory.oauthCard("", "Teams SSO Sign In", "Sign In", signInResource.signInLink, signInResource.tokenExchangeResource);

@@ -233,3 +235,3 @@ card.content.buttons[0].type = ActionTypes.Signin;

*/
getSignInResource() {
getSignInResource(loginHint) {
var _a, _b, _c, _d, _e;

@@ -255,3 +257,3 @@ internalLogger.verbose("Get sign in authentication configuration");

}
const signInLink = `${config.authentication.initiateLoginEndpoint}?scope=${encodeURI(this.settings.scopes.join(" "))}&clientId=${config.authentication.clientId}&tenantId=${config.authentication.tenantId}`;
const signInLink = `${config.authentication.initiateLoginEndpoint}?scope=${encodeURI(this.settings.scopes.join(" "))}&clientId=${config.authentication.clientId}&tenantId=${config.authentication.tenantId}&loginHint=${loginHint}`;
internalLogger.verbose("Sign in link: " + signInLink);

@@ -258,0 +260,0 @@ const tokenExchangeResource = {

32

dist/index.js

@@ -10,3 +10,3 @@ 'use strict';

var msalNode = require('@azure/msal-node');
var botbuilderCore = require('botbuilder-core');
var botbuilder = require('botbuilder');
var botbuilderDialogs = require('botbuilder-dialogs');

@@ -1045,3 +1045,3 @@ var uuid = require('uuid');

const state = (_a = dc.activeDialog) === null || _a === void 0 ? void 0 : _a.state;
const isMessage = dc.context.activity.type === botbuilderCore.ActivityTypes.Message;
const isMessage = dc.context.activity.type === botbuilder.ActivityTypes.Message;
const isTimeoutActivityType = isMessage ||

@@ -1081,3 +1081,3 @@ this.isTeamsVerificationInvoke(dc.context) ||

ensureMsTeamsChannel(dc) {
if (dc.context.activity.channelId != botbuilderCore.Channels.Msteams) {
if (dc.context.activity.channelId != botbuilder.Channels.Msteams) {
const errorMsg = formatString(ErrorMessage.OnlyMSTeamsChannelSupported, "Teams Bot SSO Prompt");

@@ -1097,6 +1097,8 @@ internalLogger.error(errorMsg);

internalLogger.verbose("Send OAuth card to get SSO token");
const signInResource = this.getSignInResource();
const card = botbuilderCore.CardFactory.oauthCard("", "Teams SSO Sign In", "Sign In", signInResource.signInLink, signInResource.tokenExchangeResource);
card.content.buttons[0].type = botbuilderCore.ActionTypes.Signin;
const msg = botbuilderCore.MessageFactory.attachment(card);
const account = yield botbuilder.TeamsInfo.getMember(context, context.activity.from.id);
internalLogger.verbose("Get Teams member account user principal name: " + account.userPrincipalName);
const signInResource = this.getSignInResource(account.userPrincipalName);
const card = botbuilder.CardFactory.oauthCard("", "Teams SSO Sign In", "Sign In", signInResource.signInLink, signInResource.tokenExchangeResource);
card.content.buttons[0].type = botbuilder.ActionTypes.Signin;
const msg = botbuilder.MessageFactory.attachment(card);
// Send prompt

@@ -1113,3 +1115,3 @@ yield context.sendActivity(msg);

*/
getSignInResource() {
getSignInResource(loginHint) {
var _a, _b, _c, _d, _e;

@@ -1135,3 +1137,3 @@ internalLogger.verbose("Get sign in authentication configuration");

}
const signInLink = `${config.authentication.initiateLoginEndpoint}?scope=${encodeURI(this.settings.scopes.join(" "))}&clientId=${config.authentication.clientId}&tenantId=${config.authentication.tenantId}`;
const signInLink = `${config.authentication.initiateLoginEndpoint}?scope=${encodeURI(this.settings.scopes.join(" "))}&clientId=${config.authentication.clientId}&tenantId=${config.authentication.tenantId}&loginHint=${loginHint}`;
internalLogger.verbose("Sign in link: " + signInLink);

@@ -1161,3 +1163,3 @@ const tokenExchangeResource = {

internalLogger.warn(warningMsg);
yield context.sendActivity(this.getTokenExchangeInvokeResponse(botbuilderCore.StatusCodes.BAD_REQUEST, warningMsg));
yield context.sendActivity(this.getTokenExchangeInvokeResponse(botbuilder.StatusCodes.BAD_REQUEST, warningMsg));
}

@@ -1171,3 +1173,3 @@ else {

if (exchangedToken) {
yield context.sendActivity(this.getTokenExchangeInvokeResponse(botbuilderCore.StatusCodes.OK, "", context.activity.value.id));
yield context.sendActivity(this.getTokenExchangeInvokeResponse(botbuilder.StatusCodes.OK, "", context.activity.value.id));
const ssoTokenExpiration = parseJwt(ssoToken).exp;

@@ -1186,3 +1188,3 @@ tokenResponse = {

internalLogger.info(warningMsg);
yield context.sendActivity(this.getTokenExchangeInvokeResponse(botbuilderCore.StatusCodes.PRECONDITION_FAILED, warningMsg, context.activity.value.id));
yield context.sendActivity(this.getTokenExchangeInvokeResponse(botbuilder.StatusCodes.PRECONDITION_FAILED, warningMsg, context.activity.value.id));
}

@@ -1194,3 +1196,3 @@ }

yield this.sendOAuthCardAsync(dc.context);
yield context.sendActivity({ type: invokeResponseType, value: { status: botbuilderCore.StatusCodes.OK } });
yield context.sendActivity({ type: invokeResponseType, value: { status: botbuilder.StatusCodes.OK } });
}

@@ -1217,3 +1219,3 @@ return tokenResponse !== undefined

const activity = context.activity;
return activity.type === botbuilderCore.ActivityTypes.Invoke && activity.name === botbuilderCore.verifyStateOperationName;
return activity.type === botbuilder.ActivityTypes.Invoke && activity.name === botbuilder.verifyStateOperationName;
}

@@ -1225,3 +1227,3 @@ /**

const activity = context.activity;
return activity.type === botbuilderCore.ActivityTypes.Invoke && activity.name === botbuilderCore.tokenExchangeOperationName;
return activity.type === botbuilder.ActivityTypes.Invoke && activity.name === botbuilder.tokenExchangeOperationName;
}

@@ -1228,0 +1230,0 @@ /**

{
"name": "@microsoft/teamsfx",
"version": "0.2.2",
"version": "0.2.3-alpha.08541594.0",
"description": "Microsoft Teams Framework for Node.js and browser.",

@@ -37,3 +37,3 @@ "main": "dist/index.js",

"unit-test:browser": "karma start --single-run --glob=./dist-test/index.unit.browser.js",
"unit-test:node": "nyc --reporter=html --reporter=json-summary --reporter=text mocha --no-timeouts -r test/mocha.env.ts --require ts-node/register test/unit/node/**/*.spec.ts test/unit/*.spec.ts",
"unit-test:node": "nyc mocha --no-timeouts -r test/mocha.env.ts --require ts-node/register \"test/unit/node/**/*.spec.ts\" \"test/unit/*.spec.ts\"",
"test:unit": "npm run build:test && npm run unit-test:node && npm run unit-test:browser",

@@ -70,2 +70,3 @@ "ui-test": "mocha --no-timeouts -r test/mocha.env.ts -r ts-node/register test/ui/**/*.spec.ts --exit",

"axios": "^0.21.1",
"botbuilder": ">=4.9.3 <5.0.0",
"botbuilder-core": ">=4.9.3 <5.0.0",

@@ -84,2 +85,3 @@ "botbuilder-dialogs": ">=4.9.3 < 5.0.0",

"@commitlint/config-conventional": "^12.0.1",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@microsoft/api-documenter": "^7.12.4",

@@ -139,2 +141,3 @@ "@microsoft/api-extractor": "7.7.11",

"sinon": "^9.2.4",
"source-map-support": "^0.5.19",
"ts-node": "^9.1.1",

@@ -145,3 +148,3 @@ "typescript": "^4.1.2",

},
"gitHead": "c9000fc45cc6859777ebef04abfe2923413274b6",
"gitHead": "8e085350f7b1610867aca5681dab0d224a8ad919",
"publishConfig": {

@@ -148,0 +151,0 @@ "access": "public"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc