@abtnode/core 1.16.51-beta-20250904-031834-c611f059 → 1.16.51-beta-20250905-023351-70af144b
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/lib/api/team.js +13 -2
- package/lib/blocklet/migration-dist/migration.cjs +456 -456
- package/lib/blocklet/webhook/event-bus.js +1 -1
- package/lib/states/user.js +41 -15
- package/lib/team/manager.js +9 -5
- package/lib/util/validate-user-role-passport.js +27 -0
- package/lib/util/verify-access-key-user.js +4 -2
- package/lib/util/verify-user-private.js +42 -0
- package/package.json +26 -26
package/lib/api/team.js
CHANGED
|
@@ -59,6 +59,7 @@ const { getBlocklet } = require('../util/blocklet');
|
|
|
59
59
|
const StoreUtil = require('../util/store');
|
|
60
60
|
const { profileSchema } = require('../validators/user');
|
|
61
61
|
const { passportDisplaySchema } = require('../validators/util');
|
|
62
|
+
const { validateUserRolePassport } = require('../util/validate-user-role-passport');
|
|
62
63
|
|
|
63
64
|
const sanitizeUrl = (url) => {
|
|
64
65
|
if (!url) {
|
|
@@ -683,9 +684,11 @@ class TeamAPI extends EventEmitter {
|
|
|
683
684
|
}
|
|
684
685
|
}
|
|
685
686
|
|
|
686
|
-
async getUserFollowStats({ teamDid, userDids }) {
|
|
687
|
+
async getUserFollowStats({ teamDid, userDids }, context = {}) {
|
|
687
688
|
const state = await this.getUserState(teamDid);
|
|
688
|
-
|
|
689
|
+
const info = await this.node.read();
|
|
690
|
+
const prefix = process.env.NODE_ENV === 'production' ? info.routing.adminPath : '';
|
|
691
|
+
return state.getFollowStats({ userDids, teamDid, prefix }, context);
|
|
689
692
|
}
|
|
690
693
|
|
|
691
694
|
async checkFollowing({ teamDid, userDids = [], followerDid }) {
|
|
@@ -1094,6 +1097,14 @@ class TeamAPI extends EventEmitter {
|
|
|
1094
1097
|
throw new Error('Inviter does not exist');
|
|
1095
1098
|
}
|
|
1096
1099
|
|
|
1100
|
+
if ((user?.role || '').startsWith('blocklet-')) {
|
|
1101
|
+
const userInfo = await this.getUser({ teamDid, user });
|
|
1102
|
+
validateUserRolePassport({
|
|
1103
|
+
role: (user?.role || '').replace('blocklet-', ''),
|
|
1104
|
+
passports: userInfo?.passports || [],
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1097
1108
|
const expireDate = Date.now() + (expireTime || this.memberInviteExpireTime);
|
|
1098
1109
|
const state = await this.getSessionState(teamDid);
|
|
1099
1110
|
const { id: inviteId } = await state.start({
|
|
@@ -5429,11 +5429,457 @@ SafeBuffer.allocUnsafeSlow = function (size) {
|
|
|
5429
5429
|
|
|
5430
5430
|
/***/ }),
|
|
5431
5431
|
|
|
5432
|
-
/***/
|
|
5432
|
+
/***/ 4953:
|
|
5433
|
+
/***/ ((module) => {
|
|
5434
|
+
|
|
5435
|
+
"use strict";
|
|
5436
|
+
|
|
5437
|
+
|
|
5438
|
+
module.exports = {
|
|
5439
|
+
"aliceblue": [240, 248, 255],
|
|
5440
|
+
"antiquewhite": [250, 235, 215],
|
|
5441
|
+
"aqua": [0, 255, 255],
|
|
5442
|
+
"aquamarine": [127, 255, 212],
|
|
5443
|
+
"azure": [240, 255, 255],
|
|
5444
|
+
"beige": [245, 245, 220],
|
|
5445
|
+
"bisque": [255, 228, 196],
|
|
5446
|
+
"black": [0, 0, 0],
|
|
5447
|
+
"blanchedalmond": [255, 235, 205],
|
|
5448
|
+
"blue": [0, 0, 255],
|
|
5449
|
+
"blueviolet": [138, 43, 226],
|
|
5450
|
+
"brown": [165, 42, 42],
|
|
5451
|
+
"burlywood": [222, 184, 135],
|
|
5452
|
+
"cadetblue": [95, 158, 160],
|
|
5453
|
+
"chartreuse": [127, 255, 0],
|
|
5454
|
+
"chocolate": [210, 105, 30],
|
|
5455
|
+
"coral": [255, 127, 80],
|
|
5456
|
+
"cornflowerblue": [100, 149, 237],
|
|
5457
|
+
"cornsilk": [255, 248, 220],
|
|
5458
|
+
"crimson": [220, 20, 60],
|
|
5459
|
+
"cyan": [0, 255, 255],
|
|
5460
|
+
"darkblue": [0, 0, 139],
|
|
5461
|
+
"darkcyan": [0, 139, 139],
|
|
5462
|
+
"darkgoldenrod": [184, 134, 11],
|
|
5463
|
+
"darkgray": [169, 169, 169],
|
|
5464
|
+
"darkgreen": [0, 100, 0],
|
|
5465
|
+
"darkgrey": [169, 169, 169],
|
|
5466
|
+
"darkkhaki": [189, 183, 107],
|
|
5467
|
+
"darkmagenta": [139, 0, 139],
|
|
5468
|
+
"darkolivegreen": [85, 107, 47],
|
|
5469
|
+
"darkorange": [255, 140, 0],
|
|
5470
|
+
"darkorchid": [153, 50, 204],
|
|
5471
|
+
"darkred": [139, 0, 0],
|
|
5472
|
+
"darksalmon": [233, 150, 122],
|
|
5473
|
+
"darkseagreen": [143, 188, 143],
|
|
5474
|
+
"darkslateblue": [72, 61, 139],
|
|
5475
|
+
"darkslategray": [47, 79, 79],
|
|
5476
|
+
"darkslategrey": [47, 79, 79],
|
|
5477
|
+
"darkturquoise": [0, 206, 209],
|
|
5478
|
+
"darkviolet": [148, 0, 211],
|
|
5479
|
+
"deeppink": [255, 20, 147],
|
|
5480
|
+
"deepskyblue": [0, 191, 255],
|
|
5481
|
+
"dimgray": [105, 105, 105],
|
|
5482
|
+
"dimgrey": [105, 105, 105],
|
|
5483
|
+
"dodgerblue": [30, 144, 255],
|
|
5484
|
+
"firebrick": [178, 34, 34],
|
|
5485
|
+
"floralwhite": [255, 250, 240],
|
|
5486
|
+
"forestgreen": [34, 139, 34],
|
|
5487
|
+
"fuchsia": [255, 0, 255],
|
|
5488
|
+
"gainsboro": [220, 220, 220],
|
|
5489
|
+
"ghostwhite": [248, 248, 255],
|
|
5490
|
+
"gold": [255, 215, 0],
|
|
5491
|
+
"goldenrod": [218, 165, 32],
|
|
5492
|
+
"gray": [128, 128, 128],
|
|
5493
|
+
"green": [0, 128, 0],
|
|
5494
|
+
"greenyellow": [173, 255, 47],
|
|
5495
|
+
"grey": [128, 128, 128],
|
|
5496
|
+
"honeydew": [240, 255, 240],
|
|
5497
|
+
"hotpink": [255, 105, 180],
|
|
5498
|
+
"indianred": [205, 92, 92],
|
|
5499
|
+
"indigo": [75, 0, 130],
|
|
5500
|
+
"ivory": [255, 255, 240],
|
|
5501
|
+
"khaki": [240, 230, 140],
|
|
5502
|
+
"lavender": [230, 230, 250],
|
|
5503
|
+
"lavenderblush": [255, 240, 245],
|
|
5504
|
+
"lawngreen": [124, 252, 0],
|
|
5505
|
+
"lemonchiffon": [255, 250, 205],
|
|
5506
|
+
"lightblue": [173, 216, 230],
|
|
5507
|
+
"lightcoral": [240, 128, 128],
|
|
5508
|
+
"lightcyan": [224, 255, 255],
|
|
5509
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
|
5510
|
+
"lightgray": [211, 211, 211],
|
|
5511
|
+
"lightgreen": [144, 238, 144],
|
|
5512
|
+
"lightgrey": [211, 211, 211],
|
|
5513
|
+
"lightpink": [255, 182, 193],
|
|
5514
|
+
"lightsalmon": [255, 160, 122],
|
|
5515
|
+
"lightseagreen": [32, 178, 170],
|
|
5516
|
+
"lightskyblue": [135, 206, 250],
|
|
5517
|
+
"lightslategray": [119, 136, 153],
|
|
5518
|
+
"lightslategrey": [119, 136, 153],
|
|
5519
|
+
"lightsteelblue": [176, 196, 222],
|
|
5520
|
+
"lightyellow": [255, 255, 224],
|
|
5521
|
+
"lime": [0, 255, 0],
|
|
5522
|
+
"limegreen": [50, 205, 50],
|
|
5523
|
+
"linen": [250, 240, 230],
|
|
5524
|
+
"magenta": [255, 0, 255],
|
|
5525
|
+
"maroon": [128, 0, 0],
|
|
5526
|
+
"mediumaquamarine": [102, 205, 170],
|
|
5527
|
+
"mediumblue": [0, 0, 205],
|
|
5528
|
+
"mediumorchid": [186, 85, 211],
|
|
5529
|
+
"mediumpurple": [147, 112, 219],
|
|
5530
|
+
"mediumseagreen": [60, 179, 113],
|
|
5531
|
+
"mediumslateblue": [123, 104, 238],
|
|
5532
|
+
"mediumspringgreen": [0, 250, 154],
|
|
5533
|
+
"mediumturquoise": [72, 209, 204],
|
|
5534
|
+
"mediumvioletred": [199, 21, 133],
|
|
5535
|
+
"midnightblue": [25, 25, 112],
|
|
5536
|
+
"mintcream": [245, 255, 250],
|
|
5537
|
+
"mistyrose": [255, 228, 225],
|
|
5538
|
+
"moccasin": [255, 228, 181],
|
|
5539
|
+
"navajowhite": [255, 222, 173],
|
|
5540
|
+
"navy": [0, 0, 128],
|
|
5541
|
+
"oldlace": [253, 245, 230],
|
|
5542
|
+
"olive": [128, 128, 0],
|
|
5543
|
+
"olivedrab": [107, 142, 35],
|
|
5544
|
+
"orange": [255, 165, 0],
|
|
5545
|
+
"orangered": [255, 69, 0],
|
|
5546
|
+
"orchid": [218, 112, 214],
|
|
5547
|
+
"palegoldenrod": [238, 232, 170],
|
|
5548
|
+
"palegreen": [152, 251, 152],
|
|
5549
|
+
"paleturquoise": [175, 238, 238],
|
|
5550
|
+
"palevioletred": [219, 112, 147],
|
|
5551
|
+
"papayawhip": [255, 239, 213],
|
|
5552
|
+
"peachpuff": [255, 218, 185],
|
|
5553
|
+
"peru": [205, 133, 63],
|
|
5554
|
+
"pink": [255, 192, 203],
|
|
5555
|
+
"plum": [221, 160, 221],
|
|
5556
|
+
"powderblue": [176, 224, 230],
|
|
5557
|
+
"purple": [128, 0, 128],
|
|
5558
|
+
"rebeccapurple": [102, 51, 153],
|
|
5559
|
+
"red": [255, 0, 0],
|
|
5560
|
+
"rosybrown": [188, 143, 143],
|
|
5561
|
+
"royalblue": [65, 105, 225],
|
|
5562
|
+
"saddlebrown": [139, 69, 19],
|
|
5563
|
+
"salmon": [250, 128, 114],
|
|
5564
|
+
"sandybrown": [244, 164, 96],
|
|
5565
|
+
"seagreen": [46, 139, 87],
|
|
5566
|
+
"seashell": [255, 245, 238],
|
|
5567
|
+
"sienna": [160, 82, 45],
|
|
5568
|
+
"silver": [192, 192, 192],
|
|
5569
|
+
"skyblue": [135, 206, 235],
|
|
5570
|
+
"slateblue": [106, 90, 205],
|
|
5571
|
+
"slategray": [112, 128, 144],
|
|
5572
|
+
"slategrey": [112, 128, 144],
|
|
5573
|
+
"snow": [255, 250, 250],
|
|
5574
|
+
"springgreen": [0, 255, 127],
|
|
5575
|
+
"steelblue": [70, 130, 180],
|
|
5576
|
+
"tan": [210, 180, 140],
|
|
5577
|
+
"teal": [0, 128, 128],
|
|
5578
|
+
"thistle": [216, 191, 216],
|
|
5579
|
+
"tomato": [255, 99, 71],
|
|
5580
|
+
"turquoise": [64, 224, 208],
|
|
5581
|
+
"violet": [238, 130, 238],
|
|
5582
|
+
"wheat": [245, 222, 179],
|
|
5583
|
+
"white": [255, 255, 255],
|
|
5584
|
+
"whitesmoke": [245, 245, 245],
|
|
5585
|
+
"yellow": [255, 255, 0],
|
|
5586
|
+
"yellowgreen": [154, 205, 50]
|
|
5587
|
+
};
|
|
5588
|
+
|
|
5589
|
+
|
|
5590
|
+
/***/ }),
|
|
5591
|
+
|
|
5592
|
+
/***/ 9407:
|
|
5593
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5594
|
+
|
|
5595
|
+
/* MIT license */
|
|
5596
|
+
var colorNames = __nccwpck_require__(4953);
|
|
5597
|
+
var swizzle = __nccwpck_require__(4421);
|
|
5598
|
+
var hasOwnProperty = Object.hasOwnProperty;
|
|
5599
|
+
|
|
5600
|
+
var reverseNames = Object.create(null);
|
|
5601
|
+
|
|
5602
|
+
// create a list of reverse color names
|
|
5603
|
+
for (var name in colorNames) {
|
|
5604
|
+
if (hasOwnProperty.call(colorNames, name)) {
|
|
5605
|
+
reverseNames[colorNames[name]] = name;
|
|
5606
|
+
}
|
|
5607
|
+
}
|
|
5608
|
+
|
|
5609
|
+
var cs = module.exports = {
|
|
5610
|
+
to: {},
|
|
5611
|
+
get: {}
|
|
5612
|
+
};
|
|
5613
|
+
|
|
5614
|
+
cs.get = function (string) {
|
|
5615
|
+
var prefix = string.substring(0, 3).toLowerCase();
|
|
5616
|
+
var val;
|
|
5617
|
+
var model;
|
|
5618
|
+
switch (prefix) {
|
|
5619
|
+
case 'hsl':
|
|
5620
|
+
val = cs.get.hsl(string);
|
|
5621
|
+
model = 'hsl';
|
|
5622
|
+
break;
|
|
5623
|
+
case 'hwb':
|
|
5624
|
+
val = cs.get.hwb(string);
|
|
5625
|
+
model = 'hwb';
|
|
5626
|
+
break;
|
|
5627
|
+
default:
|
|
5628
|
+
val = cs.get.rgb(string);
|
|
5629
|
+
model = 'rgb';
|
|
5630
|
+
break;
|
|
5631
|
+
}
|
|
5632
|
+
|
|
5633
|
+
if (!val) {
|
|
5634
|
+
return null;
|
|
5635
|
+
}
|
|
5636
|
+
|
|
5637
|
+
return {model: model, value: val};
|
|
5638
|
+
};
|
|
5639
|
+
|
|
5640
|
+
cs.get.rgb = function (string) {
|
|
5641
|
+
if (!string) {
|
|
5642
|
+
return null;
|
|
5643
|
+
}
|
|
5644
|
+
|
|
5645
|
+
var abbr = /^#([a-f0-9]{3,4})$/i;
|
|
5646
|
+
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
|
5647
|
+
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
5648
|
+
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
5649
|
+
var keyword = /^(\w+)$/;
|
|
5650
|
+
|
|
5651
|
+
var rgb = [0, 0, 0, 1];
|
|
5652
|
+
var match;
|
|
5653
|
+
var i;
|
|
5654
|
+
var hexAlpha;
|
|
5655
|
+
|
|
5656
|
+
if (match = string.match(hex)) {
|
|
5657
|
+
hexAlpha = match[2];
|
|
5658
|
+
match = match[1];
|
|
5659
|
+
|
|
5660
|
+
for (i = 0; i < 3; i++) {
|
|
5661
|
+
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
5662
|
+
var i2 = i * 2;
|
|
5663
|
+
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
|
5664
|
+
}
|
|
5665
|
+
|
|
5666
|
+
if (hexAlpha) {
|
|
5667
|
+
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
|
5668
|
+
}
|
|
5669
|
+
} else if (match = string.match(abbr)) {
|
|
5670
|
+
match = match[1];
|
|
5671
|
+
hexAlpha = match[3];
|
|
5672
|
+
|
|
5673
|
+
for (i = 0; i < 3; i++) {
|
|
5674
|
+
rgb[i] = parseInt(match[i] + match[i], 16);
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
if (hexAlpha) {
|
|
5678
|
+
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
5679
|
+
}
|
|
5680
|
+
} else if (match = string.match(rgba)) {
|
|
5681
|
+
for (i = 0; i < 3; i++) {
|
|
5682
|
+
rgb[i] = parseInt(match[i + 1], 0);
|
|
5683
|
+
}
|
|
5684
|
+
|
|
5685
|
+
if (match[4]) {
|
|
5686
|
+
if (match[5]) {
|
|
5687
|
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
5688
|
+
} else {
|
|
5689
|
+
rgb[3] = parseFloat(match[4]);
|
|
5690
|
+
}
|
|
5691
|
+
}
|
|
5692
|
+
} else if (match = string.match(per)) {
|
|
5693
|
+
for (i = 0; i < 3; i++) {
|
|
5694
|
+
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
|
5695
|
+
}
|
|
5696
|
+
|
|
5697
|
+
if (match[4]) {
|
|
5698
|
+
if (match[5]) {
|
|
5699
|
+
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
5700
|
+
} else {
|
|
5701
|
+
rgb[3] = parseFloat(match[4]);
|
|
5702
|
+
}
|
|
5703
|
+
}
|
|
5704
|
+
} else if (match = string.match(keyword)) {
|
|
5705
|
+
if (match[1] === 'transparent') {
|
|
5706
|
+
return [0, 0, 0, 0];
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5709
|
+
if (!hasOwnProperty.call(colorNames, match[1])) {
|
|
5710
|
+
return null;
|
|
5711
|
+
}
|
|
5712
|
+
|
|
5713
|
+
rgb = colorNames[match[1]];
|
|
5714
|
+
rgb[3] = 1;
|
|
5715
|
+
|
|
5716
|
+
return rgb;
|
|
5717
|
+
} else {
|
|
5718
|
+
return null;
|
|
5719
|
+
}
|
|
5720
|
+
|
|
5721
|
+
for (i = 0; i < 3; i++) {
|
|
5722
|
+
rgb[i] = clamp(rgb[i], 0, 255);
|
|
5723
|
+
}
|
|
5724
|
+
rgb[3] = clamp(rgb[3], 0, 1);
|
|
5725
|
+
|
|
5726
|
+
return rgb;
|
|
5727
|
+
};
|
|
5728
|
+
|
|
5729
|
+
cs.get.hsl = function (string) {
|
|
5730
|
+
if (!string) {
|
|
5731
|
+
return null;
|
|
5732
|
+
}
|
|
5733
|
+
|
|
5734
|
+
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
5735
|
+
var match = string.match(hsl);
|
|
5736
|
+
|
|
5737
|
+
if (match) {
|
|
5738
|
+
var alpha = parseFloat(match[4]);
|
|
5739
|
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
5740
|
+
var s = clamp(parseFloat(match[2]), 0, 100);
|
|
5741
|
+
var l = clamp(parseFloat(match[3]), 0, 100);
|
|
5742
|
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
5743
|
+
|
|
5744
|
+
return [h, s, l, a];
|
|
5745
|
+
}
|
|
5746
|
+
|
|
5747
|
+
return null;
|
|
5748
|
+
};
|
|
5749
|
+
|
|
5750
|
+
cs.get.hwb = function (string) {
|
|
5751
|
+
if (!string) {
|
|
5752
|
+
return null;
|
|
5753
|
+
}
|
|
5754
|
+
|
|
5755
|
+
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
5756
|
+
var match = string.match(hwb);
|
|
5757
|
+
|
|
5758
|
+
if (match) {
|
|
5759
|
+
var alpha = parseFloat(match[4]);
|
|
5760
|
+
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
5761
|
+
var w = clamp(parseFloat(match[2]), 0, 100);
|
|
5762
|
+
var b = clamp(parseFloat(match[3]), 0, 100);
|
|
5763
|
+
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
5764
|
+
return [h, w, b, a];
|
|
5765
|
+
}
|
|
5766
|
+
|
|
5767
|
+
return null;
|
|
5768
|
+
};
|
|
5769
|
+
|
|
5770
|
+
cs.to.hex = function () {
|
|
5771
|
+
var rgba = swizzle(arguments);
|
|
5772
|
+
|
|
5773
|
+
return (
|
|
5774
|
+
'#' +
|
|
5775
|
+
hexDouble(rgba[0]) +
|
|
5776
|
+
hexDouble(rgba[1]) +
|
|
5777
|
+
hexDouble(rgba[2]) +
|
|
5778
|
+
(rgba[3] < 1
|
|
5779
|
+
? (hexDouble(Math.round(rgba[3] * 255)))
|
|
5780
|
+
: '')
|
|
5781
|
+
);
|
|
5782
|
+
};
|
|
5783
|
+
|
|
5784
|
+
cs.to.rgb = function () {
|
|
5785
|
+
var rgba = swizzle(arguments);
|
|
5786
|
+
|
|
5787
|
+
return rgba.length < 4 || rgba[3] === 1
|
|
5788
|
+
? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
|
|
5789
|
+
: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
|
|
5790
|
+
};
|
|
5791
|
+
|
|
5792
|
+
cs.to.rgb.percent = function () {
|
|
5793
|
+
var rgba = swizzle(arguments);
|
|
5794
|
+
|
|
5795
|
+
var r = Math.round(rgba[0] / 255 * 100);
|
|
5796
|
+
var g = Math.round(rgba[1] / 255 * 100);
|
|
5797
|
+
var b = Math.round(rgba[2] / 255 * 100);
|
|
5798
|
+
|
|
5799
|
+
return rgba.length < 4 || rgba[3] === 1
|
|
5800
|
+
? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
|
|
5801
|
+
: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
|
5802
|
+
};
|
|
5803
|
+
|
|
5804
|
+
cs.to.hsl = function () {
|
|
5805
|
+
var hsla = swizzle(arguments);
|
|
5806
|
+
return hsla.length < 4 || hsla[3] === 1
|
|
5807
|
+
? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
|
|
5808
|
+
: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
|
5809
|
+
};
|
|
5810
|
+
|
|
5811
|
+
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
5812
|
+
// (hwb have alpha optional & 1 is default value)
|
|
5813
|
+
cs.to.hwb = function () {
|
|
5814
|
+
var hwba = swizzle(arguments);
|
|
5815
|
+
|
|
5816
|
+
var a = '';
|
|
5817
|
+
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
5818
|
+
a = ', ' + hwba[3];
|
|
5819
|
+
}
|
|
5820
|
+
|
|
5821
|
+
return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
|
|
5822
|
+
};
|
|
5823
|
+
|
|
5824
|
+
cs.to.keyword = function (rgb) {
|
|
5825
|
+
return reverseNames[rgb.slice(0, 3)];
|
|
5826
|
+
};
|
|
5827
|
+
|
|
5828
|
+
// helpers
|
|
5829
|
+
function clamp(num, min, max) {
|
|
5830
|
+
return Math.min(Math.max(min, num), max);
|
|
5831
|
+
}
|
|
5832
|
+
|
|
5833
|
+
function hexDouble(num) {
|
|
5834
|
+
var str = Math.round(num).toString(16).toUpperCase();
|
|
5835
|
+
return (str.length < 2) ? '0' + str : str;
|
|
5836
|
+
}
|
|
5837
|
+
|
|
5838
|
+
|
|
5839
|
+
/***/ }),
|
|
5840
|
+
|
|
5841
|
+
/***/ 8107:
|
|
5842
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5843
|
+
|
|
5844
|
+
"use strict";
|
|
5845
|
+
|
|
5846
|
+
|
|
5847
|
+
var color = __nccwpck_require__(1696)
|
|
5848
|
+
, hex = __nccwpck_require__(5143);
|
|
5849
|
+
|
|
5850
|
+
/**
|
|
5851
|
+
* Generate a color for a given name. But be reasonably smart about it by
|
|
5852
|
+
* understanding name spaces and coloring each namespace a bit lighter so they
|
|
5853
|
+
* still have the same base color as the root.
|
|
5854
|
+
*
|
|
5855
|
+
* @param {string} namespace The namespace
|
|
5856
|
+
* @param {string} [delimiter] The delimiter
|
|
5857
|
+
* @returns {string} color
|
|
5858
|
+
*/
|
|
5859
|
+
module.exports = function colorspace(namespace, delimiter) {
|
|
5860
|
+
var split = namespace.split(delimiter || ':');
|
|
5861
|
+
var base = hex(split[0]);
|
|
5862
|
+
|
|
5863
|
+
if (!split.length) return base;
|
|
5864
|
+
|
|
5865
|
+
for (var i = 0, l = split.length - 1; i < l; i++) {
|
|
5866
|
+
base = color(base)
|
|
5867
|
+
.mix(color(hex(split[i + 1])))
|
|
5868
|
+
.saturate(1)
|
|
5869
|
+
.hex();
|
|
5870
|
+
}
|
|
5871
|
+
|
|
5872
|
+
return base;
|
|
5873
|
+
};
|
|
5874
|
+
|
|
5875
|
+
|
|
5876
|
+
/***/ }),
|
|
5877
|
+
|
|
5878
|
+
/***/ 4618:
|
|
5433
5879
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
5434
5880
|
|
|
5435
5881
|
/* MIT license */
|
|
5436
|
-
var cssKeywords = __nccwpck_require__(
|
|
5882
|
+
var cssKeywords = __nccwpck_require__(8402);
|
|
5437
5883
|
|
|
5438
5884
|
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
|
5439
5885
|
// values that give correct `typeof` results).
|
|
@@ -6304,11 +6750,11 @@ convert.rgb.gray = function (rgb) {
|
|
|
6304
6750
|
|
|
6305
6751
|
/***/ }),
|
|
6306
6752
|
|
|
6307
|
-
/***/
|
|
6753
|
+
/***/ 192:
|
|
6308
6754
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
6309
6755
|
|
|
6310
|
-
var conversions = __nccwpck_require__(
|
|
6311
|
-
var route = __nccwpck_require__(
|
|
6756
|
+
var conversions = __nccwpck_require__(4618);
|
|
6757
|
+
var route = __nccwpck_require__(209);
|
|
6312
6758
|
|
|
6313
6759
|
var convert = {};
|
|
6314
6760
|
|
|
@@ -6389,170 +6835,10 @@ module.exports = convert;
|
|
|
6389
6835
|
|
|
6390
6836
|
/***/ }),
|
|
6391
6837
|
|
|
6392
|
-
/***/
|
|
6393
|
-
/***/ ((module) => {
|
|
6394
|
-
|
|
6395
|
-
"use strict";
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
module.exports = {
|
|
6399
|
-
"aliceblue": [240, 248, 255],
|
|
6400
|
-
"antiquewhite": [250, 235, 215],
|
|
6401
|
-
"aqua": [0, 255, 255],
|
|
6402
|
-
"aquamarine": [127, 255, 212],
|
|
6403
|
-
"azure": [240, 255, 255],
|
|
6404
|
-
"beige": [245, 245, 220],
|
|
6405
|
-
"bisque": [255, 228, 196],
|
|
6406
|
-
"black": [0, 0, 0],
|
|
6407
|
-
"blanchedalmond": [255, 235, 205],
|
|
6408
|
-
"blue": [0, 0, 255],
|
|
6409
|
-
"blueviolet": [138, 43, 226],
|
|
6410
|
-
"brown": [165, 42, 42],
|
|
6411
|
-
"burlywood": [222, 184, 135],
|
|
6412
|
-
"cadetblue": [95, 158, 160],
|
|
6413
|
-
"chartreuse": [127, 255, 0],
|
|
6414
|
-
"chocolate": [210, 105, 30],
|
|
6415
|
-
"coral": [255, 127, 80],
|
|
6416
|
-
"cornflowerblue": [100, 149, 237],
|
|
6417
|
-
"cornsilk": [255, 248, 220],
|
|
6418
|
-
"crimson": [220, 20, 60],
|
|
6419
|
-
"cyan": [0, 255, 255],
|
|
6420
|
-
"darkblue": [0, 0, 139],
|
|
6421
|
-
"darkcyan": [0, 139, 139],
|
|
6422
|
-
"darkgoldenrod": [184, 134, 11],
|
|
6423
|
-
"darkgray": [169, 169, 169],
|
|
6424
|
-
"darkgreen": [0, 100, 0],
|
|
6425
|
-
"darkgrey": [169, 169, 169],
|
|
6426
|
-
"darkkhaki": [189, 183, 107],
|
|
6427
|
-
"darkmagenta": [139, 0, 139],
|
|
6428
|
-
"darkolivegreen": [85, 107, 47],
|
|
6429
|
-
"darkorange": [255, 140, 0],
|
|
6430
|
-
"darkorchid": [153, 50, 204],
|
|
6431
|
-
"darkred": [139, 0, 0],
|
|
6432
|
-
"darksalmon": [233, 150, 122],
|
|
6433
|
-
"darkseagreen": [143, 188, 143],
|
|
6434
|
-
"darkslateblue": [72, 61, 139],
|
|
6435
|
-
"darkslategray": [47, 79, 79],
|
|
6436
|
-
"darkslategrey": [47, 79, 79],
|
|
6437
|
-
"darkturquoise": [0, 206, 209],
|
|
6438
|
-
"darkviolet": [148, 0, 211],
|
|
6439
|
-
"deeppink": [255, 20, 147],
|
|
6440
|
-
"deepskyblue": [0, 191, 255],
|
|
6441
|
-
"dimgray": [105, 105, 105],
|
|
6442
|
-
"dimgrey": [105, 105, 105],
|
|
6443
|
-
"dodgerblue": [30, 144, 255],
|
|
6444
|
-
"firebrick": [178, 34, 34],
|
|
6445
|
-
"floralwhite": [255, 250, 240],
|
|
6446
|
-
"forestgreen": [34, 139, 34],
|
|
6447
|
-
"fuchsia": [255, 0, 255],
|
|
6448
|
-
"gainsboro": [220, 220, 220],
|
|
6449
|
-
"ghostwhite": [248, 248, 255],
|
|
6450
|
-
"gold": [255, 215, 0],
|
|
6451
|
-
"goldenrod": [218, 165, 32],
|
|
6452
|
-
"gray": [128, 128, 128],
|
|
6453
|
-
"green": [0, 128, 0],
|
|
6454
|
-
"greenyellow": [173, 255, 47],
|
|
6455
|
-
"grey": [128, 128, 128],
|
|
6456
|
-
"honeydew": [240, 255, 240],
|
|
6457
|
-
"hotpink": [255, 105, 180],
|
|
6458
|
-
"indianred": [205, 92, 92],
|
|
6459
|
-
"indigo": [75, 0, 130],
|
|
6460
|
-
"ivory": [255, 255, 240],
|
|
6461
|
-
"khaki": [240, 230, 140],
|
|
6462
|
-
"lavender": [230, 230, 250],
|
|
6463
|
-
"lavenderblush": [255, 240, 245],
|
|
6464
|
-
"lawngreen": [124, 252, 0],
|
|
6465
|
-
"lemonchiffon": [255, 250, 205],
|
|
6466
|
-
"lightblue": [173, 216, 230],
|
|
6467
|
-
"lightcoral": [240, 128, 128],
|
|
6468
|
-
"lightcyan": [224, 255, 255],
|
|
6469
|
-
"lightgoldenrodyellow": [250, 250, 210],
|
|
6470
|
-
"lightgray": [211, 211, 211],
|
|
6471
|
-
"lightgreen": [144, 238, 144],
|
|
6472
|
-
"lightgrey": [211, 211, 211],
|
|
6473
|
-
"lightpink": [255, 182, 193],
|
|
6474
|
-
"lightsalmon": [255, 160, 122],
|
|
6475
|
-
"lightseagreen": [32, 178, 170],
|
|
6476
|
-
"lightskyblue": [135, 206, 250],
|
|
6477
|
-
"lightslategray": [119, 136, 153],
|
|
6478
|
-
"lightslategrey": [119, 136, 153],
|
|
6479
|
-
"lightsteelblue": [176, 196, 222],
|
|
6480
|
-
"lightyellow": [255, 255, 224],
|
|
6481
|
-
"lime": [0, 255, 0],
|
|
6482
|
-
"limegreen": [50, 205, 50],
|
|
6483
|
-
"linen": [250, 240, 230],
|
|
6484
|
-
"magenta": [255, 0, 255],
|
|
6485
|
-
"maroon": [128, 0, 0],
|
|
6486
|
-
"mediumaquamarine": [102, 205, 170],
|
|
6487
|
-
"mediumblue": [0, 0, 205],
|
|
6488
|
-
"mediumorchid": [186, 85, 211],
|
|
6489
|
-
"mediumpurple": [147, 112, 219],
|
|
6490
|
-
"mediumseagreen": [60, 179, 113],
|
|
6491
|
-
"mediumslateblue": [123, 104, 238],
|
|
6492
|
-
"mediumspringgreen": [0, 250, 154],
|
|
6493
|
-
"mediumturquoise": [72, 209, 204],
|
|
6494
|
-
"mediumvioletred": [199, 21, 133],
|
|
6495
|
-
"midnightblue": [25, 25, 112],
|
|
6496
|
-
"mintcream": [245, 255, 250],
|
|
6497
|
-
"mistyrose": [255, 228, 225],
|
|
6498
|
-
"moccasin": [255, 228, 181],
|
|
6499
|
-
"navajowhite": [255, 222, 173],
|
|
6500
|
-
"navy": [0, 0, 128],
|
|
6501
|
-
"oldlace": [253, 245, 230],
|
|
6502
|
-
"olive": [128, 128, 0],
|
|
6503
|
-
"olivedrab": [107, 142, 35],
|
|
6504
|
-
"orange": [255, 165, 0],
|
|
6505
|
-
"orangered": [255, 69, 0],
|
|
6506
|
-
"orchid": [218, 112, 214],
|
|
6507
|
-
"palegoldenrod": [238, 232, 170],
|
|
6508
|
-
"palegreen": [152, 251, 152],
|
|
6509
|
-
"paleturquoise": [175, 238, 238],
|
|
6510
|
-
"palevioletred": [219, 112, 147],
|
|
6511
|
-
"papayawhip": [255, 239, 213],
|
|
6512
|
-
"peachpuff": [255, 218, 185],
|
|
6513
|
-
"peru": [205, 133, 63],
|
|
6514
|
-
"pink": [255, 192, 203],
|
|
6515
|
-
"plum": [221, 160, 221],
|
|
6516
|
-
"powderblue": [176, 224, 230],
|
|
6517
|
-
"purple": [128, 0, 128],
|
|
6518
|
-
"rebeccapurple": [102, 51, 153],
|
|
6519
|
-
"red": [255, 0, 0],
|
|
6520
|
-
"rosybrown": [188, 143, 143],
|
|
6521
|
-
"royalblue": [65, 105, 225],
|
|
6522
|
-
"saddlebrown": [139, 69, 19],
|
|
6523
|
-
"salmon": [250, 128, 114],
|
|
6524
|
-
"sandybrown": [244, 164, 96],
|
|
6525
|
-
"seagreen": [46, 139, 87],
|
|
6526
|
-
"seashell": [255, 245, 238],
|
|
6527
|
-
"sienna": [160, 82, 45],
|
|
6528
|
-
"silver": [192, 192, 192],
|
|
6529
|
-
"skyblue": [135, 206, 235],
|
|
6530
|
-
"slateblue": [106, 90, 205],
|
|
6531
|
-
"slategray": [112, 128, 144],
|
|
6532
|
-
"slategrey": [112, 128, 144],
|
|
6533
|
-
"snow": [255, 250, 250],
|
|
6534
|
-
"springgreen": [0, 255, 127],
|
|
6535
|
-
"steelblue": [70, 130, 180],
|
|
6536
|
-
"tan": [210, 180, 140],
|
|
6537
|
-
"teal": [0, 128, 128],
|
|
6538
|
-
"thistle": [216, 191, 216],
|
|
6539
|
-
"tomato": [255, 99, 71],
|
|
6540
|
-
"turquoise": [64, 224, 208],
|
|
6541
|
-
"violet": [238, 130, 238],
|
|
6542
|
-
"wheat": [245, 222, 179],
|
|
6543
|
-
"white": [255, 255, 255],
|
|
6544
|
-
"whitesmoke": [245, 245, 245],
|
|
6545
|
-
"yellow": [255, 255, 0],
|
|
6546
|
-
"yellowgreen": [154, 205, 50]
|
|
6547
|
-
};
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
/***/ }),
|
|
6551
|
-
|
|
6552
|
-
/***/ 4200:
|
|
6838
|
+
/***/ 209:
|
|
6553
6839
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
6554
6840
|
|
|
6555
|
-
var conversions = __nccwpck_require__(
|
|
6841
|
+
var conversions = __nccwpck_require__(4618);
|
|
6556
6842
|
|
|
6557
6843
|
/*
|
|
6558
6844
|
this function routes a model to all other models.
|
|
@@ -6653,7 +6939,7 @@ module.exports = function (fromModel) {
|
|
|
6653
6939
|
|
|
6654
6940
|
/***/ }),
|
|
6655
6941
|
|
|
6656
|
-
/***/
|
|
6942
|
+
/***/ 8402:
|
|
6657
6943
|
/***/ ((module) => {
|
|
6658
6944
|
|
|
6659
6945
|
"use strict";
|
|
@@ -6811,292 +7097,6 @@ module.exports = {
|
|
|
6811
7097
|
};
|
|
6812
7098
|
|
|
6813
7099
|
|
|
6814
|
-
/***/ }),
|
|
6815
|
-
|
|
6816
|
-
/***/ 9407:
|
|
6817
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
6818
|
-
|
|
6819
|
-
/* MIT license */
|
|
6820
|
-
var colorNames = __nccwpck_require__(4953);
|
|
6821
|
-
var swizzle = __nccwpck_require__(4421);
|
|
6822
|
-
var hasOwnProperty = Object.hasOwnProperty;
|
|
6823
|
-
|
|
6824
|
-
var reverseNames = Object.create(null);
|
|
6825
|
-
|
|
6826
|
-
// create a list of reverse color names
|
|
6827
|
-
for (var name in colorNames) {
|
|
6828
|
-
if (hasOwnProperty.call(colorNames, name)) {
|
|
6829
|
-
reverseNames[colorNames[name]] = name;
|
|
6830
|
-
}
|
|
6831
|
-
}
|
|
6832
|
-
|
|
6833
|
-
var cs = module.exports = {
|
|
6834
|
-
to: {},
|
|
6835
|
-
get: {}
|
|
6836
|
-
};
|
|
6837
|
-
|
|
6838
|
-
cs.get = function (string) {
|
|
6839
|
-
var prefix = string.substring(0, 3).toLowerCase();
|
|
6840
|
-
var val;
|
|
6841
|
-
var model;
|
|
6842
|
-
switch (prefix) {
|
|
6843
|
-
case 'hsl':
|
|
6844
|
-
val = cs.get.hsl(string);
|
|
6845
|
-
model = 'hsl';
|
|
6846
|
-
break;
|
|
6847
|
-
case 'hwb':
|
|
6848
|
-
val = cs.get.hwb(string);
|
|
6849
|
-
model = 'hwb';
|
|
6850
|
-
break;
|
|
6851
|
-
default:
|
|
6852
|
-
val = cs.get.rgb(string);
|
|
6853
|
-
model = 'rgb';
|
|
6854
|
-
break;
|
|
6855
|
-
}
|
|
6856
|
-
|
|
6857
|
-
if (!val) {
|
|
6858
|
-
return null;
|
|
6859
|
-
}
|
|
6860
|
-
|
|
6861
|
-
return {model: model, value: val};
|
|
6862
|
-
};
|
|
6863
|
-
|
|
6864
|
-
cs.get.rgb = function (string) {
|
|
6865
|
-
if (!string) {
|
|
6866
|
-
return null;
|
|
6867
|
-
}
|
|
6868
|
-
|
|
6869
|
-
var abbr = /^#([a-f0-9]{3,4})$/i;
|
|
6870
|
-
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
|
6871
|
-
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
6872
|
-
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
6873
|
-
var keyword = /^(\w+)$/;
|
|
6874
|
-
|
|
6875
|
-
var rgb = [0, 0, 0, 1];
|
|
6876
|
-
var match;
|
|
6877
|
-
var i;
|
|
6878
|
-
var hexAlpha;
|
|
6879
|
-
|
|
6880
|
-
if (match = string.match(hex)) {
|
|
6881
|
-
hexAlpha = match[2];
|
|
6882
|
-
match = match[1];
|
|
6883
|
-
|
|
6884
|
-
for (i = 0; i < 3; i++) {
|
|
6885
|
-
// https://jsperf.com/slice-vs-substr-vs-substring-methods-long-string/19
|
|
6886
|
-
var i2 = i * 2;
|
|
6887
|
-
rgb[i] = parseInt(match.slice(i2, i2 + 2), 16);
|
|
6888
|
-
}
|
|
6889
|
-
|
|
6890
|
-
if (hexAlpha) {
|
|
6891
|
-
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
|
6892
|
-
}
|
|
6893
|
-
} else if (match = string.match(abbr)) {
|
|
6894
|
-
match = match[1];
|
|
6895
|
-
hexAlpha = match[3];
|
|
6896
|
-
|
|
6897
|
-
for (i = 0; i < 3; i++) {
|
|
6898
|
-
rgb[i] = parseInt(match[i] + match[i], 16);
|
|
6899
|
-
}
|
|
6900
|
-
|
|
6901
|
-
if (hexAlpha) {
|
|
6902
|
-
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
6903
|
-
}
|
|
6904
|
-
} else if (match = string.match(rgba)) {
|
|
6905
|
-
for (i = 0; i < 3; i++) {
|
|
6906
|
-
rgb[i] = parseInt(match[i + 1], 0);
|
|
6907
|
-
}
|
|
6908
|
-
|
|
6909
|
-
if (match[4]) {
|
|
6910
|
-
if (match[5]) {
|
|
6911
|
-
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
6912
|
-
} else {
|
|
6913
|
-
rgb[3] = parseFloat(match[4]);
|
|
6914
|
-
}
|
|
6915
|
-
}
|
|
6916
|
-
} else if (match = string.match(per)) {
|
|
6917
|
-
for (i = 0; i < 3; i++) {
|
|
6918
|
-
rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
|
|
6919
|
-
}
|
|
6920
|
-
|
|
6921
|
-
if (match[4]) {
|
|
6922
|
-
if (match[5]) {
|
|
6923
|
-
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
6924
|
-
} else {
|
|
6925
|
-
rgb[3] = parseFloat(match[4]);
|
|
6926
|
-
}
|
|
6927
|
-
}
|
|
6928
|
-
} else if (match = string.match(keyword)) {
|
|
6929
|
-
if (match[1] === 'transparent') {
|
|
6930
|
-
return [0, 0, 0, 0];
|
|
6931
|
-
}
|
|
6932
|
-
|
|
6933
|
-
if (!hasOwnProperty.call(colorNames, match[1])) {
|
|
6934
|
-
return null;
|
|
6935
|
-
}
|
|
6936
|
-
|
|
6937
|
-
rgb = colorNames[match[1]];
|
|
6938
|
-
rgb[3] = 1;
|
|
6939
|
-
|
|
6940
|
-
return rgb;
|
|
6941
|
-
} else {
|
|
6942
|
-
return null;
|
|
6943
|
-
}
|
|
6944
|
-
|
|
6945
|
-
for (i = 0; i < 3; i++) {
|
|
6946
|
-
rgb[i] = clamp(rgb[i], 0, 255);
|
|
6947
|
-
}
|
|
6948
|
-
rgb[3] = clamp(rgb[3], 0, 1);
|
|
6949
|
-
|
|
6950
|
-
return rgb;
|
|
6951
|
-
};
|
|
6952
|
-
|
|
6953
|
-
cs.get.hsl = function (string) {
|
|
6954
|
-
if (!string) {
|
|
6955
|
-
return null;
|
|
6956
|
-
}
|
|
6957
|
-
|
|
6958
|
-
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
6959
|
-
var match = string.match(hsl);
|
|
6960
|
-
|
|
6961
|
-
if (match) {
|
|
6962
|
-
var alpha = parseFloat(match[4]);
|
|
6963
|
-
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
6964
|
-
var s = clamp(parseFloat(match[2]), 0, 100);
|
|
6965
|
-
var l = clamp(parseFloat(match[3]), 0, 100);
|
|
6966
|
-
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
6967
|
-
|
|
6968
|
-
return [h, s, l, a];
|
|
6969
|
-
}
|
|
6970
|
-
|
|
6971
|
-
return null;
|
|
6972
|
-
};
|
|
6973
|
-
|
|
6974
|
-
cs.get.hwb = function (string) {
|
|
6975
|
-
if (!string) {
|
|
6976
|
-
return null;
|
|
6977
|
-
}
|
|
6978
|
-
|
|
6979
|
-
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
6980
|
-
var match = string.match(hwb);
|
|
6981
|
-
|
|
6982
|
-
if (match) {
|
|
6983
|
-
var alpha = parseFloat(match[4]);
|
|
6984
|
-
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
|
|
6985
|
-
var w = clamp(parseFloat(match[2]), 0, 100);
|
|
6986
|
-
var b = clamp(parseFloat(match[3]), 0, 100);
|
|
6987
|
-
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
6988
|
-
return [h, w, b, a];
|
|
6989
|
-
}
|
|
6990
|
-
|
|
6991
|
-
return null;
|
|
6992
|
-
};
|
|
6993
|
-
|
|
6994
|
-
cs.to.hex = function () {
|
|
6995
|
-
var rgba = swizzle(arguments);
|
|
6996
|
-
|
|
6997
|
-
return (
|
|
6998
|
-
'#' +
|
|
6999
|
-
hexDouble(rgba[0]) +
|
|
7000
|
-
hexDouble(rgba[1]) +
|
|
7001
|
-
hexDouble(rgba[2]) +
|
|
7002
|
-
(rgba[3] < 1
|
|
7003
|
-
? (hexDouble(Math.round(rgba[3] * 255)))
|
|
7004
|
-
: '')
|
|
7005
|
-
);
|
|
7006
|
-
};
|
|
7007
|
-
|
|
7008
|
-
cs.to.rgb = function () {
|
|
7009
|
-
var rgba = swizzle(arguments);
|
|
7010
|
-
|
|
7011
|
-
return rgba.length < 4 || rgba[3] === 1
|
|
7012
|
-
? 'rgb(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ')'
|
|
7013
|
-
: 'rgba(' + Math.round(rgba[0]) + ', ' + Math.round(rgba[1]) + ', ' + Math.round(rgba[2]) + ', ' + rgba[3] + ')';
|
|
7014
|
-
};
|
|
7015
|
-
|
|
7016
|
-
cs.to.rgb.percent = function () {
|
|
7017
|
-
var rgba = swizzle(arguments);
|
|
7018
|
-
|
|
7019
|
-
var r = Math.round(rgba[0] / 255 * 100);
|
|
7020
|
-
var g = Math.round(rgba[1] / 255 * 100);
|
|
7021
|
-
var b = Math.round(rgba[2] / 255 * 100);
|
|
7022
|
-
|
|
7023
|
-
return rgba.length < 4 || rgba[3] === 1
|
|
7024
|
-
? 'rgb(' + r + '%, ' + g + '%, ' + b + '%)'
|
|
7025
|
-
: 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + rgba[3] + ')';
|
|
7026
|
-
};
|
|
7027
|
-
|
|
7028
|
-
cs.to.hsl = function () {
|
|
7029
|
-
var hsla = swizzle(arguments);
|
|
7030
|
-
return hsla.length < 4 || hsla[3] === 1
|
|
7031
|
-
? 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)'
|
|
7032
|
-
: 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + hsla[3] + ')';
|
|
7033
|
-
};
|
|
7034
|
-
|
|
7035
|
-
// hwb is a bit different than rgb(a) & hsl(a) since there is no alpha specific syntax
|
|
7036
|
-
// (hwb have alpha optional & 1 is default value)
|
|
7037
|
-
cs.to.hwb = function () {
|
|
7038
|
-
var hwba = swizzle(arguments);
|
|
7039
|
-
|
|
7040
|
-
var a = '';
|
|
7041
|
-
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
7042
|
-
a = ', ' + hwba[3];
|
|
7043
|
-
}
|
|
7044
|
-
|
|
7045
|
-
return 'hwb(' + hwba[0] + ', ' + hwba[1] + '%, ' + hwba[2] + '%' + a + ')';
|
|
7046
|
-
};
|
|
7047
|
-
|
|
7048
|
-
cs.to.keyword = function (rgb) {
|
|
7049
|
-
return reverseNames[rgb.slice(0, 3)];
|
|
7050
|
-
};
|
|
7051
|
-
|
|
7052
|
-
// helpers
|
|
7053
|
-
function clamp(num, min, max) {
|
|
7054
|
-
return Math.min(Math.max(min, num), max);
|
|
7055
|
-
}
|
|
7056
|
-
|
|
7057
|
-
function hexDouble(num) {
|
|
7058
|
-
var str = Math.round(num).toString(16).toUpperCase();
|
|
7059
|
-
return (str.length < 2) ? '0' + str : str;
|
|
7060
|
-
}
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
/***/ }),
|
|
7064
|
-
|
|
7065
|
-
/***/ 8107:
|
|
7066
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
7067
|
-
|
|
7068
|
-
"use strict";
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
var color = __nccwpck_require__(1696)
|
|
7072
|
-
, hex = __nccwpck_require__(5143);
|
|
7073
|
-
|
|
7074
|
-
/**
|
|
7075
|
-
* Generate a color for a given name. But be reasonably smart about it by
|
|
7076
|
-
* understanding name spaces and coloring each namespace a bit lighter so they
|
|
7077
|
-
* still have the same base color as the root.
|
|
7078
|
-
*
|
|
7079
|
-
* @param {string} namespace The namespace
|
|
7080
|
-
* @param {string} [delimiter] The delimiter
|
|
7081
|
-
* @returns {string} color
|
|
7082
|
-
*/
|
|
7083
|
-
module.exports = function colorspace(namespace, delimiter) {
|
|
7084
|
-
var split = namespace.split(delimiter || ':');
|
|
7085
|
-
var base = hex(split[0]);
|
|
7086
|
-
|
|
7087
|
-
if (!split.length) return base;
|
|
7088
|
-
|
|
7089
|
-
for (var i = 0, l = split.length - 1; i < l; i++) {
|
|
7090
|
-
base = color(base)
|
|
7091
|
-
.mix(color(hex(split[i + 1])))
|
|
7092
|
-
.saturate(1)
|
|
7093
|
-
.hex();
|
|
7094
|
-
}
|
|
7095
|
-
|
|
7096
|
-
return base;
|
|
7097
|
-
};
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
7100
|
/***/ }),
|
|
7101
7101
|
|
|
7102
7102
|
/***/ 1696:
|
|
@@ -7106,7 +7106,7 @@ module.exports = function colorspace(namespace, delimiter) {
|
|
|
7106
7106
|
|
|
7107
7107
|
|
|
7108
7108
|
var colorString = __nccwpck_require__(9407);
|
|
7109
|
-
var convert = __nccwpck_require__(
|
|
7109
|
+
var convert = __nccwpck_require__(192);
|
|
7110
7110
|
|
|
7111
7111
|
var _slice = [].slice;
|
|
7112
7112
|
|
|
@@ -38946,7 +38946,7 @@ module.exports = require("zlib");
|
|
|
38946
38946
|
/***/ ((module) => {
|
|
38947
38947
|
|
|
38948
38948
|
"use strict";
|
|
38949
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.50","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib","test":"node tools/jest.js","coverage":"npm run test -- --coverage"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.16.50","@abtnode/auth":"1.16.50","@abtnode/certificate-manager":"1.16.50","@abtnode/constant":"1.16.50","@abtnode/cron":"1.16.50","@abtnode/db-cache":"1.16.50","@abtnode/docker-utils":"1.16.50","@abtnode/logger":"1.16.50","@abtnode/models":"1.16.50","@abtnode/queue":"1.16.50","@abtnode/rbac":"1.16.50","@abtnode/router-provider":"1.16.50","@abtnode/static-server":"1.16.50","@abtnode/timemachine":"1.16.50","@abtnode/util":"1.16.50","@aigne/aigne-hub":"^0.8.6","@arcblock/did":"1.24.0","@arcblock/did-connect-js":"1.24.0","@arcblock/did-ext":"1.24.0","@arcblock/did-motif":"^1.1.14","@arcblock/did-util":"1.24.0","@arcblock/event-hub":"1.24.0","@arcblock/jwt":"1.24.0","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"1.24.0","@arcblock/vc":"1.24.0","@blocklet/constant":"1.16.50","@blocklet/did-space-js":"^1.1.
|
|
38949
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@abtnode/core","publishConfig":{"access":"public"},"version":"1.16.50","description":"","main":"lib/index.js","files":["lib"],"scripts":{"lint":"eslint tests lib --ignore-pattern \'tests/assets/*\'","lint:fix":"eslint --fix tests lib","test":"node tools/jest.js","coverage":"npm run test -- --coverage"},"keywords":[],"author":"wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)","license":"Apache-2.0","dependencies":{"@abtnode/analytics":"1.16.50","@abtnode/auth":"1.16.50","@abtnode/certificate-manager":"1.16.50","@abtnode/constant":"1.16.50","@abtnode/cron":"1.16.50","@abtnode/db-cache":"1.16.50","@abtnode/docker-utils":"1.16.50","@abtnode/logger":"1.16.50","@abtnode/models":"1.16.50","@abtnode/queue":"1.16.50","@abtnode/rbac":"1.16.50","@abtnode/router-provider":"1.16.50","@abtnode/static-server":"1.16.50","@abtnode/timemachine":"1.16.50","@abtnode/util":"1.16.50","@aigne/aigne-hub":"^0.8.6","@arcblock/did":"1.24.0","@arcblock/did-connect-js":"1.24.0","@arcblock/did-ext":"1.24.0","@arcblock/did-motif":"^1.1.14","@arcblock/did-util":"1.24.0","@arcblock/event-hub":"1.24.0","@arcblock/jwt":"1.24.0","@arcblock/pm2-events":"^0.0.5","@arcblock/validator":"1.24.0","@arcblock/vc":"1.24.0","@blocklet/constant":"1.16.50","@blocklet/did-space-js":"^1.1.22","@blocklet/env":"1.16.50","@blocklet/error":"^0.2.5","@blocklet/meta":"1.16.50","@blocklet/resolver":"1.16.50","@blocklet/sdk":"1.16.50","@blocklet/server-js":"1.16.50","@blocklet/store":"1.16.50","@blocklet/theme":"^3.1.34","@fidm/x509":"^1.2.1","@ocap/mcrypto":"1.24.0","@ocap/util":"1.24.0","@ocap/wallet":"1.24.0","@slack/webhook":"^5.0.4","archiver":"^7.0.1","axios":"^1.7.9","axon":"^2.0.3","chalk":"^4.1.2","cross-spawn":"^7.0.3","dayjs":"^1.11.13","deep-diff":"^1.0.2","detect-port":"^1.5.1","envfile":"^7.1.0","escape-string-regexp":"^4.0.0","fast-glob":"^3.3.2","filesize":"^10.1.1","flat":"^5.0.2","fs-extra":"^11.2.0","get-port":"^5.1.1","hasha":"^5.2.2","is-base64":"^1.1.0","is-cidr":"4","is-ip":"3","is-url":"^1.2.4","joi":"17.12.2","joi-extension-semver":"^5.0.0","js-yaml":"^4.1.0","kill-port":"^2.0.1","lodash":"^4.17.21","node-stream-zip":"^1.15.0","p-all":"^3.0.0","p-limit":"^3.1.0","p-map":"^4.0.0","p-retry":"^4.6.2","p-wait-for":"^3.2.0","private-ip":"^2.3.4","rate-limiter-flexible":"^5.0.5","read-last-lines":"^1.8.0","semver":"^7.6.3","sequelize":"^6.35.0","shelljs":"^0.8.5","slugify":"^1.6.6","ssri":"^8.0.1","stream-throttle":"^0.1.3","stream-to-promise":"^3.0.0","systeminformation":"^5.23.3","tail":"^2.2.4","tar":"^6.1.11","transliteration":"^2.3.5","ua-parser-js":"^1.0.2","ufo":"^1.5.3","uuid":"^11.1.0","valid-url":"^1.0.9","which":"^2.0.2","xbytes":"^1.8.0"},"devDependencies":{"expand-tilde":"^2.0.2","express":"^4.18.2","jest":"^29.7.0","unzipper":"^0.10.11"},"gitHead":"e5764f753181ed6a7c615cd4fc6682aacf0cb7cd"}');
|
|
38950
38950
|
|
|
38951
38951
|
/***/ }),
|
|
38952
38952
|
|
|
@@ -51,7 +51,7 @@ const init = ({ states, teamManager }) => {
|
|
|
51
51
|
const { event } = data;
|
|
52
52
|
const { type, source, object_id: objectId, object_type: objectType } = event;
|
|
53
53
|
|
|
54
|
-
const request = event.data;
|
|
54
|
+
const request = { ...event.data, $eventName: type };
|
|
55
55
|
logger.info('create webhook event', { type, source, request });
|
|
56
56
|
|
|
57
57
|
const { webhookEventState } = await teamManager.getWebhookState(appDid);
|
package/lib/states/user.js
CHANGED
|
@@ -11,12 +11,12 @@ const { updateConnectedAccount } = require('@abtnode/util/lib/user');
|
|
|
11
11
|
const { LOGIN_PROVIDER } = require('@blocklet/constant');
|
|
12
12
|
const { CustomError } = require('@blocklet/error');
|
|
13
13
|
const { Joi } = require('@arcblock/validator');
|
|
14
|
-
|
|
15
14
|
const logger = require('@abtnode/logger')('@abtnode/core:states:user');
|
|
16
15
|
|
|
17
16
|
const { validateOwner } = require('../util');
|
|
18
17
|
const { loginSchema, disconnectAccountSchema } = require('../validators/user');
|
|
19
18
|
const ExtendBase = require('./base');
|
|
19
|
+
const { isInDashboard, isUserPrivacyEnabled, isAdminUser } = require('../util/verify-user-private');
|
|
20
20
|
|
|
21
21
|
const isNullOrUndefined = (x) => x === undefined || x === null;
|
|
22
22
|
|
|
@@ -962,6 +962,8 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
962
962
|
|
|
963
963
|
const { user: contextUser } = context;
|
|
964
964
|
|
|
965
|
+
const contextUserDid = contextUser?.userInfo?.did || contextUser?.did;
|
|
966
|
+
|
|
965
967
|
await this._validateUsersExist([targetDid]);
|
|
966
968
|
|
|
967
969
|
const isFollowers = type === 'followers';
|
|
@@ -977,15 +979,15 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
977
979
|
const userDids = [...new Set(result.list.map((follow) => (isFollowers ? follow.followerDid : follow.userDid)))];
|
|
978
980
|
const users = await this.find({
|
|
979
981
|
where: { did: { [Op.in]: userDids } },
|
|
980
|
-
attributes: ['did', 'fullName', 'avatar'
|
|
982
|
+
attributes: ['did', 'fullName', 'avatar'],
|
|
981
983
|
});
|
|
982
984
|
userMap = new Map(users.map((user) => [user.did, user]));
|
|
983
985
|
}
|
|
984
986
|
|
|
985
987
|
// 准备关注状态映射
|
|
986
988
|
let followingStatusMap = {};
|
|
987
|
-
if (includeFollowStatus &&
|
|
988
|
-
if (
|
|
989
|
+
if (includeFollowStatus && contextUserDid) {
|
|
990
|
+
if (contextUserDid !== targetDid) {
|
|
989
991
|
// 查询当前用户对列表中所有用户的关注状态
|
|
990
992
|
const targetUserDids = result.list.map((follow) => (isFollowers ? follow.followerDid : follow.userDid));
|
|
991
993
|
followingStatusMap = await this.isFollowing(contextUser.did, targetUserDids);
|
|
@@ -1008,8 +1010,8 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1008
1010
|
}
|
|
1009
1011
|
|
|
1010
1012
|
// 添加关注状态
|
|
1011
|
-
if (includeFollowStatus &&
|
|
1012
|
-
if (
|
|
1013
|
+
if (includeFollowStatus && contextUserDid) {
|
|
1014
|
+
if (contextUserDid !== targetDid) {
|
|
1013
1015
|
// 如果查看的是别人的关注列表,需要添加是否已关注的信息
|
|
1014
1016
|
enrichedFollow.isFollowing = followingStatusMap[userDid] || false;
|
|
1015
1017
|
} else if (isFollowers) {
|
|
@@ -1087,7 +1089,7 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1087
1089
|
* @param {string[]} userDids - 用户的 DID 数组
|
|
1088
1090
|
* @returns {Promise<{[userDid: string]: {followers: number, following: number}}>} - 返回对象,键为用户DID,值为统计信息
|
|
1089
1091
|
*/
|
|
1090
|
-
async getFollowStats(userDids = []) {
|
|
1092
|
+
async getFollowStats({ userDids = [], teamDid, prefix }, context = {}) {
|
|
1091
1093
|
if (!this.userFollowers || !Array.isArray(userDids) || userDids.length === 0) {
|
|
1092
1094
|
return userDids.reduce(
|
|
1093
1095
|
(acc, userDid) => ({
|
|
@@ -1099,6 +1101,20 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1099
1101
|
}
|
|
1100
1102
|
|
|
1101
1103
|
try {
|
|
1104
|
+
const { user: contextUser } = context;
|
|
1105
|
+
const contextUserDid = contextUser?.userInfo?.did || contextUser?.did;
|
|
1106
|
+
|
|
1107
|
+
const privacyMap = new Map();
|
|
1108
|
+
if (!(isInDashboard(teamDid, prefix, context) && isAdminUser(context))) {
|
|
1109
|
+
// 批量获取用户隐私设置
|
|
1110
|
+
const usersInfo = await this.find({ did: { $in: userDids } }, { did: 1, extra: 1 });
|
|
1111
|
+
|
|
1112
|
+
usersInfo.forEach((userInfo) => {
|
|
1113
|
+
const isPrivate = isUserPrivacyEnabled(userInfo);
|
|
1114
|
+
privacyMap.set(userInfo.did, isPrivate);
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1102
1118
|
// 使用原生 SQL 查询进行批量统计,提高性能
|
|
1103
1119
|
const followersQuery = `
|
|
1104
1120
|
SELECT "userDid", COUNT(*) as count
|
|
@@ -1123,15 +1139,25 @@ SELECT did,inviter,generation FROM UserTree`.trim();
|
|
|
1123
1139
|
const followersMap = new Map(followersResults.map((row) => [row.userDid, Number(row.count)]));
|
|
1124
1140
|
const followingMap = new Map(followingResults.map((row) => [row.followerDid, Number(row.count)]));
|
|
1125
1141
|
|
|
1126
|
-
// 使用 Object.fromEntries
|
|
1142
|
+
// 使用 Object.fromEntries 优化结果对象构建,并进行隐私判断
|
|
1127
1143
|
const result = Object.fromEntries(
|
|
1128
|
-
userDids.map((userDid) =>
|
|
1129
|
-
userDid
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1144
|
+
userDids.map((userDid) => {
|
|
1145
|
+
const isPrivate = privacyMap.get(userDid) || false;
|
|
1146
|
+
const isOwner = contextUserDid === userDid;
|
|
1147
|
+
|
|
1148
|
+
// 如果用户设置了隐私且查看者不是用户本人,返回 0
|
|
1149
|
+
if (isPrivate && !isOwner) {
|
|
1150
|
+
return [userDid, { followers: 0, following: 0 }];
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
return [
|
|
1154
|
+
userDid,
|
|
1155
|
+
{
|
|
1156
|
+
followers: followersMap.get(userDid) || 0,
|
|
1157
|
+
following: followingMap.get(userDid) || 0,
|
|
1158
|
+
},
|
|
1159
|
+
];
|
|
1160
|
+
})
|
|
1135
1161
|
);
|
|
1136
1162
|
|
|
1137
1163
|
return result;
|
package/lib/team/manager.js
CHANGED
|
@@ -226,10 +226,14 @@ class TeamManager extends EventEmitter {
|
|
|
226
226
|
userDids.map((did) => userState.getUser(did, { includePassports: true, enableConnectedAccount: true }))
|
|
227
227
|
);
|
|
228
228
|
|
|
229
|
-
const validUsers = queryUsers.filter((user) => {
|
|
229
|
+
const validUsers = queryUsers.filter((user, index) => {
|
|
230
|
+
if (!user) {
|
|
231
|
+
logger.warn('receiver is not exist: ', { userDid: userDids[index] });
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
230
234
|
const { passports = [] } = user;
|
|
231
235
|
// 如果用户没有 passport,或者 有一个 passport 没有过期,则返回 true
|
|
232
|
-
if (!passports
|
|
236
|
+
if (!passports?.length || passports.some((x) => !this.isPassportExpired(x))) {
|
|
233
237
|
return true;
|
|
234
238
|
}
|
|
235
239
|
logger.warn(`user's passports are all expired: ${user.did}`);
|
|
@@ -480,7 +484,7 @@ class TeamManager extends EventEmitter {
|
|
|
480
484
|
...(actorInfo ? { actorInfo } : {}),
|
|
481
485
|
options: typeof payload.options === 'object' && payload.options !== null ? payload.options : {},
|
|
482
486
|
});
|
|
483
|
-
logger.info('notification has been added to the push queue', { notificationId: doc.id });
|
|
487
|
+
logger.info('notification has been added to the push queue', { teamDid, notificationId: doc.id });
|
|
484
488
|
} catch (error) {
|
|
485
489
|
logger.error('Failed to emit notification events', { error });
|
|
486
490
|
throw new Error(`Failed to emit notification events: ${error.message}`);
|
|
@@ -538,14 +542,14 @@ class TeamManager extends EventEmitter {
|
|
|
538
542
|
|
|
539
543
|
const doc = await this._createNotificationDoc(notificationState, payload, receivers, source, isServices, teamDid);
|
|
540
544
|
|
|
541
|
-
logger.info('notification created successfully', { notificationId: doc.id });
|
|
545
|
+
logger.info('notification created successfully', { teamDid, notificationId: doc.id });
|
|
542
546
|
|
|
543
547
|
const defaultChannel = this._getDefaultChannels(isServices, source);
|
|
544
548
|
await this._emitNotificationEvents(doc, payload, receivers, teamDid, isServices, defaultChannel, actorInfo);
|
|
545
549
|
|
|
546
550
|
return doc;
|
|
547
551
|
} catch (error) {
|
|
548
|
-
logger.error('notification create failed', { error });
|
|
552
|
+
logger.error('notification create failed', { teamDid, error });
|
|
549
553
|
throw error;
|
|
550
554
|
}
|
|
551
555
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { CustomError } = require('@blocklet/error');
|
|
2
|
+
|
|
3
|
+
const validateUserRolePassport = ({ role, passports }) => {
|
|
4
|
+
if (!Array.isArray(passports)) {
|
|
5
|
+
throw new CustomError(400, 'Invalid passports: must be an array');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!role || typeof role !== 'string') {
|
|
9
|
+
throw new CustomError(400, 'Invalid role: must be a non-empty string');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const filterPassports = passports.filter((x) => x.status === 'valid' && x.role === role);
|
|
13
|
+
|
|
14
|
+
if (filterPassports.length === 0) {
|
|
15
|
+
throw new CustomError(400, `No valid passport found: you don't have the required role "${role}".`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const isValid = filterPassports.every((x) => x.expirationDate);
|
|
19
|
+
if (isValid) {
|
|
20
|
+
throw new CustomError(
|
|
21
|
+
400,
|
|
22
|
+
`The passport for role "${role}" is only temporary and cannot be used to invite new members.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports = { validateUserRolePassport };
|
|
@@ -6,10 +6,12 @@ const {
|
|
|
6
6
|
WELLKNOWN_BLOCKLET_USER_PATH,
|
|
7
7
|
} = require('@abtnode/constant');
|
|
8
8
|
|
|
9
|
-
const { parseURL } = require('ufo');
|
|
9
|
+
const { parseURL, joinURL } = require('ufo');
|
|
10
10
|
|
|
11
11
|
const isAdminPath = (pathname) => pathname.startsWith(WELLKNOWN_BLOCKLET_ADMIN_PATH);
|
|
12
12
|
const isUserCenterPath = (pathname) => pathname.startsWith(WELLKNOWN_BLOCKLET_USER_PATH);
|
|
13
|
+
const isServerDashboardPath = (pathname, prefix, teamDid) =>
|
|
14
|
+
!teamDid ? false : pathname.startsWith(joinURL(prefix, 'blocklets', teamDid));
|
|
13
15
|
|
|
14
16
|
const getEndpoint = (context) => {
|
|
15
17
|
const { pathname } = parseURL(context.referrer);
|
|
@@ -54,4 +56,4 @@ const validateOperator = (context, operatorDid) => {
|
|
|
54
56
|
}
|
|
55
57
|
};
|
|
56
58
|
|
|
57
|
-
module.exports = { validateOperator, getEndpoint, isUserCenterPath, isAdminPath };
|
|
59
|
+
module.exports = { validateOperator, getEndpoint, isUserCenterPath, isAdminPath, isServerDashboardPath };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { ROLES, SERVER_ROLES, WELLKNOWN_BLOCKLET_USER_PATH } = require('@abtnode/constant');
|
|
2
|
+
const get = require('lodash/get');
|
|
3
|
+
const { joinURL } = require('ufo');
|
|
4
|
+
const logger = require('@abtnode/logger')('@abtnode/core:util:verify-user-private');
|
|
5
|
+
|
|
6
|
+
const { getEndpoint, isServerDashboardPath, isAdminPath } = require('./verify-access-key-user');
|
|
7
|
+
|
|
8
|
+
const USER_FOLLOWERS_PATH = joinURL(WELLKNOWN_BLOCKLET_USER_PATH, 'user-followers');
|
|
9
|
+
|
|
10
|
+
const isAdminUser = (context) => {
|
|
11
|
+
const { user = {} } = context || {};
|
|
12
|
+
const role = user.userInfo?.role || user.role;
|
|
13
|
+
return [ROLES.ADMIN, ROLES.OWNER, SERVER_ROLES.BLOCKLET_ADMIN, SERVER_ROLES.BLOCKLET_OWNER].includes(role);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const isUserPrivacyEnabled = (userInfo) => {
|
|
17
|
+
// 在 server 的dashboard 和 service 的 dashboard 中,不需要判断
|
|
18
|
+
const privacyInfo = get(userInfo, 'extra.privacy', {});
|
|
19
|
+
return get(privacyInfo, USER_FOLLOWERS_PATH, false);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const isInDashboard = (teamDid, prefix, context = {}) => {
|
|
23
|
+
const { user = {}, hostname, referrer } = context || {};
|
|
24
|
+
if (user.role === SERVER_ROLES.BLOCKLET_SDK || !teamDid) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!hostname || !referrer) {
|
|
29
|
+
logger.warn('Missing hostname or referrer context');
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const pathname = getEndpoint(context);
|
|
35
|
+
return isAdminPath(pathname) || isServerDashboardPath(pathname, prefix, teamDid);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
logger.warn('Failed to check if in dashboard', { error });
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = { isInDashboard, isUserPrivacyEnabled, isAdminUser };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.51-beta-
|
|
6
|
+
"version": "1.16.51-beta-20250905-023351-70af144b",
|
|
7
7
|
"description": "",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -19,21 +19,21 @@
|
|
|
19
19
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@abtnode/analytics": "1.16.51-beta-
|
|
23
|
-
"@abtnode/auth": "1.16.51-beta-
|
|
24
|
-
"@abtnode/certificate-manager": "1.16.51-beta-
|
|
25
|
-
"@abtnode/constant": "1.16.51-beta-
|
|
26
|
-
"@abtnode/cron": "1.16.51-beta-
|
|
27
|
-
"@abtnode/db-cache": "1.16.51-beta-
|
|
28
|
-
"@abtnode/docker-utils": "1.16.51-beta-
|
|
29
|
-
"@abtnode/logger": "1.16.51-beta-
|
|
30
|
-
"@abtnode/models": "1.16.51-beta-
|
|
31
|
-
"@abtnode/queue": "1.16.51-beta-
|
|
32
|
-
"@abtnode/rbac": "1.16.51-beta-
|
|
33
|
-
"@abtnode/router-provider": "1.16.51-beta-
|
|
34
|
-
"@abtnode/static-server": "1.16.51-beta-
|
|
35
|
-
"@abtnode/timemachine": "1.16.51-beta-
|
|
36
|
-
"@abtnode/util": "1.16.51-beta-
|
|
22
|
+
"@abtnode/analytics": "1.16.51-beta-20250905-023351-70af144b",
|
|
23
|
+
"@abtnode/auth": "1.16.51-beta-20250905-023351-70af144b",
|
|
24
|
+
"@abtnode/certificate-manager": "1.16.51-beta-20250905-023351-70af144b",
|
|
25
|
+
"@abtnode/constant": "1.16.51-beta-20250905-023351-70af144b",
|
|
26
|
+
"@abtnode/cron": "1.16.51-beta-20250905-023351-70af144b",
|
|
27
|
+
"@abtnode/db-cache": "1.16.51-beta-20250905-023351-70af144b",
|
|
28
|
+
"@abtnode/docker-utils": "1.16.51-beta-20250905-023351-70af144b",
|
|
29
|
+
"@abtnode/logger": "1.16.51-beta-20250905-023351-70af144b",
|
|
30
|
+
"@abtnode/models": "1.16.51-beta-20250905-023351-70af144b",
|
|
31
|
+
"@abtnode/queue": "1.16.51-beta-20250905-023351-70af144b",
|
|
32
|
+
"@abtnode/rbac": "1.16.51-beta-20250905-023351-70af144b",
|
|
33
|
+
"@abtnode/router-provider": "1.16.51-beta-20250905-023351-70af144b",
|
|
34
|
+
"@abtnode/static-server": "1.16.51-beta-20250905-023351-70af144b",
|
|
35
|
+
"@abtnode/timemachine": "1.16.51-beta-20250905-023351-70af144b",
|
|
36
|
+
"@abtnode/util": "1.16.51-beta-20250905-023351-70af144b",
|
|
37
37
|
"@aigne/aigne-hub": "^0.8.6",
|
|
38
38
|
"@arcblock/did": "1.24.0",
|
|
39
39
|
"@arcblock/did-connect-js": "1.24.0",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"@arcblock/pm2-events": "^0.0.5",
|
|
46
46
|
"@arcblock/validator": "1.24.0",
|
|
47
47
|
"@arcblock/vc": "1.24.0",
|
|
48
|
-
"@blocklet/constant": "1.16.51-beta-
|
|
49
|
-
"@blocklet/did-space-js": "^1.1.
|
|
50
|
-
"@blocklet/env": "1.16.51-beta-
|
|
48
|
+
"@blocklet/constant": "1.16.51-beta-20250905-023351-70af144b",
|
|
49
|
+
"@blocklet/did-space-js": "^1.1.22",
|
|
50
|
+
"@blocklet/env": "1.16.51-beta-20250905-023351-70af144b",
|
|
51
51
|
"@blocklet/error": "^0.2.5",
|
|
52
|
-
"@blocklet/meta": "1.16.51-beta-
|
|
53
|
-
"@blocklet/resolver": "1.16.51-beta-
|
|
54
|
-
"@blocklet/sdk": "1.16.51-beta-
|
|
55
|
-
"@blocklet/server-js": "1.16.51-beta-
|
|
56
|
-
"@blocklet/store": "1.16.51-beta-
|
|
57
|
-
"@blocklet/theme": "^3.1.
|
|
52
|
+
"@blocklet/meta": "1.16.51-beta-20250905-023351-70af144b",
|
|
53
|
+
"@blocklet/resolver": "1.16.51-beta-20250905-023351-70af144b",
|
|
54
|
+
"@blocklet/sdk": "1.16.51-beta-20250905-023351-70af144b",
|
|
55
|
+
"@blocklet/server-js": "1.16.51-beta-20250905-023351-70af144b",
|
|
56
|
+
"@blocklet/store": "1.16.51-beta-20250905-023351-70af144b",
|
|
57
|
+
"@blocklet/theme": "^3.1.34",
|
|
58
58
|
"@fidm/x509": "^1.2.1",
|
|
59
59
|
"@ocap/mcrypto": "1.24.0",
|
|
60
60
|
"@ocap/util": "1.24.0",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"jest": "^29.7.0",
|
|
119
119
|
"unzipper": "^0.10.11"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "d19892df7ce4f08a4a7a3ce96dff3bc6b01925ad"
|
|
122
122
|
}
|