Skip to content

Commit

Permalink
Removed warnings from msal-node.api.md (#7376)
Browse files Browse the repository at this point in the history
JSDocs improvements to eliminate most warnings in msal-node.api.md
  • Loading branch information
Robbie-Microsoft authored Oct 17, 2024
1 parent 09066cc commit 8bba9f9
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 167 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Removed warnings from msal-node-api.md #7376",
"packageName": "@azure/msal-node",
"email": "[email protected]",
"dependentChangeType": "none"
}
110 changes: 6 additions & 104 deletions lib/msal-node/apiReview/msal-node.api.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/msal-node/src/cache/NodeStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class NodeStorage extends CacheManager {

/**
* Reads account from cache, builds it into an account entity and returns it.
* @param accountKey
* @param accountKey - lookup key to fetch cache type AccountEntity
* @returns
*/
getCachedAccountEntity(accountKey: string): AccountEntity | null {
Expand Down Expand Up @@ -462,7 +462,7 @@ export class NodeStorage extends CacheManager {

/**
* Remove account entity from the platform cache if it's outdated
* @param accountKey
* @param accountKey - lookup key to fetch cache type AccountEntity
*/
removeOutdatedAccount(accountKey: string): void {
this.removeItem(accountKey);
Expand Down
12 changes: 12 additions & 0 deletions lib/msal-node/src/cache/distributed/DistributedCachePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { TokenCache } from "../TokenCache.js";
import { IPartitionManager } from "./IPartitionManager.js";
import { ICacheClient } from "./ICacheClient.js";

/**
* Cache plugin that serializes data to the cache and deserializes data from the cache
* @public
*/
export class DistributedCachePlugin implements ICachePlugin {
private client: ICacheClient;
private partitionManager: IPartitionManager;
Expand All @@ -21,6 +25,10 @@ export class DistributedCachePlugin implements ICachePlugin {
this.partitionManager = partitionManager;
}

/**
* Deserializes the cache before accessing it
* @param cacheContext - TokenCacheContext
*/
public async beforeCacheAccess(
cacheContext: TokenCacheContext
): Promise<void> {
Expand All @@ -29,6 +37,10 @@ export class DistributedCachePlugin implements ICachePlugin {
cacheContext.tokenCache.deserialize(cacheData);
}

/**
* Serializes the cache after accessing it
* @param cacheContext - TokenCacheContext
*/
public async afterCacheAccess(
cacheContext: TokenCacheContext
): Promise<void> {
Expand Down
10 changes: 7 additions & 3 deletions lib/msal-node/src/cache/distributed/ICacheClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
* Licensed under the MIT License.
*/

/**
* Interface for the cache that defines a getter and setter
* @public
*/
export interface ICacheClient {
/**
* Retrieve the value from the cache
*
* @param key string
* @param key - key of item in the cache
* @returns Promise<string>
*/
get(key: string): Promise<string>;

/**
* Save the required value using the provided key to cache
*
* @param key string
* @param value string
* @param key - key of item in the cache
* @param value - value of item to be saved in the cache
* @returns Promise<string>
*/
set(key: string, value: string): Promise<string>;
Expand Down
6 changes: 5 additions & 1 deletion lib/msal-node/src/cache/distributed/IPartitionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

import { AccountEntity } from "@azure/msal-common/node";

/**
* Interface that defines getter methods to get keys used to identity data in the cache
* @public
*/
export interface IPartitionManager {
/**
* This function should return the correct key from which to read
Expand All @@ -28,7 +32,7 @@ export interface IPartitionManager {
* this function would return the homeAccountId from
* the provided AccountEntity
*
* @param accountEntity: AccountEntity
* @param accountEntity - AccountEntity
* @returns Promise<string>
*/
extractKey(accountEntity: AccountEntity): Promise<string>;
Expand Down
17 changes: 9 additions & 8 deletions lib/msal-node/src/cache/serializer/Deserializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ import {
} from "./SerializerTypes.js";

/**
* This class deserializes cache entities read from the file into in memory object types defined internally
* This class deserializes cache entities read from the file into in-memory object types defined internally
* @internal
*/
export class Deserializer {
/**
* Parse the JSON blob in memory and deserialize the content
* @param cachedJson
* @param cachedJson - JSON blob cache
*/
static deserializeJSONBlob(jsonFile: string): JsonCache {
const deserializedCache = !jsonFile ? {} : JSON.parse(jsonFile);
Expand All @@ -42,7 +43,7 @@ export class Deserializer {

/**
* Deserializes accounts to AccountEntity objects
* @param accounts
* @param accounts - accounts of type SerializedAccountEntity
*/
static deserializeAccounts(
accounts: Record<string, SerializedAccountEntity>
Expand Down Expand Up @@ -79,7 +80,7 @@ export class Deserializer {

/**
* Deserializes id tokens to IdTokenEntity objects
* @param idTokens
* @param idTokens - credentials of type SerializedIdTokenEntity
*/
static deserializeIdTokens(
idTokens: Record<string, SerializedIdTokenEntity>
Expand All @@ -105,7 +106,7 @@ export class Deserializer {

/**
* Deserializes access tokens to AccessTokenEntity objects
* @param accessTokens
* @param accessTokens - access tokens of type SerializedAccessTokenEntity
*/
static deserializeAccessTokens(
accessTokens: Record<string, SerializedAccessTokenEntity>
Expand Down Expand Up @@ -142,7 +143,7 @@ export class Deserializer {

/**
* Deserializes refresh tokens to RefreshTokenEntity objects
* @param refreshTokens
* @param refreshTokens - refresh tokens of type SerializedRefreshTokenEntity
*/
static deserializeRefreshTokens(
refreshTokens: Record<string, SerializedRefreshTokenEntity>
Expand Down Expand Up @@ -171,7 +172,7 @@ export class Deserializer {

/**
* Deserializes appMetadata to AppMetaData objects
* @param appMetadata
* @param appMetadata - app metadata of type SerializedAppMetadataEntity
*/
static deserializeAppMetadata(
appMetadata: Record<string, SerializedAppMetadataEntity>
Expand All @@ -193,7 +194,7 @@ export class Deserializer {

/**
* Deserialize an inMemory Cache
* @param jsonCache
* @param jsonCache - JSON blob cache
*/
static deserializeAllCache(jsonCache: JsonCache): InMemoryCache {
return {
Expand Down
18 changes: 11 additions & 7 deletions lib/msal-node/src/cache/serializer/Serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@ import {
SerializedAppMetadataEntity,
} from "./SerializerTypes.js";

/**
* This class serializes cache entities to be saved into in-memory object types defined internally
* @internal
*/
export class Serializer {
/**
* serialize the JSON blob
* @param data
* @param data - JSON blob cache
*/
static serializeJSONBlob(data: JsonCache): string {
return JSON.stringify(data);
}

/**
* Serialize Accounts
* @param accCache
* @param accCache - cache of accounts
*/
static serializeAccounts(
accCache: AccountCache
Expand Down Expand Up @@ -63,7 +67,7 @@ export class Serializer {

/**
* Serialize IdTokens
* @param idTCache
* @param idTCache - cache of ID tokens
*/
static serializeIdTokens(
idTCache: IdTokenCache
Expand All @@ -86,7 +90,7 @@ export class Serializer {

/**
* Serializes AccessTokens
* @param atCache
* @param atCache - cache of access tokens
*/
static serializeAccessTokens(
atCache: AccessTokenCache
Expand Down Expand Up @@ -119,7 +123,7 @@ export class Serializer {

/**
* Serialize refreshTokens
* @param rtCache
* @param rtCache - cache of refresh tokens
*/
static serializeRefreshTokens(
rtCache: RefreshTokenCache
Expand All @@ -144,7 +148,7 @@ export class Serializer {

/**
* Serialize amdtCache
* @param amdtCache
* @param amdtCache - cache of app metadata
*/
static serializeAppMetadata(
amdtCache: AppMetadataCache
Expand All @@ -164,7 +168,7 @@ export class Serializer {

/**
* Serialize the cache
* @param jsonContent
* @param inMemCache - itemised cache read from the JSON
*/
static serializeAllCache(inMemCache: InMemoryCache): JsonCache {
return {
Expand Down
4 changes: 2 additions & 2 deletions lib/msal-node/src/client/ClientApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ export abstract class ClientApplication {
* This API is provided for scenarios where you would use OAuth2.0 state parameter to mitigate against
* CSRF attacks.
* For more information about state, visit https://datatracker.ietf.org/doc/html/rfc6819#section-3.6.
* @param state
* @param cachedState
* @param state - Unique GUID generated by the user that is cached by the user and sent to the server during the first leg of the flow
* @param cachedState - This string is sent back by the server with the authorization code
*/
protected validateState(state: string, cachedState: string): void {
if (!state) {
Expand Down
9 changes: 5 additions & 4 deletions lib/msal-node/src/client/ClientCredentialClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {

/**
* OAuth2.0 client credential grant
* @public
*/
export class ClientCredentialClient extends BaseClient {
private readonly appTokenProvider?: IAppTokenProvider;
Expand All @@ -56,7 +57,7 @@ export class ClientCredentialClient extends BaseClient {

/**
* Public API to acquire a token with ClientCredential Flow for Confidential clients
* @param request
* @param request - CommonClientCredentialRequest provided by the developer
*/
public async acquireToken(
request: CommonClientCredentialRequest
Expand Down Expand Up @@ -232,8 +233,8 @@ export class ClientCredentialClient extends BaseClient {

/**
* Makes a network call to request the token from the service
* @param request
* @param authority
* @param request - CommonClientCredentialRequest provided by the developer
* @param authority - authority object
*/
private async executeTokenRequest(
request: CommonClientCredentialRequest,
Expand Down Expand Up @@ -330,7 +331,7 @@ export class ClientCredentialClient extends BaseClient {

/**
* generate the request to the server in the acceptable format
* @param request
* @param request - CommonClientCredentialRequest provided by the developer
*/
private async createTokenRequestBody(
request: CommonClientCredentialRequest
Expand Down
37 changes: 21 additions & 16 deletions lib/msal-node/src/client/DeviceCodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {

/**
* OAuth2.0 Device code client
* @public
*/
export class DeviceCodeClient extends BaseClient {
constructor(configuration: ClientConfiguration) {
Expand All @@ -36,7 +37,7 @@ export class DeviceCodeClient extends BaseClient {
/**
* Gets device code from device code endpoint, calls back to with device code response, and
* polls token endpoint to exchange device code for tokens
* @param request
* @param request - developer provided CommonDeviceCodeRequest
*/
public async acquireToken(
request: CommonDeviceCodeRequest
Expand Down Expand Up @@ -70,7 +71,7 @@ export class DeviceCodeClient extends BaseClient {

/**
* Creates device code request and executes http GET
* @param request
* @param request - developer provided CommonDeviceCodeRequest
*/
private async getDeviceCode(
request: CommonDeviceCodeRequest
Expand Down Expand Up @@ -104,9 +105,11 @@ export class DeviceCodeClient extends BaseClient {

/**
* Creates query string for the device code request
* @param request
* @param request - developer provided CommonDeviceCodeRequest
*/
createExtraQueryParameters(request: CommonDeviceCodeRequest): string {
public createExtraQueryParameters(
request: CommonDeviceCodeRequest
): string {
const parameterBuilder = new RequestParameterBuilder();

if (request.extraQueryParameters) {
Expand All @@ -120,9 +123,10 @@ export class DeviceCodeClient extends BaseClient {

/**
* Executes POST request to device code endpoint
* @param deviceCodeEndpoint
* @param queryString
* @param headers
* @param deviceCodeEndpoint - token endpoint
* @param queryString - string to be used in the body of the request
* @param headers - headers for the request
* @param thumbprint - unique request thumbprint
*/
private async executePostRequestToDeviceCodeEndpoint(
deviceCodeEndpoint: string,
Expand Down Expand Up @@ -160,6 +164,7 @@ export class DeviceCodeClient extends BaseClient {

/**
* Create device code endpoint query parameters and returns string
* @param request - developer provided CommonDeviceCodeRequest
*/
private createQueryString(request: CommonDeviceCodeRequest): string {
const parameterBuilder: RequestParameterBuilder =
Expand Down Expand Up @@ -189,9 +194,10 @@ export class DeviceCodeClient extends BaseClient {
}

/**
* Breaks the polling with specific conditions.
* @param request CommonDeviceCodeRequest
* @param deviceCodeResponse DeviceCodeResponse
* Breaks the polling with specific conditions
* @param deviceCodeExpirationTime - expiration time for the device code request
* @param userSpecifiedTimeout - developer provided timeout, to be compared against deviceCodeExpirationTime
* @param userSpecifiedCancelFlag - boolean indicating the developer would like to cancel the request
*/
private continuePolling(
deviceCodeExpirationTime: number,
Expand Down Expand Up @@ -231,10 +237,9 @@ export class DeviceCodeClient extends BaseClient {
}

/**
* Creates token request with device code response and polls token endpoint at interval set by the device code
* response
* @param request
* @param deviceCodeResponse
* Creates token request with device code response and polls token endpoint at interval set by the device code response
* @param request - developer provided CommonDeviceCodeRequest
* @param deviceCodeResponse - DeviceCodeResponse returned by the security token service device code endpoint
*/
private async acquireTokenWithDeviceCode(
request: CommonDeviceCodeRequest,
Expand Down Expand Up @@ -326,8 +331,8 @@ export class DeviceCodeClient extends BaseClient {

/**
* Creates query parameters and converts to string.
* @param request
* @param deviceCodeResponse
* @param request - developer provided CommonDeviceCodeRequest
* @param deviceCodeResponse - DeviceCodeResponse returned by the security token service device code endpoint
*/
private createTokenRequestBody(
request: CommonDeviceCodeRequest,
Expand Down
Loading

0 comments on commit 8bba9f9

Please sign in to comment.