@faable/auth-sdk 1.0.19 → 1.1.1
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/ava.config.cjs +7 -0
- package/dist/FaableAuthApi.d.ts +27 -14
- package/dist/FaableAuthApi.js +20 -16
- package/dist/error_handler.js +2 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -17
- package/dist/types/api.d.ts +3 -0
- package/dist/types/api.js +1 -2
- package/dist/types/{index.d.ts → types.d.ts} +2 -1
- package/dist/types/types.js +1 -0
- package/package.json +4 -14
- package/tsconfig.json +2 -2
- package/dist/fetcher_axios.d.ts +0 -8
- package/dist/fetcher_axios.js +0 -41
- package/dist/paginator.d.ts +0 -18
- package/dist/paginator.js +0 -38
- package/dist/types/index.js +0 -2
package/ava.config.cjs
ADDED
package/dist/FaableAuthApi.d.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
constructor(client?: AxiosInstance);
|
|
1
|
+
import { TeamCreate, UserCreate, UserUpdate } from "./types/types.js";
|
|
2
|
+
import { ApiParams, FaableApi } from "@faable/sdk-base";
|
|
3
|
+
type FaableAuthApiParams = {
|
|
4
|
+
team: string;
|
|
5
|
+
} & ApiParams;
|
|
6
|
+
export declare class FaableAuthApi extends FaableApi {
|
|
7
|
+
constructor(params?: FaableAuthApiParams);
|
|
9
8
|
setUserMetadata(user_id: string, user_metadata: Record<string, string | any[] | boolean | number | null | undefined>): Promise<{
|
|
10
9
|
[key: string]: unknown;
|
|
11
10
|
}>;
|
|
12
11
|
getUserMetadata(user_id: string): Promise<{
|
|
13
12
|
[key: string]: unknown;
|
|
14
13
|
}>;
|
|
14
|
+
currentAccount(): Promise<{
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
domain: string;
|
|
18
|
+
logo_src?: string | null | undefined;
|
|
19
|
+
callback_hostnames: string[];
|
|
20
|
+
token_signature: string;
|
|
21
|
+
default_connection?: unknown;
|
|
22
|
+
default_locale: string;
|
|
23
|
+
team?: string | null | undefined;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
updatedAt?: string | undefined;
|
|
26
|
+
}>;
|
|
15
27
|
listUsers(params?: {
|
|
16
28
|
email?: string;
|
|
17
29
|
}): {
|
|
@@ -43,7 +55,7 @@ export declare class FaableAuthApi {
|
|
|
43
55
|
createdAt: string;
|
|
44
56
|
updatedAt?: string | undefined;
|
|
45
57
|
}[]>;
|
|
46
|
-
first: () => Promise<Page<{
|
|
58
|
+
first: () => Promise<import("@faable/sdk-base/dist/helpers/paginator.js").Page<{
|
|
47
59
|
id: string;
|
|
48
60
|
name?: string | null | undefined;
|
|
49
61
|
username?: string | null | undefined;
|
|
@@ -74,7 +86,7 @@ export declare class FaableAuthApi {
|
|
|
74
86
|
pass: (params?: {
|
|
75
87
|
cursor?: string | undefined;
|
|
76
88
|
pageSize?: string | undefined;
|
|
77
|
-
}) => Promise<Page<{
|
|
89
|
+
} | undefined) => Promise<import("@faable/sdk-base/dist/helpers/paginator.js").Page<{
|
|
78
90
|
id: string;
|
|
79
91
|
name?: string | null | undefined;
|
|
80
92
|
username?: string | null | undefined;
|
|
@@ -229,7 +241,7 @@ export declare class FaableAuthApi {
|
|
|
229
241
|
createdAt: string;
|
|
230
242
|
updatedAt?: string | undefined;
|
|
231
243
|
}[]>;
|
|
232
|
-
first: () => Promise<Page<{
|
|
244
|
+
first: () => Promise<import("@faable/sdk-base/dist/helpers/paginator.js").Page<{
|
|
233
245
|
id: string;
|
|
234
246
|
name: string;
|
|
235
247
|
slug: string;
|
|
@@ -245,7 +257,7 @@ export declare class FaableAuthApi {
|
|
|
245
257
|
pass: (params?: {
|
|
246
258
|
cursor?: string | undefined;
|
|
247
259
|
pageSize?: string | undefined;
|
|
248
|
-
}) => Promise<Page<{
|
|
260
|
+
} | undefined) => Promise<import("@faable/sdk-base/dist/helpers/paginator.js").Page<{
|
|
249
261
|
id: string;
|
|
250
262
|
name: string;
|
|
251
263
|
slug: string;
|
|
@@ -274,7 +286,7 @@ export declare class FaableAuthApi {
|
|
|
274
286
|
createdAt: string;
|
|
275
287
|
updatedAt?: string | undefined;
|
|
276
288
|
}[]>;
|
|
277
|
-
first: () => Promise<Page<{
|
|
289
|
+
first: () => Promise<import("@faable/sdk-base/dist/helpers/paginator.js").Page<{
|
|
278
290
|
id: string;
|
|
279
291
|
user: unknown;
|
|
280
292
|
team: unknown;
|
|
@@ -289,7 +301,7 @@ export declare class FaableAuthApi {
|
|
|
289
301
|
pass: (params?: {
|
|
290
302
|
cursor?: string | undefined;
|
|
291
303
|
pageSize?: string | undefined;
|
|
292
|
-
}) => Promise<Page<{
|
|
304
|
+
} | undefined) => Promise<import("@faable/sdk-base/dist/helpers/paginator.js").Page<{
|
|
293
305
|
id: string;
|
|
294
306
|
user: unknown;
|
|
295
307
|
team: unknown;
|
|
@@ -304,3 +316,4 @@ export declare class FaableAuthApi {
|
|
|
304
316
|
};
|
|
305
317
|
isUserMemberOfTeam(user_id: string, team_id: string): Promise<boolean>;
|
|
306
318
|
}
|
|
319
|
+
export {};
|
package/dist/FaableAuthApi.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { FaableApi } from "@faable/sdk-base";
|
|
2
|
+
export class FaableAuthApi extends FaableApi {
|
|
3
|
+
constructor(params) {
|
|
4
|
+
super({
|
|
5
|
+
...params,
|
|
6
|
+
baseURL: "https://faable.auth.faable.link",
|
|
7
|
+
fetcher: {
|
|
8
|
+
...params?.fetcher,
|
|
9
|
+
headers: {
|
|
10
|
+
...params?.fetcher?.headers,
|
|
11
|
+
"x-faable-team": params?.team,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
13
15
|
}
|
|
14
16
|
async setUserMetadata(user_id, user_metadata) {
|
|
15
17
|
const user = await this.fetcher.post(`/user/${user_id}`, {
|
|
@@ -21,8 +23,11 @@ class FaableAuthApi {
|
|
|
21
23
|
const user = await this.fetcher.get(`/user/${user_id}`);
|
|
22
24
|
return user.user_metadata;
|
|
23
25
|
}
|
|
26
|
+
currentAccount() {
|
|
27
|
+
return this.fetcher.get("/account/current");
|
|
28
|
+
}
|
|
24
29
|
listUsers(params = {}) {
|
|
25
|
-
return this.paginator
|
|
30
|
+
return this.paginator({ url: "/user", params });
|
|
26
31
|
}
|
|
27
32
|
getUser(user_id) {
|
|
28
33
|
return this.fetcher.get(`/user/${user_id}`);
|
|
@@ -40,10 +45,10 @@ class FaableAuthApi {
|
|
|
40
45
|
return this.fetcher.post(`/team`, data);
|
|
41
46
|
}
|
|
42
47
|
listTeams(params) {
|
|
43
|
-
return this.paginator
|
|
48
|
+
return this.paginator({ url: "/team", params });
|
|
44
49
|
}
|
|
45
50
|
listTeamMembers(params) {
|
|
46
|
-
return this.paginator
|
|
51
|
+
return this.paginator({
|
|
47
52
|
url: `/member`,
|
|
48
53
|
params: {
|
|
49
54
|
...params,
|
|
@@ -55,4 +60,3 @@ class FaableAuthApi {
|
|
|
55
60
|
return this.fetcher.check(`/team/${team_id}/member/check/${user_id}`);
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
|
-
exports.FaableAuthApi = FaableAuthApi;
|
package/dist/error_handler.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleErrorInterceptor = exports.FaableApiError = void 0;
|
|
4
|
-
class FaableApiError extends Error {
|
|
1
|
+
export class FaableApiError extends Error {
|
|
5
2
|
constructor(msg) {
|
|
6
3
|
super(msg);
|
|
7
4
|
this.name = "FaableApiError";
|
|
8
5
|
Object.setPrototypeOf(this, FaableApiError.prototype);
|
|
9
6
|
}
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
const handleErrorInterceptor = async (e) => {
|
|
8
|
+
export const handleErrorInterceptor = async (e) => {
|
|
13
9
|
const data = e.response?.data;
|
|
14
10
|
throw new FaableApiError(`FaableApiError: ${data?.message} (status=${e.response?.status}, url=${e.response?.config.url})`);
|
|
15
11
|
};
|
|
16
|
-
exports.handleErrorInterceptor = handleErrorInterceptor;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./FaableAuthApi";
|
|
1
|
+
export * from "./FaableAuthApi.js";
|
|
2
|
+
export * from "./types/types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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);
|
|
1
|
+
export * from "./FaableAuthApi.js";
|
|
2
|
+
export * from "./types/types.js";
|
package/dist/types/api.d.ts
CHANGED
|
@@ -87,6 +87,7 @@ export interface paths {
|
|
|
87
87
|
token_signature: string;
|
|
88
88
|
default_connection?: unknown;
|
|
89
89
|
default_locale: string;
|
|
90
|
+
team?: string | null;
|
|
90
91
|
/** @description AuthAccount creation date */
|
|
91
92
|
createdAt: string;
|
|
92
93
|
/** @description AuthAccount updated date */
|
|
@@ -122,6 +123,7 @@ export interface paths {
|
|
|
122
123
|
token_signature: string;
|
|
123
124
|
default_connection?: unknown;
|
|
124
125
|
default_locale: string;
|
|
126
|
+
team?: string | null;
|
|
125
127
|
/** @description AuthAccount creation date */
|
|
126
128
|
createdAt: string;
|
|
127
129
|
/** @description AuthAccount updated date */
|
|
@@ -677,6 +679,7 @@ export interface components {
|
|
|
677
679
|
token_signature: string;
|
|
678
680
|
default_connection?: unknown;
|
|
679
681
|
default_locale: string;
|
|
682
|
+
team?: string | null;
|
|
680
683
|
/** @description AuthAccount creation date */
|
|
681
684
|
createdAt: string;
|
|
682
685
|
/** @description AuthAccount updated date */
|
package/dist/types/api.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { components } from "./api";
|
|
1
|
+
import { components } from "./api.js";
|
|
2
2
|
export type User = components["schemas"]["User"];
|
|
3
3
|
export type UserCreate = components["schemas"]["UserCreate"];
|
|
4
4
|
export type UserUpdate = components["schemas"]["UserUpdate"];
|
|
5
5
|
export type Team = components["schemas"]["Team"];
|
|
6
6
|
export type TeamMember = components["schemas"]["TeamMember"];
|
|
7
7
|
export type TeamCreate = components["schemas"]["TeamCreate"];
|
|
8
|
+
export type AuthAccount = components["schemas"]["AuthAccount"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faable/auth-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"author": "Marc Pomar <marc@faable.com>",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
10
10
|
},
|
|
11
|
+
"type": "module",
|
|
11
12
|
"dependencies": {
|
|
12
|
-
"@faable/
|
|
13
|
-
"axios": "^1.6.2"
|
|
13
|
+
"@faable/sdk-base": "^1.0.7"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@ava/typescript": "^5.0.0",
|
|
17
|
+
"@septh/ts-run": "^1.3.3",
|
|
17
18
|
"@types/node": "^20.10.5",
|
|
18
19
|
"ava": "^6.1.3",
|
|
19
20
|
"dotenv": "^16.4.5",
|
|
@@ -23,17 +24,6 @@
|
|
|
23
24
|
"tsimp": "^2.0.11",
|
|
24
25
|
"typescript": "^5.3.3"
|
|
25
26
|
},
|
|
26
|
-
"ava": {
|
|
27
|
-
"extensions": {
|
|
28
|
-
"ts": "module"
|
|
29
|
-
},
|
|
30
|
-
"require": [
|
|
31
|
-
"dotenv/config"
|
|
32
|
-
],
|
|
33
|
-
"nodeArguments": [
|
|
34
|
-
"--import=tsimp"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
27
|
"scripts": {
|
|
38
28
|
"gentypes": "openapi-typescript https://faable.auth.faable.link/docs/json -o src/types/api.ts",
|
|
39
29
|
"build": "rimraf dist && tsc",
|
package/tsconfig.json
CHANGED
package/dist/fetcher_axios.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
-
export type Fetcher = ReturnType<typeof fetcher_axios>;
|
|
3
|
-
export declare const fetcher_axios: (instance: AxiosInstance) => {
|
|
4
|
-
get: <T>(url: string) => Promise<T>;
|
|
5
|
-
post: <T_1>(url: string, data: any) => Promise<T_1>;
|
|
6
|
-
request: <T_2>(params: AxiosRequestConfig) => Promise<T_2>;
|
|
7
|
-
check: <T_3>(url: string) => Promise<boolean>;
|
|
8
|
-
};
|
package/dist/fetcher_axios.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetcher_axios = void 0;
|
|
4
|
-
const error_handler_1 = require("./error_handler");
|
|
5
|
-
const fetcher_axios = (instance) => {
|
|
6
|
-
// Add base interceptor
|
|
7
|
-
instance.interceptors.response.use((res) => {
|
|
8
|
-
console.log(`Request ${res.config.url}`);
|
|
9
|
-
return res;
|
|
10
|
-
}, error_handler_1.handleErrorInterceptor);
|
|
11
|
-
return {
|
|
12
|
-
get: async (url) => {
|
|
13
|
-
const res = await instance.request({
|
|
14
|
-
method: "GET",
|
|
15
|
-
url,
|
|
16
|
-
});
|
|
17
|
-
return res.data;
|
|
18
|
-
},
|
|
19
|
-
post: async (url, data) => {
|
|
20
|
-
const res = await instance.request({
|
|
21
|
-
method: "POST",
|
|
22
|
-
url,
|
|
23
|
-
data,
|
|
24
|
-
});
|
|
25
|
-
return res.data;
|
|
26
|
-
},
|
|
27
|
-
request: async (params) => {
|
|
28
|
-
const res = await instance.request(params);
|
|
29
|
-
return res.data;
|
|
30
|
-
},
|
|
31
|
-
check: async (url) => {
|
|
32
|
-
const res = await instance.request({
|
|
33
|
-
method: "GET",
|
|
34
|
-
url,
|
|
35
|
-
validateStatus: () => true,
|
|
36
|
-
});
|
|
37
|
-
return res.status == 200;
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
exports.fetcher_axios = fetcher_axios;
|
package/dist/paginator.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from "axios";
|
|
2
|
-
import { Fetcher } from "./fetcher_axios";
|
|
3
|
-
export interface Page<T> {
|
|
4
|
-
next: string | null;
|
|
5
|
-
results: T[];
|
|
6
|
-
}
|
|
7
|
-
export declare class FaablePaginator {
|
|
8
|
-
client: Fetcher;
|
|
9
|
-
constructor(client: Fetcher);
|
|
10
|
-
paginate<T>(req: AxiosRequestConfig): {
|
|
11
|
-
all: () => Promise<T[]>;
|
|
12
|
-
first: () => Promise<Page<T>>;
|
|
13
|
-
pass: (params?: {
|
|
14
|
-
cursor?: string;
|
|
15
|
-
pageSize?: string;
|
|
16
|
-
}) => Promise<Page<T>>;
|
|
17
|
-
};
|
|
18
|
-
}
|
package/dist/paginator.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FaablePaginator = void 0;
|
|
4
|
-
class FaablePaginator {
|
|
5
|
-
client;
|
|
6
|
-
constructor(client) {
|
|
7
|
-
this.client = client;
|
|
8
|
-
}
|
|
9
|
-
paginate(req) {
|
|
10
|
-
return {
|
|
11
|
-
all: async () => {
|
|
12
|
-
const pages = [];
|
|
13
|
-
let data;
|
|
14
|
-
do {
|
|
15
|
-
data = await this.client.request({
|
|
16
|
-
...req,
|
|
17
|
-
params: { ...req.params, next: data && data?.next },
|
|
18
|
-
});
|
|
19
|
-
pages.push(data);
|
|
20
|
-
} while (data.next);
|
|
21
|
-
return pages.map((page) => page.results).flat();
|
|
22
|
-
},
|
|
23
|
-
first: async () => {
|
|
24
|
-
return this.client.request(req);
|
|
25
|
-
},
|
|
26
|
-
pass: async (params = {}) => {
|
|
27
|
-
return this.client.request({
|
|
28
|
-
...req,
|
|
29
|
-
params: {
|
|
30
|
-
...req.params,
|
|
31
|
-
...params,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.FaablePaginator = FaablePaginator;
|
package/dist/types/index.js
DELETED