Skip to content

Commit

Permalink
Modified the style of some comments.
Browse files Browse the repository at this point in the history
Modified the commenting style for the comments not to be left out
during the build.

Relates-to: OLPEDGE-869

Signed-off-by: Halyna Dumych <ext-halyna.dumych@here.com>
  • Loading branch information
HalynaDumych authored and Oleksii Zubko committed Dec 11, 2019
1 parent a5f5bd2 commit b7ad993
Show file tree
Hide file tree
Showing 28 changed files with 260 additions and 208 deletions.
67 changes: 36 additions & 31 deletions @here/olp-sdk-authentication/lib/UserAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ import { OAuthArgs, Token } from "./requestToken_common";

/**
* User credentials.
*
*
* Download the file with credentials from the [Open Location Platform (OLP) portal](https://account.here.com/).
* The downloaded **credentials.properties** file contains the access key ID and access key secret needed to get the access token.
* You can also use the access key ID and access key secret for authentication.
*/
export interface AuthCredentials {
/**
* Your access key ID.
*
*
* Find the access key ID in the **credentials.properties** file downloaded from the OLP Portal.
*/
accessKeyId?: string;
/**
* Your access key secret.
*
*
* Find the access key secret in the **credentials.properties** file downloaded from the OLP Portal.
*/
accessKeySecret?: string;
}

/**
* Gets an access token.
*
*
* @param args The arguments needed to get the access token.
* @return The generated access token.
*/
Expand All @@ -53,27 +53,29 @@ export type TokenRequesterFn = (args: OAuthArgs) => Promise<Token>;
* Parameters for authentification.
*/
export interface UserAuthConfig {
// Credentials for authorization.
/** Credentials for authorization. */
credentials?: AuthCredentials;
// One of the following environments: here, here-dev, here-cn, and here-cn-dev.
/** One of the following environments: here, here-dev, here-cn, and here-cn-dev. */
env?: string;
// The URL of your custom environment.
/** The URL of your custom environment. */
customUrl?: string;
/**
* Gets the access token.
*
* You can provide your own implementation or use one from `@here/olp-sdk-authentication`.
*
* There are two functions that work for the browser and Node.js.
* For the browser, `UserAuth` uses `requestToken()` from [[requestToken.web.ts]](requestToken.web.ts).
* For Node.js,`UserAuth` uses `requestToken()` from [[requestToken.ts]](requestToken.ts).
* For the browser, `UserAuth` uses `requestToken()` from requestToken.web.ts.
* For Node.js,`UserAuth` uses `requestToken()` from requestToken.ts.
*
* When a function imports a function using `import { requestToken }` from "@here/olp-sdk-authentication"`,
* the code automatically applies to the corresponding function.
*
* The following code is applicable for both the browser and Node.js.
*
* @example
*
* ```typescript
* import { UserAuth, requestToken } from "@here/olp-sdk-authentication";
*
* const userAuth = new UserAuth({
Expand All @@ -83,11 +85,12 @@ export interface UserAuthConfig {
* },
* tokenRequester: requestToken
* });
*
* ```
*/
tokenRequester: TokenRequesterFn;
/**
* Project scope.
*
* If the project is specified, the resulting token is bound to it.
* If the desired resource is restricted to a specific project, to get a valid token, specify this project.
*/
Expand All @@ -103,28 +106,28 @@ export interface UserInfo {
* Begins with `AUTHINVITE` if status is invited. Otherwise, use your HERE ID.
*/
userId: string;
// The realm to which you belong.
/** The realm to which you belong. */
realm: string;
// Your first name.
/** Your first name. */
firstname: string;
// Your last name.
/** Your last name. */
lastname: string;
// Your email address.
/** Your email address. */
email: string;
// Your date of birth.
/** Your date of birth. */
dob: string;
// Your native language.
/** Your native language. */
language: string;
// The code of the country in which you live.
/** The code of the country in which you live. */
countryCode: string;
// `true` if your email is verified, `false` otherwise.
/** True if your email is verified, false otherwise. */
emailVerified: boolean;
marketingEnabled: boolean;
// The Unix time (seconds) when the authorization was created.
/** The Unix time (seconds) when the authorization was created. */
createdTime: number;
// The Unix time (seconds) when the authorization was updated.
/** The Unix time (seconds) when the authorization was updated. */
updatedTime: number;
// Your user status.
/** Your user status. */
state: string;
}

Expand All @@ -140,7 +143,7 @@ export class UserAuth {

/**
* Creates the [[UserAuth]] instance.
*
*
* @param config Parameters for authentication.
* @return The [[UserAuth]] instance.
*/
Expand Down Expand Up @@ -181,7 +184,7 @@ export class UserAuth {

/**
* Retrieves the access token.
*
*
* @return The access token if it is valid, or an error if at least one of the following credentials is not stated:
* access key ID or acces key secret.
*/
Expand All @@ -200,12 +203,14 @@ export class UserAuth {
);
}

const response = await this.config.tokenRequester({
url: this.m_apiUrl + "oauth2/token",
consumerKey: this.m_credentials.accessKeyId,
secretKey: this.m_credentials.accessKeySecret,
scope: this.m_scope
}).catch(err => Promise.reject(`Error fetching token: ${err}`));
const response = await this.config
.tokenRequester({
url: this.m_apiUrl + "oauth2/token",
consumerKey: this.m_credentials.accessKeyId,
secretKey: this.m_credentials.accessKeySecret,
scope: this.m_scope
})
.catch(err => Promise.reject(`Error fetching token: ${err}`));

if (response.accessToken) {
this.m_accessToken = response.accessToken;
Expand All @@ -224,7 +229,7 @@ export class UserAuth {

/**
* Validates the access token.
*
*
* @param token The string containing the token.
* @return True if the access token is valid, false otherwise.
*/
Expand Down Expand Up @@ -253,7 +258,7 @@ export class UserAuth {

/**
* Retrieves user data.
*
*
* @param userToken The string that contains the user token.
* @return The `json` object with the user data.
*/
Expand Down
4 changes: 2 additions & 2 deletions @here/olp-sdk-authentication/lib/loadCredentialsFromFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { AuthCredentials } from "./UserAuth";

/**
* Parses the **credentials.properties** file from the
* [Open Location Platform (OLP) website]
* (https://developer.here.com/olp/documentation/access-control/user-guide/topics/get-credentials.html)
* Open Location Platform (OLP)
* [website](https://developer.here.com/olp/documentation/access-control/user-guide/topics/get-credentials.html)
* and retrieves an object with user credentials.
*
* @param path The path to the **credentials.properties** file.
Expand Down
25 changes: 13 additions & 12 deletions @here/olp-sdk-authentication/lib/requestToken_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
export interface Signer {
/**
* Signs data using your secret key and returns a `Promise` that fulfills `ArrayBuffer` containing the signature.
*
*
* @param data The `ArrayBufferLike` object containing the data to be signed.
* @param secretKey Your secret key that is used for signing.
* @return The encrypted ID for an access token.
*/
sign: (data: ArrayBufferLike, secretKey: string) => Promise<string>;
/**
* Fills the passed `TypedArray` with cryptographically strong random values (random in its cryptographic meaning).
*
*
* @param data The integer-based `TypedArray`.
* @return The input array.
* @note The `TypedArray` is modified in-place, and no copy is made.
Expand All @@ -43,30 +43,31 @@ export interface Signer {
* Contains arguments needed to get an access token.
*/
export interface OAuthArgs {
// The environment in which you work.
/** The environment in which you work. */
url: string;
// Your consumer key.
/** Your consumer key. */
consumerKey: string;
// Your secret key.
/** Your secret key. */
secretKey: string;
// A unique token that your application generates for each unique request. If not provided, the default token is used.
/** A unique token that your application generates for each unique request. If not provided, the default token is used. */
nonce?: string;
// The time when you authenticated.
/** The time when you authenticated. */
timestamp?: number;
// The expiration time (in milliseconds).
/** The expiration time (in milliseconds). */
expiresIn?: number;
/** The project scope. */
scope?: string;
}

/**
* Interface for an access token.
*/
export interface Token {
// The token for access
/** The token for access. */
accessToken: string;
// The type of token.
/** The type of token. */
tokenType: string;
// The expiration time (in milliseconds).
/** The expiration time (in milliseconds). */
expiresIn: number;
}

Expand Down Expand Up @@ -133,7 +134,7 @@ async function getOAuthAuthorization(

/**
* Creates an access token.
*
*
* @param args The arguments needed to get the access token.
* @param tokenSigner The encrypted ID for the access token.
* @return The access token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DeferredPromise<T> {
}

/**
* * An implementation of the [[DownloadManager]] interface requested by the `datastore-api` module
* An implementation of the [[DownloadManager]] interface requested by the `datastore-api` module
* for fetching data from the backend or sending requests to the backend.
* This implementation allows you to fetch blob or JSON data with aborting or re-sending (on timeouts) mechanisms
* that limit maximum parallel requests.
Expand All @@ -68,7 +68,7 @@ export class DataStoreDownloadManager implements DownloadManager {
*/
static readonly retryTimeout = 500;

// The number of maximum parallel downloads.
/** The number of maximum parallel downloads. */
static readonly maxParallelDownloads = 16;

private activeDownloadCount = 0;
Expand Down
12 changes: 7 additions & 5 deletions @here/olp-sdk-dataservice-read/lib/DataStoreRequestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ async function addBearerToken(
export class DataStoreRequestBuilder extends RequestBuilder {
/**
* Cerates the [[DataStoreRequestBuilder]] instance.
*
*
* @param downloadManager The configured instance of the [[DownloadManager]] interface implementation.
* You can use our default [[DatastoreDownloadManager]] or create your implementation.
* You can use our default `DatastoreDownloadManager` or create your implementation.
* @param baseUrl The URL string.
* @param getBearerToken Retrieves the access token.
* @return The access token.
* @param abortSignal A signal object that allows you to communicate with a request (such as the `fetch` request)
* and, if required, abort it using the `AbortController` object.
*
* For more information, see the [`AbortController` documentation](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
*
* @return The [[DataStoreRequestBuilder]] instance.
*/
constructor(
Expand All @@ -73,7 +75,7 @@ export class DataStoreRequestBuilder extends RequestBuilder {

/**
* Downloads data from the provided URL.
*
*
* @param url The URL of the data that you want to download.
* @param init The helper object for the request.
* @return The data of the type specified in the generics.
Expand All @@ -94,7 +96,7 @@ export class DataStoreRequestBuilder extends RequestBuilder {

/**
* Downloads the blob data from the specified URL.
*
*
* @param url The URL of the blob data that you want to download.
* @param init The helper object for the request.
* @return The blob data.
Expand Down
2 changes: 1 addition & 1 deletion @here/olp-sdk-dataservice-read/lib/DownloadManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* [[DataStoreRequestBuilder]] has its own default implementation of the download manager.
* If you want to use your download manager, you can implement this interface, and then set your download manager.
*
* @see DataStoreRequestBuilder.
* @see [[DataStoreRequestBuilder]]
*/
export interface DownloadManager {
/**
Expand Down
20 changes: 14 additions & 6 deletions @here/olp-sdk-dataservice-read/lib/HRN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
export interface HRNData {
/**
* One of the following string partitions:
* * `"here"
* * `"here"`
* * `"here-dev"`
* * `"here-cn"`
* * `"here-cn-dev"`
*/
partition: string;
/**
* The name of the API service.
*
*
* @example `"data"`.
*/
service: string;
// The region of the HRN.
/** The region of the HRN. */
region?: string;
// The account of the HRN.
/** The account of the HRN. */
account?: string;
/**
* The resource of the HRN.
*
*
* @example The catalog name of the `datastore` HRNs.
*/
resource: string;
Expand All @@ -63,6 +63,14 @@ export class HRN {
private static RESOURCE_TYPE_POS = 3;
private static RESOURCE_PARAMS_COUNT = 3;

/**
* Returns a new HRN from a string representation of an HRN.
*
* @example `hrn:here:data:::example-catalog`
*
* @param hrn The HRN string
* @return The new HRN.
*/
static fromString(hrn: string): HRN {
// special case - also allow http and https as 'catalog-url' local URLs
if (hrn.startsWith("http:") || hrn.startsWith("https:")) {
Expand Down Expand Up @@ -110,7 +118,7 @@ export class HRN {

/**
* Converts the specified HRN to its string representation.
*
*
* @example
* `hrn:partition:service:region:account:resource`.
*
Expand Down
Loading

0 comments on commit b7ad993

Please sign in to comment.