Skip to content

Commit bedfd47

Browse files
author
Jian Shen
committed
Commit
1 parent 8972d9e commit bedfd47

22 files changed

+1182
-18
lines changed

lib/msal-native-auth/doc/tech-design/Tech Design.md

+818
Large diffs are not rendered by default.
Loading
Loading
Loading
Loading
Loading
Loading

lib/msal-native-auth/src/INativeAuthPublicClientApplication.ts

+20
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,34 @@ import {
1515
} from "./NativeAuthActionOptions.js";
1616

1717
export interface INativeAuthPublicClientApplication {
18+
/*
19+
* Gets the current account from the cache.
20+
* @param getAccountOptions - Options for getting the current cached account
21+
* @returns - A promise that resolves to GetAccountResult
22+
*/
1823
getCurrentAccount(
1924
getAccountOptions: GetAccountOptions
2025
): Promise<GetAccountResult>;
2126

27+
/*
28+
* Initiates the sign-in flow.
29+
* @param signInOptions - Options for the sign-in flow
30+
* @returns - A promise that resolves to SignInResult
31+
*/
2232
signIn(signInOptions: SignInOptions): Promise<SignInResult>;
2333

34+
/*
35+
* Initiates the sign-up flow.
36+
* @param signUpOptions - Options for the sign-up flow
37+
* @returns - A promise that resolves to SignUpResult
38+
*/
2439
signUp(signUpOptions: SignUpOptions): Promise<SignUpResult>;
2540

41+
/*
42+
* Initiates the reset password flow.
43+
* @param resetPasswordOptions - Options for the reset password flow
44+
* @returns - A promise that resolves to ResetPasswordStartResult
45+
*/
2646
resetPassword(
2747
resetPasswordOptions: ResetPasswordOptions
2848
): Promise<ResetPasswordStartResult>;

lib/msal-native-auth/src/NativeAuthPublicClientApplication.ts

+29
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,21 @@ export class NativeAuthPublicClientApplication
2626
{
2727
private readonly nativeAuthController: NativeAuthStandardController;
2828

29+
/*
30+
* Creates a new instance of a PublicClientApplication with the given configuration.
31+
* @param config - A configuration object for the PublicClientApplication instance
32+
*/
2933
static create(
3034
config: NativeAuthConfiguration
3135
): NativeAuthPublicClientApplication {
3236
return new NativeAuthPublicClientApplication(config);
3337
}
3438

39+
/*
40+
* Creates a new instance of a PublicClientApplication with the given configuration and controller.
41+
* @param config - A configuration object for the PublicClientApplication instance
42+
* @param controller - A controller object for the PublicClientApplication instance
43+
*/
3544
constructor(
3645
config: NativeAuthConfiguration,
3746
controller?: INativeAuthStardardController
@@ -45,6 +54,11 @@ export class NativeAuthPublicClientApplication
4554
this.nativeAuthController = nativeAuthController;
4655
}
4756

57+
/*
58+
* Gets the current account from the cache.
59+
* @param getAccountOptions - Options for getting the current cached account
60+
* @returns - A promise that resolves to GetAccountResult
61+
*/
4862
getCurrentAccount(
4963
getAccountOptions: GetAccountOptions
5064
): Promise<GetAccountResult> {
@@ -53,16 +67,31 @@ export class NativeAuthPublicClientApplication
5367
);
5468
}
5569

70+
/*
71+
* Initiates the sign-in flow.
72+
* @param signInOptions - Options for the sign-in flow
73+
* @returns - A promise that resolves to SignInResult
74+
*/
5675
signIn(signInOptions: SignInOptions): Promise<SignInResult> {
5776
return this.nativeAuthController.signIn(signInOptions);
5877
}
5978

79+
/*
80+
* Initiates the sign-up flow.
81+
* @param signUpOptions - Options for the sign-up flow
82+
* @returns - A promise that resolves to SignUpResult
83+
*/
6084
signUp(signUpOptions: SignUpOptions): Promise<SignUpResult> {
6185
throw new Error(
6286
`Method not implemented with parameter ${signUpOptions}`
6387
);
6488
}
6589

90+
/*
91+
* Initiates the reset password flow.
92+
* @param resetPasswordOptions - Options for the reset password flow
93+
* @returns - A promise that resolves to ResetPasswordStartResult
94+
*/
6695
resetPassword(
6796
resetPasswordOptions: ResetPasswordOptions
6897
): Promise<ResetPasswordStartResult> {

lib/msal-native-auth/src/auth_flow/data/AccountInfo.ts

+31
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ import {
1717
TokenClaims,
1818
} from "@azure/msal-browser";
1919

20+
/*
21+
* Account information.
22+
*/
2023
export class AccountInfo {
24+
/*
25+
* Constructor
26+
* @param account - Account data
27+
* @param correlationId - Correlation id
28+
* @param config - Configuration
29+
*/
2130
constructor(
2231
private readonly account: AccountData,
2332
private readonly correlationId: string,
@@ -36,18 +45,34 @@ export class AccountInfo {
3645
}
3746
}
3847

48+
/*
49+
* Signs the current user out
50+
* @returns The result of the operation.
51+
*/
3952
signOut(): Promise<SignOutResult> {
4053
throw new Error("Method not implemented.");
4154
}
4255

56+
/*
57+
* Gets the account data.
58+
* @returns The account data.
59+
*/
4360
getAccount(): AccountData {
4461
return this.account;
4562
}
4663

64+
/*
65+
* Gets the account id-token.
66+
* @returns The account id-token.
67+
*/
4768
getIdToken(): string | undefined {
4869
return this.account.idToken;
4970
}
5071

72+
/*
73+
* Gets the token claims.
74+
* @returns The token claims.
75+
*/
5176
getClaims():
5277
| (TokenClaims & {
5378
[key: string]:
@@ -62,6 +87,12 @@ export class AccountInfo {
6287
return this.account.idTokenClaims;
6388
}
6489

90+
/*
91+
* Gets the access token from cache.
92+
* @param forceRefresh - Force a token refresh
93+
* @param scopes - The scopes to request
94+
* @returns The result of the operation.
95+
*/
6596
getAccessToken(
6697
forceRefresh: boolean = false,
6798
scopes?: Array<string>

lib/msal-native-auth/src/auth_flow/handler/ResetPasswordHandler.ts

+30
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ import {
1212
} from "../result/ResetPasswordResult.js";
1313
import { HandlerBase } from "./HandlerBase.js";
1414

15+
/*
16+
* Base handler for reset password operation.
17+
*/
1518
abstract class ResetPasswordHandler extends HandlerBase {
19+
/*
20+
* Creates a new handler for reset password operation.
21+
* @param correlationId - The correlationId for the request.
22+
* @param continuationToken - The continuation token for the request.
23+
* @param config - The configuration for the request.
24+
* @param username - The username for the request.
25+
*/
1626
constructor(
1727
correlationId: string,
1828
continuationToken: string,
@@ -31,7 +41,15 @@ abstract class ResetPasswordHandler extends HandlerBase {
3141
}
3242
}
3343

44+
/*
45+
* Handler for reset password operations that require a code.
46+
*/
3447
export class ResetPasswordCodeRequiredHandler extends ResetPasswordHandler {
48+
/*
49+
* Submits a code for reset password.
50+
* @param code - The code to submit.
51+
* @returns The result of the operation.
52+
*/
3553
submitCode(code: string): Promise<ResetPasswordSubmitCodeResult> {
3654
if (!code) {
3755
return Promise.resolve(
@@ -44,12 +62,24 @@ export class ResetPasswordCodeRequiredHandler extends ResetPasswordHandler {
4462
throw new Error("Method not implemented.");
4563
}
4664

65+
/*
66+
* Resends a code for reset password.
67+
* @returns The result of the operation.
68+
*/
4769
resendCode(): Promise<ResetPasswordResendCodeResult> {
4870
throw new Error("Method not implemented.");
4971
}
5072
}
5173

74+
/*
75+
* Handler for reset password operations that require a password.
76+
*/
5277
export class ResetPasswordPasswordRequiredHandler extends ResetPasswordHandler {
78+
/*
79+
* Submits a password for reset password.
80+
* @param password - The password to submit.
81+
* @returns The result of the operation.
82+
*/
5383
sumbmitPassword(
5484
password: string
5585
): Promise<ResetPasswordSubmitPasswordResult> {

lib/msal-native-auth/src/auth_flow/handler/SignInHandler.ts

+46
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@ import {
1616
} from "../result/SignInResult.js";
1717
import { HandlerBase } from "./HandlerBase.js";
1818

19+
/*
20+
* Base handler for sign-in operations.
21+
*/
1922
abstract class SignInHandler extends HandlerBase {
23+
/*
24+
* Constructor for SignInHandler.
25+
* @param signInClient - The client to use for sign-in operations.
26+
* @param correlationId - The correlation ID for the request.
27+
* @param continuationToken - The continuation token for the sign-in operation.
28+
* @param config - The configuration for the client.
29+
* @param scopes - The scopes to request during sign-in.
30+
*/
2031
constructor(
2132
protected signInClient: SigninClient,
2233
correlationId: string,
@@ -40,7 +51,15 @@ abstract class SignInHandler extends HandlerBase {
4051
}
4152
}
4253

54+
/*
55+
* Handler for sign-in operations that require a code.
56+
*/
4357
export class SignInCodeRequiredHandler extends SignInHandler {
58+
/*
59+
* Submits a code for sign-in.
60+
* @param code - The code to submit.
61+
* @returns The result of the operation.
62+
*/
4463
async submitCode(code: string): Promise<SignInSubmitCodeResult> {
4564
if (!code) {
4665
const result = SignInSubmitCodeResult.createWithError(
@@ -78,12 +97,24 @@ export class SignInCodeRequiredHandler extends SignInHandler {
7897
}
7998
}
8099

100+
/*
101+
* Resends a code for sign-in.
102+
* @returns The result of the operation.
103+
*/
81104
async resendCode(): Promise<SignInResendCodeResult> {
82105
throw new Error("Method not implemented.");
83106
}
84107
}
85108

109+
/*
110+
* Handler for sign-in operations that require a password.
111+
*/
86112
export class SignInPasswordRequiredHandler extends SignInHandler {
113+
/*
114+
* Submits a password for sign-in.
115+
* @param password - The password to submit.
116+
* @returns The result of the operation.
117+
*/
87118
async sumbmitPassword(
88119
password: string
89120
): Promise<SignInSubmitPasswordResult> {
@@ -99,7 +130,17 @@ export class SignInPasswordRequiredHandler extends SignInHandler {
99130
}
100131
}
101132

133+
/*
134+
* Handler for sign-in operations that require a continuation token.
135+
*/
102136
export class SignInContinuationHandler extends HandlerBase {
137+
/*
138+
* Constructor for SignInContinuationHandler.
139+
* @param correlationId - The correlation ID for the request.
140+
* @param continuationToken - The continuation token for the sign-in operation.
141+
* @param config - The configuration for the client.
142+
* @param username - The username for the sign-in operation.
143+
*/
103144
constructor(
104145
correlationId: string,
105146
continuationToken: string,
@@ -121,6 +162,11 @@ export class SignInContinuationHandler extends HandlerBase {
121162
}
122163
}
123164

165+
/*
166+
* Initiates the sign-in flow with continuation token.
167+
* @param scopes - The scopes to request during sign-in.
168+
* @returns The result of the operation.
169+
*/
124170
signIn(scopes?: Array<string>): Promise<SignInResult> {
125171
throw new Error(`Method not implemented with parameter: ${scopes}`);
126172
}

lib/msal-native-auth/src/auth_flow/handler/SignUpHandler.ts

+38
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ import {
1414
} from "../result/SignUpResult.js";
1515
import { HandlerBase } from "./HandlerBase.js";
1616

17+
/*
18+
* Base handler for sign-up flow.
19+
*/
1720
abstract class SignUpHandler extends HandlerBase {
21+
/*
22+
* Creates a new SignUpHandler.
23+
* @param correlationId - The correlation ID for the request.
24+
* @param continuationToken - The continuation token for the request.
25+
* @param config - The configuration for the request.
26+
* @param username - The username for the request.
27+
*/
1828
constructor(
1929
correlationId: string,
2030
continuationToken: string,
@@ -33,7 +43,15 @@ abstract class SignUpHandler extends HandlerBase {
3343
}
3444
}
3545

46+
/*
47+
* Handler for sign-up operations that require a code.
48+
*/
3649
export class SignUpCodeRequiredHandler extends SignUpHandler {
50+
/*
51+
* Submits a code for sign-up.
52+
* @param code - The code to submit.
53+
* @returns The result of the operation.
54+
*/
3755
submitCode(code: string): Promise<SignUpSubmitCodeResult> {
3856
if (!code) {
3957
return Promise.resolve(
@@ -46,12 +64,24 @@ export class SignUpCodeRequiredHandler extends SignUpHandler {
4664
throw new Error("Method not implemented.");
4765
}
4866

67+
/*
68+
* Resends a code for sign-up.
69+
* @returns The result of the operation.
70+
*/
4971
resendCode(): Promise<SignUpResendCodeResult> {
5072
throw new Error("Method not implemented.");
5173
}
5274
}
5375

76+
/*
77+
* Handler for sign-up operations that require a password.
78+
*/
5479
export class SignUpPasswordRequiredHandler extends SignUpHandler {
80+
/*
81+
* Submits a password for sign-up.
82+
* @param password - The password to submit.
83+
* @returns The result of the operation.
84+
*/
5585
sumbmitPassword(password: string): Promise<SignUpSubmitPasswordResult> {
5686
if (!password) {
5787
return Promise.resolve(
@@ -65,7 +95,15 @@ export class SignUpPasswordRequiredHandler extends SignUpHandler {
6595
}
6696
}
6797

98+
/*
99+
* Handler for sign-up operations that require attributes.
100+
*/
68101
export class SignUpAttributesRequiredHandler extends SignUpHandler {
102+
/*
103+
* Submits attributes for sign-up.
104+
* @param attributes - The attributes to submit.
105+
* @returns The result of the operation.
106+
*/
69107
sumbmitAttributes(
70108
attributes: UserAccountAttributes
71109
): Promise<SignUpSubmitAttributesResult> {

lib/msal-native-auth/src/auth_flow/result/GetAccessTokenResult.ts

+3
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
import { AuthenticationResult } from "@azure/msal-browser";
77
import { ResultBase } from "./ResultBase.js";
88

9+
/*
10+
* Result of getting an access token.
11+
*/
912
export class GetAccessTokenResult extends ResultBase<AuthenticationResult> {}

0 commit comments

Comments
 (0)