0.1.36 • Published 5 years ago
onemedics-sdk-user-test v0.1.36
Onemedics Library
이 프로젝트는 회원가입/로그인 기능을 간편하게 만들수 있도록 SDK 제공하는데 그 목적이 있습니다.
개발문서는 아래링크 참조
1. 설치
$npm i onemedics-sdk-user[@<version>]2. 사용예제
기본 UserModule 생성 및 초기 로그인 REST
import * as React from 'react';
import { useRef } from 'react';
import { UserModule, Token } from 'onemedics-sdk-user';
export function App() {
const userId = useRef<HTMLInputElement | null>(null);
const password = useRef<HTMLInputElement | null>(null);
// 유저모듈 초기화
const userModule = new UserModule({
uri: 'https://dev.one.net:9000',
token: 'Basic dGVzdDpwYXNz',
});
const onLogin = () => {
// 아이디 비밀번호로 초기 로그인
userModule
.signIn({
username: userId.current?.value,
password: password.current?.value,
})
.then(({ data }: AxiosResponse<Token>) => {
/* 토큰정보 저장 프로세스 수행 및 로그인 후 프로세스 수행 */
});
};
return (
<div className='App'>
<input type='text' ref={userId} placeholder={'아이디'} />
<input type='password' ref={password} placeholder={'아이디'} />
<button onClick={onLogin}>로그인</button>
</div>
);
}
export default App;3. 초기설정
사용자 측에서 import할 UserModule을 생성합니다
- 요청
변수병 유형 설명 uri string호출할 서버의 uri token stringheader에 전달될 초기 인증 token 값( client_id:client_secret Base64 Basic Auth 토큰값 ) graphqlEndpoint [optional]stringgraphql endpoint( default: '/user/graphql')restBaseURL [optional]stringREST API base URL( default: 변수 uri 로 초기화됨)- 예시
//App.tsx import {UserModule} from 'onemedics-sdk-user';
export const userModule = new UserModule({ clientId: '{clientId}', uri: '{uri}', token: 'Basic {auth token}', });
## 4. API 리스트
- [requestAuthNumber](#request-auth-num)
- [identifyAuthNumber](#identify-auth-num)
- [checkDuplicateId](#check-duplicate-id)
- [getTerms](#get-terms)
- [getTermsByTermsType](#get-terms-by-terms-type)
- [getTermsByClientId](#get-terms-by-client-id)
- [signUp](#sign-up)
- [getToken](#get-token)
- [getMe](#get-me)
- [signIn](#sign-in)
- [refreshToken](#refresh-token)
- [serializeForm](#serialize-form)
#### requestAuthNumber
<a name='request-auth-num'></a>
>[인증공통]인증번호 생성 요청
##### - 요청
|변수병|유형|설명|
|---|:-----:|---|
|variables.authNumType| `'SIGNUP'` `'FIND_ID'` `'FIND_PW'` `'MODIFY_MYINFO'` |인증번호 유형|
|variables.phone|`string`|모바일 번호|
##### - 응답
|변수병|유형|설명|
|---|:-----:|---|
|data.createAuthNum.authNumId| `string` |인증번호 id|
| loading | `boolean` | 응답대기 상태인지 여부 |
| networkStatus | `NetworkStatus` [참고](https://github.com/apollographql/apollo-client/blob/master/src/core/networkStatus.ts#L4) | 네트워크 상태 |
##### - 예제
```typescript jsx
import {userModule} from './App'
import { AuthNumType } from 'onemedics-sdk-user';
userModule
.requestAuthNumber({
variables: {
authNumType: AuthNumType.Signup,
phone: '{phone number}',
},
})
.then((result) => {})
.catch((error) => {
/*에러처리*/
});identifyAuthNumber 구현예정
인증공통인증번호 생성 확인
- 요청
변수병 유형 설명 - 응답
변수병 유형 설명 - 예제
checkDuplicateId
회원가입아이디 중복체크 수행
- 요청
변수병 유형 설명 variables.loginId string로그인 아이디 - 응답
변수병 유형 설명 data.FindByLoginId boolean인증번호 id loading boolean응답대기 상태인지 여부 networkStatus NetworkStatus참고네트워크 상태 - 예제
import { userModule } from './App';
userModule
.checkDuplicateId({
variables: {
loginId: "{loginId}",
},
})
.then((result) => {
/*result process*/
});#### getTerms
<a name='get-terms'></a>
> [회원가입]약관 가져오기
##### - 요청
|변수병| |유형|설명|
|---|:---:|:---:|---|
| 없음 | | | |
##### - 응답
|변수병| |유형|설명|
|---:|:---|:-----:|---|
|data.terms.|termsId | `number` | 약관아이디 |
| |clientId | `string` | client ID |
| |title | `string` | 약관 제목 |
| |content | `string` | 약관 내용 |
| |termsType | `number` | 약관 유형 |
| |isEnabled | `boolean` | 사용여부 |
| |createdAt | `string` | 생성일자 |
| |createUserId | `string` | 생성자 ID |
| |updatedAt | `string` | 수정일자 |
| |updateUserId | `string` | 수정자 ID |
| loading | | `boolean` | 응답대기 상태인지 여부 |
| networkStatus | | `NetworkStatus` [참고](https://github.com/apollographql/apollo-client/blob/master/src/core/networkStatus.ts#L4) | 네트워크 상태 |
##### - 예제
```typescript jsx
import { userModule } from './App';
userModule
.getTerms()
.then((result) => {
/*result process*/
});getTermsByTermsType
회원가입특정 약관(termsType) 가져오기
- 요청
변수병 유형 설명 variables termsType 약관유형 0:이용약관,1:위치기반 서비스,2:개인정보보호방침 약관유형 - 응답
변수병 유형 설명 data.terms. termsId number약관아이디 clientId stringclient ID title string약관 제목 content string약관 내용 termsType number약관 유형 isEnabled boolean사용여부 createdAt string생성일자 createUserId string생성자 ID updatedAt string수정일자 updateUserId string수정자 ID loading boolean응답대기 상태인지 여부 networkStatus NetworkStatus참고네트워크 상태 - 예제
import { userModule } from './App'; import { TERMS_OF_SERVICE } from 'onemedics-sdk-user';
userModule
.getTermsBy({
variables: {
termsType: TERMS_OF_SERVICE,
},
})
.then((result) => {
/*result process*/
});#### getTermsByClientId
<a name='get-terms-by-client-id'></a>
> [회원가입]해당 클라이언트의 약관 목록 조회(header의 clientId를 참조)
##### - 요청
|변수병| |유형|설명|
|---|:---:|:---:|---|
| 없음 | | | |
##### - 응답
|변수병| |유형|설명|
|---:|:---|:-----:|---|
|data.terms.|termsId | `number` | 약관아이디 |
| |clientId | `string` | client ID |
| |title | `string` | 약관 제목 |
| |content | `string` | 약관 내용 |
| |termsType | `number` | 약관 유형 |
| |isEnabled | `boolean` | 사용여부 |
| |createdAt | `string` | 생성일자 |
| |createUserId | `string` | 생성자 ID |
| |updatedAt | `string` | 수정일자 |
| |updateUserId | `string` | 수정자 ID |
| loading | | `boolean` | 응답대기 상태인지 여부 |
| networkStatus | | `NetworkStatus` [참고](https://github.com/apollographql/apollo-client/blob/master/src/core/networkStatus.ts#L4) | 네트워크 상태 |
##### - 예제
```typescript jsx
import { userModule } from './App';
import { TERMS_OF_SERVICE } from 'onemedics-sdk-user';
userModule
.getTermsBy({
variables: {
termsType: TERMS_OF_SERVICE,
},
})
.then((result) => {
/*result process*/
});signUp
회원가입약관 가져오기
- 요청
변수병 유형 설명 clientId string클라이언트 아이디 loginId string로그인 아이디 password string비밀번호 username string유저명 phone string핸드폰번호 marketingAgreement boolean마케팅 수신동의 authNumId number인증번호 ID authNum string인증번호 getToken
로그인토큰 가져오기
- 요청
변수병 유형 설명 username string아이디 password string암호 grant_typeoptional string인증유형(default: 'password')getMe
로그인회원정보 가져오기
- 요청
변수병 유형 설명 token stringaccess_token값
signIn
로그인아이디 패스워드 로그인 가져오기
- 요청
변수병 유형 설명 username string아이디 password string암호 grant_typeoptional string인증유형(default: 'password')
refreshToken
로그인token정보 업데이트 가져오기
- 요청
변수병 유형 설명 refresh_token stringrefresh_token값 grant_type [optional]string인증유형(default: 'refresh_token'
serializeForm
로그인 FormData 생성
- 요청
변수병 유형 설명 params object FormData로 생성할 object
4. 버전 관리
CHANGELOG.md 파일 참조 부탁드립니다.
0.1.30
5 years ago
0.1.31
5 years ago
0.1.32
5 years ago
0.1.33
5 years ago
0.1.34
5 years ago
0.1.35
5 years ago
0.1.36
5 years ago
0.1.27
5 years ago
0.1.28
5 years ago
0.1.29
5 years ago
0.1.25
5 years ago
0.1.26
5 years ago
0.1.21
5 years ago
0.1.22
5 years ago
0.1.23
5 years ago
0.1.24
5 years ago
0.1.20
5 years ago
0.1.16
5 years ago
0.1.17
5 years ago
0.1.18
5 years ago
0.1.19
5 years ago
0.1.15
5 years ago
0.1.14
5 years ago