Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 67 additions & 20 deletions README-sdk-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ It is intended for BB2 team members or others performing SDK development work.

npm recommends install node using nvm (node version manager), for install instruction, check out: https://github.com/nvm-sh/nvm


```
check nvm version:
nvm -v
Expand Down Expand Up @@ -102,6 +101,7 @@ cd my_proj
yarn init
...
```

Setting npm config global settings will make subsequently created pacakge projects 'private'.

Note that publishing package 'private' is a npm option that requires payment.
Expand All @@ -110,31 +110,78 @@ Note that publishing package 'private' is a npm option that requires payment.

1. Consuming from npm registry:

```
mkdir my_proj
cd my_proj
yarn init
yarn add cms-bluebutton-sdk
```
mkdir my_proj
cd my_proj
yarn init
yarn add cms-bluebutton-sdk

continue adding other dependencies, e.g. express, ts-node, etc., ...
continue adding other dependencies, e.g. express, ts-node, etc., ...

yarn add express @types/express ts-node
yarn add <other dependencies>
```
yarn add express @types/express ts-node
yarn add <other dependencies>
```

2. Consuming from a local SDK repository (as a good test before publishing):

After built and generated typescript types (needed if to be consumed by typescript project), the sdk can be consumed by other projects as shown by below example:
After built and generated typescript types (needed if to be consumed by typescript project), the sdk can be consumed by other projects as shown by below example:

```
mkdir my_proj
cd my_proj
yarn init
yarn add <path to local cms-bluebutton-sdk local repository base directory>

continue adding other dependencies, e.g. express, ts-node, etc., ...

yarn add express @types/express ts-node
yarn add <other dependencies>
```

3. Consuming from the sample client

This process should definitely be reworked for a better dev experience. Currently there are a lot of manual steps.

Build the project using the instructions below:

```
yarn build
yarn build:types
Comment on lines +148 to +149
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably wrap this with `blah` or ```blah``` to match formatting from other sections and make this easier to read.

```

The yarn build:types is to create the index.d.ts, which is used for type checking throughout the project. While during startup, it may not error out, there
can be issues during runtime. It is to ensure that the types of everything used in the project are consistent.

Copy each file from the dist folder after the build. You will have:

cms-bluebutton-sdk.cjs.js
cms-bluebutton-sdk.esm.js
cms-bluebutton-sdk.umd.js
index.d.ts

The three files are used so that the sdk can be used in a variety of projects, such as a module or in a browser.

In the sample-client, you will then create a folder within the server folder location. Name the folder something like node-sdk.
Copy the entire contents of the dist folder into the newly created node-sdk folder.
Put the .js files into a new dist folder within the node-sdk folder.
Back in this repo (cms-bb2-node-sdk) copy the package.json into the sample client's node-sdk folder.
This entire process is to allow the sdk to be locally referenced while inside the Docker container. Ideally, there would be a more elegant way to do this.

The folder structure will look like this:

```
mkdir my_proj
cd my_proj
yarn init
yarn add <path to local cms-bluebutton-sdk local repository base directory>
```
server
└───node-sdk
│ │ index.d.ts
│ │ package.json (THIS IS THE ONE FROM THIS SDK REPO)
│ └───dist
│ │ cms-bluebutton-sdk.umd.js
│ │ ms-bluebutton-sdk.esm.js
│ │ cms-bluebutton-sdk.cjs.js
```

continue adding other dependencies, e.g. express, ts-node, etc., ...
Within the sample client in the server folder, there is another package.json (Note: NOT the one in node-sdk) This package.json will have

yarn add express @types/express ts-node
yarn add <other dependencies>
```
"cms-bluebutton-sdk": "^{version}",

Replace the version with "file:node-sdk" to use the locally created node-sdk folder from previous steps. This will allow you to see changes to this repo.
1 change: 0 additions & 1 deletion src/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ test("expect auth method generateTokenPostData() function", () => {
client_id: "foo",
client_secret: "bar",
code: "test-code",
code_challenge: AuthData.codeChallenge,
code_verifier: AuthData.verifier,
grant_type: "authorization_code",
redirect_uri: "http://localhost/callback/",
Expand Down
2 changes: 0 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export type TokenPostData = {
grant_type: string;
redirect_uri: string;
code_verifier: string;
code_challenge: string;
};

export function generateAuthData(): AuthData {
Expand Down Expand Up @@ -94,7 +93,6 @@ export function generateTokenPostData(
grant_type: "authorization_code",
redirect_uri: bb.callbackUrl,
code_verifier: authData.verifier,
code_challenge: authData.codeChallenge,
};
}

Expand Down