From a98b75224b574ab994d0c00e0bd503bc512d9dc4 Mon Sep 17 00:00:00 2001 From: Arthur Minduca Date: Fri, 23 Nov 2018 09:54:29 -0500 Subject: [PATCH] *Better comments --- README.md | 4 ++-- lib/README.md | 4 ++-- lib/src/CoveoSearchTokenGenerator.ts | 2 +- samples/node-token-server/Index.ts | 6 ++++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index bc0be44..83da971 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,10 @@ Node.js module that serves Coveo search tokens for a Dynamics portal. ```javascript -// Decodes the authentication token from your portal to extract the payload related to the authenticated user. +// Decodes the authentication token from the portal and extracts from it the e-mail address of the current user (i.e. the one that made the call). const portalAuth: IDecodedPortalAuthTokenPayload = await portal.decodeAuthToken(req.headers.authorization); -// Fetches a search token from Coveo for the user passed as argument. +// Fetches a search token from Coveo Cloud providing the current user e-mail (or empty for anonymous users), which then returns the search token. const coveoSearchToken: string = await coveo.fetchSearchToken(portalAuth.email); ``` diff --git a/lib/README.md b/lib/README.md index 100c333..5e4b29d 100644 --- a/lib/README.md +++ b/lib/README.md @@ -3,10 +3,10 @@ Node.js module that generates Coveo search tokens for a Dynamics portal. ```javascript -// Decodes the authentication token from your portal to extract the payload related to the authenticated user. +// Decodes the authentication token from the portal and extracts from it the e-mail address of the current user (i.e. the one that made the call). const portalAuth: IDecodedPortalAuthTokenPayload = await portal.decodeAuthToken(req.headers.authorization); -// Fetches a search token from Coveo for the user passed as argument. +// Fetches a search token from Coveo Cloud providing the current user e-mail (or empty for anonymous users), which then returns the search token. const coveoSearchToken: string = await coveo.fetchSearchToken(portalAuth.email); ``` diff --git a/lib/src/CoveoSearchTokenGenerator.ts b/lib/src/CoveoSearchTokenGenerator.ts index 9e7b9b3..3c551b8 100644 --- a/lib/src/CoveoSearchTokenGenerator.ts +++ b/lib/src/CoveoSearchTokenGenerator.ts @@ -13,7 +13,7 @@ interface ISearchTokenResponse { } /** - * Generates search tokens to query Coveo. + * Generates search tokens to query Coveo Cloud. */ export class CoveoSearchTokenGenerator { constructor(private readonly _apiKey: string, private readonly _platformUrl: string) { } diff --git a/samples/node-token-server/Index.ts b/samples/node-token-server/Index.ts index adf725d..588f171 100644 --- a/samples/node-token-server/Index.ts +++ b/samples/node-token-server/Index.ts @@ -20,13 +20,15 @@ const coveo = new CoveoSearchTokenGenerator(config.coveoApiKey, config.coveoPlat const getCoveoToken: express.RequestHandler = async (req: express.Request, res: express.Response): Promise => { try { let userEmail: string; + // Checks in the request object for the existence of an optional authentication token from the portal. + // A token should be present only if the user is authenticated on your portal. If a token is not present, the user will be considered anonymous. if (req.headers.authorization) { - // Decodes the authentication token from your portal to extract the payload related to the authenticated user. + // Decodes the authentication token from the portal and extracts from it the e-mail address of the current user (i.e. the one that made the call). const portalAuth: IDecodedPortalAuthTokenPayload = await portal.decodeAuthToken(req.headers.authorization); userEmail = portalAuth.email; } - // Fetches a search token from Coveo for the user passed as argument. + // Fetches a search token from Coveo Cloud providing the current user e-mail (or empty for anonymous users), which then returns the search token. const coveoSearchToken: string = await coveo.fetchSearchToken(userEmail); // Returns the search token to the client.