@coopenomics/extension-kit 2026.9.14 → 2026.9.16-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +8 -2
- package/dist/index.d.cts +13 -2
- package/dist/index.d.mts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.mjs +9 -4
- package/dist/sync/index.cjs +2 -2
- package/dist/sync/index.mjs +2 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -21,10 +21,14 @@ const moment__default = /*#__PURE__*/_interopDefaultCompat(moment);
|
|
|
21
21
|
const moment__default$1 = /*#__PURE__*/_interopDefaultCompat(moment$1);
|
|
22
22
|
const crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
|
|
23
23
|
|
|
24
|
+
const ROLES_DENY_SELF_KEY = "roles_deny_self";
|
|
24
25
|
function AuthRoles(roles, options = {}) {
|
|
25
26
|
const self = options.self ?? [];
|
|
26
27
|
const args = self.length ? `roles: ${JSON.stringify(roles)}, self: ${JSON.stringify(self)}` : `roles: ${JSON.stringify(roles)}`;
|
|
27
|
-
|
|
28
|
+
const decorators = [common.SetMetadata("roles", roles), graphql.Directive(`@auth(${args})`)];
|
|
29
|
+
if (options.allowSelf === false)
|
|
30
|
+
decorators.push(common.SetMetadata(ROLES_DENY_SELF_KEY, true));
|
|
31
|
+
return common.applyDecorators(...decorators);
|
|
28
32
|
}
|
|
29
33
|
const CurrentUser = common.createParamDecorator((data, context) => {
|
|
30
34
|
const ctx = graphql.GqlExecutionContext.create(context);
|
|
@@ -149,7 +153,8 @@ exports.RolesGuard = class RolesGuard {
|
|
|
149
153
|
const args = ctx.getArgs();
|
|
150
154
|
const data = args.data;
|
|
151
155
|
const filter = args.filter;
|
|
152
|
-
|
|
156
|
+
const denySelf = this.reflector.get(ROLES_DENY_SELF_KEY, context.getHandler()) === true;
|
|
157
|
+
if (!denySelf && (data && data.username && user.username === data.username || filter && filter.username && user.username === filter.username || args.username && user.username === args.username)) {
|
|
153
158
|
return true;
|
|
154
159
|
}
|
|
155
160
|
if (allowedRoles.includes(user.role)) {
|
|
@@ -1929,6 +1934,7 @@ exports.OptionalCurrentUser = OptionalCurrentUser;
|
|
|
1929
1934
|
exports.PaginationResult = PaginationResult;
|
|
1930
1935
|
exports.PaginationUtils = PaginationUtils;
|
|
1931
1936
|
exports.QuantityUtils = QuantityUtils;
|
|
1937
|
+
exports.ROLES_DENY_SELF_KEY = ROLES_DENY_SELF_KEY;
|
|
1932
1938
|
exports.UseBucket = UseBucket;
|
|
1933
1939
|
exports.bucketProvidersFor = bucketProvidersFor;
|
|
1934
1940
|
exports.bucketTokenFor = bucketTokenFor;
|
package/dist/index.d.cts
CHANGED
|
@@ -16,7 +16,17 @@ import { Cooperative } from 'cooptypes';
|
|
|
16
16
|
*/
|
|
17
17
|
interface AuthRolesOptions {
|
|
18
18
|
self?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Пускает ли `RolesGuard` пайщика без нужной роли, когда `username` в
|
|
21
|
+
* аргументах — он сам. По умолчанию да: так пайщик читает свои записи и
|
|
22
|
+
* подаёт свои заявления. Для полномочий совета, где `username` — адресат
|
|
23
|
+
* действия (подтвердить соглашение, внести данные, импортировать вклад),
|
|
24
|
+
* ставится `false`: иначе пайщик выполнил бы его над собой.
|
|
25
|
+
*/
|
|
26
|
+
allowSelf?: boolean;
|
|
19
27
|
}
|
|
28
|
+
/** Ключ метаданных: самообход `RolesGuard` запрещён. */
|
|
29
|
+
declare const ROLES_DENY_SELF_KEY = "roles_deny_self";
|
|
20
30
|
/**
|
|
21
31
|
* Ограничение доступа к резолверу или к отдельному полю объекта.
|
|
22
32
|
*
|
|
@@ -87,7 +97,8 @@ declare class HttpJwtAuthGuard extends HttpJwtAuthGuard_base {
|
|
|
87
97
|
* 1. Валидный `server-secret` — доступ разрешён.
|
|
88
98
|
* 2. Роли не заданы — доступ открыт.
|
|
89
99
|
* 3. Пользователь обращается к своим ресурсам (`username` вложенный в `data`/`filter`
|
|
90
|
-
* либо плоским аргументом совпадает с `user.username`) —
|
|
100
|
+
* либо плоским аргументом совпадает с `user.username`) — разрешено, если
|
|
101
|
+
* операция не объявила `AuthRoles(..., { allowSelf: false })`.
|
|
91
102
|
* 4. У пользователя есть одна из разрешённых ролей — разрешено.
|
|
92
103
|
* 5. Иначе — отказ.
|
|
93
104
|
*/
|
|
@@ -1520,5 +1531,5 @@ declare class HttpApiError extends HttpException {
|
|
|
1520
1531
|
*/
|
|
1521
1532
|
declare function rethrowChainError(error: unknown): never;
|
|
1522
1533
|
|
|
1523
|
-
export { ActiveUserStatusGuard, AmountFormatterUtils, AssetUtils, AuthRoles, BaseExtensionModule, BucketRegistry, CandidateFilterInputDTO, CandidateOutputDTO, CandidateStatus, CurrencyValidationUtil, CurrentUser, DEFAULT_DOCUMENT_VERSION, DateUtils, DocumentAggregateDTO, DomainToBlockchainUtils, EMPTY_HASH, EXTENSION_APP_TERMINATE_EVENT, EXTENSION_REPOSITORY, EXTENSION_SECRET_SET, EXTENSION_SECRET_UNSET, ExpenseProposalStatementGenerateDocumentInputDTO, ExpenseProposalStatementSignedDocumentInputDTO, ExpenseProposalStatementSignedMetaDocumentInputDTO, ExtensionAvailability, ExtensionConfigSuppliedBy, ExtensionDomainEntity, GenerateDocumentInputDTO, GenerateDocumentOptionsInputDTO, GenerateMetaDocumentInputDTO, GeneratedDocumentDTO, GqlJwtAuthGuard, HttpApiError, HttpJwtAuthGuard, IPNProvider, InjectBucket, LOG_EXTENSION_REPOSITORY, LangType, LogExtensionDomainEntity, MetaDocumentInputDTO, ONBOARDING_EXPIRY_DAYS, ONBOARDING_EXPIRY_MS, OptionalCurrentUser, OptionalGqlJwtAuthGuard, PaginationInputDTO, PaginationResult, PaginationUtils, PaymentProvider, PollingProvider, QuantityUtils, RolesGuard, SignatureInfoDTO, SignatureInfoInputDTO, SignedDigitalDocumentDTO, SignedDigitalDocumentInputDTO, TransactionDTO, UseBucket, bucketProvidersFor, bucketTokenFor, buildPaginationResult, checkPaymentAmount, checkPaymentSymbol, computeOnboardingExpiresAt, configureExtensionAuth, configurePlatformSettings, createPaginationResult, extensionEntities, generateHashFromString, generateRandomHash, generateUniqueHash, getAmountPlusFee, getAppliedBlockNum, hasServerSecret, isExtensionAvailable, mergeSecretConfig, paginationInputToOffset, platformSettings, providerSuppliedPaths, redactSecretConfig, registerExtensionEntities, resetExtensionEntities, rethrowChainError, verifySignedDocumentAgainstStoredDraft, waitAfterTransactBeforeChainTableRead };
|
|
1534
|
+
export { ActiveUserStatusGuard, AmountFormatterUtils, AssetUtils, AuthRoles, BaseExtensionModule, BucketRegistry, CandidateFilterInputDTO, CandidateOutputDTO, CandidateStatus, CurrencyValidationUtil, CurrentUser, DEFAULT_DOCUMENT_VERSION, DateUtils, DocumentAggregateDTO, DomainToBlockchainUtils, EMPTY_HASH, EXTENSION_APP_TERMINATE_EVENT, EXTENSION_REPOSITORY, EXTENSION_SECRET_SET, EXTENSION_SECRET_UNSET, ExpenseProposalStatementGenerateDocumentInputDTO, ExpenseProposalStatementSignedDocumentInputDTO, ExpenseProposalStatementSignedMetaDocumentInputDTO, ExtensionAvailability, ExtensionConfigSuppliedBy, ExtensionDomainEntity, GenerateDocumentInputDTO, GenerateDocumentOptionsInputDTO, GenerateMetaDocumentInputDTO, GeneratedDocumentDTO, GqlJwtAuthGuard, HttpApiError, HttpJwtAuthGuard, IPNProvider, InjectBucket, LOG_EXTENSION_REPOSITORY, LangType, LogExtensionDomainEntity, MetaDocumentInputDTO, ONBOARDING_EXPIRY_DAYS, ONBOARDING_EXPIRY_MS, OptionalCurrentUser, OptionalGqlJwtAuthGuard, PaginationInputDTO, PaginationResult, PaginationUtils, PaymentProvider, PollingProvider, QuantityUtils, ROLES_DENY_SELF_KEY, RolesGuard, SignatureInfoDTO, SignatureInfoInputDTO, SignedDigitalDocumentDTO, SignedDigitalDocumentInputDTO, TransactionDTO, UseBucket, bucketProvidersFor, bucketTokenFor, buildPaginationResult, checkPaymentAmount, checkPaymentSymbol, computeOnboardingExpiresAt, configureExtensionAuth, configurePlatformSettings, createPaginationResult, extensionEntities, generateHashFromString, generateRandomHash, generateUniqueHash, getAmountPlusFee, getAppliedBlockNum, hasServerSecret, isExtensionAvailable, mergeSecretConfig, paginationInputToOffset, platformSettings, providerSuppliedPaths, redactSecretConfig, registerExtensionEntities, resetExtensionEntities, rethrowChainError, verifySignedDocumentAgainstStoredDraft, waitAfterTransactBeforeChainTableRead };
|
|
1524
1535
|
export type { AuthRolesOptions, BucketSource, BucketSpec, DeserializedDescriptionOfExtension, ExcludeCommonProps, ExtensionAppTerminatePayload, ExtensionAuthOptions, ExtensionConfigFieldPolicy, ExtensionConfigPolicy, ExtensionDomainInterface, ExtensionDomainRepository, ExtensionEntityClass, ExtensionSchemaMigrationAfterContext, GeneratedDocumentDomainInterface, GeneratedDocumentDraft, IDesktopConfig, IExtensionSchemaMigration, IRegistryExtension, IResolvedRegistryExtension, LoadGeneratedDocumentByDocHash, LogExtensionDomainInterface, LogExtensionDomainRepository, LogExtensionFilter, LogExtensionPaginationOptions, LogExtensionPaginationResult, PaymentDetails, PlatformBlockchainSettings, PlatformSettings, RegisteredBucket, RequireFields, SignedDocumentMetaCompareMode, SignedDocumentMetaVerification, SignedDocumentToVerify, TransactResultWithResponse };
|
package/dist/index.d.mts
CHANGED
|
@@ -16,7 +16,17 @@ import { Cooperative } from 'cooptypes';
|
|
|
16
16
|
*/
|
|
17
17
|
interface AuthRolesOptions {
|
|
18
18
|
self?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Пускает ли `RolesGuard` пайщика без нужной роли, когда `username` в
|
|
21
|
+
* аргументах — он сам. По умолчанию да: так пайщик читает свои записи и
|
|
22
|
+
* подаёт свои заявления. Для полномочий совета, где `username` — адресат
|
|
23
|
+
* действия (подтвердить соглашение, внести данные, импортировать вклад),
|
|
24
|
+
* ставится `false`: иначе пайщик выполнил бы его над собой.
|
|
25
|
+
*/
|
|
26
|
+
allowSelf?: boolean;
|
|
19
27
|
}
|
|
28
|
+
/** Ключ метаданных: самообход `RolesGuard` запрещён. */
|
|
29
|
+
declare const ROLES_DENY_SELF_KEY = "roles_deny_self";
|
|
20
30
|
/**
|
|
21
31
|
* Ограничение доступа к резолверу или к отдельному полю объекта.
|
|
22
32
|
*
|
|
@@ -87,7 +97,8 @@ declare class HttpJwtAuthGuard extends HttpJwtAuthGuard_base {
|
|
|
87
97
|
* 1. Валидный `server-secret` — доступ разрешён.
|
|
88
98
|
* 2. Роли не заданы — доступ открыт.
|
|
89
99
|
* 3. Пользователь обращается к своим ресурсам (`username` вложенный в `data`/`filter`
|
|
90
|
-
* либо плоским аргументом совпадает с `user.username`) —
|
|
100
|
+
* либо плоским аргументом совпадает с `user.username`) — разрешено, если
|
|
101
|
+
* операция не объявила `AuthRoles(..., { allowSelf: false })`.
|
|
91
102
|
* 4. У пользователя есть одна из разрешённых ролей — разрешено.
|
|
92
103
|
* 5. Иначе — отказ.
|
|
93
104
|
*/
|
|
@@ -1520,5 +1531,5 @@ declare class HttpApiError extends HttpException {
|
|
|
1520
1531
|
*/
|
|
1521
1532
|
declare function rethrowChainError(error: unknown): never;
|
|
1522
1533
|
|
|
1523
|
-
export { ActiveUserStatusGuard, AmountFormatterUtils, AssetUtils, AuthRoles, BaseExtensionModule, BucketRegistry, CandidateFilterInputDTO, CandidateOutputDTO, CandidateStatus, CurrencyValidationUtil, CurrentUser, DEFAULT_DOCUMENT_VERSION, DateUtils, DocumentAggregateDTO, DomainToBlockchainUtils, EMPTY_HASH, EXTENSION_APP_TERMINATE_EVENT, EXTENSION_REPOSITORY, EXTENSION_SECRET_SET, EXTENSION_SECRET_UNSET, ExpenseProposalStatementGenerateDocumentInputDTO, ExpenseProposalStatementSignedDocumentInputDTO, ExpenseProposalStatementSignedMetaDocumentInputDTO, ExtensionAvailability, ExtensionConfigSuppliedBy, ExtensionDomainEntity, GenerateDocumentInputDTO, GenerateDocumentOptionsInputDTO, GenerateMetaDocumentInputDTO, GeneratedDocumentDTO, GqlJwtAuthGuard, HttpApiError, HttpJwtAuthGuard, IPNProvider, InjectBucket, LOG_EXTENSION_REPOSITORY, LangType, LogExtensionDomainEntity, MetaDocumentInputDTO, ONBOARDING_EXPIRY_DAYS, ONBOARDING_EXPIRY_MS, OptionalCurrentUser, OptionalGqlJwtAuthGuard, PaginationInputDTO, PaginationResult, PaginationUtils, PaymentProvider, PollingProvider, QuantityUtils, RolesGuard, SignatureInfoDTO, SignatureInfoInputDTO, SignedDigitalDocumentDTO, SignedDigitalDocumentInputDTO, TransactionDTO, UseBucket, bucketProvidersFor, bucketTokenFor, buildPaginationResult, checkPaymentAmount, checkPaymentSymbol, computeOnboardingExpiresAt, configureExtensionAuth, configurePlatformSettings, createPaginationResult, extensionEntities, generateHashFromString, generateRandomHash, generateUniqueHash, getAmountPlusFee, getAppliedBlockNum, hasServerSecret, isExtensionAvailable, mergeSecretConfig, paginationInputToOffset, platformSettings, providerSuppliedPaths, redactSecretConfig, registerExtensionEntities, resetExtensionEntities, rethrowChainError, verifySignedDocumentAgainstStoredDraft, waitAfterTransactBeforeChainTableRead };
|
|
1534
|
+
export { ActiveUserStatusGuard, AmountFormatterUtils, AssetUtils, AuthRoles, BaseExtensionModule, BucketRegistry, CandidateFilterInputDTO, CandidateOutputDTO, CandidateStatus, CurrencyValidationUtil, CurrentUser, DEFAULT_DOCUMENT_VERSION, DateUtils, DocumentAggregateDTO, DomainToBlockchainUtils, EMPTY_HASH, EXTENSION_APP_TERMINATE_EVENT, EXTENSION_REPOSITORY, EXTENSION_SECRET_SET, EXTENSION_SECRET_UNSET, ExpenseProposalStatementGenerateDocumentInputDTO, ExpenseProposalStatementSignedDocumentInputDTO, ExpenseProposalStatementSignedMetaDocumentInputDTO, ExtensionAvailability, ExtensionConfigSuppliedBy, ExtensionDomainEntity, GenerateDocumentInputDTO, GenerateDocumentOptionsInputDTO, GenerateMetaDocumentInputDTO, GeneratedDocumentDTO, GqlJwtAuthGuard, HttpApiError, HttpJwtAuthGuard, IPNProvider, InjectBucket, LOG_EXTENSION_REPOSITORY, LangType, LogExtensionDomainEntity, MetaDocumentInputDTO, ONBOARDING_EXPIRY_DAYS, ONBOARDING_EXPIRY_MS, OptionalCurrentUser, OptionalGqlJwtAuthGuard, PaginationInputDTO, PaginationResult, PaginationUtils, PaymentProvider, PollingProvider, QuantityUtils, ROLES_DENY_SELF_KEY, RolesGuard, SignatureInfoDTO, SignatureInfoInputDTO, SignedDigitalDocumentDTO, SignedDigitalDocumentInputDTO, TransactionDTO, UseBucket, bucketProvidersFor, bucketTokenFor, buildPaginationResult, checkPaymentAmount, checkPaymentSymbol, computeOnboardingExpiresAt, configureExtensionAuth, configurePlatformSettings, createPaginationResult, extensionEntities, generateHashFromString, generateRandomHash, generateUniqueHash, getAmountPlusFee, getAppliedBlockNum, hasServerSecret, isExtensionAvailable, mergeSecretConfig, paginationInputToOffset, platformSettings, providerSuppliedPaths, redactSecretConfig, registerExtensionEntities, resetExtensionEntities, rethrowChainError, verifySignedDocumentAgainstStoredDraft, waitAfterTransactBeforeChainTableRead };
|
|
1524
1535
|
export type { AuthRolesOptions, BucketSource, BucketSpec, DeserializedDescriptionOfExtension, ExcludeCommonProps, ExtensionAppTerminatePayload, ExtensionAuthOptions, ExtensionConfigFieldPolicy, ExtensionConfigPolicy, ExtensionDomainInterface, ExtensionDomainRepository, ExtensionEntityClass, ExtensionSchemaMigrationAfterContext, GeneratedDocumentDomainInterface, GeneratedDocumentDraft, IDesktopConfig, IExtensionSchemaMigration, IRegistryExtension, IResolvedRegistryExtension, LoadGeneratedDocumentByDocHash, LogExtensionDomainInterface, LogExtensionDomainRepository, LogExtensionFilter, LogExtensionPaginationOptions, LogExtensionPaginationResult, PaymentDetails, PlatformBlockchainSettings, PlatformSettings, RegisteredBucket, RequireFields, SignedDocumentMetaCompareMode, SignedDocumentMetaVerification, SignedDocumentToVerify, TransactResultWithResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,17 @@ import { Cooperative } from 'cooptypes';
|
|
|
16
16
|
*/
|
|
17
17
|
interface AuthRolesOptions {
|
|
18
18
|
self?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Пускает ли `RolesGuard` пайщика без нужной роли, когда `username` в
|
|
21
|
+
* аргументах — он сам. По умолчанию да: так пайщик читает свои записи и
|
|
22
|
+
* подаёт свои заявления. Для полномочий совета, где `username` — адресат
|
|
23
|
+
* действия (подтвердить соглашение, внести данные, импортировать вклад),
|
|
24
|
+
* ставится `false`: иначе пайщик выполнил бы его над собой.
|
|
25
|
+
*/
|
|
26
|
+
allowSelf?: boolean;
|
|
19
27
|
}
|
|
28
|
+
/** Ключ метаданных: самообход `RolesGuard` запрещён. */
|
|
29
|
+
declare const ROLES_DENY_SELF_KEY = "roles_deny_self";
|
|
20
30
|
/**
|
|
21
31
|
* Ограничение доступа к резолверу или к отдельному полю объекта.
|
|
22
32
|
*
|
|
@@ -87,7 +97,8 @@ declare class HttpJwtAuthGuard extends HttpJwtAuthGuard_base {
|
|
|
87
97
|
* 1. Валидный `server-secret` — доступ разрешён.
|
|
88
98
|
* 2. Роли не заданы — доступ открыт.
|
|
89
99
|
* 3. Пользователь обращается к своим ресурсам (`username` вложенный в `data`/`filter`
|
|
90
|
-
* либо плоским аргументом совпадает с `user.username`) —
|
|
100
|
+
* либо плоским аргументом совпадает с `user.username`) — разрешено, если
|
|
101
|
+
* операция не объявила `AuthRoles(..., { allowSelf: false })`.
|
|
91
102
|
* 4. У пользователя есть одна из разрешённых ролей — разрешено.
|
|
92
103
|
* 5. Иначе — отказ.
|
|
93
104
|
*/
|
|
@@ -1520,5 +1531,5 @@ declare class HttpApiError extends HttpException {
|
|
|
1520
1531
|
*/
|
|
1521
1532
|
declare function rethrowChainError(error: unknown): never;
|
|
1522
1533
|
|
|
1523
|
-
export { ActiveUserStatusGuard, AmountFormatterUtils, AssetUtils, AuthRoles, BaseExtensionModule, BucketRegistry, CandidateFilterInputDTO, CandidateOutputDTO, CandidateStatus, CurrencyValidationUtil, CurrentUser, DEFAULT_DOCUMENT_VERSION, DateUtils, DocumentAggregateDTO, DomainToBlockchainUtils, EMPTY_HASH, EXTENSION_APP_TERMINATE_EVENT, EXTENSION_REPOSITORY, EXTENSION_SECRET_SET, EXTENSION_SECRET_UNSET, ExpenseProposalStatementGenerateDocumentInputDTO, ExpenseProposalStatementSignedDocumentInputDTO, ExpenseProposalStatementSignedMetaDocumentInputDTO, ExtensionAvailability, ExtensionConfigSuppliedBy, ExtensionDomainEntity, GenerateDocumentInputDTO, GenerateDocumentOptionsInputDTO, GenerateMetaDocumentInputDTO, GeneratedDocumentDTO, GqlJwtAuthGuard, HttpApiError, HttpJwtAuthGuard, IPNProvider, InjectBucket, LOG_EXTENSION_REPOSITORY, LangType, LogExtensionDomainEntity, MetaDocumentInputDTO, ONBOARDING_EXPIRY_DAYS, ONBOARDING_EXPIRY_MS, OptionalCurrentUser, OptionalGqlJwtAuthGuard, PaginationInputDTO, PaginationResult, PaginationUtils, PaymentProvider, PollingProvider, QuantityUtils, RolesGuard, SignatureInfoDTO, SignatureInfoInputDTO, SignedDigitalDocumentDTO, SignedDigitalDocumentInputDTO, TransactionDTO, UseBucket, bucketProvidersFor, bucketTokenFor, buildPaginationResult, checkPaymentAmount, checkPaymentSymbol, computeOnboardingExpiresAt, configureExtensionAuth, configurePlatformSettings, createPaginationResult, extensionEntities, generateHashFromString, generateRandomHash, generateUniqueHash, getAmountPlusFee, getAppliedBlockNum, hasServerSecret, isExtensionAvailable, mergeSecretConfig, paginationInputToOffset, platformSettings, providerSuppliedPaths, redactSecretConfig, registerExtensionEntities, resetExtensionEntities, rethrowChainError, verifySignedDocumentAgainstStoredDraft, waitAfterTransactBeforeChainTableRead };
|
|
1534
|
+
export { ActiveUserStatusGuard, AmountFormatterUtils, AssetUtils, AuthRoles, BaseExtensionModule, BucketRegistry, CandidateFilterInputDTO, CandidateOutputDTO, CandidateStatus, CurrencyValidationUtil, CurrentUser, DEFAULT_DOCUMENT_VERSION, DateUtils, DocumentAggregateDTO, DomainToBlockchainUtils, EMPTY_HASH, EXTENSION_APP_TERMINATE_EVENT, EXTENSION_REPOSITORY, EXTENSION_SECRET_SET, EXTENSION_SECRET_UNSET, ExpenseProposalStatementGenerateDocumentInputDTO, ExpenseProposalStatementSignedDocumentInputDTO, ExpenseProposalStatementSignedMetaDocumentInputDTO, ExtensionAvailability, ExtensionConfigSuppliedBy, ExtensionDomainEntity, GenerateDocumentInputDTO, GenerateDocumentOptionsInputDTO, GenerateMetaDocumentInputDTO, GeneratedDocumentDTO, GqlJwtAuthGuard, HttpApiError, HttpJwtAuthGuard, IPNProvider, InjectBucket, LOG_EXTENSION_REPOSITORY, LangType, LogExtensionDomainEntity, MetaDocumentInputDTO, ONBOARDING_EXPIRY_DAYS, ONBOARDING_EXPIRY_MS, OptionalCurrentUser, OptionalGqlJwtAuthGuard, PaginationInputDTO, PaginationResult, PaginationUtils, PaymentProvider, PollingProvider, QuantityUtils, ROLES_DENY_SELF_KEY, RolesGuard, SignatureInfoDTO, SignatureInfoInputDTO, SignedDigitalDocumentDTO, SignedDigitalDocumentInputDTO, TransactionDTO, UseBucket, bucketProvidersFor, bucketTokenFor, buildPaginationResult, checkPaymentAmount, checkPaymentSymbol, computeOnboardingExpiresAt, configureExtensionAuth, configurePlatformSettings, createPaginationResult, extensionEntities, generateHashFromString, generateRandomHash, generateUniqueHash, getAmountPlusFee, getAppliedBlockNum, hasServerSecret, isExtensionAvailable, mergeSecretConfig, paginationInputToOffset, platformSettings, providerSuppliedPaths, redactSecretConfig, registerExtensionEntities, resetExtensionEntities, rethrowChainError, verifySignedDocumentAgainstStoredDraft, waitAfterTransactBeforeChainTableRead };
|
|
1524
1535
|
export type { AuthRolesOptions, BucketSource, BucketSpec, DeserializedDescriptionOfExtension, ExcludeCommonProps, ExtensionAppTerminatePayload, ExtensionAuthOptions, ExtensionConfigFieldPolicy, ExtensionConfigPolicy, ExtensionDomainInterface, ExtensionDomainRepository, ExtensionEntityClass, ExtensionSchemaMigrationAfterContext, GeneratedDocumentDomainInterface, GeneratedDocumentDraft, IDesktopConfig, IExtensionSchemaMigration, IRegistryExtension, IResolvedRegistryExtension, LoadGeneratedDocumentByDocHash, LogExtensionDomainInterface, LogExtensionDomainRepository, LogExtensionFilter, LogExtensionPaginationOptions, LogExtensionPaginationResult, PaymentDetails, PlatformBlockchainSettings, PlatformSettings, RegisteredBucket, RequireFields, SignedDocumentMetaCompareMode, SignedDocumentMetaVerification, SignedDocumentToVerify, TransactResultWithResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createParamDecorator, UnauthorizedException,
|
|
1
|
+
import { createParamDecorator, UnauthorizedException, SetMetadata, applyDecorators, Injectable, Inject, ForbiddenException, HttpException, HttpStatus, BadRequestException } from '@nestjs/common';
|
|
2
2
|
import { GqlExecutionContext, Directive, Field, InputType, registerEnumType, Int, IntersectionType, OmitType, ObjectType } from '@nestjs/graphql';
|
|
3
3
|
import { Reflector } from '@nestjs/core';
|
|
4
4
|
import { AuthGuard } from '@nestjs/passport';
|
|
@@ -13,10 +13,14 @@ import moment$1 from 'moment-timezone';
|
|
|
13
13
|
import 'moment/locale/ru';
|
|
14
14
|
import crypto from 'crypto';
|
|
15
15
|
|
|
16
|
+
const ROLES_DENY_SELF_KEY = "roles_deny_self";
|
|
16
17
|
function AuthRoles(roles, options = {}) {
|
|
17
18
|
const self = options.self ?? [];
|
|
18
19
|
const args = self.length ? `roles: ${JSON.stringify(roles)}, self: ${JSON.stringify(self)}` : `roles: ${JSON.stringify(roles)}`;
|
|
19
|
-
|
|
20
|
+
const decorators = [SetMetadata("roles", roles), Directive(`@auth(${args})`)];
|
|
21
|
+
if (options.allowSelf === false)
|
|
22
|
+
decorators.push(SetMetadata(ROLES_DENY_SELF_KEY, true));
|
|
23
|
+
return applyDecorators(...decorators);
|
|
20
24
|
}
|
|
21
25
|
const CurrentUser = createParamDecorator((data, context) => {
|
|
22
26
|
const ctx = GqlExecutionContext.create(context);
|
|
@@ -141,7 +145,8 @@ let RolesGuard = class {
|
|
|
141
145
|
const args = ctx.getArgs();
|
|
142
146
|
const data = args.data;
|
|
143
147
|
const filter = args.filter;
|
|
144
|
-
|
|
148
|
+
const denySelf = this.reflector.get(ROLES_DENY_SELF_KEY, context.getHandler()) === true;
|
|
149
|
+
if (!denySelf && (data && data.username && user.username === data.username || filter && filter.username && user.username === filter.username || args.username && user.username === args.username)) {
|
|
145
150
|
return true;
|
|
146
151
|
}
|
|
147
152
|
if (allowedRoles.includes(user.role)) {
|
|
@@ -1893,4 +1898,4 @@ function rethrowChainError(error) {
|
|
|
1893
1898
|
throw new BadRequestException(clean);
|
|
1894
1899
|
}
|
|
1895
1900
|
|
|
1896
|
-
export { ActiveUserStatusGuard, AmountFormatterUtils, AssetUtils, AuthRoles, BaseExtensionModule, BucketRegistry, CandidateFilterInputDTO, CandidateOutputDTO, CandidateStatus, CurrencyValidationUtil, CurrentUser, DEFAULT_DOCUMENT_VERSION, DateUtils, DocumentAggregateDTO, DomainToBlockchainUtils, EMPTY_HASH, EXTENSION_APP_TERMINATE_EVENT, EXTENSION_REPOSITORY, EXTENSION_SECRET_SET, EXTENSION_SECRET_UNSET, ExpenseProposalStatementGenerateDocumentInputDTO, ExpenseProposalStatementSignedDocumentInputDTO, ExpenseProposalStatementSignedMetaDocumentInputDTO, ExtensionAvailability, ExtensionConfigSuppliedBy, ExtensionDomainEntity, GenerateDocumentInputDTO, GenerateDocumentOptionsInputDTO, GenerateMetaDocumentInputDTO, GeneratedDocumentDTO, GqlJwtAuthGuard, HttpApiError, HttpJwtAuthGuard, IPNProvider, InjectBucket, LOG_EXTENSION_REPOSITORY, LangType, LogExtensionDomainEntity, MetaDocumentInputDTO, ONBOARDING_EXPIRY_DAYS, ONBOARDING_EXPIRY_MS, OptionalCurrentUser, OptionalGqlJwtAuthGuard, PaginationInputDTO, PaginationResult, PaginationUtils, PaymentProvider, PollingProvider, QuantityUtils, RolesGuard, SignatureInfoDTO, SignatureInfoInputDTO, SignedDigitalDocumentDTO, SignedDigitalDocumentInputDTO, TransactionDTO, UseBucket, bucketProvidersFor, bucketTokenFor, buildPaginationResult, checkPaymentAmount, checkPaymentSymbol, computeOnboardingExpiresAt, configureExtensionAuth, configurePlatformSettings, createPaginationResult, extensionEntities, generateHashFromString, generateRandomHash, generateUniqueHash, getAmountPlusFee, getAppliedBlockNum, hasServerSecret, isExtensionAvailable, mergeSecretConfig, paginationInputToOffset, platformSettings, providerSuppliedPaths, redactSecretConfig, registerExtensionEntities, resetExtensionEntities, rethrowChainError, verifySignedDocumentAgainstStoredDraft, waitAfterTransactBeforeChainTableRead };
|
|
1901
|
+
export { ActiveUserStatusGuard, AmountFormatterUtils, AssetUtils, AuthRoles, BaseExtensionModule, BucketRegistry, CandidateFilterInputDTO, CandidateOutputDTO, CandidateStatus, CurrencyValidationUtil, CurrentUser, DEFAULT_DOCUMENT_VERSION, DateUtils, DocumentAggregateDTO, DomainToBlockchainUtils, EMPTY_HASH, EXTENSION_APP_TERMINATE_EVENT, EXTENSION_REPOSITORY, EXTENSION_SECRET_SET, EXTENSION_SECRET_UNSET, ExpenseProposalStatementGenerateDocumentInputDTO, ExpenseProposalStatementSignedDocumentInputDTO, ExpenseProposalStatementSignedMetaDocumentInputDTO, ExtensionAvailability, ExtensionConfigSuppliedBy, ExtensionDomainEntity, GenerateDocumentInputDTO, GenerateDocumentOptionsInputDTO, GenerateMetaDocumentInputDTO, GeneratedDocumentDTO, GqlJwtAuthGuard, HttpApiError, HttpJwtAuthGuard, IPNProvider, InjectBucket, LOG_EXTENSION_REPOSITORY, LangType, LogExtensionDomainEntity, MetaDocumentInputDTO, ONBOARDING_EXPIRY_DAYS, ONBOARDING_EXPIRY_MS, OptionalCurrentUser, OptionalGqlJwtAuthGuard, PaginationInputDTO, PaginationResult, PaginationUtils, PaymentProvider, PollingProvider, QuantityUtils, ROLES_DENY_SELF_KEY, RolesGuard, SignatureInfoDTO, SignatureInfoInputDTO, SignedDigitalDocumentDTO, SignedDigitalDocumentInputDTO, TransactionDTO, UseBucket, bucketProvidersFor, bucketTokenFor, buildPaginationResult, checkPaymentAmount, checkPaymentSymbol, computeOnboardingExpiresAt, configureExtensionAuth, configurePlatformSettings, createPaginationResult, extensionEntities, generateHashFromString, generateRandomHash, generateUniqueHash, getAmountPlusFee, getAppliedBlockNum, hasServerSecret, isExtensionAvailable, mergeSecretConfig, paginationInputToOffset, platformSettings, providerSuppliedPaths, redactSecretConfig, registerExtensionEntities, resetExtensionEntities, rethrowChainError, verifySignedDocumentAgainstStoredDraft, waitAfterTransactBeforeChainTableRead };
|
package/dist/sync/index.cjs
CHANGED
|
@@ -871,7 +871,7 @@ exports.BaseBlockchainRepository = class BaseBlockchainRepository {
|
|
|
871
871
|
* Найти сущность по кастомному ключу синхронизации
|
|
872
872
|
*/
|
|
873
873
|
async findBySyncKey(syncKey, syncValue) {
|
|
874
|
-
const whereCondition = { [syncKey]: syncValue.toLowerCase() };
|
|
874
|
+
const whereCondition = { [syncKey]: String(syncValue).toLowerCase() };
|
|
875
875
|
const entity = await this.repository.findOne({
|
|
876
876
|
where: whereCondition
|
|
877
877
|
});
|
|
@@ -907,7 +907,7 @@ exports.BaseBlockchainRepository = class BaseBlockchainRepository {
|
|
|
907
907
|
present,
|
|
908
908
|
_created_at: now,
|
|
909
909
|
_updated_at: now,
|
|
910
|
-
[syncKey]: syncValue.toLowerCase()
|
|
910
|
+
[syncKey]: String(syncValue).toLowerCase()
|
|
911
911
|
// ключ синхронизации
|
|
912
912
|
};
|
|
913
913
|
const newEntity = this.createDomainEntity(minimalDatabaseData, blockchainData);
|
package/dist/sync/index.mjs
CHANGED
|
@@ -869,7 +869,7 @@ let BaseBlockchainRepository = class {
|
|
|
869
869
|
* Найти сущность по кастомному ключу синхронизации
|
|
870
870
|
*/
|
|
871
871
|
async findBySyncKey(syncKey, syncValue) {
|
|
872
|
-
const whereCondition = { [syncKey]: syncValue.toLowerCase() };
|
|
872
|
+
const whereCondition = { [syncKey]: String(syncValue).toLowerCase() };
|
|
873
873
|
const entity = await this.repository.findOne({
|
|
874
874
|
where: whereCondition
|
|
875
875
|
});
|
|
@@ -905,7 +905,7 @@ let BaseBlockchainRepository = class {
|
|
|
905
905
|
present,
|
|
906
906
|
_created_at: now,
|
|
907
907
|
_updated_at: now,
|
|
908
|
-
[syncKey]: syncValue.toLowerCase()
|
|
908
|
+
[syncKey]: String(syncValue).toLowerCase()
|
|
909
909
|
// ключ синхронизации
|
|
910
910
|
};
|
|
911
911
|
const newEntity = this.createDomainEntity(minimalDatabaseData, blockchainData);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coopenomics/extension-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2026.9.
|
|
4
|
+
"version": "2026.9.16-2",
|
|
5
5
|
"description": "Служебный каркас расширения цифрового кооператива: базовый модуль, сущности и репозитории расширения, авторизация, каркас блокчейн-синхронизации, контракт миграций схемы, контракт реестра",
|
|
6
6
|
"author": "Alex Ant <dacom.dark.sun@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typecheck": "tsc --noEmit"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@coopenomics/sdk": "2026.9.
|
|
41
|
+
"@coopenomics/sdk": "2026.9.16-2",
|
|
42
42
|
"@nestjs/common": "^10.0.0",
|
|
43
43
|
"@nestjs/core": "^10.0.0",
|
|
44
44
|
"@nestjs/graphql": "^12.2.1",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@wharfkit/session": "^1.4.0",
|
|
69
69
|
"class-transformer": "^0.5.1",
|
|
70
70
|
"class-validator": "^0.14.1",
|
|
71
|
-
"cooptypes": "2026.9.
|
|
71
|
+
"cooptypes": "2026.9.16-2",
|
|
72
72
|
"graphql": "^16.9.0",
|
|
73
73
|
"graphql-type-json": "^0.3.2",
|
|
74
74
|
"moment": "^2.30.1",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"unbuild": "^2.0.0",
|
|
81
81
|
"zod": "^3.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "97b9f48f94efe92b20cecb66630e8bf821c73b59"
|
|
84
84
|
}
|