diff --git a/LICENSE b/LICENSE index 56121ee..69da43b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Coveo +Copyright (c) 2005-2018 Coveo Solutions Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fb8b62b..bc0be44 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Coveo Search Token Generator -Node.js module that serves Coveo search tokens for Dynamics portal. +Node.js module that serves Coveo search tokens for a Dynamics portal. ```javascript -// Decodes the authentication token from portal to extract the payload related to the authenticated user. +// Decodes the authentication token from your portal to extract the payload related to the authenticated user. const portalAuth: IDecodedPortalAuthTokenPayload = await portal.decodeAuthToken(req.headers.authorization); -// Gets a search token from Coveo for the user specified in the token. +// Fetches a search token from Coveo for the user passed as argument. const coveoSearchToken: string = await coveo.fetchSearchToken(portalAuth.email); ``` diff --git a/lib/LICENSE b/lib/LICENSE index 56121ee..69da43b 100644 --- a/lib/LICENSE +++ b/lib/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Coveo +Copyright (c) 2005-2018 Coveo Solutions Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/README.md b/lib/README.md index 0a27fbe..100c333 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,12 +1,12 @@ # Coveo Search Token Generator -Node.js module that serves Coveo search tokens for Dynamics portal. +Node.js module that generates Coveo search tokens for a Dynamics portal. ```javascript -// Decodes the authentication token from portal to extract the payload related to the authenticated user. +// Decodes the authentication token from your portal to extract the payload related to the authenticated user. const portalAuth: IDecodedPortalAuthTokenPayload = await portal.decodeAuthToken(req.headers.authorization); -// Gets a search token from Coveo for the user specified in the token. +// Fetches a search token from Coveo for the user passed as argument. const coveoSearchToken: string = await coveo.fetchSearchToken(portalAuth.email); ``` diff --git a/lib/package.json b/lib/package.json index a61ba8f..9c7344e 100644 --- a/lib/package.json +++ b/lib/package.json @@ -1,6 +1,6 @@ { "name": "coveo-search-token-generator", - "description": "Serves Coveo search tokens for Dynamics portal.", + "description": "Generates Coveo search tokens for a Dynamics portal.", "author": "Coveo", "license": "MIT", "version": "0.0.2", diff --git a/lib/src/CoveoSearchTokenGenerator.ts b/lib/src/CoveoSearchTokenGenerator.ts index 745c69e..9e7b9b3 100644 --- a/lib/src/CoveoSearchTokenGenerator.ts +++ b/lib/src/CoveoSearchTokenGenerator.ts @@ -13,13 +13,13 @@ interface ISearchTokenResponse { } /** - * Gets or create a search token. + * Generates search tokens to query Coveo. */ export class CoveoSearchTokenGenerator { constructor(private readonly _apiKey: string, private readonly _platformUrl: string) { } /** - * Gets or create a search token for the given user. + * Fetches a search token for the given user. * If no e-mail is provided, the token returned will * correspond to the anonymous profile. */ diff --git a/lib/src/DynamicsPortalAuthTokenDecoder.ts b/lib/src/DynamicsPortalAuthTokenDecoder.ts index cad49f6..ba7e107 100644 --- a/lib/src/DynamicsPortalAuthTokenDecoder.ts +++ b/lib/src/DynamicsPortalAuthTokenDecoder.ts @@ -11,7 +11,7 @@ export interface IDecodedPortalAuthTokenPayload { } /** - * Decodes a portal authentication token. + * Decodes an authentication token from a portal. */ export class DynamicsPortalAuthTokenDecoder { private _lastPublicKey: string; diff --git a/samples/node-token-server/Index.ts b/samples/node-token-server/Index.ts index 1e66fcc..2c80eba 100644 --- a/samples/node-token-server/Index.ts +++ b/samples/node-token-server/Index.ts @@ -5,12 +5,14 @@ import * as express from "express"; // ----------------------------------------------------------------------------- // Change this configuration accordingly to represent your environment. const config = { - portalUrl: "", // Example: https://yourportalurl.microsoftcrmportals.com (without slash at the end) + portalUrl: "https://yourportalurl.microsoftcrmportals.com/", // Example: https://yourportalurl.microsoftcrmportals.com coveoApiKey: "", // The API key used to query Coveo and create a search token. It must have at least the privilege "Impersonate" enabled. - coveoPlatformUrl: "platform.cloud.coveo.com" // The URL of the Coveo Cloud V2 platform. + coveoPlatformUrl: "platform.cloud.coveo.com" // The Coveo Cloud URL. }; // ----------------------------------------------------------------------------- +config.portalUrl = config.portalUrl.replace(/\/$/, ""); // Remove from the address an eventual trailing slash. + const portal = new DynamicsPortalAuthTokenDecoder(config.portalUrl); const coveo = new CoveoSearchTokenGenerator(config.coveoApiKey, config.coveoPlatformUrl); @@ -18,12 +20,12 @@ const getCoveoToken: express.RequestHandler = async (req: express.Request, res: try { let userEmail: string; if (req.headers.authorization) { - // Decodes the authentication token from portal to extract the payload related to the authenticated user. + // Decodes the authentication token from your portal to extract the payload related to the authenticated user. const portalAuth: IDecodedPortalAuthTokenPayload = await portal.decodeAuthToken(req.headers.authorization); userEmail = portalAuth.email; } - // Gets a search token from Coveo for the user specified in the token. + // Fetches a search token from Coveo for the user passed as argument. const coveoSearchToken: string = await coveo.fetchSearchToken(userEmail); // Returns the search token to the client. diff --git a/samples/node-token-server/LICENSE b/samples/node-token-server/LICENSE index 56121ee..69da43b 100644 --- a/samples/node-token-server/LICENSE +++ b/samples/node-token-server/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Coveo +Copyright (c) 2005-2018 Coveo Solutions Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/samples/node-token-server/README.md b/samples/node-token-server/README.md index 7ad501c..6ea9ded 100644 --- a/samples/node-token-server/README.md +++ b/samples/node-token-server/README.md @@ -1,6 +1,6 @@ # Node.js Express Server Sample -Express server that generates Coveo search tokens for Dynamics portal. +Express server that generates Coveo search tokens for a Dynamics portal. ## Configuration diff --git a/samples/node-token-server/package.json b/samples/node-token-server/package.json index 2c87b62..f835201 100644 --- a/samples/node-token-server/package.json +++ b/samples/node-token-server/package.json @@ -1,9 +1,9 @@ { "name": "sample-token-server", - "description": "Express server that generates Coveo search tokens for Dynamics portal.", + "description": "Express server that generates Coveo search tokens for a Dynamics portal.", "author": "Coveo", "license": "MIT", - "version": "0.0.1", + "private": true, "keywords": [ "coveo", "typescript", @@ -17,7 +17,7 @@ "homepage": "https://github.com/coveo/coveo-search-token-generator", "dependencies": { "express": "^4.16.0", - "coveo-search-token-generator": "file:../../lib" + "coveo-search-token-generator": "0.0.2" }, "scripts": { "setup": "npm install",