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
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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"
},
Expand Down
28 changes: 27 additions & 1 deletion src/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
},
},
}