@unchainedshop/api 1.2.40 → 2.0.0-beta2
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 +4 -0
- package/lib/errors.js +4 -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/addWeb3Address.d.ts +4 -0
- package/lib/resolvers/mutations/accounts/addWeb3Address.js +21 -0
- package/lib/resolvers/mutations/accounts/addWeb3Address.js.map +1 -0
- 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/removeWeb3Address.d.ts +4 -0
- package/lib/resolvers/mutations/accounts/removeWeb3Address.js +18 -0
- package/lib/resolvers/mutations/accounts/removeWeb3Address.js.map +1 -0
- 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/accounts/verifyWeb3Address.d.ts +5 -0
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.js +40 -0
- package/lib/resolvers/mutations/accounts/verifyWeb3Address.js.map +1 -0
- package/lib/resolvers/mutations/index.d.ts +174 -157
- package/lib/resolvers/mutations/index.js +20 -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 +5 -1
- package/lib/resolvers/type/user-types.js +12 -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 +57 -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 +39 -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 +11 -9
- 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 +20 -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/addWeb3Address.ts +33 -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/removeWeb3Address.ts +32 -0
- package/src/resolvers/mutations/accounts/removeWebAuthnCredentials.ts +30 -0
- package/src/resolvers/mutations/accounts/verifyWeb3Address.ts +60 -0
- package/src/resolvers/mutations/{index.js → index.ts} +20 -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 +26 -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 +57 -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 +39 -1
- package/src/schema/types/warehousing.js +23 -1
- package/src/user-context.ts +23 -9
package/src/schema/types/user.js
CHANGED
|
@@ -49,6 +49,41 @@ export default [
|
|
|
49
49
|
countryCode: String
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
type WebAuthnMDSv3Metadata {
|
|
53
|
+
legalHeader: String
|
|
54
|
+
description: String
|
|
55
|
+
authenticatorVersion: Int
|
|
56
|
+
protocolFamily: String
|
|
57
|
+
schema: Int
|
|
58
|
+
upv: [JSON!]
|
|
59
|
+
authenticationAlgorithms: [String!]
|
|
60
|
+
publicKeyAlgAndEncodings: [String!]
|
|
61
|
+
attestationTypes: [String!]
|
|
62
|
+
userVerificationDetails: [JSON!]
|
|
63
|
+
keyProtection: [String!]
|
|
64
|
+
matcherProtection: [String!]
|
|
65
|
+
cryptoStrength: Int
|
|
66
|
+
attachmentHint: [String!]
|
|
67
|
+
tcDisplay: [JSON!]
|
|
68
|
+
attestationRootCertificates: [String!]
|
|
69
|
+
icon: String
|
|
70
|
+
authenticatorGetInfo: JSON
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type WebAuthnCredentials {
|
|
74
|
+
_id: ID!
|
|
75
|
+
created: DateTime!
|
|
76
|
+
aaguid: String!
|
|
77
|
+
counter: Int!
|
|
78
|
+
mdsMetadata: WebAuthnMDSv3Metadata
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type Web3Address {
|
|
82
|
+
address: String!
|
|
83
|
+
nonce: Int
|
|
84
|
+
verified: Boolean!
|
|
85
|
+
}
|
|
86
|
+
|
|
52
87
|
type User {
|
|
53
88
|
_id: ID!
|
|
54
89
|
email: String @deprecated(reason: "Please use primaryEmail.address instead")
|
|
@@ -57,6 +92,8 @@ export default [
|
|
|
57
92
|
isGuest: Boolean!
|
|
58
93
|
isTwoFactorEnabled: Boolean!
|
|
59
94
|
isInitialPassword: Boolean!
|
|
95
|
+
webAuthnCredentials: [WebAuthnCredentials!]!
|
|
96
|
+
web3Addresses: [Web3Address!]!
|
|
60
97
|
name: String!
|
|
61
98
|
avatar: Media
|
|
62
99
|
profile: UserProfile
|
|
@@ -68,7 +105,7 @@ export default [
|
|
|
68
105
|
primaryEmail: UserEmail
|
|
69
106
|
emails: [UserEmail!]
|
|
70
107
|
roles: [String!]
|
|
71
|
-
tags: [
|
|
108
|
+
tags: [LowerCaseString!]
|
|
72
109
|
cart(orderNumber: String): Order
|
|
73
110
|
orders(includeCarts: Boolean = false, sort: [SortOptionInput!], queryString: String): [Order!]!
|
|
74
111
|
quotations(sort: [SortOptionInput!], queryString: String): [Quotation!]!
|
|
@@ -76,6 +113,7 @@ export default [
|
|
|
76
113
|
paymentCredentials: [PaymentCredentials!]!
|
|
77
114
|
enrollments(sort: [SortOptionInput!], queryString: String): [Enrollment!]!
|
|
78
115
|
allowedActions: [RoleAction!]!
|
|
116
|
+
tokens: [Token!]!
|
|
79
117
|
}
|
|
80
118
|
`,
|
|
81
119
|
];
|
|
@@ -8,9 +8,13 @@ export default [
|
|
|
8
8
|
|
|
9
9
|
enum WarehousingProviderType {
|
|
10
10
|
"""
|
|
11
|
-
Physical
|
|
11
|
+
Physical warehousing providers resemble stores or facilities that hold a quantity of stocks physically in stock.
|
|
12
12
|
"""
|
|
13
13
|
PHYSICAL
|
|
14
|
+
"""
|
|
15
|
+
Virtual warehousing providers resemble software that control ownership and validity of virtual products (for ex. smart contract bridges)
|
|
16
|
+
"""
|
|
17
|
+
VIRTUAL
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
enum WarehousingProviderError {
|
|
@@ -31,5 +35,23 @@ export default [
|
|
|
31
35
|
configurationError: WarehousingProviderError
|
|
32
36
|
isActive: Boolean
|
|
33
37
|
}
|
|
38
|
+
|
|
39
|
+
enum TokenExportStatus {
|
|
40
|
+
CENTRALIZED
|
|
41
|
+
EXPORTING
|
|
42
|
+
DECENTRALIZED
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type Token {
|
|
46
|
+
_id: ID!
|
|
47
|
+
user: User
|
|
48
|
+
walletAddress: String
|
|
49
|
+
product: TokenizedProduct!
|
|
50
|
+
status: TokenExportStatus!
|
|
51
|
+
quantity: Int!
|
|
52
|
+
contractAddress: String
|
|
53
|
+
chainId: String
|
|
54
|
+
chainTokenId: String
|
|
55
|
+
}
|
|
34
56
|
`,
|
|
35
57
|
];
|
package/src/user-context.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UnchainedUserContext } from '@unchainedshop/types/api';
|
|
2
2
|
import { UnchainedCore } from '@unchainedshop/types/core';
|
|
3
|
-
import { IncomingMessage } from 'http';
|
|
3
|
+
import { IncomingMessage, OutgoingMessage } from 'http';
|
|
4
|
+
import cookie from 'cookie';
|
|
4
5
|
|
|
5
6
|
function isString(input) {
|
|
6
7
|
return typeof input === 'string' && Object.prototype.toString.call(input) === '[object String]';
|
|
@@ -8,16 +9,28 @@ function isString(input) {
|
|
|
8
9
|
|
|
9
10
|
export const getUserContext = async (
|
|
10
11
|
req: IncomingMessage & { cookies?: any },
|
|
12
|
+
res: OutgoingMessage,
|
|
11
13
|
unchainedAPI: UnchainedCore,
|
|
12
14
|
): Promise<UnchainedUserContext> => {
|
|
13
15
|
// there is a possible current user connected!
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const cookieName = process.env.UNCHAINED_COOKIE_NAME || 'unchained_token';
|
|
17
|
+
const domain = process.env.UNCHAINED_COOKIE_DOMAIN;
|
|
18
|
+
|
|
19
|
+
let loginToken = req.cookies?.[cookieName];
|
|
20
|
+
|
|
21
|
+
function setLoginToken(token: string, expires: Date) {
|
|
22
|
+
if (!domain) return;
|
|
23
|
+
const authCookie = cookie.serialize(cookieName, token || null, {
|
|
24
|
+
domain,
|
|
25
|
+
httpOnly: true,
|
|
26
|
+
expires: token ? expires : undefined,
|
|
27
|
+
maxAge: token ? undefined : -1,
|
|
28
|
+
sameSite: 'lax',
|
|
29
|
+
secure: process.env.NODE_ENV === 'production',
|
|
30
|
+
});
|
|
31
|
+
res.setHeader('Set-Cookie', authCookie);
|
|
20
32
|
}
|
|
33
|
+
|
|
21
34
|
if (req.headers.authorization) {
|
|
22
35
|
const [type, token] = req.headers.authorization.split(' ');
|
|
23
36
|
if (type === 'Bearer') {
|
|
@@ -54,11 +67,12 @@ export const getUserContext = async (
|
|
|
54
67
|
user: currentUser,
|
|
55
68
|
userId: currentUser._id,
|
|
56
69
|
loginToken: loginToken as string,
|
|
70
|
+
setLoginToken,
|
|
57
71
|
};
|
|
58
72
|
}
|
|
59
73
|
}
|
|
60
|
-
return { loginToken: loginToken as string };
|
|
74
|
+
return { loginToken: loginToken as string, setLoginToken };
|
|
61
75
|
}
|
|
62
76
|
|
|
63
|
-
return {};
|
|
77
|
+
return { setLoginToken };
|
|
64
78
|
};
|