authtara-sdk 1.1.21 → 1.1.23
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/{chunk-HTTKR24S.mjs → chunk-RW4FN3I3.mjs} +3 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/index.mjs +1 -1
- package/dist/react.js +33 -25
- package/dist/react.mjs +31 -25
- package/package.json +90 -90
|
@@ -170,7 +170,9 @@ var AuthModule = class {
|
|
|
170
170
|
user: {
|
|
171
171
|
id: ssoPayload.sub ?? "",
|
|
172
172
|
email: ssoPayload.email ?? "",
|
|
173
|
-
name: ssoPayload.name ?? null
|
|
173
|
+
name: ssoPayload.name ?? null,
|
|
174
|
+
platformRole: ssoPayload.platformRole
|
|
175
|
+
// Platform-level role
|
|
174
176
|
},
|
|
175
177
|
tenant: ssoPayload.tenant,
|
|
176
178
|
subscription: ssoPayload.subscription
|
package/dist/index.d.mts
CHANGED
|
@@ -17,6 +17,7 @@ interface SessionVerifyResult {
|
|
|
17
17
|
id: string;
|
|
18
18
|
email: string;
|
|
19
19
|
name: string | null;
|
|
20
|
+
platformRole?: string;
|
|
20
21
|
};
|
|
21
22
|
tenant?: {
|
|
22
23
|
id: string;
|
|
@@ -39,6 +40,7 @@ interface ExchangeResult {
|
|
|
39
40
|
id: string;
|
|
40
41
|
email: string;
|
|
41
42
|
name: string | null;
|
|
43
|
+
platformRole?: string;
|
|
42
44
|
};
|
|
43
45
|
tenant: {
|
|
44
46
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ interface SessionVerifyResult {
|
|
|
17
17
|
id: string;
|
|
18
18
|
email: string;
|
|
19
19
|
name: string | null;
|
|
20
|
+
platformRole?: string;
|
|
20
21
|
};
|
|
21
22
|
tenant?: {
|
|
22
23
|
id: string;
|
|
@@ -39,6 +40,7 @@ interface ExchangeResult {
|
|
|
39
40
|
id: string;
|
|
40
41
|
email: string;
|
|
41
42
|
name: string | null;
|
|
43
|
+
platformRole?: string;
|
|
42
44
|
};
|
|
43
45
|
tenant: {
|
|
44
46
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -202,7 +202,9 @@ var AuthModule = class {
|
|
|
202
202
|
user: {
|
|
203
203
|
id: ssoPayload.sub ?? "",
|
|
204
204
|
email: ssoPayload.email ?? "",
|
|
205
|
-
name: ssoPayload.name ?? null
|
|
205
|
+
name: ssoPayload.name ?? null,
|
|
206
|
+
platformRole: ssoPayload.platformRole
|
|
207
|
+
// Platform-level role
|
|
206
208
|
},
|
|
207
209
|
tenant: ssoPayload.tenant,
|
|
208
210
|
subscription: ssoPayload.subscription
|
package/dist/index.mjs
CHANGED
package/dist/react.js
CHANGED
|
@@ -280,10 +280,37 @@ function AuthTaraAuth({
|
|
|
280
280
|
const [error, setError] = React2.useState(null);
|
|
281
281
|
const [isCredentialsLoading, setIsCredentialsLoading] = React2.useState(false);
|
|
282
282
|
const [turnstileToken, setTurnstileToken] = React2.useState(null);
|
|
283
|
-
const
|
|
283
|
+
const turnstileContainerRef = React2.useRef(null);
|
|
284
|
+
const turnstileWidgetId = React2.useRef(null);
|
|
284
285
|
const [email, setEmail] = React2.useState("");
|
|
285
286
|
const [password, setPassword] = React2.useState("");
|
|
286
287
|
const isLoading = oauthLoading || isCredentialsLoading;
|
|
288
|
+
const isDark = appearance?.theme === "dark";
|
|
289
|
+
React2.useEffect(() => {
|
|
290
|
+
if (!turnstileSiteKey || !turnstileContainerRef.current) return;
|
|
291
|
+
if (typeof window === "undefined" || !window.turnstile) return;
|
|
292
|
+
if (turnstileWidgetId.current) return;
|
|
293
|
+
const widgetId = window.turnstile.render(turnstileContainerRef.current, {
|
|
294
|
+
sitekey: turnstileSiteKey,
|
|
295
|
+
theme: isDark ? "dark" : "light",
|
|
296
|
+
callback: (token) => setTurnstileToken(token),
|
|
297
|
+
"expired-callback": () => setTurnstileToken(null),
|
|
298
|
+
"error-callback": () => setTurnstileToken(null)
|
|
299
|
+
});
|
|
300
|
+
turnstileWidgetId.current = widgetId;
|
|
301
|
+
return () => {
|
|
302
|
+
if (turnstileWidgetId.current && window.turnstile) {
|
|
303
|
+
window.turnstile.remove(turnstileWidgetId.current);
|
|
304
|
+
turnstileWidgetId.current = null;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
}, [turnstileSiteKey, isDark]);
|
|
308
|
+
function resetTurnstile() {
|
|
309
|
+
if (turnstileWidgetId.current && window.turnstile) {
|
|
310
|
+
window.turnstile.reset(turnstileWidgetId.current);
|
|
311
|
+
setTurnstileToken(null);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
287
314
|
async function handleOAuthSignIn(selectedProvider) {
|
|
288
315
|
setError(null);
|
|
289
316
|
try {
|
|
@@ -332,13 +359,11 @@ function AuthTaraAuth({
|
|
|
332
359
|
const message = err instanceof Error ? err.message : "Authentication failed";
|
|
333
360
|
setError(message);
|
|
334
361
|
onError?.(err);
|
|
335
|
-
|
|
336
|
-
setTurnstileToken(null);
|
|
362
|
+
resetTurnstile();
|
|
337
363
|
} finally {
|
|
338
364
|
setIsCredentialsLoading(false);
|
|
339
365
|
}
|
|
340
366
|
}
|
|
341
|
-
const isDark = appearance?.theme === "dark";
|
|
342
367
|
const cardBgColor = isDark ? "#111111" : "#ffffff";
|
|
343
368
|
const cardBorderColor = isDark ? "#222222" : "#e5e7eb";
|
|
344
369
|
const textColor = isDark ? "#ffffff" : "#111827";
|
|
@@ -553,26 +578,7 @@ function AuthTaraAuth({
|
|
|
553
578
|
}
|
|
554
579
|
)
|
|
555
580
|
] }),
|
|
556
|
-
turnstileSiteKey && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", justifyContent: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
557
|
-
"div",
|
|
558
|
-
{
|
|
559
|
-
id: "turnstile-widget",
|
|
560
|
-
ref: (el) => {
|
|
561
|
-
if (el && typeof window !== "undefined" && window.turnstile) {
|
|
562
|
-
window.turnstile.render(el, {
|
|
563
|
-
sitekey: turnstileSiteKey,
|
|
564
|
-
theme: isDark ? "dark" : "light",
|
|
565
|
-
callback: (token) => setTurnstileToken(token),
|
|
566
|
-
"expired-callback": () => setTurnstileToken(null),
|
|
567
|
-
"error-callback": () => setTurnstileToken(null)
|
|
568
|
-
});
|
|
569
|
-
turnstileRef.current = {
|
|
570
|
-
reset: () => window.turnstile.reset(el)
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
) }),
|
|
581
|
+
turnstileSiteKey && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", justifyContent: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: turnstileContainerRef }) }),
|
|
576
582
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
577
583
|
"button",
|
|
578
584
|
{
|
|
@@ -802,7 +808,9 @@ var AuthModule = class {
|
|
|
802
808
|
user: {
|
|
803
809
|
id: ssoPayload.sub ?? "",
|
|
804
810
|
email: ssoPayload.email ?? "",
|
|
805
|
-
name: ssoPayload.name ?? null
|
|
811
|
+
name: ssoPayload.name ?? null,
|
|
812
|
+
platformRole: ssoPayload.platformRole
|
|
813
|
+
// Platform-level role
|
|
806
814
|
},
|
|
807
815
|
tenant: ssoPayload.tenant,
|
|
808
816
|
subscription: ssoPayload.subscription
|
package/dist/react.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Authtara
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RW4FN3I3.mjs";
|
|
4
4
|
|
|
5
5
|
// src/components/providers/AuthTaraProvider.tsx
|
|
6
6
|
import * as React from "react";
|
|
@@ -244,10 +244,37 @@ function AuthTaraAuth({
|
|
|
244
244
|
const [error, setError] = React2.useState(null);
|
|
245
245
|
const [isCredentialsLoading, setIsCredentialsLoading] = React2.useState(false);
|
|
246
246
|
const [turnstileToken, setTurnstileToken] = React2.useState(null);
|
|
247
|
-
const
|
|
247
|
+
const turnstileContainerRef = React2.useRef(null);
|
|
248
|
+
const turnstileWidgetId = React2.useRef(null);
|
|
248
249
|
const [email, setEmail] = React2.useState("");
|
|
249
250
|
const [password, setPassword] = React2.useState("");
|
|
250
251
|
const isLoading = oauthLoading || isCredentialsLoading;
|
|
252
|
+
const isDark = appearance?.theme === "dark";
|
|
253
|
+
React2.useEffect(() => {
|
|
254
|
+
if (!turnstileSiteKey || !turnstileContainerRef.current) return;
|
|
255
|
+
if (typeof window === "undefined" || !window.turnstile) return;
|
|
256
|
+
if (turnstileWidgetId.current) return;
|
|
257
|
+
const widgetId = window.turnstile.render(turnstileContainerRef.current, {
|
|
258
|
+
sitekey: turnstileSiteKey,
|
|
259
|
+
theme: isDark ? "dark" : "light",
|
|
260
|
+
callback: (token) => setTurnstileToken(token),
|
|
261
|
+
"expired-callback": () => setTurnstileToken(null),
|
|
262
|
+
"error-callback": () => setTurnstileToken(null)
|
|
263
|
+
});
|
|
264
|
+
turnstileWidgetId.current = widgetId;
|
|
265
|
+
return () => {
|
|
266
|
+
if (turnstileWidgetId.current && window.turnstile) {
|
|
267
|
+
window.turnstile.remove(turnstileWidgetId.current);
|
|
268
|
+
turnstileWidgetId.current = null;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}, [turnstileSiteKey, isDark]);
|
|
272
|
+
function resetTurnstile() {
|
|
273
|
+
if (turnstileWidgetId.current && window.turnstile) {
|
|
274
|
+
window.turnstile.reset(turnstileWidgetId.current);
|
|
275
|
+
setTurnstileToken(null);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
251
278
|
async function handleOAuthSignIn(selectedProvider) {
|
|
252
279
|
setError(null);
|
|
253
280
|
try {
|
|
@@ -296,13 +323,11 @@ function AuthTaraAuth({
|
|
|
296
323
|
const message = err instanceof Error ? err.message : "Authentication failed";
|
|
297
324
|
setError(message);
|
|
298
325
|
onError?.(err);
|
|
299
|
-
|
|
300
|
-
setTurnstileToken(null);
|
|
326
|
+
resetTurnstile();
|
|
301
327
|
} finally {
|
|
302
328
|
setIsCredentialsLoading(false);
|
|
303
329
|
}
|
|
304
330
|
}
|
|
305
|
-
const isDark = appearance?.theme === "dark";
|
|
306
331
|
const cardBgColor = isDark ? "#111111" : "#ffffff";
|
|
307
332
|
const cardBorderColor = isDark ? "#222222" : "#e5e7eb";
|
|
308
333
|
const textColor = isDark ? "#ffffff" : "#111827";
|
|
@@ -517,26 +542,7 @@ function AuthTaraAuth({
|
|
|
517
542
|
}
|
|
518
543
|
)
|
|
519
544
|
] }),
|
|
520
|
-
turnstileSiteKey && /* @__PURE__ */ jsx2("div", { style: { display: "flex", justifyContent: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ jsx2(
|
|
521
|
-
"div",
|
|
522
|
-
{
|
|
523
|
-
id: "turnstile-widget",
|
|
524
|
-
ref: (el) => {
|
|
525
|
-
if (el && typeof window !== "undefined" && window.turnstile) {
|
|
526
|
-
window.turnstile.render(el, {
|
|
527
|
-
sitekey: turnstileSiteKey,
|
|
528
|
-
theme: isDark ? "dark" : "light",
|
|
529
|
-
callback: (token) => setTurnstileToken(token),
|
|
530
|
-
"expired-callback": () => setTurnstileToken(null),
|
|
531
|
-
"error-callback": () => setTurnstileToken(null)
|
|
532
|
-
});
|
|
533
|
-
turnstileRef.current = {
|
|
534
|
-
reset: () => window.turnstile.reset(el)
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
) }),
|
|
545
|
+
turnstileSiteKey && /* @__PURE__ */ jsx2("div", { style: { display: "flex", justifyContent: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ jsx2("div", { ref: turnstileContainerRef }) }),
|
|
540
546
|
/* @__PURE__ */ jsx2(
|
|
541
547
|
"button",
|
|
542
548
|
{
|
package/package.json
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "authtara-sdk",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "SDK Client untuk integrasi dengan DigitalSolution Platform - SSO, Billing, dan Metering",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"module": "./dist/index.mjs",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.mjs",
|
|
12
|
-
"require": "./dist/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./react": {
|
|
15
|
-
"types": "./dist/react.d.ts",
|
|
16
|
-
"import": "./dist/react.mjs",
|
|
17
|
-
"require": "./dist/react.js"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist",
|
|
22
|
-
"README.md",
|
|
23
|
-
"LICENSE"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsup src/index.ts src/react.ts --format cjs,esm --dts --clean",
|
|
27
|
-
"dev": "tsup src/index.ts src/react.ts --format cjs,esm --dts --watch",
|
|
28
|
-
"test": "vitest",
|
|
29
|
-
"test:run": "vitest run",
|
|
30
|
-
"test:coverage": "vitest run --coverage",
|
|
31
|
-
"typecheck": "tsc --noEmit",
|
|
32
|
-
"prepublishOnly": "bun run build && bun test:run",
|
|
33
|
-
"release": "bun run build && bun test:run && npm version patch",
|
|
34
|
-
"release:minor": "bun run build && bun test:run && npm version minor",
|
|
35
|
-
"release:major": "bun run build && bun test:run && npm version major"
|
|
36
|
-
},
|
|
37
|
-
"keywords": [
|
|
38
|
-
"digitalsolution",
|
|
39
|
-
"authtara",
|
|
40
|
-
"sdk",
|
|
41
|
-
"sso",
|
|
42
|
-
"authentication",
|
|
43
|
-
"billing",
|
|
44
|
-
"metering",
|
|
45
|
-
"oauth",
|
|
46
|
-
"jwt",
|
|
47
|
-
"saas"
|
|
48
|
-
],
|
|
49
|
-
"author": "DigitalSolution Team",
|
|
50
|
-
"license": "MIT",
|
|
51
|
-
"repository": {
|
|
52
|
-
"type": "git",
|
|
53
|
-
"url": "https://github.com/digitalsolution/authtara-sdk.git"
|
|
54
|
-
},
|
|
55
|
-
"bugs": {
|
|
56
|
-
"url": "https://github.com/digitalsolution/authtara-sdk/issues",
|
|
57
|
-
"email": "support@digitalsolution.com"
|
|
58
|
-
},
|
|
59
|
-
"homepage": "https://docs.digitalsolution.com/sdk",
|
|
60
|
-
"dependencies": {
|
|
61
|
-
"jose": "^6.0.11"
|
|
62
|
-
},
|
|
63
|
-
"peerDependencies": {
|
|
64
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
65
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
66
|
-
},
|
|
67
|
-
"peerDependenciesMeta": {
|
|
68
|
-
"react": {
|
|
69
|
-
"optional": true
|
|
70
|
-
},
|
|
71
|
-
"react-dom": {
|
|
72
|
-
"optional": true
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
"devDependencies": {
|
|
76
|
-
"@types/node": "^24.0.0",
|
|
77
|
-
"@types/react": "^19.2.8",
|
|
78
|
-
"@types/react-dom": "^19.2.3",
|
|
79
|
-
"@vitest/coverage-v8": "^4.0.15",
|
|
80
|
-
"tsup": "^8.5.0",
|
|
81
|
-
"typescript": "^5.9.3",
|
|
82
|
-
"vitest": "^4.0.15"
|
|
83
|
-
},
|
|
84
|
-
"engines": {
|
|
85
|
-
"node": ">=18.0.0"
|
|
86
|
-
},
|
|
87
|
-
"publishConfig": {
|
|
88
|
-
"access": "public",
|
|
89
|
-
"registry": "https://registry.npmjs.org/"
|
|
90
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "authtara-sdk",
|
|
3
|
+
"version": "1.1.23",
|
|
4
|
+
"description": "SDK Client untuk integrasi dengan DigitalSolution Platform - SSO, Billing, dan Metering",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./react": {
|
|
15
|
+
"types": "./dist/react.d.ts",
|
|
16
|
+
"import": "./dist/react.mjs",
|
|
17
|
+
"require": "./dist/react.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup src/index.ts src/react.ts --format cjs,esm --dts --clean",
|
|
27
|
+
"dev": "tsup src/index.ts src/react.ts --format cjs,esm --dts --watch",
|
|
28
|
+
"test": "vitest",
|
|
29
|
+
"test:run": "vitest run",
|
|
30
|
+
"test:coverage": "vitest run --coverage",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"prepublishOnly": "bun run build && bun test:run",
|
|
33
|
+
"release": "bun run build && bun test:run && npm version patch",
|
|
34
|
+
"release:minor": "bun run build && bun test:run && npm version minor",
|
|
35
|
+
"release:major": "bun run build && bun test:run && npm version major"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"digitalsolution",
|
|
39
|
+
"authtara",
|
|
40
|
+
"sdk",
|
|
41
|
+
"sso",
|
|
42
|
+
"authentication",
|
|
43
|
+
"billing",
|
|
44
|
+
"metering",
|
|
45
|
+
"oauth",
|
|
46
|
+
"jwt",
|
|
47
|
+
"saas"
|
|
48
|
+
],
|
|
49
|
+
"author": "DigitalSolution Team",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/digitalsolution/authtara-sdk.git"
|
|
54
|
+
},
|
|
55
|
+
"bugs": {
|
|
56
|
+
"url": "https://github.com/digitalsolution/authtara-sdk/issues",
|
|
57
|
+
"email": "support@digitalsolution.com"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://docs.digitalsolution.com/sdk",
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"jose": "^6.0.11"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
65
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
66
|
+
},
|
|
67
|
+
"peerDependenciesMeta": {
|
|
68
|
+
"react": {
|
|
69
|
+
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"react-dom": {
|
|
72
|
+
"optional": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@types/node": "^24.0.0",
|
|
77
|
+
"@types/react": "^19.2.8",
|
|
78
|
+
"@types/react-dom": "^19.2.3",
|
|
79
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
80
|
+
"tsup": "^8.5.0",
|
|
81
|
+
"typescript": "^5.9.3",
|
|
82
|
+
"vitest": "^4.0.15"
|
|
83
|
+
},
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=18.0.0"
|
|
86
|
+
},
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public",
|
|
89
|
+
"registry": "https://registry.npmjs.org/"
|
|
90
|
+
}
|
|
91
91
|
}
|