@savant-realms/federated-auth-realm-sdk-ts-js 0.4.2 → 0.4.4
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/discovery.d.ts +9 -1
- package/dist/discovery.js +45 -4
- package/dist/types/index.d.ts +14 -0
- package/package.json +1 -1
package/dist/discovery.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
1
2
|
export interface RealmInfo {
|
|
2
3
|
id: string;
|
|
3
4
|
url: string;
|
|
@@ -10,9 +11,15 @@ export interface SRWPWhisperRequest {
|
|
|
10
11
|
timestamp: number;
|
|
11
12
|
knownRealms: RealmInfo[];
|
|
12
13
|
}
|
|
14
|
+
export interface SRWPDiscoveryClientConfig {
|
|
15
|
+
baseURL: string;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
headers?: AxiosRequestConfig['headers'];
|
|
18
|
+
httpsAgent?: AxiosRequestConfig['httpsAgent'];
|
|
19
|
+
}
|
|
13
20
|
export declare class SRWPDiscoveryClient {
|
|
14
21
|
private client;
|
|
15
|
-
constructor(
|
|
22
|
+
constructor(config: string | SRWPDiscoveryClientConfig);
|
|
16
23
|
whisper(data: SRWPWhisperRequest): Promise<{
|
|
17
24
|
message: string;
|
|
18
25
|
}>;
|
|
@@ -20,4 +27,5 @@ export declare class SRWPDiscoveryClient {
|
|
|
20
27
|
bootstrap(peerUrl: string): Promise<{
|
|
21
28
|
message: string;
|
|
22
29
|
}>;
|
|
30
|
+
private resolveBaseUrl;
|
|
23
31
|
}
|
package/dist/discovery.js
CHANGED
|
@@ -6,13 +6,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.SRWPDiscoveryClient = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
class SRWPDiscoveryClient {
|
|
9
|
-
constructor(
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
constructor(config) {
|
|
10
|
+
const baseURL = typeof config === 'string' ? config : config.baseURL;
|
|
11
|
+
const resolvedBaseURL = this.resolveBaseUrl(baseURL);
|
|
12
|
+
const axiosConfig = {
|
|
13
|
+
baseURL: resolvedBaseURL,
|
|
12
14
|
headers: {
|
|
13
15
|
'Content-Type': 'application/json',
|
|
14
16
|
},
|
|
15
|
-
}
|
|
17
|
+
};
|
|
18
|
+
if (typeof config === 'object') {
|
|
19
|
+
if (config.headers) {
|
|
20
|
+
axiosConfig.headers = {
|
|
21
|
+
...axiosConfig.headers,
|
|
22
|
+
...config.headers,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
if (config.timeout !== undefined) {
|
|
26
|
+
axiosConfig.timeout = config.timeout;
|
|
27
|
+
}
|
|
28
|
+
if (config.httpsAgent) {
|
|
29
|
+
axiosConfig.httpsAgent = config.httpsAgent;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
this.client = axios_1.default.create(axiosConfig);
|
|
16
33
|
}
|
|
17
34
|
async whisper(data) {
|
|
18
35
|
const response = await this.client.post('/whisper', data);
|
|
@@ -28,5 +45,29 @@ class SRWPDiscoveryClient {
|
|
|
28
45
|
});
|
|
29
46
|
return response.data;
|
|
30
47
|
}
|
|
48
|
+
resolveBaseUrl(baseURL) {
|
|
49
|
+
if (!baseURL) {
|
|
50
|
+
throw new Error('SRWP baseURL is required');
|
|
51
|
+
}
|
|
52
|
+
let candidate = baseURL.trim();
|
|
53
|
+
if (!candidate) {
|
|
54
|
+
throw new Error('SRWP baseURL is required');
|
|
55
|
+
}
|
|
56
|
+
if (!/^https?:\/\//i.test(candidate)) {
|
|
57
|
+
const normalized = candidate.replace(/^\/+/, '');
|
|
58
|
+
const isLocalHost = normalized.startsWith('localhost') ||
|
|
59
|
+
normalized.startsWith('127.') ||
|
|
60
|
+
normalized.startsWith('0.0.0.0');
|
|
61
|
+
candidate = `${isLocalHost ? 'http' : 'https'}://${normalized}`;
|
|
62
|
+
}
|
|
63
|
+
let parsed;
|
|
64
|
+
try {
|
|
65
|
+
parsed = new URL(candidate);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
throw new Error(`Invalid SRWP baseURL provided: ${baseURL}. Expected a fully qualified URL.`);
|
|
69
|
+
}
|
|
70
|
+
return `${parsed.origin}/srwp`;
|
|
71
|
+
}
|
|
31
72
|
}
|
|
32
73
|
exports.SRWPDiscoveryClient = SRWPDiscoveryClient;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -176,10 +176,24 @@ export interface Application {
|
|
|
176
176
|
name: string;
|
|
177
177
|
logo?: string;
|
|
178
178
|
description?: string;
|
|
179
|
+
category?: string;
|
|
179
180
|
status?: ApplicationStatus;
|
|
180
181
|
managerId?: string;
|
|
182
|
+
managerName?: string;
|
|
183
|
+
managerSurname?: string;
|
|
184
|
+
contactEmail?: string;
|
|
185
|
+
contactPhone?: string;
|
|
181
186
|
isPublic?: boolean;
|
|
182
187
|
platforms?: Platform[];
|
|
188
|
+
allowRegistration?: boolean;
|
|
189
|
+
requireEmailVerification?: boolean;
|
|
190
|
+
requireApproval?: boolean;
|
|
191
|
+
autoGrantAccess?: boolean;
|
|
192
|
+
maxUsers?: number;
|
|
193
|
+
allowGuestUsers?: boolean;
|
|
194
|
+
registrationRequiredFields?: string[];
|
|
195
|
+
otherOptionalFields?: string[];
|
|
196
|
+
pendingAccessRequests?: any[];
|
|
183
197
|
config?: Record<string, unknown>;
|
|
184
198
|
createdAt?: string;
|
|
185
199
|
updatedAt?: string;
|