@authsome/client 0.0.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/dist/client.d.ts +91 -0
- package/dist/client.js +129 -0
- package/dist/errors.d.ts +31 -0
- package/dist/errors.js +94 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +47 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +3 -0
- package/dist/plugins/admin.d.ts +20 -0
- package/dist/plugins/admin.js +71 -0
- package/dist/plugins/anonymous.d.ts +11 -0
- package/dist/plugins/anonymous.js +27 -0
- package/dist/plugins/apikey.d.ts +16 -0
- package/dist/plugins/apikey.js +47 -0
- package/dist/plugins/backupauth.d.ts +38 -0
- package/dist/plugins/backupauth.js +177 -0
- package/dist/plugins/compliance.d.ts +42 -0
- package/dist/plugins/compliance.js +169 -0
- package/dist/plugins/consent.d.ts +27 -0
- package/dist/plugins/consent.js +105 -0
- package/dist/plugins/emailotp.d.ts +11 -0
- package/dist/plugins/emailotp.js +29 -0
- package/dist/plugins/idverification.d.ts +20 -0
- package/dist/plugins/idverification.js +67 -0
- package/dist/plugins/impersonation.d.ts +15 -0
- package/dist/plugins/impersonation.js +45 -0
- package/dist/plugins/jwt.d.ts +13 -0
- package/dist/plugins/jwt.js +37 -0
- package/dist/plugins/magiclink.d.ts +11 -0
- package/dist/plugins/magiclink.js +27 -0
- package/dist/plugins/mfa.d.ts +25 -0
- package/dist/plugins/mfa.js +93 -0
- package/dist/plugins/multiapp.d.ts +28 -0
- package/dist/plugins/multiapp.js +95 -0
- package/dist/plugins/multisession.d.ts +12 -0
- package/dist/plugins/multisession.js +31 -0
- package/dist/plugins/notification.d.ts +24 -0
- package/dist/plugins/notification.js +81 -0
- package/dist/plugins/oidcprovider.d.ts +22 -0
- package/dist/plugins/oidcprovider.js +75 -0
- package/dist/plugins/organization.d.ts +25 -0
- package/dist/plugins/organization.js +81 -0
- package/dist/plugins/passkey.d.ts +16 -0
- package/dist/plugins/passkey.js +45 -0
- package/dist/plugins/phone.d.ts +12 -0
- package/dist/plugins/phone.js +35 -0
- package/dist/plugins/social.d.ts +14 -0
- package/dist/plugins/social.js +41 -0
- package/dist/plugins/sso.d.ts +15 -0
- package/dist/plugins/sso.js +47 -0
- package/dist/plugins/stepup.d.ts +23 -0
- package/dist/plugins/stepup.js +81 -0
- package/dist/plugins/twofa.d.ts +15 -0
- package/dist/plugins/twofa.js +53 -0
- package/dist/plugins/username.d.ts +11 -0
- package/dist/plugins/username.js +25 -0
- package/dist/plugins/webhook.d.ts +32 -0
- package/dist/plugins/webhook.js +44 -0
- package/dist/types.d.ts +3175 -0
- package/dist/types.js +3 -0
- package/package.json +38 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { ClientPlugin } from './plugin';
|
|
2
|
+
import * as types from './types';
|
|
3
|
+
/**
|
|
4
|
+
* AuthSome client configuration
|
|
5
|
+
* Supports multiple authentication methods that can be used simultaneously:
|
|
6
|
+
* - Cookies: Automatically sent with every request (session-based auth)
|
|
7
|
+
* - Bearer Token: JWT tokens sent in Authorization header when auth: true
|
|
8
|
+
* - API Key: Sent with every request for server-to-server auth
|
|
9
|
+
* - Publishable Key (pk_*): Safe for frontend, limited permissions
|
|
10
|
+
* - Secret Key (sk_*): Backend only, full admin access
|
|
11
|
+
*/
|
|
12
|
+
export interface AuthsomeClientConfig {
|
|
13
|
+
/** Base URL of the AuthSome API */
|
|
14
|
+
baseURL: string;
|
|
15
|
+
/** Plugin instances to initialize */
|
|
16
|
+
plugins?: ClientPlugin[];
|
|
17
|
+
/** JWT/Bearer token for user authentication (sent only when auth: true) */
|
|
18
|
+
token?: string;
|
|
19
|
+
/** API key for server-to-server auth (pk_* or sk_*, sent with all requests) */
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
/** Custom header name for API key (default: 'X-API-Key') */
|
|
22
|
+
apiKeyHeader?: string;
|
|
23
|
+
/** Custom headers to include with all requests */
|
|
24
|
+
headers?: Record<string, string>;
|
|
25
|
+
}
|
|
26
|
+
export declare class AuthsomeClient {
|
|
27
|
+
private baseURL;
|
|
28
|
+
private token?;
|
|
29
|
+
private apiKey?;
|
|
30
|
+
private apiKeyHeader;
|
|
31
|
+
private headers;
|
|
32
|
+
private plugins;
|
|
33
|
+
constructor(config: AuthsomeClientConfig);
|
|
34
|
+
setToken(token: string): void;
|
|
35
|
+
setApiKey(apiKey: string, header?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Set a publishable key (pk_*) - safe for frontend use
|
|
38
|
+
* Publishable keys have limited permissions and can be exposed in client-side code
|
|
39
|
+
* Typically used for: session creation, user verification, public data reads
|
|
40
|
+
*/
|
|
41
|
+
setPublishableKey(publishableKey: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Set a secret key (sk_*) - MUST be kept secret on server-side only!
|
|
44
|
+
* Secret keys have full administrative access to all operations
|
|
45
|
+
* WARNING: Never expose secret keys in client-side code (browser, mobile apps)
|
|
46
|
+
*/
|
|
47
|
+
setSecretKey(secretKey: string): void;
|
|
48
|
+
getPlugin<T extends ClientPlugin>(id: string): T | undefined;
|
|
49
|
+
request<T>(method: string, path: string, options?: {
|
|
50
|
+
body?: any;
|
|
51
|
+
query?: Record<string, string>;
|
|
52
|
+
auth?: boolean;
|
|
53
|
+
}): Promise<T>;
|
|
54
|
+
signUp(request: {
|
|
55
|
+
email: string;
|
|
56
|
+
password: string;
|
|
57
|
+
name?: string;
|
|
58
|
+
}): Promise<{
|
|
59
|
+
user: types.User;
|
|
60
|
+
session: types.Session;
|
|
61
|
+
}>;
|
|
62
|
+
signIn(request: {
|
|
63
|
+
email: string;
|
|
64
|
+
password: string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
session: types.Session;
|
|
67
|
+
requiresTwoFactor: boolean;
|
|
68
|
+
user: types.User;
|
|
69
|
+
}>;
|
|
70
|
+
signOut(): Promise<{
|
|
71
|
+
success: boolean;
|
|
72
|
+
}>;
|
|
73
|
+
getSession(): Promise<{
|
|
74
|
+
session: types.Session;
|
|
75
|
+
user: types.User;
|
|
76
|
+
}>;
|
|
77
|
+
updateUser(request: {
|
|
78
|
+
name?: string;
|
|
79
|
+
email?: string;
|
|
80
|
+
}): Promise<{
|
|
81
|
+
user: types.User;
|
|
82
|
+
}>;
|
|
83
|
+
listDevices(): Promise<{
|
|
84
|
+
devices: types.Device[];
|
|
85
|
+
}>;
|
|
86
|
+
revokeDevice(request: {
|
|
87
|
+
deviceId: string;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
success: boolean;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Auto-generated AuthSome client
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AuthsomeClient = void 0;
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
class AuthsomeClient {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.baseURL = config.baseURL;
|
|
9
|
+
this.token = config.token;
|
|
10
|
+
this.apiKey = config.apiKey;
|
|
11
|
+
this.apiKeyHeader = config.apiKeyHeader || 'X-API-Key';
|
|
12
|
+
this.headers = config.headers || {};
|
|
13
|
+
this.plugins = new Map();
|
|
14
|
+
if (config.plugins) {
|
|
15
|
+
for (const plugin of config.plugins) {
|
|
16
|
+
this.plugins.set(plugin.id, plugin);
|
|
17
|
+
plugin.init(this);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
setToken(token) {
|
|
22
|
+
this.token = token;
|
|
23
|
+
}
|
|
24
|
+
setApiKey(apiKey, header) {
|
|
25
|
+
this.apiKey = apiKey;
|
|
26
|
+
if (header) {
|
|
27
|
+
this.apiKeyHeader = header;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Set a publishable key (pk_*) - safe for frontend use
|
|
32
|
+
* Publishable keys have limited permissions and can be exposed in client-side code
|
|
33
|
+
* Typically used for: session creation, user verification, public data reads
|
|
34
|
+
*/
|
|
35
|
+
setPublishableKey(publishableKey) {
|
|
36
|
+
if (!publishableKey.startsWith('pk_')) {
|
|
37
|
+
console.warn('Warning: Publishable keys should start with pk_');
|
|
38
|
+
}
|
|
39
|
+
this.setApiKey(publishableKey);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Set a secret key (sk_*) - MUST be kept secret on server-side only!
|
|
43
|
+
* Secret keys have full administrative access to all operations
|
|
44
|
+
* WARNING: Never expose secret keys in client-side code (browser, mobile apps)
|
|
45
|
+
*/
|
|
46
|
+
setSecretKey(secretKey) {
|
|
47
|
+
if (!secretKey.startsWith('sk_')) {
|
|
48
|
+
console.warn('Warning: Secret keys should start with sk_');
|
|
49
|
+
}
|
|
50
|
+
this.setApiKey(secretKey);
|
|
51
|
+
}
|
|
52
|
+
getPlugin(id) {
|
|
53
|
+
return this.plugins.get(id);
|
|
54
|
+
}
|
|
55
|
+
async request(method, path, options) {
|
|
56
|
+
const url = new URL(path, this.baseURL);
|
|
57
|
+
if (options?.query) {
|
|
58
|
+
for (const [key, value] of Object.entries(options.query)) {
|
|
59
|
+
url.searchParams.append(key, value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const headers = {
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
...this.headers,
|
|
65
|
+
};
|
|
66
|
+
if (options?.auth && this.token) {
|
|
67
|
+
headers['Authorization'] = `Bearer ${this.token}`;
|
|
68
|
+
}
|
|
69
|
+
if (this.apiKey) {
|
|
70
|
+
headers[this.apiKeyHeader] = this.apiKey;
|
|
71
|
+
}
|
|
72
|
+
const response = await fetch(url.toString(), {
|
|
73
|
+
method,
|
|
74
|
+
headers,
|
|
75
|
+
body: options?.body ? JSON.stringify(options.body) : undefined,
|
|
76
|
+
credentials: 'include',
|
|
77
|
+
});
|
|
78
|
+
if (!response.ok) {
|
|
79
|
+
const error = await response.json().catch(() => ({ error: response.statusText }));
|
|
80
|
+
throw (0, errors_1.createErrorFromResponse)(response.status, error.error || error.message || 'Request failed');
|
|
81
|
+
}
|
|
82
|
+
return response.json();
|
|
83
|
+
}
|
|
84
|
+
async signUp(request) {
|
|
85
|
+
const path = '/api/auth/signup';
|
|
86
|
+
return this.request('POST', path, {
|
|
87
|
+
body: request,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async signIn(request) {
|
|
91
|
+
const path = '/api/auth/signin';
|
|
92
|
+
return this.request('POST', path, {
|
|
93
|
+
body: request,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async signOut() {
|
|
97
|
+
const path = '/api/auth/signout';
|
|
98
|
+
return this.request('POST', path, {
|
|
99
|
+
auth: true,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
async getSession() {
|
|
103
|
+
const path = '/api/auth/session';
|
|
104
|
+
return this.request('GET', path, {
|
|
105
|
+
auth: true,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async updateUser(request) {
|
|
109
|
+
const path = '/api/auth/user/update';
|
|
110
|
+
return this.request('POST', path, {
|
|
111
|
+
body: request,
|
|
112
|
+
auth: true,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
async listDevices() {
|
|
116
|
+
const path = '/api/auth/devices';
|
|
117
|
+
return this.request('GET', path, {
|
|
118
|
+
auth: true,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
async revokeDevice(request) {
|
|
122
|
+
const path = '/api/auth/devices/revoke';
|
|
123
|
+
return this.request('POST', path, {
|
|
124
|
+
body: request,
|
|
125
|
+
auth: true,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.AuthsomeClient = AuthsomeClient;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare class AuthsomeError extends Error {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
code?: string | undefined;
|
|
4
|
+
constructor(message: string, statusCode: number, code?: string | undefined);
|
|
5
|
+
}
|
|
6
|
+
export declare class NetworkError extends AuthsomeError {
|
|
7
|
+
constructor(message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class ValidationError extends AuthsomeError {
|
|
10
|
+
fields?: Record<string, string> | undefined;
|
|
11
|
+
constructor(message: string, fields?: Record<string, string> | undefined);
|
|
12
|
+
}
|
|
13
|
+
export declare class UnauthorizedError extends AuthsomeError {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class ForbiddenError extends AuthsomeError {
|
|
17
|
+
constructor(message?: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class NotFoundError extends AuthsomeError {
|
|
20
|
+
constructor(message?: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class ConflictError extends AuthsomeError {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class RateLimitError extends AuthsomeError {
|
|
26
|
+
constructor(message?: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class ServerError extends AuthsomeError {
|
|
29
|
+
constructor(message?: string);
|
|
30
|
+
}
|
|
31
|
+
export declare function createErrorFromResponse(statusCode: number, message: string): AuthsomeError;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Auto-generated error classes
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ServerError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.ValidationError = exports.NetworkError = exports.AuthsomeError = void 0;
|
|
5
|
+
exports.createErrorFromResponse = createErrorFromResponse;
|
|
6
|
+
class AuthsomeError extends Error {
|
|
7
|
+
constructor(message, statusCode, code) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.name = 'AuthsomeError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.AuthsomeError = AuthsomeError;
|
|
15
|
+
class NetworkError extends AuthsomeError {
|
|
16
|
+
constructor(message) {
|
|
17
|
+
super(message, 0, 'NETWORK_ERROR');
|
|
18
|
+
this.name = 'NetworkError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.NetworkError = NetworkError;
|
|
22
|
+
class ValidationError extends AuthsomeError {
|
|
23
|
+
constructor(message, fields) {
|
|
24
|
+
super(message, 400, 'VALIDATION_ERROR');
|
|
25
|
+
this.fields = fields;
|
|
26
|
+
this.name = 'ValidationError';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.ValidationError = ValidationError;
|
|
30
|
+
class UnauthorizedError extends AuthsomeError {
|
|
31
|
+
constructor(message = 'Unauthorized') {
|
|
32
|
+
super(message, 401, 'UNAUTHORIZED');
|
|
33
|
+
this.name = 'UnauthorizedError';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.UnauthorizedError = UnauthorizedError;
|
|
37
|
+
class ForbiddenError extends AuthsomeError {
|
|
38
|
+
constructor(message = 'Forbidden') {
|
|
39
|
+
super(message, 403, 'FORBIDDEN');
|
|
40
|
+
this.name = 'ForbiddenError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.ForbiddenError = ForbiddenError;
|
|
44
|
+
class NotFoundError extends AuthsomeError {
|
|
45
|
+
constructor(message = 'Not found') {
|
|
46
|
+
super(message, 404, 'NOT_FOUND');
|
|
47
|
+
this.name = 'NotFoundError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.NotFoundError = NotFoundError;
|
|
51
|
+
class ConflictError extends AuthsomeError {
|
|
52
|
+
constructor(message) {
|
|
53
|
+
super(message, 409, 'CONFLICT');
|
|
54
|
+
this.name = 'ConflictError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ConflictError = ConflictError;
|
|
58
|
+
class RateLimitError extends AuthsomeError {
|
|
59
|
+
constructor(message = 'Rate limit exceeded') {
|
|
60
|
+
super(message, 429, 'RATE_LIMIT_EXCEEDED');
|
|
61
|
+
this.name = 'RateLimitError';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.RateLimitError = RateLimitError;
|
|
65
|
+
class ServerError extends AuthsomeError {
|
|
66
|
+
constructor(message = 'Internal server error') {
|
|
67
|
+
super(message, 500, 'SERVER_ERROR');
|
|
68
|
+
this.name = 'ServerError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.ServerError = ServerError;
|
|
72
|
+
function createErrorFromResponse(statusCode, message) {
|
|
73
|
+
switch (statusCode) {
|
|
74
|
+
case 400:
|
|
75
|
+
return new ValidationError(message);
|
|
76
|
+
case 401:
|
|
77
|
+
return new UnauthorizedError(message);
|
|
78
|
+
case 403:
|
|
79
|
+
return new ForbiddenError(message);
|
|
80
|
+
case 404:
|
|
81
|
+
return new NotFoundError(message);
|
|
82
|
+
case 409:
|
|
83
|
+
return new ConflictError(message);
|
|
84
|
+
case 429:
|
|
85
|
+
return new RateLimitError(message);
|
|
86
|
+
case 500:
|
|
87
|
+
case 502:
|
|
88
|
+
case 503:
|
|
89
|
+
case 504:
|
|
90
|
+
return new ServerError(message);
|
|
91
|
+
default:
|
|
92
|
+
return new AuthsomeError(message, statusCode);
|
|
93
|
+
}
|
|
94
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { AuthsomeClient, AuthsomeClientConfig } from './client';
|
|
2
|
+
export { ClientPlugin } from './plugin';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './errors';
|
|
5
|
+
export * from './plugins/consent';
|
|
6
|
+
export * from './plugins/idverification';
|
|
7
|
+
export * from './plugins/stepup';
|
|
8
|
+
export * from './plugins/organization';
|
|
9
|
+
export * from './plugins/social';
|
|
10
|
+
export * from './plugins/sso';
|
|
11
|
+
export * from './plugins/backupauth';
|
|
12
|
+
export * from './plugins/multiapp';
|
|
13
|
+
export * from './plugins/twofa';
|
|
14
|
+
export * from './plugins/username';
|
|
15
|
+
export * from './plugins/webhook';
|
|
16
|
+
export * from './plugins/apikey';
|
|
17
|
+
export * from './plugins/impersonation';
|
|
18
|
+
export * from './plugins/jwt';
|
|
19
|
+
export * from './plugins/magiclink';
|
|
20
|
+
export * from './plugins/multisession';
|
|
21
|
+
export * from './plugins/notification';
|
|
22
|
+
export * from './plugins/passkey';
|
|
23
|
+
export * from './plugins/phone';
|
|
24
|
+
export * from './plugins/emailotp';
|
|
25
|
+
export * from './plugins/compliance';
|
|
26
|
+
export * from './plugins/mfa';
|
|
27
|
+
export * from './plugins/oidcprovider';
|
|
28
|
+
export * from './plugins/admin';
|
|
29
|
+
export * from './plugins/anonymous';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Auto-generated exports
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AuthsomeClient = void 0;
|
|
19
|
+
var client_1 = require("./client");
|
|
20
|
+
Object.defineProperty(exports, "AuthsomeClient", { enumerable: true, get: function () { return client_1.AuthsomeClient; } });
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
__exportStar(require("./errors"), exports);
|
|
23
|
+
__exportStar(require("./plugins/consent"), exports);
|
|
24
|
+
__exportStar(require("./plugins/idverification"), exports);
|
|
25
|
+
__exportStar(require("./plugins/stepup"), exports);
|
|
26
|
+
__exportStar(require("./plugins/organization"), exports);
|
|
27
|
+
__exportStar(require("./plugins/social"), exports);
|
|
28
|
+
__exportStar(require("./plugins/sso"), exports);
|
|
29
|
+
__exportStar(require("./plugins/backupauth"), exports);
|
|
30
|
+
__exportStar(require("./plugins/multiapp"), exports);
|
|
31
|
+
__exportStar(require("./plugins/twofa"), exports);
|
|
32
|
+
__exportStar(require("./plugins/username"), exports);
|
|
33
|
+
__exportStar(require("./plugins/webhook"), exports);
|
|
34
|
+
__exportStar(require("./plugins/apikey"), exports);
|
|
35
|
+
__exportStar(require("./plugins/impersonation"), exports);
|
|
36
|
+
__exportStar(require("./plugins/jwt"), exports);
|
|
37
|
+
__exportStar(require("./plugins/magiclink"), exports);
|
|
38
|
+
__exportStar(require("./plugins/multisession"), exports);
|
|
39
|
+
__exportStar(require("./plugins/notification"), exports);
|
|
40
|
+
__exportStar(require("./plugins/passkey"), exports);
|
|
41
|
+
__exportStar(require("./plugins/phone"), exports);
|
|
42
|
+
__exportStar(require("./plugins/emailotp"), exports);
|
|
43
|
+
__exportStar(require("./plugins/compliance"), exports);
|
|
44
|
+
__exportStar(require("./plugins/mfa"), exports);
|
|
45
|
+
__exportStar(require("./plugins/oidcprovider"), exports);
|
|
46
|
+
__exportStar(require("./plugins/admin"), exports);
|
|
47
|
+
__exportStar(require("./plugins/anonymous"), exports);
|
package/dist/plugin.d.ts
ADDED
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ClientPlugin } from '../plugin';
|
|
2
|
+
import { AuthsomeClient } from '../client';
|
|
3
|
+
import * as types from '../types';
|
|
4
|
+
export declare class AdminPlugin implements ClientPlugin {
|
|
5
|
+
readonly id = "admin";
|
|
6
|
+
private client;
|
|
7
|
+
init(client: AuthsomeClient): void;
|
|
8
|
+
createUser(request: types.CreateUser_reqBody): Promise<void>;
|
|
9
|
+
listUsers(): Promise<void>;
|
|
10
|
+
deleteUser(): Promise<types.MessageResponse>;
|
|
11
|
+
banUser(request: types.BanUser_reqBody): Promise<types.MessageResponse>;
|
|
12
|
+
unbanUser(request: types.UnbanUser_reqBody): Promise<types.MessageResponse>;
|
|
13
|
+
impersonateUser(request: types.ImpersonateUser_reqBody): Promise<void>;
|
|
14
|
+
setUserRole(request: types.SetUserRole_reqBody): Promise<types.MessageResponse>;
|
|
15
|
+
listSessions(): Promise<void>;
|
|
16
|
+
revokeSession(): Promise<types.MessageResponse>;
|
|
17
|
+
getStats(): Promise<void>;
|
|
18
|
+
getAuditLogs(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export declare function adminClient(): AdminPlugin;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Auto-generated admin plugin
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AdminPlugin = void 0;
|
|
5
|
+
exports.adminClient = adminClient;
|
|
6
|
+
class AdminPlugin {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.id = 'admin';
|
|
9
|
+
}
|
|
10
|
+
init(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
async createUser(request) {
|
|
14
|
+
const path = '/users';
|
|
15
|
+
return this.client.request('POST', path, {
|
|
16
|
+
body: request,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async listUsers() {
|
|
20
|
+
const path = '/users';
|
|
21
|
+
return this.client.request('GET', path);
|
|
22
|
+
}
|
|
23
|
+
async deleteUser() {
|
|
24
|
+
const path = '/users/:id';
|
|
25
|
+
return this.client.request('DELETE', path);
|
|
26
|
+
}
|
|
27
|
+
async banUser(request) {
|
|
28
|
+
const path = '/users/:id/ban';
|
|
29
|
+
return this.client.request('POST', path, {
|
|
30
|
+
body: request,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async unbanUser(request) {
|
|
34
|
+
const path = '/users/:id/unban';
|
|
35
|
+
return this.client.request('POST', path, {
|
|
36
|
+
body: request,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async impersonateUser(request) {
|
|
40
|
+
const path = '/users/:id/impersonate';
|
|
41
|
+
return this.client.request('POST', path, {
|
|
42
|
+
body: request,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async setUserRole(request) {
|
|
46
|
+
const path = '/users/:id/role';
|
|
47
|
+
return this.client.request('POST', path, {
|
|
48
|
+
body: request,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async listSessions() {
|
|
52
|
+
const path = '/sessions';
|
|
53
|
+
return this.client.request('GET', path);
|
|
54
|
+
}
|
|
55
|
+
async revokeSession() {
|
|
56
|
+
const path = '/sessions/:id';
|
|
57
|
+
return this.client.request('DELETE', path);
|
|
58
|
+
}
|
|
59
|
+
async getStats() {
|
|
60
|
+
const path = '/stats';
|
|
61
|
+
return this.client.request('GET', path);
|
|
62
|
+
}
|
|
63
|
+
async getAuditLogs() {
|
|
64
|
+
const path = '/audit-logs';
|
|
65
|
+
return this.client.request('GET', path);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.AdminPlugin = AdminPlugin;
|
|
69
|
+
function adminClient() {
|
|
70
|
+
return new AdminPlugin();
|
|
71
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClientPlugin } from '../plugin';
|
|
2
|
+
import { AuthsomeClient } from '../client';
|
|
3
|
+
import * as types from '../types';
|
|
4
|
+
export declare class AnonymousPlugin implements ClientPlugin {
|
|
5
|
+
readonly id = "anonymous";
|
|
6
|
+
private client;
|
|
7
|
+
init(client: AuthsomeClient): void;
|
|
8
|
+
signIn(): Promise<types.SignInResponse>;
|
|
9
|
+
link(request: types.LinkRequest): Promise<types.LinkResponse>;
|
|
10
|
+
}
|
|
11
|
+
export declare function anonymousClient(): AnonymousPlugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Auto-generated anonymous plugin
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AnonymousPlugin = void 0;
|
|
5
|
+
exports.anonymousClient = anonymousClient;
|
|
6
|
+
class AnonymousPlugin {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.id = 'anonymous';
|
|
9
|
+
}
|
|
10
|
+
init(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
async signIn() {
|
|
14
|
+
const path = '/anonymous/signin';
|
|
15
|
+
return this.client.request('POST', path);
|
|
16
|
+
}
|
|
17
|
+
async link(request) {
|
|
18
|
+
const path = '/anonymous/link';
|
|
19
|
+
return this.client.request('POST', path, {
|
|
20
|
+
body: request,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AnonymousPlugin = AnonymousPlugin;
|
|
25
|
+
function anonymousClient() {
|
|
26
|
+
return new AnonymousPlugin();
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ClientPlugin } from '../plugin';
|
|
2
|
+
import { AuthsomeClient } from '../client';
|
|
3
|
+
import * as types from '../types';
|
|
4
|
+
export declare class ApikeyPlugin implements ClientPlugin {
|
|
5
|
+
readonly id = "apikey";
|
|
6
|
+
private client;
|
|
7
|
+
init(client: AuthsomeClient): void;
|
|
8
|
+
createAPIKey(request: types.CreateAPIKey_reqBody): Promise<types.CreateAPIKeyResponse>;
|
|
9
|
+
listAPIKeys(): Promise<void>;
|
|
10
|
+
getAPIKey(): Promise<void>;
|
|
11
|
+
updateAPIKey(): Promise<void>;
|
|
12
|
+
deleteAPIKey(): Promise<types.MessageResponse>;
|
|
13
|
+
rotateAPIKey(): Promise<types.RotateAPIKeyResponse>;
|
|
14
|
+
verifyAPIKey(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare function apikeyClient(): ApikeyPlugin;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Auto-generated apikey plugin
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ApikeyPlugin = void 0;
|
|
5
|
+
exports.apikeyClient = apikeyClient;
|
|
6
|
+
class ApikeyPlugin {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.id = 'apikey';
|
|
9
|
+
}
|
|
10
|
+
init(client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
async createAPIKey(request) {
|
|
14
|
+
const path = '/createapikey';
|
|
15
|
+
return this.client.request('POST', path, {
|
|
16
|
+
body: request,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async listAPIKeys() {
|
|
20
|
+
const path = '/listapikeys';
|
|
21
|
+
return this.client.request('GET', path);
|
|
22
|
+
}
|
|
23
|
+
async getAPIKey() {
|
|
24
|
+
const path = '/:id';
|
|
25
|
+
return this.client.request('GET', path);
|
|
26
|
+
}
|
|
27
|
+
async updateAPIKey() {
|
|
28
|
+
const path = '/:id';
|
|
29
|
+
return this.client.request('PUT', path);
|
|
30
|
+
}
|
|
31
|
+
async deleteAPIKey() {
|
|
32
|
+
const path = '/:id';
|
|
33
|
+
return this.client.request('DELETE', path);
|
|
34
|
+
}
|
|
35
|
+
async rotateAPIKey() {
|
|
36
|
+
const path = '/:id/rotate';
|
|
37
|
+
return this.client.request('POST', path);
|
|
38
|
+
}
|
|
39
|
+
async verifyAPIKey() {
|
|
40
|
+
const path = '/verify';
|
|
41
|
+
return this.client.request('POST', path);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.ApikeyPlugin = ApikeyPlugin;
|
|
45
|
+
function apikeyClient() {
|
|
46
|
+
return new ApikeyPlugin();
|
|
47
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ClientPlugin } from '../plugin';
|
|
2
|
+
import { AuthsomeClient } from '../client';
|
|
3
|
+
import * as types from '../types';
|
|
4
|
+
export declare class BackupauthPlugin implements ClientPlugin {
|
|
5
|
+
readonly id = "backupauth";
|
|
6
|
+
private client;
|
|
7
|
+
init(client: AuthsomeClient): void;
|
|
8
|
+
startRecovery(request: types.StartRecoveryRequest): Promise<types.ErrorResponse>;
|
|
9
|
+
continueRecovery(request: types.ContinueRecoveryRequest): Promise<types.ErrorResponse>;
|
|
10
|
+
completeRecovery(request: types.CompleteRecoveryRequest): Promise<types.ErrorResponse>;
|
|
11
|
+
cancelRecovery(request: types.CancelRecoveryRequest): Promise<types.SuccessResponse>;
|
|
12
|
+
generateRecoveryCodes(request: types.GenerateRecoveryCodesRequest): Promise<types.ErrorResponse>;
|
|
13
|
+
verifyRecoveryCode(request: types.VerifyRecoveryCodeRequest): Promise<types.ErrorResponse>;
|
|
14
|
+
setupSecurityQuestions(request: types.SetupSecurityQuestionsRequest): Promise<types.ErrorResponse>;
|
|
15
|
+
getSecurityQuestions(request: types.GetSecurityQuestionsRequest): Promise<types.ErrorResponse>;
|
|
16
|
+
verifySecurityAnswers(request: types.VerifySecurityAnswersRequest): Promise<types.ErrorResponse>;
|
|
17
|
+
addTrustedContact(request: types.AddTrustedContactRequest): Promise<types.ErrorResponse>;
|
|
18
|
+
listTrustedContacts(): Promise<types.ErrorResponse>;
|
|
19
|
+
verifyTrustedContact(request: types.VerifyTrustedContactRequest): Promise<types.ErrorResponse>;
|
|
20
|
+
requestTrustedContactVerification(request: types.RequestTrustedContactVerificationRequest): Promise<types.ErrorResponse>;
|
|
21
|
+
removeTrustedContact(): Promise<types.SuccessResponse>;
|
|
22
|
+
sendVerificationCode(request: types.SendVerificationCodeRequest): Promise<types.ErrorResponse>;
|
|
23
|
+
verifyCode(request: types.VerifyCodeRequest): Promise<types.ErrorResponse>;
|
|
24
|
+
scheduleVideoSession(request: types.ScheduleVideoSessionRequest): Promise<types.ErrorResponse>;
|
|
25
|
+
startVideoSession(request: types.StartVideoSessionRequest): Promise<types.ErrorResponse>;
|
|
26
|
+
completeVideoSession(request: types.CompleteVideoSessionRequest): Promise<types.ErrorResponse>;
|
|
27
|
+
uploadDocument(request: types.UploadDocumentRequest): Promise<types.ErrorResponse>;
|
|
28
|
+
getDocumentVerification(): Promise<types.ErrorResponse>;
|
|
29
|
+
reviewDocument(request: types.ReviewDocumentRequest): Promise<types.SuccessResponse>;
|
|
30
|
+
listRecoverySessions(): Promise<void>;
|
|
31
|
+
approveRecovery(request: types.ApproveRecoveryRequest): Promise<types.ErrorResponse>;
|
|
32
|
+
rejectRecovery(request: types.RejectRecoveryRequest): Promise<types.ErrorResponse>;
|
|
33
|
+
getRecoveryStats(): Promise<void>;
|
|
34
|
+
getRecoveryConfig(): Promise<void>;
|
|
35
|
+
updateRecoveryConfig(request: types.UpdateRecoveryConfigRequest): Promise<types.SuccessResponse>;
|
|
36
|
+
healthCheck(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export declare function backupauthClient(): BackupauthPlugin;
|