@faable/auth-sdk 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +20 -0
- package/README.md +26 -0
- package/dist/FaableAuthApi.d.ts +11 -0
- package/dist/FaableAuthApi.js +36 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/package.json +43 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
"on":
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
jobs:
|
|
7
|
+
release:
|
|
8
|
+
name: release
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-node@v3
|
|
13
|
+
with:
|
|
14
|
+
cache: npm
|
|
15
|
+
node-version: lts/*
|
|
16
|
+
- run: yarn install --frozen-lockfile
|
|
17
|
+
- run: yarn run release
|
|
18
|
+
env:
|
|
19
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://faable.com">
|
|
3
|
+
<h1 align="center">Faable Auth SDK Client</h1>
|
|
4
|
+
</a>
|
|
5
|
+
<p align="center">Faable Auth management and auth API Client</p>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a aria-label="NPM version" href="https://www.npmjs.com/package/@faable/auth-sdk">
|
|
10
|
+
<img alt="" src="https://img.shields.io/npm/v/@faable/swr-pagination-adapter.svg?style=for-the-badge&labelColor=000000">
|
|
11
|
+
</a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
With Yarn:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
yarn add @faablecloud/auth-sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
With NPM:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @faablecloud/auth-sdk
|
|
26
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
export declare class FaableAuthApi {
|
|
3
|
+
client: AxiosInstance;
|
|
4
|
+
constructor(client?: AxiosInstance);
|
|
5
|
+
setUserMetadata(user_id: string, user_metadata: Record<string, string | any[] | boolean | number | null | undefined>): Promise<{
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}>;
|
|
8
|
+
getUserMetadata(user_id: string): Promise<{
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FaableAuthApi = void 0;
|
|
4
|
+
const auth_helpers_axios_1 = require("@faable/auth-helpers-axios");
|
|
5
|
+
const handleError = async (q) => {
|
|
6
|
+
try {
|
|
7
|
+
const res = await q;
|
|
8
|
+
if (res.status >= 200 && res.status < 300) {
|
|
9
|
+
return res.data;
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`Error API Call code=${res.status} url=${res.config.url}`);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
const e = error;
|
|
15
|
+
if (e.isAxiosError) {
|
|
16
|
+
throw new Error(`API ERROR code=${e.response?.status} url=${e.response?.config.url}`);
|
|
17
|
+
}
|
|
18
|
+
throw new Error("Bad API");
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
class FaableAuthApi {
|
|
22
|
+
client;
|
|
23
|
+
constructor(client) {
|
|
24
|
+
if (!client) {
|
|
25
|
+
this.client = (0, auth_helpers_axios_1.authorize)();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async setUserMetadata(user_id, user_metadata) {
|
|
29
|
+
return (await handleError(this.client.post(`/user/${user_id}`, { user_metadata }))).user_metadata;
|
|
30
|
+
}
|
|
31
|
+
async getUserMetadata(user_id) {
|
|
32
|
+
return (await handleError(this.client.get(`/user/${user_id}`)))
|
|
33
|
+
.user_metadata;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.FaableAuthApi = FaableAuthApi;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./FaableAuthApi";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./FaableAuthApi"), exports);
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@faable/auth-sdk",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"author": "Marc Pomar <marc@faable.com>",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@faable/auth-helpers-axios": "^0.0.9",
|
|
13
|
+
"axios": "^1.6.2"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^20.10.5",
|
|
17
|
+
"openapi-typescript": "^6.7.3",
|
|
18
|
+
"rimraf": "^5.0.5",
|
|
19
|
+
"semantic-release": "^22.0.12",
|
|
20
|
+
"typescript": "^5.3.3"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"gentypes": "openapi-typescript https://faable.auth.faable.link/docs/json -o src/types/api.d.ts",
|
|
24
|
+
"build": "rimraf dist && tsc",
|
|
25
|
+
"prepublishOnly": "yarn run gentypes && yarn run build",
|
|
26
|
+
"release": "semantic-release"
|
|
27
|
+
},
|
|
28
|
+
"resolutions": {
|
|
29
|
+
"npm/chalk": "^4.1.2"
|
|
30
|
+
},
|
|
31
|
+
"release": {
|
|
32
|
+
"branches": [
|
|
33
|
+
"main"
|
|
34
|
+
],
|
|
35
|
+
"plugins": [
|
|
36
|
+
"@semantic-release/release-notes-generator",
|
|
37
|
+
"@semantic-release/github",
|
|
38
|
+
[
|
|
39
|
+
"@semantic-release/npm"
|
|
40
|
+
]
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"esModuleInterop": true,
|
|
4
|
+
"moduleResolution": "node",
|
|
5
|
+
"target": "esnext",
|
|
6
|
+
"module": "CommonJS",
|
|
7
|
+
"allowJs": false,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"experimentalDecorators": true,
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"]
|
|
14
|
+
}
|