diff --git a/package.json b/package.json index a1553a9..38d4fe3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@begin/api", - "version": "1.7.0", + "version": "1.8.0-RC.0", "description": "Node.js client for api.begin.com", "type": "module", "module": "./src/index.mjs", @@ -14,7 +14,8 @@ ], "scripts": { "lint": "eslint src --ext .js,.cjs,.mjs --fix", - "test": "npm run lint && tape test/*-test.*js | tap-arc" + "test": "npm run lint && tape test/*-test.*js | tap-arc", + "rc": "npm version prerelease --preid RC" }, "repository": { "type": "git", @@ -28,13 +29,13 @@ "homepage": "https://github.com/beginner-corp/begin-api#readme", "dependencies": { "@begin/chunker": "^1.1.2", - "tiny-json-http": "^7.5.0", + "tiny-json-http": "^7.5.1", "zip-dir": "^2.0.0" }, "devDependencies": { "@architect/eslint-config": "^2.1.1", - "dotenv": "^16.0.3", - "eslint": "^8.35.0", + "dotenv": "^16.3.1", + "eslint": "^8.43.0", "tap-arc": "^0.3.5", "tape": "^5.6.3" }, diff --git a/src/index.cjs b/src/index.cjs index 17f7755..d91d25a 100644 --- a/src/index.cjs +++ b/src/index.cjs @@ -245,5 +245,31 @@ module.exports = { return write({ token, appID, path: 'team/leave', _staging }) }, - } + }, + + tokens: { + /** + * list an account's tokens + * @param {BaseParams} options + */ + async list ({ token, _staging }) { + return read({ token, scope: 'tokens', _staging }) + }, + + /** + * generate a new token + * @param {BaseParams & {tokenType?: string}} options + */ + async create ({ token, _staging, tokenType = 'personal_access', ttl }) { + return write({ token, scope: 'tokens', _staging }, { tokenType, ttl }) + }, + + /** + * revoke a token + * @param {BaseParams & {tokenID: string}} options + */ + async revoke ({ token, appID, tokenID, _staging }) { + return write({ token, appID, scope: 'tokens', path: `${tokenID}/delete`, _staging }) + }, + }, }