Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KMS SDK refactor, improvements, fixes, and refresh token + cross-platform support #18

Merged
merged 104 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
cbe931a
Stop storing JWT in localStorage.
Danziger Jul 4, 2024
7e1be39
Add environment variables.
Danziger Jul 5, 2024
a3df4e2
Re-structure Othent KMS SDK.
Danziger Jul 16, 2024
79a88c6
Update connect() logic and fix some type/conversion issues.
Danziger Jul 16, 2024
c3e118e
Finish implementing refresh tokens.
Danziger Jul 16, 2024
83c9066
Update auth/user types.
Danziger Jul 17, 2024
faf0224
Improve b64 encoding type and parsing.
Danziger Jul 18, 2024
7396a4e
Updates request and response data format and encoding/decoding of bin…
Danziger Jul 19, 2024
dc1606b
Format code.
Danziger Jul 19, 2024
d38e2d1
Remove unused type.
Danziger Jul 19, 2024
05fe4c0
Format code.
Danziger Jul 19, 2024
9ec216c
Use auth flow logs only in development.
Danziger Jul 19, 2024
665cd37
Adds missing methods from ArConnect and updates dispatch's arguments.
Danziger Jul 19, 2024
99288b5
Updates dispatch to not require an arweave instance param.
Danziger Jul 19, 2024
b54ea39
Install arweave dependency.
Danziger Jul 19, 2024
ed3dec9
Update README.
Danziger Jul 19, 2024
259848a
Update some TODOs and make some minor type improvements.
Danziger Jul 19, 2024
2ddd5c3
Add an onAuth event.
Danziger Jul 19, 2024
e7e24ac
Handle refresh token / user data expiration.
Danziger Jul 19, 2024
e78a7a8
Add autoConnect (eager, lazy, off) to auto-connect and fix issue with…
Danziger Jul 19, 2024
a3fa7db
Add a throwErrors: boolean option to prevent the SDK from throwing er…
Danziger Jul 19, 2024
13cbba1
Add an additional check to make sure the error event can only be used…
Danziger Jul 19, 2024
9a56ae2
Clarify the unhandled unthrown error error message.
Danziger Jul 19, 2024
a99ed23
Format code.
Danziger Jul 19, 2024
ef14507
Add option for common tags, add option for app name and version (whic…
Danziger Jul 19, 2024
dab32ed
Format code.
Danziger Jul 19, 2024
f5fbada
Improve auth flow to avoid emitting duplicate events and to automatic…
Danziger Jul 22, 2024
e28d9f9
Throw an error when trying to use eager autoConnect with in-memory re…
Danziger Jul 22, 2024
043d573
Code formatting.
Danziger Jul 22, 2024
effa7de
Add SDK and API versions, and app name and version, to Auth0's transa…
Danziger Jul 22, 2024
7e2dc50
Remove TODO and comments that I've moved to the PR itself.
Danziger Jul 22, 2024
1dd40a2
Move the Othent class to its own file, reorganiza a bit some types an…
Danziger Jul 22, 2024
3f58c62
Move DEFAULT_REFRESH_TOKEN_EXPIRATION_MS to option.
Danziger Jul 23, 2024
8e4d11c
Add an option to sync userData across tabs using localStorage and two…
Danziger Jul 23, 2024
f75c7f7
Format code.
Danziger Jul 24, 2024
be6cd23
Add TSDoc comments to all options.
Danziger Jul 24, 2024
640c1c7
Rename cookie and localStorage options to persistCookie and persistLo…
Danziger Jul 24, 2024
2b33d0d
Add isAuthenticated to auth event.
Danziger Jul 24, 2024
1632086
Format code.
Danziger Jul 24, 2024
b4f95ef
Manually bump package version (also in code).
Danziger Jul 24, 2024
76d065b
Add a TODO to avoid mutating the input transaction in sign().
Danziger Jul 24, 2024
0e4384e
Update TSDoc comments and document the release process in the README.
Danziger Jul 26, 2024
d2c82e2
2.0.0-beta.0
Danziger Jul 26, 2024
a702657
Add .npmrc file.
Danziger Jul 26, 2024
a1671bc
Add preversion, version and postversion scripts to partially automate…
Danziger Jul 26, 2024
e48b739
Add Husky and lint-staged to format on commit and custom pre-commit t…
Danziger Jul 26, 2024
938d79b
Update sed comamnd in Husky's pre-commit to use double-quotes.
Danziger Jul 26, 2024
5711723
Check if Husky and lint-staged are working fine.
Danziger Jul 26, 2024
fa8f5ee
Add git update-index --again to pre-commit hook.
Danziger Jul 26, 2024
7c1a70c
Update the manual publish flow in the README.
Danziger Jul 26, 2024
9ca93e1
2.0.0-beta.1
Danziger Jul 26, 2024
085959c
Update version scripts to always update the version constant.
Danziger Jul 26, 2024
cbd7b76
2.0.0-beta.1
Danziger Jul 26, 2024
5831e08
Remove TODOs from README.
Danziger Jul 26, 2024
c7dcc62
Update README.
Danziger Jul 26, 2024
40f3386
Remove .env file as tsup doesn't support it anyway.
Danziger Jul 26, 2024
137a407
Updated pre-commit hook.
Danziger Jul 26, 2024
7692872
Remove engines and updates PNPM lock file.
Danziger Jul 26, 2024
e794e51
Update README.
Danziger Jul 26, 2024
88eac4e
2.0.0-beta.2
Danziger Jul 26, 2024
6665690
Update postversion script to avoid removing the dist folder before ru…
Danziger Jul 26, 2024
1c59573
2.0.0-beta.3
Danziger Jul 26, 2024
fcca264
Attempt at fixing the Arweave-crypto issue on React Native.
Danziger Jul 30, 2024
04326e1
2.0.0-beta.4
Danziger Jul 30, 2024
c3ee8d8
Move othent.config logs from here to the playground and remove develo…
Danziger Jul 31, 2024
245e68a
Implement mergeOptions() function.
Danziger Jul 31, 2024
fc88fdc
Add a mergeOptions() function and improves name/label generation for …
Danziger Jul 31, 2024
31acf2b
Change arweave import to arweave/web.
Danziger Aug 1, 2024
1692099
2.0.0-beta.5
Danziger Aug 1, 2024
0be47b5
Add gatewayConfig to Othent options and fix CookieStorage localhost c…
Danziger Aug 6, 2024
88eab0a
2.0.0-beta.6
Danziger Aug 6, 2024
43d629b
Remove crypto option, update sign() to return a new Transaction insta…
Danziger Aug 6, 2024
87ed43d
Fix typo in comment.
Danziger Aug 6, 2024
3ecd4cc
2.0.0-beta.7
Danziger Aug 6, 2024
a6d7f8a
Check Auth0 error types using Auth's exported error classes, when ava…
Danziger Aug 6, 2024
7341a0c
Add ANS resolution for getWalletNames() and UserDetails.
Danziger Aug 7, 2024
318b7d4
Update pre-commit hook to get the package version from the NPM variab…
Danziger Aug 7, 2024
00f603f
Update pre-commit hook to get the package version from the NPM variab…
Danziger Aug 7, 2024
9a0e7f6
Update pre-commit hook to get the package version from the NPM variab…
Danziger Aug 7, 2024
5e21649
Just add a TODO comment.
Danziger Aug 7, 2024
bd32918
2.0.0-beta.8
Danziger Aug 7, 2024
74ef887
Update Othent to also use redirects instead of popups for authenticat…
Danziger Aug 9, 2024
385fcd1
Remove console.log().
Danziger Aug 9, 2024
d9fdc27
Add a debug option to enable additional logs.
Danziger Aug 9, 2024
b6424da
Update version script to update version constant properly.
Danziger Aug 9, 2024
8f001ee
2.0.0-beta.9
Danziger Aug 9, 2024
4ed1893
Update version script to update version constant properly.
Danziger Aug 9, 2024
974fb97
2.0.0-beta.10
Danziger Aug 9, 2024
3d87159
Update version script to update version constant properly.
Danziger Aug 9, 2024
0bf0d88
2.0.0-beta.10
Danziger Aug 9, 2024
a1b97ff
2.0.0-beta.11
Danziger Aug 9, 2024
ba0ca02
Update version script to update version constant properly.
Danziger Aug 9, 2024
1d65df9
2.0.0-beta.10
Danziger Aug 9, 2024
9048413
Update decrypt() to return Uint8Array.
Danziger Aug 19, 2024
9babd0c
Add missing appLogo option and remove some TOODs tha have been moved …
Danziger Aug 20, 2024
b06c246
Update appInfo to be passed in as a single prop to the Othent constru…
Danziger Aug 21, 2024
06673f2
Export types using export type.
Danziger Aug 21, 2024
e0f7fd9
2.0.0-beta.11
Danziger Aug 21, 2024
06e17f2
Add validation for appInfo and gatewayConfig.
Danziger Aug 21, 2024
8b17c2d
Add ArrayBufferView to BinaryDataType.
Danziger Aug 21, 2024
0e49b0d
Improve appInfo and gatewayConfig setter and validation.
Danziger Aug 21, 2024
e5e5154
2.0.0-beta.12
Danziger Aug 21, 2024
1ec1bd7
Remove Bun and update instructions to link with PNPM.
Danziger Aug 21, 2024
cf28c29
Minor changes to exported types, TODO comments and CookieStorage.
Danziger Aug 22, 2024
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
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{sh,bash}]
end_of_line = lf
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pnpm lint-staged

git update-index --again
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auto-install-peers=true
engine-strict=true
120 changes: 117 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,119 @@
# @othent/kms
# Othent KMS JS SDK

The Othent KMS package.
Othent JS SDK to manage Arweave custodial wallets backend by Auth0 and Google Key Management Service.

Please find code examples on how to use this package at https://github.com/Othent/KMS-test-repo.
Try our demo at [kms-demo.othent.io](https://kms-demo.othent.io)!

<br />

[![Othent KMS JS SDK NPM page](https://img.shields.io/npm/v/%40othent%2Fkms?style=for-the-badge&color=%23CC3534)](https://www.npmjs.com/package/@othent/kms)

<br />

[![Othent KMS JS SDK NPM demo](https://kms-demo.othent.io/othent-kms-demo-screenshot.png)](https://kms-demo.othent.io)

<br />

Learn how to set it up at https://docs.othent.io or looking at our demo's code at https://github.com/Othent/KMS-test-repo.

<br />

## Installation

npm install --save @othent/kms
yarn install --save @othent/kms
pnpm add --save @othent/kms

<br />

## Usage

```ts
import { Othent, AppInfo } from "@othent/kms";

const appInfo: AppInfo = {
name: "My Awesome App",
version: "1.0.0",
env: "production",
};

const othent = new Othent({ appInfo, throwErrors: false, ... });

othent.addEventLister("error", (err) => {
console.error(err);
});

await othent.connect();

const mySecret = await othent.encrypt("My secret");

const transaction = await arweave.createTransaction({
data: imySecret,
});

const result = await othent.dispatch(transaction);
const transactionURL = `https://viewblock.io/arweave/tx/${result.id}`;

console.log(transactionURL);
```

You can find more information and examples at https://docs.othent.io or looking at our demo's code at
https://github.com/Othent/KMS-test-repo.

<br />

## Publishing A New Release:
Danziger marked this conversation as resolved.
Show resolved Hide resolved

### Manually:

1. Use [`pnpm version`](https://docs.npmjs.com/cli/v7/commands/npm-version) to bump the version, which will also make sure
the next commit has the right tags.

**Stable release:**

```
npm version patch
npm version minor
npm version major
```


**Pre-release:**

```
npm version prerelease --preid=beta
npm version prepatch --preid=beta
npm version preminor --preid=beta
npm version premajor --preid=beta
```

The `preversion`, `version` and `postversion` scripts defined in `package.json` will test, format, build, tag and
push all the changes automatically. See https://docs.npmjs.com/cli/v10/commands/npm-version.

2. To publish a stable release, simply run [`pnpm publish`](https://docs.npmjs.com/cli/v8/commands/npm-publish).

The `latest` tag will also point to this new version.

If you are publishing a pre-release version and don't want the `latest` tag to be updated, run this instead:

pnpm publish --tag beta

<br />

### Troubleshooting

If you accidentally updated the `latest` tag, you can point it to another version with the following command:

npm dist-tag add @othent/kms@<version> latest

You can see the package distribution (not version) tags like this:

npm view . dist-tags

If you added / pushed an incorrect tag, you can delete it from the server with:

git push origin :refs/tags/v0.1.0

And locally with:

git tag -d v0.1.0
Binary file removed bun.lockb
Binary file not shown.
32 changes: 24 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@othent/kms",
"version": "1.0.12",
"description": "Arweave Oauth Othent wallets enabled Google Key Management Service.",
"version": "2.0.0-beta.12",
"description": "Othent JS SDK to manage Arweave custodial wallets backend by Auth0 and Google Key Management Service.",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand All @@ -22,10 +22,16 @@
"README.md"
],
"scripts": {
"build": "bun run prettier && tsup src/index.ts --format cjs,esm --dts",
"dev": "bun run build && bun link",
"test": "bun test",
"prettier": "prettier --write ."
"build": "tsup src/index.ts --format cjs,esm --dts",
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
"clean": "rm -rf dist",
"nuke": "pnpm clean && rm -rf node_modules pnpm-lock.yaml",
"test": "echo \"Error: no test specified\" && exit 1",
"prettier": "prettier --write .",
"preversion": "pnpm test",
"version": "bash ./scripts/sync-version.sh && pnpm run build && git add .",
"postversion": "git push && git push --tags",
"prepare": "husky"
},
"repository": {
"type": "git",
Expand All @@ -39,25 +45,30 @@
"homepage": "https://othent.io",
"dependencies": {
"@auth0/auth0-spa-js": "^2.1.3",
"arweave": "^1.14.4",
"arweave": "^1.15.1",
"axios": "^1.6.0",
"base64-js": "^1.5.1",
"buffer": "^6.0.3",
"extend": "^3.0.2",
"jwk-to-pem": "^2.0.5",
"jwt-decode": "^4.0.0",
"pem-jwk": "^2.0.0",
"tmp-promise": "^3.0.3",
"warp-arbundles": "^1.0.4"
},
"devDependencies": {
"tsup": "^8.0.1",
"@types/bun": "^1.0.2",
"@types/extend": "^3.0.4",
"@types/jwk-to-pem": "^2.0.1",
"@types/node": "^20.2.5",
"@types/pem-jwk": "^2.0.1",
"arconnect": "^1.0.3",
"husky": "^9.1.2",
"lint-staged": "^15.2.7",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"tslib": "^2.5.0",
"tsup": "^8.0.1",
"typescript": "^5.0.4"
},
"exports": {
Expand All @@ -66,5 +77,10 @@
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"lint-staged": {
"*": [
"prettier --write --ignore-unknown"
]
}
}
Loading