Socket
Socket
Sign inDemoInstall

@lemoncloud/lemon-front-lib

Package Overview
Dependencies
Maintainers
2
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lemoncloud/lemon-front-lib

Web Core Library for Lemoncloud


Version published
Maintainers
2
Created
Source

lemon-front-lib build status npm package

Core JS library for Lemoncloud; written by Typescript

Install

$ npm install @lemoncloud/lemon-front-lib
// or
$ yarn add @lemoncloud/lemon-front-lib

Usage

import { AuthService } from '@lemoncloud/lemon-front-lib';

const oAuthEndpoint = 'http://localhost:8086'; // refresh 때 필요
const project = 'LEMON';
const authService = new AuthService({ project, oAuthEndpoint });

Authentication

buildCredentialsByToken()

oauth api를 통해 발급 받은 token으로 AWS Credentials 생성

const ENDPOINT = 'https://..../oauth/kakao/token'; // lemoncloud oauth-api
const body = { code }; // get from kakao, naver, google...

const credentials = authService.requestWithSign('POST', ENDPOINT, '/', {}, body)
    .then(data => authService.buildCredentialsByToken(data));
isAuthenticated()

AWS Credentials 데이터 유무로 로그인 체크

AuthService.isAuthenticated();
getCredentials()

AWS Credentials 리턴. 로그인하지 않았을 경우 null 리턴

AuthService.getCredentials();
request()

axios를 이용한 HTTP 요청. AWS Credentials이 있을 경우, Signature V4 Signing 과정을 거쳐 요청

AuthService.request('GET', 'YOUR_URL', '/');
AuthService.request('GET', 'YOUR_URL', '/', { page: 0 });
AuthService.request('POST', 'YOUR_URL', '/', {}, { mock: 'MOCK_VALUE' });
requestWithCredentials()

내부에서 getCredentials()을 호출 후 request() 진행

AuthService.requestWithCredentials('GET', 'YOUR_URL', '/');
AuthService.requestWithCredentials('GET', 'YOUR_URL', '/', { page: 0 });
AuthService.requestWithCredentials('POST', 'YOUR_URL', '/', {}, { mock: 'MOCK_VALUE' });
logout()

AWS Credentials 데이터 삭제

AuthService.logout();

Example

$ node example/example.js
# open localhost:8888 on browser

Keywords

FAQs

Package last updated on 02 Feb 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc