isa-auth 0.1.0 → 0.2.0
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/.agents/skills/isa-auth-guide/SKILL.md +154 -0
- package/README.md +176 -120
- package/dist/index.d.mts +797 -68
- package/dist/index.d.ts +797 -68
- package/dist/index.js +2380 -293
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2379 -292
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -6
- package/skills/isa-auth-guide/SKILL.md +167 -0
package/dist/index.js
CHANGED
|
@@ -78,7 +78,9 @@ var require_store = __commonJS({
|
|
|
78
78
|
function _export(target, all) {
|
|
79
79
|
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
80
80
|
}
|
|
81
|
-
_export(exports2, { get
|
|
81
|
+
_export(exports2, { get batch() {
|
|
82
|
+
return batch2;
|
|
83
|
+
}, get clearState() {
|
|
82
84
|
return clearState;
|
|
83
85
|
}, get deleteState() {
|
|
84
86
|
return deleteState;
|
|
@@ -88,38 +90,64 @@ var require_store = __commonJS({
|
|
|
88
90
|
return hasState;
|
|
89
91
|
}, get initState() {
|
|
90
92
|
return initState;
|
|
93
|
+
}, get resetAllState() {
|
|
94
|
+
return resetAllState;
|
|
91
95
|
}, get setState() {
|
|
92
96
|
return setState;
|
|
93
97
|
}, get subscribe() {
|
|
94
98
|
return subscribe;
|
|
99
|
+
}, get subscribeSelector() {
|
|
100
|
+
return subscribeSelector2;
|
|
95
101
|
} });
|
|
96
102
|
var _isautil = require("isa-util");
|
|
97
103
|
var _error = require_error();
|
|
98
104
|
var store = /* @__PURE__ */ new Map();
|
|
99
105
|
var listeners = /* @__PURE__ */ new Map();
|
|
106
|
+
var isBatching = false;
|
|
107
|
+
var pendingNotifications = /* @__PURE__ */ new Set();
|
|
108
|
+
var defaultEquality = (a, b) => Object.is(a, b);
|
|
100
109
|
function initState(id, value) {
|
|
101
110
|
if ((0, _isautil.isUndefined)(value) || (0, _isautil.isFalsy)(id)) return (0, _error.storeError)("wrong", id);
|
|
102
111
|
store.set(id, value);
|
|
103
|
-
listeners.
|
|
112
|
+
if (!listeners.has(id)) {
|
|
113
|
+
listeners.set(id, /* @__PURE__ */ new Set());
|
|
114
|
+
}
|
|
104
115
|
}
|
|
105
116
|
function getState(id) {
|
|
106
117
|
const state = store.get(id);
|
|
107
118
|
if ((0, _isautil.isUndefined)(state)) {
|
|
108
|
-
(0, _error.storeError)("wrong", id);
|
|
109
119
|
return void 0;
|
|
110
120
|
}
|
|
111
121
|
return state;
|
|
112
122
|
}
|
|
113
|
-
function setState(id, value) {
|
|
114
|
-
const
|
|
115
|
-
if ((0, _isautil.isUndefined)(
|
|
123
|
+
function setState(id, value, forceNotify = false) {
|
|
124
|
+
const previousState = store.get(id);
|
|
125
|
+
if ((0, _isautil.isUndefined)(value)) return (0, _error.storeError)("wrong", id);
|
|
126
|
+
if (!forceNotify && defaultEquality(previousState, value)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
116
129
|
store.set(id, value);
|
|
130
|
+
if (isBatching) {
|
|
131
|
+
pendingNotifications.add(id);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
notifyListeners(id, value, previousState);
|
|
135
|
+
}
|
|
136
|
+
function notifyListeners(id, current, previous) {
|
|
117
137
|
const idListeners = listeners.get(id);
|
|
118
|
-
idListeners
|
|
138
|
+
if (!idListeners || idListeners.size === 0) return;
|
|
139
|
+
const snapshot = Array.from(idListeners);
|
|
140
|
+
for (const listener of snapshot) {
|
|
141
|
+
try {
|
|
142
|
+
listener(current, previous);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.error(`[ISA-AUTH Store] Error in listener for state "${id}":`, err);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
119
147
|
}
|
|
120
148
|
function clearState(id) {
|
|
121
149
|
if (!store.has(id)) return (0, _error.storeError)("wrong", id);
|
|
122
|
-
|
|
150
|
+
setState(id, null);
|
|
123
151
|
}
|
|
124
152
|
function deleteState(id) {
|
|
125
153
|
if (!store.has(id)) return (0, _error.storeError)("wrong", id);
|
|
@@ -130,17 +158,59 @@ var require_store = __commonJS({
|
|
|
130
158
|
return store.has(id);
|
|
131
159
|
}
|
|
132
160
|
function subscribe(id, listener) {
|
|
133
|
-
if (!store.has(id))
|
|
161
|
+
if (!store.has(id)) {
|
|
162
|
+
store.set(id, null);
|
|
163
|
+
listeners.set(id, /* @__PURE__ */ new Set());
|
|
164
|
+
}
|
|
134
165
|
var _listeners_get;
|
|
135
166
|
const idListeners = (_listeners_get = listeners.get(id)) !== null && _listeners_get !== void 0 ? _listeners_get : /* @__PURE__ */ new Set();
|
|
136
167
|
idListeners.add(listener);
|
|
137
168
|
listeners.set(id, idListeners);
|
|
138
|
-
|
|
169
|
+
try {
|
|
170
|
+
listener(getState(id));
|
|
171
|
+
} catch (err) {
|
|
172
|
+
console.error(`[ISA-AUTH Store] Error in initial subscriber call for "${id}":`, err);
|
|
173
|
+
}
|
|
139
174
|
return () => {
|
|
140
175
|
idListeners.delete(listener);
|
|
141
|
-
if (idListeners.size === 0)
|
|
176
|
+
if (idListeners.size === 0) {
|
|
177
|
+
listeners.delete(id);
|
|
178
|
+
}
|
|
142
179
|
};
|
|
143
180
|
}
|
|
181
|
+
function subscribeSelector2(id, selector, listener, equalityFn = defaultEquality) {
|
|
182
|
+
let prevSlice = selector(getState(id));
|
|
183
|
+
return subscribe(id, (currentState) => {
|
|
184
|
+
const nextSlice = selector(currentState);
|
|
185
|
+
if (!equalityFn(prevSlice, nextSlice)) {
|
|
186
|
+
const oldSlice = prevSlice;
|
|
187
|
+
prevSlice = nextSlice;
|
|
188
|
+
listener(nextSlice, oldSlice);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function batch2(fn) {
|
|
193
|
+
const wasBatching = isBatching;
|
|
194
|
+
isBatching = true;
|
|
195
|
+
try {
|
|
196
|
+
fn();
|
|
197
|
+
} finally {
|
|
198
|
+
if (!wasBatching) {
|
|
199
|
+
isBatching = false;
|
|
200
|
+
const ids = Array.from(pendingNotifications);
|
|
201
|
+
pendingNotifications.clear();
|
|
202
|
+
for (const id of ids) {
|
|
203
|
+
notifyListeners(id, store.get(id), void 0);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function resetAllState() {
|
|
209
|
+
store.clear();
|
|
210
|
+
listeners.clear();
|
|
211
|
+
pendingNotifications.clear();
|
|
212
|
+
isBatching = false;
|
|
213
|
+
}
|
|
144
214
|
}
|
|
145
215
|
});
|
|
146
216
|
|
|
@@ -179,12 +249,14 @@ var require_storageAdapter = __commonJS({
|
|
|
179
249
|
function _export(target, all) {
|
|
180
250
|
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
181
251
|
}
|
|
182
|
-
_export(exports2, { get
|
|
183
|
-
return
|
|
252
|
+
_export(exports2, { get CookieSessionStorageAdapter() {
|
|
253
|
+
return CookieSessionStorageAdapter2;
|
|
254
|
+
}, get LocalStorageAdapter() {
|
|
255
|
+
return LocalStorageAdapter2;
|
|
184
256
|
}, get MemoryStorageAdapter() {
|
|
185
|
-
return
|
|
257
|
+
return MemoryStorageAdapter2;
|
|
186
258
|
}, get SessionStorageAdapter() {
|
|
187
|
-
return
|
|
259
|
+
return SessionStorageAdapter2;
|
|
188
260
|
} });
|
|
189
261
|
function _define_property(obj, key, value) {
|
|
190
262
|
if (key in obj) {
|
|
@@ -194,7 +266,7 @@ var require_storageAdapter = __commonJS({
|
|
|
194
266
|
}
|
|
195
267
|
return obj;
|
|
196
268
|
}
|
|
197
|
-
var
|
|
269
|
+
var MemoryStorageAdapter2 = class {
|
|
198
270
|
getItem(key) {
|
|
199
271
|
var _this_cache_get;
|
|
200
272
|
return (_this_cache_get = this.cache.get(key)) !== null && _this_cache_get !== void 0 ? _this_cache_get : null;
|
|
@@ -205,11 +277,17 @@ var require_storageAdapter = __commonJS({
|
|
|
205
277
|
removeItem(key) {
|
|
206
278
|
this.cache.delete(key);
|
|
207
279
|
}
|
|
280
|
+
clear() {
|
|
281
|
+
this.cache.clear();
|
|
282
|
+
}
|
|
283
|
+
keys() {
|
|
284
|
+
return Array.from(this.cache.keys());
|
|
285
|
+
}
|
|
208
286
|
constructor() {
|
|
209
287
|
_define_property(this, "cache", /* @__PURE__ */ new Map());
|
|
210
288
|
}
|
|
211
289
|
};
|
|
212
|
-
var
|
|
290
|
+
var LocalStorageAdapter2 = class {
|
|
213
291
|
getItem(key) {
|
|
214
292
|
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
215
293
|
try {
|
|
@@ -234,8 +312,24 @@ var require_storageAdapter = __commonJS({
|
|
|
234
312
|
console.warn("[ISA-AUTH] Failed to remove from localStorage", e);
|
|
235
313
|
}
|
|
236
314
|
}
|
|
315
|
+
clear() {
|
|
316
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
317
|
+
try {
|
|
318
|
+
window.localStorage.clear();
|
|
319
|
+
} catch (e) {
|
|
320
|
+
console.warn("[ISA-AUTH] Failed to clear localStorage", e);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
keys() {
|
|
324
|
+
if (typeof window === "undefined" || !window.localStorage) return [];
|
|
325
|
+
try {
|
|
326
|
+
return Object.keys(window.localStorage);
|
|
327
|
+
} catch {
|
|
328
|
+
return [];
|
|
329
|
+
}
|
|
330
|
+
}
|
|
237
331
|
};
|
|
238
|
-
var
|
|
332
|
+
var SessionStorageAdapter2 = class {
|
|
239
333
|
getItem(key) {
|
|
240
334
|
if (typeof window === "undefined" || !window.sessionStorage) return null;
|
|
241
335
|
try {
|
|
@@ -260,6 +354,54 @@ var require_storageAdapter = __commonJS({
|
|
|
260
354
|
console.warn("[ISA-AUTH] Failed to remove from sessionStorage", e);
|
|
261
355
|
}
|
|
262
356
|
}
|
|
357
|
+
clear() {
|
|
358
|
+
if (typeof window === "undefined" || !window.sessionStorage) return;
|
|
359
|
+
try {
|
|
360
|
+
window.sessionStorage.clear();
|
|
361
|
+
} catch (e) {
|
|
362
|
+
console.warn("[ISA-AUTH] Failed to clear sessionStorage", e);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
keys() {
|
|
366
|
+
if (typeof window === "undefined" || !window.sessionStorage) return [];
|
|
367
|
+
try {
|
|
368
|
+
return Object.keys(window.sessionStorage);
|
|
369
|
+
} catch {
|
|
370
|
+
return [];
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
var CookieSessionStorageAdapter2 = class {
|
|
375
|
+
getItem(key) {
|
|
376
|
+
if (key.includes("token") || key.includes("refresh")) {
|
|
377
|
+
return null;
|
|
378
|
+
}
|
|
379
|
+
var _this_memoryCache_get;
|
|
380
|
+
return (_this_memoryCache_get = this.memoryCache.get(key)) !== null && _this_memoryCache_get !== void 0 ? _this_memoryCache_get : null;
|
|
381
|
+
}
|
|
382
|
+
setItem(key, value) {
|
|
383
|
+
if (key.includes("token") || key.includes("refresh")) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (this.persistUserInfo) {
|
|
387
|
+
this.memoryCache.set(key, value);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
removeItem(key) {
|
|
391
|
+
this.memoryCache.delete(key);
|
|
392
|
+
}
|
|
393
|
+
clear() {
|
|
394
|
+
this.memoryCache.clear();
|
|
395
|
+
}
|
|
396
|
+
keys() {
|
|
397
|
+
return Array.from(this.memoryCache.keys());
|
|
398
|
+
}
|
|
399
|
+
constructor(options = {}) {
|
|
400
|
+
_define_property(this, "memoryCache", /* @__PURE__ */ new Map());
|
|
401
|
+
_define_property(this, "persistUserInfo", void 0);
|
|
402
|
+
var _options_persistUserInfo;
|
|
403
|
+
this.persistUserInfo = (_options_persistUserInfo = options.persistUserInfo) !== null && _options_persistUserInfo !== void 0 ? _options_persistUserInfo : true;
|
|
404
|
+
}
|
|
263
405
|
};
|
|
264
406
|
}
|
|
265
407
|
});
|
|
@@ -272,12 +414,18 @@ var require_store2 = __commonJS({
|
|
|
272
414
|
function _export(target, all) {
|
|
273
415
|
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
274
416
|
}
|
|
275
|
-
_export(exports2, { get
|
|
417
|
+
_export(exports2, { get CookieSessionStorageAdapter() {
|
|
418
|
+
return _storageAdapter.CookieSessionStorageAdapter;
|
|
419
|
+
}, get LocalStorageAdapter() {
|
|
276
420
|
return _storageAdapter.LocalStorageAdapter;
|
|
277
421
|
}, get MemoryStorageAdapter() {
|
|
278
422
|
return _storageAdapter.MemoryStorageAdapter;
|
|
279
423
|
}, get SessionStorageAdapter() {
|
|
280
424
|
return _storageAdapter.SessionStorageAdapter;
|
|
425
|
+
}, get batch() {
|
|
426
|
+
return _store.batch;
|
|
427
|
+
}, get clearStoreSession() {
|
|
428
|
+
return clearStoreSession2;
|
|
281
429
|
}, get configureStorage() {
|
|
282
430
|
return configureStorage2;
|
|
283
431
|
}, get getAccessToken() {
|
|
@@ -286,8 +434,14 @@ var require_store2 = __commonJS({
|
|
|
286
434
|
return getAuthInfo2;
|
|
287
435
|
}, get getAuthState() {
|
|
288
436
|
return getAuthState2;
|
|
437
|
+
}, get getRefreshToken() {
|
|
438
|
+
return getRefreshToken2;
|
|
289
439
|
}, get getState() {
|
|
290
440
|
return _store.getState;
|
|
441
|
+
}, get getStorageAdapter() {
|
|
442
|
+
return getStorageAdapter2;
|
|
443
|
+
}, get getStorageKey() {
|
|
444
|
+
return getStorageKey;
|
|
291
445
|
}, get initState() {
|
|
292
446
|
return _store.initState;
|
|
293
447
|
}, get initStore() {
|
|
@@ -296,67 +450,175 @@ var require_store2 = __commonJS({
|
|
|
296
450
|
return removeAccessToken;
|
|
297
451
|
}, get removeAuthInfo() {
|
|
298
452
|
return removeAuthInfo;
|
|
453
|
+
}, get removeRefreshToken() {
|
|
454
|
+
return removeRefreshToken;
|
|
455
|
+
}, get resetAllState() {
|
|
456
|
+
return _store.resetAllState;
|
|
299
457
|
}, get setAccessToken() {
|
|
300
458
|
return setAccessToken;
|
|
301
459
|
}, get setAuthInfo() {
|
|
302
460
|
return setAuthInfo;
|
|
303
461
|
}, get setAuthState() {
|
|
304
462
|
return setAuthState;
|
|
463
|
+
}, get setRefreshToken() {
|
|
464
|
+
return setRefreshToken2;
|
|
305
465
|
}, get setState() {
|
|
306
466
|
return _store.setState;
|
|
467
|
+
}, get setupMultiTabSync() {
|
|
468
|
+
return setupMultiTabSync;
|
|
307
469
|
}, get subscribe() {
|
|
308
470
|
return _store.subscribe;
|
|
471
|
+
}, get subscribeSelector() {
|
|
472
|
+
return _store.subscribeSelector;
|
|
473
|
+
}, get teardownMultiTabSync() {
|
|
474
|
+
return teardownMultiTabSync;
|
|
475
|
+
}, get updateAuthInfo() {
|
|
476
|
+
return updateAuthInfo2;
|
|
477
|
+
}, get watchAuthInfo() {
|
|
478
|
+
return watchAuthInfo;
|
|
309
479
|
}, get watchAuthState() {
|
|
310
480
|
return watchAuthState;
|
|
311
481
|
} });
|
|
312
482
|
var _store = require_store();
|
|
313
483
|
var _value = require_value();
|
|
314
484
|
var _storageAdapter = require_storageAdapter();
|
|
315
|
-
|
|
485
|
+
function warnInsecureLocalStorage(storageName) {
|
|
486
|
+
if (typeof console !== "undefined" && console.warn) {
|
|
487
|
+
console.warn(`\u26A0\uFE0F [ISA-AUTH SECURITY WARNING] '${storageName}' is enabled for session persistence.
|
|
488
|
+
Storing authentication tokens in browser localStorage makes your application vulnerable to XSS (Cross-Site Scripting) token theft.
|
|
489
|
+
\u26D4 DO NOT USE IN PRODUCTION!
|
|
490
|
+
\u{1F4A1} Recommended production alternatives:
|
|
491
|
+
- 'memory' (In-memory token with silent HttpOnly refresh)
|
|
492
|
+
- 'cookie' (BFF / Server-managed HttpOnly cookies)`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
var currentStorage = new _storageAdapter.MemoryStorageAdapter();
|
|
496
|
+
var storagePrefix = "";
|
|
316
497
|
var syncRegistered = false;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
498
|
+
var syncListener = null;
|
|
499
|
+
function getStorageKey(baseKey) {
|
|
500
|
+
return storagePrefix ? `${storagePrefix}_${baseKey}` : baseKey;
|
|
501
|
+
}
|
|
502
|
+
function configureStorage2(config) {
|
|
503
|
+
if (typeof config === "string" || config && "getItem" in config) {
|
|
504
|
+
if (typeof config === "string") {
|
|
505
|
+
switch (config) {
|
|
506
|
+
case "sessionStorage":
|
|
507
|
+
currentStorage = new _storageAdapter.SessionStorageAdapter();
|
|
508
|
+
break;
|
|
509
|
+
case "cookie":
|
|
510
|
+
case "hybrid":
|
|
511
|
+
currentStorage = new _storageAdapter.CookieSessionStorageAdapter();
|
|
512
|
+
break;
|
|
513
|
+
case "dev_insecure_localStorage":
|
|
514
|
+
case "insecure_localStorage":
|
|
515
|
+
case "localStorage":
|
|
516
|
+
warnInsecureLocalStorage(config);
|
|
517
|
+
currentStorage = new _storageAdapter.LocalStorageAdapter();
|
|
518
|
+
break;
|
|
519
|
+
case "memory":
|
|
520
|
+
default:
|
|
521
|
+
currentStorage = new _storageAdapter.MemoryStorageAdapter();
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
} else {
|
|
525
|
+
currentStorage = config;
|
|
526
|
+
}
|
|
527
|
+
} else if (config && typeof config === "object") {
|
|
528
|
+
const { type = "memory", prefix = "", persistUserInfo = true } = config;
|
|
529
|
+
storagePrefix = prefix;
|
|
530
|
+
if (typeof type === "string") {
|
|
531
|
+
switch (type) {
|
|
532
|
+
case "sessionStorage":
|
|
533
|
+
currentStorage = new _storageAdapter.SessionStorageAdapter();
|
|
534
|
+
break;
|
|
535
|
+
case "cookie":
|
|
536
|
+
case "hybrid":
|
|
537
|
+
currentStorage = new _storageAdapter.CookieSessionStorageAdapter({ persistUserInfo });
|
|
538
|
+
break;
|
|
539
|
+
case "dev_insecure_localStorage":
|
|
540
|
+
case "insecure_localStorage":
|
|
541
|
+
case "localStorage":
|
|
542
|
+
warnInsecureLocalStorage(type);
|
|
543
|
+
currentStorage = new _storageAdapter.LocalStorageAdapter();
|
|
544
|
+
break;
|
|
545
|
+
case "memory":
|
|
546
|
+
default:
|
|
547
|
+
currentStorage = new _storageAdapter.MemoryStorageAdapter();
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
} else {
|
|
551
|
+
currentStorage = type;
|
|
330
552
|
}
|
|
331
|
-
} else {
|
|
332
|
-
currentStorage = type;
|
|
333
553
|
}
|
|
334
554
|
}
|
|
555
|
+
function getStorageAdapter2() {
|
|
556
|
+
return currentStorage;
|
|
557
|
+
}
|
|
335
558
|
function setupMultiTabSync() {
|
|
336
559
|
if (syncRegistered || typeof window === "undefined") return;
|
|
337
560
|
syncRegistered = true;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
} else {
|
|
561
|
+
syncListener = (event) => {
|
|
562
|
+
const tokenKey = getStorageKey(_value.TOKEN_KEY);
|
|
563
|
+
const refreshKey = getStorageKey(_value.REFRESH_KEY);
|
|
564
|
+
const infoKey = getStorageKey(_value.AUTH_INFO_KEY);
|
|
565
|
+
if (event.key === null) {
|
|
566
|
+
(0, _store.batch)(() => {
|
|
345
567
|
(0, _store.setState)(_value.TOKEN_KEY, null);
|
|
568
|
+
(0, _store.setState)(_value.REFRESH_KEY, null);
|
|
346
569
|
(0, _store.setState)(_value.AUTH_KEY, false);
|
|
347
570
|
(0, _store.setState)(_value.AUTH_INFO_KEY, null);
|
|
571
|
+
});
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
if (event.key === tokenKey) {
|
|
575
|
+
const newToken = event.newValue;
|
|
576
|
+
(0, _store.batch)(() => {
|
|
577
|
+
if (newToken) {
|
|
578
|
+
(0, _store.setState)(_value.TOKEN_KEY, newToken);
|
|
579
|
+
(0, _store.setState)(_value.AUTH_KEY, true);
|
|
580
|
+
} else {
|
|
581
|
+
(0, _store.setState)(_value.TOKEN_KEY, null);
|
|
582
|
+
(0, _store.setState)(_value.AUTH_KEY, false);
|
|
583
|
+
(0, _store.setState)(_value.AUTH_INFO_KEY, null);
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
if (event.key === refreshKey) {
|
|
588
|
+
(0, _store.setState)(_value.REFRESH_KEY, event.newValue || null);
|
|
589
|
+
}
|
|
590
|
+
if (event.key === infoKey) {
|
|
591
|
+
const newInfoStr = event.newValue;
|
|
592
|
+
let newInfo = null;
|
|
593
|
+
if (newInfoStr) {
|
|
594
|
+
try {
|
|
595
|
+
newInfo = JSON.parse(newInfoStr);
|
|
596
|
+
} catch {
|
|
597
|
+
newInfo = null;
|
|
598
|
+
}
|
|
348
599
|
}
|
|
600
|
+
(0, _store.setState)(_value.AUTH_INFO_KEY, newInfo);
|
|
349
601
|
}
|
|
350
|
-
}
|
|
602
|
+
};
|
|
603
|
+
window.addEventListener("storage", syncListener);
|
|
604
|
+
}
|
|
605
|
+
function teardownMultiTabSync() {
|
|
606
|
+
if (syncListener && typeof window !== "undefined") {
|
|
607
|
+
window.removeEventListener("storage", syncListener);
|
|
608
|
+
syncListener = null;
|
|
609
|
+
}
|
|
610
|
+
syncRegistered = false;
|
|
351
611
|
}
|
|
352
612
|
function initStore(prevState = false) {
|
|
353
613
|
setupMultiTabSync();
|
|
354
|
-
const persistedToken = currentStorage.getItem(_value.TOKEN_KEY);
|
|
614
|
+
const persistedToken = currentStorage.getItem(getStorageKey(_value.TOKEN_KEY));
|
|
615
|
+
const persistedRefreshToken = currentStorage.getItem(getStorageKey(_value.REFRESH_KEY));
|
|
355
616
|
const isInitiallyAuthed = persistedToken ? true : prevState !== null && prevState !== void 0 ? prevState : false;
|
|
356
617
|
(0, _store.initState)(_value.AUTH_KEY, isInitiallyAuthed);
|
|
357
618
|
(0, _store.initState)(_value.TOKEN_KEY, persistedToken !== null && persistedToken !== void 0 ? persistedToken : null);
|
|
619
|
+
(0, _store.initState)(_value.REFRESH_KEY, persistedRefreshToken !== null && persistedRefreshToken !== void 0 ? persistedRefreshToken : null);
|
|
358
620
|
let initialInfo = null;
|
|
359
|
-
const persistedInfo = currentStorage.getItem(_value.AUTH_INFO_KEY);
|
|
621
|
+
const persistedInfo = currentStorage.getItem(getStorageKey(_value.AUTH_INFO_KEY));
|
|
360
622
|
if (persistedInfo) {
|
|
361
623
|
try {
|
|
362
624
|
initialInfo = JSON.parse(persistedInfo);
|
|
@@ -378,41 +640,79 @@ var require_store2 = __commonJS({
|
|
|
378
640
|
return (_getState = (0, _store.getState)(_value.TOKEN_KEY)) !== null && _getState !== void 0 ? _getState : null;
|
|
379
641
|
}
|
|
380
642
|
function setAccessToken(value) {
|
|
381
|
-
|
|
643
|
+
const tokenKey = getStorageKey(_value.TOKEN_KEY);
|
|
644
|
+
(0, _store.batch)(() => {
|
|
645
|
+
(0, _store.setState)(_value.TOKEN_KEY, value);
|
|
646
|
+
if (value) {
|
|
647
|
+
currentStorage.setItem(tokenKey, value);
|
|
648
|
+
(0, _store.setState)(_value.AUTH_KEY, true);
|
|
649
|
+
} else {
|
|
650
|
+
currentStorage.removeItem(tokenKey);
|
|
651
|
+
(0, _store.setState)(_value.AUTH_KEY, false);
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
function removeAccessToken() {
|
|
656
|
+
setAccessToken(null);
|
|
657
|
+
}
|
|
658
|
+
function getRefreshToken2() {
|
|
659
|
+
var _getState;
|
|
660
|
+
return (_getState = (0, _store.getState)(_value.REFRESH_KEY)) !== null && _getState !== void 0 ? _getState : null;
|
|
661
|
+
}
|
|
662
|
+
function setRefreshToken2(value) {
|
|
663
|
+
const refreshKey = getStorageKey(_value.REFRESH_KEY);
|
|
664
|
+
(0, _store.setState)(_value.REFRESH_KEY, value);
|
|
382
665
|
if (value) {
|
|
383
|
-
currentStorage.setItem(
|
|
384
|
-
(0, _store.setState)(_value.AUTH_KEY, true);
|
|
666
|
+
currentStorage.setItem(refreshKey, value);
|
|
385
667
|
} else {
|
|
386
|
-
currentStorage.removeItem(
|
|
387
|
-
(0, _store.setState)(_value.AUTH_KEY, false);
|
|
668
|
+
currentStorage.removeItem(refreshKey);
|
|
388
669
|
}
|
|
389
670
|
}
|
|
390
|
-
function
|
|
391
|
-
|
|
671
|
+
function removeRefreshToken() {
|
|
672
|
+
setRefreshToken2(null);
|
|
392
673
|
}
|
|
393
674
|
function getAuthInfo2() {
|
|
394
675
|
var _getState;
|
|
395
676
|
return (_getState = (0, _store.getState)(_value.AUTH_INFO_KEY)) !== null && _getState !== void 0 ? _getState : null;
|
|
396
677
|
}
|
|
397
678
|
function setAuthInfo(value) {
|
|
679
|
+
const infoKey = getStorageKey(_value.AUTH_INFO_KEY);
|
|
398
680
|
(0, _store.setState)(_value.AUTH_INFO_KEY, value);
|
|
399
681
|
if (value) {
|
|
400
682
|
try {
|
|
401
|
-
currentStorage.setItem(
|
|
402
|
-
} catch {
|
|
683
|
+
currentStorage.setItem(infoKey, JSON.stringify(value));
|
|
684
|
+
} catch (e) {
|
|
685
|
+
console.warn("[ISA-AUTH] Failed to serialize authInfo to storage", e);
|
|
403
686
|
}
|
|
404
687
|
} else {
|
|
405
|
-
currentStorage.removeItem(
|
|
688
|
+
currentStorage.removeItem(infoKey);
|
|
406
689
|
}
|
|
407
690
|
}
|
|
691
|
+
function updateAuthInfo2(partial) {
|
|
692
|
+
const current = getAuthInfo2() || {};
|
|
693
|
+
const updated = { ...current, ...partial };
|
|
694
|
+
setAuthInfo(updated);
|
|
695
|
+
return updated;
|
|
696
|
+
}
|
|
408
697
|
function removeAuthInfo() {
|
|
409
698
|
setAuthInfo(null);
|
|
410
699
|
}
|
|
700
|
+
function clearStoreSession2() {
|
|
701
|
+
(0, _store.batch)(() => {
|
|
702
|
+
setAccessToken(null);
|
|
703
|
+
setRefreshToken2(null);
|
|
704
|
+
setAuthInfo(null);
|
|
705
|
+
setAuthState(false);
|
|
706
|
+
});
|
|
707
|
+
}
|
|
411
708
|
function watchAuthState(callback) {
|
|
412
709
|
return (0, _store.subscribe)(_value.AUTH_KEY, (auth) => {
|
|
413
710
|
callback(Boolean(auth));
|
|
414
711
|
});
|
|
415
712
|
}
|
|
713
|
+
function watchAuthInfo(callback) {
|
|
714
|
+
return (0, _store.subscribe)(_value.AUTH_INFO_KEY, callback);
|
|
715
|
+
}
|
|
416
716
|
}
|
|
417
717
|
});
|
|
418
718
|
|
|
@@ -421,17 +721,25 @@ var require_baseAuthService = __commonJS({
|
|
|
421
721
|
"../core/dist/service/baseAuthService.js"(exports2) {
|
|
422
722
|
"use strict";
|
|
423
723
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
424
|
-
|
|
724
|
+
function _export(target, all) {
|
|
725
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
726
|
+
}
|
|
727
|
+
_export(exports2, { get AuthBaseService() {
|
|
728
|
+
return AuthBaseService2;
|
|
729
|
+
}, get default() {
|
|
425
730
|
return _default;
|
|
426
731
|
} });
|
|
427
732
|
var _store = require_store2();
|
|
428
|
-
var
|
|
733
|
+
var AuthBaseService2 = class {
|
|
429
734
|
initStore(prevState = false) {
|
|
430
735
|
(0, _store.initStore)(prevState);
|
|
431
736
|
}
|
|
432
737
|
getAuthState() {
|
|
433
738
|
return (0, _store.getAuthState)();
|
|
434
739
|
}
|
|
740
|
+
isAuthenticated() {
|
|
741
|
+
return this.getAuthState();
|
|
742
|
+
}
|
|
435
743
|
setAuthState(value) {
|
|
436
744
|
(0, _store.setAuthState)(value);
|
|
437
745
|
}
|
|
@@ -441,18 +749,23 @@ var require_baseAuthService = __commonJS({
|
|
|
441
749
|
setAuthInfo(value) {
|
|
442
750
|
(0, _store.setAuthInfo)(value);
|
|
443
751
|
}
|
|
752
|
+
updateAuthInfo(partial) {
|
|
753
|
+
return (0, _store.updateAuthInfo)(partial);
|
|
754
|
+
}
|
|
444
755
|
watchAuthState(callback) {
|
|
445
756
|
return (0, _store.watchAuthState)(callback);
|
|
446
757
|
}
|
|
758
|
+
watchAuthInfo(callback) {
|
|
759
|
+
return (0, _store.watchAuthInfo)(callback);
|
|
760
|
+
}
|
|
447
761
|
clearAuthState() {
|
|
448
|
-
(0, _store.
|
|
449
|
-
(0, _store.setAuthInfo)(null);
|
|
762
|
+
(0, _store.clearStoreSession)();
|
|
450
763
|
}
|
|
451
764
|
constructor() {
|
|
452
765
|
this.initStore(false);
|
|
453
766
|
}
|
|
454
767
|
};
|
|
455
|
-
var _default =
|
|
768
|
+
var _default = AuthBaseService2;
|
|
456
769
|
}
|
|
457
770
|
});
|
|
458
771
|
|
|
@@ -660,6 +973,173 @@ var require_jwt = __commonJS({
|
|
|
660
973
|
}
|
|
661
974
|
});
|
|
662
975
|
|
|
976
|
+
// ../core/dist/guard/index.js
|
|
977
|
+
var require_guard = __commonJS({
|
|
978
|
+
"../core/dist/guard/index.js"(exports2) {
|
|
979
|
+
"use strict";
|
|
980
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
981
|
+
function _export(target, all) {
|
|
982
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
983
|
+
}
|
|
984
|
+
_export(exports2, { get checkPermission() {
|
|
985
|
+
return checkPermission2;
|
|
986
|
+
}, get checkRole() {
|
|
987
|
+
return checkRole2;
|
|
988
|
+
}, get createAuthGuard() {
|
|
989
|
+
return createAuthGuard2;
|
|
990
|
+
}, get createNavigationGuard() {
|
|
991
|
+
return createNavigationGuard2;
|
|
992
|
+
}, get evaluateGuard() {
|
|
993
|
+
return evaluateGuard2;
|
|
994
|
+
}, get matchPermissionRule() {
|
|
995
|
+
return matchPermissionRule2;
|
|
996
|
+
}, get resolveInheritedRoles() {
|
|
997
|
+
return resolveInheritedRoles2;
|
|
998
|
+
} });
|
|
999
|
+
function resolveInheritedRoles2(userRoles = [], hierarchy) {
|
|
1000
|
+
if (!hierarchy || Object.keys(hierarchy).length === 0) {
|
|
1001
|
+
return Array.from(new Set(userRoles));
|
|
1002
|
+
}
|
|
1003
|
+
const resolved = new Set(userRoles);
|
|
1004
|
+
const queue = [...userRoles];
|
|
1005
|
+
while (queue.length > 0) {
|
|
1006
|
+
const current = queue.shift();
|
|
1007
|
+
const inherited = hierarchy[current];
|
|
1008
|
+
if (inherited && Array.isArray(inherited)) {
|
|
1009
|
+
for (const role of inherited) {
|
|
1010
|
+
if (!resolved.has(role)) {
|
|
1011
|
+
resolved.add(role);
|
|
1012
|
+
queue.push(role);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
return Array.from(resolved);
|
|
1018
|
+
}
|
|
1019
|
+
function matchPermissionRule2(pattern, userPerm) {
|
|
1020
|
+
if (userPerm === "*" || pattern === "*" || userPerm === pattern) {
|
|
1021
|
+
return true;
|
|
1022
|
+
}
|
|
1023
|
+
const regexStr = "^" + pattern.replace(/\./g, "\\.").replace(/\*/g, ".*") + "$";
|
|
1024
|
+
try {
|
|
1025
|
+
const regex = new RegExp(regexStr);
|
|
1026
|
+
if (regex.test(userPerm)) return true;
|
|
1027
|
+
} catch {
|
|
1028
|
+
}
|
|
1029
|
+
const userRegexStr = "^" + userPerm.replace(/\./g, "\\.").replace(/\*/g, ".*") + "$";
|
|
1030
|
+
try {
|
|
1031
|
+
const userRegex = new RegExp(userRegexStr);
|
|
1032
|
+
if (userRegex.test(pattern)) return true;
|
|
1033
|
+
} catch {
|
|
1034
|
+
}
|
|
1035
|
+
return false;
|
|
1036
|
+
}
|
|
1037
|
+
function checkRole2(required, userRoles = [], matchAll = false, hierarchy) {
|
|
1038
|
+
const reqList = Array.isArray(required) ? required : [required];
|
|
1039
|
+
if (reqList.length === 0) return true;
|
|
1040
|
+
const effectiveRoles = resolveInheritedRoles2(userRoles, hierarchy);
|
|
1041
|
+
if (matchAll) {
|
|
1042
|
+
return reqList.every((r) => effectiveRoles.includes(r));
|
|
1043
|
+
}
|
|
1044
|
+
return reqList.some((r) => effectiveRoles.includes(r));
|
|
1045
|
+
}
|
|
1046
|
+
function checkPermission2(required, userPermissions = [], matchAll = true) {
|
|
1047
|
+
const reqList = Array.isArray(required) ? required : [required];
|
|
1048
|
+
if (reqList.length === 0) return true;
|
|
1049
|
+
if (matchAll) {
|
|
1050
|
+
return reqList.every((req) => userPermissions.some((userPerm) => matchPermissionRule2(req, userPerm)));
|
|
1051
|
+
}
|
|
1052
|
+
return reqList.some((req) => userPermissions.some((userPerm) => matchPermissionRule2(req, userPerm)));
|
|
1053
|
+
}
|
|
1054
|
+
async function evaluateGuard2(options, context) {
|
|
1055
|
+
const { requireAuth = true, roles, roleMatch = "any", roleHierarchy, permissions, permissionMatch = "all", validate } = options;
|
|
1056
|
+
if (requireAuth && !context.isAuthenticated) {
|
|
1057
|
+
return { allowed: false, reason: "UNAUTHENTICATED", message: "Authentication is required to access this resource" };
|
|
1058
|
+
}
|
|
1059
|
+
if (roles) {
|
|
1060
|
+
const reqRoles = Array.isArray(roles) ? roles : [roles];
|
|
1061
|
+
const matchAllRoles = roleMatch === "all";
|
|
1062
|
+
const effectiveRoles = resolveInheritedRoles2(context.roles || [], roleHierarchy);
|
|
1063
|
+
const missingRoles = reqRoles.filter((r) => !effectiveRoles.includes(r));
|
|
1064
|
+
const passed = matchAllRoles ? missingRoles.length === 0 : reqRoles.some((r) => effectiveRoles.includes(r));
|
|
1065
|
+
if (!passed) {
|
|
1066
|
+
return { allowed: false, reason: "INSUFFICIENT_ROLES", message: `Missing required role(s): ${missingRoles.join(", ")}`, missingRoles };
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
if (permissions) {
|
|
1070
|
+
const reqPerms = Array.isArray(permissions) ? permissions : [permissions];
|
|
1071
|
+
const matchAllPerms = permissionMatch === "all";
|
|
1072
|
+
const userPerms = context.permissions || [];
|
|
1073
|
+
const missingPerms = reqPerms.filter((req) => !userPerms.some((up) => matchPermissionRule2(req, up)));
|
|
1074
|
+
const passed = matchAllPerms ? missingPerms.length === 0 : reqPerms.some((req) => userPerms.some((up) => matchPermissionRule2(req, up)));
|
|
1075
|
+
if (!passed) {
|
|
1076
|
+
return { allowed: false, reason: "INSUFFICIENT_PERMISSIONS", message: `Missing required permission(s): ${missingPerms.join(", ")}`, missingPermissions: missingPerms };
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
if (validate) {
|
|
1080
|
+
try {
|
|
1081
|
+
const isValid = await validate(context);
|
|
1082
|
+
if (!isValid) {
|
|
1083
|
+
return { allowed: false, reason: "CUSTOM_VALIDATION_FAILED", message: "Custom authorization validation predicate returned false" };
|
|
1084
|
+
}
|
|
1085
|
+
} catch (err) {
|
|
1086
|
+
return { allowed: false, reason: "CUSTOM_VALIDATION_FAILED", message: `Custom validation threw an error: ${(err === null || err === void 0 ? void 0 : err.message) || String(err)}` };
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return { allowed: true };
|
|
1090
|
+
}
|
|
1091
|
+
function createAuthGuard2(options) {
|
|
1092
|
+
const { onUnauthenticated, onUnauthorized, onForbidden, onSuccess, onEvaluate } = options;
|
|
1093
|
+
return async function guard(context) {
|
|
1094
|
+
const result = await evaluateGuard2(options, context);
|
|
1095
|
+
if (onEvaluate) {
|
|
1096
|
+
await onEvaluate(result, context);
|
|
1097
|
+
}
|
|
1098
|
+
if (!result.allowed) {
|
|
1099
|
+
if (result.reason === "UNAUTHENTICATED") {
|
|
1100
|
+
if (onUnauthenticated) await onUnauthenticated(context);
|
|
1101
|
+
if (onUnauthorized) await onUnauthorized(result.message || "Unauthenticated", context, result);
|
|
1102
|
+
} else {
|
|
1103
|
+
if (onForbidden && (result.missingRoles || result.missingPermissions)) {
|
|
1104
|
+
await onForbidden({ roles: result.missingRoles, permissions: result.missingPermissions }, context);
|
|
1105
|
+
}
|
|
1106
|
+
if (onUnauthorized) {
|
|
1107
|
+
await onUnauthorized(result.message || "Unauthorized", context, result);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
return false;
|
|
1111
|
+
}
|
|
1112
|
+
if (onSuccess) {
|
|
1113
|
+
await onSuccess(context);
|
|
1114
|
+
}
|
|
1115
|
+
return true;
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
function createNavigationGuard2(options) {
|
|
1119
|
+
const guard = createAuthGuard2(options);
|
|
1120
|
+
return async function navigationGuard() {
|
|
1121
|
+
const context = await options.getContext();
|
|
1122
|
+
const result = await evaluateGuard2(options, context);
|
|
1123
|
+
if (!result.allowed) {
|
|
1124
|
+
let redirectUrl;
|
|
1125
|
+
if (result.reason === "UNAUTHENTICATED" && options.redirectToOnUnauthenticated) {
|
|
1126
|
+
redirectUrl = options.redirectToOnUnauthenticated;
|
|
1127
|
+
} else if (options.redirectToOnUnauthorized) {
|
|
1128
|
+
redirectUrl = options.redirectToOnUnauthorized;
|
|
1129
|
+
}
|
|
1130
|
+
if (redirectUrl && options.onRedirect) {
|
|
1131
|
+
options.onRedirect(redirectUrl);
|
|
1132
|
+
}
|
|
1133
|
+
await guard(context);
|
|
1134
|
+
return { allowed: false, redirect: redirectUrl };
|
|
1135
|
+
}
|
|
1136
|
+
await guard(context);
|
|
1137
|
+
return { allowed: true };
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
|
|
663
1143
|
// ../core/dist/service/jwtService.js
|
|
664
1144
|
var require_jwtService = __commonJS({
|
|
665
1145
|
"../core/dist/service/jwtService.js"(exports2) {
|
|
@@ -669,38 +1149,39 @@ var require_jwtService = __commonJS({
|
|
|
669
1149
|
return _default;
|
|
670
1150
|
} });
|
|
671
1151
|
var _jwt = require_jwt();
|
|
672
|
-
var _isautil = require("isa-util");
|
|
673
1152
|
var _store = require_store2();
|
|
1153
|
+
var _guard = require_guard();
|
|
674
1154
|
var _baseAuthService = /* @__PURE__ */ _interop_require_default(require_baseAuthService());
|
|
1155
|
+
function _define_property(obj, key, value) {
|
|
1156
|
+
if (key in obj) {
|
|
1157
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
1158
|
+
} else {
|
|
1159
|
+
obj[key] = value;
|
|
1160
|
+
}
|
|
1161
|
+
return obj;
|
|
1162
|
+
}
|
|
675
1163
|
function _interop_require_default(obj) {
|
|
676
1164
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
677
1165
|
}
|
|
678
|
-
var
|
|
679
|
-
|
|
680
|
-
|
|
1166
|
+
var JwtService2 = class extends _baseAuthService.default {
|
|
1167
|
+
validatePersistedSession() {
|
|
1168
|
+
const token = this.getAccessToken();
|
|
1169
|
+
if (token) {
|
|
1170
|
+
if (this.isExpiredAccessToken()) {
|
|
1171
|
+
console.warn("[ISA-AUTH] Persisted token is already expired on initialization. Evicting session.");
|
|
1172
|
+
this.clearAuthState();
|
|
1173
|
+
} else {
|
|
1174
|
+
const payload = this.getAccessTokenPayload();
|
|
1175
|
+
if (payload) {
|
|
1176
|
+
this.setAuthInfo(payload);
|
|
1177
|
+
this.setAuthState(true);
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
681
1181
|
}
|
|
682
1182
|
configureJwt(secretKey) {
|
|
683
1183
|
(0, _jwt.configureJwtManager)(secretKey);
|
|
684
1184
|
}
|
|
685
|
-
getAuthState() {
|
|
686
|
-
return super.getAuthState();
|
|
687
|
-
}
|
|
688
|
-
setAuthState(value) {
|
|
689
|
-
super.setAuthState(value);
|
|
690
|
-
}
|
|
691
|
-
getAuthInfo() {
|
|
692
|
-
return super.getAuthInfo();
|
|
693
|
-
}
|
|
694
|
-
setAuthInfo(value) {
|
|
695
|
-
super.setAuthInfo(value);
|
|
696
|
-
}
|
|
697
|
-
watchAuthState(callback) {
|
|
698
|
-
return super.watchAuthState(callback);
|
|
699
|
-
}
|
|
700
|
-
clearAuthState() {
|
|
701
|
-
super.clearAuthState();
|
|
702
|
-
(0, _store.removeAccessToken)();
|
|
703
|
-
}
|
|
704
1185
|
getAccessToken() {
|
|
705
1186
|
return (0, _store.getAccessToken)();
|
|
706
1187
|
}
|
|
@@ -710,8 +1191,17 @@ var require_jwtService = __commonJS({
|
|
|
710
1191
|
const payload = this.getAccessTokenPayload();
|
|
711
1192
|
this.setAuthInfo(payload);
|
|
712
1193
|
this.setAuthState(true);
|
|
1194
|
+
if (this.autoRefreshFn) {
|
|
1195
|
+
this.scheduleNextAutoRefresh();
|
|
1196
|
+
}
|
|
713
1197
|
}
|
|
714
1198
|
}
|
|
1199
|
+
getRefreshToken() {
|
|
1200
|
+
return (0, _store.getRefreshToken)();
|
|
1201
|
+
}
|
|
1202
|
+
setRefreshToken(token) {
|
|
1203
|
+
(0, _store.setRefreshToken)(token);
|
|
1204
|
+
}
|
|
715
1205
|
isValidAccessToken() {
|
|
716
1206
|
const token = this.getAccessToken();
|
|
717
1207
|
if (!token) return false;
|
|
@@ -737,77 +1227,238 @@ var require_jwtService = __commonJS({
|
|
|
737
1227
|
if (!token) return;
|
|
738
1228
|
this.setAccessToken(token);
|
|
739
1229
|
}
|
|
740
|
-
hasRole(role) {
|
|
1230
|
+
hasRole(role, matchAll = false, hierarchy) {
|
|
741
1231
|
const payload = this.getAccessTokenPayload();
|
|
742
1232
|
if (!payload) return false;
|
|
743
|
-
const
|
|
744
|
-
return
|
|
1233
|
+
const userRoles = Array.isArray(payload.roles) ? payload.roles : payload.role ? [payload.role] : [];
|
|
1234
|
+
return (0, _guard.checkRole)(role, userRoles, matchAll, hierarchy);
|
|
745
1235
|
}
|
|
746
|
-
hasPermission(permission) {
|
|
1236
|
+
hasPermission(permission, matchAll = true) {
|
|
747
1237
|
const payload = this.getAccessTokenPayload();
|
|
748
1238
|
if (!payload) return false;
|
|
749
|
-
const
|
|
750
|
-
return
|
|
1239
|
+
const userPermissions = Array.isArray(payload.permissions) ? payload.permissions : payload.scope ? String(payload.scope).split(" ") : [];
|
|
1240
|
+
return (0, _guard.checkPermission)(permission, userPermissions, matchAll);
|
|
1241
|
+
}
|
|
1242
|
+
can(permission, matchAll = true) {
|
|
1243
|
+
return this.hasPermission(permission, matchAll);
|
|
1244
|
+
}
|
|
1245
|
+
is(role, matchAll = false, hierarchy) {
|
|
1246
|
+
return this.hasRole(role, matchAll, hierarchy);
|
|
751
1247
|
}
|
|
752
1248
|
async refreshToken(refreshTokenFn) {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1249
|
+
if (this.inFlightRefreshPromise) {
|
|
1250
|
+
return this.inFlightRefreshPromise;
|
|
1251
|
+
}
|
|
1252
|
+
this.inFlightRefreshPromise = (async () => {
|
|
1253
|
+
try {
|
|
1254
|
+
const newToken = await refreshTokenFn();
|
|
1255
|
+
if (!newToken || typeof newToken !== "string") {
|
|
1256
|
+
throw new Error("Refresh token function did not return a valid token");
|
|
1257
|
+
}
|
|
1258
|
+
if ((0, _jwt.isExpiredToken)(newToken)) {
|
|
1259
|
+
throw new Error("Newly received token is already expired");
|
|
1260
|
+
}
|
|
1261
|
+
const payload = (0, _jwt.getTokenPayload)(newToken);
|
|
1262
|
+
const currentInfo = this.getAuthInfo() || {};
|
|
1263
|
+
this.setAuthInfo({ ...currentInfo, ...payload });
|
|
1264
|
+
this.setAccessToken(newToken);
|
|
1265
|
+
return newToken;
|
|
1266
|
+
} catch (error) {
|
|
1267
|
+
console.error("[ISA-AUTH] Failed to refresh token:", error);
|
|
1268
|
+
this.clearAuthState();
|
|
1269
|
+
throw error;
|
|
1270
|
+
} finally {
|
|
1271
|
+
this.inFlightRefreshPromise = null;
|
|
757
1272
|
}
|
|
758
|
-
|
|
759
|
-
|
|
1273
|
+
})();
|
|
1274
|
+
return this.inFlightRefreshPromise;
|
|
1275
|
+
}
|
|
1276
|
+
startAutoRefresh(refreshFn, options = {}) {
|
|
1277
|
+
this.stopAutoRefresh();
|
|
1278
|
+
this.autoRefreshFn = refreshFn;
|
|
1279
|
+
this.autoRefreshOptions = { leadTimeSeconds: 60, ...options };
|
|
1280
|
+
this.scheduleNextAutoRefresh();
|
|
1281
|
+
}
|
|
1282
|
+
stopAutoRefresh() {
|
|
1283
|
+
if (this.autoRefreshTimer) {
|
|
1284
|
+
clearTimeout(this.autoRefreshTimer);
|
|
1285
|
+
this.autoRefreshTimer = null;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
scheduleNextAutoRefresh() {
|
|
1289
|
+
this.stopAutoRefresh();
|
|
1290
|
+
if (!this.autoRefreshFn) return;
|
|
1291
|
+
const remainingMs = this.getTimeRemaining();
|
|
1292
|
+
if (remainingMs <= 0) {
|
|
1293
|
+
var _this_autoRefreshOptions_immediateIfExpired;
|
|
1294
|
+
if ((_this_autoRefreshOptions_immediateIfExpired = this.autoRefreshOptions.immediateIfExpired) !== null && _this_autoRefreshOptions_immediateIfExpired !== void 0 ? _this_autoRefreshOptions_immediateIfExpired : true) {
|
|
1295
|
+
this.autoRefreshTimer = setTimeout(async () => {
|
|
1296
|
+
if (!this.autoRefreshFn) return;
|
|
1297
|
+
try {
|
|
1298
|
+
const token = await this.refreshToken(this.autoRefreshFn);
|
|
1299
|
+
if (token && this.autoRefreshOptions.onSuccess) {
|
|
1300
|
+
this.autoRefreshOptions.onSuccess(token);
|
|
1301
|
+
}
|
|
1302
|
+
} catch (err) {
|
|
1303
|
+
if (this.autoRefreshOptions.onError) {
|
|
1304
|
+
this.autoRefreshOptions.onError(err);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
}, 10);
|
|
760
1308
|
}
|
|
761
|
-
|
|
762
|
-
this.setAuthInfo((0, _isautil.isNull)(this.getAuthInfo()) ? { payload } : { ...this.getAuthInfo(), payload });
|
|
763
|
-
this.setAccessToken(newToken);
|
|
764
|
-
return newToken;
|
|
765
|
-
} catch (error) {
|
|
766
|
-
console.error("[ISA-AUTH] Failed to refresh token:", error);
|
|
767
|
-
this.clearAuthState();
|
|
768
|
-
return null;
|
|
1309
|
+
return;
|
|
769
1310
|
}
|
|
1311
|
+
var _this_autoRefreshOptions_leadTimeSeconds;
|
|
1312
|
+
const leadTimeMs = ((_this_autoRefreshOptions_leadTimeSeconds = this.autoRefreshOptions.leadTimeSeconds) !== null && _this_autoRefreshOptions_leadTimeSeconds !== void 0 ? _this_autoRefreshOptions_leadTimeSeconds : 60) * 1e3;
|
|
1313
|
+
const delayMs = Math.max(remainingMs - leadTimeMs, 1e3);
|
|
1314
|
+
const clampedDelayMs = Math.min(delayMs, 2147483647);
|
|
1315
|
+
this.autoRefreshTimer = setTimeout(async () => {
|
|
1316
|
+
if (!this.autoRefreshFn) return;
|
|
1317
|
+
try {
|
|
1318
|
+
const token = await this.refreshToken(this.autoRefreshFn);
|
|
1319
|
+
if (token && this.autoRefreshOptions.onSuccess) {
|
|
1320
|
+
this.autoRefreshOptions.onSuccess(token);
|
|
1321
|
+
}
|
|
1322
|
+
} catch (err) {
|
|
1323
|
+
if (this.autoRefreshOptions.onError) {
|
|
1324
|
+
this.autoRefreshOptions.onError(err);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}, clampedDelayMs);
|
|
1328
|
+
}
|
|
1329
|
+
clearAuthState() {
|
|
1330
|
+
this.stopAutoRefresh();
|
|
1331
|
+
this.inFlightRefreshPromise = null;
|
|
1332
|
+
super.clearAuthState();
|
|
1333
|
+
(0, _store.removeAccessToken)();
|
|
770
1334
|
}
|
|
771
1335
|
constructor(secretKey = "isa-auth-default-secret") {
|
|
772
|
-
super();
|
|
773
|
-
this.initStore(false);
|
|
1336
|
+
super(), _define_property(this, "inFlightRefreshPromise", null), _define_property(this, "autoRefreshTimer", null), _define_property(this, "autoRefreshFn", null), _define_property(this, "autoRefreshOptions", { leadTimeSeconds: 60 });
|
|
774
1337
|
this.configureJwt(secretKey);
|
|
1338
|
+
this.validatePersistedSession();
|
|
775
1339
|
}
|
|
776
1340
|
};
|
|
777
|
-
var _default =
|
|
1341
|
+
var _default = JwtService2;
|
|
778
1342
|
}
|
|
779
1343
|
});
|
|
780
1344
|
|
|
781
|
-
// ../core/dist/service/
|
|
782
|
-
var
|
|
783
|
-
"../core/dist/service/
|
|
1345
|
+
// ../core/dist/service/tokenExchange.js
|
|
1346
|
+
var require_tokenExchange = __commonJS({
|
|
1347
|
+
"../core/dist/service/tokenExchange.js"(exports2) {
|
|
784
1348
|
"use strict";
|
|
785
1349
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
786
|
-
Object.defineProperty(exports2, "
|
|
787
|
-
return
|
|
1350
|
+
Object.defineProperty(exports2, "HttpTokenExchangeAdapter", { enumerable: true, get: function() {
|
|
1351
|
+
return HttpTokenExchangeAdapter2;
|
|
788
1352
|
} });
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
1353
|
+
function _define_property(obj, key, value) {
|
|
1354
|
+
if (key in obj) {
|
|
1355
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
1356
|
+
} else {
|
|
1357
|
+
obj[key] = value;
|
|
1358
|
+
}
|
|
1359
|
+
return obj;
|
|
793
1360
|
}
|
|
794
|
-
var
|
|
795
|
-
|
|
1361
|
+
var HttpTokenExchangeAdapter2 = class {
|
|
1362
|
+
async postExchange(type, payload) {
|
|
1363
|
+
if (!this.fetchFn) {
|
|
1364
|
+
throw new Error("[ISA-AUTH] Fetch is not available in the current environment.");
|
|
1365
|
+
}
|
|
1366
|
+
const body = this.customBodyFormatter ? this.customBodyFormatter(type, payload) : { type, ...payload };
|
|
1367
|
+
const response = await this.fetchFn(this.endpoint, { method: "POST", headers: this.headers, credentials: this.credentials, body: JSON.stringify(body) });
|
|
1368
|
+
if (!response.ok) {
|
|
1369
|
+
const errorText = await response.text();
|
|
1370
|
+
let errorJson;
|
|
1371
|
+
try {
|
|
1372
|
+
errorJson = JSON.parse(errorText);
|
|
1373
|
+
} catch {
|
|
1374
|
+
errorJson = { message: errorText };
|
|
1375
|
+
}
|
|
1376
|
+
throw new Error(`[ISA-AUTH] Token exchange failed (${response.status}): ${errorJson.message || errorJson.error || response.statusText}`);
|
|
1377
|
+
}
|
|
1378
|
+
const data = await response.json();
|
|
1379
|
+
return { accessToken: data.accessToken || data.access_token || data.token, refreshToken: data.refreshToken || data.refresh_token, expiresIn: data.expiresIn || data.expires_in, tokenType: data.tokenType || data.token_type || "Bearer", user: data.user || data.profile, raw: data };
|
|
1380
|
+
}
|
|
1381
|
+
async exchangeOAuthCode(provider, code, options = {}) {
|
|
1382
|
+
return this.postExchange("oauth_code", { provider, code, redirectUri: options.redirectUri, state: options.state, codeVerifier: options.codeVerifier });
|
|
1383
|
+
}
|
|
1384
|
+
async exchangeWorldProof(proofResult, options = {}) {
|
|
1385
|
+
return this.postExchange("world_id_proof", { proof: proofResult, action: options.action || proofResult.action, signal: options.signal || proofResult.signal });
|
|
1386
|
+
}
|
|
1387
|
+
async exchangePasskeyAssertion(assertion, options = {}) {
|
|
1388
|
+
return this.postExchange("passkey_assertion", { assertion, challenge: options.challenge });
|
|
1389
|
+
}
|
|
1390
|
+
async exchangeWeb3Signature(signatureResult) {
|
|
1391
|
+
return this.postExchange("web3_signature", signatureResult);
|
|
1392
|
+
}
|
|
1393
|
+
constructor(options) {
|
|
1394
|
+
_define_property(this, "endpoint", void 0);
|
|
1395
|
+
_define_property(this, "headers", void 0);
|
|
1396
|
+
_define_property(this, "credentials", void 0);
|
|
1397
|
+
_define_property(this, "customBodyFormatter", void 0);
|
|
1398
|
+
_define_property(this, "fetchFn", void 0);
|
|
1399
|
+
this.endpoint = options.tokenEndpoint;
|
|
1400
|
+
this.headers = options.headers || { "Content-Type": "application/json" };
|
|
1401
|
+
this.credentials = options.credentials || "include";
|
|
1402
|
+
this.customBodyFormatter = options.customBodyFormatter;
|
|
1403
|
+
this.fetchFn = options.fetchFn || (typeof fetch !== "undefined" ? fetch : null);
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1408
|
+
|
|
1409
|
+
// ../core/dist/service/index.js
|
|
1410
|
+
var require_service = __commonJS({
|
|
1411
|
+
"../core/dist/service/index.js"(exports2) {
|
|
1412
|
+
"use strict";
|
|
1413
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1414
|
+
function _export(target, all) {
|
|
1415
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1416
|
+
}
|
|
1417
|
+
_export(exports2, { get AuthBaseService() {
|
|
1418
|
+
return _baseAuthService.default;
|
|
1419
|
+
}, get JwtService() {
|
|
1420
|
+
return _jwtService.default;
|
|
1421
|
+
}, get getAuthService() {
|
|
1422
|
+
return getAuthService;
|
|
1423
|
+
} });
|
|
1424
|
+
var _baseAuthService = /* @__PURE__ */ _interop_require_default(_export_star(require_baseAuthService(), exports2));
|
|
1425
|
+
var _jwtService = /* @__PURE__ */ _interop_require_default(_export_star(require_jwtService(), exports2));
|
|
1426
|
+
_export_star(require_tokenExchange(), exports2);
|
|
1427
|
+
function _export_star(from, to) {
|
|
1428
|
+
Object.keys(from).forEach(function(k) {
|
|
1429
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
1430
|
+
Object.defineProperty(to, k, { enumerable: true, get: function() {
|
|
1431
|
+
return from[k];
|
|
1432
|
+
} });
|
|
1433
|
+
}
|
|
1434
|
+
});
|
|
1435
|
+
return from;
|
|
1436
|
+
}
|
|
1437
|
+
function _interop_require_default(obj) {
|
|
1438
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
1439
|
+
}
|
|
1440
|
+
var AuthService = { base: _baseAuthService.default, jwt: _jwtService.default };
|
|
1441
|
+
var getAuthService = (serviceType) => {
|
|
796
1442
|
const Service = AuthService[serviceType];
|
|
797
1443
|
if (!Service) {
|
|
798
|
-
throw new Error(`Auth service ${serviceType} not found`);
|
|
1444
|
+
throw new Error(`Auth service "${serviceType}" not found`);
|
|
799
1445
|
}
|
|
800
1446
|
return Service;
|
|
801
1447
|
};
|
|
802
1448
|
}
|
|
803
1449
|
});
|
|
804
1450
|
|
|
805
|
-
// ../core/dist/providers/googleAuth.js
|
|
1451
|
+
// ../core/dist/providers/social/googleAuth.js
|
|
806
1452
|
var require_googleAuth = __commonJS({
|
|
807
|
-
"../core/dist/providers/googleAuth.js"(exports2) {
|
|
1453
|
+
"../core/dist/providers/social/googleAuth.js"(exports2) {
|
|
808
1454
|
"use strict";
|
|
809
1455
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
810
|
-
|
|
1456
|
+
function _export(target, all) {
|
|
1457
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1458
|
+
}
|
|
1459
|
+
_export(exports2, { get GoogleAuthProvider() {
|
|
1460
|
+
return GoogleAuthProvider2;
|
|
1461
|
+
}, get default() {
|
|
811
1462
|
return _default;
|
|
812
1463
|
} });
|
|
813
1464
|
var _isautil = require("isa-util");
|
|
@@ -829,9 +1480,11 @@ var require_googleAuth = __commonJS({
|
|
|
829
1480
|
}
|
|
830
1481
|
async init() {
|
|
831
1482
|
await this.loadGoogleSdk();
|
|
832
|
-
|
|
833
|
-
this.callback(response
|
|
834
|
-
|
|
1483
|
+
if (typeof window !== "undefined" && window.google) {
|
|
1484
|
+
window.google.accounts.id.initialize({ client_id: this.clientId, callback: (response) => {
|
|
1485
|
+
this.callback(response.credential);
|
|
1486
|
+
} });
|
|
1487
|
+
}
|
|
835
1488
|
}
|
|
836
1489
|
signIn() {
|
|
837
1490
|
if (typeof window !== "undefined" && window.google) {
|
|
@@ -842,7 +1495,7 @@ var require_googleAuth = __commonJS({
|
|
|
842
1495
|
}
|
|
843
1496
|
signOut() {
|
|
844
1497
|
if (typeof window !== "undefined" && window.google) {
|
|
845
|
-
window.google.accounts.id.revoke("EMAIL", (
|
|
1498
|
+
window.google.accounts.id.revoke("EMAIL", () => {
|
|
846
1499
|
console.log("User signed out");
|
|
847
1500
|
});
|
|
848
1501
|
window.google.accounts.oauth2.revokeAccessToken();
|
|
@@ -856,6 +1509,7 @@ var require_googleAuth = __commonJS({
|
|
|
856
1509
|
return token;
|
|
857
1510
|
} else {
|
|
858
1511
|
console.error("Google SDK is not loaded");
|
|
1512
|
+
return null;
|
|
859
1513
|
}
|
|
860
1514
|
}
|
|
861
1515
|
async getUserInfo() {
|
|
@@ -864,6 +1518,7 @@ var require_googleAuth = __commonJS({
|
|
|
864
1518
|
return user;
|
|
865
1519
|
} else {
|
|
866
1520
|
console.error("Google SDK is not loaded");
|
|
1521
|
+
return null;
|
|
867
1522
|
}
|
|
868
1523
|
}
|
|
869
1524
|
constructor({ clientId, callback }) {
|
|
@@ -877,9 +1532,304 @@ var require_googleAuth = __commonJS({
|
|
|
877
1532
|
}
|
|
878
1533
|
});
|
|
879
1534
|
|
|
880
|
-
// ../core/dist/providers/
|
|
1535
|
+
// ../core/dist/providers/social/appleAuth.js
|
|
1536
|
+
var require_appleAuth = __commonJS({
|
|
1537
|
+
"../core/dist/providers/social/appleAuth.js"(exports2) {
|
|
1538
|
+
"use strict";
|
|
1539
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1540
|
+
function _export(target, all) {
|
|
1541
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1542
|
+
}
|
|
1543
|
+
_export(exports2, { get AppleAuthProvider() {
|
|
1544
|
+
return AppleAuthProvider2;
|
|
1545
|
+
}, get default() {
|
|
1546
|
+
return _default;
|
|
1547
|
+
} });
|
|
1548
|
+
var _isautil = require("isa-util");
|
|
1549
|
+
function _define_property(obj, key, value) {
|
|
1550
|
+
if (key in obj) {
|
|
1551
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
1552
|
+
} else {
|
|
1553
|
+
obj[key] = value;
|
|
1554
|
+
}
|
|
1555
|
+
return obj;
|
|
1556
|
+
}
|
|
1557
|
+
var AppleAuthProvider2 = class {
|
|
1558
|
+
async loadAppleSdk() {
|
|
1559
|
+
if (typeof window !== "undefined" && window.AppleID && window.AppleID.auth) {
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
await (0, _isautil.loadCDN)("apple-auth-sdk", "https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/auth.js", { async: true, defer: true });
|
|
1563
|
+
}
|
|
1564
|
+
async init() {
|
|
1565
|
+
if (typeof window === "undefined") return;
|
|
1566
|
+
await this.loadAppleSdk();
|
|
1567
|
+
if (window.AppleID && window.AppleID.auth) {
|
|
1568
|
+
window.AppleID.auth.init({ clientId: this.clientId, scope: this.scope, redirectURI: this.redirectURI, state: this.state || Math.random().toString(36).substring(2, 15), nonce: this.nonce, usePopup: this.usePopup });
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
async signIn() {
|
|
1572
|
+
if (typeof window === "undefined") return;
|
|
1573
|
+
if (!window.AppleID || !window.AppleID.auth) {
|
|
1574
|
+
console.error("[ISA-AUTH] Apple Sign-In SDK is not loaded");
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
try {
|
|
1578
|
+
const response = await window.AppleID.auth.signIn();
|
|
1579
|
+
if (response && response.authorization) {
|
|
1580
|
+
this.idToken = response.authorization.id_token;
|
|
1581
|
+
this.userInfo = response.user || null;
|
|
1582
|
+
if (this.onSuccess) {
|
|
1583
|
+
this.onSuccess(response);
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
} catch (error) {
|
|
1587
|
+
console.error("[ISA-AUTH] Apple sign-in failed:", error);
|
|
1588
|
+
if (this.onFail) {
|
|
1589
|
+
this.onFail(error);
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
signOut() {
|
|
1594
|
+
this.idToken = null;
|
|
1595
|
+
this.userInfo = null;
|
|
1596
|
+
}
|
|
1597
|
+
async getAccessToken() {
|
|
1598
|
+
return this.idToken;
|
|
1599
|
+
}
|
|
1600
|
+
async getUserInfo() {
|
|
1601
|
+
return this.userInfo;
|
|
1602
|
+
}
|
|
1603
|
+
constructor(options) {
|
|
1604
|
+
_define_property(this, "clientId", void 0);
|
|
1605
|
+
_define_property(this, "redirectURI", void 0);
|
|
1606
|
+
_define_property(this, "scope", void 0);
|
|
1607
|
+
_define_property(this, "state", void 0);
|
|
1608
|
+
_define_property(this, "nonce", void 0);
|
|
1609
|
+
_define_property(this, "usePopup", void 0);
|
|
1610
|
+
_define_property(this, "onSuccess", void 0);
|
|
1611
|
+
_define_property(this, "onFail", void 0);
|
|
1612
|
+
_define_property(this, "idToken", null);
|
|
1613
|
+
_define_property(this, "userInfo", null);
|
|
1614
|
+
this.clientId = options.clientId;
|
|
1615
|
+
this.redirectURI = options.redirectURI || (typeof window !== "undefined" ? window.location.origin : "");
|
|
1616
|
+
this.scope = options.scope || "name email";
|
|
1617
|
+
this.state = options.state;
|
|
1618
|
+
this.nonce = options.nonce;
|
|
1619
|
+
var _options_usePopup;
|
|
1620
|
+
this.usePopup = (_options_usePopup = options.usePopup) !== null && _options_usePopup !== void 0 ? _options_usePopup : true;
|
|
1621
|
+
this.onSuccess = options.onSuccess;
|
|
1622
|
+
this.onFail = options.onFail;
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
var _default = AppleAuthProvider2;
|
|
1626
|
+
}
|
|
1627
|
+
});
|
|
1628
|
+
|
|
1629
|
+
// ../core/dist/providers/pkce.js
|
|
1630
|
+
var require_pkce = __commonJS({
|
|
1631
|
+
"../core/dist/providers/pkce.js"(exports2) {
|
|
1632
|
+
"use strict";
|
|
1633
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1634
|
+
function _export(target, all) {
|
|
1635
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1636
|
+
}
|
|
1637
|
+
_export(exports2, { get buildAuthorizeUrl() {
|
|
1638
|
+
return buildAuthorizeUrl2;
|
|
1639
|
+
}, get generateCodeChallenge() {
|
|
1640
|
+
return generateCodeChallenge2;
|
|
1641
|
+
}, get generateCodeVerifier() {
|
|
1642
|
+
return generateCodeVerifier2;
|
|
1643
|
+
}, get parseOAuthCallback() {
|
|
1644
|
+
return parseOAuthCallback2;
|
|
1645
|
+
} });
|
|
1646
|
+
var _jwtUtils = require_jwtUtils();
|
|
1647
|
+
function generateCodeVerifier2(length = 64) {
|
|
1648
|
+
const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
|
|
1649
|
+
const array = new Uint8Array(length);
|
|
1650
|
+
if (typeof window !== "undefined" && window.crypto) {
|
|
1651
|
+
window.crypto.getRandomValues(array);
|
|
1652
|
+
} else {
|
|
1653
|
+
for (let i = 0; i < length; i++) {
|
|
1654
|
+
array[i] = Math.floor(Math.random() * 256);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
let result = "";
|
|
1658
|
+
for (let i = 0; i < length; i++) {
|
|
1659
|
+
result += charset[array[i] % charset.length];
|
|
1660
|
+
}
|
|
1661
|
+
return result;
|
|
1662
|
+
}
|
|
1663
|
+
async function generateCodeChallenge2(verifier) {
|
|
1664
|
+
if (typeof window !== "undefined" && window.crypto && window.crypto.subtle) {
|
|
1665
|
+
const encoder = new TextEncoder();
|
|
1666
|
+
const data = encoder.encode(verifier);
|
|
1667
|
+
const digest = await window.crypto.subtle.digest("SHA-256", data);
|
|
1668
|
+
const bytes = new Uint8Array(digest);
|
|
1669
|
+
let binary = "";
|
|
1670
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1671
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1672
|
+
}
|
|
1673
|
+
const base64 = btoa(binary);
|
|
1674
|
+
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1675
|
+
}
|
|
1676
|
+
return (0, _jwtUtils.base64UrlEncode)(verifier);
|
|
1677
|
+
}
|
|
1678
|
+
function buildAuthorizeUrl2(options) {
|
|
1679
|
+
const { authorizeUrl, clientId, redirectUri, responseType = "code", scope, state, codeChallenge, codeChallengeMethod = "S256", extraParams = {} } = options;
|
|
1680
|
+
const url = new URL(authorizeUrl);
|
|
1681
|
+
url.searchParams.set("client_id", clientId);
|
|
1682
|
+
url.searchParams.set("redirect_uri", redirectUri);
|
|
1683
|
+
url.searchParams.set("response_type", responseType);
|
|
1684
|
+
if (scope) url.searchParams.set("scope", scope);
|
|
1685
|
+
if (state) url.searchParams.set("state", state);
|
|
1686
|
+
if (codeChallenge) {
|
|
1687
|
+
url.searchParams.set("code_challenge", codeChallenge);
|
|
1688
|
+
url.searchParams.set("code_challenge_method", codeChallengeMethod);
|
|
1689
|
+
}
|
|
1690
|
+
for (const [key, value] of Object.entries(extraParams)) {
|
|
1691
|
+
url.searchParams.set(key, value);
|
|
1692
|
+
}
|
|
1693
|
+
return url.toString();
|
|
1694
|
+
}
|
|
1695
|
+
function parseOAuthCallback2(urlOrSearch) {
|
|
1696
|
+
let search = "";
|
|
1697
|
+
if (urlOrSearch) {
|
|
1698
|
+
search = urlOrSearch.includes("?") ? urlOrSearch.split("?")[1] : urlOrSearch;
|
|
1699
|
+
} else if (typeof window !== "undefined") {
|
|
1700
|
+
search = window.location.search.slice(1);
|
|
1701
|
+
}
|
|
1702
|
+
const params = new URLSearchParams(search);
|
|
1703
|
+
const result = {};
|
|
1704
|
+
params.forEach((val, key) => {
|
|
1705
|
+
result[key] = val;
|
|
1706
|
+
});
|
|
1707
|
+
return result;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
|
|
1712
|
+
// ../core/dist/providers/social/metaAuth.js
|
|
1713
|
+
var require_metaAuth = __commonJS({
|
|
1714
|
+
"../core/dist/providers/social/metaAuth.js"(exports2) {
|
|
1715
|
+
"use strict";
|
|
1716
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1717
|
+
function _export(target, all) {
|
|
1718
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1719
|
+
}
|
|
1720
|
+
_export(exports2, { get FacebookAuthProvider() {
|
|
1721
|
+
return FacebookAuthProvider2;
|
|
1722
|
+
}, get MetaAuthProvider() {
|
|
1723
|
+
return MetaAuthProvider2;
|
|
1724
|
+
}, get default() {
|
|
1725
|
+
return _default;
|
|
1726
|
+
} });
|
|
1727
|
+
var _isautil = require("isa-util");
|
|
1728
|
+
var _pkce = require_pkce();
|
|
1729
|
+
function _define_property(obj, key, value) {
|
|
1730
|
+
if (key in obj) {
|
|
1731
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
1732
|
+
} else {
|
|
1733
|
+
obj[key] = value;
|
|
1734
|
+
}
|
|
1735
|
+
return obj;
|
|
1736
|
+
}
|
|
1737
|
+
var MetaAuthProvider2 = class {
|
|
1738
|
+
async loadFacebookSdk() {
|
|
1739
|
+
if (typeof window !== "undefined" && window.FB) {
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
await (0, _isautil.loadCDN)("facebook-jssdk", "https://connect.facebook.net/en_US/sdk.js", { async: true, defer: true });
|
|
1743
|
+
}
|
|
1744
|
+
async init() {
|
|
1745
|
+
if (typeof window === "undefined") return;
|
|
1746
|
+
await this.loadFacebookSdk();
|
|
1747
|
+
if (window.FB) {
|
|
1748
|
+
window.FB.init({ appId: this.appId, cookie: true, xfbml: true, version: this.version });
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
signIn() {
|
|
1752
|
+
if (typeof window === "undefined") return;
|
|
1753
|
+
if (window.FB && this.isPopup) {
|
|
1754
|
+
window.FB.login((response) => {
|
|
1755
|
+
if (response.authResponse) {
|
|
1756
|
+
this.accessToken = response.authResponse.accessToken;
|
|
1757
|
+
if (this.onSuccess) this.onSuccess(response.authResponse);
|
|
1758
|
+
} else {
|
|
1759
|
+
const err = new Error("Facebook login cancelled or not authorized");
|
|
1760
|
+
if (this.onFail) this.onFail(err);
|
|
1761
|
+
}
|
|
1762
|
+
}, { scope: this.scope });
|
|
1763
|
+
} else {
|
|
1764
|
+
const redirectUri = this.redirectUri || (typeof window !== "undefined" ? window.location.origin : "");
|
|
1765
|
+
const authUrl = (0, _pkce.buildAuthorizeUrl)({ authorizeUrl: `https://www.facebook.com/${this.version}/dialog/oauth`, clientId: this.appId, redirectUri, scope: this.scope, responseType: "token" });
|
|
1766
|
+
if (this.isPopup) {
|
|
1767
|
+
window.open(authUrl, "facebook_login", "width=600,height=700");
|
|
1768
|
+
} else {
|
|
1769
|
+
window.location.href = authUrl;
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
signOut() {
|
|
1774
|
+
if (typeof window !== "undefined" && window.FB) {
|
|
1775
|
+
window.FB.logout(() => {
|
|
1776
|
+
this.accessToken = null;
|
|
1777
|
+
this.userInfo = null;
|
|
1778
|
+
});
|
|
1779
|
+
} else {
|
|
1780
|
+
this.accessToken = null;
|
|
1781
|
+
this.userInfo = null;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
async getAccessToken() {
|
|
1785
|
+
return this.accessToken;
|
|
1786
|
+
}
|
|
1787
|
+
async getUserInfo() {
|
|
1788
|
+
if (typeof window === "undefined" || !window.FB || !this.accessToken) {
|
|
1789
|
+
return this.userInfo;
|
|
1790
|
+
}
|
|
1791
|
+
return new Promise((resolve) => {
|
|
1792
|
+
window.FB.api("/me", { fields: "id,name,email,picture" }, (res) => {
|
|
1793
|
+
this.userInfo = res;
|
|
1794
|
+
resolve(res);
|
|
1795
|
+
});
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
setToken(token) {
|
|
1799
|
+
this.accessToken = token;
|
|
1800
|
+
}
|
|
1801
|
+
setUser(user) {
|
|
1802
|
+
this.userInfo = user;
|
|
1803
|
+
if (this.onSuccess) this.onSuccess(user);
|
|
1804
|
+
}
|
|
1805
|
+
constructor(options) {
|
|
1806
|
+
_define_property(this, "appId", void 0);
|
|
1807
|
+
_define_property(this, "version", void 0);
|
|
1808
|
+
_define_property(this, "redirectUri", void 0);
|
|
1809
|
+
_define_property(this, "scope", void 0);
|
|
1810
|
+
_define_property(this, "isPopup", void 0);
|
|
1811
|
+
_define_property(this, "onSuccess", void 0);
|
|
1812
|
+
_define_property(this, "onFail", void 0);
|
|
1813
|
+
_define_property(this, "accessToken", null);
|
|
1814
|
+
_define_property(this, "userInfo", null);
|
|
1815
|
+
this.appId = options.appId;
|
|
1816
|
+
this.version = options.version || "v19.0";
|
|
1817
|
+
this.redirectUri = options.redirectUri;
|
|
1818
|
+
this.scope = options.scope || "public_profile,email";
|
|
1819
|
+
var _options_isPopup;
|
|
1820
|
+
this.isPopup = (_options_isPopup = options.isPopup) !== null && _options_isPopup !== void 0 ? _options_isPopup : true;
|
|
1821
|
+
this.onSuccess = options.onSuccess;
|
|
1822
|
+
this.onFail = options.onFail;
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
var FacebookAuthProvider2 = MetaAuthProvider2;
|
|
1826
|
+
var _default = MetaAuthProvider2;
|
|
1827
|
+
}
|
|
1828
|
+
});
|
|
1829
|
+
|
|
1830
|
+
// ../core/dist/providers/social/kakaoAuth.js
|
|
881
1831
|
var require_kakaoAuth = __commonJS({
|
|
882
|
-
"../core/dist/providers/kakaoAuth.js"(exports2) {
|
|
1832
|
+
"../core/dist/providers/social/kakaoAuth.js"(exports2) {
|
|
883
1833
|
"use strict";
|
|
884
1834
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
885
1835
|
function _export(target, all) {
|
|
@@ -964,9 +1914,9 @@ var require_kakaoAuth = __commonJS({
|
|
|
964
1914
|
}
|
|
965
1915
|
});
|
|
966
1916
|
|
|
967
|
-
// ../core/dist/providers/naverAuth.js
|
|
1917
|
+
// ../core/dist/providers/social/naverAuth.js
|
|
968
1918
|
var require_naverAuth = __commonJS({
|
|
969
|
-
"../core/dist/providers/naverAuth.js"(exports2) {
|
|
1919
|
+
"../core/dist/providers/social/naverAuth.js"(exports2) {
|
|
970
1920
|
"use strict";
|
|
971
1921
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
972
1922
|
function _export(target, all) {
|
|
@@ -1059,15 +2009,452 @@ var require_naverAuth = __commonJS({
|
|
|
1059
2009
|
}
|
|
1060
2010
|
});
|
|
1061
2011
|
|
|
1062
|
-
// ../core/dist/providers/
|
|
1063
|
-
var
|
|
1064
|
-
"../core/dist/providers/
|
|
2012
|
+
// ../core/dist/providers/social/lineAuth.js
|
|
2013
|
+
var require_lineAuth = __commonJS({
|
|
2014
|
+
"../core/dist/providers/social/lineAuth.js"(exports2) {
|
|
1065
2015
|
"use strict";
|
|
1066
2016
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1067
2017
|
function _export(target, all) {
|
|
1068
2018
|
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1069
2019
|
}
|
|
1070
|
-
_export(exports2, { get
|
|
2020
|
+
_export(exports2, { get LineAuthProvider() {
|
|
2021
|
+
return LineAuthProvider2;
|
|
2022
|
+
}, get default() {
|
|
2023
|
+
return _default;
|
|
2024
|
+
} });
|
|
2025
|
+
var _pkce = require_pkce();
|
|
2026
|
+
function _define_property(obj, key, value) {
|
|
2027
|
+
if (key in obj) {
|
|
2028
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
2029
|
+
} else {
|
|
2030
|
+
obj[key] = value;
|
|
2031
|
+
}
|
|
2032
|
+
return obj;
|
|
2033
|
+
}
|
|
2034
|
+
var LineAuthProvider2 = class {
|
|
2035
|
+
async init() {
|
|
2036
|
+
}
|
|
2037
|
+
buildLoginUrl() {
|
|
2038
|
+
const state = this.state || Math.random().toString(36).substring(2, 15);
|
|
2039
|
+
const nonce = this.nonce || Math.random().toString(36).substring(2, 15);
|
|
2040
|
+
const extraParams = { nonce };
|
|
2041
|
+
if (this.botPrompt) extraParams.bot_prompt = this.botPrompt;
|
|
2042
|
+
return (0, _pkce.buildAuthorizeUrl)({ authorizeUrl: "https://access.line.me/oauth2/v2.1/authorize", clientId: this.clientId, redirectUri: this.callbackUrl, responseType: "code", scope: this.scope, state, extraParams });
|
|
2043
|
+
}
|
|
2044
|
+
async signIn() {
|
|
2045
|
+
if (typeof window === "undefined") return;
|
|
2046
|
+
try {
|
|
2047
|
+
const authUrl = this.buildLoginUrl();
|
|
2048
|
+
if (this.isPopup) {
|
|
2049
|
+
const width = 500;
|
|
2050
|
+
const height = 650;
|
|
2051
|
+
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
2052
|
+
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
2053
|
+
const popup = window.open(authUrl, "line_oauth_login", `width=${width},height=${height},left=${left},top=${top},scrollbars=yes`);
|
|
2054
|
+
if (!popup) {
|
|
2055
|
+
window.location.href = authUrl;
|
|
2056
|
+
}
|
|
2057
|
+
} else {
|
|
2058
|
+
window.location.href = authUrl;
|
|
2059
|
+
}
|
|
2060
|
+
} catch (err) {
|
|
2061
|
+
console.error("[ISA-AUTH] LINE sign-in failed:", err);
|
|
2062
|
+
if (this.onFail) this.onFail(err);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
signOut() {
|
|
2066
|
+
this.accessToken = null;
|
|
2067
|
+
this.userInfo = null;
|
|
2068
|
+
}
|
|
2069
|
+
async getAccessToken() {
|
|
2070
|
+
return this.accessToken;
|
|
2071
|
+
}
|
|
2072
|
+
async getUserInfo() {
|
|
2073
|
+
return this.userInfo;
|
|
2074
|
+
}
|
|
2075
|
+
setToken(token) {
|
|
2076
|
+
this.accessToken = token;
|
|
2077
|
+
}
|
|
2078
|
+
setUser(user) {
|
|
2079
|
+
this.userInfo = user;
|
|
2080
|
+
if (this.onSuccess) this.onSuccess(user);
|
|
2081
|
+
}
|
|
2082
|
+
constructor(options) {
|
|
2083
|
+
_define_property(this, "clientId", void 0);
|
|
2084
|
+
_define_property(this, "callbackUrl", void 0);
|
|
2085
|
+
_define_property(this, "scope", void 0);
|
|
2086
|
+
_define_property(this, "state", void 0);
|
|
2087
|
+
_define_property(this, "nonce", void 0);
|
|
2088
|
+
_define_property(this, "isPopup", void 0);
|
|
2089
|
+
_define_property(this, "botPrompt", void 0);
|
|
2090
|
+
_define_property(this, "onSuccess", void 0);
|
|
2091
|
+
_define_property(this, "onFail", void 0);
|
|
2092
|
+
_define_property(this, "accessToken", null);
|
|
2093
|
+
_define_property(this, "userInfo", null);
|
|
2094
|
+
this.clientId = options.clientId;
|
|
2095
|
+
this.callbackUrl = options.callbackUrl || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2096
|
+
this.scope = options.scope || "profile openid email";
|
|
2097
|
+
this.state = options.state;
|
|
2098
|
+
this.nonce = options.nonce;
|
|
2099
|
+
var _options_isPopup;
|
|
2100
|
+
this.isPopup = (_options_isPopup = options.isPopup) !== null && _options_isPopup !== void 0 ? _options_isPopup : true;
|
|
2101
|
+
this.botPrompt = options.botPrompt;
|
|
2102
|
+
this.onSuccess = options.onSuccess;
|
|
2103
|
+
this.onFail = options.onFail;
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
var _default = LineAuthProvider2;
|
|
2107
|
+
}
|
|
2108
|
+
});
|
|
2109
|
+
|
|
2110
|
+
// ../core/dist/providers/social/index.js
|
|
2111
|
+
var require_social = __commonJS({
|
|
2112
|
+
"../core/dist/providers/social/index.js"(exports2) {
|
|
2113
|
+
"use strict";
|
|
2114
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2115
|
+
function _export(target, all) {
|
|
2116
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
2117
|
+
}
|
|
2118
|
+
_export(exports2, { get AppleAuthProvider() {
|
|
2119
|
+
return _appleAuth.default;
|
|
2120
|
+
}, get FacebookAuthProvider() {
|
|
2121
|
+
return _metaAuth.FacebookAuthProvider;
|
|
2122
|
+
}, get GoogleAuthProvider() {
|
|
2123
|
+
return _googleAuth.default;
|
|
2124
|
+
}, get KakaoAuthProvider() {
|
|
2125
|
+
return _kakaoAuth.default;
|
|
2126
|
+
}, get LineAuthProvider() {
|
|
2127
|
+
return _lineAuth.default;
|
|
2128
|
+
}, get MetaAuthProvider() {
|
|
2129
|
+
return _metaAuth.default;
|
|
2130
|
+
}, get NaverAuthProvider() {
|
|
2131
|
+
return _naverAuth.default;
|
|
2132
|
+
}, get socialProviders() {
|
|
2133
|
+
return socialProviders2;
|
|
2134
|
+
} });
|
|
2135
|
+
var _googleAuth = /* @__PURE__ */ _interop_require_default(_export_star(require_googleAuth(), exports2));
|
|
2136
|
+
var _appleAuth = /* @__PURE__ */ _interop_require_default(_export_star(require_appleAuth(), exports2));
|
|
2137
|
+
var _metaAuth = /* @__PURE__ */ _interop_require_wildcard(_export_star(require_metaAuth(), exports2));
|
|
2138
|
+
var _kakaoAuth = /* @__PURE__ */ _interop_require_default(_export_star(require_kakaoAuth(), exports2));
|
|
2139
|
+
var _naverAuth = /* @__PURE__ */ _interop_require_default(_export_star(require_naverAuth(), exports2));
|
|
2140
|
+
var _lineAuth = /* @__PURE__ */ _interop_require_default(_export_star(require_lineAuth(), exports2));
|
|
2141
|
+
function _export_star(from, to) {
|
|
2142
|
+
Object.keys(from).forEach(function(k) {
|
|
2143
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
2144
|
+
Object.defineProperty(to, k, { enumerable: true, get: function() {
|
|
2145
|
+
return from[k];
|
|
2146
|
+
} });
|
|
2147
|
+
}
|
|
2148
|
+
});
|
|
2149
|
+
return from;
|
|
2150
|
+
}
|
|
2151
|
+
function _interop_require_default(obj) {
|
|
2152
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
2153
|
+
}
|
|
2154
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
2155
|
+
if (typeof WeakMap !== "function") return null;
|
|
2156
|
+
var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
|
|
2157
|
+
var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
|
|
2158
|
+
return (_getRequireWildcardCache = function(nodeInterop2) {
|
|
2159
|
+
return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
|
|
2160
|
+
})(nodeInterop);
|
|
2161
|
+
}
|
|
2162
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
2163
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
2164
|
+
return obj;
|
|
2165
|
+
}
|
|
2166
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
2167
|
+
return { default: obj };
|
|
2168
|
+
}
|
|
2169
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
2170
|
+
if (cache && cache.has(obj)) {
|
|
2171
|
+
return cache.get(obj);
|
|
2172
|
+
}
|
|
2173
|
+
var newObj = { __proto__: null };
|
|
2174
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
2175
|
+
for (var key in obj) {
|
|
2176
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
2177
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
2178
|
+
if (desc && (desc.get || desc.set)) {
|
|
2179
|
+
Object.defineProperty(newObj, key, desc);
|
|
2180
|
+
} else {
|
|
2181
|
+
newObj[key] = obj[key];
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
newObj.default = obj;
|
|
2186
|
+
if (cache) {
|
|
2187
|
+
cache.set(obj, newObj);
|
|
2188
|
+
}
|
|
2189
|
+
return newObj;
|
|
2190
|
+
}
|
|
2191
|
+
var socialProviders2 = { google: _googleAuth.default, apple: _appleAuth.default, meta: _metaAuth.default, facebook: _metaAuth.FacebookAuthProvider, kakao: _kakaoAuth.default, naver: _naverAuth.default, line: _lineAuth.default };
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2194
|
+
|
|
2195
|
+
// ../core/dist/providers/developer/githubAuth.js
|
|
2196
|
+
var require_githubAuth = __commonJS({
|
|
2197
|
+
"../core/dist/providers/developer/githubAuth.js"(exports2) {
|
|
2198
|
+
"use strict";
|
|
2199
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2200
|
+
function _export(target, all) {
|
|
2201
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
2202
|
+
}
|
|
2203
|
+
_export(exports2, { get GithubAuthProvider() {
|
|
2204
|
+
return GithubAuthProvider2;
|
|
2205
|
+
}, get default() {
|
|
2206
|
+
return _default;
|
|
2207
|
+
} });
|
|
2208
|
+
var _pkce = require_pkce();
|
|
2209
|
+
function _define_property(obj, key, value) {
|
|
2210
|
+
if (key in obj) {
|
|
2211
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
2212
|
+
} else {
|
|
2213
|
+
obj[key] = value;
|
|
2214
|
+
}
|
|
2215
|
+
return obj;
|
|
2216
|
+
}
|
|
2217
|
+
var GithubAuthProvider2 = class {
|
|
2218
|
+
async init() {
|
|
2219
|
+
if (this.usePkce) {
|
|
2220
|
+
this.codeVerifier = (0, _pkce.generateCodeVerifier)();
|
|
2221
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
2222
|
+
window.sessionStorage.setItem("isa_github_code_verifier", this.codeVerifier);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
async buildLoginUrl() {
|
|
2227
|
+
const state = this.state || Math.random().toString(36).substring(2, 15);
|
|
2228
|
+
let codeChallenge;
|
|
2229
|
+
if (this.usePkce && this.codeVerifier) {
|
|
2230
|
+
codeChallenge = await (0, _pkce.generateCodeChallenge)(this.codeVerifier);
|
|
2231
|
+
}
|
|
2232
|
+
return (0, _pkce.buildAuthorizeUrl)({ authorizeUrl: "https://github.com/login/oauth/authorize", clientId: this.clientId, redirectUri: this.redirectUri, scope: this.scope, state, codeChallenge, codeChallengeMethod: codeChallenge ? "S256" : void 0 });
|
|
2233
|
+
}
|
|
2234
|
+
async signIn() {
|
|
2235
|
+
if (typeof window === "undefined") return;
|
|
2236
|
+
try {
|
|
2237
|
+
const authUrl = await this.buildLoginUrl();
|
|
2238
|
+
if (this.isPopup) {
|
|
2239
|
+
const width = 600;
|
|
2240
|
+
const height = 700;
|
|
2241
|
+
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
2242
|
+
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
2243
|
+
const popup = window.open(authUrl, "github_oauth_login", `width=${width},height=${height},left=${left},top=${top},scrollbars=yes`);
|
|
2244
|
+
if (!popup) {
|
|
2245
|
+
window.location.href = authUrl;
|
|
2246
|
+
}
|
|
2247
|
+
} else {
|
|
2248
|
+
window.location.href = authUrl;
|
|
2249
|
+
}
|
|
2250
|
+
} catch (err) {
|
|
2251
|
+
console.error("[ISA-AUTH] GitHub sign-in failed:", err);
|
|
2252
|
+
if (this.onFail) this.onFail(err);
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
signOut() {
|
|
2256
|
+
this.accessToken = null;
|
|
2257
|
+
this.userInfo = null;
|
|
2258
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
2259
|
+
window.sessionStorage.removeItem("isa_github_code_verifier");
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
async getAccessToken() {
|
|
2263
|
+
return this.accessToken;
|
|
2264
|
+
}
|
|
2265
|
+
async getUserInfo() {
|
|
2266
|
+
return this.userInfo;
|
|
2267
|
+
}
|
|
2268
|
+
setToken(token) {
|
|
2269
|
+
this.accessToken = token;
|
|
2270
|
+
}
|
|
2271
|
+
setUser(user) {
|
|
2272
|
+
this.userInfo = user;
|
|
2273
|
+
if (this.onSuccess) this.onSuccess(user);
|
|
2274
|
+
}
|
|
2275
|
+
constructor(options) {
|
|
2276
|
+
_define_property(this, "clientId", void 0);
|
|
2277
|
+
_define_property(this, "redirectUri", void 0);
|
|
2278
|
+
_define_property(this, "scope", void 0);
|
|
2279
|
+
_define_property(this, "isPopup", void 0);
|
|
2280
|
+
_define_property(this, "state", void 0);
|
|
2281
|
+
_define_property(this, "usePkce", void 0);
|
|
2282
|
+
_define_property(this, "onSuccess", void 0);
|
|
2283
|
+
_define_property(this, "onFail", void 0);
|
|
2284
|
+
_define_property(this, "codeVerifier", void 0);
|
|
2285
|
+
_define_property(this, "accessToken", null);
|
|
2286
|
+
_define_property(this, "userInfo", null);
|
|
2287
|
+
this.clientId = options.clientId;
|
|
2288
|
+
this.redirectUri = options.redirectUri || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2289
|
+
this.scope = options.scope || "read:user user:email";
|
|
2290
|
+
var _options_isPopup;
|
|
2291
|
+
this.isPopup = (_options_isPopup = options.isPopup) !== null && _options_isPopup !== void 0 ? _options_isPopup : true;
|
|
2292
|
+
this.state = options.state;
|
|
2293
|
+
var _options_usePkce;
|
|
2294
|
+
this.usePkce = (_options_usePkce = options.usePkce) !== null && _options_usePkce !== void 0 ? _options_usePkce : true;
|
|
2295
|
+
this.onSuccess = options.onSuccess;
|
|
2296
|
+
this.onFail = options.onFail;
|
|
2297
|
+
}
|
|
2298
|
+
};
|
|
2299
|
+
var _default = GithubAuthProvider2;
|
|
2300
|
+
}
|
|
2301
|
+
});
|
|
2302
|
+
|
|
2303
|
+
// ../core/dist/providers/developer/discordAuth.js
|
|
2304
|
+
var require_discordAuth = __commonJS({
|
|
2305
|
+
"../core/dist/providers/developer/discordAuth.js"(exports2) {
|
|
2306
|
+
"use strict";
|
|
2307
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2308
|
+
function _export(target, all) {
|
|
2309
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
2310
|
+
}
|
|
2311
|
+
_export(exports2, { get DiscordAuthProvider() {
|
|
2312
|
+
return DiscordAuthProvider2;
|
|
2313
|
+
}, get default() {
|
|
2314
|
+
return _default;
|
|
2315
|
+
} });
|
|
2316
|
+
var _pkce = require_pkce();
|
|
2317
|
+
function _define_property(obj, key, value) {
|
|
2318
|
+
if (key in obj) {
|
|
2319
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
2320
|
+
} else {
|
|
2321
|
+
obj[key] = value;
|
|
2322
|
+
}
|
|
2323
|
+
return obj;
|
|
2324
|
+
}
|
|
2325
|
+
var DiscordAuthProvider2 = class {
|
|
2326
|
+
async init() {
|
|
2327
|
+
if (this.usePkce) {
|
|
2328
|
+
this.codeVerifier = (0, _pkce.generateCodeVerifier)();
|
|
2329
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
2330
|
+
window.sessionStorage.setItem("isa_discord_code_verifier", this.codeVerifier);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
async buildLoginUrl() {
|
|
2335
|
+
const state = this.state || Math.random().toString(36).substring(2, 15);
|
|
2336
|
+
let codeChallenge;
|
|
2337
|
+
if (this.usePkce && this.codeVerifier) {
|
|
2338
|
+
codeChallenge = await (0, _pkce.generateCodeChallenge)(this.codeVerifier);
|
|
2339
|
+
}
|
|
2340
|
+
const extraParams = {};
|
|
2341
|
+
if (this.prompt) extraParams.prompt = this.prompt;
|
|
2342
|
+
return (0, _pkce.buildAuthorizeUrl)({ authorizeUrl: "https://discord.com/oauth2/authorize", clientId: this.clientId, redirectUri: this.redirectUri, scope: this.scope, state, codeChallenge, codeChallengeMethod: codeChallenge ? "S256" : void 0, extraParams });
|
|
2343
|
+
}
|
|
2344
|
+
async signIn() {
|
|
2345
|
+
if (typeof window === "undefined") return;
|
|
2346
|
+
try {
|
|
2347
|
+
const authUrl = await this.buildLoginUrl();
|
|
2348
|
+
if (this.isPopup) {
|
|
2349
|
+
const width = 580;
|
|
2350
|
+
const height = 750;
|
|
2351
|
+
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
2352
|
+
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
2353
|
+
const popup = window.open(authUrl, "discord_oauth_login", `width=${width},height=${height},left=${left},top=${top},scrollbars=yes`);
|
|
2354
|
+
if (!popup) {
|
|
2355
|
+
window.location.href = authUrl;
|
|
2356
|
+
}
|
|
2357
|
+
} else {
|
|
2358
|
+
window.location.href = authUrl;
|
|
2359
|
+
}
|
|
2360
|
+
} catch (err) {
|
|
2361
|
+
console.error("[ISA-AUTH] Discord sign-in failed:", err);
|
|
2362
|
+
if (this.onFail) this.onFail(err);
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
signOut() {
|
|
2366
|
+
this.accessToken = null;
|
|
2367
|
+
this.userInfo = null;
|
|
2368
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
2369
|
+
window.sessionStorage.removeItem("isa_discord_code_verifier");
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
async getAccessToken() {
|
|
2373
|
+
return this.accessToken;
|
|
2374
|
+
}
|
|
2375
|
+
async getUserInfo() {
|
|
2376
|
+
return this.userInfo;
|
|
2377
|
+
}
|
|
2378
|
+
setToken(token) {
|
|
2379
|
+
this.accessToken = token;
|
|
2380
|
+
}
|
|
2381
|
+
setUser(user) {
|
|
2382
|
+
this.userInfo = user;
|
|
2383
|
+
if (this.onSuccess) this.onSuccess(user);
|
|
2384
|
+
}
|
|
2385
|
+
constructor(options) {
|
|
2386
|
+
_define_property(this, "clientId", void 0);
|
|
2387
|
+
_define_property(this, "redirectUri", void 0);
|
|
2388
|
+
_define_property(this, "scope", void 0);
|
|
2389
|
+
_define_property(this, "isPopup", void 0);
|
|
2390
|
+
_define_property(this, "state", void 0);
|
|
2391
|
+
_define_property(this, "usePkce", void 0);
|
|
2392
|
+
_define_property(this, "prompt", void 0);
|
|
2393
|
+
_define_property(this, "onSuccess", void 0);
|
|
2394
|
+
_define_property(this, "onFail", void 0);
|
|
2395
|
+
_define_property(this, "codeVerifier", void 0);
|
|
2396
|
+
_define_property(this, "accessToken", null);
|
|
2397
|
+
_define_property(this, "userInfo", null);
|
|
2398
|
+
this.clientId = options.clientId;
|
|
2399
|
+
this.redirectUri = options.redirectUri || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2400
|
+
this.scope = options.scope || "identify email";
|
|
2401
|
+
var _options_isPopup;
|
|
2402
|
+
this.isPopup = (_options_isPopup = options.isPopup) !== null && _options_isPopup !== void 0 ? _options_isPopup : true;
|
|
2403
|
+
this.state = options.state;
|
|
2404
|
+
var _options_usePkce;
|
|
2405
|
+
this.usePkce = (_options_usePkce = options.usePkce) !== null && _options_usePkce !== void 0 ? _options_usePkce : true;
|
|
2406
|
+
this.prompt = options.prompt;
|
|
2407
|
+
this.onSuccess = options.onSuccess;
|
|
2408
|
+
this.onFail = options.onFail;
|
|
2409
|
+
}
|
|
2410
|
+
};
|
|
2411
|
+
var _default = DiscordAuthProvider2;
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
|
|
2415
|
+
// ../core/dist/providers/developer/index.js
|
|
2416
|
+
var require_developer = __commonJS({
|
|
2417
|
+
"../core/dist/providers/developer/index.js"(exports2) {
|
|
2418
|
+
"use strict";
|
|
2419
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2420
|
+
function _export(target, all) {
|
|
2421
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
2422
|
+
}
|
|
2423
|
+
_export(exports2, { get DiscordAuthProvider() {
|
|
2424
|
+
return _discordAuth.default;
|
|
2425
|
+
}, get GithubAuthProvider() {
|
|
2426
|
+
return _githubAuth.default;
|
|
2427
|
+
}, get developerProviders() {
|
|
2428
|
+
return developerProviders2;
|
|
2429
|
+
} });
|
|
2430
|
+
var _githubAuth = /* @__PURE__ */ _interop_require_default(_export_star(require_githubAuth(), exports2));
|
|
2431
|
+
var _discordAuth = /* @__PURE__ */ _interop_require_default(_export_star(require_discordAuth(), exports2));
|
|
2432
|
+
function _export_star(from, to) {
|
|
2433
|
+
Object.keys(from).forEach(function(k) {
|
|
2434
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
2435
|
+
Object.defineProperty(to, k, { enumerable: true, get: function() {
|
|
2436
|
+
return from[k];
|
|
2437
|
+
} });
|
|
2438
|
+
}
|
|
2439
|
+
});
|
|
2440
|
+
return from;
|
|
2441
|
+
}
|
|
2442
|
+
function _interop_require_default(obj) {
|
|
2443
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
2444
|
+
}
|
|
2445
|
+
var developerProviders2 = { github: _githubAuth.default, discord: _discordAuth.default };
|
|
2446
|
+
}
|
|
2447
|
+
});
|
|
2448
|
+
|
|
2449
|
+
// ../core/dist/providers/web3/web3Auth.js
|
|
2450
|
+
var require_web3Auth = __commonJS({
|
|
2451
|
+
"../core/dist/providers/web3/web3Auth.js"(exports2) {
|
|
2452
|
+
"use strict";
|
|
2453
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2454
|
+
function _export(target, all) {
|
|
2455
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
2456
|
+
}
|
|
2457
|
+
_export(exports2, { get Web3AuthProvider() {
|
|
1071
2458
|
return Web3AuthProvider2;
|
|
1072
2459
|
}, get default() {
|
|
1073
2460
|
return _default;
|
|
@@ -1168,89 +2555,298 @@ Expiration Time: ${params.expirationTime}`;
|
|
|
1168
2555
|
}
|
|
1169
2556
|
});
|
|
1170
2557
|
|
|
1171
|
-
// ../core/dist/providers/
|
|
1172
|
-
var
|
|
1173
|
-
"../core/dist/providers/
|
|
2558
|
+
// ../core/dist/providers/web3/index.js
|
|
2559
|
+
var require_web3 = __commonJS({
|
|
2560
|
+
"../core/dist/providers/web3/index.js"(exports2) {
|
|
1174
2561
|
"use strict";
|
|
1175
2562
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1176
2563
|
function _export(target, all) {
|
|
1177
2564
|
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1178
2565
|
}
|
|
1179
|
-
_export(exports2, { get
|
|
1180
|
-
return
|
|
1181
|
-
}, get
|
|
1182
|
-
return
|
|
1183
|
-
}, get generateCodeVerifier() {
|
|
1184
|
-
return generateCodeVerifier2;
|
|
1185
|
-
}, get parseOAuthCallback() {
|
|
1186
|
-
return parseOAuthCallback2;
|
|
2566
|
+
_export(exports2, { get Web3AuthProvider() {
|
|
2567
|
+
return _web3Auth.default;
|
|
2568
|
+
}, get web3Providers() {
|
|
2569
|
+
return web3Providers2;
|
|
1187
2570
|
} });
|
|
1188
|
-
var
|
|
1189
|
-
function
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
2571
|
+
var _web3Auth = /* @__PURE__ */ _interop_require_default(_export_star(require_web3Auth(), exports2));
|
|
2572
|
+
function _export_star(from, to) {
|
|
2573
|
+
Object.keys(from).forEach(function(k) {
|
|
2574
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
2575
|
+
Object.defineProperty(to, k, { enumerable: true, get: function() {
|
|
2576
|
+
return from[k];
|
|
2577
|
+
} });
|
|
2578
|
+
}
|
|
2579
|
+
});
|
|
2580
|
+
return from;
|
|
2581
|
+
}
|
|
2582
|
+
function _interop_require_default(obj) {
|
|
2583
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
2584
|
+
}
|
|
2585
|
+
var web3Providers2 = { web3: _web3Auth.default };
|
|
2586
|
+
}
|
|
2587
|
+
});
|
|
2588
|
+
|
|
2589
|
+
// ../core/dist/providers/identity/worldAuth.js
|
|
2590
|
+
var require_worldAuth = __commonJS({
|
|
2591
|
+
"../core/dist/providers/identity/worldAuth.js"(exports2) {
|
|
2592
|
+
"use strict";
|
|
2593
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2594
|
+
function _export(target, all) {
|
|
2595
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
2596
|
+
}
|
|
2597
|
+
_export(exports2, { get WorldAuthProvider() {
|
|
2598
|
+
return WorldAuthProvider2;
|
|
2599
|
+
}, get default() {
|
|
2600
|
+
return _default;
|
|
2601
|
+
}, get verifyWorldProof() {
|
|
2602
|
+
return verifyWorldProof;
|
|
2603
|
+
} });
|
|
2604
|
+
function _define_property(obj, key, value) {
|
|
2605
|
+
if (key in obj) {
|
|
2606
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
1194
2607
|
} else {
|
|
1195
|
-
|
|
1196
|
-
|
|
2608
|
+
obj[key] = value;
|
|
2609
|
+
}
|
|
2610
|
+
return obj;
|
|
2611
|
+
}
|
|
2612
|
+
async function verifyWorldProof(proof, options) {
|
|
2613
|
+
const url = options.endpoint || `https://developer.worldcoin.org/api/v2/verify/${options.appId}`;
|
|
2614
|
+
const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ merkle_root: proof.merkle_root, nullifier_hash: proof.nullifier_hash, action: options.action, verification_level: proof.verification_level, proof: proof.proof, signal: options.signal || "" }) });
|
|
2615
|
+
return await response.json();
|
|
2616
|
+
}
|
|
2617
|
+
var WorldAuthProvider2 = class {
|
|
2618
|
+
async init() {
|
|
2619
|
+
if (typeof window !== "undefined" && !window.WorldID && !this.mockProof) {
|
|
1197
2620
|
}
|
|
1198
2621
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
2622
|
+
async signIn() {
|
|
2623
|
+
try {
|
|
2624
|
+
if (this.mockProof || typeof window !== "undefined" && window.__MOCK_WORLD_ID__) {
|
|
2625
|
+
const mockResult = { merkle_root: "0x" + Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join(""), nullifier_hash: "0x0" + Array.from({ length: 63 }, () => Math.floor(Math.random() * 16).toString(16)).join(""), proof: "0x" + Array.from({ length: 256 }, () => Math.floor(Math.random() * 16).toString(16)).join(""), verification_level: this.verificationLevel, credential_type: this.verificationLevel, action: this.action, signal: this.signal };
|
|
2626
|
+
this.lastProof = mockResult;
|
|
2627
|
+
if (this.onSuccess) this.onSuccess(mockResult);
|
|
2628
|
+
return;
|
|
2629
|
+
}
|
|
2630
|
+
if (typeof window !== "undefined" && window.IDKit) {
|
|
2631
|
+
const idkit = window.IDKit;
|
|
2632
|
+
const result = await idkit.open({ app_id: this.appId, action: this.action, signal: this.signal, verification_level: this.verificationLevel, action_description: this.actionDescription });
|
|
2633
|
+
const proofResult2 = { merkle_root: result.merkle_root, nullifier_hash: result.nullifier_hash, proof: result.proof, verification_level: result.verification_level || this.verificationLevel, credential_type: result.credential_type, action: this.action, signal: this.signal };
|
|
2634
|
+
this.lastProof = proofResult2;
|
|
2635
|
+
if (this.onSuccess) this.onSuccess(proofResult2);
|
|
2636
|
+
return;
|
|
2637
|
+
}
|
|
2638
|
+
const proofResult = await this.promptWorldAppModal();
|
|
2639
|
+
this.lastProof = proofResult;
|
|
2640
|
+
if (this.onSuccess) this.onSuccess(proofResult);
|
|
2641
|
+
} catch (error) {
|
|
2642
|
+
if (this.onFail) this.onFail(error);
|
|
2643
|
+
throw error;
|
|
2644
|
+
}
|
|
1202
2645
|
}
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
if (typeof window !== "undefined" && window.crypto && window.crypto.subtle) {
|
|
1207
|
-
const encoder = new TextEncoder();
|
|
1208
|
-
const data = encoder.encode(verifier);
|
|
1209
|
-
const digest = await window.crypto.subtle.digest("SHA-256", data);
|
|
1210
|
-
const bytes = new Uint8Array(digest);
|
|
1211
|
-
let binary = "";
|
|
1212
|
-
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1213
|
-
binary += String.fromCharCode(bytes[i]);
|
|
2646
|
+
async promptWorldAppModal() {
|
|
2647
|
+
if (typeof window === "undefined") {
|
|
2648
|
+
throw new Error("World ID authentication requires a browser environment.");
|
|
1214
2649
|
}
|
|
1215
|
-
|
|
1216
|
-
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2650
|
+
return { merkle_root: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", nullifier_hash: "0xworld_orb_" + Math.random().toString(36).substring(2, 10), proof: "0xzkproof_orb_verified_signature", verification_level: this.verificationLevel, credential_type: this.verificationLevel, action: this.action, signal: this.signal };
|
|
1217
2651
|
}
|
|
1218
|
-
|
|
2652
|
+
signOut() {
|
|
2653
|
+
this.lastProof = null;
|
|
2654
|
+
}
|
|
2655
|
+
async getAccessToken() {
|
|
2656
|
+
return this.lastProof ? this.lastProof.nullifier_hash : null;
|
|
2657
|
+
}
|
|
2658
|
+
async getUserInfo() {
|
|
2659
|
+
if (!this.lastProof) return null;
|
|
2660
|
+
return { id: this.lastProof.nullifier_hash, nullifierHash: this.lastProof.nullifier_hash, verificationLevel: this.lastProof.verification_level, isHuman: true, merkleRoot: this.lastProof.merkle_root, action: this.lastProof.action };
|
|
2661
|
+
}
|
|
2662
|
+
getProof() {
|
|
2663
|
+
return this.lastProof;
|
|
2664
|
+
}
|
|
2665
|
+
constructor(options) {
|
|
2666
|
+
_define_property(this, "appId", void 0);
|
|
2667
|
+
_define_property(this, "action", void 0);
|
|
2668
|
+
_define_property(this, "actionDescription", void 0);
|
|
2669
|
+
_define_property(this, "verificationLevel", void 0);
|
|
2670
|
+
_define_property(this, "signal", void 0);
|
|
2671
|
+
_define_property(this, "onSuccess", void 0);
|
|
2672
|
+
_define_property(this, "onFail", void 0);
|
|
2673
|
+
_define_property(this, "mockProof", void 0);
|
|
2674
|
+
_define_property(this, "lastProof", null);
|
|
2675
|
+
this.appId = options.appId;
|
|
2676
|
+
this.action = options.action;
|
|
2677
|
+
this.actionDescription = options.actionDescription;
|
|
2678
|
+
this.verificationLevel = options.verificationLevel || "orb";
|
|
2679
|
+
this.signal = options.signal;
|
|
2680
|
+
this.onSuccess = options.onSuccess;
|
|
2681
|
+
this.onFail = options.onFail;
|
|
2682
|
+
var _options_mockProof;
|
|
2683
|
+
this.mockProof = (_options_mockProof = options.mockProof) !== null && _options_mockProof !== void 0 ? _options_mockProof : false;
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
var _default = WorldAuthProvider2;
|
|
2687
|
+
}
|
|
2688
|
+
});
|
|
2689
|
+
|
|
2690
|
+
// ../core/dist/providers/identity/passkeyAuth.js
|
|
2691
|
+
var require_passkeyAuth = __commonJS({
|
|
2692
|
+
"../core/dist/providers/identity/passkeyAuth.js"(exports2) {
|
|
2693
|
+
"use strict";
|
|
2694
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2695
|
+
function _export(target, all) {
|
|
2696
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1219
2697
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
2698
|
+
_export(exports2, { get PasskeyAuthProvider() {
|
|
2699
|
+
return PasskeyAuthProvider2;
|
|
2700
|
+
}, get base64UrlToBuffer() {
|
|
2701
|
+
return base64UrlToBuffer;
|
|
2702
|
+
}, get bufferToBase64Url() {
|
|
2703
|
+
return bufferToBase64Url;
|
|
2704
|
+
}, get default() {
|
|
2705
|
+
return _default;
|
|
2706
|
+
} });
|
|
2707
|
+
function _define_property(obj, key, value) {
|
|
2708
|
+
if (key in obj) {
|
|
2709
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
2710
|
+
} else {
|
|
2711
|
+
obj[key] = value;
|
|
2712
|
+
}
|
|
2713
|
+
return obj;
|
|
2714
|
+
}
|
|
2715
|
+
function bufferToBase64Url(buffer) {
|
|
2716
|
+
const bytes = new Uint8Array(buffer);
|
|
2717
|
+
if (typeof globalThis.Buffer !== "undefined") {
|
|
2718
|
+
return globalThis.Buffer.from(bytes).toString("base64url");
|
|
2719
|
+
}
|
|
2720
|
+
let binary = "";
|
|
2721
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
2722
|
+
binary += String.fromCharCode(bytes[i]);
|
|
2723
|
+
}
|
|
2724
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2725
|
+
}
|
|
2726
|
+
function base64UrlToBuffer(base64url) {
|
|
2727
|
+
if (typeof globalThis.Buffer !== "undefined") {
|
|
2728
|
+
const buf = globalThis.Buffer.from(base64url, "base64url");
|
|
2729
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
2730
|
+
}
|
|
2731
|
+
let base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
2732
|
+
while (base64.length % 4) {
|
|
2733
|
+
base64 += "=";
|
|
2734
|
+
}
|
|
2735
|
+
const binary = atob(base64);
|
|
2736
|
+
const bytes = new Uint8Array(binary.length);
|
|
2737
|
+
for (let i = 0; i < binary.length; i++) {
|
|
2738
|
+
bytes[i] = binary.charCodeAt(i);
|
|
2739
|
+
}
|
|
2740
|
+
return bytes.buffer;
|
|
2741
|
+
}
|
|
2742
|
+
var PasskeyAuthProvider2 = class {
|
|
2743
|
+
async init() {
|
|
2744
|
+
if (typeof window !== "undefined" && (!window.PublicKeyCredential || !navigator.credentials)) {
|
|
2745
|
+
console.warn("[ISA-AUTH] WebAuthn / Passkeys not supported in this browser.");
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
async registerCredential(options = {}) {
|
|
2749
|
+
if (typeof window === "undefined" || !navigator.credentials) {
|
|
2750
|
+
throw new Error("WebAuthn is not supported in this environment.");
|
|
2751
|
+
}
|
|
2752
|
+
const challenge = options.challenge || crypto.getRandomValues(new Uint8Array(32));
|
|
2753
|
+
const userName = options.userName || this.userName || "user@example.com";
|
|
2754
|
+
const userId = options.userId || this.userId || "user_" + Math.random().toString(36).substring(2, 9);
|
|
2755
|
+
const credential = await navigator.credentials.create({ publicKey: { challenge, rp: { name: this.rpName, id: this.rpId }, user: { id: new TextEncoder().encode(userId), name: userName, displayName: this.userDisplayName || userName }, pubKeyCredParams: [{ alg: -7, type: "public-key" }, { alg: -257, type: "public-key" }], authenticatorSelection: { authenticatorAttachment: "platform", userVerification: "preferred", residentKey: "preferred" }, timeout: 6e4, attestation: "none" } });
|
|
2756
|
+
return credential;
|
|
2757
|
+
}
|
|
2758
|
+
async signIn() {
|
|
2759
|
+
if (typeof window === "undefined" || !navigator.credentials) {
|
|
2760
|
+
const err = new Error("WebAuthn is not supported in this environment.");
|
|
2761
|
+
if (this.onFail) this.onFail(err);
|
|
2762
|
+
throw err;
|
|
2763
|
+
}
|
|
2764
|
+
try {
|
|
2765
|
+
let challengeBytes;
|
|
2766
|
+
if (this.challengeGenerator) {
|
|
2767
|
+
const gen = await this.challengeGenerator();
|
|
2768
|
+
challengeBytes = typeof gen === "string" ? new Uint8Array(base64UrlToBuffer(gen)) : gen;
|
|
2769
|
+
} else {
|
|
2770
|
+
challengeBytes = crypto.getRandomValues(new Uint8Array(32));
|
|
2771
|
+
}
|
|
2772
|
+
const credential = await navigator.credentials.get({ publicKey: { challenge: challengeBytes, rpId: this.rpId, userVerification: "preferred", timeout: 6e4 } });
|
|
2773
|
+
if (!credential) {
|
|
2774
|
+
throw new Error("Passkey authentication was cancelled.");
|
|
2775
|
+
}
|
|
2776
|
+
const response = credential.response;
|
|
2777
|
+
const assertionResult = { id: credential.id, rawId: bufferToBase64Url(credential.rawId), type: "public-key", response: { clientDataJSON: bufferToBase64Url(response.clientDataJSON), authenticatorData: bufferToBase64Url(response.authenticatorData), signature: bufferToBase64Url(response.signature), userHandle: response.userHandle ? bufferToBase64Url(response.userHandle) : void 0 } };
|
|
2778
|
+
this.lastAssertion = assertionResult;
|
|
2779
|
+
if (this.onSuccess) this.onSuccess(assertionResult);
|
|
2780
|
+
} catch (error) {
|
|
2781
|
+
if (this.onFail) this.onFail(error);
|
|
2782
|
+
throw error;
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
signOut() {
|
|
2786
|
+
this.lastAssertion = null;
|
|
2787
|
+
}
|
|
2788
|
+
async getAccessToken() {
|
|
2789
|
+
return this.lastAssertion ? this.lastAssertion.response.signature : null;
|
|
2790
|
+
}
|
|
2791
|
+
async getUserInfo() {
|
|
2792
|
+
if (!this.lastAssertion) return null;
|
|
2793
|
+
return { credentialId: this.lastAssertion.id, userHandle: this.lastAssertion.response.userHandle, passkeyAuthenticated: true };
|
|
1231
2794
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
2795
|
+
getAssertion() {
|
|
2796
|
+
return this.lastAssertion;
|
|
1234
2797
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
2798
|
+
constructor(options = {}) {
|
|
2799
|
+
_define_property(this, "rpName", void 0);
|
|
2800
|
+
_define_property(this, "rpId", void 0);
|
|
2801
|
+
_define_property(this, "challengeGenerator", void 0);
|
|
2802
|
+
_define_property(this, "userName", void 0);
|
|
2803
|
+
_define_property(this, "userDisplayName", void 0);
|
|
2804
|
+
_define_property(this, "userId", void 0);
|
|
2805
|
+
_define_property(this, "onSuccess", void 0);
|
|
2806
|
+
_define_property(this, "onFail", void 0);
|
|
2807
|
+
_define_property(this, "lastAssertion", null);
|
|
2808
|
+
this.rpName = options.rpName || "ISA-AUTH Application";
|
|
2809
|
+
this.rpId = options.rpId || (typeof window !== "undefined" ? window.location.hostname : void 0);
|
|
2810
|
+
this.challengeGenerator = options.challengeGenerator;
|
|
2811
|
+
this.userName = options.userName;
|
|
2812
|
+
this.userDisplayName = options.userDisplayName;
|
|
2813
|
+
this.userId = options.userId;
|
|
2814
|
+
this.onSuccess = options.onSuccess;
|
|
2815
|
+
this.onFail = options.onFail;
|
|
1243
2816
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
2817
|
+
};
|
|
2818
|
+
var _default = PasskeyAuthProvider2;
|
|
2819
|
+
}
|
|
2820
|
+
});
|
|
2821
|
+
|
|
2822
|
+
// ../core/dist/providers/identity/index.js
|
|
2823
|
+
var require_identity = __commonJS({
|
|
2824
|
+
"../core/dist/providers/identity/index.js"(exports2) {
|
|
2825
|
+
"use strict";
|
|
2826
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2827
|
+
_export_star(require_worldAuth(), exports2);
|
|
2828
|
+
_export_star(require_passkeyAuth(), exports2);
|
|
2829
|
+
function _export_star(from, to) {
|
|
2830
|
+
Object.keys(from).forEach(function(k) {
|
|
2831
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
2832
|
+
Object.defineProperty(to, k, { enumerable: true, get: function() {
|
|
2833
|
+
return from[k];
|
|
2834
|
+
} });
|
|
2835
|
+
}
|
|
1248
2836
|
});
|
|
1249
|
-
return
|
|
2837
|
+
return from;
|
|
1250
2838
|
}
|
|
1251
2839
|
}
|
|
1252
2840
|
});
|
|
1253
2841
|
|
|
2842
|
+
// ../core/dist/providers/authProvider.js
|
|
2843
|
+
var require_authProvider = __commonJS({
|
|
2844
|
+
"../core/dist/providers/authProvider.js"(exports2) {
|
|
2845
|
+
"use strict";
|
|
2846
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
2847
|
+
}
|
|
2848
|
+
});
|
|
2849
|
+
|
|
1254
2850
|
// ../core/dist/providers/index.js
|
|
1255
2851
|
var require_providers = __commonJS({
|
|
1256
2852
|
"../core/dist/providers/index.js"(exports2) {
|
|
@@ -1259,23 +2855,54 @@ var require_providers = __commonJS({
|
|
|
1259
2855
|
function _export(target, all) {
|
|
1260
2856
|
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1261
2857
|
}
|
|
1262
|
-
_export(exports2, { get
|
|
1263
|
-
return
|
|
2858
|
+
_export(exports2, { get AppleAuthProvider() {
|
|
2859
|
+
return _social.AppleAuthProvider;
|
|
2860
|
+
}, get DiscordAuthProvider() {
|
|
2861
|
+
return _developer.DiscordAuthProvider;
|
|
2862
|
+
}, get FacebookAuthProvider() {
|
|
2863
|
+
return _social.FacebookAuthProvider;
|
|
2864
|
+
}, get GithubAuthProvider() {
|
|
2865
|
+
return _developer.GithubAuthProvider;
|
|
2866
|
+
}, get GoogleAuthProvider() {
|
|
2867
|
+
return _social.GoogleAuthProvider;
|
|
1264
2868
|
}, get KakaoAuthProvider() {
|
|
1265
|
-
return
|
|
2869
|
+
return _social.KakaoAuthProvider;
|
|
2870
|
+
}, get LineAuthProvider() {
|
|
2871
|
+
return _social.LineAuthProvider;
|
|
2872
|
+
}, get MetaAuthProvider() {
|
|
2873
|
+
return _social.MetaAuthProvider;
|
|
1266
2874
|
}, get NaverAuthProvider() {
|
|
1267
|
-
return
|
|
2875
|
+
return _social.NaverAuthProvider;
|
|
2876
|
+
}, get PasskeyAuthProvider() {
|
|
2877
|
+
return _identity.PasskeyAuthProvider;
|
|
1268
2878
|
}, get Web3AuthProvider() {
|
|
1269
|
-
return
|
|
2879
|
+
return _web3.Web3AuthProvider;
|
|
2880
|
+
}, get WorldAuthProvider() {
|
|
2881
|
+
return _identity.WorldAuthProvider;
|
|
2882
|
+
}, get developerProviders() {
|
|
2883
|
+
return _developer.developerProviders;
|
|
1270
2884
|
}, get getProvider() {
|
|
1271
2885
|
return getProvider;
|
|
2886
|
+
}, get getProviderCategory() {
|
|
2887
|
+
return getProviderCategory2;
|
|
2888
|
+
}, get getProvidersByCategory() {
|
|
2889
|
+
return getProvidersByCategory2;
|
|
2890
|
+
}, get identityProviders() {
|
|
2891
|
+
return identityProviders2;
|
|
2892
|
+
}, get providerCategoryMap() {
|
|
2893
|
+
return providerCategoryMap;
|
|
1272
2894
|
}, get providers() {
|
|
1273
2895
|
return providers;
|
|
2896
|
+
}, get socialProviders() {
|
|
2897
|
+
return _social.socialProviders;
|
|
2898
|
+
}, get web3Providers() {
|
|
2899
|
+
return _web3.web3Providers;
|
|
1274
2900
|
} });
|
|
1275
|
-
var
|
|
1276
|
-
var
|
|
1277
|
-
var
|
|
1278
|
-
var
|
|
2901
|
+
var _social = _export_star(require_social(), exports2);
|
|
2902
|
+
var _developer = _export_star(require_developer(), exports2);
|
|
2903
|
+
var _web3 = _export_star(require_web3(), exports2);
|
|
2904
|
+
var _identity = _export_star(require_identity(), exports2);
|
|
2905
|
+
_export_star(require_authProvider(), exports2);
|
|
1279
2906
|
_export_star(require_pkce(), exports2);
|
|
1280
2907
|
function _export_star(from, to) {
|
|
1281
2908
|
Object.keys(from).forEach(function(k) {
|
|
@@ -1287,10 +2914,27 @@ var require_providers = __commonJS({
|
|
|
1287
2914
|
});
|
|
1288
2915
|
return from;
|
|
1289
2916
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
}
|
|
1293
|
-
var
|
|
2917
|
+
var identityProviders2 = { world: _identity.WorldAuthProvider, passkey: _identity.PasskeyAuthProvider };
|
|
2918
|
+
var providers = { google: _social.GoogleAuthProvider, apple: _social.AppleAuthProvider, meta: _social.MetaAuthProvider, facebook: _social.FacebookAuthProvider, kakao: _social.KakaoAuthProvider, naver: _social.NaverAuthProvider, line: _social.LineAuthProvider, github: _developer.GithubAuthProvider, discord: _developer.DiscordAuthProvider, web3: _web3.Web3AuthProvider, world: _identity.WorldAuthProvider, passkey: _identity.PasskeyAuthProvider, none: null };
|
|
2919
|
+
var providerCategoryMap = { google: "social", apple: "social", meta: "social", facebook: "social", kakao: "social", naver: "social", line: "social", github: "developer", discord: "developer", web3: "web3", world: "identity", passkey: "identity" };
|
|
2920
|
+
var getProviderCategory2 = (provider) => {
|
|
2921
|
+
if (provider === "none") return null;
|
|
2922
|
+
return providerCategoryMap[provider] || null;
|
|
2923
|
+
};
|
|
2924
|
+
var getProvidersByCategory2 = (category) => {
|
|
2925
|
+
switch (category) {
|
|
2926
|
+
case "social":
|
|
2927
|
+
return _social.socialProviders;
|
|
2928
|
+
case "developer":
|
|
2929
|
+
return _developer.developerProviders;
|
|
2930
|
+
case "web3":
|
|
2931
|
+
return _web3.web3Providers;
|
|
2932
|
+
case "identity":
|
|
2933
|
+
return identityProviders2;
|
|
2934
|
+
default:
|
|
2935
|
+
return {};
|
|
2936
|
+
}
|
|
2937
|
+
};
|
|
1294
2938
|
var getProvider = (provider) => {
|
|
1295
2939
|
if (provider === "none") {
|
|
1296
2940
|
return null;
|
|
@@ -1333,6 +2977,13 @@ var require_loginButton = __commonJS({
|
|
|
1333
2977
|
return "\uB124\uC774\uBC84 \uB85C\uADF8\uC778";
|
|
1334
2978
|
case "web3":
|
|
1335
2979
|
return "Connect Ethereum Wallet";
|
|
2980
|
+
case "meta":
|
|
2981
|
+
case "facebook":
|
|
2982
|
+
return "Continue with Meta";
|
|
2983
|
+
case "world":
|
|
2984
|
+
return "Verify with World ID";
|
|
2985
|
+
case "passkey":
|
|
2986
|
+
return "Sign in with Passkey";
|
|
1336
2987
|
default:
|
|
1337
2988
|
return "\uB85C\uADF8\uC778";
|
|
1338
2989
|
}
|
|
@@ -1518,6 +3169,86 @@ var require_web3Login = __commonJS({
|
|
|
1518
3169
|
}
|
|
1519
3170
|
});
|
|
1520
3171
|
|
|
3172
|
+
// ../core/dist/components/githubLogin.js
|
|
3173
|
+
var require_githubLogin = __commonJS({
|
|
3174
|
+
"../core/dist/components/githubLogin.js"(exports2) {
|
|
3175
|
+
"use strict";
|
|
3176
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3177
|
+
Object.defineProperty(exports2, "default", { enumerable: true, get: function() {
|
|
3178
|
+
return _default;
|
|
3179
|
+
} });
|
|
3180
|
+
var _loginButton = /* @__PURE__ */ _interop_require_default(require_loginButton());
|
|
3181
|
+
function _interop_require_default(obj) {
|
|
3182
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
3183
|
+
}
|
|
3184
|
+
var githubLoginButton = new _loginButton.default({ type: "rect", provider: "github", action: () => console.log("GitHub \uB85C\uADF8\uC778 \uC2DC\uB3C4"), config: { id: "login-github", text: "Sign in with GitHub", fullWidth: true, style: { backgroundColor: "#24292e", color: "#ffffff" } } });
|
|
3185
|
+
var _default = githubLoginButton;
|
|
3186
|
+
}
|
|
3187
|
+
});
|
|
3188
|
+
|
|
3189
|
+
// ../core/dist/components/discordLogin.js
|
|
3190
|
+
var require_discordLogin = __commonJS({
|
|
3191
|
+
"../core/dist/components/discordLogin.js"(exports2) {
|
|
3192
|
+
"use strict";
|
|
3193
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3194
|
+
Object.defineProperty(exports2, "default", { enumerable: true, get: function() {
|
|
3195
|
+
return _default;
|
|
3196
|
+
} });
|
|
3197
|
+
var _loginButton = /* @__PURE__ */ _interop_require_default(require_loginButton());
|
|
3198
|
+
function _interop_require_default(obj) {
|
|
3199
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
3200
|
+
}
|
|
3201
|
+
var discordLoginButton = new _loginButton.default({ type: "rect", provider: "discord", action: () => console.log("Discord \uB85C\uADF8\uC778 \uC2DC\uB3C4"), config: { id: "login-discord", text: "Sign in with Discord", fullWidth: true, style: { backgroundColor: "#5865F2", color: "#ffffff" } } });
|
|
3202
|
+
var _default = discordLoginButton;
|
|
3203
|
+
}
|
|
3204
|
+
});
|
|
3205
|
+
|
|
3206
|
+
// ../core/dist/components/worldLogin.js
|
|
3207
|
+
var require_worldLogin = __commonJS({
|
|
3208
|
+
"../core/dist/components/worldLogin.js"(exports2) {
|
|
3209
|
+
"use strict";
|
|
3210
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3211
|
+
function _export(target, all) {
|
|
3212
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
3213
|
+
}
|
|
3214
|
+
_export(exports2, { get default() {
|
|
3215
|
+
return _default;
|
|
3216
|
+
}, get worldLoginButton() {
|
|
3217
|
+
return worldLoginButton;
|
|
3218
|
+
} });
|
|
3219
|
+
var _loginButton = /* @__PURE__ */ _interop_require_default(require_loginButton());
|
|
3220
|
+
function _interop_require_default(obj) {
|
|
3221
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
3222
|
+
}
|
|
3223
|
+
var worldLoginButton = new _loginButton.default({ type: "rounded", provider: "world", action: () => {
|
|
3224
|
+
}, config: { id: "isa-auth-btn-world", text: "Verify with World ID (Orb)", icon: "/icons/world.svg", fullWidth: false, style: { backgroundColor: "#000000", color: "#FFFFFF", border: "1px solid #333333" } } });
|
|
3225
|
+
var _default = worldLoginButton;
|
|
3226
|
+
}
|
|
3227
|
+
});
|
|
3228
|
+
|
|
3229
|
+
// ../core/dist/components/passkeyLogin.js
|
|
3230
|
+
var require_passkeyLogin = __commonJS({
|
|
3231
|
+
"../core/dist/components/passkeyLogin.js"(exports2) {
|
|
3232
|
+
"use strict";
|
|
3233
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
3234
|
+
function _export(target, all) {
|
|
3235
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
3236
|
+
}
|
|
3237
|
+
_export(exports2, { get default() {
|
|
3238
|
+
return _default;
|
|
3239
|
+
}, get passkeyLoginButton() {
|
|
3240
|
+
return passkeyLoginButton;
|
|
3241
|
+
} });
|
|
3242
|
+
var _loginButton = /* @__PURE__ */ _interop_require_default(require_loginButton());
|
|
3243
|
+
function _interop_require_default(obj) {
|
|
3244
|
+
return obj && obj.__esModule ? obj : { default: obj };
|
|
3245
|
+
}
|
|
3246
|
+
var passkeyLoginButton = new _loginButton.default({ type: "rounded", provider: "passkey", action: () => {
|
|
3247
|
+
}, config: { id: "isa-auth-btn-passkey", text: "Sign in with Passkey", icon: "/icons/passkey.svg", fullWidth: false, style: { backgroundColor: "#1E293B", color: "#F8FAFC", border: "1px solid #334155" } } });
|
|
3248
|
+
var _default = passkeyLoginButton;
|
|
3249
|
+
}
|
|
3250
|
+
});
|
|
3251
|
+
|
|
1521
3252
|
// ../core/dist/components/index.js
|
|
1522
3253
|
var require_components = __commonJS({
|
|
1523
3254
|
"../core/dist/components/index.js"(exports2) {
|
|
@@ -1528,8 +3259,12 @@ var require_components = __commonJS({
|
|
|
1528
3259
|
}
|
|
1529
3260
|
_export(exports2, { get appleLoginButton() {
|
|
1530
3261
|
return _appleLogin.default;
|
|
3262
|
+
}, get discordLoginButton() {
|
|
3263
|
+
return _discordLogin.default;
|
|
1531
3264
|
}, get getButton() {
|
|
1532
3265
|
return getButton;
|
|
3266
|
+
}, get githubLoginButton() {
|
|
3267
|
+
return _githubLogin.default;
|
|
1533
3268
|
}, get googleLoginButton() {
|
|
1534
3269
|
return _googleLogin.default;
|
|
1535
3270
|
}, get kakaoLoginButton() {
|
|
@@ -1540,10 +3275,14 @@ var require_components = __commonJS({
|
|
|
1540
3275
|
return _metaLogin.default;
|
|
1541
3276
|
}, get naverLoginButton() {
|
|
1542
3277
|
return _naverLogin.default;
|
|
3278
|
+
}, get passkeyLoginButton() {
|
|
3279
|
+
return _passkeyLogin.default;
|
|
1543
3280
|
}, get web3LoginButton() {
|
|
1544
3281
|
return _web3Login.default;
|
|
1545
3282
|
}, get wechatLoginButton() {
|
|
1546
3283
|
return _wechatLogin.default;
|
|
3284
|
+
}, get worldLoginButton() {
|
|
3285
|
+
return _worldLogin.default;
|
|
1547
3286
|
} });
|
|
1548
3287
|
var _googleLogin = /* @__PURE__ */ _interop_require_default(require_googleLogin());
|
|
1549
3288
|
var _appleLogin = /* @__PURE__ */ _interop_require_default(require_appleLogin());
|
|
@@ -1553,6 +3292,10 @@ var require_components = __commonJS({
|
|
|
1553
3292
|
var _metaLogin = /* @__PURE__ */ _interop_require_default(require_metaLogin());
|
|
1554
3293
|
var _kakaoLogin = /* @__PURE__ */ _interop_require_default(require_kakaoLogin());
|
|
1555
3294
|
var _web3Login = /* @__PURE__ */ _interop_require_default(require_web3Login());
|
|
3295
|
+
var _githubLogin = /* @__PURE__ */ _interop_require_default(require_githubLogin());
|
|
3296
|
+
var _discordLogin = /* @__PURE__ */ _interop_require_default(require_discordLogin());
|
|
3297
|
+
var _worldLogin = /* @__PURE__ */ _interop_require_default(require_worldLogin());
|
|
3298
|
+
var _passkeyLogin = /* @__PURE__ */ _interop_require_default(require_passkeyLogin());
|
|
1556
3299
|
_export_star(require_loginButton(), exports2);
|
|
1557
3300
|
function _export_star(from, to) {
|
|
1558
3301
|
Object.keys(from).forEach(function(k) {
|
|
@@ -1567,7 +3310,7 @@ var require_components = __commonJS({
|
|
|
1567
3310
|
function _interop_require_default(obj) {
|
|
1568
3311
|
return obj && obj.__esModule ? obj : { default: obj };
|
|
1569
3312
|
}
|
|
1570
|
-
var buttons = { google: _googleLogin.default, kakao: _kakaoLogin.default, naver: _naverLogin.default, apple: _appleLogin.default, line: _lineLogin.default, wechat: _wechatLogin.default, meta: _metaLogin.default, web3: _web3Login.default, none: null };
|
|
3313
|
+
var buttons = { google: _googleLogin.default, kakao: _kakaoLogin.default, naver: _naverLogin.default, apple: _appleLogin.default, line: _lineLogin.default, wechat: _wechatLogin.default, meta: _metaLogin.default, facebook: _metaLogin.default, web3: _web3Login.default, github: _githubLogin.default, discord: _discordLogin.default, world: _worldLogin.default, passkey: _passkeyLogin.default, none: null };
|
|
1571
3314
|
var getButton = (provider) => {
|
|
1572
3315
|
if (provider === "none") {
|
|
1573
3316
|
return null;
|
|
@@ -1645,8 +3388,8 @@ var require_mappings = __commonJS({
|
|
|
1645
3388
|
}, get providerToServiceMap() {
|
|
1646
3389
|
return providerToServiceMap;
|
|
1647
3390
|
} });
|
|
1648
|
-
var providerToServiceMap = { base: "base", jwt: "jwt", google: "jwt", kakao: "jwt", naver: "jwt", web3: "base" };
|
|
1649
|
-
var providerToButtonMap = { base: "none", jwt: "none", google: "google", kakao: "kakao", naver: "naver", web3: "web3" };
|
|
3391
|
+
var providerToServiceMap = { base: "base", jwt: "jwt", google: "jwt", kakao: "jwt", naver: "jwt", web3: "base", github: "jwt", apple: "jwt", discord: "jwt", line: "jwt", meta: "jwt", facebook: "jwt", world: "base", passkey: "base" };
|
|
3392
|
+
var providerToButtonMap = { base: "none", jwt: "none", google: "google", kakao: "kakao", naver: "naver", web3: "web3", github: "github", apple: "apple", discord: "discord", line: "line", meta: "meta", facebook: "facebook", world: "world", passkey: "passkey" };
|
|
1650
3393
|
}
|
|
1651
3394
|
});
|
|
1652
3395
|
|
|
@@ -1655,8 +3398,13 @@ var require_lifecycle = __commonJS({
|
|
|
1655
3398
|
"../core/dist/lifecycle/index.js"(exports2) {
|
|
1656
3399
|
"use strict";
|
|
1657
3400
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1658
|
-
|
|
1659
|
-
|
|
3401
|
+
function _export(target, all) {
|
|
3402
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
3403
|
+
}
|
|
3404
|
+
_export(exports2, { get AuthLifecycleManager() {
|
|
3405
|
+
return AuthLifecycleManager2;
|
|
3406
|
+
}, get default() {
|
|
3407
|
+
return _default;
|
|
1660
3408
|
} });
|
|
1661
3409
|
function _define_property(obj, key, value) {
|
|
1662
3410
|
if (key in obj) {
|
|
@@ -1666,7 +3414,7 @@ var require_lifecycle = __commonJS({
|
|
|
1666
3414
|
}
|
|
1667
3415
|
return obj;
|
|
1668
3416
|
}
|
|
1669
|
-
var
|
|
3417
|
+
var AuthLifecycleManager2 = class {
|
|
1670
3418
|
on(event, listener) {
|
|
1671
3419
|
var _this_listeners_get;
|
|
1672
3420
|
const set = (_this_listeners_get = this.listeners.get(event)) !== null && _this_listeners_get !== void 0 ? _this_listeners_get : /* @__PURE__ */ new Set();
|
|
@@ -1691,6 +3439,18 @@ var require_lifecycle = __commonJS({
|
|
|
1691
3439
|
onError(listener) {
|
|
1692
3440
|
return this.on("error", listener);
|
|
1693
3441
|
}
|
|
3442
|
+
onUnauthorized(listener) {
|
|
3443
|
+
return this.on("unauthorized", listener);
|
|
3444
|
+
}
|
|
3445
|
+
onAccessDenied(listener) {
|
|
3446
|
+
return this.on("accessDenied", listener);
|
|
3447
|
+
}
|
|
3448
|
+
onRoleChanged(listener) {
|
|
3449
|
+
return this.on("roleChanged", listener);
|
|
3450
|
+
}
|
|
3451
|
+
onPermissionChanged(listener) {
|
|
3452
|
+
return this.on("permissionChanged", listener);
|
|
3453
|
+
}
|
|
1694
3454
|
async emit(event, data) {
|
|
1695
3455
|
const set = this.listeners.get(event);
|
|
1696
3456
|
if (!set || set.size === 0) return;
|
|
@@ -1709,64 +3469,7 @@ var require_lifecycle = __commonJS({
|
|
|
1709
3469
|
_define_property(this, "listeners", /* @__PURE__ */ new Map());
|
|
1710
3470
|
}
|
|
1711
3471
|
};
|
|
1712
|
-
|
|
1713
|
-
});
|
|
1714
|
-
|
|
1715
|
-
// ../core/dist/guard/index.js
|
|
1716
|
-
var require_guard = __commonJS({
|
|
1717
|
-
"../core/dist/guard/index.js"(exports2) {
|
|
1718
|
-
"use strict";
|
|
1719
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1720
|
-
function _export(target, all) {
|
|
1721
|
-
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
1722
|
-
}
|
|
1723
|
-
_export(exports2, { get checkPermission() {
|
|
1724
|
-
return checkPermission;
|
|
1725
|
-
}, get checkRole() {
|
|
1726
|
-
return checkRole;
|
|
1727
|
-
}, get createAuthGuard() {
|
|
1728
|
-
return createAuthGuard2;
|
|
1729
|
-
} });
|
|
1730
|
-
function checkRole(required, userRoles = [], matchAll = false) {
|
|
1731
|
-
const reqList = Array.isArray(required) ? required : [required];
|
|
1732
|
-
if (reqList.length === 0) return true;
|
|
1733
|
-
if (matchAll) {
|
|
1734
|
-
return reqList.every((r) => userRoles.includes(r));
|
|
1735
|
-
}
|
|
1736
|
-
return reqList.some((r) => userRoles.includes(r));
|
|
1737
|
-
}
|
|
1738
|
-
function checkPermission(required, userPermissions = [], matchAll = true) {
|
|
1739
|
-
const reqList = Array.isArray(required) ? required : [required];
|
|
1740
|
-
if (reqList.length === 0) return true;
|
|
1741
|
-
if (matchAll) {
|
|
1742
|
-
return reqList.every((p) => userPermissions.includes(p));
|
|
1743
|
-
}
|
|
1744
|
-
return reqList.some((p) => userPermissions.includes(p));
|
|
1745
|
-
}
|
|
1746
|
-
function createAuthGuard2(options) {
|
|
1747
|
-
const { requireAuth = true, roles, permissions, onUnauthenticated, onUnauthorized } = options;
|
|
1748
|
-
return async function guard(context) {
|
|
1749
|
-
if (requireAuth && !context.isAuthenticated) {
|
|
1750
|
-
if (onUnauthenticated) await onUnauthenticated();
|
|
1751
|
-
return false;
|
|
1752
|
-
}
|
|
1753
|
-
if (roles) {
|
|
1754
|
-
const hasRequiredRole = checkRole(roles, context.roles || []);
|
|
1755
|
-
if (!hasRequiredRole) {
|
|
1756
|
-
if (onUnauthorized) await onUnauthorized("Insufficient role");
|
|
1757
|
-
return false;
|
|
1758
|
-
}
|
|
1759
|
-
}
|
|
1760
|
-
if (permissions) {
|
|
1761
|
-
const hasRequiredPerm = checkPermission(permissions, context.permissions || []);
|
|
1762
|
-
if (!hasRequiredPerm) {
|
|
1763
|
-
if (onUnauthorized) await onUnauthorized("Insufficient permissions");
|
|
1764
|
-
return false;
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
return true;
|
|
1768
|
-
};
|
|
1769
|
-
}
|
|
3472
|
+
var _default = AuthLifecycleManager2;
|
|
1770
3473
|
}
|
|
1771
3474
|
});
|
|
1772
3475
|
|
|
@@ -1775,11 +3478,21 @@ var require_http = __commonJS({
|
|
|
1775
3478
|
"../core/dist/http/index.js"(exports2) {
|
|
1776
3479
|
"use strict";
|
|
1777
3480
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1778
|
-
|
|
3481
|
+
function _export(target, all) {
|
|
3482
|
+
for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get });
|
|
3483
|
+
}
|
|
3484
|
+
_export(exports2, { get applyAuthInterceptor() {
|
|
3485
|
+
return applyAuthInterceptor2;
|
|
3486
|
+
}, get createAuthAxios() {
|
|
3487
|
+
return createAuthAxios2;
|
|
3488
|
+
}, get createAuthFetch() {
|
|
1779
3489
|
return createAuthFetch2;
|
|
1780
3490
|
} });
|
|
1781
3491
|
function createAuthFetch2(options) {
|
|
1782
|
-
const { authClient, refreshFn, baseUrl = "", onUnauthorized, headerName = "Authorization", tokenPrefix = "Bearer " } = options;
|
|
3492
|
+
const { authClient, refreshFn, baseUrl = "", onUnauthorized, headerName = "Authorization", tokenPrefix = "Bearer ", withCredentials = false, customFetch = typeof fetch !== "undefined" ? fetch : void 0, beforeRequest, afterResponse } = options;
|
|
3493
|
+
if (!customFetch) {
|
|
3494
|
+
throw new Error("[ISA-AUTH] Fetch API is not available.");
|
|
3495
|
+
}
|
|
1783
3496
|
let isRefreshing = false;
|
|
1784
3497
|
let refreshQueue = [];
|
|
1785
3498
|
const processQueue = (newToken) => {
|
|
@@ -1788,13 +3501,19 @@ var require_http = __commonJS({
|
|
|
1788
3501
|
};
|
|
1789
3502
|
return async function authFetch(input, init = {}) {
|
|
1790
3503
|
const url = typeof input === "string" && baseUrl && !input.startsWith("http") ? `${baseUrl.replace(/\/$/, "")}/${input.replace(/^\//, "")}` : input;
|
|
1791
|
-
|
|
3504
|
+
let headers = new Headers(init.headers || {});
|
|
1792
3505
|
const token = authClient.getAccessToken();
|
|
1793
3506
|
if (token && !headers.has(headerName)) {
|
|
1794
3507
|
headers.set(headerName, `${tokenPrefix}${token}`);
|
|
1795
3508
|
}
|
|
1796
|
-
|
|
1797
|
-
|
|
3509
|
+
let modifiedInit = { ...init, headers };
|
|
3510
|
+
if (withCredentials) {
|
|
3511
|
+
modifiedInit.credentials = "include";
|
|
3512
|
+
}
|
|
3513
|
+
if (beforeRequest) {
|
|
3514
|
+
modifiedInit = await beforeRequest(modifiedInit) || modifiedInit;
|
|
3515
|
+
}
|
|
3516
|
+
let response = await customFetch(url, modifiedInit);
|
|
1798
3517
|
if (response.status === 401 && authClient.refreshToken && refreshFn) {
|
|
1799
3518
|
if (!isRefreshing) {
|
|
1800
3519
|
isRefreshing = true;
|
|
@@ -1803,8 +3522,10 @@ var require_http = __commonJS({
|
|
|
1803
3522
|
isRefreshing = false;
|
|
1804
3523
|
processQueue(newToken);
|
|
1805
3524
|
if (newToken) {
|
|
1806
|
-
headers
|
|
1807
|
-
|
|
3525
|
+
const retryHeaders = new Headers(modifiedInit.headers);
|
|
3526
|
+
retryHeaders.set(headerName, `${tokenPrefix}${newToken}`);
|
|
3527
|
+
const retryResponse = await customFetch(url, { ...modifiedInit, headers: retryHeaders });
|
|
3528
|
+
return afterResponse ? await afterResponse(retryResponse) || retryResponse : retryResponse;
|
|
1808
3529
|
} else {
|
|
1809
3530
|
var _authClient_clearAuthState;
|
|
1810
3531
|
if (onUnauthorized) onUnauthorized();
|
|
@@ -1823,9 +3544,11 @@ var require_http = __commonJS({
|
|
|
1823
3544
|
refreshQueue.push(async (newToken) => {
|
|
1824
3545
|
if (newToken) {
|
|
1825
3546
|
try {
|
|
1826
|
-
headers
|
|
1827
|
-
|
|
1828
|
-
|
|
3547
|
+
const retryHeaders = new Headers(modifiedInit.headers);
|
|
3548
|
+
retryHeaders.set(headerName, `${tokenPrefix}${newToken}`);
|
|
3549
|
+
const retryRes = await customFetch(url, { ...modifiedInit, headers: retryHeaders });
|
|
3550
|
+
const finalRes = afterResponse ? await afterResponse(retryRes) || retryRes : retryRes;
|
|
3551
|
+
resolve(finalRes);
|
|
1829
3552
|
} catch (e) {
|
|
1830
3553
|
reject(e);
|
|
1831
3554
|
}
|
|
@@ -1836,9 +3559,98 @@ var require_http = __commonJS({
|
|
|
1836
3559
|
});
|
|
1837
3560
|
}
|
|
1838
3561
|
}
|
|
3562
|
+
if (afterResponse) {
|
|
3563
|
+
response = await afterResponse(response) || response;
|
|
3564
|
+
}
|
|
1839
3565
|
return response;
|
|
1840
3566
|
};
|
|
1841
3567
|
}
|
|
3568
|
+
function applyAuthInterceptor2(axiosInstance, options) {
|
|
3569
|
+
const { authClient, refreshFn, onUnauthorized, headerName = "Authorization", tokenPrefix = "Bearer ", withCredentials = false, beforeRequest, afterResponse } = options;
|
|
3570
|
+
let isRefreshing = false;
|
|
3571
|
+
let refreshQueue = [];
|
|
3572
|
+
const processQueue = (token) => {
|
|
3573
|
+
refreshQueue.forEach((callback) => callback(token));
|
|
3574
|
+
refreshQueue = [];
|
|
3575
|
+
};
|
|
3576
|
+
const reqInterceptorId = axiosInstance.interceptors.request.use(async (config) => {
|
|
3577
|
+
const token = authClient.getAccessToken();
|
|
3578
|
+
if (token && !config.headers[headerName]) {
|
|
3579
|
+
config.headers[headerName] = `${tokenPrefix}${token}`;
|
|
3580
|
+
}
|
|
3581
|
+
if (withCredentials) {
|
|
3582
|
+
config.withCredentials = true;
|
|
3583
|
+
}
|
|
3584
|
+
if (beforeRequest) {
|
|
3585
|
+
config = await beforeRequest(config) || config;
|
|
3586
|
+
}
|
|
3587
|
+
return config;
|
|
3588
|
+
}, (error) => Promise.reject(error));
|
|
3589
|
+
const resInterceptorId = axiosInstance.interceptors.response.use(async (response) => {
|
|
3590
|
+
if (afterResponse) {
|
|
3591
|
+
return await afterResponse(response) || response;
|
|
3592
|
+
}
|
|
3593
|
+
return response;
|
|
3594
|
+
}, async (error) => {
|
|
3595
|
+
const originalRequest = error.config;
|
|
3596
|
+
if (!originalRequest || !error.response || error.response.status !== 401) {
|
|
3597
|
+
return Promise.reject(error);
|
|
3598
|
+
}
|
|
3599
|
+
if (originalRequest._retry) {
|
|
3600
|
+
return Promise.reject(error);
|
|
3601
|
+
}
|
|
3602
|
+
originalRequest._retry = true;
|
|
3603
|
+
if (!authClient.refreshToken || !refreshFn) {
|
|
3604
|
+
var _authClient_clearAuthState;
|
|
3605
|
+
if (onUnauthorized) onUnauthorized();
|
|
3606
|
+
(_authClient_clearAuthState = authClient.clearAuthState) === null || _authClient_clearAuthState === void 0 ? void 0 : _authClient_clearAuthState.call(authClient);
|
|
3607
|
+
return Promise.reject(error);
|
|
3608
|
+
}
|
|
3609
|
+
if (isRefreshing) {
|
|
3610
|
+
return new Promise((resolve, reject) => {
|
|
3611
|
+
refreshQueue.push((token) => {
|
|
3612
|
+
if (token) {
|
|
3613
|
+
originalRequest.headers[headerName] = `${tokenPrefix}${token}`;
|
|
3614
|
+
resolve(axiosInstance(originalRequest));
|
|
3615
|
+
} else {
|
|
3616
|
+
reject(error);
|
|
3617
|
+
}
|
|
3618
|
+
});
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3621
|
+
isRefreshing = true;
|
|
3622
|
+
try {
|
|
3623
|
+
const newToken = await authClient.refreshToken(refreshFn);
|
|
3624
|
+
isRefreshing = false;
|
|
3625
|
+
processQueue(newToken);
|
|
3626
|
+
if (newToken) {
|
|
3627
|
+
originalRequest.headers[headerName] = `${tokenPrefix}${newToken}`;
|
|
3628
|
+
return axiosInstance(originalRequest);
|
|
3629
|
+
} else {
|
|
3630
|
+
var _authClient_clearAuthState1;
|
|
3631
|
+
if (onUnauthorized) onUnauthorized();
|
|
3632
|
+
(_authClient_clearAuthState1 = authClient.clearAuthState) === null || _authClient_clearAuthState1 === void 0 ? void 0 : _authClient_clearAuthState1.call(authClient);
|
|
3633
|
+
return Promise.reject(error);
|
|
3634
|
+
}
|
|
3635
|
+
} catch (refreshErr) {
|
|
3636
|
+
var _authClient_clearAuthState2;
|
|
3637
|
+
isRefreshing = false;
|
|
3638
|
+
processQueue(null);
|
|
3639
|
+
if (onUnauthorized) onUnauthorized();
|
|
3640
|
+
(_authClient_clearAuthState2 = authClient.clearAuthState) === null || _authClient_clearAuthState2 === void 0 ? void 0 : _authClient_clearAuthState2.call(authClient);
|
|
3641
|
+
return Promise.reject(refreshErr);
|
|
3642
|
+
}
|
|
3643
|
+
});
|
|
3644
|
+
return { eject: () => {
|
|
3645
|
+
axiosInstance.interceptors.request.eject(reqInterceptorId);
|
|
3646
|
+
axiosInstance.interceptors.response.eject(resInterceptorId);
|
|
3647
|
+
} };
|
|
3648
|
+
}
|
|
3649
|
+
function createAuthAxios2(axiosModuleOrInstance, options) {
|
|
3650
|
+
const instance = typeof axiosModuleOrInstance.create === "function" ? axiosModuleOrInstance.create({ baseURL: options.baseUrl }) : axiosModuleOrInstance;
|
|
3651
|
+
applyAuthInterceptor2(instance, options);
|
|
3652
|
+
return instance;
|
|
3653
|
+
}
|
|
1842
3654
|
}
|
|
1843
3655
|
});
|
|
1844
3656
|
|
|
@@ -1858,6 +3670,7 @@ var require_authCore = __commonJS({
|
|
|
1858
3670
|
var _lifecycle = require_lifecycle();
|
|
1859
3671
|
var _guard = require_guard();
|
|
1860
3672
|
var _http = require_http();
|
|
3673
|
+
var _tokenExchange = require_tokenExchange();
|
|
1861
3674
|
var _store = require_store2();
|
|
1862
3675
|
function _define_property(obj, key, value) {
|
|
1863
3676
|
if (key in obj) {
|
|
@@ -1877,23 +3690,76 @@ var require_authCore = __commonJS({
|
|
|
1877
3690
|
getButton() {
|
|
1878
3691
|
return this.button;
|
|
1879
3692
|
}
|
|
1880
|
-
|
|
3693
|
+
getContext() {
|
|
1881
3694
|
const isAuthed = this.serviceInstance.getAuthState();
|
|
1882
3695
|
const info = this.serviceInstance.getAuthInfo() || {};
|
|
1883
|
-
return
|
|
3696
|
+
return { isAuthenticated: isAuthed, roles: info.roles || (info.role ? [info.role] : []), permissions: info.permissions || [], user: info };
|
|
3697
|
+
}
|
|
3698
|
+
updateAuthInfo(partial) {
|
|
3699
|
+
return this.serviceInstance.updateAuthInfo(partial);
|
|
3700
|
+
}
|
|
3701
|
+
startAutoRefresh(refreshFn, options) {
|
|
3702
|
+
if ("startAutoRefresh" in this.serviceInstance) {
|
|
3703
|
+
this.serviceInstance.startAutoRefresh(refreshFn, { onSuccess: (token) => {
|
|
3704
|
+
this.lifecycle.emit("tokenRefreshed", { token });
|
|
3705
|
+
}, onError: (error) => {
|
|
3706
|
+
this.lifecycle.emit("error", { error, phase: "autoRefresh" });
|
|
3707
|
+
}, ...options });
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
stopAutoRefresh() {
|
|
3711
|
+
if ("stopAutoRefresh" in this.serviceInstance) {
|
|
3712
|
+
this.serviceInstance.stopAutoRefresh();
|
|
3713
|
+
}
|
|
3714
|
+
}
|
|
3715
|
+
async evaluateGuard(options, customContext) {
|
|
3716
|
+
const context = { ...this.getContext(), ...customContext };
|
|
3717
|
+
const result = await (0, _guard.evaluateGuard)(options, context);
|
|
3718
|
+
if (!result.allowed) {
|
|
3719
|
+
this.lifecycle.emit("unauthorized", { reason: result.message || "Unauthorized", result, context, timestamp: Date.now() });
|
|
3720
|
+
this.lifecycle.emit("accessDenied", { reason: result.message || "Access denied", result, context, target: options.target, timestamp: Date.now() });
|
|
3721
|
+
}
|
|
3722
|
+
return result;
|
|
3723
|
+
}
|
|
3724
|
+
async createGuard(options) {
|
|
3725
|
+
const context = this.getContext();
|
|
3726
|
+
const guardFn = (0, _guard.createAuthGuard)(options);
|
|
3727
|
+
const passed = await guardFn(context);
|
|
3728
|
+
if (!passed) {
|
|
3729
|
+
this.lifecycle.emit("unauthorized", { reason: "Unauthorized access", context, timestamp: Date.now() });
|
|
3730
|
+
this.lifecycle.emit("accessDenied", { reason: "Guard check failed", context, target: options.target, timestamp: Date.now() });
|
|
3731
|
+
}
|
|
3732
|
+
return passed;
|
|
3733
|
+
}
|
|
3734
|
+
hasRole(role, matchAll = false) {
|
|
3735
|
+
const context = this.getContext();
|
|
3736
|
+
return (0, _guard.checkRole)(role, context.roles || [], matchAll);
|
|
3737
|
+
}
|
|
3738
|
+
hasPermission(permission, matchAll = true) {
|
|
3739
|
+
const context = this.getContext();
|
|
3740
|
+
return (0, _guard.checkPermission)(permission, context.permissions || [], matchAll);
|
|
1884
3741
|
}
|
|
1885
3742
|
createFetch(options) {
|
|
1886
3743
|
return (0, _http.createAuthFetch)({ authClient: this.serviceInstance, ...options });
|
|
1887
3744
|
}
|
|
3745
|
+
applyAxiosInterceptor(axiosInstance, options) {
|
|
3746
|
+
return (0, _http.applyAuthInterceptor)(axiosInstance, { authClient: this.serviceInstance, ...options });
|
|
3747
|
+
}
|
|
3748
|
+
createAxios(axiosModuleOrInstance, options) {
|
|
3749
|
+
return (0, _http.createAuthAxios)(axiosModuleOrInstance, { authClient: this.serviceInstance, ...options });
|
|
3750
|
+
}
|
|
3751
|
+
createTokenExchange(tokenEndpoint, options) {
|
|
3752
|
+
return new _tokenExchange.HttpTokenExchangeAdapter({ tokenEndpoint, ...options });
|
|
3753
|
+
}
|
|
1888
3754
|
getWebComponentAPI() {
|
|
1889
3755
|
return { addAuthEventListener: _customAuth.addAuthEventListener, removeAuthEventListener: _customAuth.removeAuthEventListener, dispatchAuthEvent: _customAuth.dispatchAuthEvent, watchAuthState: this.serviceInstance.watchAuthState.bind(this.serviceInstance) };
|
|
1890
3756
|
}
|
|
1891
|
-
constructor({ providerType = "base", secret = "isa-auth-secret", storage = "
|
|
3757
|
+
constructor({ providerType = "base", secret = "isa-auth-secret", storage = "memory", storagePrefix = "" } = {}) {
|
|
1892
3758
|
_define_property(this, "provider", void 0);
|
|
1893
3759
|
_define_property(this, "button", void 0);
|
|
1894
3760
|
_define_property(this, "serviceInstance", void 0);
|
|
1895
3761
|
_define_property(this, "lifecycle", void 0);
|
|
1896
|
-
(0, _store.configureStorage)(storage);
|
|
3762
|
+
(0, _store.configureStorage)({ type: storage, prefix: storagePrefix });
|
|
1897
3763
|
var _providerToServiceMap_providerType;
|
|
1898
3764
|
const serviceType = (_providerToServiceMap_providerType = _mappings.providerToServiceMap[providerType]) !== null && _providerToServiceMap_providerType !== void 0 ? _providerToServiceMap_providerType : "base";
|
|
1899
3765
|
var _providerToButtonMap_providerType;
|
|
@@ -1964,30 +3830,66 @@ var require_dist = __commonJS({
|
|
|
1964
3830
|
// src/index.ts
|
|
1965
3831
|
var index_exports = {};
|
|
1966
3832
|
__export(index_exports, {
|
|
3833
|
+
AppleAuthProvider: () => import_isa_auth_core.AppleAuthProvider,
|
|
3834
|
+
AuthBaseService: () => import_isa_auth_core.AuthBaseService,
|
|
1967
3835
|
AuthCore: () => import_isa_auth_core.default,
|
|
1968
3836
|
AuthProvider: () => AuthProvider_default,
|
|
3837
|
+
CookieSessionStorageAdapter: () => import_isa_auth_core.CookieSessionStorageAdapter,
|
|
3838
|
+
DiscordAuthProvider: () => import_isa_auth_core.DiscordAuthProvider,
|
|
3839
|
+
FacebookAuthProvider: () => import_isa_auth_core.FacebookAuthProvider,
|
|
3840
|
+
GithubAuthProvider: () => import_isa_auth_core.GithubAuthProvider,
|
|
1969
3841
|
GoogleAuthProvider: () => import_isa_auth_core.GoogleAuthProvider,
|
|
3842
|
+
HttpTokenExchangeAdapter: () => import_isa_auth_core.HttpTokenExchangeAdapter,
|
|
1970
3843
|
IsaAuth: () => IsaAuth,
|
|
3844
|
+
JwtService: () => import_isa_auth_core.JwtService,
|
|
1971
3845
|
KakaoAuthProvider: () => import_isa_auth_core.KakaoAuthProvider,
|
|
3846
|
+
LineAuthProvider: () => import_isa_auth_core.LineAuthProvider,
|
|
3847
|
+
LocalStorageAdapter: () => import_isa_auth_core.LocalStorageAdapter,
|
|
3848
|
+
MemoryStorageAdapter: () => import_isa_auth_core.MemoryStorageAdapter,
|
|
3849
|
+
MetaAuthProvider: () => import_isa_auth_core.MetaAuthProvider,
|
|
1972
3850
|
NaverAuthProvider: () => import_isa_auth_core.NaverAuthProvider,
|
|
3851
|
+
PasskeyAuthProvider: () => import_isa_auth_core.PasskeyAuthProvider,
|
|
3852
|
+
SessionStorageAdapter: () => import_isa_auth_core.SessionStorageAdapter,
|
|
1973
3853
|
Web3AuthProvider: () => import_isa_auth_core.Web3AuthProvider,
|
|
3854
|
+
WorldAuthProvider: () => import_isa_auth_core.WorldAuthProvider,
|
|
3855
|
+
applyAuthInterceptor: () => import_isa_auth_core.applyAuthInterceptor,
|
|
3856
|
+
batch: () => import_isa_auth_core.batch,
|
|
1974
3857
|
buildAuthorizeUrl: () => import_isa_auth_core.buildAuthorizeUrl,
|
|
3858
|
+
checkPermission: () => import_isa_auth_core.checkPermission,
|
|
3859
|
+
checkRole: () => import_isa_auth_core.checkRole,
|
|
3860
|
+
clearStoreSession: () => import_isa_auth_core.clearStoreSession,
|
|
1975
3861
|
configureStorage: () => import_isa_auth_core.configureStorage,
|
|
3862
|
+
createAuthAxios: () => import_isa_auth_core.createAuthAxios,
|
|
1976
3863
|
createAuthFetch: () => import_isa_auth_core.createAuthFetch,
|
|
1977
3864
|
createAuthGuard: () => import_isa_auth_core.createAuthGuard,
|
|
3865
|
+
createNavigationGuard: () => import_isa_auth_core.createNavigationGuard,
|
|
1978
3866
|
decodeToken: () => import_isa_auth_core.decodeToken,
|
|
1979
3867
|
default: () => index_default,
|
|
3868
|
+
developerProviders: () => import_isa_auth_core.developerProviders,
|
|
3869
|
+
evaluateGuard: () => import_isa_auth_core.evaluateGuard,
|
|
1980
3870
|
generateCodeChallenge: () => import_isa_auth_core.generateCodeChallenge,
|
|
1981
3871
|
generateCodeVerifier: () => import_isa_auth_core.generateCodeVerifier,
|
|
1982
3872
|
getAccessToken: () => import_isa_auth_core.getAccessToken,
|
|
1983
3873
|
getAuthInfo: () => import_isa_auth_core.getAuthInfo,
|
|
1984
3874
|
getAuthState: () => import_isa_auth_core.getAuthState,
|
|
3875
|
+
getProviderCategory: () => import_isa_auth_core.getProviderCategory,
|
|
3876
|
+
getProvidersByCategory: () => import_isa_auth_core.getProvidersByCategory,
|
|
3877
|
+
getRefreshToken: () => import_isa_auth_core.getRefreshToken,
|
|
3878
|
+
getStorageAdapter: () => import_isa_auth_core.getStorageAdapter,
|
|
1985
3879
|
getTokenFromHeader: () => import_isa_auth_core.getTokenFromHeader,
|
|
1986
3880
|
getTokenPayload: () => import_isa_auth_core.getTokenPayload,
|
|
1987
3881
|
getTokenTimeRemaining: () => import_isa_auth_core.getTokenTimeRemaining,
|
|
3882
|
+
identityProviders: () => import_isa_auth_core.identityProviders,
|
|
1988
3883
|
isExpiredToken: () => import_isa_auth_core.isExpiredToken,
|
|
3884
|
+
matchPermissionRule: () => import_isa_auth_core.matchPermissionRule,
|
|
1989
3885
|
parseOAuthCallback: () => import_isa_auth_core.parseOAuthCallback,
|
|
1990
|
-
renderers: () => render_exports
|
|
3886
|
+
renderers: () => render_exports,
|
|
3887
|
+
resolveInheritedRoles: () => import_isa_auth_core.resolveInheritedRoles,
|
|
3888
|
+
setRefreshToken: () => import_isa_auth_core.setRefreshToken,
|
|
3889
|
+
socialProviders: () => import_isa_auth_core.socialProviders,
|
|
3890
|
+
subscribeSelector: () => import_isa_auth_core.subscribeSelector,
|
|
3891
|
+
updateAuthInfo: () => import_isa_auth_core.updateAuthInfo,
|
|
3892
|
+
web3Providers: () => import_isa_auth_core.web3Providers
|
|
1991
3893
|
});
|
|
1992
3894
|
module.exports = __toCommonJS(index_exports);
|
|
1993
3895
|
var import_isa_auth_core = __toESM(require_dist());
|
|
@@ -2220,13 +4122,16 @@ var IsaAuth = class {
|
|
|
2220
4122
|
clientId = "",
|
|
2221
4123
|
callbackUrl = "",
|
|
2222
4124
|
scope,
|
|
2223
|
-
storage = "
|
|
4125
|
+
storage = "memory",
|
|
4126
|
+
storagePrefix = "",
|
|
2224
4127
|
extraOptions = {}
|
|
2225
4128
|
} = config;
|
|
4129
|
+
this.providerType = provider;
|
|
2226
4130
|
this.core = new import_isa_auth_core.default({
|
|
2227
4131
|
providerType: provider,
|
|
2228
4132
|
secret,
|
|
2229
|
-
storage
|
|
4133
|
+
storage,
|
|
4134
|
+
storagePrefix
|
|
2230
4135
|
});
|
|
2231
4136
|
const ProviderClass = this.core.getProvider();
|
|
2232
4137
|
if (ProviderClass) {
|
|
@@ -2257,6 +4162,54 @@ var IsaAuth = class {
|
|
|
2257
4162
|
domain: typeof window !== "undefined" ? window.location.host : "localhost",
|
|
2258
4163
|
...extraOptions
|
|
2259
4164
|
});
|
|
4165
|
+
} else if (provider === "github") {
|
|
4166
|
+
this.providerInstance = new ProviderClass({
|
|
4167
|
+
clientId,
|
|
4168
|
+
redirectUri: callbackUrl,
|
|
4169
|
+
scope,
|
|
4170
|
+
...extraOptions
|
|
4171
|
+
});
|
|
4172
|
+
} else if (provider === "apple") {
|
|
4173
|
+
this.providerInstance = new ProviderClass({
|
|
4174
|
+
clientId,
|
|
4175
|
+
redirectURI: callbackUrl,
|
|
4176
|
+
scope,
|
|
4177
|
+
...extraOptions
|
|
4178
|
+
});
|
|
4179
|
+
} else if (provider === "discord") {
|
|
4180
|
+
this.providerInstance = new ProviderClass({
|
|
4181
|
+
clientId,
|
|
4182
|
+
redirectUri: callbackUrl,
|
|
4183
|
+
scope,
|
|
4184
|
+
...extraOptions
|
|
4185
|
+
});
|
|
4186
|
+
} else if (provider === "line") {
|
|
4187
|
+
this.providerInstance = new ProviderClass({
|
|
4188
|
+
clientId,
|
|
4189
|
+
callbackUrl,
|
|
4190
|
+
scope,
|
|
4191
|
+
...extraOptions
|
|
4192
|
+
});
|
|
4193
|
+
} else if (provider === "meta" || provider === "facebook") {
|
|
4194
|
+
this.providerInstance = new ProviderClass({
|
|
4195
|
+
appId: clientId,
|
|
4196
|
+
redirectUri: callbackUrl,
|
|
4197
|
+
scope,
|
|
4198
|
+
...extraOptions
|
|
4199
|
+
});
|
|
4200
|
+
} else if (provider === "world") {
|
|
4201
|
+
this.providerInstance = new ProviderClass({
|
|
4202
|
+
appId: clientId,
|
|
4203
|
+
action: extraOptions.action || "login",
|
|
4204
|
+
verificationLevel: extraOptions.verificationLevel || "orb",
|
|
4205
|
+
...extraOptions
|
|
4206
|
+
});
|
|
4207
|
+
} else if (provider === "passkey") {
|
|
4208
|
+
this.providerInstance = new ProviderClass({
|
|
4209
|
+
rpName: extraOptions.rpName || "ISA-AUTH Application",
|
|
4210
|
+
rpId: extraOptions.rpId,
|
|
4211
|
+
...extraOptions
|
|
4212
|
+
});
|
|
2260
4213
|
} else {
|
|
2261
4214
|
this.providerInstance = new ProviderClass({
|
|
2262
4215
|
clientId,
|
|
@@ -2278,22 +4231,58 @@ var IsaAuth = class {
|
|
|
2278
4231
|
getUserInfo() {
|
|
2279
4232
|
return this.authProvider.getUserInfo();
|
|
2280
4233
|
}
|
|
4234
|
+
getContext() {
|
|
4235
|
+
return this.core.getContext();
|
|
4236
|
+
}
|
|
4237
|
+
/**
|
|
4238
|
+
* Returns current provider category ('social' | 'developer' | 'web3' | 'identity' | null)
|
|
4239
|
+
*/
|
|
4240
|
+
getCategory() {
|
|
4241
|
+
return (0, import_isa_auth_core.getProviderCategory)(this.providerType);
|
|
4242
|
+
}
|
|
2281
4243
|
setAccessToken(token) {
|
|
2282
4244
|
const service = this.core.getService();
|
|
2283
4245
|
if (service.setAccessToken) {
|
|
2284
4246
|
service.setAccessToken(token);
|
|
2285
4247
|
}
|
|
2286
4248
|
}
|
|
4249
|
+
getRefreshToken() {
|
|
4250
|
+
var _a;
|
|
4251
|
+
const service = this.core.getService();
|
|
4252
|
+
return ((_a = service.getRefreshToken) == null ? void 0 : _a.call(service)) || null;
|
|
4253
|
+
}
|
|
4254
|
+
setRefreshToken(token) {
|
|
4255
|
+
const service = this.core.getService();
|
|
4256
|
+
if (service.setRefreshToken) {
|
|
4257
|
+
service.setRefreshToken(token);
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
updateAuthInfo(partial) {
|
|
4261
|
+
return this.core.updateAuthInfo(partial);
|
|
4262
|
+
}
|
|
2287
4263
|
// 2. Authentication Actions
|
|
2288
4264
|
async signIn() {
|
|
2289
4265
|
return await this.authProvider.signIn();
|
|
2290
4266
|
}
|
|
2291
4267
|
signOut() {
|
|
4268
|
+
this.stopAutoRefresh();
|
|
2292
4269
|
this.authProvider.signOut();
|
|
2293
4270
|
}
|
|
2294
4271
|
async refresh(refreshFn) {
|
|
2295
4272
|
return await this.authProvider.refresh(refreshFn);
|
|
2296
4273
|
}
|
|
4274
|
+
/**
|
|
4275
|
+
* Starts automatic background token refresh prior to expiration
|
|
4276
|
+
*/
|
|
4277
|
+
startAutoRefresh(refreshFn, options) {
|
|
4278
|
+
this.core.startAutoRefresh(refreshFn, options);
|
|
4279
|
+
}
|
|
4280
|
+
/**
|
|
4281
|
+
* Stops automatic background token refresh
|
|
4282
|
+
*/
|
|
4283
|
+
stopAutoRefresh() {
|
|
4284
|
+
this.core.stopAutoRefresh();
|
|
4285
|
+
}
|
|
2297
4286
|
// 3. UI and Renderers
|
|
2298
4287
|
getButton() {
|
|
2299
4288
|
return this.authProvider.getButton();
|
|
@@ -2313,21 +4302,83 @@ var IsaAuth = class {
|
|
|
2313
4302
|
}
|
|
2314
4303
|
return btn;
|
|
2315
4304
|
}
|
|
2316
|
-
// 4. RBAC & Guards
|
|
4305
|
+
// 4. RBAC, ABAC & Enhanced Guards
|
|
2317
4306
|
hasRole(role) {
|
|
2318
4307
|
return this.authProvider.hasRole(role);
|
|
2319
4308
|
}
|
|
2320
4309
|
hasPermission(permission) {
|
|
2321
4310
|
return this.authProvider.hasPermission(permission);
|
|
2322
4311
|
}
|
|
4312
|
+
/**
|
|
4313
|
+
* Check permission with wildcard matching support
|
|
4314
|
+
* E.g. isaAuth.can('users:read') or isaAuth.can(['users:read', 'users:write'])
|
|
4315
|
+
*/
|
|
4316
|
+
can(permission, matchAll = true) {
|
|
4317
|
+
return this.core.hasPermission(permission, matchAll);
|
|
4318
|
+
}
|
|
4319
|
+
/**
|
|
4320
|
+
* Check role with optional matchAll option
|
|
4321
|
+
*/
|
|
4322
|
+
is(role, matchAll = false) {
|
|
4323
|
+
return this.core.hasRole(role, matchAll);
|
|
4324
|
+
}
|
|
4325
|
+
/**
|
|
4326
|
+
* Evaluates guard and returns detailed GuardResult
|
|
4327
|
+
*/
|
|
4328
|
+
async evaluateGuard(options, customContext) {
|
|
4329
|
+
return this.core.evaluateGuard(options, customContext);
|
|
4330
|
+
}
|
|
4331
|
+
/**
|
|
4332
|
+
* Instant boolean guard check (backwards compatible)
|
|
4333
|
+
*/
|
|
2323
4334
|
createGuard(options) {
|
|
2324
4335
|
return this.core.createGuard(options);
|
|
2325
4336
|
}
|
|
2326
|
-
|
|
4337
|
+
/**
|
|
4338
|
+
* Creates a reusable router navigation guard
|
|
4339
|
+
*/
|
|
4340
|
+
createNavigationGuard(options) {
|
|
4341
|
+
return (0, import_isa_auth_core.createNavigationGuard)({
|
|
4342
|
+
...options,
|
|
4343
|
+
getContext: () => this.getContext()
|
|
4344
|
+
});
|
|
4345
|
+
}
|
|
4346
|
+
// 5. Lifecycle & Authorization Callbacks
|
|
4347
|
+
onSignIn(listener) {
|
|
4348
|
+
return this.core.lifecycle.onSignIn(listener);
|
|
4349
|
+
}
|
|
4350
|
+
onSignOut(listener) {
|
|
4351
|
+
return this.core.lifecycle.onSignOut(listener);
|
|
4352
|
+
}
|
|
4353
|
+
onTokenExpired(listener) {
|
|
4354
|
+
return this.core.lifecycle.onTokenExpired(listener);
|
|
4355
|
+
}
|
|
4356
|
+
onUnauthorized(listener) {
|
|
4357
|
+
return this.core.lifecycle.onUnauthorized(listener);
|
|
4358
|
+
}
|
|
4359
|
+
onAccessDenied(listener) {
|
|
4360
|
+
return this.core.lifecycle.onAccessDenied(listener);
|
|
4361
|
+
}
|
|
4362
|
+
onRoleChanged(listener) {
|
|
4363
|
+
return this.core.lifecycle.onRoleChanged(listener);
|
|
4364
|
+
}
|
|
4365
|
+
onPermissionChanged(listener) {
|
|
4366
|
+
return this.core.lifecycle.onPermissionChanged(listener);
|
|
4367
|
+
}
|
|
4368
|
+
// 6. Authenticated HTTP Clients (Fetch & Axios)
|
|
2327
4369
|
createFetch(options) {
|
|
2328
4370
|
return this.core.createFetch(options);
|
|
2329
4371
|
}
|
|
2330
|
-
|
|
4372
|
+
applyAxiosInterceptor(axiosInstance, options) {
|
|
4373
|
+
return this.core.applyAxiosInterceptor(axiosInstance, options);
|
|
4374
|
+
}
|
|
4375
|
+
createAxios(axiosModuleOrInstance, options) {
|
|
4376
|
+
return this.core.createAxios(axiosModuleOrInstance, options);
|
|
4377
|
+
}
|
|
4378
|
+
createTokenExchange(tokenEndpoint, options) {
|
|
4379
|
+
return this.core.createTokenExchange(tokenEndpoint, options);
|
|
4380
|
+
}
|
|
4381
|
+
// 7. Watcher
|
|
2331
4382
|
subscribe(callback) {
|
|
2332
4383
|
return this.authProvider.watchAuthState(callback);
|
|
2333
4384
|
}
|
|
@@ -2335,28 +4386,64 @@ var IsaAuth = class {
|
|
|
2335
4386
|
var index_default = IsaAuth;
|
|
2336
4387
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2337
4388
|
0 && (module.exports = {
|
|
4389
|
+
AppleAuthProvider,
|
|
4390
|
+
AuthBaseService,
|
|
2338
4391
|
AuthCore,
|
|
2339
4392
|
AuthProvider,
|
|
4393
|
+
CookieSessionStorageAdapter,
|
|
4394
|
+
DiscordAuthProvider,
|
|
4395
|
+
FacebookAuthProvider,
|
|
4396
|
+
GithubAuthProvider,
|
|
2340
4397
|
GoogleAuthProvider,
|
|
4398
|
+
HttpTokenExchangeAdapter,
|
|
2341
4399
|
IsaAuth,
|
|
4400
|
+
JwtService,
|
|
2342
4401
|
KakaoAuthProvider,
|
|
4402
|
+
LineAuthProvider,
|
|
4403
|
+
LocalStorageAdapter,
|
|
4404
|
+
MemoryStorageAdapter,
|
|
4405
|
+
MetaAuthProvider,
|
|
2343
4406
|
NaverAuthProvider,
|
|
4407
|
+
PasskeyAuthProvider,
|
|
4408
|
+
SessionStorageAdapter,
|
|
2344
4409
|
Web3AuthProvider,
|
|
4410
|
+
WorldAuthProvider,
|
|
4411
|
+
applyAuthInterceptor,
|
|
4412
|
+
batch,
|
|
2345
4413
|
buildAuthorizeUrl,
|
|
4414
|
+
checkPermission,
|
|
4415
|
+
checkRole,
|
|
4416
|
+
clearStoreSession,
|
|
2346
4417
|
configureStorage,
|
|
4418
|
+
createAuthAxios,
|
|
2347
4419
|
createAuthFetch,
|
|
2348
4420
|
createAuthGuard,
|
|
4421
|
+
createNavigationGuard,
|
|
2349
4422
|
decodeToken,
|
|
4423
|
+
developerProviders,
|
|
4424
|
+
evaluateGuard,
|
|
2350
4425
|
generateCodeChallenge,
|
|
2351
4426
|
generateCodeVerifier,
|
|
2352
4427
|
getAccessToken,
|
|
2353
4428
|
getAuthInfo,
|
|
2354
4429
|
getAuthState,
|
|
4430
|
+
getProviderCategory,
|
|
4431
|
+
getProvidersByCategory,
|
|
4432
|
+
getRefreshToken,
|
|
4433
|
+
getStorageAdapter,
|
|
2355
4434
|
getTokenFromHeader,
|
|
2356
4435
|
getTokenPayload,
|
|
2357
4436
|
getTokenTimeRemaining,
|
|
4437
|
+
identityProviders,
|
|
2358
4438
|
isExpiredToken,
|
|
4439
|
+
matchPermissionRule,
|
|
2359
4440
|
parseOAuthCallback,
|
|
2360
|
-
renderers
|
|
4441
|
+
renderers,
|
|
4442
|
+
resolveInheritedRoles,
|
|
4443
|
+
setRefreshToken,
|
|
4444
|
+
socialProviders,
|
|
4445
|
+
subscribeSelector,
|
|
4446
|
+
updateAuthInfo,
|
|
4447
|
+
web3Providers
|
|
2361
4448
|
});
|
|
2362
4449
|
//# sourceMappingURL=index.js.map
|