Skip to content
Open
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
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1738772fec746bca5575c5e7d8b0fbd3acad505a
100 changes: 50 additions & 50 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,53 @@
on: [push]

jobs:
audit:
name: Audit Project

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '24'

- name: Lib - Install
run: npm i
working-directory: ./keeperapi
env:
NPM_TOKEN: ""

- name: Lib - Build
run: npm run build
working-directory: ./keeperapi
env:
NPM_TOKEN: ""

- name: Lib - Check Types
run: npm run types:ci
working-directory: ./keeperapi
env:
NPM_TOKEN: ""

- name: Lib - Run Unit Tests
run: npm run test
working-directory: ./keeperapi

- name: Examples (node) - Installation
run: npm run link-local
working-directory: ./examples/print-vault-node

- name: Examples (node) - Check Types
run: npm run types:ci
working-directory: ./examples/print-vault-node

- name: Examples (browser) - Installation
run: npm run link-local
working-directory: ./examples/print-vault-browser

- name: Examples (browser) - Check Types
run: npm run types:ci
working-directory: ./examples/print-vault-browser
audit:
name: Audit Project

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '24'

- name: Lib - Install
run: npm i
working-directory: ./keeperapi
env:
NPM_TOKEN: ''

- name: Lib - Build
run: npm run build
working-directory: ./keeperapi
env:
NPM_TOKEN: ''

- name: Lib - Check Types
run: npm run types:ci
working-directory: ./keeperapi
env:
NPM_TOKEN: ''

- name: Lib - Run Unit Tests
run: npm run test
working-directory: ./keeperapi

- name: Examples (node) - Installation
run: npm run link-local
working-directory: ./examples/print-vault-node

- name: Examples (node) - Check Types
run: npm run types:ci
working-directory: ./examples/print-vault-node

- name: Examples (browser) - Installation
run: npm run link-local
working-directory: ./examples/print-vault-browser

- name: Examples (browser) - Check Types
run: npm run types:ci
working-directory: ./examples/print-vault-browser
Comment on lines +7 to +55

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 5 days ago

To fix the problem, explicitly declare restricted GITHUB_TOKEN permissions in the workflow. The safest and simplest approach here is to add a permissions: block at the workflow (top) level, which will apply to the audit job and any future jobs that don’t override it. Since the workflow only needs to read repository contents, we can set contents: read, which matches the minimal permissions CodeQL suggested.

Concretely, in .github/workflows/main.yml, add a permissions: block after the on: definition and before jobs:. No existing steps or functionality need to change; the workflow will still be triggered on push, run on ubuntu-latest, and execute the same npm commands, but with a GITHUB_TOKEN limited to reading repository contents. No imports, extra methods, or additional configuration files are required.

Suggested changeset 1
.github/workflows/main.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -2,6 +2,9 @@
 
 on: [push]
 
+permissions:
+    contents: read
+
 jobs:
     audit:
         name: Audit Project
EOF
@@ -2,6 +2,9 @@

on: [push]

permissions:
contents: read

jobs:
audit:
name: Audit Project
Copilot is powered by AI and may make mistakes. Always verify output.
42 changes: 21 additions & 21 deletions .github/workflows/publish.npm.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
name: Publish to NPM
on:
workflow_dispatch:
workflow_dispatch:

permissions:
contents: read
id-token: write
contents: read
id-token: write

jobs:
publish-npm:
environment: prod
runs-on: ubuntu-latest
publish-npm:
environment: prod
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./keeperapi
defaults:
run:
working-directory: ./keeperapi

steps:
- name: Get the source code
uses: actions/checkout@v4
steps:
- name: Get the source code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm install
- name: Install dependencies
run: npm install

- name: Publish package
run: npm publish
- name: Publish package
run: npm publish
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"semi": true,
"tabWidth": 4,
"printWidth": 120,
"trailingComma": "es5"
}
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,28 @@ npm install keeperapi
```

```typescript
try {
let auth = new Auth({
host: KeeperEnvironment.DEV
});
await auth.login(username, password);
console.log("login successful");
let vault = new Vault(auth);
await vault.syncDown();
vault.records.forEach(x => console.log(JSON.stringify(x)));
} catch (e) {
console.log(e);
}
try {
let auth = new Auth({
host: KeeperEnvironment.DEV,
});
await auth.login(username, password);
console.log('login successful');
let vault = new Vault(auth);
await vault.syncDown();
vault.records.forEach((x) => console.log(JSON.stringify(x)));
} catch (e) {
console.log(e);
}
```

For local development,
For local development,

```bash
npm run build
```
from "keeperapi" folder, then


from "keeperapi" folder, then

```bash
npm link ../../keeperapi
```
Expand Down
4 changes: 3 additions & 1 deletion examples/print-vault-browser/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# print-vault-browser

### INSTRUCTIONS

- `npm install`
- `npm start`

### NOTES
- By default, the `preinstall` script links the installed version of `keeperapi` to the local version in this repo

- By default, the `preinstall` script links the installed version of `keeperapi` to the local version in this repo
74 changes: 37 additions & 37 deletions examples/print-vault-browser/package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
{
"name": "print-vault-browser",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"link-local": "npm link ../../keeperapi",
"types": "tsc --watch",
"types:ci": "tsc"
},
"dependencies": {
"keeperapi": "0.2.0",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"devDependencies": {
"@types/jest": "24.0.15",
"@types/node": "12.0.8",
"@types/react": "16.8.21",
"@types/react-dom": "16.8.4",
"react-scripts": "3.0.1",
"typescript": "^4.0.1"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
"name": "print-vault-browser",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"link-local": "npm link ../../keeperapi",
"types": "tsc --watch",
"types:ci": "tsc"
},
"dependencies": {
"keeperapi": "0.2.0",
"react": "^16.8.6",
"react-dom": "^16.8.6"
},
"devDependencies": {
"@types/jest": "24.0.15",
"@types/node": "12.0.8",
"@types/react": "16.8.21",
"@types/react-dom": "16.8.4",
"react-scripts": "3.0.1",
"typescript": "^4.0.1"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
33 changes: 16 additions & 17 deletions examples/print-vault-browser/public/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -19,12 +19,12 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Keeper SDK - Browser</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<title>Keeper SDK - Browser</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

Expand All @@ -33,6 +33,5 @@

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
--></body>
</html>
26 changes: 13 additions & 13 deletions examples/print-vault-browser/public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Loading