@attraccess/plugins-backend-sdk 1.11.0-beta.1 → 1.11.0-beta.3
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/LICENSE.md +8 -2
- package/package.json +3 -3
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -1
- package/src/lib/auth-decorator.d.ts +4 -3
- package/src/lib/auth-decorator.js.map +1 -1
- package/src/lib/auth.types.d.ts +2 -0
- package/src/lib/plugin-audit.d.ts +14 -1
- package/src/lib/plugin-audit.js +6 -1
- package/src/lib/plugin-audit.js.map +1 -1
- package/src/lib/plugin-backend-module.d.ts +9 -0
- package/src/lib/plugin-ble-fake.d.ts +8 -0
- package/src/lib/plugin-ble-fake.js +20 -2
- package/src/lib/plugin-ble-fake.js.map +1 -1
- package/src/lib/plugin-ble-notification-stream.d.ts +2 -0
- package/src/lib/plugin-ble-notification-stream.js +4 -0
- package/src/lib/plugin-ble-notification-stream.js.map +1 -1
- package/src/lib/plugin-ble-session-engine.d.ts +39 -7
- package/src/lib/plugin-ble-session-engine.js +73 -18
- package/src/lib/plugin-ble-session-engine.js.map +1 -1
- package/src/lib/plugin-ble.d.ts +9 -0
- package/src/lib/plugin-ble.js +3 -0
- package/src/lib/plugin-ble.js.map +1 -1
- package/src/lib/plugin-cards.d.ts +95 -0
- package/src/lib/plugin-cards.js +48 -0
- package/src/lib/plugin-cards.js.map +1 -0
- package/src/lib/plugin-context.d.ts +12 -0
- package/src/lib/plugin-context.js.map +1 -1
- package/src/lib/plugin-license.d.ts +39 -0
- package/src/lib/plugin-license.js +13 -0
- package/src/lib/plugin-license.js.map +1 -0
- package/src/lib/plugin-permissions.d.ts +65 -0
- package/src/lib/plugin-permissions.js +107 -0
- package/src/lib/plugin-permissions.js.map +1 -0
- package/src/lib/plugin-resource-access.d.ts +2 -1
- package/src/lib/plugin.interface.d.ts +3 -1
- package/src/lib/plugin.interface.js +3 -0
- package/src/lib/plugin.interface.js.map +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { SystemPermission } from '@attraccess/shared';
|
|
2
|
+
import type { PluginLocalizedLabel } from './plugin-notifications';
|
|
3
|
+
/**
|
|
4
|
+
* RBAC permission keys a plugin declares through `PluginBackendModule.permissions`. The host registers them in the
|
|
5
|
+
* permission catalog at load time, so they appear in the role editor and the API-token picker, and the plugin
|
|
6
|
+
* guards its routes with them like core keys (`@Auth(PERMISSIONS.keys['acme.widgets.read'])`).
|
|
7
|
+
*
|
|
8
|
+
* Not to be confused with the manifest `permissions` field, which lists host capabilities ({@link PluginPermission}).
|
|
9
|
+
*/
|
|
10
|
+
/** Lowercase dotted segments, at least two, for example `acme.widgets.read`. */
|
|
11
|
+
export declare const PLUGIN_PERMISSION_KEY_PATTERN: RegExp;
|
|
12
|
+
export declare const PLUGIN_PERMISSION_KEY_MAX_LENGTH = 100;
|
|
13
|
+
/** Namespaces of the core catalog. A plugin key must not start with one of them. */
|
|
14
|
+
export declare const RESERVED_PERMISSION_NAMESPACES: readonly ["resources.", "users.", "system.", "billing."];
|
|
15
|
+
/** The system roles a plugin may grant its keys to on first registration. */
|
|
16
|
+
export declare const PLUGIN_PERMISSION_DEFAULT_ROLES: readonly ["user", "resource-manager", "user-manager", "billing-manager", "system-admin", "administrator"];
|
|
17
|
+
export type PluginPermissionDefaultRole = (typeof PLUGIN_PERMISSION_DEFAULT_ROLES)[number];
|
|
18
|
+
export declare const PLUGIN_PERMISSION_LIMITS: {
|
|
19
|
+
readonly permissionsPerPlugin: 64;
|
|
20
|
+
readonly labelLength: 120;
|
|
21
|
+
readonly descriptionLength: 500;
|
|
22
|
+
};
|
|
23
|
+
declare const pluginPermissionKeyBrand: unique symbol;
|
|
24
|
+
/** A key returned by {@link definePluginPermissions}. Only declared keys carry the brand. */
|
|
25
|
+
export type PluginPermissionKey<K extends string = string> = K & {
|
|
26
|
+
readonly [pluginPermissionKeyBrand]: true;
|
|
27
|
+
};
|
|
28
|
+
/** What `@Auth`, `@AuthAny`, `@SessionAuth` and `resourceAccess.hasPermission` accept. */
|
|
29
|
+
export type PermissionKey = SystemPermission | PluginPermissionKey;
|
|
30
|
+
export interface PluginPermissionDefinition<K extends string = string> {
|
|
31
|
+
readonly key: K;
|
|
32
|
+
readonly label: PluginLocalizedLabel;
|
|
33
|
+
readonly description: PluginLocalizedLabel;
|
|
34
|
+
/**
|
|
35
|
+
* System roles that receive the key when the host registers it for the first time. Later boots never grant it
|
|
36
|
+
* again, so an administrator's removal sticks. `administrator` always holds every plugin key, listed or not.
|
|
37
|
+
*/
|
|
38
|
+
readonly defaultRoles?: readonly PluginPermissionDefaultRole[];
|
|
39
|
+
}
|
|
40
|
+
export interface PluginPermissionsDeclaration {
|
|
41
|
+
/** Group label in the role editor. Defaults to the plugin name from the manifest. */
|
|
42
|
+
readonly category?: PluginLocalizedLabel;
|
|
43
|
+
readonly permissions: readonly PluginPermissionDefinition[];
|
|
44
|
+
}
|
|
45
|
+
export type DefinedPluginPermissions<P extends readonly PluginPermissionDefinition[]> = PluginPermissionsDeclaration & {
|
|
46
|
+
readonly permissions: P;
|
|
47
|
+
/** The declared keys, typed for `@Auth` and friends. */
|
|
48
|
+
readonly keys: {
|
|
49
|
+
readonly [D in P[number] as D['key']]: PluginPermissionKey<D['key']>;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/** Declares a plugin's permission keys and returns them typed for the auth decorators. */
|
|
53
|
+
export declare function definePluginPermissions<const P extends readonly PluginPermissionDefinition[]>(declaration: {
|
|
54
|
+
category?: PluginLocalizedLabel;
|
|
55
|
+
permissions: P;
|
|
56
|
+
}): DefinedPluginPermissions<P>;
|
|
57
|
+
/** Why `key` cannot be a plugin permission key, or null when its shape is valid. */
|
|
58
|
+
export declare function pluginPermissionKeyError(key: unknown): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Validates a plugin's permission declaration and returns it unchanged. Throws a descriptive error on any
|
|
61
|
+
* violation; the host quarantines the plugin in that case. Collisions with core keys and with keys of other
|
|
62
|
+
* plugins are checked by the host.
|
|
63
|
+
*/
|
|
64
|
+
export declare function validatePluginPermissionsDeclaration(declaration: unknown): PluginPermissionsDeclaration;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLUGIN_PERMISSION_LIMITS = exports.PLUGIN_PERMISSION_DEFAULT_ROLES = exports.RESERVED_PERMISSION_NAMESPACES = exports.PLUGIN_PERMISSION_KEY_MAX_LENGTH = exports.PLUGIN_PERMISSION_KEY_PATTERN = void 0;
|
|
4
|
+
exports.definePluginPermissions = definePluginPermissions;
|
|
5
|
+
exports.pluginPermissionKeyError = pluginPermissionKeyError;
|
|
6
|
+
exports.validatePluginPermissionsDeclaration = validatePluginPermissionsDeclaration;
|
|
7
|
+
/**
|
|
8
|
+
* RBAC permission keys a plugin declares through `PluginBackendModule.permissions`. The host registers them in the
|
|
9
|
+
* permission catalog at load time, so they appear in the role editor and the API-token picker, and the plugin
|
|
10
|
+
* guards its routes with them like core keys (`@Auth(PERMISSIONS.keys['acme.widgets.read'])`).
|
|
11
|
+
*
|
|
12
|
+
* Not to be confused with the manifest `permissions` field, which lists host capabilities ({@link PluginPermission}).
|
|
13
|
+
*/
|
|
14
|
+
/** Lowercase dotted segments, at least two, for example `acme.widgets.read`. */
|
|
15
|
+
exports.PLUGIN_PERMISSION_KEY_PATTERN = /^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/;
|
|
16
|
+
exports.PLUGIN_PERMISSION_KEY_MAX_LENGTH = 100;
|
|
17
|
+
/** Namespaces of the core catalog. A plugin key must not start with one of them. */
|
|
18
|
+
exports.RESERVED_PERMISSION_NAMESPACES = ['resources.', 'users.', 'system.', 'billing.'];
|
|
19
|
+
/** The system roles a plugin may grant its keys to on first registration. */
|
|
20
|
+
exports.PLUGIN_PERMISSION_DEFAULT_ROLES = [
|
|
21
|
+
'user',
|
|
22
|
+
'resource-manager',
|
|
23
|
+
'user-manager',
|
|
24
|
+
'billing-manager',
|
|
25
|
+
'system-admin',
|
|
26
|
+
'administrator',
|
|
27
|
+
];
|
|
28
|
+
exports.PLUGIN_PERMISSION_LIMITS = {
|
|
29
|
+
permissionsPerPlugin: 64,
|
|
30
|
+
labelLength: 120,
|
|
31
|
+
descriptionLength: 500,
|
|
32
|
+
};
|
|
33
|
+
/** Declares a plugin's permission keys and returns them typed for the auth decorators. */
|
|
34
|
+
function definePluginPermissions(declaration) {
|
|
35
|
+
const keys = Object.fromEntries(declaration.permissions.map((permission) => [permission.key, permission.key]));
|
|
36
|
+
return Object.freeze(Object.assign(Object.assign({}, declaration), { keys: Object.freeze(keys) }));
|
|
37
|
+
}
|
|
38
|
+
// Realm-agnostic: plugin code may build its declaration in another realm, whose Object.prototype differs.
|
|
39
|
+
const isPlainRecord = (value) => {
|
|
40
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
41
|
+
return false;
|
|
42
|
+
const prototype = Object.getPrototypeOf(value);
|
|
43
|
+
return prototype === null || Object.getPrototypeOf(prototype) === null;
|
|
44
|
+
};
|
|
45
|
+
function validateLocalized(where, value, maxLength) {
|
|
46
|
+
if (!isPlainRecord(value))
|
|
47
|
+
throw new Error(`${where} must be an object with "en" and "de"`);
|
|
48
|
+
for (const locale of ['en', 'de']) {
|
|
49
|
+
const text = value[locale];
|
|
50
|
+
if (typeof text !== 'string' || text.trim().length === 0 || text.length > maxLength)
|
|
51
|
+
throw new Error(`${where}.${locale} must be 1-${maxLength} characters`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Why `key` cannot be a plugin permission key, or null when its shape is valid. */
|
|
55
|
+
function pluginPermissionKeyError(key) {
|
|
56
|
+
if (typeof key !== 'string' ||
|
|
57
|
+
key.length > exports.PLUGIN_PERMISSION_KEY_MAX_LENGTH ||
|
|
58
|
+
!exports.PLUGIN_PERMISSION_KEY_PATTERN.test(key))
|
|
59
|
+
return `must match ${exports.PLUGIN_PERMISSION_KEY_PATTERN.source} and be at most ${exports.PLUGIN_PERMISSION_KEY_MAX_LENGTH} characters`;
|
|
60
|
+
const reserved = exports.RESERVED_PERMISSION_NAMESPACES.find((namespace) => key.startsWith(namespace));
|
|
61
|
+
if (reserved)
|
|
62
|
+
return `must not use the reserved core namespace "${reserved}"`;
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validates a plugin's permission declaration and returns it unchanged. Throws a descriptive error on any
|
|
67
|
+
* violation; the host quarantines the plugin in that case. Collisions with core keys and with keys of other
|
|
68
|
+
* plugins are checked by the host.
|
|
69
|
+
*/
|
|
70
|
+
function validatePluginPermissionsDeclaration(declaration) {
|
|
71
|
+
if (!isPlainRecord(declaration))
|
|
72
|
+
throw new Error('Plugin permissions must be a plain object');
|
|
73
|
+
if (declaration.category !== undefined)
|
|
74
|
+
validateLocalized('Plugin permissions category', declaration.category, exports.PLUGIN_PERMISSION_LIMITS.labelLength);
|
|
75
|
+
const permissions = declaration.permissions;
|
|
76
|
+
if (!Array.isArray(permissions) || permissions.length === 0)
|
|
77
|
+
throw new Error('Plugin permissions: permissions must be a non-empty array');
|
|
78
|
+
if (permissions.length > exports.PLUGIN_PERMISSION_LIMITS.permissionsPerPlugin)
|
|
79
|
+
throw new Error(`Plugin permissions: at most ${exports.PLUGIN_PERMISSION_LIMITS.permissionsPerPlugin} keys`);
|
|
80
|
+
const seen = new Set();
|
|
81
|
+
for (const entry of permissions) {
|
|
82
|
+
if (!isPlainRecord(entry))
|
|
83
|
+
throw new Error('Plugin permission: each entry must be a plain object');
|
|
84
|
+
const key = entry.key;
|
|
85
|
+
const keyError = pluginPermissionKeyError(key);
|
|
86
|
+
if (keyError)
|
|
87
|
+
throw new Error(`Plugin permission "${String(key)}": key ${keyError}`);
|
|
88
|
+
const where = `Plugin permission "${key}"`;
|
|
89
|
+
if (seen.has(key))
|
|
90
|
+
throw new Error(`${where}: declared twice`);
|
|
91
|
+
seen.add(key);
|
|
92
|
+
for (const property of Object.keys(entry))
|
|
93
|
+
if (!['key', 'label', 'description', 'defaultRoles'].includes(property))
|
|
94
|
+
throw new Error(`${where}: unknown property "${property}"`);
|
|
95
|
+
validateLocalized(`${where}: label`, entry.label, exports.PLUGIN_PERMISSION_LIMITS.labelLength);
|
|
96
|
+
validateLocalized(`${where}: description`, entry.description, exports.PLUGIN_PERMISSION_LIMITS.descriptionLength);
|
|
97
|
+
if (entry.defaultRoles !== undefined) {
|
|
98
|
+
if (!Array.isArray(entry.defaultRoles))
|
|
99
|
+
throw new Error(`${where}: defaultRoles must be an array`);
|
|
100
|
+
for (const role of entry.defaultRoles)
|
|
101
|
+
if (!exports.PLUGIN_PERMISSION_DEFAULT_ROLES.includes(role))
|
|
102
|
+
throw new Error(`${where}: default role "${String(role)}" is not a system role (${exports.PLUGIN_PERMISSION_DEFAULT_ROLES.join(', ')})`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return declaration;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=plugin-permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-permissions.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin-permissions.ts"],"names":[],"mappings":";;;AAqEA,0DAMC;AAmBD,4DAUC;AAOD,oFAiCC;AA7ID;;;;;;GAMG;AAEH,gFAAgF;AACnE,QAAA,6BAA6B,GAAG,uCAAuC,CAAC;AAExE,QAAA,gCAAgC,GAAG,GAAG,CAAC;AAEpD,oFAAoF;AACvE,QAAA,8BAA8B,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAU,CAAC;AAEvG,6EAA6E;AAChE,QAAA,+BAA+B,GAAG;IAC7C,MAAM;IACN,kBAAkB;IAClB,cAAc;IACd,iBAAiB;IACjB,cAAc;IACd,eAAe;CACP,CAAC;AAIE,QA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G,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,YAAY;gBACnC,IAAI,CAAE,uCAAsD,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACzE,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,mBAAmB,MAAM,CAAC,IAAI,CAAC,2BAA2B,uCAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAChH,CAAC;QACR,CAAC;IACH,CAAC;IACD,OAAO,WAAsD,CAAC;AAChE,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PermissionKey } from './plugin-permissions';
|
|
1
2
|
/** Result of {@link PluginResourceAccessContext.canStart}. */
|
|
2
3
|
export interface PluginCanStartResult {
|
|
3
4
|
/** The user may start a session on their own right now (introduction valid, no mandatory supervision). */
|
|
@@ -71,7 +72,7 @@ export interface PluginResourceAccessContext {
|
|
|
71
72
|
*/
|
|
72
73
|
canSeeUsageAttribution(principal: PluginAccessPrincipal, resourceId: number): Promise<boolean>;
|
|
73
74
|
/** Whether the user holds the RBAC permission (e.g. `resources.update`), limited to a request's scope. */
|
|
74
|
-
hasPermission(principal: PluginAccessPrincipal, permission:
|
|
75
|
+
hasPermission(principal: PluginAccessPrincipal, permission: PermissionKey): Promise<boolean>;
|
|
75
76
|
/**
|
|
76
77
|
* Ids of resources the user is introduced to in the sense of canStart's introduction rule:
|
|
77
78
|
* valid, not retraining-blocked direct or group introduction, introducer/maintainer role, or `resources.update`.
|
|
@@ -142,7 +142,9 @@ export declare enum PluginPermission {
|
|
|
142
142
|
/** Send in-app, push and email notifications to users via notifications.dispatch(). */
|
|
143
143
|
SEND_NOTIFICATIONS = "SEND_NOTIFICATIONS",
|
|
144
144
|
/** Use the Bluetooth radio of administrator-approved Attractap readers through context.ble, limited to the plugin's own BLE profiles. */
|
|
145
|
-
BLE_TRANSPORT = "BLE_TRANSPORT"
|
|
145
|
+
BLE_TRANSPORT = "BLE_TRANSPORT",
|
|
146
|
+
/** Authenticate NFC cards held to the plugin's own devices through context.cards. The plugin never sees card keys. */
|
|
147
|
+
CARD_AUTHENTICATION = "CARD_AUTHENTICATION"
|
|
146
148
|
}
|
|
147
149
|
/**
|
|
148
150
|
* Human-readable description of each permission, surfaced to admins and plugin
|
|
@@ -57,6 +57,8 @@ var PluginPermission;
|
|
|
57
57
|
PluginPermission["SEND_NOTIFICATIONS"] = "SEND_NOTIFICATIONS";
|
|
58
58
|
/** Use the Bluetooth radio of administrator-approved Attractap readers through context.ble, limited to the plugin's own BLE profiles. */
|
|
59
59
|
PluginPermission["BLE_TRANSPORT"] = "BLE_TRANSPORT";
|
|
60
|
+
/** Authenticate NFC cards held to the plugin's own devices through context.cards. The plugin never sees card keys. */
|
|
61
|
+
PluginPermission["CARD_AUTHENTICATION"] = "CARD_AUTHENTICATION";
|
|
60
62
|
})(PluginPermission || (exports.PluginPermission = PluginPermission = {}));
|
|
61
63
|
/**
|
|
62
64
|
* Human-readable description of each permission, surfaced to admins and plugin
|
|
@@ -77,6 +79,7 @@ exports.PLUGIN_PERMISSION_DESCRIPTIONS = {
|
|
|
77
79
|
[PluginPermission.ACCESS_HOOKS]: 'Ask users for confirmation or block resource session starts through pre-start hooks.',
|
|
78
80
|
[PluginPermission.SEND_NOTIFICATIONS]: 'Send notifications to users (in-app, push and email) under plugin-declared notification categories.',
|
|
79
81
|
[PluginPermission.BLE_TRANSPORT]: 'Use the Bluetooth radio of Attractap readers that an administrator opened for plugins, limited to the BLE profiles this plugin registers.',
|
|
82
|
+
[PluginPermission.CARD_AUTHENTICATION]: "Authenticate NFC cards held to the plugin's own devices with the Attraccess card keys. The plugin receives the card and its owner, never the keys.",
|
|
80
83
|
};
|
|
81
84
|
/**
|
|
82
85
|
* Returns true when the given string is a known PluginPermission value.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.interface.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin.interface.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plugin.interface.js","sourceRoot":"","sources":["../../../../../libs/plugins-backend-sdk/src/lib/plugin.interface.ts"],"names":[],"mappings":";;;AA2LA,gDAEC;AA3LD,IAAY,WAkBX;AAlBD,WAAY,WAAW;IACrB,gEAAiD,CAAA;IACjD,4DAA6C,CAAA;IAC7C,oGAAoG;IACpG,0DAA2C,CAAA;IAC3C,wFAAwF;IACxF,kEAAmD,CAAA;IACnD,qEAAqE;IACrE,gFAAiE,CAAA;IACjE,kEAAkE;IAClE,sFAAuE,CAAA;IACvE,uEAAuE;IACvE,4EAA6D,CAAA;IAC7D;;;OAGG;IACH,gFAAiE,CAAA;AACnE,CAAC,EAlBW,WAAW,2BAAX,WAAW,QAkBtB;AAmGD;;;;GAIG;AACH,IAAY,gBA+BX;AA/BD,WAAY,gBAAgB;IAC1B,wDAAwD;IACxD,6CAAyB,CAAA;IACzB,sEAAsE;IACtE,yDAAqC,CAAA;IACrC,8DAA8D;IAC9D,mDAA+B,CAAA;IAC/B,0DAA0D;IAC1D,uDAAmC,CAAA;IACnC,wEAAwE;IACxE,+CAA2B,CAAA;IAC3B,4EAA4E;IAC5E,mDAA+B,CAAA;IAC/B,mEAAmE;IACnE,qEAAiD,CAAA;IACjD,gGAAgG;IAChG,+DAA2C,CAAA;IAC3C,0EAA0E;IAC1E,mDAA+B,CAAA;IAC/B,qFAAqF;IACrF,qDAAiC,CAAA;IACjC,iEAAiE;IACjE,2CAAuB,CAAA;IACvB,yFAAyF;IACzF,iDAA6B,CAAA;IAC7B,uFAAuF;IACvF,6DAAyC,CAAA;IACzC,yIAAyI;IACzI,mDAA+B,CAAA;IAC/B,sHAAsH;IACtH,+DAA2C,CAAA;AAC7C,CAAC,EA/BW,gBAAgB,gCAAhB,gBAAgB,QA+B3B;AAED;;;GAGG;AACU,QAAA,8BAA8B,GAAqC;IAC9E,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,uCAAuC;IACtE,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EACjC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