@azure/msal-node 2.0.1 → 2.1.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.
- package/README.md +3 -1
- package/dist/cache/NodeStorage.cjs +1 -1
- package/dist/cache/NodeStorage.cjs.map +1 -1
- package/dist/cache/NodeStorage.d.ts +1 -1
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +1 -1
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.cjs +5 -9
- package/dist/cache/TokenCache.cjs.map +1 -1
- package/dist/cache/TokenCache.d.ts +3 -3
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +6 -10
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.cjs +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.cjs.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.d.ts +2 -2
- package/dist/cache/distributed/DistributedCachePlugin.d.ts.map +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.mjs.map +1 -1
- package/dist/cache/serializer/Deserializer.cjs +2 -4
- package/dist/cache/serializer/Deserializer.cjs.map +1 -1
- package/dist/cache/serializer/Deserializer.d.ts +1 -1
- package/dist/cache/serializer/Deserializer.d.ts.map +1 -1
- package/dist/cache/serializer/Deserializer.mjs +3 -5
- package/dist/cache/serializer/Deserializer.mjs.map +1 -1
- package/dist/cache/serializer/Serializer.cjs +1 -1
- package/dist/cache/serializer/Serializer.cjs.map +1 -1
- package/dist/cache/serializer/Serializer.d.ts +1 -1
- package/dist/cache/serializer/Serializer.d.ts.map +1 -1
- package/dist/cache/serializer/Serializer.mjs +1 -1
- package/dist/cache/serializer/Serializer.mjs.map +1 -1
- package/dist/client/ClientApplication.cjs +2 -2
- package/dist/client/ClientApplication.cjs.map +1 -1
- package/dist/client/ClientApplication.d.ts +10 -10
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/ClientApplication.mjs +2 -2
- package/dist/client/ClientApplication.mjs.map +1 -1
- package/dist/client/ClientAssertion.cjs +3 -3
- package/dist/client/ClientAssertion.cjs.map +1 -1
- package/dist/client/ClientAssertion.d.ts +1 -1
- package/dist/client/ClientAssertion.d.ts.map +1 -1
- package/dist/client/ClientAssertion.mjs +3 -3
- package/dist/client/ClientAssertion.mjs.map +1 -1
- package/dist/client/ClientCredentialClient.cjs +26 -4
- package/dist/client/ClientCredentialClient.cjs.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts +1 -0
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.mjs +27 -5
- package/dist/client/ClientCredentialClient.mjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.cjs +4 -5
- package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts +5 -5
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +5 -6
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.cjs +3 -3
- package/dist/client/DeviceCodeClient.cjs.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.mjs +4 -4
- package/dist/client/DeviceCodeClient.mjs.map +1 -1
- package/dist/client/IConfidentialClientApplication.d.ts +8 -8
- package/dist/client/IConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/IPublicClientApplication.d.ts +9 -9
- package/dist/client/IPublicClientApplication.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.cjs +7 -8
- package/dist/client/OnBehalfOfClient.cjs.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +7 -8
- package/dist/client/OnBehalfOfClient.mjs.map +1 -1
- package/dist/client/PublicClientApplication.cjs +36 -29
- package/dist/client/PublicClientApplication.cjs.map +1 -1
- package/dist/client/PublicClientApplication.d.ts +7 -7
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.mjs +40 -33
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.cjs +2 -2
- package/dist/client/UsernamePasswordClient.cjs.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.mjs +2 -2
- package/dist/client/UsernamePasswordClient.mjs.map +1 -1
- package/dist/config/Configuration.cjs +2 -2
- package/dist/config/Configuration.cjs.map +1 -1
- package/dist/config/Configuration.d.ts +5 -4
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +2 -2
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/crypto/CryptoProvider.cjs +1 -1
- package/dist/crypto/CryptoProvider.cjs.map +1 -1
- package/dist/crypto/CryptoProvider.mjs +1 -1
- package/dist/crypto/CryptoProvider.mjs.map +1 -1
- package/dist/crypto/GuidGenerator.cjs +1 -1
- package/dist/crypto/GuidGenerator.cjs.map +1 -1
- package/dist/crypto/GuidGenerator.mjs +1 -1
- package/dist/crypto/GuidGenerator.mjs.map +1 -1
- package/dist/crypto/HashUtils.cjs +1 -1
- package/dist/crypto/HashUtils.cjs.map +1 -1
- package/dist/crypto/HashUtils.mjs +1 -1
- package/dist/crypto/HashUtils.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.cjs +1 -1
- package/dist/crypto/PkceGenerator.cjs.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs.map +1 -1
- package/dist/error/NodeAuthError.cjs +1 -1
- package/dist/error/NodeAuthError.cjs.map +1 -1
- package/dist/error/NodeAuthError.mjs +1 -1
- package/dist/error/NodeAuthError.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +32 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internals.cjs +1 -1
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.d.ts +2 -2
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/internals.mjs.map +1 -1
- package/dist/network/HttpClient.cjs +10 -9
- package/dist/network/HttpClient.cjs.map +1 -1
- package/dist/network/HttpClient.d.ts.map +1 -1
- package/dist/network/HttpClient.mjs +3 -2
- package/dist/network/HttpClient.mjs.map +1 -1
- package/dist/network/LoopbackClient.cjs +2 -2
- package/dist/network/LoopbackClient.cjs.map +1 -1
- package/dist/network/LoopbackClient.d.ts +1 -1
- package/dist/network/LoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.mjs +5 -5
- package/dist/network/LoopbackClient.mjs.map +1 -1
- package/dist/packageMetadata.cjs +2 -2
- package/dist/packageMetadata.cjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/packageMetadata.mjs.map +1 -1
- package/dist/request/InteractiveRequest.d.ts +2 -2
- package/dist/request/InteractiveRequest.d.ts.map +1 -1
- package/dist/utils/Constants.cjs +1 -11
- package/dist/utils/Constants.cjs.map +1 -1
- package/dist/utils/Constants.d.ts +0 -10
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +2 -11
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/EncodingUtils.cjs +1 -1
- package/dist/utils/EncodingUtils.cjs.map +1 -1
- package/dist/utils/EncodingUtils.mjs +1 -1
- package/dist/utils/EncodingUtils.mjs.map +1 -1
- package/dist/utils/NetworkUtils.cjs +1 -1
- package/dist/utils/NetworkUtils.cjs.map +1 -1
- package/dist/utils/NetworkUtils.mjs +1 -1
- package/dist/utils/NetworkUtils.mjs.map +1 -1
- package/package.json +9 -6
- package/src/cache/ITokenCache.ts +24 -0
- package/src/cache/NodeStorage.ts +533 -0
- package/src/cache/TokenCache.ts +358 -0
- package/src/cache/distributed/DistributedCachePlugin.ts +56 -0
- package/src/cache/distributed/ICacheClient.ts +23 -0
- package/src/cache/distributed/IPartitionManager.ts +35 -0
- package/src/cache/serializer/Deserializer.ts +218 -0
- package/src/cache/serializer/Serializer.ts +173 -0
- package/src/cache/serializer/SerializerTypes.ts +121 -0
- package/src/client/ClientApplication.ts +595 -0
- package/src/client/ClientAssertion.ts +160 -0
- package/src/client/ClientCredentialClient.ts +348 -0
- package/src/client/ConfidentialClientApplication.ts +261 -0
- package/src/client/DeviceCodeClient.ts +360 -0
- package/src/client/IConfidentialClientApplication.ts +72 -0
- package/src/client/IPublicClientApplication.ts +72 -0
- package/src/client/OnBehalfOfClient.ts +361 -0
- package/src/client/PublicClientApplication.ts +283 -0
- package/src/client/UsernamePasswordClient.ts +180 -0
- package/src/config/Configuration.ts +201 -0
- package/src/crypto/CryptoProvider.ts +98 -0
- package/src/crypto/GuidGenerator.ts +28 -0
- package/src/crypto/HashUtils.ts +17 -0
- package/src/crypto/PkceGenerator.ts +63 -0
- package/src/error/NodeAuthError.ts +117 -0
- package/src/index.ts +121 -0
- package/src/internals.ts +12 -0
- package/src/network/HttpClient.ts +425 -0
- package/src/network/ILoopbackClient.ts +19 -0
- package/src/network/LoopbackClient.ts +126 -0
- package/src/packageMetadata.ts +3 -0
- package/src/request/AuthorizationCodeRequest.ts +39 -0
- package/src/request/AuthorizationUrlRequest.ts +50 -0
- package/src/request/ClientCredentialRequest.ts +29 -0
- package/src/request/DeviceCodeRequest.ts +34 -0
- package/src/request/InteractiveRequest.ts +39 -0
- package/src/request/OnBehalfOfRequest.ts +30 -0
- package/src/request/RefreshTokenRequest.ts +34 -0
- package/src/request/SignOutRequest.ts +11 -0
- package/src/request/SilentFlowRequest.ts +32 -0
- package/src/request/UsernamePasswordRequest.ts +36 -0
- package/src/utils/Constants.ts +103 -0
- package/src/utils/EncodingUtils.ts +50 -0
- package/src/utils/NetworkUtils.ts +49 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { ICrypto, PkceCodes } from "@azure/msal-common";
|
|
7
|
+
import { GuidGenerator } from "./GuidGenerator.js";
|
|
8
|
+
import { EncodingUtils } from "../utils/EncodingUtils.js";
|
|
9
|
+
import { PkceGenerator } from "./PkceGenerator.js";
|
|
10
|
+
import { HashUtils } from "./HashUtils.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This class implements MSAL node's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and
|
|
14
|
+
* implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export class CryptoProvider implements ICrypto {
|
|
18
|
+
private pkceGenerator: PkceGenerator;
|
|
19
|
+
private guidGenerator: GuidGenerator;
|
|
20
|
+
private hashUtils: HashUtils;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
// Browser crypto needs to be validated first before any other classes can be set.
|
|
24
|
+
this.pkceGenerator = new PkceGenerator();
|
|
25
|
+
this.guidGenerator = new GuidGenerator();
|
|
26
|
+
this.hashUtils = new HashUtils();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new random GUID - used to populate state and nonce.
|
|
31
|
+
* @returns string (GUID)
|
|
32
|
+
*/
|
|
33
|
+
createNewGuid(): string {
|
|
34
|
+
return this.guidGenerator.generateGuid();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Encodes input string to base64.
|
|
39
|
+
* @param input - string to be encoded
|
|
40
|
+
*/
|
|
41
|
+
base64Encode(input: string): string {
|
|
42
|
+
return EncodingUtils.base64Encode(input);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Decodes input string from base64.
|
|
47
|
+
* @param input - string to be decoded
|
|
48
|
+
*/
|
|
49
|
+
base64Decode(input: string): string {
|
|
50
|
+
return EncodingUtils.base64Decode(input);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Generates PKCE codes used in Authorization Code Flow.
|
|
55
|
+
*/
|
|
56
|
+
generatePkceCodes(): Promise<PkceCodes> {
|
|
57
|
+
return this.pkceGenerator.generatePkceCodes();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Generates a keypair, stores it and returns a thumbprint - not yet implemented for node
|
|
62
|
+
*/
|
|
63
|
+
getPublicKeyThumbprint(): Promise<string> {
|
|
64
|
+
throw new Error("Method not implemented.");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Removes cryptographic keypair from key store matching the keyId passed in
|
|
69
|
+
* @param kid
|
|
70
|
+
*/
|
|
71
|
+
removeTokenBindingKey(): Promise<boolean> {
|
|
72
|
+
throw new Error("Method not implemented.");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Removes all cryptographic keys from Keystore
|
|
77
|
+
*/
|
|
78
|
+
clearKeystore(): Promise<boolean> {
|
|
79
|
+
throw new Error("Method not implemented.");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Signs the given object as a jwt payload with private key retrieved by given kid - currently not implemented for node
|
|
84
|
+
*/
|
|
85
|
+
signJwt(): Promise<string> {
|
|
86
|
+
throw new Error("Method not implemented.");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns the SHA-256 hash of an input string
|
|
91
|
+
*/
|
|
92
|
+
async hashString(plainText: string): Promise<string> {
|
|
93
|
+
return EncodingUtils.base64EncodeUrl(
|
|
94
|
+
this.hashUtils.sha256(plainText).toString("base64"),
|
|
95
|
+
"base64"
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IGuidGenerator } from "@azure/msal-common";
|
|
7
|
+
import { v4 as uuidv4 } from "uuid";
|
|
8
|
+
|
|
9
|
+
export class GuidGenerator implements IGuidGenerator {
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* RFC4122: The version 4 UUID is meant for generating UUIDs from truly-random or pseudo-random numbers.
|
|
13
|
+
* uuidv4 generates guids from cryprtographically-string random
|
|
14
|
+
*/
|
|
15
|
+
generateGuid(): string {
|
|
16
|
+
return uuidv4();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* verifies if a string is GUID
|
|
21
|
+
* @param guid
|
|
22
|
+
*/
|
|
23
|
+
isGuid(guid: string): boolean {
|
|
24
|
+
const regexGuid =
|
|
25
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
26
|
+
return regexGuid.test(guid);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Hash } from "../utils/Constants.js";
|
|
7
|
+
import crypto from "crypto";
|
|
8
|
+
|
|
9
|
+
export class HashUtils {
|
|
10
|
+
/**
|
|
11
|
+
* generate 'SHA256' hash
|
|
12
|
+
* @param buffer
|
|
13
|
+
*/
|
|
14
|
+
sha256(buffer: string): Buffer {
|
|
15
|
+
return crypto.createHash(Hash.SHA256).update(buffer).digest();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Constants, PkceCodes } from "@azure/msal-common";
|
|
7
|
+
import { CharSet, RANDOM_OCTET_SIZE } from "../utils/Constants.js";
|
|
8
|
+
import { EncodingUtils } from "../utils/EncodingUtils.js";
|
|
9
|
+
import { HashUtils } from "./HashUtils.js";
|
|
10
|
+
import crypto from "crypto";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* https://tools.ietf.org/html/rfc7636#page-8
|
|
14
|
+
*/
|
|
15
|
+
export class PkceGenerator {
|
|
16
|
+
private hashUtils: HashUtils;
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
this.hashUtils = new HashUtils();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* generates the codeVerfier and the challenge from the codeVerfier
|
|
23
|
+
* reference: https://tools.ietf.org/html/rfc7636#section-4.1 and https://tools.ietf.org/html/rfc7636#section-4.2
|
|
24
|
+
*/
|
|
25
|
+
async generatePkceCodes(): Promise<PkceCodes> {
|
|
26
|
+
const verifier = this.generateCodeVerifier();
|
|
27
|
+
const challenge = this.generateCodeChallengeFromVerifier(verifier);
|
|
28
|
+
return { verifier, challenge };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* generates the codeVerfier; reference: https://tools.ietf.org/html/rfc7636#section-4.1
|
|
33
|
+
*/
|
|
34
|
+
private generateCodeVerifier(): string {
|
|
35
|
+
const charArr = [];
|
|
36
|
+
const maxNumber = 256 - (256 % CharSet.CV_CHARSET.length);
|
|
37
|
+
while (charArr.length <= RANDOM_OCTET_SIZE) {
|
|
38
|
+
const byte = crypto.randomBytes(1)[0];
|
|
39
|
+
if (byte >= maxNumber) {
|
|
40
|
+
/*
|
|
41
|
+
* Ignore this number to maintain randomness.
|
|
42
|
+
* Including it would result in an unequal distribution of characters after doing the modulo
|
|
43
|
+
*/
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const index = byte % CharSet.CV_CHARSET.length;
|
|
47
|
+
charArr.push(CharSet.CV_CHARSET[index]);
|
|
48
|
+
}
|
|
49
|
+
const verifier: string = charArr.join(Constants.EMPTY_STRING);
|
|
50
|
+
return EncodingUtils.base64EncodeUrl(verifier);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* generate the challenge from the codeVerfier; reference: https://tools.ietf.org/html/rfc7636#section-4.2
|
|
55
|
+
* @param codeVerifier
|
|
56
|
+
*/
|
|
57
|
+
private generateCodeChallengeFromVerifier(codeVerifier: string): string {
|
|
58
|
+
return EncodingUtils.base64EncodeUrl(
|
|
59
|
+
this.hashUtils.sha256(codeVerifier).toString("base64"),
|
|
60
|
+
"base64"
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AuthError } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* NodeAuthErrorMessage class containing string constants used by error codes and messages.
|
|
10
|
+
*/
|
|
11
|
+
export const NodeAuthErrorMessage = {
|
|
12
|
+
invalidLoopbackAddressType: {
|
|
13
|
+
code: "invalid_loopback_server_address_type",
|
|
14
|
+
desc: "Loopback server address is not type string. This is unexpected.",
|
|
15
|
+
},
|
|
16
|
+
unableToLoadRedirectUri: {
|
|
17
|
+
code: "unable_to_load_redirectUrl",
|
|
18
|
+
desc: "Loopback server callback was invoked without a url. This is unexpected.",
|
|
19
|
+
},
|
|
20
|
+
noAuthCodeInResponse: {
|
|
21
|
+
code: "no_auth_code_in_response",
|
|
22
|
+
desc: "No auth code found in the server response. Please check your network trace to determine what happened.",
|
|
23
|
+
},
|
|
24
|
+
noLoopbackServerExists: {
|
|
25
|
+
code: "no_loopback_server_exists",
|
|
26
|
+
desc: "No loopback server exists yet.",
|
|
27
|
+
},
|
|
28
|
+
loopbackServerAlreadyExists: {
|
|
29
|
+
code: "loopback_server_already_exists",
|
|
30
|
+
desc: "Loopback server already exists. Cannot create another.",
|
|
31
|
+
},
|
|
32
|
+
loopbackServerTimeout: {
|
|
33
|
+
code: "loopback_server_timeout",
|
|
34
|
+
desc: "Timed out waiting for auth code listener to be registered.",
|
|
35
|
+
},
|
|
36
|
+
stateNotFoundError: {
|
|
37
|
+
code: "state_not_found",
|
|
38
|
+
desc: "State not found. Please verify that the request originated from msal.",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export class NodeAuthError extends AuthError {
|
|
43
|
+
constructor(errorCode: string, errorMessage?: string) {
|
|
44
|
+
super(errorCode, errorMessage);
|
|
45
|
+
this.name = "NodeAuthError";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Creates an error thrown if loopback server address is of type string.
|
|
50
|
+
*/
|
|
51
|
+
static createInvalidLoopbackAddressTypeError(): NodeAuthError {
|
|
52
|
+
return new NodeAuthError(
|
|
53
|
+
NodeAuthErrorMessage.invalidLoopbackAddressType.code,
|
|
54
|
+
`${NodeAuthErrorMessage.invalidLoopbackAddressType.desc}`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Creates an error thrown if the loopback server is unable to get a url.
|
|
60
|
+
*/
|
|
61
|
+
static createUnableToLoadRedirectUrlError(): NodeAuthError {
|
|
62
|
+
return new NodeAuthError(
|
|
63
|
+
NodeAuthErrorMessage.unableToLoadRedirectUri.code,
|
|
64
|
+
`${NodeAuthErrorMessage.unableToLoadRedirectUri.desc}`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Creates an error thrown if the server response does not contain an auth code.
|
|
70
|
+
*/
|
|
71
|
+
static createNoAuthCodeInResponseError(): NodeAuthError {
|
|
72
|
+
return new NodeAuthError(
|
|
73
|
+
NodeAuthErrorMessage.noAuthCodeInResponse.code,
|
|
74
|
+
`${NodeAuthErrorMessage.noAuthCodeInResponse.desc}`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Creates an error thrown if the loopback server has not been spun up yet.
|
|
80
|
+
*/
|
|
81
|
+
static createNoLoopbackServerExistsError(): NodeAuthError {
|
|
82
|
+
return new NodeAuthError(
|
|
83
|
+
NodeAuthErrorMessage.noLoopbackServerExists.code,
|
|
84
|
+
`${NodeAuthErrorMessage.noLoopbackServerExists.desc}`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Creates an error thrown if a loopback server already exists when attempting to create another one.
|
|
90
|
+
*/
|
|
91
|
+
static createLoopbackServerAlreadyExistsError(): NodeAuthError {
|
|
92
|
+
return new NodeAuthError(
|
|
93
|
+
NodeAuthErrorMessage.loopbackServerAlreadyExists.code,
|
|
94
|
+
`${NodeAuthErrorMessage.loopbackServerAlreadyExists.desc}`
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates an error thrown if the loopback server times out registering the auth code listener.
|
|
100
|
+
*/
|
|
101
|
+
static createLoopbackServerTimeoutError(): NodeAuthError {
|
|
102
|
+
return new NodeAuthError(
|
|
103
|
+
NodeAuthErrorMessage.loopbackServerTimeout.code,
|
|
104
|
+
`${NodeAuthErrorMessage.loopbackServerTimeout.desc}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Creates an error thrown when the state is not present.
|
|
110
|
+
*/
|
|
111
|
+
static createStateNotFoundError(): NodeAuthError {
|
|
112
|
+
return new NodeAuthError(
|
|
113
|
+
NodeAuthErrorMessage.stateNotFoundError.code,
|
|
114
|
+
NodeAuthErrorMessage.stateNotFoundError.desc
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* @module @azure/msal-node
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Warning: This set of exports is purely intended to be used by other MSAL libraries, and should be considered potentially unstable. We strongly discourage using them directly, you do so at your own risk.
|
|
13
|
+
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import * as internals from "./internals.js";
|
|
17
|
+
export { internals };
|
|
18
|
+
|
|
19
|
+
// Interfaces
|
|
20
|
+
export { IPublicClientApplication } from "./client/IPublicClientApplication.js";
|
|
21
|
+
export { IConfidentialClientApplication } from "./client/IConfidentialClientApplication.js";
|
|
22
|
+
export { ITokenCache } from "./cache/ITokenCache.js";
|
|
23
|
+
export { ICacheClient } from "./cache/distributed/ICacheClient.js";
|
|
24
|
+
export { IPartitionManager } from "./cache/distributed/IPartitionManager.js";
|
|
25
|
+
export { ILoopbackClient } from "./network/ILoopbackClient.js";
|
|
26
|
+
|
|
27
|
+
// Clients and Configuration
|
|
28
|
+
export { PublicClientApplication } from "./client/PublicClientApplication.js";
|
|
29
|
+
export { ConfidentialClientApplication } from "./client/ConfidentialClientApplication.js";
|
|
30
|
+
export { ClientApplication } from "./client/ClientApplication.js";
|
|
31
|
+
export { ClientCredentialClient } from "./client/ClientCredentialClient.js";
|
|
32
|
+
export { DeviceCodeClient } from "./client/DeviceCodeClient.js";
|
|
33
|
+
export { OnBehalfOfClient } from "./client/OnBehalfOfClient.js";
|
|
34
|
+
export { UsernamePasswordClient } from "./client/UsernamePasswordClient.js";
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
Configuration,
|
|
38
|
+
buildAppConfiguration,
|
|
39
|
+
NodeAuthOptions,
|
|
40
|
+
NodeSystemOptions,
|
|
41
|
+
BrokerOptions,
|
|
42
|
+
NodeTelemetryOptions,
|
|
43
|
+
CacheOptions,
|
|
44
|
+
} from "./config/Configuration.js";
|
|
45
|
+
export { ClientAssertion } from "./client/ClientAssertion.js";
|
|
46
|
+
|
|
47
|
+
// Cache and Storage
|
|
48
|
+
export { TokenCache } from "./cache/TokenCache.js";
|
|
49
|
+
export { NodeStorage } from "./cache/NodeStorage.js";
|
|
50
|
+
export {
|
|
51
|
+
CacheKVStore,
|
|
52
|
+
JsonCache,
|
|
53
|
+
InMemoryCache,
|
|
54
|
+
SerializedAccountEntity,
|
|
55
|
+
SerializedIdTokenEntity,
|
|
56
|
+
SerializedAccessTokenEntity,
|
|
57
|
+
SerializedAppMetadataEntity,
|
|
58
|
+
SerializedRefreshTokenEntity,
|
|
59
|
+
} from "./cache/serializer/SerializerTypes.js";
|
|
60
|
+
export { DistributedCachePlugin } from "./cache/distributed/DistributedCachePlugin.js";
|
|
61
|
+
|
|
62
|
+
// Crypto
|
|
63
|
+
export { CryptoProvider } from "./crypto/CryptoProvider.js";
|
|
64
|
+
|
|
65
|
+
// Request objects
|
|
66
|
+
export type { AuthorizationCodeRequest } from "./request/AuthorizationCodeRequest.js";
|
|
67
|
+
export type { AuthorizationUrlRequest } from "./request/AuthorizationUrlRequest.js";
|
|
68
|
+
export type { ClientCredentialRequest } from "./request/ClientCredentialRequest.js";
|
|
69
|
+
export type { DeviceCodeRequest } from "./request/DeviceCodeRequest.js";
|
|
70
|
+
export type { OnBehalfOfRequest } from "./request/OnBehalfOfRequest.js";
|
|
71
|
+
export type { UsernamePasswordRequest } from "./request/UsernamePasswordRequest.js";
|
|
72
|
+
export type { RefreshTokenRequest } from "./request/RefreshTokenRequest.js";
|
|
73
|
+
export type { SilentFlowRequest } from "./request/SilentFlowRequest.js";
|
|
74
|
+
export type { InteractiveRequest } from "./request/InteractiveRequest.js";
|
|
75
|
+
export type { SignOutRequest } from "./request/SignOutRequest.js";
|
|
76
|
+
|
|
77
|
+
// Common Object Formats
|
|
78
|
+
export {
|
|
79
|
+
// Request
|
|
80
|
+
PromptValue,
|
|
81
|
+
ResponseMode,
|
|
82
|
+
AuthorizationCodePayload,
|
|
83
|
+
// Response
|
|
84
|
+
AuthenticationResult,
|
|
85
|
+
ServerAuthorizationCodeResponse,
|
|
86
|
+
IdTokenClaims,
|
|
87
|
+
// Cache
|
|
88
|
+
AccountInfo,
|
|
89
|
+
ValidCacheType,
|
|
90
|
+
// Error
|
|
91
|
+
AuthError,
|
|
92
|
+
AuthErrorMessage,
|
|
93
|
+
ClientAuthError,
|
|
94
|
+
ClientAuthErrorMessage,
|
|
95
|
+
ClientConfigurationError,
|
|
96
|
+
ClientConfigurationErrorMessage,
|
|
97
|
+
InteractionRequiredAuthError,
|
|
98
|
+
InteractionRequiredAuthErrorMessage,
|
|
99
|
+
ServerError,
|
|
100
|
+
// Network Interface
|
|
101
|
+
INetworkModule,
|
|
102
|
+
NetworkRequestOptions,
|
|
103
|
+
NetworkResponse,
|
|
104
|
+
// Logger
|
|
105
|
+
Logger,
|
|
106
|
+
LogLevel,
|
|
107
|
+
// ProtocolMode enum
|
|
108
|
+
ProtocolMode,
|
|
109
|
+
ICachePlugin,
|
|
110
|
+
TokenCacheContext,
|
|
111
|
+
ISerializableTokenCache,
|
|
112
|
+
// AzureCloudInstance enum
|
|
113
|
+
AzureCloudInstance,
|
|
114
|
+
AzureCloudOptions,
|
|
115
|
+
// IAppTokenProvider
|
|
116
|
+
IAppTokenProvider,
|
|
117
|
+
AppTokenProviderParameters,
|
|
118
|
+
AppTokenProviderResult,
|
|
119
|
+
} from "@azure/msal-common";
|
|
120
|
+
|
|
121
|
+
export { version } from "./packageMetadata.js";
|
package/src/internals.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Warning: This set of exports is purely intended to be used by other MSAL libraries, and should be considered potentially unstable. We strongly discourage using them directly, you do so at your own risk.
|
|
8
|
+
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export { Serializer } from "./cache/serializer/Serializer.js";
|
|
12
|
+
export { Deserializer } from "./cache/serializer/Deserializer.js";
|