Skip to content

Repository files navigation

node-kas

A drop-in replacement for KAS.

Services

To add a service, use node scripts/add-service which is an interactive CLI. To remove a service, use DELETE FROM <table prefix>services WHERE name = '<service name>'; . To modify a service, use UPDATE <table prefix>services SET <key> TO <value> WHERE name = '<service name>' . See sql/init.sql for the database structure.

API

This documentation is generated partially by using the command: node scripts/doc-responses.

Terminology

  • RL: Requires Login (Cookies)
  • RA: Rate limit
  • RS: Requires Service (Authorization: Bearer <token> HTTP header)
  • NC: CSRF Token needed (See the CSRF section)

General rules

Request should be application/x-www-form-urlencoded or application/json and Content-Type header should be set.

Returns JSON if not otherwise stated:

  • {"status":0,"message":"成功","result":"some result"} - 0 indicates OK
  • {"status":1,"message":"非法请求","code":"EINVALID_REQUEST"} - 1 indicates an invalid request
  • {"status":-1,"message":"TypeError: Cannot convert null or undefined to object","code":"EUNKNOWN"} - -1 indicates an unknown error
  • {"status":-2,"message":"您尚未登录","code":"EUNAUTHORIZED"} - -2 indicates unauthorized
  • {"status":429,"message":"您的操作过于频繁,请稍候再试。","code":"EABUSE"} - 429 indicates rate limit exceeded

Please use the code to identify exceptions when possible, as status codes (except 0) are non-informational and may subject to change.

GET /api/status

Gets the status of the service.

Responses

  • { status: 0 }

POST /api/avatar

RL NC Multipart, Sets avatar
Form fields:

  • _csrf
  • frontend = true if is a frontend request (see below); else do not present this field (or leave blank)
  • avatar:file avatar file

Returns:

  • Frontend request: redirect to home page (302) if success; else message as plain text
  • Else: see below.

Responses

  • { status: 0 }
  • { status: 2, message: 'Not an image', code: 'ENOT_IMAGE' }
  • { status: 3, message: 'Image too large', code: 'ETOO_LARGE' }

PUT /api/email

RL RA(1min), Sends verification email
Form fields:

  • email:string email address

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '这个地址已经被其他帐号绑定。', code: 'ETAKEN' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '邮件地址不正确', code: 'EINVALID_ADDRESS' }
  • { status: 5, message: '暂时无法发送邮件', code: 'ESEND' }

PUT /api/keeer-id

RL, Sets KEEER ID
Form fields:

  • id:string KEEER ID

Responses

  • { status: 0, message: '成功设置 KEEER ID' }
  • { status: 3, message: 'KEEER ID 包含非法字符', code: 'EINVALID_ID' }
  • { status: 4, message: '这个 KEEER ID 已被占用', code: 'EDUPLICATE' }

PUT /api/nickname

RL, Sets nickname
Form fields:

  • nickname:string Nickname

Responses

  • { status: 0, message: '成功修改昵称' }
  • { status: 2, message: '昵称过长', code: 'ETOO_LONG' }
  • { status: 3, message: '您不能使用这个昵称,确需使用请联系 KEEER', code: 'EINVALID_NICKNAME' }

PUT /api/password

Sets or finds back password

Set password:

RL, Form fields:

  • current:string Current password
  • password:string New password

Find back password:

Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string New password

Responses

  • { status: 0, message: '成功重置密码' }
  • { status: 0, message: '成功修改密码' }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '密码错误', code: 'EBAD_PASSWORD' }

PUT /api/phone-number

RL, Sets phone number
Form fields:

  • number:string Phone number
  • code:string Verification code

Responses

  • { status: 0, message: '成功设置手机号' }
  • { status: 2, message: '密码错误', code: 'EBAD_PASSWORD' }
  • { status: 3, message: '验证码不正确', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }

PUT /api/sms-code

RA(1min), Sends SMS.
Form fields:

  • number:string Phone number
  • type:enum Send type

Types:

  • SMS_TYPE_REGISTER Register
  • SMS_TYPE_FIND_BACK_PASSWORD Find back password
  • SMS_TYPE_SET_PHONE_NUMBER RL, Sets new phone number

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '您已经注册。', code: 'EDUPLICATE' }
  • { status: 2, message: '您尚未注册。', code: 'ENOTFOUND' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '暂时无法发送短信', code: 'ESEND' }

GET /api/user-information

RL, Gets user information
Returns:

  • avatar:string? Avatar URL
  • nickname:string? Nickname
  • keeerId:string? KEEER ID
  • kredit:int Centi-kredit

Responses

  • { status: 0, result: { avatar, nickname, keeerId, kredit } }

GET /api/sessions

RL, Gets current sessions Returns:

  • id:int session ID
  • current:boolean true if the session is the current session
  • loginTime:string ISO string of login time
  • lastSeenTime:string ISO string of last seen time
  • loginLocation:string location of login
  • lastSeenLocation:string location of last seen
  • icons:string[] icons names to show for the session
  • uaString:string name to show for the session

Responses

  • { status: 0, result: [ (...) ] }

GET /api/login-config?service=<service name>

Gets login UI config for the designated service
Returns: { title, logoSrc, backgroundUrl, themeColor, redirectUrl, backgroundCopyright, backgroundCopyrightUrl }

Responses

  • { status: 0, result: cfg }
  • { status: 0, result: false }: indicates no configuration in the service

GET /api/<login token>/kiuid

RS, Gets KIUID of the token.
Returns :string KIUID

Responses

  • { status: 0, result: user.options.kiuid }
  • { status: 2, message: '这个帐号不存在。', code: 'ENOTFOUND' }

GET /api/recharge-order?id=<order ID>[&watch=true]

RL, Gets [ and watches ] a recharge order
Returns :boolean true if completed

Responses

  • { status: 0, result: state }
  • { status: 0, result: await createLongPoll(id) }
  • { status: 2, message: '订单不存在', code: 'ENOTFOUND' }
  • { status: 127, message: '超时', code: 'ETIMEOUT' }

PUT /api/recharge-order

RL, Creates recharge order
Form fields:

  • amount:number Cents

Responses

  • { status: 0, result: '/recharge-cashier?' + search }

POST /api/pay

RS, Makes payment
Form fields:

  • type:enum Identity type, see below
  • identity:string Identity
  • amount:number Cents

Identity types:

  • phone-number or phoneNumber
  • email
  • keeer-id or keeerId
  • kiuid

Responses

  • { status: 0 }
  • { status: 2, message: '找不到帐号', code: 'ENOTFOUND' }
  • { status: 3, message: String(e), code: 'EINVALID_AMOUNT' } Invalid amount
  • { status: 4, message: '余额不足', code: 'EINSUFFICIENT_KREDIT' } User has insufficient kredit

PUT /api/token[?set-cookie=true]

Logs in (i.e. creates a token) [ and sets the token in response header ].
Headers:

  • Authorization: basic <credentials> where credentials is base64(identity ':' password)

Responses

  • { status: 0, message: '登录成功', result: token }
  • { status: 2, message: '用户名或密码错误', code: 'EBAD_CREDENTIALS' }

DELETE /api/token/<token?>[?set-cookie=true]

Log out (i.e. destroys the token in URL or cookies) [ and removes cookies ]. Token is a KEEER Account Token (i.e. UUID for current implementation) or a session ID (i.e. integer).

Responses

For KEEER Account Tokens:

  • { status: 0, message: '退出登录成功' }
  • { status: 2, message: '已失效的登录', code: 'ENOTFOUND' }

For session IDs:

  • { status: 0, message: '移除设备成功' }
  • { status: 3, message: '不存在这个设备', code: 'ENOTFOUND' }

PUT /api/user[?set-cookie=true]

Signs up (i.e. creates a new user) [ and sets token cookie in response header ]
Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string Password

Responses

  • { status: 0, message: '您已经成功注册!', result: token }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '您已经注册,请直接登录或找回密码', code: 'EDUPLICATE' }

GET /api/idframe

See IDFrame.

CSRF

Set a cookie named _csrf with a random value, and submit this random value in a form field called _csrf.

IDFrame

IDFrame is a functionality built into Node KAS that was previously available at https://idframe.keeer.net/js/appbar.js. It allows KEEER services to show a box containing user information or log in links at the top-right of a page, in order to provide common look and feel for KAS. IDFrame can only be called with a *.keeer.net referrer. Usage is shown below.

Getting started for IDFrame

<divid="idframe"></div><style>#idframe { position: fixed; top:12px; right:12px; }</style><scriptsrc="https://account.keeer.net/api/idframe"></script><script>newidFrame.AppBarFrame({container: '#idframe'})</script>

API for IDFrame

idFrame.AppBarFrame

Class representing a IDFrame object.

new AppBarFrame()
ParamTypeDescription
config.containerstring | HTMLElementIDFrame container, string will be interpreted as selector
[config.loginUrl]stringlogin button URL
[config.signupUrl]stringsignup button URL
[config.items[]]string | objectitems to show
[config.serviceName]stringKAS service name to include in login and sign up URLs

appBarFrame.updateItems(items[])

Updates menu items.

ParamTypeDescription
items[]string | objectitems to be displayed.

Build Setup

# install dependencies
$ npm install
# initialize project
$ cp sample.env .env
$ vi .env # edit application config
$ node scripts/db-init # initialize database# serve with hot reload at localhost:3000
$ npm run dev
# add a service
$ node scripts/add-service
# deploy assets to Aliyun OSS (optional)
$ node scripts/deploy-to-oss
# build for production and launch server
$ npm run build
$ npm run start
# update database schema
$ node scripts/migrate-database

Please do not run the content in sql/migration directly. Instead, use the script at scripts/migrate-database.

For detailed explanation on how things work, check out Nuxt.js docs.

About

Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - KEEER/node-kas: Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas · GitHub
Skip to content

Repository files navigation

node-kas

A drop-in replacement for KAS.

Services

To add a service, use node scripts/add-service which is an interactive CLI. To remove a service, use DELETE FROM <table prefix>services WHERE name = '<service name>'; . To modify a service, use UPDATE <table prefix>services SET <key> TO <value> WHERE name = '<service name>' . See sql/init.sql for the database structure.

API

This documentation is generated partially by using the command: node scripts/doc-responses.

Terminology

  • RL: Requires Login (Cookies)
  • RA: Rate limit
  • RS: Requires Service (Authorization: Bearer <token> HTTP header)
  • NC: CSRF Token needed (See the CSRF section)

General rules

Request should be application/x-www-form-urlencoded or application/json and Content-Type header should be set.

Returns JSON if not otherwise stated:

  • {"status":0,"message":"成功","result":"some result"} - 0 indicates OK
  • {"status":1,"message":"非法请求","code":"EINVALID_REQUEST"} - 1 indicates an invalid request
  • {"status":-1,"message":"TypeError: Cannot convert null or undefined to object","code":"EUNKNOWN"} - -1 indicates an unknown error
  • {"status":-2,"message":"您尚未登录","code":"EUNAUTHORIZED"} - -2 indicates unauthorized
  • {"status":429,"message":"您的操作过于频繁,请稍候再试。","code":"EABUSE"} - 429 indicates rate limit exceeded

Please use the code to identify exceptions when possible, as status codes (except 0) are non-informational and may subject to change.

GET /api/status

Gets the status of the service.

Responses

  • { status: 0 }

POST /api/avatar

RL NC Multipart, Sets avatar
Form fields:

  • _csrf
  • frontend = true if is a frontend request (see below); else do not present this field (or leave blank)
  • avatar:file avatar file

Returns:

  • Frontend request: redirect to home page (302) if success; else message as plain text
  • Else: see below.

Responses

  • { status: 0 }
  • { status: 2, message: 'Not an image', code: 'ENOT_IMAGE' }
  • { status: 3, message: 'Image too large', code: 'ETOO_LARGE' }

PUT /api/email

RL RA(1min), Sends verification email
Form fields:

  • email:string email address

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '这个地址已经被其他帐号绑定。', code: 'ETAKEN' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '邮件地址不正确', code: 'EINVALID_ADDRESS' }
  • { status: 5, message: '暂时无法发送邮件', code: 'ESEND' }

PUT /api/keeer-id

RL, Sets KEEER ID
Form fields:

  • id:string KEEER ID

Responses

  • { status: 0, message: '成功设置 KEEER ID' }
  • { status: 3, message: 'KEEER ID 包含非法字符', code: 'EINVALID_ID' }
  • { status: 4, message: '这个 KEEER ID 已被占用', code: 'EDUPLICATE' }

PUT /api/nickname

RL, Sets nickname
Form fields:

  • nickname:string Nickname

Responses

  • { status: 0, message: '成功修改昵称' }
  • { status: 2, message: '昵称过长', code: 'ETOO_LONG' }
  • { status: 3, message: '您不能使用这个昵称,确需使用请联系 KEEER', code: 'EINVALID_NICKNAME' }

PUT /api/password

Sets or finds back password

Set password:

RL, Form fields:

  • current:string Current password
  • password:string New password

Find back password:

Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string New password

Responses

  • { status: 0, message: '成功重置密码' }
  • { status: 0, message: '成功修改密码' }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '密码错误', code: 'EBAD_PASSWORD' }

PUT /api/phone-number

RL, Sets phone number
Form fields:

  • number:string Phone number
  • code:string Verification code

Responses

  • { status: 0, message: '成功设置手机号' }
  • { status: 2, message: '密码错误', code: 'EBAD_PASSWORD' }
  • { status: 3, message: '验证码不正确', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }

PUT /api/sms-code

RA(1min), Sends SMS.
Form fields:

  • number:string Phone number
  • type:enum Send type

Types:

  • SMS_TYPE_REGISTER Register
  • SMS_TYPE_FIND_BACK_PASSWORD Find back password
  • SMS_TYPE_SET_PHONE_NUMBER RL, Sets new phone number

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '您已经注册。', code: 'EDUPLICATE' }
  • { status: 2, message: '您尚未注册。', code: 'ENOTFOUND' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '暂时无法发送短信', code: 'ESEND' }

GET /api/user-information

RL, Gets user information
Returns:

  • avatar:string? Avatar URL
  • nickname:string? Nickname
  • keeerId:string? KEEER ID
  • kredit:int Centi-kredit

Responses

  • { status: 0, result: { avatar, nickname, keeerId, kredit } }

GET /api/sessions

RL, Gets current sessions Returns:

  • id:int session ID
  • current:boolean true if the session is the current session
  • loginTime:string ISO string of login time
  • lastSeenTime:string ISO string of last seen time
  • loginLocation:string location of login
  • lastSeenLocation:string location of last seen
  • icons:string[] icons names to show for the session
  • uaString:string name to show for the session

Responses

  • { status: 0, result: [ (...) ] }

GET /api/login-config?service=<service name>

Gets login UI config for the designated service
Returns: { title, logoSrc, backgroundUrl, themeColor, redirectUrl, backgroundCopyright, backgroundCopyrightUrl }

Responses

  • { status: 0, result: cfg }
  • { status: 0, result: false }: indicates no configuration in the service

GET /api/<login token>/kiuid

RS, Gets KIUID of the token.
Returns :string KIUID

Responses

  • { status: 0, result: user.options.kiuid }
  • { status: 2, message: '这个帐号不存在。', code: 'ENOTFOUND' }

GET /api/recharge-order?id=<order ID>[&watch=true]

RL, Gets [ and watches ] a recharge order
Returns :boolean true if completed

Responses

  • { status: 0, result: state }
  • { status: 0, result: await createLongPoll(id) }
  • { status: 2, message: '订单不存在', code: 'ENOTFOUND' }
  • { status: 127, message: '超时', code: 'ETIMEOUT' }

PUT /api/recharge-order

RL, Creates recharge order
Form fields:

  • amount:number Cents

Responses

  • { status: 0, result: '/recharge-cashier?' + search }

POST /api/pay

RS, Makes payment
Form fields:

  • type:enum Identity type, see below
  • identity:string Identity
  • amount:number Cents

Identity types:

  • phone-number or phoneNumber
  • email
  • keeer-id or keeerId
  • kiuid

Responses

  • { status: 0 }
  • { status: 2, message: '找不到帐号', code: 'ENOTFOUND' }
  • { status: 3, message: String(e), code: 'EINVALID_AMOUNT' } Invalid amount
  • { status: 4, message: '余额不足', code: 'EINSUFFICIENT_KREDIT' } User has insufficient kredit

PUT /api/token[?set-cookie=true]

Logs in (i.e. creates a token) [ and sets the token in response header ].
Headers:

  • Authorization: basic <credentials> where credentials is base64(identity ':' password)

Responses

  • { status: 0, message: '登录成功', result: token }
  • { status: 2, message: '用户名或密码错误', code: 'EBAD_CREDENTIALS' }

DELETE /api/token/<token?>[?set-cookie=true]

Log out (i.e. destroys the token in URL or cookies) [ and removes cookies ]. Token is a KEEER Account Token (i.e. UUID for current implementation) or a session ID (i.e. integer).

Responses

For KEEER Account Tokens:

  • { status: 0, message: '退出登录成功' }
  • { status: 2, message: '已失效的登录', code: 'ENOTFOUND' }

For session IDs:

  • { status: 0, message: '移除设备成功' }
  • { status: 3, message: '不存在这个设备', code: 'ENOTFOUND' }

PUT /api/user[?set-cookie=true]

Signs up (i.e. creates a new user) [ and sets token cookie in response header ]
Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string Password

Responses

  • { status: 0, message: '您已经成功注册!', result: token }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '您已经注册,请直接登录或找回密码', code: 'EDUPLICATE' }

GET /api/idframe

See IDFrame.

CSRF

Set a cookie named _csrf with a random value, and submit this random value in a form field called _csrf.

IDFrame

IDFrame is a functionality built into Node KAS that was previously available at https://idframe.keeer.net/js/appbar.js. It allows KEEER services to show a box containing user information or log in links at the top-right of a page, in order to provide common look and feel for KAS. IDFrame can only be called with a *.keeer.net referrer. Usage is shown below.

Getting started for IDFrame

<divid="idframe"></div><style>#idframe { position: fixed; top:12px; right:12px; }</style><scriptsrc="https://account.keeer.net/api/idframe"></script><script>newidFrame.AppBarFrame({container: '#idframe'})</script>

API for IDFrame

idFrame.AppBarFrame

Class representing a IDFrame object.

new AppBarFrame()
ParamTypeDescription
config.containerstring | HTMLElementIDFrame container, string will be interpreted as selector
[config.loginUrl]stringlogin button URL
[config.signupUrl]stringsignup button URL
[config.items[]]string | objectitems to show
[config.serviceName]stringKAS service name to include in login and sign up URLs

appBarFrame.updateItems(items[])

Updates menu items.

ParamTypeDescription
items[]string | objectitems to be displayed.

Build Setup

# install dependencies
$ npm install
# initialize project
$ cp sample.env .env
$ vi .env # edit application config
$ node scripts/db-init # initialize database# serve with hot reload at localhost:3000
$ npm run dev
# add a service
$ node scripts/add-service
# deploy assets to Aliyun OSS (optional)
$ node scripts/deploy-to-oss
# build for production and launch server
$ npm run build
$ npm run start
# update database schema
$ node scripts/migrate-database

Please do not run the content in sql/migration directly. Instead, use the script at scripts/migrate-database.

For detailed explanation on how things work, check out Nuxt.js docs.

About

Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - KEEER/node-kas: Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas · GitHub
Skip to content

Repository files navigation

node-kas

A drop-in replacement for KAS.

Services

To add a service, use node scripts/add-service which is an interactive CLI. To remove a service, use DELETE FROM <table prefix>services WHERE name = '<service name>'; . To modify a service, use UPDATE <table prefix>services SET <key> TO <value> WHERE name = '<service name>' . See sql/init.sql for the database structure.

API

This documentation is generated partially by using the command: node scripts/doc-responses.

Terminology

  • RL: Requires Login (Cookies)
  • RA: Rate limit
  • RS: Requires Service (Authorization: Bearer <token> HTTP header)
  • NC: CSRF Token needed (See the CSRF section)

General rules

Request should be application/x-www-form-urlencoded or application/json and Content-Type header should be set.

Returns JSON if not otherwise stated:

  • {"status":0,"message":"成功","result":"some result"} - 0 indicates OK
  • {"status":1,"message":"非法请求","code":"EINVALID_REQUEST"} - 1 indicates an invalid request
  • {"status":-1,"message":"TypeError: Cannot convert null or undefined to object","code":"EUNKNOWN"} - -1 indicates an unknown error
  • {"status":-2,"message":"您尚未登录","code":"EUNAUTHORIZED"} - -2 indicates unauthorized
  • {"status":429,"message":"您的操作过于频繁,请稍候再试。","code":"EABUSE"} - 429 indicates rate limit exceeded

Please use the code to identify exceptions when possible, as status codes (except 0) are non-informational and may subject to change.

GET /api/status

Gets the status of the service.

Responses

  • { status: 0 }

POST /api/avatar

RL NC Multipart, Sets avatar
Form fields:

  • _csrf
  • frontend = true if is a frontend request (see below); else do not present this field (or leave blank)
  • avatar:file avatar file

Returns:

  • Frontend request: redirect to home page (302) if success; else message as plain text
  • Else: see below.

Responses

  • { status: 0 }
  • { status: 2, message: 'Not an image', code: 'ENOT_IMAGE' }
  • { status: 3, message: 'Image too large', code: 'ETOO_LARGE' }

PUT /api/email

RL RA(1min), Sends verification email
Form fields:

  • email:string email address

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '这个地址已经被其他帐号绑定。', code: 'ETAKEN' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '邮件地址不正确', code: 'EINVALID_ADDRESS' }
  • { status: 5, message: '暂时无法发送邮件', code: 'ESEND' }

PUT /api/keeer-id

RL, Sets KEEER ID
Form fields:

  • id:string KEEER ID

Responses

  • { status: 0, message: '成功设置 KEEER ID' }
  • { status: 3, message: 'KEEER ID 包含非法字符', code: 'EINVALID_ID' }
  • { status: 4, message: '这个 KEEER ID 已被占用', code: 'EDUPLICATE' }

PUT /api/nickname

RL, Sets nickname
Form fields:

  • nickname:string Nickname

Responses

  • { status: 0, message: '成功修改昵称' }
  • { status: 2, message: '昵称过长', code: 'ETOO_LONG' }
  • { status: 3, message: '您不能使用这个昵称,确需使用请联系 KEEER', code: 'EINVALID_NICKNAME' }

PUT /api/password

Sets or finds back password

Set password:

RL, Form fields:

  • current:string Current password
  • password:string New password

Find back password:

Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string New password

Responses

  • { status: 0, message: '成功重置密码' }
  • { status: 0, message: '成功修改密码' }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '密码错误', code: 'EBAD_PASSWORD' }

PUT /api/phone-number

RL, Sets phone number
Form fields:

  • number:string Phone number
  • code:string Verification code

Responses

  • { status: 0, message: '成功设置手机号' }
  • { status: 2, message: '密码错误', code: 'EBAD_PASSWORD' }
  • { status: 3, message: '验证码不正确', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }

PUT /api/sms-code

RA(1min), Sends SMS.
Form fields:

  • number:string Phone number
  • type:enum Send type

Types:

  • SMS_TYPE_REGISTER Register
  • SMS_TYPE_FIND_BACK_PASSWORD Find back password
  • SMS_TYPE_SET_PHONE_NUMBER RL, Sets new phone number

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '您已经注册。', code: 'EDUPLICATE' }
  • { status: 2, message: '您尚未注册。', code: 'ENOTFOUND' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '暂时无法发送短信', code: 'ESEND' }

GET /api/user-information

RL, Gets user information
Returns:

  • avatar:string? Avatar URL
  • nickname:string? Nickname
  • keeerId:string? KEEER ID
  • kredit:int Centi-kredit

Responses

  • { status: 0, result: { avatar, nickname, keeerId, kredit } }

GET /api/sessions

RL, Gets current sessions Returns:

  • id:int session ID
  • current:boolean true if the session is the current session
  • loginTime:string ISO string of login time
  • lastSeenTime:string ISO string of last seen time
  • loginLocation:string location of login
  • lastSeenLocation:string location of last seen
  • icons:string[] icons names to show for the session
  • uaString:string name to show for the session

Responses

  • { status: 0, result: [ (...) ] }

GET /api/login-config?service=<service name>

Gets login UI config for the designated service
Returns: { title, logoSrc, backgroundUrl, themeColor, redirectUrl, backgroundCopyright, backgroundCopyrightUrl }

Responses

  • { status: 0, result: cfg }
  • { status: 0, result: false }: indicates no configuration in the service

GET /api/<login token>/kiuid

RS, Gets KIUID of the token.
Returns :string KIUID

Responses

  • { status: 0, result: user.options.kiuid }
  • { status: 2, message: '这个帐号不存在。', code: 'ENOTFOUND' }

GET /api/recharge-order?id=<order ID>[&watch=true]

RL, Gets [ and watches ] a recharge order
Returns :boolean true if completed

Responses

  • { status: 0, result: state }
  • { status: 0, result: await createLongPoll(id) }
  • { status: 2, message: '订单不存在', code: 'ENOTFOUND' }
  • { status: 127, message: '超时', code: 'ETIMEOUT' }

PUT /api/recharge-order

RL, Creates recharge order
Form fields:

  • amount:number Cents

Responses

  • { status: 0, result: '/recharge-cashier?' + search }

POST /api/pay

RS, Makes payment
Form fields:

  • type:enum Identity type, see below
  • identity:string Identity
  • amount:number Cents

Identity types:

  • phone-number or phoneNumber
  • email
  • keeer-id or keeerId
  • kiuid

Responses

  • { status: 0 }
  • { status: 2, message: '找不到帐号', code: 'ENOTFOUND' }
  • { status: 3, message: String(e), code: 'EINVALID_AMOUNT' } Invalid amount
  • { status: 4, message: '余额不足', code: 'EINSUFFICIENT_KREDIT' } User has insufficient kredit

PUT /api/token[?set-cookie=true]

Logs in (i.e. creates a token) [ and sets the token in response header ].
Headers:

  • Authorization: basic <credentials> where credentials is base64(identity ':' password)

Responses

  • { status: 0, message: '登录成功', result: token }
  • { status: 2, message: '用户名或密码错误', code: 'EBAD_CREDENTIALS' }

DELETE /api/token/<token?>[?set-cookie=true]

Log out (i.e. destroys the token in URL or cookies) [ and removes cookies ]. Token is a KEEER Account Token (i.e. UUID for current implementation) or a session ID (i.e. integer).

Responses

For KEEER Account Tokens:

  • { status: 0, message: '退出登录成功' }
  • { status: 2, message: '已失效的登录', code: 'ENOTFOUND' }

For session IDs:

  • { status: 0, message: '移除设备成功' }
  • { status: 3, message: '不存在这个设备', code: 'ENOTFOUND' }

PUT /api/user[?set-cookie=true]

Signs up (i.e. creates a new user) [ and sets token cookie in response header ]
Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string Password

Responses

  • { status: 0, message: '您已经成功注册!', result: token }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '您已经注册,请直接登录或找回密码', code: 'EDUPLICATE' }

GET /api/idframe

See IDFrame.

CSRF

Set a cookie named _csrf with a random value, and submit this random value in a form field called _csrf.

IDFrame

IDFrame is a functionality built into Node KAS that was previously available at https://idframe.keeer.net/js/appbar.js. It allows KEEER services to show a box containing user information or log in links at the top-right of a page, in order to provide common look and feel for KAS. IDFrame can only be called with a *.keeer.net referrer. Usage is shown below.

Getting started for IDFrame

<divid="idframe"></div><style>#idframe { position: fixed; top:12px; right:12px; }</style><scriptsrc="https://account.keeer.net/api/idframe"></script><script>newidFrame.AppBarFrame({container: '#idframe'})</script>

API for IDFrame

idFrame.AppBarFrame

Class representing a IDFrame object.

new AppBarFrame()
ParamTypeDescription
config.containerstring | HTMLElementIDFrame container, string will be interpreted as selector
[config.loginUrl]stringlogin button URL
[config.signupUrl]stringsignup button URL
[config.items[]]string | objectitems to show
[config.serviceName]stringKAS service name to include in login and sign up URLs

appBarFrame.updateItems(items[])

Updates menu items.

ParamTypeDescription
items[]string | objectitems to be displayed.

Build Setup

# install dependencies
$ npm install
# initialize project
$ cp sample.env .env
$ vi .env # edit application config
$ node scripts/db-init # initialize database# serve with hot reload at localhost:3000
$ npm run dev
# add a service
$ node scripts/add-service
# deploy assets to Aliyun OSS (optional)
$ node scripts/deploy-to-oss
# build for production and launch server
$ npm run build
$ npm run start
# update database schema
$ node scripts/migrate-database

Please do not run the content in sql/migration directly. Instead, use the script at scripts/migrate-database.

For detailed explanation on how things work, check out Nuxt.js docs.

About

Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - KEEER/node-kas: Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas · GitHub
Skip to content

Repository files navigation

node-kas

A drop-in replacement for KAS.

Services

To add a service, use node scripts/add-service which is an interactive CLI. To remove a service, use DELETE FROM <table prefix>services WHERE name = '<service name>'; . To modify a service, use UPDATE <table prefix>services SET <key> TO <value> WHERE name = '<service name>' . See sql/init.sql for the database structure.

API

This documentation is generated partially by using the command: node scripts/doc-responses.

Terminology

  • RL: Requires Login (Cookies)
  • RA: Rate limit
  • RS: Requires Service (Authorization: Bearer <token> HTTP header)
  • NC: CSRF Token needed (See the CSRF section)

General rules

Request should be application/x-www-form-urlencoded or application/json and Content-Type header should be set.

Returns JSON if not otherwise stated:

  • {"status":0,"message":"成功","result":"some result"} - 0 indicates OK
  • {"status":1,"message":"非法请求","code":"EINVALID_REQUEST"} - 1 indicates an invalid request
  • {"status":-1,"message":"TypeError: Cannot convert null or undefined to object","code":"EUNKNOWN"} - -1 indicates an unknown error
  • {"status":-2,"message":"您尚未登录","code":"EUNAUTHORIZED"} - -2 indicates unauthorized
  • {"status":429,"message":"您的操作过于频繁,请稍候再试。","code":"EABUSE"} - 429 indicates rate limit exceeded

Please use the code to identify exceptions when possible, as status codes (except 0) are non-informational and may subject to change.

GET /api/status

Gets the status of the service.

Responses

  • { status: 0 }

POST /api/avatar

RL NC Multipart, Sets avatar
Form fields:

  • _csrf
  • frontend = true if is a frontend request (see below); else do not present this field (or leave blank)
  • avatar:file avatar file

Returns:

  • Frontend request: redirect to home page (302) if success; else message as plain text
  • Else: see below.

Responses

  • { status: 0 }
  • { status: 2, message: 'Not an image', code: 'ENOT_IMAGE' }
  • { status: 3, message: 'Image too large', code: 'ETOO_LARGE' }

PUT /api/email

RL RA(1min), Sends verification email
Form fields:

  • email:string email address

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '这个地址已经被其他帐号绑定。', code: 'ETAKEN' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '邮件地址不正确', code: 'EINVALID_ADDRESS' }
  • { status: 5, message: '暂时无法发送邮件', code: 'ESEND' }

PUT /api/keeer-id

RL, Sets KEEER ID
Form fields:

  • id:string KEEER ID

Responses

  • { status: 0, message: '成功设置 KEEER ID' }
  • { status: 3, message: 'KEEER ID 包含非法字符', code: 'EINVALID_ID' }
  • { status: 4, message: '这个 KEEER ID 已被占用', code: 'EDUPLICATE' }

PUT /api/nickname

RL, Sets nickname
Form fields:

  • nickname:string Nickname

Responses

  • { status: 0, message: '成功修改昵称' }
  • { status: 2, message: '昵称过长', code: 'ETOO_LONG' }
  • { status: 3, message: '您不能使用这个昵称,确需使用请联系 KEEER', code: 'EINVALID_NICKNAME' }

PUT /api/password

Sets or finds back password

Set password:

RL, Form fields:

  • current:string Current password
  • password:string New password

Find back password:

Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string New password

Responses

  • { status: 0, message: '成功重置密码' }
  • { status: 0, message: '成功修改密码' }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '密码错误', code: 'EBAD_PASSWORD' }

PUT /api/phone-number

RL, Sets phone number
Form fields:

  • number:string Phone number
  • code:string Verification code

Responses

  • { status: 0, message: '成功设置手机号' }
  • { status: 2, message: '密码错误', code: 'EBAD_PASSWORD' }
  • { status: 3, message: '验证码不正确', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }

PUT /api/sms-code

RA(1min), Sends SMS.
Form fields:

  • number:string Phone number
  • type:enum Send type

Types:

  • SMS_TYPE_REGISTER Register
  • SMS_TYPE_FIND_BACK_PASSWORD Find back password
  • SMS_TYPE_SET_PHONE_NUMBER RL, Sets new phone number

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '您已经注册。', code: 'EDUPLICATE' }
  • { status: 2, message: '您尚未注册。', code: 'ENOTFOUND' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '暂时无法发送短信', code: 'ESEND' }

GET /api/user-information

RL, Gets user information
Returns:

  • avatar:string? Avatar URL
  • nickname:string? Nickname
  • keeerId:string? KEEER ID
  • kredit:int Centi-kredit

Responses

  • { status: 0, result: { avatar, nickname, keeerId, kredit } }

GET /api/sessions

RL, Gets current sessions Returns:

  • id:int session ID
  • current:boolean true if the session is the current session
  • loginTime:string ISO string of login time
  • lastSeenTime:string ISO string of last seen time
  • loginLocation:string location of login
  • lastSeenLocation:string location of last seen
  • icons:string[] icons names to show for the session
  • uaString:string name to show for the session

Responses

  • { status: 0, result: [ (...) ] }

GET /api/login-config?service=<service name>

Gets login UI config for the designated service
Returns: { title, logoSrc, backgroundUrl, themeColor, redirectUrl, backgroundCopyright, backgroundCopyrightUrl }

Responses

  • { status: 0, result: cfg }
  • { status: 0, result: false }: indicates no configuration in the service

GET /api/<login token>/kiuid

RS, Gets KIUID of the token.
Returns :string KIUID

Responses

  • { status: 0, result: user.options.kiuid }
  • { status: 2, message: '这个帐号不存在。', code: 'ENOTFOUND' }

GET /api/recharge-order?id=<order ID>[&watch=true]

RL, Gets [ and watches ] a recharge order
Returns :boolean true if completed

Responses

  • { status: 0, result: state }
  • { status: 0, result: await createLongPoll(id) }
  • { status: 2, message: '订单不存在', code: 'ENOTFOUND' }
  • { status: 127, message: '超时', code: 'ETIMEOUT' }

PUT /api/recharge-order

RL, Creates recharge order
Form fields:

  • amount:number Cents

Responses

  • { status: 0, result: '/recharge-cashier?' + search }

POST /api/pay

RS, Makes payment
Form fields:

  • type:enum Identity type, see below
  • identity:string Identity
  • amount:number Cents

Identity types:

  • phone-number or phoneNumber
  • email
  • keeer-id or keeerId
  • kiuid

Responses

  • { status: 0 }
  • { status: 2, message: '找不到帐号', code: 'ENOTFOUND' }
  • { status: 3, message: String(e), code: 'EINVALID_AMOUNT' } Invalid amount
  • { status: 4, message: '余额不足', code: 'EINSUFFICIENT_KREDIT' } User has insufficient kredit

PUT /api/token[?set-cookie=true]

Logs in (i.e. creates a token) [ and sets the token in response header ].
Headers:

  • Authorization: basic <credentials> where credentials is base64(identity ':' password)

Responses

  • { status: 0, message: '登录成功', result: token }
  • { status: 2, message: '用户名或密码错误', code: 'EBAD_CREDENTIALS' }

DELETE /api/token/<token?>[?set-cookie=true]

Log out (i.e. destroys the token in URL or cookies) [ and removes cookies ]. Token is a KEEER Account Token (i.e. UUID for current implementation) or a session ID (i.e. integer).

Responses

For KEEER Account Tokens:

  • { status: 0, message: '退出登录成功' }
  • { status: 2, message: '已失效的登录', code: 'ENOTFOUND' }

For session IDs:

  • { status: 0, message: '移除设备成功' }
  • { status: 3, message: '不存在这个设备', code: 'ENOTFOUND' }

PUT /api/user[?set-cookie=true]

Signs up (i.e. creates a new user) [ and sets token cookie in response header ]
Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string Password

Responses

  • { status: 0, message: '您已经成功注册!', result: token }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '您已经注册,请直接登录或找回密码', code: 'EDUPLICATE' }

GET /api/idframe

See IDFrame.

CSRF

Set a cookie named _csrf with a random value, and submit this random value in a form field called _csrf.

IDFrame

IDFrame is a functionality built into Node KAS that was previously available at https://idframe.keeer.net/js/appbar.js. It allows KEEER services to show a box containing user information or log in links at the top-right of a page, in order to provide common look and feel for KAS. IDFrame can only be called with a *.keeer.net referrer. Usage is shown below.

Getting started for IDFrame

<divid="idframe"></div><style>#idframe { position: fixed; top:12px; right:12px; }</style><scriptsrc="https://account.keeer.net/api/idframe"></script><script>newidFrame.AppBarFrame({container: '#idframe'})</script>

API for IDFrame

idFrame.AppBarFrame

Class representing a IDFrame object.

new AppBarFrame()
ParamTypeDescription
config.containerstring | HTMLElementIDFrame container, string will be interpreted as selector
[config.loginUrl]stringlogin button URL
[config.signupUrl]stringsignup button URL
[config.items[]]string | objectitems to show
[config.serviceName]stringKAS service name to include in login and sign up URLs

appBarFrame.updateItems(items[])

Updates menu items.

ParamTypeDescription
items[]string | objectitems to be displayed.

Build Setup

# install dependencies
$ npm install
# initialize project
$ cp sample.env .env
$ vi .env # edit application config
$ node scripts/db-init # initialize database# serve with hot reload at localhost:3000
$ npm run dev
# add a service
$ node scripts/add-service
# deploy assets to Aliyun OSS (optional)
$ node scripts/deploy-to-oss
# build for production and launch server
$ npm run build
$ npm run start
# update database schema
$ node scripts/migrate-database

Please do not run the content in sql/migration directly. Instead, use the script at scripts/migrate-database.

For detailed explanation on how things work, check out Nuxt.js docs.

About

Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - KEEER/node-kas: Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas · GitHub
Skip to content

Repository files navigation

node-kas

A drop-in replacement for KAS.

Services

To add a service, use node scripts/add-service which is an interactive CLI. To remove a service, use DELETE FROM <table prefix>services WHERE name = '<service name>'; . To modify a service, use UPDATE <table prefix>services SET <key> TO <value> WHERE name = '<service name>' . See sql/init.sql for the database structure.

API

This documentation is generated partially by using the command: node scripts/doc-responses.

Terminology

  • RL: Requires Login (Cookies)
  • RA: Rate limit
  • RS: Requires Service (Authorization: Bearer <token> HTTP header)
  • NC: CSRF Token needed (See the CSRF section)

General rules

Request should be application/x-www-form-urlencoded or application/json and Content-Type header should be set.

Returns JSON if not otherwise stated:

  • {"status":0,"message":"成功","result":"some result"} - 0 indicates OK
  • {"status":1,"message":"非法请求","code":"EINVALID_REQUEST"} - 1 indicates an invalid request
  • {"status":-1,"message":"TypeError: Cannot convert null or undefined to object","code":"EUNKNOWN"} - -1 indicates an unknown error
  • {"status":-2,"message":"您尚未登录","code":"EUNAUTHORIZED"} - -2 indicates unauthorized
  • {"status":429,"message":"您的操作过于频繁,请稍候再试。","code":"EABUSE"} - 429 indicates rate limit exceeded

Please use the code to identify exceptions when possible, as status codes (except 0) are non-informational and may subject to change.

GET /api/status

Gets the status of the service.

Responses

  • { status: 0 }

POST /api/avatar

RL NC Multipart, Sets avatar
Form fields:

  • _csrf
  • frontend = true if is a frontend request (see below); else do not present this field (or leave blank)
  • avatar:file avatar file

Returns:

  • Frontend request: redirect to home page (302) if success; else message as plain text
  • Else: see below.

Responses

  • { status: 0 }
  • { status: 2, message: 'Not an image', code: 'ENOT_IMAGE' }
  • { status: 3, message: 'Image too large', code: 'ETOO_LARGE' }

PUT /api/email

RL RA(1min), Sends verification email
Form fields:

  • email:string email address

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '这个地址已经被其他帐号绑定。', code: 'ETAKEN' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '邮件地址不正确', code: 'EINVALID_ADDRESS' }
  • { status: 5, message: '暂时无法发送邮件', code: 'ESEND' }

PUT /api/keeer-id

RL, Sets KEEER ID
Form fields:

  • id:string KEEER ID

Responses

  • { status: 0, message: '成功设置 KEEER ID' }
  • { status: 3, message: 'KEEER ID 包含非法字符', code: 'EINVALID_ID' }
  • { status: 4, message: '这个 KEEER ID 已被占用', code: 'EDUPLICATE' }

PUT /api/nickname

RL, Sets nickname
Form fields:

  • nickname:string Nickname

Responses

  • { status: 0, message: '成功修改昵称' }
  • { status: 2, message: '昵称过长', code: 'ETOO_LONG' }
  • { status: 3, message: '您不能使用这个昵称,确需使用请联系 KEEER', code: 'EINVALID_NICKNAME' }

PUT /api/password

Sets or finds back password

Set password:

RL, Form fields:

  • current:string Current password
  • password:string New password

Find back password:

Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string New password

Responses

  • { status: 0, message: '成功重置密码' }
  • { status: 0, message: '成功修改密码' }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '密码错误', code: 'EBAD_PASSWORD' }

PUT /api/phone-number

RL, Sets phone number
Form fields:

  • number:string Phone number
  • code:string Verification code

Responses

  • { status: 0, message: '成功设置手机号' }
  • { status: 2, message: '密码错误', code: 'EBAD_PASSWORD' }
  • { status: 3, message: '验证码不正确', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }

PUT /api/sms-code

RA(1min), Sends SMS.
Form fields:

  • number:string Phone number
  • type:enum Send type

Types:

  • SMS_TYPE_REGISTER Register
  • SMS_TYPE_FIND_BACK_PASSWORD Find back password
  • SMS_TYPE_SET_PHONE_NUMBER RL, Sets new phone number

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '您已经注册。', code: 'EDUPLICATE' }
  • { status: 2, message: '您尚未注册。', code: 'ENOTFOUND' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '暂时无法发送短信', code: 'ESEND' }

GET /api/user-information

RL, Gets user information
Returns:

  • avatar:string? Avatar URL
  • nickname:string? Nickname
  • keeerId:string? KEEER ID
  • kredit:int Centi-kredit

Responses

  • { status: 0, result: { avatar, nickname, keeerId, kredit } }

GET /api/sessions

RL, Gets current sessions Returns:

  • id:int session ID
  • current:boolean true if the session is the current session
  • loginTime:string ISO string of login time
  • lastSeenTime:string ISO string of last seen time
  • loginLocation:string location of login
  • lastSeenLocation:string location of last seen
  • icons:string[] icons names to show for the session
  • uaString:string name to show for the session

Responses

  • { status: 0, result: [ (...) ] }

GET /api/login-config?service=<service name>

Gets login UI config for the designated service
Returns: { title, logoSrc, backgroundUrl, themeColor, redirectUrl, backgroundCopyright, backgroundCopyrightUrl }

Responses

  • { status: 0, result: cfg }
  • { status: 0, result: false }: indicates no configuration in the service

GET /api/<login token>/kiuid

RS, Gets KIUID of the token.
Returns :string KIUID

Responses

  • { status: 0, result: user.options.kiuid }
  • { status: 2, message: '这个帐号不存在。', code: 'ENOTFOUND' }

GET /api/recharge-order?id=<order ID>[&watch=true]

RL, Gets [ and watches ] a recharge order
Returns :boolean true if completed

Responses

  • { status: 0, result: state }
  • { status: 0, result: await createLongPoll(id) }
  • { status: 2, message: '订单不存在', code: 'ENOTFOUND' }
  • { status: 127, message: '超时', code: 'ETIMEOUT' }

PUT /api/recharge-order

RL, Creates recharge order
Form fields:

  • amount:number Cents

Responses

  • { status: 0, result: '/recharge-cashier?' + search }

POST /api/pay

RS, Makes payment
Form fields:

  • type:enum Identity type, see below
  • identity:string Identity
  • amount:number Cents

Identity types:

  • phone-number or phoneNumber
  • email
  • keeer-id or keeerId
  • kiuid

Responses

  • { status: 0 }
  • { status: 2, message: '找不到帐号', code: 'ENOTFOUND' }
  • { status: 3, message: String(e), code: 'EINVALID_AMOUNT' } Invalid amount
  • { status: 4, message: '余额不足', code: 'EINSUFFICIENT_KREDIT' } User has insufficient kredit

PUT /api/token[?set-cookie=true]

Logs in (i.e. creates a token) [ and sets the token in response header ].
Headers:

  • Authorization: basic <credentials> where credentials is base64(identity ':' password)

Responses

  • { status: 0, message: '登录成功', result: token }
  • { status: 2, message: '用户名或密码错误', code: 'EBAD_CREDENTIALS' }

DELETE /api/token/<token?>[?set-cookie=true]

Log out (i.e. destroys the token in URL or cookies) [ and removes cookies ]. Token is a KEEER Account Token (i.e. UUID for current implementation) or a session ID (i.e. integer).

Responses

For KEEER Account Tokens:

  • { status: 0, message: '退出登录成功' }
  • { status: 2, message: '已失效的登录', code: 'ENOTFOUND' }

For session IDs:

  • { status: 0, message: '移除设备成功' }
  • { status: 3, message: '不存在这个设备', code: 'ENOTFOUND' }

PUT /api/user[?set-cookie=true]

Signs up (i.e. creates a new user) [ and sets token cookie in response header ]
Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string Password

Responses

  • { status: 0, message: '您已经成功注册!', result: token }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '您已经注册,请直接登录或找回密码', code: 'EDUPLICATE' }

GET /api/idframe

See IDFrame.

CSRF

Set a cookie named _csrf with a random value, and submit this random value in a form field called _csrf.

IDFrame

IDFrame is a functionality built into Node KAS that was previously available at https://idframe.keeer.net/js/appbar.js. It allows KEEER services to show a box containing user information or log in links at the top-right of a page, in order to provide common look and feel for KAS. IDFrame can only be called with a *.keeer.net referrer. Usage is shown below.

Getting started for IDFrame

<divid="idframe"></div><style>#idframe { position: fixed; top:12px; right:12px; }</style><scriptsrc="https://account.keeer.net/api/idframe"></script><script>newidFrame.AppBarFrame({container: '#idframe'})</script>

API for IDFrame

idFrame.AppBarFrame

Class representing a IDFrame object.

new AppBarFrame()
ParamTypeDescription
config.containerstring | HTMLElementIDFrame container, string will be interpreted as selector
[config.loginUrl]stringlogin button URL
[config.signupUrl]stringsignup button URL
[config.items[]]string | objectitems to show
[config.serviceName]stringKAS service name to include in login and sign up URLs

appBarFrame.updateItems(items[])

Updates menu items.

ParamTypeDescription
items[]string | objectitems to be displayed.

Build Setup

# install dependencies
$ npm install
# initialize project
$ cp sample.env .env
$ vi .env # edit application config
$ node scripts/db-init # initialize database# serve with hot reload at localhost:3000
$ npm run dev
# add a service
$ node scripts/add-service
# deploy assets to Aliyun OSS (optional)
$ node scripts/deploy-to-oss
# build for production and launch server
$ npm run build
$ npm run start
# update database schema
$ node scripts/migrate-database

Please do not run the content in sql/migration directly. Instead, use the script at scripts/migrate-database.

For detailed explanation on how things work, check out Nuxt.js docs.

About

Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - KEEER/node-kas: Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas · GitHub
Skip to content

Repository files navigation

node-kas

A drop-in replacement for KAS.

Services

To add a service, use node scripts/add-service which is an interactive CLI. To remove a service, use DELETE FROM <table prefix>services WHERE name = '<service name>'; . To modify a service, use UPDATE <table prefix>services SET <key> TO <value> WHERE name = '<service name>' . See sql/init.sql for the database structure.

API

This documentation is generated partially by using the command: node scripts/doc-responses.

Terminology

  • RL: Requires Login (Cookies)
  • RA: Rate limit
  • RS: Requires Service (Authorization: Bearer <token> HTTP header)
  • NC: CSRF Token needed (See the CSRF section)

General rules

Request should be application/x-www-form-urlencoded or application/json and Content-Type header should be set.

Returns JSON if not otherwise stated:

  • {"status":0,"message":"成功","result":"some result"} - 0 indicates OK
  • {"status":1,"message":"非法请求","code":"EINVALID_REQUEST"} - 1 indicates an invalid request
  • {"status":-1,"message":"TypeError: Cannot convert null or undefined to object","code":"EUNKNOWN"} - -1 indicates an unknown error
  • {"status":-2,"message":"您尚未登录","code":"EUNAUTHORIZED"} - -2 indicates unauthorized
  • {"status":429,"message":"您的操作过于频繁,请稍候再试。","code":"EABUSE"} - 429 indicates rate limit exceeded

Please use the code to identify exceptions when possible, as status codes (except 0) are non-informational and may subject to change.

GET /api/status

Gets the status of the service.

Responses

  • { status: 0 }

POST /api/avatar

RL NC Multipart, Sets avatar
Form fields:

  • _csrf
  • frontend = true if is a frontend request (see below); else do not present this field (or leave blank)
  • avatar:file avatar file

Returns:

  • Frontend request: redirect to home page (302) if success; else message as plain text
  • Else: see below.

Responses

  • { status: 0 }
  • { status: 2, message: 'Not an image', code: 'ENOT_IMAGE' }
  • { status: 3, message: 'Image too large', code: 'ETOO_LARGE' }

PUT /api/email

RL RA(1min), Sends verification email
Form fields:

  • email:string email address

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '这个地址已经被其他帐号绑定。', code: 'ETAKEN' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '邮件地址不正确', code: 'EINVALID_ADDRESS' }
  • { status: 5, message: '暂时无法发送邮件', code: 'ESEND' }

PUT /api/keeer-id

RL, Sets KEEER ID
Form fields:

  • id:string KEEER ID

Responses

  • { status: 0, message: '成功设置 KEEER ID' }
  • { status: 3, message: 'KEEER ID 包含非法字符', code: 'EINVALID_ID' }
  • { status: 4, message: '这个 KEEER ID 已被占用', code: 'EDUPLICATE' }

PUT /api/nickname

RL, Sets nickname
Form fields:

  • nickname:string Nickname

Responses

  • { status: 0, message: '成功修改昵称' }
  • { status: 2, message: '昵称过长', code: 'ETOO_LONG' }
  • { status: 3, message: '您不能使用这个昵称,确需使用请联系 KEEER', code: 'EINVALID_NICKNAME' }

PUT /api/password

Sets or finds back password

Set password:

RL, Form fields:

  • current:string Current password
  • password:string New password

Find back password:

Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string New password

Responses

  • { status: 0, message: '成功重置密码' }
  • { status: 0, message: '成功修改密码' }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '密码错误', code: 'EBAD_PASSWORD' }

PUT /api/phone-number

RL, Sets phone number
Form fields:

  • number:string Phone number
  • code:string Verification code

Responses

  • { status: 0, message: '成功设置手机号' }
  • { status: 2, message: '密码错误', code: 'EBAD_PASSWORD' }
  • { status: 3, message: '验证码不正确', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }

PUT /api/sms-code

RA(1min), Sends SMS.
Form fields:

  • number:string Phone number
  • type:enum Send type

Types:

  • SMS_TYPE_REGISTER Register
  • SMS_TYPE_FIND_BACK_PASSWORD Find back password
  • SMS_TYPE_SET_PHONE_NUMBER RL, Sets new phone number

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '您已经注册。', code: 'EDUPLICATE' }
  • { status: 2, message: '您尚未注册。', code: 'ENOTFOUND' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '暂时无法发送短信', code: 'ESEND' }

GET /api/user-information

RL, Gets user information
Returns:

  • avatar:string? Avatar URL
  • nickname:string? Nickname
  • keeerId:string? KEEER ID
  • kredit:int Centi-kredit

Responses

  • { status: 0, result: { avatar, nickname, keeerId, kredit } }

GET /api/sessions

RL, Gets current sessions Returns:

  • id:int session ID
  • current:boolean true if the session is the current session
  • loginTime:string ISO string of login time
  • lastSeenTime:string ISO string of last seen time
  • loginLocation:string location of login
  • lastSeenLocation:string location of last seen
  • icons:string[] icons names to show for the session
  • uaString:string name to show for the session

Responses

  • { status: 0, result: [ (...) ] }

GET /api/login-config?service=<service name>

Gets login UI config for the designated service
Returns: { title, logoSrc, backgroundUrl, themeColor, redirectUrl, backgroundCopyright, backgroundCopyrightUrl }

Responses

  • { status: 0, result: cfg }
  • { status: 0, result: false }: indicates no configuration in the service

GET /api/<login token>/kiuid

RS, Gets KIUID of the token.
Returns :string KIUID

Responses

  • { status: 0, result: user.options.kiuid }
  • { status: 2, message: '这个帐号不存在。', code: 'ENOTFOUND' }

GET /api/recharge-order?id=<order ID>[&watch=true]

RL, Gets [ and watches ] a recharge order
Returns :boolean true if completed

Responses

  • { status: 0, result: state }
  • { status: 0, result: await createLongPoll(id) }
  • { status: 2, message: '订单不存在', code: 'ENOTFOUND' }
  • { status: 127, message: '超时', code: 'ETIMEOUT' }

PUT /api/recharge-order

RL, Creates recharge order
Form fields:

  • amount:number Cents

Responses

  • { status: 0, result: '/recharge-cashier?' + search }

POST /api/pay

RS, Makes payment
Form fields:

  • type:enum Identity type, see below
  • identity:string Identity
  • amount:number Cents

Identity types:

  • phone-number or phoneNumber
  • email
  • keeer-id or keeerId
  • kiuid

Responses

  • { status: 0 }
  • { status: 2, message: '找不到帐号', code: 'ENOTFOUND' }
  • { status: 3, message: String(e), code: 'EINVALID_AMOUNT' } Invalid amount
  • { status: 4, message: '余额不足', code: 'EINSUFFICIENT_KREDIT' } User has insufficient kredit

PUT /api/token[?set-cookie=true]

Logs in (i.e. creates a token) [ and sets the token in response header ].
Headers:

  • Authorization: basic <credentials> where credentials is base64(identity ':' password)

Responses

  • { status: 0, message: '登录成功', result: token }
  • { status: 2, message: '用户名或密码错误', code: 'EBAD_CREDENTIALS' }

DELETE /api/token/<token?>[?set-cookie=true]

Log out (i.e. destroys the token in URL or cookies) [ and removes cookies ]. Token is a KEEER Account Token (i.e. UUID for current implementation) or a session ID (i.e. integer).

Responses

For KEEER Account Tokens:

  • { status: 0, message: '退出登录成功' }
  • { status: 2, message: '已失效的登录', code: 'ENOTFOUND' }

For session IDs:

  • { status: 0, message: '移除设备成功' }
  • { status: 3, message: '不存在这个设备', code: 'ENOTFOUND' }

PUT /api/user[?set-cookie=true]

Signs up (i.e. creates a new user) [ and sets token cookie in response header ]
Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string Password

Responses

  • { status: 0, message: '您已经成功注册!', result: token }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '您已经注册,请直接登录或找回密码', code: 'EDUPLICATE' }

GET /api/idframe

See IDFrame.

CSRF

Set a cookie named _csrf with a random value, and submit this random value in a form field called _csrf.

IDFrame

IDFrame is a functionality built into Node KAS that was previously available at https://idframe.keeer.net/js/appbar.js. It allows KEEER services to show a box containing user information or log in links at the top-right of a page, in order to provide common look and feel for KAS. IDFrame can only be called with a *.keeer.net referrer. Usage is shown below.

Getting started for IDFrame

<divid="idframe"></div><style>#idframe { position: fixed; top:12px; right:12px; }</style><scriptsrc="https://account.keeer.net/api/idframe"></script><script>newidFrame.AppBarFrame({container: '#idframe'})</script>

API for IDFrame

idFrame.AppBarFrame

Class representing a IDFrame object.

new AppBarFrame()
ParamTypeDescription
config.containerstring | HTMLElementIDFrame container, string will be interpreted as selector
[config.loginUrl]stringlogin button URL
[config.signupUrl]stringsignup button URL
[config.items[]]string | objectitems to show
[config.serviceName]stringKAS service name to include in login and sign up URLs

appBarFrame.updateItems(items[])

Updates menu items.

ParamTypeDescription
items[]string | objectitems to be displayed.

Build Setup

# install dependencies
$ npm install
# initialize project
$ cp sample.env .env
$ vi .env # edit application config
$ node scripts/db-init # initialize database# serve with hot reload at localhost:3000
$ npm run dev
# add a service
$ node scripts/add-service
# deploy assets to Aliyun OSS (optional)
$ node scripts/deploy-to-oss
# build for production and launch server
$ npm run build
$ npm run start
# update database schema
$ node scripts/migrate-database

Please do not run the content in sql/migration directly. Instead, use the script at scripts/migrate-database.

For detailed explanation on how things work, check out Nuxt.js docs.

About

Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - KEEER/node-kas: Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas · GitHub
Skip to content

Repository files navigation

node-kas

A drop-in replacement for KAS.

Services

To add a service, use node scripts/add-service which is an interactive CLI. To remove a service, use DELETE FROM <table prefix>services WHERE name = '<service name>'; . To modify a service, use UPDATE <table prefix>services SET <key> TO <value> WHERE name = '<service name>' . See sql/init.sql for the database structure.

API

This documentation is generated partially by using the command: node scripts/doc-responses.

Terminology

  • RL: Requires Login (Cookies)
  • RA: Rate limit
  • RS: Requires Service (Authorization: Bearer <token> HTTP header)
  • NC: CSRF Token needed (See the CSRF section)

General rules

Request should be application/x-www-form-urlencoded or application/json and Content-Type header should be set.

Returns JSON if not otherwise stated:

  • {"status":0,"message":"成功","result":"some result"} - 0 indicates OK
  • {"status":1,"message":"非法请求","code":"EINVALID_REQUEST"} - 1 indicates an invalid request
  • {"status":-1,"message":"TypeError: Cannot convert null or undefined to object","code":"EUNKNOWN"} - -1 indicates an unknown error
  • {"status":-2,"message":"您尚未登录","code":"EUNAUTHORIZED"} - -2 indicates unauthorized
  • {"status":429,"message":"您的操作过于频繁,请稍候再试。","code":"EABUSE"} - 429 indicates rate limit exceeded

Please use the code to identify exceptions when possible, as status codes (except 0) are non-informational and may subject to change.

GET /api/status

Gets the status of the service.

Responses

  • { status: 0 }

POST /api/avatar

RL NC Multipart, Sets avatar
Form fields:

  • _csrf
  • frontend = true if is a frontend request (see below); else do not present this field (or leave blank)
  • avatar:file avatar file

Returns:

  • Frontend request: redirect to home page (302) if success; else message as plain text
  • Else: see below.

Responses

  • { status: 0 }
  • { status: 2, message: 'Not an image', code: 'ENOT_IMAGE' }
  • { status: 3, message: 'Image too large', code: 'ETOO_LARGE' }

PUT /api/email

RL RA(1min), Sends verification email
Form fields:

  • email:string email address

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '这个地址已经被其他帐号绑定。', code: 'ETAKEN' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '邮件地址不正确', code: 'EINVALID_ADDRESS' }
  • { status: 5, message: '暂时无法发送邮件', code: 'ESEND' }

PUT /api/keeer-id

RL, Sets KEEER ID
Form fields:

  • id:string KEEER ID

Responses

  • { status: 0, message: '成功设置 KEEER ID' }
  • { status: 3, message: 'KEEER ID 包含非法字符', code: 'EINVALID_ID' }
  • { status: 4, message: '这个 KEEER ID 已被占用', code: 'EDUPLICATE' }

PUT /api/nickname

RL, Sets nickname
Form fields:

  • nickname:string Nickname

Responses

  • { status: 0, message: '成功修改昵称' }
  • { status: 2, message: '昵称过长', code: 'ETOO_LONG' }
  • { status: 3, message: '您不能使用这个昵称,确需使用请联系 KEEER', code: 'EINVALID_NICKNAME' }

PUT /api/password

Sets or finds back password

Set password:

RL, Form fields:

  • current:string Current password
  • password:string New password

Find back password:

Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string New password

Responses

  • { status: 0, message: '成功重置密码' }
  • { status: 0, message: '成功修改密码' }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '密码错误', code: 'EBAD_PASSWORD' }

PUT /api/phone-number

RL, Sets phone number
Form fields:

  • number:string Phone number
  • code:string Verification code

Responses

  • { status: 0, message: '成功设置手机号' }
  • { status: 2, message: '密码错误', code: 'EBAD_PASSWORD' }
  • { status: 3, message: '验证码不正确', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }

PUT /api/sms-code

RA(1min), Sends SMS.
Form fields:

  • number:string Phone number
  • type:enum Send type

Types:

  • SMS_TYPE_REGISTER Register
  • SMS_TYPE_FIND_BACK_PASSWORD Find back password
  • SMS_TYPE_SET_PHONE_NUMBER RL, Sets new phone number

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '您已经注册。', code: 'EDUPLICATE' }
  • { status: 2, message: '您尚未注册。', code: 'ENOTFOUND' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '暂时无法发送短信', code: 'ESEND' }

GET /api/user-information

RL, Gets user information
Returns:

  • avatar:string? Avatar URL
  • nickname:string? Nickname
  • keeerId:string? KEEER ID
  • kredit:int Centi-kredit

Responses

  • { status: 0, result: { avatar, nickname, keeerId, kredit } }

GET /api/sessions

RL, Gets current sessions Returns:

  • id:int session ID
  • current:boolean true if the session is the current session
  • loginTime:string ISO string of login time
  • lastSeenTime:string ISO string of last seen time
  • loginLocation:string location of login
  • lastSeenLocation:string location of last seen
  • icons:string[] icons names to show for the session
  • uaString:string name to show for the session

Responses

  • { status: 0, result: [ (...) ] }

GET /api/login-config?service=<service name>

Gets login UI config for the designated service
Returns: { title, logoSrc, backgroundUrl, themeColor, redirectUrl, backgroundCopyright, backgroundCopyrightUrl }

Responses

  • { status: 0, result: cfg }
  • { status: 0, result: false }: indicates no configuration in the service

GET /api/<login token>/kiuid

RS, Gets KIUID of the token.
Returns :string KIUID

Responses

  • { status: 0, result: user.options.kiuid }
  • { status: 2, message: '这个帐号不存在。', code: 'ENOTFOUND' }

GET /api/recharge-order?id=<order ID>[&watch=true]

RL, Gets [ and watches ] a recharge order
Returns :boolean true if completed

Responses

  • { status: 0, result: state }
  • { status: 0, result: await createLongPoll(id) }
  • { status: 2, message: '订单不存在', code: 'ENOTFOUND' }
  • { status: 127, message: '超时', code: 'ETIMEOUT' }

PUT /api/recharge-order

RL, Creates recharge order
Form fields:

  • amount:number Cents

Responses

  • { status: 0, result: '/recharge-cashier?' + search }

POST /api/pay

RS, Makes payment
Form fields:

  • type:enum Identity type, see below
  • identity:string Identity
  • amount:number Cents

Identity types:

  • phone-number or phoneNumber
  • email
  • keeer-id or keeerId
  • kiuid

Responses

  • { status: 0 }
  • { status: 2, message: '找不到帐号', code: 'ENOTFOUND' }
  • { status: 3, message: String(e), code: 'EINVALID_AMOUNT' } Invalid amount
  • { status: 4, message: '余额不足', code: 'EINSUFFICIENT_KREDIT' } User has insufficient kredit

PUT /api/token[?set-cookie=true]

Logs in (i.e. creates a token) [ and sets the token in response header ].
Headers:

  • Authorization: basic <credentials> where credentials is base64(identity ':' password)

Responses

  • { status: 0, message: '登录成功', result: token }
  • { status: 2, message: '用户名或密码错误', code: 'EBAD_CREDENTIALS' }

DELETE /api/token/<token?>[?set-cookie=true]

Log out (i.e. destroys the token in URL or cookies) [ and removes cookies ]. Token is a KEEER Account Token (i.e. UUID for current implementation) or a session ID (i.e. integer).

Responses

For KEEER Account Tokens:

  • { status: 0, message: '退出登录成功' }
  • { status: 2, message: '已失效的登录', code: 'ENOTFOUND' }

For session IDs:

  • { status: 0, message: '移除设备成功' }
  • { status: 3, message: '不存在这个设备', code: 'ENOTFOUND' }

PUT /api/user[?set-cookie=true]

Signs up (i.e. creates a new user) [ and sets token cookie in response header ]
Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string Password

Responses

  • { status: 0, message: '您已经成功注册!', result: token }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '您已经注册,请直接登录或找回密码', code: 'EDUPLICATE' }

GET /api/idframe

See IDFrame.

CSRF

Set a cookie named _csrf with a random value, and submit this random value in a form field called _csrf.

IDFrame

IDFrame is a functionality built into Node KAS that was previously available at https://idframe.keeer.net/js/appbar.js. It allows KEEER services to show a box containing user information or log in links at the top-right of a page, in order to provide common look and feel for KAS. IDFrame can only be called with a *.keeer.net referrer. Usage is shown below.

Getting started for IDFrame

<divid="idframe"></div><style>#idframe { position: fixed; top:12px; right:12px; }</style><scriptsrc="https://account.keeer.net/api/idframe"></script><script>newidFrame.AppBarFrame({container: '#idframe'})</script>

API for IDFrame

idFrame.AppBarFrame

Class representing a IDFrame object.

new AppBarFrame()
ParamTypeDescription
config.containerstring | HTMLElementIDFrame container, string will be interpreted as selector
[config.loginUrl]stringlogin button URL
[config.signupUrl]stringsignup button URL
[config.items[]]string | objectitems to show
[config.serviceName]stringKAS service name to include in login and sign up URLs

appBarFrame.updateItems(items[])

Updates menu items.

ParamTypeDescription
items[]string | objectitems to be displayed.

Build Setup

# install dependencies
$ npm install
# initialize project
$ cp sample.env .env
$ vi .env # edit application config
$ node scripts/db-init # initialize database# serve with hot reload at localhost:3000
$ npm run dev
# add a service
$ node scripts/add-service
# deploy assets to Aliyun OSS (optional)
$ node scripts/deploy-to-oss
# build for production and launch server
$ npm run build
$ npm run start
# update database schema
$ node scripts/migrate-database

Please do not run the content in sql/migration directly. Instead, use the script at scripts/migrate-database.

For detailed explanation on how things work, check out Nuxt.js docs.

About

Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - KEEER/node-kas: Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas · GitHub
Skip to content

Repository files navigation

node-kas

A drop-in replacement for KAS.

Services

To add a service, use node scripts/add-service which is an interactive CLI. To remove a service, use DELETE FROM <table prefix>services WHERE name = '<service name>'; . To modify a service, use UPDATE <table prefix>services SET <key> TO <value> WHERE name = '<service name>' . See sql/init.sql for the database structure.

API

This documentation is generated partially by using the command: node scripts/doc-responses.

Terminology

  • RL: Requires Login (Cookies)
  • RA: Rate limit
  • RS: Requires Service (Authorization: Bearer <token> HTTP header)
  • NC: CSRF Token needed (See the CSRF section)

General rules

Request should be application/x-www-form-urlencoded or application/json and Content-Type header should be set.

Returns JSON if not otherwise stated:

  • {"status":0,"message":"成功","result":"some result"} - 0 indicates OK
  • {"status":1,"message":"非法请求","code":"EINVALID_REQUEST"} - 1 indicates an invalid request
  • {"status":-1,"message":"TypeError: Cannot convert null or undefined to object","code":"EUNKNOWN"} - -1 indicates an unknown error
  • {"status":-2,"message":"您尚未登录","code":"EUNAUTHORIZED"} - -2 indicates unauthorized
  • {"status":429,"message":"您的操作过于频繁,请稍候再试。","code":"EABUSE"} - 429 indicates rate limit exceeded

Please use the code to identify exceptions when possible, as status codes (except 0) are non-informational and may subject to change.

GET /api/status

Gets the status of the service.

Responses

  • { status: 0 }

POST /api/avatar

RL NC Multipart, Sets avatar
Form fields:

  • _csrf
  • frontend = true if is a frontend request (see below); else do not present this field (or leave blank)
  • avatar:file avatar file

Returns:

  • Frontend request: redirect to home page (302) if success; else message as plain text
  • Else: see below.

Responses

  • { status: 0 }
  • { status: 2, message: 'Not an image', code: 'ENOT_IMAGE' }
  • { status: 3, message: 'Image too large', code: 'ETOO_LARGE' }

PUT /api/email

RL RA(1min), Sends verification email
Form fields:

  • email:string email address

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '这个地址已经被其他帐号绑定。', code: 'ETAKEN' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '邮件地址不正确', code: 'EINVALID_ADDRESS' }
  • { status: 5, message: '暂时无法发送邮件', code: 'ESEND' }

PUT /api/keeer-id

RL, Sets KEEER ID
Form fields:

  • id:string KEEER ID

Responses

  • { status: 0, message: '成功设置 KEEER ID' }
  • { status: 3, message: 'KEEER ID 包含非法字符', code: 'EINVALID_ID' }
  • { status: 4, message: '这个 KEEER ID 已被占用', code: 'EDUPLICATE' }

PUT /api/nickname

RL, Sets nickname
Form fields:

  • nickname:string Nickname

Responses

  • { status: 0, message: '成功修改昵称' }
  • { status: 2, message: '昵称过长', code: 'ETOO_LONG' }
  • { status: 3, message: '您不能使用这个昵称,确需使用请联系 KEEER', code: 'EINVALID_NICKNAME' }

PUT /api/password

Sets or finds back password

Set password:

RL, Form fields:

  • current:string Current password
  • password:string New password

Find back password:

Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string New password

Responses

  • { status: 0, message: '成功重置密码' }
  • { status: 0, message: '成功修改密码' }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '密码错误', code: 'EBAD_PASSWORD' }

PUT /api/phone-number

RL, Sets phone number
Form fields:

  • number:string Phone number
  • code:string Verification code

Responses

  • { status: 0, message: '成功设置手机号' }
  • { status: 2, message: '密码错误', code: 'EBAD_PASSWORD' }
  • { status: 3, message: '验证码不正确', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }

PUT /api/sms-code

RA(1min), Sends SMS.
Form fields:

  • number:string Phone number
  • type:enum Send type

Types:

  • SMS_TYPE_REGISTER Register
  • SMS_TYPE_FIND_BACK_PASSWORD Find back password
  • SMS_TYPE_SET_PHONE_NUMBER RL, Sets new phone number

Responses

  • { status: 0, message: '验证码已发送,请查收。' }
  • { status: 2, message: '您已经注册。', code: 'EDUPLICATE' }
  • { status: 2, message: '您尚未注册。', code: 'ENOTFOUND' }
  • { status: 3, message: '操作过于频繁,请过一分钟后再试', code: 'EABUSE' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '暂时无法发送短信', code: 'ESEND' }

GET /api/user-information

RL, Gets user information
Returns:

  • avatar:string? Avatar URL
  • nickname:string? Nickname
  • keeerId:string? KEEER ID
  • kredit:int Centi-kredit

Responses

  • { status: 0, result: { avatar, nickname, keeerId, kredit } }

GET /api/sessions

RL, Gets current sessions Returns:

  • id:int session ID
  • current:boolean true if the session is the current session
  • loginTime:string ISO string of login time
  • lastSeenTime:string ISO string of last seen time
  • loginLocation:string location of login
  • lastSeenLocation:string location of last seen
  • icons:string[] icons names to show for the session
  • uaString:string name to show for the session

Responses

  • { status: 0, result: [ (...) ] }

GET /api/login-config?service=<service name>

Gets login UI config for the designated service
Returns: { title, logoSrc, backgroundUrl, themeColor, redirectUrl, backgroundCopyright, backgroundCopyrightUrl }

Responses

  • { status: 0, result: cfg }
  • { status: 0, result: false }: indicates no configuration in the service

GET /api/<login token>/kiuid

RS, Gets KIUID of the token.
Returns :string KIUID

Responses

  • { status: 0, result: user.options.kiuid }
  • { status: 2, message: '这个帐号不存在。', code: 'ENOTFOUND' }

GET /api/recharge-order?id=<order ID>[&watch=true]

RL, Gets [ and watches ] a recharge order
Returns :boolean true if completed

Responses

  • { status: 0, result: state }
  • { status: 0, result: await createLongPoll(id) }
  • { status: 2, message: '订单不存在', code: 'ENOTFOUND' }
  • { status: 127, message: '超时', code: 'ETIMEOUT' }

PUT /api/recharge-order

RL, Creates recharge order
Form fields:

  • amount:number Cents

Responses

  • { status: 0, result: '/recharge-cashier?' + search }

POST /api/pay

RS, Makes payment
Form fields:

  • type:enum Identity type, see below
  • identity:string Identity
  • amount:number Cents

Identity types:

  • phone-number or phoneNumber
  • email
  • keeer-id or keeerId
  • kiuid

Responses

  • { status: 0 }
  • { status: 2, message: '找不到帐号', code: 'ENOTFOUND' }
  • { status: 3, message: String(e), code: 'EINVALID_AMOUNT' } Invalid amount
  • { status: 4, message: '余额不足', code: 'EINSUFFICIENT_KREDIT' } User has insufficient kredit

PUT /api/token[?set-cookie=true]

Logs in (i.e. creates a token) [ and sets the token in response header ].
Headers:

  • Authorization: basic <credentials> where credentials is base64(identity ':' password)

Responses

  • { status: 0, message: '登录成功', result: token }
  • { status: 2, message: '用户名或密码错误', code: 'EBAD_CREDENTIALS' }

DELETE /api/token/<token?>[?set-cookie=true]

Log out (i.e. destroys the token in URL or cookies) [ and removes cookies ]. Token is a KEEER Account Token (i.e. UUID for current implementation) or a session ID (i.e. integer).

Responses

For KEEER Account Tokens:

  • { status: 0, message: '退出登录成功' }
  • { status: 2, message: '已失效的登录', code: 'ENOTFOUND' }

For session IDs:

  • { status: 0, message: '移除设备成功' }
  • { status: 3, message: '不存在这个设备', code: 'ENOTFOUND' }

PUT /api/user[?set-cookie=true]

Signs up (i.e. creates a new user) [ and sets token cookie in response header ]
Form fields:

  • number:string Phone number
  • code:string Verification code
  • password:string Password

Responses

  • { status: 0, message: '您已经成功注册!', result: token }
  • { status: 2, message: '密码不符合要求', code: 'EINVALID_PASSWORD' }
  • { status: 3, message: '验证码错误', code: 'EBAD_TOKEN' }
  • { status: 4, message: '手机号不正确', code: 'EINVALID_PHONE_NUMBER' }
  • { status: 5, message: '您已经注册,请直接登录或找回密码', code: 'EDUPLICATE' }

GET /api/idframe

See IDFrame.

CSRF

Set a cookie named _csrf with a random value, and submit this random value in a form field called _csrf.

IDFrame

IDFrame is a functionality built into Node KAS that was previously available at https://idframe.keeer.net/js/appbar.js. It allows KEEER services to show a box containing user information or log in links at the top-right of a page, in order to provide common look and feel for KAS. IDFrame can only be called with a *.keeer.net referrer. Usage is shown below.

Getting started for IDFrame

<divid="idframe"></div><style>#idframe { position: fixed; top:12px; right:12px; }</style><scriptsrc="https://account.keeer.net/api/idframe"></script><script>newidFrame.AppBarFrame({container: '#idframe'})</script>

API for IDFrame

idFrame.AppBarFrame

Class representing a IDFrame object.

new AppBarFrame()
ParamTypeDescription
config.containerstring | HTMLElementIDFrame container, string will be interpreted as selector
[config.loginUrl]stringlogin button URL
[config.signupUrl]stringsignup button URL
[config.items[]]string | objectitems to show
[config.serviceName]stringKAS service name to include in login and sign up URLs

appBarFrame.updateItems(items[])

Updates menu items.

ParamTypeDescription
items[]string | objectitems to be displayed.

Build Setup

# install dependencies
$ npm install
# initialize project
$ cp sample.env .env
$ vi .env # edit application config
$ node scripts/db-init # initialize database# serve with hot reload at localhost:3000
$ npm run dev
# add a service
$ node scripts/add-service
# deploy assets to Aliyun OSS (optional)
$ node scripts/deploy-to-oss
# build for production and launch server
$ npm run build
$ npm run start
# update database schema
$ node scripts/migrate-database

Please do not run the content in sql/migration directly. Instead, use the script at scripts/migrate-database.

For detailed explanation on how things work, check out Nuxt.js docs.

About

Currently deployed version of the KEEER Account Service (KAS). Upstream: https://webgit.keeer.net/KEEER/node-kas

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages