Skip to content
This repository was archived by the owner on Jul 31, 2024. It is now read-only.

Commit da98703

Browse files
author
Shuhei-Kotegawa
authored
Merge pull request #1 from freee/release-1.0.0
release 1.0.0
2 parents 01a57b9 + 61b9984 commit da98703

26 files changed

+10581
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.idea

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2019 freee K.K.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 概要
2+
3+
## 動作確認方法

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,63 @@
1-
# firebase-sdk-js
1+
# freee 会計 API SDK for firebase in Javascript (β版)
2+
3+
freee アプリストアのアプリを firebase 上で開発するための SDK です。
4+
5+
## できること
6+
7+
- freee ログイン -> 認可 -> リダイレクト -> firebase にアカウント情報保存 -> firebase ログインの一連の処理
8+
- freee の API をトークンを意識せず呼び出すことが可能
9+
- freee アクセストークン・リフレッシュトークンの暗号化・復号処理
10+
11+
## このSDKについて
12+
13+
本 SDK は主要な機能が含まれていますが、β版のステータスとなっており、制限およびバグがある可能性があります。また、このステータスの記載が更新されるまでは、API やインターフェイスに変更が入る可能性がありますので、ご利用の際はご留意ください。
14+
15+
## 目次
16+
17+
- [チュートリアル](#チュートリアル)
18+
- [前提条件](#前提条件)
19+
- [freee アプリストアへのアプリケーション登録](#freee-アプリストアへのアプリケーション登録)
20+
- [サンプルアプリ](#サンプルアプリ)
21+
- [SDK の導入方法](#SDK-の導入方法)
22+
- [ライセンス](#ライセンス)
23+
24+
## チュートリアル
25+
26+
本 SDK を利用する手順について記載します。
27+
28+
### 前提条件
29+
30+
本 SDK を利用する前に下記をご確認ください。
31+
32+
- freee 本体のアカウントを持っていること
33+
- firebase のアカウントを持っていること
34+
35+
freee 本体のアカウントは、後述する [freee アプリストアへのアプリケーション登録](#freee-アプリストアへのアプリケーション登録) で必要になります。
36+
37+
freee API に関しては、[チュートリアルガイド](https://app.secure.freee.co.jp/developers/tutorials/1-freee%20API%E3%82%92%E5%A7%8B%E3%82%81%E3%82%8B#freee%20API%E3%82%92%E5%A7%8B%E3%82%81%E3%82%8B) をご参照ください。
38+
39+
firebase の基礎知識については、Google が提供する[firebase のドキュメント](https://firebase.google.com/docs) をご参照ください。
40+
41+
### freee アプリストアへのアプリケーション登録
42+
43+
本 SDK で利用する `ClientId` および `ClientSecret` を取得するため、freee アプリストアの開発者ページでアプリケーションを登録します。
44+
45+
こちらの [チュートリアル | freee アプリストア](https://app.secure.freee.co.jp/developers/tutorials/2-%E3%82%A2%E3%83%97%E3%83%AA%E3%82%B1%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B) を参考に、アプリケーションを登録して下さい。
46+
47+
### サンプルアプリ
48+
49+
#### WebApp のサンプル
50+
51+
こちらの[サンプルアプリのリポジトリ](https://github.com/freee/freee-app-template-firebase)の README にしたがって、セットアップを行なってください。
52+
53+
### SDK の導入方法
54+
55+
該当のプロジェクトディレクトリで以下のコマンドを実行してください。
56+
57+
`npm install freee-firebase-sdk`
58+
59+
## ライセンス
60+
61+
ライセンスについては下記をご参照ください。
62+
63+
[MIT License](./LICENSE)

jest.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
"roots": [
3+
`${__dirname}/src`
4+
],
5+
"transform": {
6+
"^.+\\.tsx?$": "ts-jest"
7+
},
8+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
9+
"moduleFileExtensions": [
10+
"ts",
11+
"tsx",
12+
"js",
13+
"jsx",
14+
"json",
15+
"node"
16+
],
17+
}

lib/index.d.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { AxiosPromise } from 'axios';
2+
import * as express from 'express';
3+
import * as admin from 'firebase-admin';
4+
import { ParamJSON, SDKConfig } from '../src/sdk/const/types';
5+
6+
declare module 'freee-firebase-sdk' {
7+
/**
8+
* Freee Server SDK
9+
*/
10+
export class FreeeServerSDK {
11+
constructor(config: SDKConfig, serviceAccount: { [key: string]: string })
12+
13+
/**
14+
* get firebase admin instance
15+
*/
16+
firebaseApp(): admin.app.App
17+
18+
/**
19+
* get freee api client instance
20+
*/
21+
api(): FreeeAPIClient
22+
23+
/**
24+
* get auth client instance
25+
*/
26+
auth(): FreeeFirebaseAuthClient
27+
}
28+
29+
class FreeeAPIClient {
30+
get<T = any>(
31+
url: string,
32+
params: ParamJSON,
33+
userId: string
34+
): AxiosPromise<T>
35+
post<T = any>(url: string, data: ParamJSON, userId: string): AxiosPromise<T>
36+
put<T = any>(url: string, data: ParamJSON, userId: string): AxiosPromise<T>
37+
delete(url: string, data: ParamJSON, userId: string): AxiosPromise
38+
}
39+
40+
class FreeeFirebaseAuthClient {
41+
/**
42+
* Redirect url to authorize
43+
*/
44+
redirect(res: express.Response): void
45+
/**
46+
* Get token with authorized code from freee, save it to firebase and login firebase
47+
*/
48+
callback(code: string, res: express.Response): void
49+
/**
50+
* path for redirect on freee authorization
51+
*/
52+
getRedirectPath(): string
53+
/**
54+
* path for callback on freee authorization
55+
*/
56+
getCallbackPath(): string
57+
/**
58+
* path for callback on freee authorization
59+
*/
60+
getCompaniesPath(): string
61+
62+
/**
63+
* Create crypto key to bucket for it by specified date
64+
*
65+
* {@link SDKConfig#firebase#cryptoKeyBucket} must be specified
66+
*/
67+
createCryptoKey(date: Date): Promise<void>
68+
}
69+
}

lib/index.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)