@azure/msal-browser 3.2.0 → 3.3.0

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.
Files changed (202) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +2 -2
  3. package/dist/app/PublicClientApplication.mjs.map +1 -1
  4. package/dist/app/PublicClientNext.d.ts +274 -0
  5. package/dist/app/PublicClientNext.d.ts.map +1 -0
  6. package/dist/app/PublicClientNext.mjs +362 -0
  7. package/dist/app/PublicClientNext.mjs.map +1 -0
  8. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
  9. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  10. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  11. package/dist/cache/BrowserCacheManager.d.ts +2 -13
  12. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  13. package/dist/cache/BrowserCacheManager.mjs +7 -64
  14. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  15. package/dist/cache/BrowserStorage.mjs +1 -1
  16. package/dist/cache/CryptoKeyStore.mjs +1 -1
  17. package/dist/cache/DatabaseStorage.mjs +1 -1
  18. package/dist/cache/MemoryStorage.mjs +1 -1
  19. package/dist/cache/TokenCache.mjs +1 -1
  20. package/dist/config/Configuration.d.ts +4 -0
  21. package/dist/config/Configuration.d.ts.map +1 -1
  22. package/dist/config/Configuration.mjs +2 -1
  23. package/dist/config/Configuration.mjs.map +1 -1
  24. package/dist/controllers/ControllerFactory.d.ts +2 -1
  25. package/dist/controllers/ControllerFactory.d.ts.map +1 -1
  26. package/dist/controllers/ControllerFactory.mjs +26 -19
  27. package/dist/controllers/ControllerFactory.mjs.map +1 -1
  28. package/dist/controllers/NestedAppAuthController.d.ts +96 -0
  29. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
  30. package/dist/controllers/NestedAppAuthController.mjs +345 -0
  31. package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
  32. package/dist/controllers/StandardController.d.ts.map +1 -1
  33. package/dist/controllers/StandardController.mjs +16 -13
  34. package/dist/controllers/StandardController.mjs.map +1 -1
  35. package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
  36. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
  37. package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
  38. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
  39. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  40. package/dist/crypto/BrowserCrypto.mjs +3 -3
  41. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  42. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  43. package/dist/crypto/CryptoOps.mjs +8 -5
  44. package/dist/crypto/CryptoOps.mjs.map +1 -1
  45. package/dist/crypto/PkceGenerator.mjs +1 -1
  46. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  47. package/dist/encode/Base64Decode.mjs +1 -1
  48. package/dist/encode/Base64Encode.mjs +1 -1
  49. package/dist/error/BrowserAuthError.mjs +1 -1
  50. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  51. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  52. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  53. package/dist/error/NativeAuthError.mjs +1 -1
  54. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  55. package/dist/error/NestedAppAuthError.d.ts +15 -0
  56. package/dist/error/NestedAppAuthError.d.ts.map +1 -0
  57. package/dist/error/NestedAppAuthError.mjs +30 -0
  58. package/dist/error/NestedAppAuthError.mjs.map +1 -0
  59. package/dist/event/EventHandler.mjs +1 -1
  60. package/dist/event/EventMessage.mjs +1 -1
  61. package/dist/event/EventType.mjs +1 -1
  62. package/dist/index.d.ts +3 -5
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.mjs +4 -2
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/interaction_client/BaseInteractionClient.mjs +4 -4
  67. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  68. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  69. package/dist/interaction_client/NativeInteractionClient.mjs +15 -4
  70. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  71. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  72. package/dist/interaction_client/PopupClient.mjs +5 -4
  73. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  74. package/dist/interaction_client/RedirectClient.mjs +7 -7
  75. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  76. package/dist/interaction_client/SilentAuthCodeClient.mjs +4 -4
  77. package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
  78. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  79. package/dist/interaction_client/SilentCacheClient.mjs +4 -3
  80. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  81. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  82. package/dist/interaction_client/SilentIframeClient.mjs +27 -13
  83. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  84. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  85. package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
  86. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  87. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  88. package/dist/interaction_handler/SilentHandler.d.ts +13 -47
  89. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  90. package/dist/interaction_handler/SilentHandler.mjs +120 -155
  91. package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
  92. package/dist/naa/AccountInfo.d.ts +13 -0
  93. package/dist/naa/AccountInfo.d.ts.map +1 -0
  94. package/dist/naa/AccountRequests.d.ts +10 -0
  95. package/dist/naa/AccountRequests.d.ts.map +1 -0
  96. package/dist/naa/AuthBridge.d.ts +6 -0
  97. package/dist/naa/AuthBridge.d.ts.map +1 -0
  98. package/dist/naa/BridgeCapabilities.d.ts +4 -0
  99. package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
  100. package/dist/naa/BridgeError.d.ts +10 -0
  101. package/dist/naa/BridgeError.d.ts.map +1 -0
  102. package/dist/naa/BridgeError.mjs +12 -0
  103. package/dist/naa/BridgeError.mjs.map +1 -0
  104. package/dist/naa/BridgeProxy.d.ts +72 -0
  105. package/dist/naa/BridgeProxy.d.ts.map +1 -0
  106. package/dist/naa/BridgeProxy.mjs +154 -0
  107. package/dist/naa/BridgeProxy.mjs.map +1 -0
  108. package/dist/naa/BridgeRequest.d.ts +7 -0
  109. package/dist/naa/BridgeRequest.d.ts.map +1 -0
  110. package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
  111. package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
  112. package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
  113. package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
  114. package/dist/naa/BridgeStatusCode.d.ts +11 -0
  115. package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
  116. package/dist/naa/BridgeStatusCode.mjs +20 -0
  117. package/dist/naa/BridgeStatusCode.mjs.map +1 -0
  118. package/dist/naa/IBridgeProxy.d.ts +11 -0
  119. package/dist/naa/IBridgeProxy.d.ts.map +1 -0
  120. package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
  121. package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
  122. package/dist/naa/TokenRequest.d.ts +22 -0
  123. package/dist/naa/TokenRequest.d.ts.map +1 -0
  124. package/dist/naa/TokenResponse.d.ts +17 -0
  125. package/dist/naa/TokenResponse.d.ts.map +1 -0
  126. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
  127. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
  128. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
  129. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
  130. package/dist/navigation/NavigationClient.mjs +1 -1
  131. package/dist/network/FetchClient.mjs +1 -1
  132. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  133. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  134. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
  135. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
  136. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
  137. package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
  138. package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
  139. package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
  140. package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
  141. package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
  142. package/dist/packageMetadata.d.ts +1 -1
  143. package/dist/packageMetadata.mjs +2 -2
  144. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  145. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  146. package/dist/utils/BrowserConstants.mjs +1 -1
  147. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  148. package/dist/utils/BrowserUtils.d.ts +54 -53
  149. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  150. package/dist/utils/BrowserUtils.mjs +114 -102
  151. package/dist/utils/BrowserUtils.mjs.map +1 -1
  152. package/lib/msal-browser.cjs +61 -17728
  153. package/lib/msal-browser.cjs.map +1 -1
  154. package/lib/msal-browser.js +14625 -13223
  155. package/lib/msal-browser.js.map +1 -1
  156. package/lib/msal-browser.min.js +66 -68
  157. package/package.json +2 -2
  158. package/src/app/PublicClientApplication.ts +1 -1
  159. package/src/app/PublicClientNext.ts +442 -0
  160. package/src/cache/BrowserCacheManager.ts +11 -100
  161. package/src/config/Configuration.ts +5 -0
  162. package/src/controllers/ControllerFactory.ts +36 -25
  163. package/src/controllers/NestedAppAuthController.ts +525 -0
  164. package/src/controllers/StandardController.ts +8 -6
  165. package/src/controllers/UnknownOperatingContextController.ts +383 -0
  166. package/src/crypto/BrowserCrypto.ts +2 -2
  167. package/src/crypto/CryptoOps.ts +8 -5
  168. package/src/error/NestedAppAuthError.ts +32 -0
  169. package/src/index.ts +3 -10
  170. package/src/interaction_client/BaseInteractionClient.ts +1 -1
  171. package/src/interaction_client/NativeInteractionClient.ts +19 -3
  172. package/src/interaction_client/PopupClient.ts +2 -1
  173. package/src/interaction_client/RedirectClient.ts +1 -1
  174. package/src/interaction_client/SilentAuthCodeClient.ts +5 -4
  175. package/src/interaction_client/SilentCacheClient.ts +11 -3
  176. package/src/interaction_client/SilentIframeClient.ts +53 -17
  177. package/src/interaction_client/StandardInteractionClient.ts +1 -1
  178. package/src/interaction_handler/SilentHandler.ts +177 -233
  179. package/src/naa/AccountInfo.ts +17 -0
  180. package/src/naa/AccountRequests.ts +16 -0
  181. package/src/naa/AuthBridge.ts +16 -0
  182. package/src/naa/BridgeCapabilities.ts +8 -0
  183. package/src/naa/BridgeError.ts +18 -0
  184. package/src/naa/BridgeProxy.ts +230 -0
  185. package/src/naa/BridgeRequest.ts +12 -0
  186. package/src/naa/BridgeRequestEnvelope.ts +46 -0
  187. package/src/naa/BridgeResponseEnvelope.ts +21 -0
  188. package/src/naa/BridgeStatusCode.ts +15 -0
  189. package/src/naa/IBridgeProxy.ts +25 -0
  190. package/src/naa/InitializeBridgeResponse.ts +12 -0
  191. package/src/naa/TokenRequest.ts +26 -0
  192. package/src/naa/TokenResponse.ts +61 -0
  193. package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
  194. package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
  195. package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
  196. package/src/packageMetadata.ts +1 -1
  197. package/src/utils/BrowserUtils.ts +133 -125
  198. package/dist/utils/BrowserStringUtils.d.ts +0 -22
  199. package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
  200. package/dist/utils/BrowserStringUtils.mjs +0 -144
  201. package/dist/utils/BrowserStringUtils.mjs.map +0 -1
  202. package/src/utils/BrowserStringUtils.ts +0 -143
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { BridgeStatusCode } from "./BridgeStatusCode";
7
+
8
+ export type BridgeError = {
9
+ status: BridgeStatusCode;
10
+ code: string; // auth_flow_last_error such as invalid_grant
11
+ subError: string; // server_suberror_code such as consent_required
12
+ description: string;
13
+ properties: object; // additional telemetry info
14
+ };
15
+
16
+ export function isBridgeError(error: unknown): error is BridgeError {
17
+ return (error as BridgeError).status !== undefined;
18
+ }
@@ -0,0 +1,230 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AccountInfo } from "./AccountInfo";
7
+ import {
8
+ AccountByHomeIdRequest,
9
+ AccountByLocalIdRequest,
10
+ AccountByUsernameRequest,
11
+ } from "./AccountRequests";
12
+ import { AuthBridge } from "./AuthBridge";
13
+ import { BridgeCapabilities } from "./BridgeCapabilities";
14
+ import { BridgeRequest } from "./BridgeRequest";
15
+ import { BridgeRequestEnvelope, BridgeMethods } from "./BridgeRequestEnvelope";
16
+ import { BridgeResponseEnvelope } from "./BridgeResponseEnvelope";
17
+ import { IBridgeProxy } from "./IBridgeProxy";
18
+ import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
19
+ import { TokenRequest } from "./TokenRequest";
20
+ import { TokenResponse } from "./TokenResponse";
21
+
22
+ declare global {
23
+ interface Window {
24
+ nestedAppAuthBridge: AuthBridge;
25
+ }
26
+ }
27
+
28
+ /**
29
+ * BridgeProxy
30
+ * Provides a proxy for accessing a bridge to a host app and/or
31
+ * platform broker
32
+ */
33
+ export class BridgeProxy implements IBridgeProxy {
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
+ static bridgeRequests: any[] = [];
36
+ static crypto: Crypto;
37
+ sdkName: string;
38
+ sdkVersion: string;
39
+ capabilities: BridgeCapabilities;
40
+
41
+ /**
42
+ * initializeNestedAppAuthBridge - Initializes the bridge to the host app
43
+ * @returns a promise that resolves to an InitializeBridgeResponse or rejects with an Error
44
+ * @remarks This method will be called by the create factory method
45
+ * @remarks If the bridge is not available, this method will throw an error
46
+ */
47
+ protected static async initializeNestedAppAuthBridge(): Promise<InitializeBridgeResponse> {
48
+ if (window === undefined) {
49
+ throw new Error("window is undefined");
50
+ }
51
+ if (window.nestedAppAuthBridge === undefined) {
52
+ throw new Error("window.nestedAppAuthBridge is undefined");
53
+ }
54
+ if (window.crypto === undefined) {
55
+ throw new Error("window.crypto is undefined");
56
+ }
57
+
58
+ try {
59
+ BridgeProxy.crypto = window.crypto;
60
+
61
+ window.nestedAppAuthBridge.addEventListener(
62
+ "message",
63
+ (response: string) => {
64
+ const responseEnvelope: BridgeResponseEnvelope =
65
+ JSON.parse(response);
66
+ const request = BridgeProxy.bridgeRequests.find(
67
+ (element) =>
68
+ element.requestId === responseEnvelope.requestId
69
+ );
70
+ if (request !== undefined) {
71
+ BridgeProxy.bridgeRequests.splice(
72
+ BridgeProxy.bridgeRequests.indexOf(request),
73
+ 1
74
+ );
75
+ if (responseEnvelope.success) {
76
+ request.resolve(responseEnvelope.body);
77
+ } else {
78
+ request.reject(responseEnvelope.body);
79
+ }
80
+ }
81
+ }
82
+ );
83
+
84
+ const promise = new Promise<InitializeBridgeResponse>(
85
+ (resolve, reject) => {
86
+ const message: BridgeRequestEnvelope = {
87
+ messageType: "NestedAppAuthRequest",
88
+ method: "GetInitContext",
89
+ requestId: BridgeProxy.getRandomId(),
90
+ };
91
+ const request: BridgeRequest<InitializeBridgeResponse> = {
92
+ requestId: message.requestId,
93
+ method: message.method,
94
+ resolve: resolve,
95
+ reject: reject,
96
+ };
97
+ BridgeProxy.bridgeRequests.push(request);
98
+ window.nestedAppAuthBridge.postMessage(
99
+ JSON.stringify(message)
100
+ );
101
+ }
102
+ );
103
+
104
+ return promise;
105
+ } catch (error) {
106
+ window.console.log(error);
107
+ throw error;
108
+ }
109
+ }
110
+
111
+ public static getRandomId(): string {
112
+ return BridgeProxy.crypto.randomUUID();
113
+ }
114
+
115
+ /**
116
+ * getTokenInteractive - Attempts to get a token interactively from the bridge
117
+ * @param request A token request
118
+ * @returns a promise that resolves to a token response or rejects with a BridgeError
119
+ */
120
+ public getTokenInteractive(request: TokenRequest): Promise<TokenResponse> {
121
+ return this.sendRequest<TokenResponse>("GetTokenPopup", request);
122
+ }
123
+
124
+ /**
125
+ * getTokenSilent Attempts to get a token silently from the bridge
126
+ * @param request A token request
127
+ * @returns a promise that resolves to a token response or rejects with a BridgeError
128
+ */
129
+ public getTokenSilent(request: TokenRequest): Promise<TokenResponse> {
130
+ return this.sendRequest<TokenResponse>("GetToken", request);
131
+ }
132
+
133
+ /**
134
+ * getAccountInfo - Gets account information from the bridge
135
+ *
136
+ * @param request A request for account information
137
+ */
138
+ public getAccountInfo(
139
+ request:
140
+ | AccountByHomeIdRequest
141
+ | AccountByLocalIdRequest
142
+ | AccountByUsernameRequest
143
+ ): Promise<AccountInfo> {
144
+ let method: BridgeMethods = "GetAccountByHomeId";
145
+
146
+ if ((request as AccountByHomeIdRequest).homeAccountId !== undefined) {
147
+ method = "GetAccountByHomeId";
148
+ }
149
+
150
+ if ((request as AccountByLocalIdRequest).localAccountId !== undefined) {
151
+ method = "GetAccountByLocalId";
152
+ }
153
+
154
+ if ((request as AccountByUsernameRequest).username !== undefined) {
155
+ method = "GetAccountByUsername";
156
+ }
157
+
158
+ return this.sendRequest<AccountInfo>(method, request);
159
+ }
160
+
161
+ public getActiveAccount(): Promise<AccountInfo> {
162
+ return this.sendRequest<AccountInfo>("GetActiveAccount", undefined);
163
+ }
164
+
165
+ /**
166
+ * A method used to send a request to the bridge
167
+ * @param request A token request
168
+ * @returns a promise that resolves to a response of provided type or rejects with a BridgeError
169
+ */
170
+ private sendRequest<TResponse>(
171
+ method: BridgeMethods,
172
+ request:
173
+ | TokenRequest
174
+ | AccountByHomeIdRequest
175
+ | AccountByLocalIdRequest
176
+ | AccountByUsernameRequest
177
+ | undefined
178
+ ): Promise<TResponse> {
179
+ const message: BridgeRequestEnvelope = {
180
+ messageType: "NestedAppAuthRequest",
181
+ method: method,
182
+ requestId: BridgeProxy.getRandomId(),
183
+ body: request,
184
+ };
185
+
186
+ const promise = new Promise<TResponse>((resolve, reject) => {
187
+ const request: BridgeRequest<TResponse> = {
188
+ requestId: message.requestId,
189
+ method: message.method,
190
+ resolve: resolve,
191
+ reject: reject,
192
+ };
193
+ BridgeProxy.bridgeRequests.push(request);
194
+ window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
195
+ });
196
+
197
+ return promise;
198
+ }
199
+
200
+ /**
201
+ * Private constructor for BridgeProxy
202
+ * @param sdkName The name of the SDK being used to make requests on behalf of the app
203
+ * @param sdkVersion The version of the SDK being used to make requests on behalf of the app
204
+ * @param capabilities The capabilities of the bridge / SDK / platform broker
205
+ */
206
+ private constructor(
207
+ sdkName: string,
208
+ sdkVersion: string,
209
+ capabilities: BridgeCapabilities
210
+ ) {
211
+ this.sdkName = sdkName;
212
+ this.sdkVersion = sdkVersion;
213
+ this.capabilities = capabilities;
214
+ }
215
+
216
+ /**
217
+ * Factory method for creating an implementation of IBridgeProxy
218
+ * @returns A promise that resolves to a BridgeProxy implementation
219
+ */
220
+ public static async create(): Promise<IBridgeProxy> {
221
+ const response = await BridgeProxy.initializeNestedAppAuthBridge();
222
+ return new BridgeProxy(
223
+ response.sdkName,
224
+ response.sdkVersion,
225
+ response.capabilities
226
+ );
227
+ }
228
+ }
229
+
230
+ export default BridgeProxy;
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export type BridgeRequest<TResponse> = {
7
+ requestId: string;
8
+ method: string;
9
+ resolve: (value: TResponse | PromiseLike<TResponse>) => void;
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ reject: (reason?: any) => void;
12
+ };
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { TokenRequest } from "./TokenRequest";
7
+ import {
8
+ AccountByHomeIdRequest,
9
+ AccountByLocalIdRequest,
10
+ AccountByUsernameRequest,
11
+ } from "./AccountRequests";
12
+
13
+ export type BridgeMethods =
14
+ | "GetToken"
15
+ | "GetActiveAccount"
16
+ | "GetAllAccounts"
17
+ | "GetAccountByHomeId"
18
+ | "GetAccountByLocalId"
19
+ | "GetAccountByUsername"
20
+ | "GetInitContext"
21
+ | "GetTokenPopup";
22
+
23
+ export type BridgeRequestEnvelope = {
24
+ messageType: "NestedAppAuthRequest";
25
+ method: BridgeMethods;
26
+ sendTime?: number; // Assume this is epoch
27
+ clientLibrary?: string;
28
+ clientLibraryVersion?: string;
29
+ requestId: string;
30
+ body?:
31
+ | TokenRequest
32
+ | AccountByHomeIdRequest
33
+ | AccountByLocalIdRequest
34
+ | AccountByUsernameRequest;
35
+ };
36
+
37
+ export function isBridgeRequestEnvelope(
38
+ obj: unknown
39
+ ): obj is BridgeRequestEnvelope {
40
+ return (
41
+ (obj as BridgeRequestEnvelope).messageType !== undefined &&
42
+ (obj as BridgeRequestEnvelope).messageType === "NestedAppAuthRequest" &&
43
+ (obj as BridgeRequestEnvelope).method !== undefined &&
44
+ (obj as BridgeRequestEnvelope).requestId !== undefined
45
+ );
46
+ }
@@ -0,0 +1,21 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { BridgeError } from "./BridgeError";
7
+ import { TokenResponse } from "./TokenResponse";
8
+ import { AccountInfo } from "./AccountInfo";
9
+ import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
10
+
11
+ export type BridgeResponseEnvelope = {
12
+ messageType: "NestedAppAuthResponse";
13
+ requestId: string;
14
+ success: boolean; // false if body is error
15
+ body:
16
+ | TokenResponse
17
+ | BridgeError
18
+ | AccountInfo
19
+ | AccountInfo[]
20
+ | InitializeBridgeResponse;
21
+ };
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export enum BridgeStatusCode {
7
+ USER_INTERACTION_REQUIRED = "USER_INTERACTION_REQUIRED",
8
+ USER_CANCEL = "USER_CANCEL",
9
+ NO_NETWORK = "NO_NETWORK",
10
+ TRANSIENT_ERROR = "TRANSIENT_ERROR",
11
+ PERSISTENT_ERROR = "PERSISTENT_ERROR",
12
+ DISABLED = "DISABLED",
13
+ ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE",
14
+ NESTED_APP_AUTH_UNAVAILABLE = "NESTED_APP_AUTH_UNAVAILABLE", // NAA is unavailable in the current context, can retry with standard browser based auth
15
+ }
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AccountInfo } from "./AccountInfo";
7
+ import {
8
+ AccountByHomeIdRequest,
9
+ AccountByLocalIdRequest,
10
+ AccountByUsernameRequest,
11
+ } from "./AccountRequests";
12
+ import { TokenRequest } from "./TokenRequest";
13
+ import { TokenResponse } from "./TokenResponse";
14
+
15
+ export interface IBridgeProxy {
16
+ getTokenInteractive(request: TokenRequest): Promise<TokenResponse>;
17
+ getTokenSilent(request: TokenRequest): Promise<TokenResponse>;
18
+ getAccountInfo(
19
+ request:
20
+ | AccountByHomeIdRequest
21
+ | AccountByLocalIdRequest
22
+ | AccountByUsernameRequest
23
+ ): Promise<AccountInfo>;
24
+ getActiveAccount(): Promise<AccountInfo>;
25
+ }
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { BridgeCapabilities } from "./BridgeCapabilities";
7
+
8
+ export interface InitializeBridgeResponse {
9
+ capabilities: BridgeCapabilities;
10
+ sdkName: string;
11
+ sdkVersion: string;
12
+ }
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export type TokenRequest = {
7
+ userObjectId?: string; // Account identifier used by OneAuth
8
+ clientId: string;
9
+ authority?: string;
10
+ scope: string;
11
+ correlationId: string;
12
+ prompt?: string; // Prompt used to identify interactive request
13
+ nonce?: string;
14
+ claims?: string;
15
+ state?: string;
16
+ reqCnf?: string; // Having OneAuth own the keypair is better for hardware token binding support
17
+ keyId?: string; // Having OneAuth own the keypair is better for hardware token binding support
18
+ authenticationScheme?: string;
19
+ shrClaims?: string;
20
+ shrNonce?: string;
21
+ clientCapabilities?: string[]; // CP1 for CAE support
22
+ resourceRequestMethod?: string;
23
+ resourceRequestUri?: string;
24
+ extendedExpiryToken?: boolean;
25
+ extraParameters?: Map<string, string>;
26
+ };
@@ -0,0 +1,61 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AccountInfo } from "./AccountInfo";
7
+
8
+ export type TokenResponse = {
9
+ access_token: string;
10
+ account: AccountInfo;
11
+ client_info: string;
12
+ expires_in: number;
13
+ id_token: string;
14
+ properties: TokenResponseProperties | null;
15
+ scope: string;
16
+ state: string;
17
+ shr?: string; // token binding enabled at native layer it is the access token, not the signing keys
18
+ extendedLifetimeToken?: boolean;
19
+ };
20
+
21
+ export type TokenResponseProperties = {
22
+ MATS?: string;
23
+ };
24
+
25
+ /*
26
+ * Sample response below
27
+ * {
28
+ * "body":{
29
+ * "access_token":"<token>",
30
+ * "account":{"environment":"login.microsoftonline.com",
31
+ * "homeAccountId":"2995ae49-d9dd-409d-8d62-ba969ce58a81.51178b70-16cc-41b5-bef1-ae1808139065",
32
+ * "idTokenClaims":{
33
+ * "aud":"a076930c-cfc9-4ebd-9607-7963bccbf666",
34
+ * "exp":"1680557128",
35
+ * "graph_url":"https://graph.microsoft.com",
36
+ * "iat":"1680553228",
37
+ * "iss":"https://login.microsoftonline.com/51178b70-16cc-41b5-bef1-ae1808139065/v2.0",
38
+ * "name":"Adele Vance",
39
+ * "nbf":"1680553228",
40
+ * "oid":"2995ae49-d9dd-409d-8d62-ba969ce58a81",
41
+ * "preferred_username":"AdeleV@vc6w6.onmicrosoft.com",
42
+ * "rh":"0.AX0AcIsXUcwWtUG-8a4YCBOQZQyTdqDJz71Olgd5Y7zL9maaAHs.",
43
+ * "sovereignty2":"Global",
44
+ * "sub":"wtxUI1WD2C--Bl8vN1p-P-VgadGud8QSqXD4Vp5i9sc",
45
+ * "tid":"51178b70-16cc-41b5-bef1-ae1808139065",
46
+ * "uti":"39pEKQyYDU6SXjD_phaCAA",
47
+ * "ver":"2.0"},
48
+ * "localAccountId":"2995ae49-d9dd-409d-8d62-ba969ce58a81",
49
+ * "name":"Adele Vance",
50
+ * "tenantId":"51178b70-16cc-41b5-bef1-ae1808139065",
51
+ * "username":"AdeleV@vc6w6.onmicrosoft.com"
52
+ * },
53
+ * "client_info":"",
54
+ * "expires_in":4290,
55
+ * "id_token":"",
56
+ * "properties":null,
57
+ * "scope":"User.Read",
58
+ * "state":""},
59
+ * "requestId":"8863d6e8-a539-43e3-84b6-ca1bf64943f3",
60
+ * "success":true}
61
+ */