@unchainedshop/api 1.2.40 → 2.0.0-beta1
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-index.d.ts +1 -0
- package/lib/api-index.js +3 -0
- package/lib/api-index.js.map +1 -1
- package/lib/context.js +3 -3
- package/lib/context.js.map +1 -1
- package/lib/createBulkImportServer.js +1 -1
- package/lib/createBulkImportServer.js.map +1 -1
- package/lib/createERCMetadataServer.d.ts +2 -0
- package/lib/createERCMetadataServer.js +53 -0
- package/lib/createERCMetadataServer.js.map +1 -0
- package/lib/errors.d.ts +1 -0
- package/lib/errors.js +1 -0
- package/lib/errors.js.map +1 -1
- package/lib/loaders/index.d.ts +2 -2
- package/lib/loaders/index.js +1 -1
- package/lib/loaders/index.js.map +1 -1
- package/lib/locale-context.d.ts +2 -2
- package/lib/locale-context.js +1 -1
- package/lib/locale-context.js.map +1 -1
- package/lib/resolvers/index.js +2 -0
- package/lib/resolvers/index.js.map +1 -1
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.d.ts +4 -0
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.js +14 -0
- package/lib/resolvers/mutations/accounts/addWebAuthnCredentials.js.map +1 -0
- package/lib/resolvers/mutations/accounts/createUser.js +18 -6
- package/lib/resolvers/mutations/accounts/createUser.js.map +1 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts +5 -0
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.js +9 -0
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.js.map +1 -0
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts +5 -0
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.js +16 -0
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.js.map +1 -0
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.d.ts +8 -0
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js +7 -0
- package/lib/resolvers/mutations/accounts/loginWithWebAuthn.js.map +1 -0
- package/lib/resolvers/mutations/accounts/logout.js +6 -2
- package/lib/resolvers/mutations/accounts/logout.js.map +1 -1
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js +6 -2
- package/lib/resolvers/mutations/accounts/logoutAllSessions.js.map +1 -1
- package/lib/resolvers/mutations/accounts/removeWebAuthnCredentials.d.ts +4 -0
- package/lib/resolvers/mutations/accounts/removeWebAuthnCredentials.js +18 -0
- package/lib/resolvers/mutations/accounts/removeWebAuthnCredentials.js.map +1 -0
- package/lib/resolvers/mutations/index.d.ts +171 -157
- package/lib/resolvers/mutations/index.js +14 -0
- package/lib/resolvers/mutations/index.js.map +1 -1
- package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js +7 -1
- package/lib/resolvers/mutations/orders/signPaymentProviderForCheckout.js.map +1 -1
- package/lib/resolvers/mutations/pageView.d.ts +2 -2
- package/lib/resolvers/mutations/pageView.js.map +1 -1
- package/lib/resolvers/mutations/products/updateProductTokenization.d.ts +6 -0
- package/lib/resolvers/mutations/products/updateProductTokenization.js +19 -0
- package/lib/resolvers/mutations/products/updateProductTokenization.js.map +1 -0
- package/lib/resolvers/mutations/warehousing/exportToken.d.ts +6 -0
- package/lib/resolvers/mutations/warehousing/exportToken.js +21 -0
- package/lib/resolvers/mutations/warehousing/exportToken.js.map +1 -0
- package/lib/resolvers/queries/index.d.ts +67 -66
- package/lib/resolvers/queries/index.js +2 -0
- package/lib/resolvers/queries/index.js.map +1 -1
- package/lib/resolvers/queries/warehousing/token.d.ts +4 -0
- package/lib/resolvers/queries/warehousing/token.js +11 -0
- package/lib/resolvers/queries/warehousing/token.js.map +1 -0
- package/lib/resolvers/scalars/LowerCaseString.d.ts +3 -0
- package/lib/resolvers/scalars/LowerCaseString.js +17 -0
- package/lib/resolvers/scalars/LowerCaseString.js.map +1 -0
- package/lib/resolvers/scalars/index.d.ts +4 -0
- package/lib/resolvers/scalars/index.js +5 -0
- package/lib/resolvers/scalars/index.js.map +1 -0
- package/lib/resolvers/type/assortment/assortment-filter-types.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-link-types.d.ts +1 -1
- package/lib/resolvers/type/assortment/assortment-product-types.d.ts +1 -1
- package/lib/resolvers/type/currency-types.d.ts +3 -0
- package/lib/resolvers/type/currency-types.js +6 -0
- package/lib/resolvers/type/currency-types.js.map +1 -0
- package/lib/resolvers/type/index.d.ts +246 -130
- package/lib/resolvers/type/index.js +8 -0
- package/lib/resolvers/type/index.js.map +1 -1
- package/lib/resolvers/type/login-method-response-types.d.ts +4 -0
- package/lib/resolvers/type/login-method-response-types.js +4 -0
- package/lib/resolvers/type/login-method-response-types.js.map +1 -1
- package/lib/resolvers/type/order/order-delivery-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-delivery-shipping-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-discountable-types.d.ts +6 -0
- package/lib/resolvers/type/order/order-discountable-types.js +1 -1
- package/lib/resolvers/type/order/order-discountable-types.js.map +1 -1
- package/lib/resolvers/type/order/order-global-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-item-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-card-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-discount-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-generic-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-payment-invoice-types.d.ts +1 -1
- package/lib/resolvers/type/order/order-types.d.ts +2 -6
- package/lib/resolvers/type/order/order-types.js +0 -1
- package/lib/resolvers/type/order/order-types.js.map +1 -1
- package/lib/resolvers/type/product/product-tokenized-types.d.ts +2 -0
- package/lib/resolvers/type/product/product-tokenized-types.js +28 -0
- package/lib/resolvers/type/product/product-tokenized-types.js.map +1 -0
- package/lib/resolvers/type/quotation-types.d.ts +0 -4
- package/lib/resolvers/type/quotation-types.js +0 -10
- package/lib/resolvers/type/quotation-types.js.map +1 -1
- package/lib/resolvers/type/shop-types.d.ts +1 -1
- package/lib/resolvers/type/token-types.d.ts +17 -0
- package/lib/resolvers/type/token-types.js +30 -0
- package/lib/resolvers/type/token-types.js.map +1 -0
- package/lib/resolvers/type/user-types.d.ts +4 -1
- package/lib/resolvers/type/user-types.js +8 -0
- package/lib/resolvers/type/user-types.js.map +1 -1
- package/lib/resolvers/type/webauthn-credentials-types.d.ts +10 -0
- package/lib/resolvers/type/webauthn-credentials-types.js +13 -0
- package/lib/resolvers/type/webauthn-credentials-types.js.map +1 -0
- package/lib/roles/admin.js +3 -0
- package/lib/roles/admin.js.map +1 -1
- package/lib/roles/all.js +3 -0
- package/lib/roles/all.js.map +1 -1
- package/lib/roles/index.d.ts +1 -1
- package/lib/roles/index.js +3 -0
- package/lib/roles/index.js.map +1 -1
- package/lib/roles/loggedIn.js +9 -0
- package/lib/roles/loggedIn.js.map +1 -1
- package/lib/schema/inputTypes.js +6 -4
- package/lib/schema/inputTypes.js.map +1 -1
- package/lib/schema/mutation.js +50 -4
- package/lib/schema/mutation.js.map +1 -1
- package/lib/schema/query.js +9 -4
- package/lib/schema/query.js.map +1 -1
- package/lib/schema/scalars.js +1 -0
- package/lib/schema/scalars.js.map +1 -1
- package/lib/schema/types/assortment.js +6 -6
- package/lib/schema/types/currency.js +1 -0
- package/lib/schema/types/currency.js.map +1 -1
- package/lib/schema/types/order/order.js +0 -33
- package/lib/schema/types/order/order.js.map +1 -1
- package/lib/schema/types/payment.js +1 -1
- package/lib/schema/types/product/bundle-product.js +2 -2
- package/lib/schema/types/product/configurable-product.js +2 -2
- package/lib/schema/types/product/index.js +9 -1
- package/lib/schema/types/product/index.js.map +1 -1
- package/lib/schema/types/product/plan-product.js +2 -2
- package/lib/schema/types/product/product.js +4 -4
- package/lib/schema/types/product/simple-product.js +2 -2
- package/lib/schema/types/product/tokenized-product.d.ts +2 -0
- package/lib/schema/types/product/tokenized-product.js +57 -0
- package/lib/schema/types/product/tokenized-product.js.map +1 -0
- package/lib/schema/types/quotation.js +0 -1
- package/lib/schema/types/quotation.js.map +1 -1
- package/lib/schema/types/user.js +32 -1
- package/lib/schema/types/user.js.map +1 -1
- package/lib/schema/types/warehousing.js +23 -1
- package/lib/schema/types/warehousing.js.map +1 -1
- package/lib/user-context.d.ts +2 -2
- package/lib/user-context.js +20 -9
- package/lib/user-context.js.map +1 -1
- package/package.json +9 -8
- package/src/api-index.ts +4 -0
- package/src/context.ts +3 -3
- package/src/createBulkImportServer.ts +1 -1
- package/src/createERCMetadataServer.ts +71 -0
- package/src/errors.ts +5 -0
- package/src/loaders/index.ts +2 -1
- package/src/locale-context.ts +2 -1
- package/src/resolvers/index.ts +2 -0
- package/src/resolvers/mutations/accounts/addWebAuthnCredentials.ts +29 -0
- package/src/resolvers/mutations/accounts/createUser.ts +28 -6
- package/src/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.ts +20 -0
- package/src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts +28 -0
- package/src/resolvers/mutations/accounts/loginWithWebAuthn.ts +16 -0
- package/src/resolvers/mutations/accounts/logout.ts +5 -2
- package/src/resolvers/mutations/accounts/logoutAllSessions.ts +5 -2
- package/src/resolvers/mutations/accounts/removeWebAuthnCredentials.ts +30 -0
- package/src/resolvers/mutations/{index.js → index.ts} +14 -0
- package/src/resolvers/mutations/orders/signPaymentProviderForCheckout.ts +8 -1
- package/src/resolvers/mutations/{pageView.js → pageView.ts} +0 -0
- package/src/resolvers/mutations/products/updateProductTokenization.ts +28 -0
- package/src/resolvers/mutations/warehousing/exportToken.ts +33 -0
- package/src/resolvers/queries/{index.js → index.ts} +2 -0
- package/src/resolvers/queries/warehousing/token.ts +17 -0
- package/src/resolvers/scalars/LowerCaseString.ts +19 -0
- package/src/resolvers/scalars/index.ts +5 -0
- package/src/resolvers/type/assortment/assortment-filter-types.ts +1 -1
- package/src/resolvers/type/assortment/assortment-link-types.ts +1 -1
- package/src/resolvers/type/assortment/assortment-product-types.ts +1 -1
- package/src/resolvers/type/currency-types.ts +5 -0
- package/src/resolvers/type/{index.js → index.ts} +8 -0
- package/src/resolvers/type/login-method-response-types.ts +4 -0
- package/src/resolvers/type/order/order-delivery-discount-types.ts +1 -1
- package/src/resolvers/type/order/order-delivery-shipping-types.ts +1 -1
- package/src/resolvers/type/order/order-discount-types.ts +1 -1
- package/src/resolvers/type/order/order-discountable-types.ts +1 -1
- package/src/resolvers/type/order/order-global-discount-types.ts +1 -1
- package/src/resolvers/type/order/order-item-discount-types.ts +1 -1
- package/src/resolvers/type/order/order-item-types.ts +1 -1
- package/src/resolvers/type/order/order-payment-card-types.ts +1 -1
- package/src/resolvers/type/order/order-payment-discount-types.ts +1 -1
- package/src/resolvers/type/order/order-payment-generic-types.ts +1 -1
- package/src/resolvers/type/order/order-payment-invoice-types.ts +1 -1
- package/src/resolvers/type/order/order-types.ts +2 -10
- package/src/resolvers/type/product/product-tokenized-types.ts +34 -0
- package/src/resolvers/type/quotation-types.ts +0 -17
- package/src/resolvers/type/shop-types.ts +1 -1
- package/src/resolvers/type/token-types.ts +43 -0
- package/src/resolvers/type/user-types.ts +14 -1
- package/src/resolvers/type/webauthn-credentials-types.ts +27 -0
- package/src/roles/admin.ts +3 -0
- package/src/roles/all.ts +3 -0
- package/src/roles/index.ts +4 -1
- package/src/roles/loggedIn.ts +13 -0
- package/src/schema/inputTypes.js +6 -4
- package/src/schema/mutation.js +50 -4
- package/src/schema/query.js +9 -4
- package/src/schema/scalars.js +1 -0
- package/src/schema/types/assortment.js +6 -6
- package/src/schema/types/currency.js +1 -0
- package/src/schema/types/order/order.js +0 -33
- package/src/schema/types/payment.js +1 -1
- package/src/schema/types/product/bundle-product.js +2 -2
- package/src/schema/types/product/configurable-product.js +2 -2
- package/src/schema/types/product/index.js +9 -1
- package/src/schema/types/product/plan-product.js +2 -2
- package/src/schema/types/product/product.js +4 -4
- package/src/schema/types/product/simple-product.js +2 -2
- package/src/schema/types/product/tokenized-product.js +56 -0
- package/src/schema/types/quotation.js +0 -1
- package/src/schema/types/user.js +32 -1
- package/src/schema/types/warehousing.js +23 -1
- package/src/user-context.ts +23 -9
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Context, Root } from '@unchainedshop/types/api';
|
|
2
|
+
import { log } from '@unchainedshop/logger';
|
|
3
|
+
import { InvalidIdError } from '../../../errors';
|
|
4
|
+
|
|
5
|
+
export default async function exportToken(
|
|
6
|
+
root: Root,
|
|
7
|
+
{
|
|
8
|
+
tokenId,
|
|
9
|
+
quantity,
|
|
10
|
+
recipientWalletAddress,
|
|
11
|
+
}: { tokenId: string; quantity: number; recipientWalletAddress: string },
|
|
12
|
+
{ modules, userId }: Context,
|
|
13
|
+
) {
|
|
14
|
+
log(`mutation exportToken ${tokenId}`, {
|
|
15
|
+
userId,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
if (!tokenId) throw new InvalidIdError({ tokenId });
|
|
19
|
+
|
|
20
|
+
const token = await modules.warehousing.findToken({ tokenId });
|
|
21
|
+
|
|
22
|
+
await modules.worker.addWork({
|
|
23
|
+
type: 'EXPORT_TOKEN',
|
|
24
|
+
retries: 5,
|
|
25
|
+
input: {
|
|
26
|
+
token,
|
|
27
|
+
quantity,
|
|
28
|
+
recipientWalletAddress,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return modules.warehousing.findToken({ tokenId });
|
|
33
|
+
}
|
|
@@ -61,6 +61,7 @@ import warehousingInterfaces from './warehousing/warehousingInterfaces';
|
|
|
61
61
|
import warehousingProvider from './warehousing/warehousingProvider';
|
|
62
62
|
import warehousingProviders from './warehousing/warehousingProviders';
|
|
63
63
|
import warehousingProvidersCount from './warehousing/warehousingProvidersCount';
|
|
64
|
+
import token from './warehousing/token';
|
|
64
65
|
import work from './worker/work';
|
|
65
66
|
import workQueue from './worker/workQueue';
|
|
66
67
|
import workQueueCount from './worker/workQueueCount';
|
|
@@ -95,6 +96,7 @@ export default {
|
|
|
95
96
|
warehousingProviders: acl(actions.viewWarehousingProviders)(warehousingProviders),
|
|
96
97
|
warehousingProvider: acl(actions.viewWarehousingProvider)(warehousingProvider),
|
|
97
98
|
warehousingInterfaces: acl(actions.viewWarehousingInterfaces)(warehousingInterfaces),
|
|
99
|
+
token: acl(actions.viewToken)(token),
|
|
98
100
|
translatedProductTexts: acl(actions.viewTranslations)(translatedProductTexts),
|
|
99
101
|
translatedProductMediaTexts: acl(actions.viewTranslations)(translatedProductMediaTexts),
|
|
100
102
|
translatedProductVariationTexts: acl(actions.viewTranslations)(translatedProductVariationTexts),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { Context, Root } from '@unchainedshop/types/api';
|
|
3
|
+
import { InvalidIdError } from '../../../errors';
|
|
4
|
+
|
|
5
|
+
export default async function token(
|
|
6
|
+
root: Root,
|
|
7
|
+
{ tokenId }: { tokenId: string },
|
|
8
|
+
{ modules, userId }: Context,
|
|
9
|
+
) {
|
|
10
|
+
log(`query token ${tokenId}`, { userId });
|
|
11
|
+
|
|
12
|
+
if (!tokenId) throw new InvalidIdError({ tokenId });
|
|
13
|
+
|
|
14
|
+
return modules.warehousing.findToken({
|
|
15
|
+
tokenId,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GraphQLScalarType, Kind } from 'graphql';
|
|
2
|
+
|
|
3
|
+
const LowerCaseString = new GraphQLScalarType({
|
|
4
|
+
name: 'LowerCaseString',
|
|
5
|
+
description: 'Lowercased string',
|
|
6
|
+
serialize: (value: any) => value?.toLowerCase(),
|
|
7
|
+
parseValue(value) {
|
|
8
|
+
return String(value)?.toLowerCase();
|
|
9
|
+
},
|
|
10
|
+
parseLiteral(ast) {
|
|
11
|
+
if (ast.kind === Kind.STRING) {
|
|
12
|
+
return ast.value?.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return null;
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export default LowerCaseString;
|
|
@@ -4,7 +4,7 @@ import { Filter } from '@unchainedshop/types/filters';
|
|
|
4
4
|
|
|
5
5
|
type HelperType<T> = (assortmentFilter: AssortmentFilterType, _: never, context: Context) => T;
|
|
6
6
|
|
|
7
|
-
type AssortmentFilterHelperTypes = {
|
|
7
|
+
export type AssortmentFilterHelperTypes = {
|
|
8
8
|
assortment: HelperType<Promise<Assortment>>;
|
|
9
9
|
filter: HelperType<Promise<Filter>>;
|
|
10
10
|
};
|
|
@@ -3,7 +3,7 @@ import { Assortment, AssortmentLink as AssortmentLinkType } from '@unchainedshop
|
|
|
3
3
|
|
|
4
4
|
type HelperType<T> = (assortmentLink: AssortmentLinkType, _: never, context: Context) => T;
|
|
5
5
|
|
|
6
|
-
type AssortmentLinkHelperTypes = {
|
|
6
|
+
export type AssortmentLinkHelperTypes = {
|
|
7
7
|
child: HelperType<Promise<Assortment>>;
|
|
8
8
|
parent: HelperType<Promise<Assortment>>;
|
|
9
9
|
};
|
|
@@ -7,7 +7,7 @@ import { Product } from '@unchainedshop/types/products';
|
|
|
7
7
|
|
|
8
8
|
type HelperType<T> = (assortmentProduct: AssortmentProductType, _: never, context: Context) => T;
|
|
9
9
|
|
|
10
|
-
type AssortmentProductHelperTypes = {
|
|
10
|
+
export type AssortmentProductHelperTypes = {
|
|
11
11
|
assortment: HelperType<Promise<Assortment>>;
|
|
12
12
|
product: HelperType<Promise<Product>>;
|
|
13
13
|
};
|
|
@@ -9,6 +9,7 @@ import { BundleProduct } from './product/product-bundle-types';
|
|
|
9
9
|
import { Color } from './color-types';
|
|
10
10
|
import { ConfigurableProduct } from './product/product-configurable-types';
|
|
11
11
|
import { Country } from './country-types';
|
|
12
|
+
import { Currency } from './currency-types';
|
|
12
13
|
import { DeliveryProvider } from './delivery-provider-types';
|
|
13
14
|
import { Dimensions } from './dimensions-types';
|
|
14
15
|
import { Dispatch } from './dispatch-types';
|
|
@@ -56,12 +57,15 @@ import { ProductVariationOption } from './product/product-variation-option-types
|
|
|
56
57
|
import { Quotation } from './quotation-types';
|
|
57
58
|
import { Shop } from './shop-types';
|
|
58
59
|
import { SimpleProduct } from './product/product-simple-types';
|
|
60
|
+
import { TokenizedProduct } from './product/product-tokenized-types';
|
|
59
61
|
import { Stock } from './stock-types';
|
|
60
62
|
import { User } from './user-types';
|
|
63
|
+
import { WebAuthnCredentials } from './webauthn-credentials-types';
|
|
61
64
|
import { WarehousingProvider } from './warehousing-provider-types';
|
|
62
65
|
import { Work } from './work-types';
|
|
63
66
|
import { Event } from './event-types';
|
|
64
67
|
import { Media } from './media-types';
|
|
68
|
+
import { Token } from './token-types';
|
|
65
69
|
|
|
66
70
|
const types = {
|
|
67
71
|
Assortment,
|
|
@@ -75,6 +79,7 @@ const types = {
|
|
|
75
79
|
Color,
|
|
76
80
|
ConfigurableProduct,
|
|
77
81
|
Country,
|
|
82
|
+
Currency,
|
|
78
83
|
DeliveryProvider,
|
|
79
84
|
Dimensions,
|
|
80
85
|
Dispatch,
|
|
@@ -122,8 +127,11 @@ const types = {
|
|
|
122
127
|
Quotation,
|
|
123
128
|
Shop,
|
|
124
129
|
SimpleProduct,
|
|
130
|
+
TokenizedProduct,
|
|
131
|
+
Token,
|
|
125
132
|
Stock,
|
|
126
133
|
User,
|
|
134
|
+
WebAuthnCredentials,
|
|
127
135
|
WarehousingProvider,
|
|
128
136
|
Work,
|
|
129
137
|
Event,
|
|
@@ -6,7 +6,7 @@ import crypto from 'crypto';
|
|
|
6
6
|
|
|
7
7
|
type HelperType<P, T> = (orderDelivery: OrderDeliveryDiscountType, params: P, context: Context) => T;
|
|
8
8
|
|
|
9
|
-
interface OrderDeliveryDiscountHelperTypes {
|
|
9
|
+
export interface OrderDeliveryDiscountHelperTypes {
|
|
10
10
|
_id: HelperType<never, string>;
|
|
11
11
|
orderDiscount: HelperType<never, Promise<OrderDiscount>>;
|
|
12
12
|
total: HelperType<never, OrderPrice>;
|
|
@@ -5,7 +5,7 @@ import { OrderDelivery, OrderDeliveryDiscount } from '@unchainedshop/types/order
|
|
|
5
5
|
|
|
6
6
|
type HelperType<T> = (orderDelivery: OrderDelivery, _: never, context: Context) => T;
|
|
7
7
|
|
|
8
|
-
interface OrderDeliveryShippingHelperTypes {
|
|
8
|
+
export interface OrderDeliveryShippingHelperTypes {
|
|
9
9
|
address: HelperType<Address>;
|
|
10
10
|
discounts: HelperType<Promise<Array<OrderDeliveryDiscount>>>;
|
|
11
11
|
provider: HelperType<Promise<DeliveryProvider>>;
|
|
@@ -6,7 +6,7 @@ import { OrderDiscountDirector } from '@unchainedshop/core-orders';
|
|
|
6
6
|
|
|
7
7
|
type HelperType<P, T> = (orderDiscount: OrderDiscountType, params: P, context: Context) => T;
|
|
8
8
|
|
|
9
|
-
interface OrderDiscountHelperTypes {
|
|
9
|
+
export interface OrderDiscountHelperTypes {
|
|
10
10
|
interface: HelperType<
|
|
11
11
|
never,
|
|
12
12
|
Promise<{
|
|
@@ -5,7 +5,7 @@ import { OrderPayment } from '@unchainedshop/types/orders.payments';
|
|
|
5
5
|
import { OrderPosition } from '@unchainedshop/types/orders.positions';
|
|
6
6
|
import { OrderPrice } from '@unchainedshop/types/orders.pricing';
|
|
7
7
|
|
|
8
|
-
const OrderDiscountableType = {
|
|
8
|
+
export const OrderDiscountableType = {
|
|
9
9
|
OrderItemDiscount: 'OrderItemDiscount',
|
|
10
10
|
OrderPaymentDiscount: 'OrderPaymentDiscount',
|
|
11
11
|
OrderDeliveryDiscount: 'OrderDeliveryDiscount',
|
|
@@ -13,7 +13,7 @@ type HelperType<P, T> = (
|
|
|
13
13
|
context: Context,
|
|
14
14
|
) => T;
|
|
15
15
|
|
|
16
|
-
interface OrderGlobalDiscountHelperTypes {
|
|
16
|
+
export interface OrderGlobalDiscountHelperTypes {
|
|
17
17
|
_id: HelperType<never, string>;
|
|
18
18
|
orderDiscount: HelperType<never, Promise<OrderDiscount>>;
|
|
19
19
|
total: HelperType<never, OrderPrice>;
|
|
@@ -6,7 +6,7 @@ import crypto from 'crypto';
|
|
|
6
6
|
|
|
7
7
|
type HelperType<P, T> = (orderPositionDiscount: OrderPositionDiscount, params: P, context: Context) => T;
|
|
8
8
|
|
|
9
|
-
interface OrderItemDiscountHelperTypes {
|
|
9
|
+
export interface OrderItemDiscountHelperTypes {
|
|
10
10
|
_id: HelperType<never, string>;
|
|
11
11
|
orderDiscount: HelperType<never, Promise<OrderDiscount>>;
|
|
12
12
|
total: HelperType<never, OrderPrice>;
|
|
@@ -10,7 +10,7 @@ import crypto from 'crypto';
|
|
|
10
10
|
|
|
11
11
|
type HelperType<P, T> = (orderPosition: OrderPosition, params: P, context: Context) => T;
|
|
12
12
|
|
|
13
|
-
interface OrderItemHelperTypes {
|
|
13
|
+
export interface OrderItemHelperTypes {
|
|
14
14
|
discounts: HelperType<never, Promise<Array<OrderPositionDiscount>>>;
|
|
15
15
|
dispatches: HelperType<
|
|
16
16
|
never,
|
|
@@ -4,7 +4,7 @@ import { PaymentProvider } from '@unchainedshop/types/payments';
|
|
|
4
4
|
|
|
5
5
|
type HelperType<T> = (orderPayment: OrderPayment, _: never, context: Context) => T;
|
|
6
6
|
|
|
7
|
-
interface OrderPaymentCardHelperTypes {
|
|
7
|
+
export interface OrderPaymentCardHelperTypes {
|
|
8
8
|
discounts: HelperType<Promise<Array<OrderPaymentDiscount>>>;
|
|
9
9
|
provider: HelperType<Promise<PaymentProvider>>;
|
|
10
10
|
status: HelperType<string>;
|
|
@@ -10,7 +10,7 @@ type HelperType<P, T> = (
|
|
|
10
10
|
context: Context,
|
|
11
11
|
) => T;
|
|
12
12
|
|
|
13
|
-
interface OrderPaymentDiscountHelperTypes {
|
|
13
|
+
export interface OrderPaymentDiscountHelperTypes {
|
|
14
14
|
_id: HelperType<never, string>;
|
|
15
15
|
orderDiscount: HelperType<never, Promise<OrderDiscount>>;
|
|
16
16
|
total: HelperType<never, OrderPrice>;
|
|
@@ -4,7 +4,7 @@ import { PaymentProvider } from '@unchainedshop/types/payments';
|
|
|
4
4
|
|
|
5
5
|
type HelperType<P, T> = (orderPayment: OrderPayment, params: P, context: Context) => T;
|
|
6
6
|
|
|
7
|
-
interface OrderPaymentGenericHelperTypes {
|
|
7
|
+
export interface OrderPaymentGenericHelperTypes {
|
|
8
8
|
discounts: HelperType<never, Promise<Array<OrderPaymentDiscount>>>;
|
|
9
9
|
provider: HelperType<never, Promise<PaymentProvider>>;
|
|
10
10
|
status: HelperType<never, string>;
|
|
@@ -4,7 +4,7 @@ import { PaymentProvider } from '@unchainedshop/types/payments';
|
|
|
4
4
|
|
|
5
5
|
type HelperType<T> = (orderPayment: OrderPayment, _: never, context: Context) => T;
|
|
6
6
|
|
|
7
|
-
interface OrderPaymentInvoiceHelperTypes {
|
|
7
|
+
export interface OrderPaymentInvoiceHelperTypes {
|
|
8
8
|
discounts: HelperType<Promise<Array<OrderPaymentDiscount>>>;
|
|
9
9
|
provider: HelperType<Promise<PaymentProvider>>;
|
|
10
10
|
status: HelperType<string>;
|
|
@@ -3,8 +3,7 @@ import { Country } from '@unchainedshop/types/countries';
|
|
|
3
3
|
import { Currency } from '@unchainedshop/types/currencies';
|
|
4
4
|
import { DeliveryProvider } from '@unchainedshop/types/delivery';
|
|
5
5
|
import { Enrollment } from '@unchainedshop/types/enrollments';
|
|
6
|
-
import {
|
|
7
|
-
import { Order as OrderType, OrderDocumentType } from '@unchainedshop/types/orders';
|
|
6
|
+
import { Order as OrderType } from '@unchainedshop/types/orders';
|
|
8
7
|
import { OrderDelivery } from '@unchainedshop/types/orders.deliveries';
|
|
9
8
|
import { OrderDiscount } from '@unchainedshop/types/orders.discounts';
|
|
10
9
|
import { OrderPayment } from '@unchainedshop/types/orders.payments';
|
|
@@ -16,14 +15,13 @@ import crypto from 'crypto';
|
|
|
16
15
|
|
|
17
16
|
type HelperType<P, T> = (order: OrderType, params: P, context: Context) => T;
|
|
18
17
|
|
|
19
|
-
interface OrderHelperTypes {
|
|
18
|
+
export interface OrderHelperTypes {
|
|
20
19
|
supportedDeliveryProviders: HelperType<never, Promise<Array<DeliveryProvider>>>;
|
|
21
20
|
supportedPaymentProviders: HelperType<never, Promise<Array<PaymentProvider>>>;
|
|
22
21
|
currency: HelperType<never, Promise<Currency>>;
|
|
23
22
|
country: HelperType<never, Promise<Country>>;
|
|
24
23
|
discounts: HelperType<never, Promise<Array<OrderDiscount>>>;
|
|
25
24
|
delivery: HelperType<never, Promise<OrderDelivery>>;
|
|
26
|
-
documents: HelperType<{ type: OrderDocumentType }, Promise<Array<File>>>;
|
|
27
25
|
enrollment: HelperType<never, Promise<Enrollment>>;
|
|
28
26
|
payment: HelperType<never, Promise<OrderPayment>>;
|
|
29
27
|
items: HelperType<never, Promise<Array<OrderPosition>>>;
|
|
@@ -55,12 +53,6 @@ export const Order: OrderHelperTypes = {
|
|
|
55
53
|
discounts: async (obj, _, { modules }) =>
|
|
56
54
|
modules.orders.discounts.findOrderDiscounts({ orderId: obj._id }),
|
|
57
55
|
|
|
58
|
-
documents: async (obj, { type }, { modules }) =>
|
|
59
|
-
modules.files.findFilesByMetaData(
|
|
60
|
-
{ meta: { orderId: obj._id, type } },
|
|
61
|
-
{ sort: { 'meta.data': -1 } },
|
|
62
|
-
),
|
|
63
|
-
|
|
64
56
|
delivery: async (obj, _, { modules }) =>
|
|
65
57
|
modules.orders.deliveries.findDelivery({
|
|
66
58
|
orderDeliveryId: obj.deliveryId,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TokenizedProductHelperTypes } from '@unchainedshop/types/products';
|
|
2
|
+
import localePkg from 'locale';
|
|
3
|
+
import { PlanProduct } from './product-plan-types';
|
|
4
|
+
|
|
5
|
+
const { Locale } = localePkg;
|
|
6
|
+
|
|
7
|
+
export const TokenizedProduct: TokenizedProductHelperTypes = {
|
|
8
|
+
...PlanProduct,
|
|
9
|
+
|
|
10
|
+
contractAddress(product) {
|
|
11
|
+
return product.tokenization?.contractAddress;
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
contractConfiguration(product) {
|
|
15
|
+
if (!product.tokenization) return null;
|
|
16
|
+
return {
|
|
17
|
+
supply: product.tokenization.supply,
|
|
18
|
+
tokenId: product.tokenization.tokenId,
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
contractStandard(product) {
|
|
23
|
+
return product.tokenization?.contractStandard;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
async ercMetadata(product, { forceLocale }, context) {
|
|
27
|
+
const locale = forceLocale ? new Locale(forceLocale) : context.localeContext;
|
|
28
|
+
return context.services.products.ercMetadata({ product, locale }, context);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
delete TokenizedProduct.salesUnit;
|
|
33
|
+
delete TokenizedProduct.salesQuantityPerUnit;
|
|
34
|
+
delete TokenizedProduct.defaultOrderQuantity;
|
|
@@ -4,14 +4,12 @@ import { User } from '@unchainedshop/types/user';
|
|
|
4
4
|
import { Product } from '@unchainedshop/types/products';
|
|
5
5
|
import { Country } from '@unchainedshop/types/countries';
|
|
6
6
|
import { Currency } from '@unchainedshop/types/currencies';
|
|
7
|
-
import { File } from '@unchainedshop/types/files';
|
|
8
7
|
|
|
9
8
|
type HelperType<P, T> = (quotation: QuotationType, params: P, context: Context) => T;
|
|
10
9
|
|
|
11
10
|
type QuotationHelperTypes = {
|
|
12
11
|
country: HelperType<never, Promise<Country>>;
|
|
13
12
|
currency: HelperType<never, Promise<Currency>>;
|
|
14
|
-
documents: HelperType<{ type: string }, Promise<Array<File>>>;
|
|
15
13
|
isExpired: HelperType<{ referenceDate: Date }, boolean>;
|
|
16
14
|
status: HelperType<never, string>;
|
|
17
15
|
product: HelperType<never, Promise<Product>>;
|
|
@@ -23,21 +21,6 @@ export const Quotation: QuotationHelperTypes = {
|
|
|
23
21
|
|
|
24
22
|
currency: async (obj, _, { modules }) => modules.currencies.findCurrency({ isoCode: obj.currency }),
|
|
25
23
|
|
|
26
|
-
documents: (obj, { type }, { modules }) =>
|
|
27
|
-
modules.files.findFilesByMetaData(
|
|
28
|
-
{
|
|
29
|
-
meta: {
|
|
30
|
-
quotationId: obj._id,
|
|
31
|
-
type,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
sort: {
|
|
36
|
-
'meta.date': -1,
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
),
|
|
40
|
-
|
|
41
24
|
isExpired: (obj, { referenceDate }, { modules }) =>
|
|
42
25
|
modules.quotations.isExpired(obj, { referenceDate }),
|
|
43
26
|
|
|
@@ -6,7 +6,7 @@ import { allRoles, actions } from '../../roles';
|
|
|
6
6
|
|
|
7
7
|
type HelperType<T> = (root: never, params: never, context: Context) => Promise<T>;
|
|
8
8
|
|
|
9
|
-
interface ShopHelperTypes {
|
|
9
|
+
export interface ShopHelperTypes {
|
|
10
10
|
_id: () => string;
|
|
11
11
|
country: HelperType<Country>;
|
|
12
12
|
language: HelperType<Language>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Context } from '@unchainedshop/types/api';
|
|
2
|
+
import { Product } from '@unchainedshop/types/products';
|
|
3
|
+
import { User } from '@unchainedshop/types/user';
|
|
4
|
+
import { TokenSurrogate } from '@unchainedshop/types/warehousing';
|
|
5
|
+
import { WorkStatus } from '@unchainedshop/types/worker';
|
|
6
|
+
|
|
7
|
+
type HelperType<T> = (root: TokenSurrogate, params: never, context: Context) => Promise<T>;
|
|
8
|
+
|
|
9
|
+
export enum TokenExportStatus {
|
|
10
|
+
CENTRALIZED = 'CENTRALIZED',
|
|
11
|
+
EXPORTING = 'EXPORTING',
|
|
12
|
+
DECENTRALIZED = 'DECENTRALIZED',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface TokenHelperTypes {
|
|
16
|
+
product: HelperType<Product>;
|
|
17
|
+
status: HelperType<TokenExportStatus>;
|
|
18
|
+
user: HelperType<User>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Token: TokenHelperTypes = {
|
|
22
|
+
product: async (token, _params, { modules }) => {
|
|
23
|
+
return modules.products.findProduct({ productId: token.productId });
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
user: async (token, _params, { modules }) => {
|
|
27
|
+
if (!token.userId) return null;
|
|
28
|
+
return modules.users.findUserById(token.userId);
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
status: async (token, _params, { modules }) => {
|
|
32
|
+
if (token.walletAddress && !token.userId) {
|
|
33
|
+
return TokenExportStatus.DECENTRALIZED;
|
|
34
|
+
}
|
|
35
|
+
const workItems = await modules.worker.findWorkQueue({
|
|
36
|
+
types: ['EXPORT_TOKEN'],
|
|
37
|
+
status: [WorkStatus.NEW, WorkStatus.ALLOCATED],
|
|
38
|
+
});
|
|
39
|
+
if (workItems.find((item) => item.input?.token?._id === token._id))
|
|
40
|
+
return TokenExportStatus.EXPORTING;
|
|
41
|
+
return TokenExportStatus.CENTRALIZED;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -8,9 +8,10 @@ import { Language } from '@unchainedshop/types/languages';
|
|
|
8
8
|
import { Order } from '@unchainedshop/types/orders';
|
|
9
9
|
import { PaymentCredentials } from '@unchainedshop/types/payments';
|
|
10
10
|
import { Quotation } from '@unchainedshop/types/quotations';
|
|
11
|
-
import { Email, User as UserType, UserProfile } from '@unchainedshop/types/user';
|
|
11
|
+
import { Email, User as UserType, UserProfile, WebAuthnCredentials } from '@unchainedshop/types/user';
|
|
12
12
|
import type { Locale } from 'locale';
|
|
13
13
|
import { log, LogLevel } from '@unchainedshop/logger';
|
|
14
|
+
import { TokenSurrogate } from '@unchainedshop/types/warehousing';
|
|
14
15
|
import { checkAction, checkTypeResolver } from '../../acl';
|
|
15
16
|
import { actions } from '../../roles';
|
|
16
17
|
|
|
@@ -41,6 +42,8 @@ export interface UserHelperTypes {
|
|
|
41
42
|
Array<Order>
|
|
42
43
|
>;
|
|
43
44
|
paymentCredentials: HelperType<any, Array<PaymentCredentials>>;
|
|
45
|
+
tokens: HelperType<any, Array<TokenSurrogate>>;
|
|
46
|
+
webAuthnCredentials: HelperType<any, Array<WebAuthnCredentials>>;
|
|
44
47
|
primaryEmail: HelperType<any, Email>;
|
|
45
48
|
profile: HelperType<any, UserProfile>;
|
|
46
49
|
quotations: HelperType<{ sort?: Array<SortOption>; queryString?: string }, Array<Quotation>>;
|
|
@@ -132,6 +135,11 @@ export const User: UserHelperTypes = {
|
|
|
132
135
|
return modules.orders.cart({ countryContext, orderNumber: params.orderNumber }, user);
|
|
133
136
|
},
|
|
134
137
|
|
|
138
|
+
async tokens(user, params, context) {
|
|
139
|
+
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
140
|
+
return context.modules.warehousing.findTokens({ userId: user._id });
|
|
141
|
+
},
|
|
142
|
+
|
|
135
143
|
country: async (user, params, context) => {
|
|
136
144
|
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
137
145
|
return context.services.users.getUserCountry(user, params, context);
|
|
@@ -181,6 +189,11 @@ export const User: UserHelperTypes = {
|
|
|
181
189
|
);
|
|
182
190
|
},
|
|
183
191
|
|
|
192
|
+
webAuthnCredentials: async (user, params, context) => {
|
|
193
|
+
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
194
|
+
return user.services.webAuthn || [];
|
|
195
|
+
},
|
|
196
|
+
|
|
184
197
|
quotations: async (user, params, context) => {
|
|
185
198
|
await checkAction(context, viewUserQuotations, [user, params]);
|
|
186
199
|
return context.modules.quotations.findQuotations({
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Context } from '@unchainedshop/types/api';
|
|
2
|
+
import { WebAuthnCredentials as WebAuthnCredentialsTypes } from '@unchainedshop/types/user';
|
|
3
|
+
|
|
4
|
+
type HelperType<P, T> = (
|
|
5
|
+
credentials: WebAuthnCredentialsTypes,
|
|
6
|
+
params: P,
|
|
7
|
+
context: Context,
|
|
8
|
+
) => Promise<T>;
|
|
9
|
+
|
|
10
|
+
export interface WebAuthnCredentialsHelperTypes {
|
|
11
|
+
_id: HelperType<any, string>;
|
|
12
|
+
created: HelperType<any, Date>;
|
|
13
|
+
mdsMetadata: HelperType<any, any>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const WebAuthnCredentials: WebAuthnCredentialsHelperTypes = {
|
|
17
|
+
async _id(obj) {
|
|
18
|
+
return obj.id;
|
|
19
|
+
},
|
|
20
|
+
async created(obj) {
|
|
21
|
+
return obj.created || new Date(0);
|
|
22
|
+
},
|
|
23
|
+
async mdsMetadata(obj, _, { modules }) {
|
|
24
|
+
const metadata = await modules.accounts.webAuthn.findMDSMetadataForAAGUID(obj.aaguid);
|
|
25
|
+
return metadata;
|
|
26
|
+
},
|
|
27
|
+
};
|
package/src/roles/admin.ts
CHANGED
|
@@ -23,6 +23,8 @@ export const admin = (role, actions) => {
|
|
|
23
23
|
role.allow(actions.managePaymentProviders, () => true);
|
|
24
24
|
role.allow(actions.manageDeliveryProviders, () => true);
|
|
25
25
|
role.allow(actions.manageWarehousingProviders, () => true);
|
|
26
|
+
role.allow(actions.updateToken, () => true);
|
|
27
|
+
role.allow(actions.viewToken, () => true);
|
|
26
28
|
role.allow(actions.manageUsers, () => true);
|
|
27
29
|
role.allow(actions.updateUser, () => true);
|
|
28
30
|
role.allow(actions.updateUsername, () => true);
|
|
@@ -47,6 +49,7 @@ export const admin = (role, actions) => {
|
|
|
47
49
|
role.allow(actions.viewUserPublicInfos, () => true);
|
|
48
50
|
role.allow(actions.viewUserPrivateInfos, () => true);
|
|
49
51
|
role.allow(actions.viewUserEnrollments, () => true);
|
|
52
|
+
role.allow(actions.viewUserTokens, () => true);
|
|
50
53
|
role.allow(actions.reviewProduct, () => true);
|
|
51
54
|
role.allow(actions.updateProductReview, () => true);
|
|
52
55
|
role.allow(actions.manageProductReviews, () => true);
|
package/src/roles/all.ts
CHANGED
|
@@ -31,6 +31,8 @@ export const all = (role, actions) => {
|
|
|
31
31
|
role.allow(actions.managePaymentProviders, () => false);
|
|
32
32
|
role.allow(actions.manageDeliveryProviders, () => false);
|
|
33
33
|
role.allow(actions.manageWarehousingProviders, () => false);
|
|
34
|
+
role.allow(actions.updateToken, () => false);
|
|
35
|
+
role.allow(actions.viewToken, () => false);
|
|
34
36
|
role.allow(actions.manageAssortments, () => false);
|
|
35
37
|
role.allow(actions.manageFilters, () => false);
|
|
36
38
|
role.allow(actions.manageUsers, () => false);
|
|
@@ -49,6 +51,7 @@ export const all = (role, actions) => {
|
|
|
49
51
|
role.allow(actions.viewLogs, isInLoginMutationResponse);
|
|
50
52
|
role.allow(actions.viewUserRoles, isInLoginMutationResponse);
|
|
51
53
|
role.allow(actions.viewUserOrders, isInLoginMutationResponse);
|
|
54
|
+
role.allow(actions.viewUserTokens, isInLoginMutationResponse);
|
|
52
55
|
role.allow(actions.viewUserQuotations, isInLoginMutationResponse);
|
|
53
56
|
role.allow(actions.viewUserPrivateInfos, isInLoginMutationResponse);
|
|
54
57
|
role.allow(actions.viewUserEnrollments, isInLoginMutationResponse);
|
package/src/roles/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ const roles = {
|
|
|
12
12
|
|
|
13
13
|
const allRoles = roles;
|
|
14
14
|
|
|
15
|
-
const actions = [
|
|
15
|
+
const actions: Record<string, string> = [
|
|
16
16
|
'viewEvent',
|
|
17
17
|
'viewEvents',
|
|
18
18
|
'viewUserRoles',
|
|
@@ -21,6 +21,7 @@ const actions = [
|
|
|
21
21
|
'viewUserPublicInfos',
|
|
22
22
|
'viewUserPrivateInfos',
|
|
23
23
|
'viewUserEnrollments',
|
|
24
|
+
'viewUserTokens',
|
|
24
25
|
'viewLogs',
|
|
25
26
|
'viewUser',
|
|
26
27
|
'viewUsers',
|
|
@@ -57,6 +58,8 @@ const actions = [
|
|
|
57
58
|
'managePaymentProviders',
|
|
58
59
|
'manageDeliveryProviders',
|
|
59
60
|
'manageWarehousingProviders',
|
|
61
|
+
'updateToken',
|
|
62
|
+
'viewToken',
|
|
60
63
|
'manageAssortments',
|
|
61
64
|
'manageFilters',
|
|
62
65
|
'createCart',
|
package/src/roles/loggedIn.ts
CHANGED
|
@@ -190,6 +190,16 @@ export const loggedIn = (role: any, actions: Record<string, string>) => {
|
|
|
190
190
|
return credentials.userId === userId;
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
+
const isOwnedToken = async (
|
|
194
|
+
obj: any,
|
|
195
|
+
{ tokenId }: { tokenId: string },
|
|
196
|
+
{ modules, userId }: Context,
|
|
197
|
+
) => {
|
|
198
|
+
const token = await modules.warehousing.findToken({ tokenId });
|
|
199
|
+
if (!token) return true;
|
|
200
|
+
return token.userId === userId;
|
|
201
|
+
};
|
|
202
|
+
|
|
193
203
|
role.allow(actions.viewEvent, false);
|
|
194
204
|
role.allow(actions.viewEvents, false);
|
|
195
205
|
role.allow(actions.viewUser, isMyself);
|
|
@@ -198,6 +208,7 @@ export const loggedIn = (role: any, actions: Record<string, string>) => {
|
|
|
198
208
|
role.allow(actions.viewUserQuotations, isMyself);
|
|
199
209
|
role.allow(actions.viewUserEnrollments, isMyself);
|
|
200
210
|
role.allow(actions.viewUserPrivateInfos, isMyself);
|
|
211
|
+
role.allow(actions.viewUserTokens, isMyself);
|
|
201
212
|
role.allow(actions.updateUser, isMyself);
|
|
202
213
|
role.allow(actions.authTwoFactor, isMyself);
|
|
203
214
|
role.allow(actions.manageTwoFactor, isMyself);
|
|
@@ -223,4 +234,6 @@ export const loggedIn = (role: any, actions: Record<string, string>) => {
|
|
|
223
234
|
role.allow(actions.voteProductReview, () => true);
|
|
224
235
|
role.allow(actions.registerPaymentCredentials, () => true);
|
|
225
236
|
role.allow(actions.managePaymentCredentials, isOwnedPaymentCredential);
|
|
237
|
+
role.allow(actions.updateToken, isOwnedToken);
|
|
238
|
+
role.allow(actions.viewToken, isOwnedToken);
|
|
226
239
|
};
|