npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

uamsdk

v1.5.7

Published

统一账户管理(Unified Account Manager) Javascript SDK 域名:[sso.bdfint.com](//sso.bdfint.com)

Downloads

6

Readme

uamsdk

统一账户管理(Unified Account Manager) Javascript SDK
域名:sso.bdfint.com

安装和引入方式

直接引用文件(推荐)

在你的项目的 html 文件中引入

<script src="//sso.bdfint.com/sdk/uamsdk.min.js"></script>

使用 npm 安装

$ npm install uamsdk

require('uamsdk'); // ES5
import 'uamsdk'; // ES6

使用方法

step1: 拷贝 example/callback.html 到您的 web 服务器中并确保可访问

step2: 文档加载完毕时调用init

uamsdk.init({
  client_id: 'YOUR_CLIENT_ID',  // 必填
  redirect_uri: '您的 callback.html 访问地址',  // 必填
});

step3: 根据业务场景手动调用登录函数(根据登录模式传递不同的display参数或者调用不同的函数login / createLoginIframe,参考下面四种登录模式的例子)

例子1: 弹窗登录(弹出一个固定大小的window窗口)login

uamsdk.init({
  client_id: 'YOUR_CLIENT_ID',  // 必填
  display: uamsdk.POPUP, // 必填
  redirect_uri: '您的 callback.html 访问地址',  // 必填
});
uamsdk.login(callback, keepSession);

例子2: 弹出遮罩层登录(弹出一个带遮罩的iframe)login

uamsdk.init({
  client_id: 'YOUR_CLIENT_ID',  // 必填
  display: uamsdk.IFRAME, // 必填
  redirect_uri: '您的 callback.html 访问地址',  // 必填
});
uamsdk.login(callback, keepSession);

例子3: 自定义嵌入登录页(用户提供容器来容纳登录部分)createLoginIframe

uamsdk.init({
  client_id: 'YOUR_CLIENT_ID',  // 必填
  redirect_uri: '您的 callback.html 访问地址',  // 必填
});
uamsdk.createLoginIframe(iframeWrapper, styleObj, callback, keepSession)

例子4: 跳转到登录页登录login

uamsdk.init({
  client_id: 'YOUR_CLIENT_ID',  // 必填
  display: uamsdk.REDIRECT, // 必填
  redirect_uri: '您的 callback.html 访问地址',  // 必填
});
uamsdk.login(callback, keepSession)

step4: 退出

uamsdk.logout(function() {
  ...
})
// 或者是
uamsdk.logout('//a.com/redirect-callback.html')

方法列表

init({client_id, redirect_uri, display}) 配置信息=>display已修改为默认iframe模式
login(locationOrcallback, keepSession) 登录
createLoginIframe(iframeWrapperId, iframeStyleObj, callback, keepSession) // 嵌入登录页的iframe,并加入自定义样式
getUserInfo() // 获取登录用户的信息,返回promise
logout() 退出登录
loggedIn() 是否已登录 true | false
loggingIn() 是否正在登陆 true | false
getToken() 获取token String
closeLoginDialog(option) 关闭登录弹层,option参数解释: 不传option默认值是{action: 'destroy'}, action为'destroy'时删除弹层元素,否则隐藏弹层元素,如果弹层是window窗口,则无视option参数
ajax(path, params, method, callback) 调用接口
get(path, params, callback) 使用 get 方式调用接口
post(path, params, callback) 使用 post 方式调用接口

init

// @param option {object} 初始化配置参数
uamsdk.init = function(option){ ... }
// opition详细配置:
option = {
  display: '登录模式(uamsdk.POPUP/uamsdk.IFRAME/uamsdk.REDIRECT)',
  client_id: '你的客户端ID',
  redirect_uri: '你的callback.html访问地址',
  loginUrl: '你要使用的登录地址,没有则不填由sdk提供默认',
  logoutUrl: '你要使用的登出地址,没有则不填由sdk提供默认'
}

login

// @param callbackOrRedirectUrl 登录成功后回调函数或者是重定向地址
// @param keepSession {boolean} 是否保持会话(重新打开浏览器是否保持登录状态),不传则默认为true,即重新打开浏览器依然保持登录
uamsdk.login = function(callback, keepSession){ ... }

createLoginIframe

// 创建登录的iframe
// @param wrapperId {string} iframe容器的ID
// @param styleObj {object} 用户自定义iframe样式
// @param callback {function} 登录成功后回调函数
// @param keepSession {boolean} 是否保持会话(重新打开浏览器是否保持登录状态),不传则默认为true,即重新打开浏览器依然保持登录
uamsdk.createLoginIframe = function(iframeWrapperId, iframeStyleObj, callback, keepSession){ ... }

logout

// @param callbackOrRedirectUrl 可以是回调函数或者是合法的跳转链接
uamsdk.logout = function(callbackOrRedirectUrl){ ... }

display参数可取值说明:

  1. 'popup': 弹窗模式,弹出新的window窗口
  2. 'redirect': 跳转模式,当前窗口跳转到登录页
  3. 'iframe': 弹出类似于模态框的iframe,不打开新的window窗口,默认居中显示
  4. 'customIframe': 自定义嵌入的iframe, 可调整sdk嵌入的iframe样式,需要提供容器给iframe,使用uamsdk.createLoginIframe方法