Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@easyv/opg-client

Package Overview
Dependencies
Maintainers
11
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@easyv/opg-client

op proxy gateway client

latest
npmnpm
Version
0.1.7
Version published
Maintainers
11
Created
Source

OP Gateway Client

OP 网关代理客户端,用于代理嵌入式 OP 登录,登录状态查询等功能。

Installation

npm install @easyv/opg-client

Quic start

使用以下方法,快速接入 op-proxy-gateway

配置概览

应用环境clientIdissuer
DTable开发环境dtablehttp://dtable.op.develop:1866

初始化 client 对象

import { EmbeddedClient } from '@easyv/opg-client';

const client = new EmbeddedClient({
  issuer: 'xxxxxx',
  clientId: 'xxxxxx',
});

获取 OP 登录状态

client.checkLoginState((data) => {
  // 使用 data 中的 isLoggedIn 属性判断当前访问者是否在 OP 登录过
});

弹窗登录

client.login((data) => {
  if (data.isNewAccount) {
    // ...
  } else {
    // ...
  }
  // 自定义业务逻辑,会在登录成功弹窗关闭后执行
});

隐式登录

client.implicitLogin(() => {
  // 自定义业务逻辑,会在登录成功后执行
});

使用举例

当接口返回 418 未授权时,查看访问者在 OP 的登录状态使用不同的方法来登录

client.checkLoginState((data) => {
  if (data.isLoggedIn) {
    // 用户已经在 OP 登录,使用隐式登录
    client.implicitLogin();
  } else {
    // 用户未在 OP 登录,根据业务决定是否弹出登录窗口
    client.login();
  }
});

FAQs

Package last updated on 15 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts