@microsoft/agents-hosting 0.5.4-ga4d0401645 → 0.5.16-g6bdf69cc43
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.
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +4 -4
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +186 -20
- package/dist/src/app/agentApplication.js +235 -33
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +1 -1
- package/dist/src/app/appRoute.d.ts +5 -0
- package/dist/src/app/authorization.d.ts +293 -0
- package/dist/src/app/authorization.js +375 -0
- package/dist/src/app/authorization.js.map +1 -0
- package/dist/src/app/index.d.ts +1 -1
- package/dist/src/app/index.js +1 -1
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/streaming/citation.d.ts +25 -0
- package/dist/src/app/streaming/{AIEntity.js → citation.js} +1 -1
- package/dist/src/app/streaming/citation.js.map +1 -0
- package/dist/src/app/streaming/{utilities.d.ts → citationUtil.d.ts} +3 -3
- package/dist/src/app/streaming/{utilities.js → citationUtil.js} +5 -36
- package/dist/src/app/streaming/citationUtil.js.map +1 -0
- package/dist/src/app/streaming/streamingResponse.d.ts +3 -4
- package/dist/src/app/streaming/streamingResponse.js +24 -22
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/auth/index.d.ts +1 -0
- package/dist/src/auth/index.js +1 -0
- package/dist/src/auth/index.js.map +1 -1
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msalTokenCredential.d.ts +10 -0
- package/dist/src/auth/msalTokenCredential.js +19 -0
- package/dist/src/auth/msalTokenCredential.js.map +1 -0
- package/dist/src/auth/msalTokenProvider.d.ts +1 -0
- package/dist/src/auth/msalTokenProvider.js +15 -0
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/cards/cardFactory.d.ts +2 -2
- package/dist/src/cards/cardFactory.js.map +1 -1
- package/dist/src/oauth/index.d.ts +1 -4
- package/dist/src/oauth/index.js +1 -4
- package/dist/src/oauth/index.js.map +1 -1
- package/dist/src/oauth/oAuthFlow.d.ts +62 -19
- package/dist/src/oauth/oAuthFlow.js +193 -67
- package/dist/src/oauth/oAuthFlow.js.map +1 -1
- package/dist/src/oauth/userTokenClient.d.ts +37 -7
- package/dist/src/oauth/userTokenClient.js +56 -15
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/oauth/userTokenClient.types.d.ts +147 -0
- package/dist/src/oauth/{oAuthCard.js → userTokenClient.types.js} +1 -1
- package/dist/src/oauth/userTokenClient.types.js.map +1 -0
- package/package.json +5 -4
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +4 -4
- package/src/app/agentApplication.ts +248 -33
- package/src/app/agentApplicationBuilder.ts +1 -1
- package/src/app/agentApplicationOptions.ts +1 -1
- package/src/app/appRoute.ts +6 -0
- package/src/app/authorization.ts +418 -0
- package/src/app/index.ts +1 -1
- package/src/app/streaming/citation.ts +29 -0
- package/src/app/streaming/{utilities.ts → citationUtil.ts} +3 -35
- package/src/app/streaming/streamingResponse.ts +28 -27
- package/src/auth/index.ts +1 -0
- package/src/auth/jwt-middleware.ts +1 -1
- package/src/auth/msalTokenCredential.ts +14 -0
- package/src/auth/msalTokenProvider.ts +17 -1
- package/src/cards/cardFactory.ts +2 -3
- package/src/oauth/index.ts +1 -4
- package/src/oauth/oAuthFlow.ts +226 -70
- package/src/oauth/userTokenClient.ts +62 -19
- package/src/oauth/userTokenClient.types.ts +173 -0
- package/dist/src/app/oauth/authorization.d.ts +0 -87
- package/dist/src/app/oauth/authorization.js +0 -135
- package/dist/src/app/oauth/authorization.js.map +0 -1
- package/dist/src/app/streaming/AIEntity.d.ts +0 -36
- package/dist/src/app/streaming/AIEntity.js.map +0 -1
- package/dist/src/app/streaming/actionCall.d.ts +0 -33
- package/dist/src/app/streaming/actionCall.js +0 -7
- package/dist/src/app/streaming/actionCall.js.map +0 -1
- package/dist/src/app/streaming/clientCitation.d.ts +0 -68
- package/dist/src/app/streaming/clientCitation.js +0 -10
- package/dist/src/app/streaming/clientCitation.js.map +0 -1
- package/dist/src/app/streaming/message.d.ts +0 -106
- package/dist/src/app/streaming/message.js +0 -7
- package/dist/src/app/streaming/message.js.map +0 -1
- package/dist/src/app/streaming/sensitivityUsageInfo.d.ts +0 -40
- package/dist/src/app/streaming/sensitivityUsageInfo.js +0 -3
- package/dist/src/app/streaming/sensitivityUsageInfo.js.map +0 -1
- package/dist/src/app/streaming/utilities.js.map +0 -1
- package/dist/src/oauth/oAuthCard.d.ts +0 -27
- package/dist/src/oauth/oAuthCard.js.map +0 -1
- package/dist/src/oauth/signingResource.d.ts +0 -43
- package/dist/src/oauth/signingResource.js +0 -5
- package/dist/src/oauth/signingResource.js.map +0 -1
- package/dist/src/oauth/tokenExchangeRequest.d.ts +0 -17
- package/dist/src/oauth/tokenExchangeRequest.js +0 -5
- package/dist/src/oauth/tokenExchangeRequest.js.map +0 -1
- package/dist/src/oauth/tokenResponse.d.ts +0 -29
- package/dist/src/oauth/tokenResponse.js +0 -25
- package/dist/src/oauth/tokenResponse.js.map +0 -1
- package/src/app/oauth/authorization.ts +0 -162
- package/src/app/streaming/AIEntity.ts +0 -44
- package/src/app/streaming/actionCall.ts +0 -37
- package/src/app/streaming/clientCitation.ts +0 -102
- package/src/app/streaming/message.ts +0 -125
- package/src/app/streaming/sensitivityUsageInfo.ts +0 -48
- package/src/oauth/oAuthCard.ts +0 -30
- package/src/oauth/signingResource.ts +0 -48
- package/src/oauth/tokenExchangeRequest.ts +0 -20
- package/src/oauth/tokenResponse.ts +0 -43
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../src/app/streaming/message.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sensitivity usage info for content sent to the user. This is used to provide information about the content to the user. See ClientCitation for more information.
|
|
3
|
-
*/
|
|
4
|
-
export interface SensitivityUsageInfo {
|
|
5
|
-
/**
|
|
6
|
-
* Must be "https://schema.org/Message"
|
|
7
|
-
*/
|
|
8
|
-
type: 'https://schema.org/Message';
|
|
9
|
-
/**
|
|
10
|
-
* Required; Set to CreativeWork;
|
|
11
|
-
*/
|
|
12
|
-
'@type': 'CreativeWork';
|
|
13
|
-
/**
|
|
14
|
-
* Sensitivity description of the content
|
|
15
|
-
*/
|
|
16
|
-
description?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Sensitivity title of the content
|
|
19
|
-
*/
|
|
20
|
-
name: string;
|
|
21
|
-
/**
|
|
22
|
-
* Optional; ignored in Teams.
|
|
23
|
-
*/
|
|
24
|
-
position?: number;
|
|
25
|
-
pattern?: {
|
|
26
|
-
/**
|
|
27
|
-
* Set to DefinedTerm
|
|
28
|
-
*/
|
|
29
|
-
'@type': 'DefinedTerm';
|
|
30
|
-
inDefinedTermSet: string;
|
|
31
|
-
/**
|
|
32
|
-
* Color
|
|
33
|
-
*/
|
|
34
|
-
name: string;
|
|
35
|
-
/**
|
|
36
|
-
* e.g. #454545
|
|
37
|
-
*/
|
|
38
|
-
termCode: string;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sensitivityUsageInfo.js","sourceRoot":"","sources":["../../../../src/app/streaming/sensitivityUsageInfo.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/app/streaming/utilities.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,mCAAmC;AAEnC,2CAA2C;AAE3C;;GAEG;AACH,MAAa,SAAS;IACtB,QAAQ;IACR,uCAAuC;IACvC,kBAAkB;IAClB,6GAA6G;IAC7G,qEAAqE;IACrE,8CAA8C;IAC9C,gIAAgI;IAChI,4CAA4C;IAC5C,UAAU;IACV,iGAAiG;IACjG,mDAAmD;IACnD,kBAAkB;IAClB,8CAA8C;IAC9C,uDAAuD;IACvD,qCAAqC;IACrC,6BAA6B;IAC7B,uCAAuC;IACvC,iBAAiB;IACjB,8CAA8C;IAC9C,0CAA0C;IAC1C,+CAA+C;IAC/C,oFAAoF;IACpF,0BAA0B;IAC1B,mBAAmB;IACnB,0BAA0B;IAC1B,YAAY;IACZ,UAAU;IACV,eAAe;IACf,gCAAgC;IAChC,QAAQ;IACR,MAAM;IAEJ;;;;;;SAMK;IACE,MAAM,CAAC,OAAO,CAAE,IAAY,EAAE,SAAiB;QACpD,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;QACtC,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QAC9E,OAAO,IAAI,KAAK,CAAA;QAChB,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;SAIK;IACE,MAAM,CAAC,uBAAuB,CAAE,IAAY;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;IACjD,CAAC;IAED;;;;;SAKK;IACE,MAAM,CAAC,gBAAgB,CAAE,IAAY,EAAE,SAA2B;QACvE,MAAM,KAAK,GAAG,aAAa,CAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAEjC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,oBAAoB;QACpB,MAAM,eAAe,GAAG,IAAI,GAAG,EAAE,CAAA;QACjC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACxB,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/B,OAAM;YACR,CAAC;YAED,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC5B,CAAC,CAAC,CAAA;QAEF,gBAAgB;QAChB,MAAM,aAAa,GAAqB,EAAE,CAAA;QAC1C,eAAe,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAChC,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,QAAQ,GAAG,KAAK,KAAK,CAAC,CAAA;YAC9E,IAAI,KAAK,EAAE,CAAC;gBACV,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC,CAAC,CAAA;QACF,OAAO,aAAa,CAAA;IACtB,CAAC;CACF;AA7FD,8BA6FC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CardAction } from '@microsoft/agents-activity';
|
|
2
|
-
import { TokenExchangeResource, TokenPostResource } from './signingResource';
|
|
3
|
-
/**
|
|
4
|
-
* Represents an OAuth card.
|
|
5
|
-
*/
|
|
6
|
-
export interface OAuthCard {
|
|
7
|
-
/**
|
|
8
|
-
* The buttons associated with the OAuth card.
|
|
9
|
-
*/
|
|
10
|
-
buttons: CardAction[];
|
|
11
|
-
/**
|
|
12
|
-
* The connection name for the OAuth card.
|
|
13
|
-
*/
|
|
14
|
-
connectionName: string;
|
|
15
|
-
/**
|
|
16
|
-
* The text content of the OAuth card.
|
|
17
|
-
*/
|
|
18
|
-
text: string;
|
|
19
|
-
/**
|
|
20
|
-
* The token exchange resource for the OAuth card.
|
|
21
|
-
*/
|
|
22
|
-
tokenExchangeResource: TokenExchangeResource;
|
|
23
|
-
/**
|
|
24
|
-
* The token post resource for the OAuth card.
|
|
25
|
-
*/
|
|
26
|
-
tokenPostResource: TokenPostResource;
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oAuthCard.js","sourceRoot":"","sources":["../../../src/oauth/oAuthCard.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a resource for exchanging tokens.
|
|
3
|
-
*/
|
|
4
|
-
export interface TokenExchangeResource {
|
|
5
|
-
/**
|
|
6
|
-
* The ID of the token exchange resource.
|
|
7
|
-
*/
|
|
8
|
-
id?: string;
|
|
9
|
-
/**
|
|
10
|
-
* The URI of the token exchange resource.
|
|
11
|
-
*/
|
|
12
|
-
uri?: string;
|
|
13
|
-
/**
|
|
14
|
-
* The provider ID for the token exchange resource.
|
|
15
|
-
*/
|
|
16
|
-
providerId?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Represents a resource for posting tokens.
|
|
20
|
-
*/
|
|
21
|
-
export interface TokenPostResource {
|
|
22
|
-
/**
|
|
23
|
-
* The SAS URL for the token post resource.
|
|
24
|
-
*/
|
|
25
|
-
sasUrl?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Represents a resource for signing in.
|
|
29
|
-
*/
|
|
30
|
-
export interface SigningResource {
|
|
31
|
-
/**
|
|
32
|
-
* The link for signing in.
|
|
33
|
-
*/
|
|
34
|
-
signInLink: string;
|
|
35
|
-
/**
|
|
36
|
-
* The resource for token exchange.
|
|
37
|
-
*/
|
|
38
|
-
tokenExchangeResource: TokenExchangeResource;
|
|
39
|
-
/**
|
|
40
|
-
* The resource for token post.
|
|
41
|
-
*/
|
|
42
|
-
tokenPostResource: TokenPostResource;
|
|
43
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signingResource.js","sourceRoot":"","sources":["../../../src/oauth/signingResource.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a request for exchanging tokens.
|
|
3
|
-
*/
|
|
4
|
-
export interface TokenExchangeRequest {
|
|
5
|
-
/**
|
|
6
|
-
* The URI for the token exchange request.
|
|
7
|
-
*/
|
|
8
|
-
uri?: string;
|
|
9
|
-
/**
|
|
10
|
-
* The token to be exchanged.
|
|
11
|
-
*/
|
|
12
|
-
token?: string;
|
|
13
|
-
/**
|
|
14
|
-
* The ID associated with the token exchange request.
|
|
15
|
-
*/
|
|
16
|
-
id?: string;
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokenExchangeRequest.js","sourceRoot":"","sources":["../../../src/oauth/tokenExchangeRequest.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents the status of an OAuth token request.
|
|
3
|
-
*/
|
|
4
|
-
export declare enum TokenRequestStatus {
|
|
5
|
-
/**
|
|
6
|
-
* Indicates that the token request was successful.
|
|
7
|
-
*/
|
|
8
|
-
Success = "Success",
|
|
9
|
-
/**
|
|
10
|
-
* Indicates that the token request failed.
|
|
11
|
-
*/
|
|
12
|
-
Failed = "Failed",
|
|
13
|
-
/**
|
|
14
|
-
* Indicates that the token request is pending.
|
|
15
|
-
*/
|
|
16
|
-
InProgress = "InProgress",
|
|
17
|
-
Expired = "Expired"
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Represents the response containing OAuth token information.
|
|
21
|
-
* This interface encapsulates all data related to an OAuth token response.
|
|
22
|
-
*/
|
|
23
|
-
export interface TokenResponse {
|
|
24
|
-
status: TokenRequestStatus;
|
|
25
|
-
/**
|
|
26
|
-
* The OAuth token string, or null if no token is available.
|
|
27
|
-
*/
|
|
28
|
-
token: string | undefined;
|
|
29
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
// Licensed under the MIT License.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.TokenRequestStatus = void 0;
|
|
6
|
-
/**
|
|
7
|
-
* Represents the status of an OAuth token request.
|
|
8
|
-
*/
|
|
9
|
-
var TokenRequestStatus;
|
|
10
|
-
(function (TokenRequestStatus) {
|
|
11
|
-
/**
|
|
12
|
-
* Indicates that the token request was successful.
|
|
13
|
-
*/
|
|
14
|
-
TokenRequestStatus["Success"] = "Success";
|
|
15
|
-
/**
|
|
16
|
-
* Indicates that the token request failed.
|
|
17
|
-
*/
|
|
18
|
-
TokenRequestStatus["Failed"] = "Failed";
|
|
19
|
-
/**
|
|
20
|
-
* Indicates that the token request is pending.
|
|
21
|
-
*/
|
|
22
|
-
TokenRequestStatus["InProgress"] = "InProgress";
|
|
23
|
-
TokenRequestStatus["Expired"] = "Expired";
|
|
24
|
-
})(TokenRequestStatus || (exports.TokenRequestStatus = TokenRequestStatus = {}));
|
|
25
|
-
//# sourceMappingURL=tokenResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokenResponse.js","sourceRoot":"","sources":["../../../src/oauth/tokenResponse.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAElC;;GAEG;AACH,IAAY,kBAiBX;AAjBD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,yCAAmB,CAAA;IAEnB;;OAEG;IACH,uCAAiB,CAAA;IAEjB;;OAEG;IACH,+CAAyB,CAAA;IAEzB,yCAAmB,CAAA;AACrB,CAAC,EAjBW,kBAAkB,kCAAlB,kBAAkB,QAiB7B"}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { TurnContext } from '../../turnContext'
|
|
7
|
-
import { debug } from '../../logger'
|
|
8
|
-
import { TurnState } from '../turnState'
|
|
9
|
-
import { Storage } from '../../storage'
|
|
10
|
-
import { OAuthFlow, TokenRequestStatus, TokenResponse } from '../../oauth'
|
|
11
|
-
import { UserState } from '../../state'
|
|
12
|
-
|
|
13
|
-
const logger = debug('agents:authorization')
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Interface defining an authorization handler for OAuth flows
|
|
17
|
-
* @interface AuthHandler
|
|
18
|
-
*/
|
|
19
|
-
export interface AuthHandler {
|
|
20
|
-
/** Connection name for the auth provider */
|
|
21
|
-
name?: string,
|
|
22
|
-
/** Whether authorization should be triggered automatically */
|
|
23
|
-
auto?: boolean,
|
|
24
|
-
/** The OAuth flow implementation */
|
|
25
|
-
flow?: OAuthFlow,
|
|
26
|
-
/** Title to display on auth cards/UI */
|
|
27
|
-
title?: string,
|
|
28
|
-
/** Text to display on auth cards/UI */
|
|
29
|
-
text?: string,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Options for configuring user authorization.
|
|
34
|
-
* Contains settings to configure OAuth connections.
|
|
35
|
-
*/
|
|
36
|
-
export interface AuthorizationHandlers extends Record<string, AuthHandler> {}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Class responsible for managing authorization and OAuth flows
|
|
40
|
-
* @class Authorization
|
|
41
|
-
*/
|
|
42
|
-
export class Authorization {
|
|
43
|
-
_authHandlers: AuthorizationHandlers
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Creates a new instance of UserAuthorization.
|
|
47
|
-
* @param {Storage} storage - The storage system to use for state management.
|
|
48
|
-
* @param {AuthorizationHandlers} authHandlers - Configuration for OAuth providers
|
|
49
|
-
* @throws {Error} If storage is null/undefined or no auth handlers are provided
|
|
50
|
-
*/
|
|
51
|
-
constructor (storage: Storage, authHandlers: AuthorizationHandlers) {
|
|
52
|
-
if (storage === undefined || storage === null) {
|
|
53
|
-
throw new Error('Storage is required for UserAuthorization')
|
|
54
|
-
}
|
|
55
|
-
const userState = new UserState(storage)
|
|
56
|
-
if (authHandlers === undefined || Object.keys(authHandlers).length === 0) {
|
|
57
|
-
throw new Error('The authorization does not have any auth handlers')
|
|
58
|
-
}
|
|
59
|
-
this._authHandlers = authHandlers
|
|
60
|
-
for (const ah in this._authHandlers) {
|
|
61
|
-
if (this._authHandlers![ah].name === undefined && process.env[ah + '_connectionName'] === undefined) {
|
|
62
|
-
throw new Error(`AuthHandler name ${ah}_connectionName not set in autorization and not found in env vars.`)
|
|
63
|
-
}
|
|
64
|
-
const currentAuthHandler = this._authHandlers![ah]
|
|
65
|
-
currentAuthHandler.name = currentAuthHandler.name ?? process.env[ah + '_connectionName'] as string
|
|
66
|
-
currentAuthHandler.title = currentAuthHandler.title ?? process.env[ah + '_connectionTitle'] as string
|
|
67
|
-
currentAuthHandler.text = currentAuthHandler.text ?? process.env[ah + '_connectionText'] as string
|
|
68
|
-
currentAuthHandler.auto = currentAuthHandler.auto ?? process.env[ah + '_connectionAuto'] === 'true'
|
|
69
|
-
currentAuthHandler.flow = new OAuthFlow(userState, currentAuthHandler.name, null!, currentAuthHandler.title, currentAuthHandler.text)
|
|
70
|
-
}
|
|
71
|
-
logger.info('Authorization handlers configured with', this._authHandlers.length, 'handlers')
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Gets the token for a specific auth handler
|
|
76
|
-
* @param {TurnContext} context - The context object for the current turn
|
|
77
|
-
* @param {string} [authHandlerId] - Optional ID of the auth handler to use, defaults to first handler
|
|
78
|
-
* @returns {Promise<TokenResponse>} The token response from the OAuth provider
|
|
79
|
-
*/
|
|
80
|
-
public async getToken (context: TurnContext, authHandlerId?: string): Promise<TokenResponse> {
|
|
81
|
-
logger.info('getToken from user token service for authHandlerId:', authHandlerId)
|
|
82
|
-
const authHandler = this.resolverHandler(authHandlerId)
|
|
83
|
-
return await authHandler.flow?.getUserToken(context)!
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Begins or continues an OAuth flow
|
|
88
|
-
* @param {TurnContext} context - The context object for the current turn
|
|
89
|
-
* @param {TurnState} state - The state object for the current turn
|
|
90
|
-
* @param {string} [authHandlerId] - Optional ID of the auth handler to use, defaults to first handler
|
|
91
|
-
* @returns {Promise<TokenResponse>} The token response from the OAuth provider
|
|
92
|
-
*/
|
|
93
|
-
public async beginOrContinueFlow (context: TurnContext, state: TurnState, authHandlerId?: string) : Promise<TokenResponse> {
|
|
94
|
-
logger.info('beginOrContinueFlow for authHandlerId:', authHandlerId)
|
|
95
|
-
const flow = this.resolverHandler(authHandlerId).flow!
|
|
96
|
-
let tokenResponse: TokenResponse
|
|
97
|
-
if (flow.state!.flowStarted === false) {
|
|
98
|
-
tokenResponse = await flow.beginFlow(context)
|
|
99
|
-
} else {
|
|
100
|
-
tokenResponse = await flow.continueFlow(context)
|
|
101
|
-
if (tokenResponse.status === TokenRequestStatus.Success) {
|
|
102
|
-
if (this._signInHandler) {
|
|
103
|
-
await this._signInHandler(context, state, authHandlerId)
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return tokenResponse
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Gets the current state of the OAuth flow
|
|
112
|
-
* @param {string} [authHandlerId] - Optional ID of the auth handler to check, defaults to first handler
|
|
113
|
-
* @returns {boolean} Whether the flow has started
|
|
114
|
-
*/
|
|
115
|
-
public getFlowState (authHandlerId?: string) : boolean {
|
|
116
|
-
const flow = this.resolverHandler(authHandlerId).flow!
|
|
117
|
-
return flow.state?.flowStarted!
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Resolves the auth handler to use based on the provided ID
|
|
122
|
-
* @param {string} [authHandlerId] - Optional ID of the auth handler to resolve, defaults to first handler
|
|
123
|
-
* @returns {AuthHandler} The resolved auth handler
|
|
124
|
-
*/
|
|
125
|
-
resolverHandler = (authHandlerId?: string) : AuthHandler => {
|
|
126
|
-
if (authHandlerId) {
|
|
127
|
-
return this._authHandlers![authHandlerId]
|
|
128
|
-
}
|
|
129
|
-
return this._authHandlers![Object.keys(this._authHandlers)[0]]
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Signs out the current user.
|
|
134
|
-
* This method clears the user's token and resets the SSO state.
|
|
135
|
-
*
|
|
136
|
-
* @param {TurnContext} context - The context object for the current turn.
|
|
137
|
-
* @param {TurnState} state - The state object for the current turn.
|
|
138
|
-
* @param {string} [authHandlerId] - Optional ID of the auth handler to use for sign out
|
|
139
|
-
* @returns {Promise<void>}
|
|
140
|
-
*/
|
|
141
|
-
async signOut (context: TurnContext, state: TurnState, authHandlerId?: string) : Promise<void> {
|
|
142
|
-
logger.info('signOut for authHandlerId:', authHandlerId)
|
|
143
|
-
if (authHandlerId === undefined) { // aw
|
|
144
|
-
for (const ah in this._authHandlers) {
|
|
145
|
-
const flow = this._authHandlers[ah].flow
|
|
146
|
-
await flow?.signOut(context)
|
|
147
|
-
}
|
|
148
|
-
} else {
|
|
149
|
-
await this.resolverHandler(authHandlerId).flow?.signOut(context)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
_signInHandler: ((context: TurnContext, state: TurnState, authHandlerId?: string) => void) | null = null
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Sets a handler to be called when sign-in is successfully completed
|
|
157
|
-
* @param {Function} handler - The handler function to call on successful sign-in
|
|
158
|
-
*/
|
|
159
|
-
public onSignInSuccess (handler: (context: TurnContext, state: TurnState, authHandlerId?: string) => void) {
|
|
160
|
-
this._signInHandler = handler
|
|
161
|
-
}
|
|
162
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { ClientCitation } from './clientCitation'
|
|
7
|
-
import { SensitivityUsageInfo } from './sensitivityUsageInfo'
|
|
8
|
-
|
|
9
|
-
export interface AIEntity {
|
|
10
|
-
/**
|
|
11
|
-
* Required as 'https://schema.org/Message'
|
|
12
|
-
*/
|
|
13
|
-
type: 'https://schema.org/Message';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Required as 'Message
|
|
17
|
-
*/
|
|
18
|
-
'@type': 'Message';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Required as 'https://schema.org
|
|
22
|
-
*/
|
|
23
|
-
'@context': 'https://schema.org';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Must be left blank. This is for Bot Framework schema.
|
|
27
|
-
*/
|
|
28
|
-
'@id': '';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Indicate that the content was generated by AI.
|
|
32
|
-
*/
|
|
33
|
-
additionalType: ['AIGeneratedContent'];
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Optional; if citations object is included, the sent activity will include the citations, referenced in the activity text.
|
|
37
|
-
*/
|
|
38
|
-
citation?: ClientCitation[];
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Optional; if usage_info object is included, the sent activity will include the sensitivity usage information.
|
|
42
|
-
*/
|
|
43
|
-
usageInfo?: SensitivityUsageInfo;
|
|
44
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* An action call to be requested by the LLM model. This type is a generic meant to be the equivalent of OpenAI's [`ChatCompletionMessageToolCall`](https://github.com/openai/openai-node/blob/master/src/resources/chat/completions.ts#L477), but is not tied to OpenAI's implementation in order to allow for flexibility for other models in the future.
|
|
8
|
-
*/
|
|
9
|
-
export interface ActionCall {
|
|
10
|
-
/**
|
|
11
|
-
* The ID of the tool call.
|
|
12
|
-
*/
|
|
13
|
-
id: string;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The function that the model called.
|
|
17
|
-
*/
|
|
18
|
-
function: {
|
|
19
|
-
/**
|
|
20
|
-
* The name of the function.
|
|
21
|
-
*/
|
|
22
|
-
name: string;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The arguments to call the function with, as generated by the model in JSON
|
|
26
|
-
* format. Note that the model does not always generate valid JSON, and may
|
|
27
|
-
* hallucinate parameters not defined by your function schema. Validate the
|
|
28
|
-
* arguments in your code before calling your function.
|
|
29
|
-
*/
|
|
30
|
-
arguments: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The type of the tool. Currently, only `function` is supported.
|
|
35
|
-
*/
|
|
36
|
-
type: 'function';
|
|
37
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module teams-ai
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6
|
-
* Licensed under the MIT License.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { SensitivityUsageInfo } from './sensitivityUsageInfo'
|
|
10
|
-
|
|
11
|
-
export type ClientCitationIconName =
|
|
12
|
-
| 'Microsoft Word'
|
|
13
|
-
| 'Microsoft Excel'
|
|
14
|
-
| 'Microsoft PowerPoint'
|
|
15
|
-
| 'Microsoft OneNote'
|
|
16
|
-
| 'Microsoft SharePoint'
|
|
17
|
-
| 'Microsoft Visio'
|
|
18
|
-
| 'Microsoft Loop'
|
|
19
|
-
| 'Microsoft Whiteboard'
|
|
20
|
-
| 'Adobe Illustrator'
|
|
21
|
-
| 'Adobe Photoshop'
|
|
22
|
-
| 'Adobe InDesign'
|
|
23
|
-
| 'Adobe Flash'
|
|
24
|
-
| 'Sketch'
|
|
25
|
-
| 'Source Code'
|
|
26
|
-
| 'Image'
|
|
27
|
-
| 'GIF'
|
|
28
|
-
| 'Video'
|
|
29
|
-
| 'Sound'
|
|
30
|
-
| 'ZIP'
|
|
31
|
-
| 'Text'
|
|
32
|
-
| 'PDF'
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Represents a Teams client citation to be included in a message. See Bot messages with AI-generated content for more details.
|
|
36
|
-
* https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/bot-messages-ai-generated-content?tabs=before%2Cbotmessage
|
|
37
|
-
*/
|
|
38
|
-
export interface ClientCitation {
|
|
39
|
-
/**
|
|
40
|
-
* Required; must be "Claim"
|
|
41
|
-
*/
|
|
42
|
-
'@type': 'Claim';
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Required. Number and position of the citation.
|
|
46
|
-
*/
|
|
47
|
-
position: number;
|
|
48
|
-
appearance: {
|
|
49
|
-
/**
|
|
50
|
-
* Required; Must be 'DigitalDocument'
|
|
51
|
-
*/
|
|
52
|
-
'@type': 'DigitalDocument';
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Name of the document. (max length 80)
|
|
56
|
-
*/
|
|
57
|
-
name: string;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Stringified adaptive card with additional information about the citation.
|
|
61
|
-
* It is rendered within the modal.
|
|
62
|
-
*/
|
|
63
|
-
text?: string;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* URL of the document. This will make the name of the citation clickable and direct the user to the specified URL.
|
|
67
|
-
*/
|
|
68
|
-
url?: string;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Extract of the referenced content. (max length 160)
|
|
72
|
-
*/
|
|
73
|
-
abstract: string;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Encoding format of the `citation.appearance.text` field.
|
|
77
|
-
*/
|
|
78
|
-
encodingFormat?: 'application/vnd.microsoft.card.adaptive';
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Information about the citation’s icon.
|
|
82
|
-
*/
|
|
83
|
-
image?: {
|
|
84
|
-
'@type': 'ImageObject';
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The image/icon name
|
|
88
|
-
*/
|
|
89
|
-
name: ClientCitationIconName;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Optional; set by developer. (max length 3) (max keyword length 28)
|
|
94
|
-
*/
|
|
95
|
-
keywords?: string[];
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Optional sensitivity content information.
|
|
99
|
-
*/
|
|
100
|
-
usageInfo?: SensitivityUsageInfo;
|
|
101
|
-
};
|
|
102
|
-
}
|