@unchainedshop/api 2.1.0 → 2.2.0
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/acl.js +1 -1
- package/lib/acl.js.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/loaders/index.js +28 -43
- package/lib/loaders/index.js.map +1 -1
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.d.ts +6 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.js +30 -0
- package/lib/resolvers/mutations/accounts/linkOAuthAccount.js.map +1 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.d.ts +7 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.js +25 -0
- package/lib/resolvers/mutations/accounts/loginWithOAuth.js.map +1 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.d.ts +5 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.js +14 -0
- package/lib/resolvers/mutations/accounts/unlinkOAuthAccount.js.map +1 -0
- package/lib/resolvers/mutations/index.d.ts +7 -0
- package/lib/resolvers/mutations/index.js +6 -0
- package/lib/resolvers/mutations/index.js.map +1 -1
- package/lib/resolvers/queries/shopInfo.d.ts +2 -0
- package/lib/resolvers/queries/shopInfo.js +3 -0
- package/lib/resolvers/queries/shopInfo.js.map +1 -1
- package/lib/resolvers/type/index.d.ts +9 -0
- package/lib/resolvers/type/index.js +4 -0
- package/lib/resolvers/type/index.js.map +1 -1
- package/lib/resolvers/type/oauth-account.d.ts +5 -0
- package/lib/resolvers/type/oauth-account.js +7 -0
- package/lib/resolvers/type/oauth-account.js.map +1 -0
- package/lib/resolvers/type/oauth-provider.d.ts +5 -0
- package/lib/resolvers/type/oauth-provider.js +6 -0
- package/lib/resolvers/type/oauth-provider.js.map +1 -0
- package/lib/resolvers/type/user-types.d.ts +2 -1
- package/lib/resolvers/type/user-types.js +9 -0
- package/lib/resolvers/type/user-types.js.map +1 -1
- package/lib/schema/mutation.js +15 -0
- package/lib/schema/mutation.js.map +1 -1
- package/lib/schema/types/shop.js +1 -0
- package/lib/schema/types/shop.js.map +1 -1
- package/lib/schema/types/user.js +14 -0
- package/lib/schema/types/user.js.map +1 -1
- package/package.json +14 -14
- package/src/acl.ts +1 -1
- package/src/errors.ts +1 -4
- package/src/loaders/index.ts +40 -42
- package/src/resolvers/mutations/accounts/linkOAuthAccount.ts +51 -0
- package/src/resolvers/mutations/accounts/loginWithOAuth.ts +38 -0
- package/src/resolvers/mutations/accounts/unlinkOAuthAccount.ts +26 -0
- package/src/resolvers/mutations/index.ts +6 -0
- package/src/resolvers/queries/shopInfo.ts +6 -1
- package/src/resolvers/type/index.ts +4 -0
- package/src/resolvers/type/oauth-account.ts +8 -0
- package/src/resolvers/type/oauth-provider.ts +5 -0
- package/src/resolvers/type/user-types.ts +11 -1
- package/src/schema/mutation.ts +15 -0
- package/src/schema/types/shop.ts +1 -0
- package/src/schema/types/user.ts +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/user-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"user-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/user-types.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AA+D/C,MAAM,EACJ,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,GAAG,OAAiC,CAAC;AAEtC,MAAM,eAAe,GAAG,CAAC,IAAc,EAAE,EAAE;IACzC,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KA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
|
package/lib/schema/mutation.js
CHANGED
|
@@ -17,6 +17,15 @@ export default [
|
|
|
17
17
|
"""
|
|
18
18
|
loginWithWebAuthn(webAuthnPublicKeyCredentials: JSON!): LoginMethodResponse
|
|
19
19
|
|
|
20
|
+
"""
|
|
21
|
+
Log the user with OAuth2 service provider
|
|
22
|
+
"""
|
|
23
|
+
loginWithOAuth(
|
|
24
|
+
provider: String!
|
|
25
|
+
authorizationCode: String!
|
|
26
|
+
redirectUrl: String!
|
|
27
|
+
): LoginMethodResponse
|
|
28
|
+
|
|
20
29
|
"""
|
|
21
30
|
Web3
|
|
22
31
|
"""
|
|
@@ -24,6 +33,12 @@ export default [
|
|
|
24
33
|
verifyWeb3Address(address: String!, hash: String!): User!
|
|
25
34
|
removeWeb3Address(address: String!): User!
|
|
26
35
|
|
|
36
|
+
"""
|
|
37
|
+
OAuth2
|
|
38
|
+
"""
|
|
39
|
+
linkOAuthAccount(provider: String!, authorizationCode: String!, redirectUrl: String!): User!
|
|
40
|
+
unlinkOAuthAccount(provider: String!, oAuthAccountId: ID!): User!
|
|
41
|
+
|
|
27
42
|
"""
|
|
28
43
|
Create a new user.
|
|
29
44
|
"""
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutation.js","sourceRoot":"","sources":["../../src/schema/mutation.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"mutation.js","sourceRoot":"","sources":["../../src/schema/mutation.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAq5Bb;CACF,CAAC"}
|
package/lib/schema/types/shop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop.js","sourceRoot":"","sources":["../../../src/schema/types/shop.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"shop.js","sourceRoot":"","sources":["../../../src/schema/types/shop.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0Bb;CACF,CAAC"}
|
package/lib/schema/types/user.js
CHANGED
|
@@ -90,6 +90,19 @@ export default [
|
|
|
90
90
|
nonce: Int
|
|
91
91
|
verified: Boolean!
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
type OAuthProvider {
|
|
95
|
+
_id: String!
|
|
96
|
+
clientId: String!
|
|
97
|
+
scopes: [String!]!
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type OAuthAccount {
|
|
101
|
+
_id: ID!
|
|
102
|
+
provider: OAuthProvider!
|
|
103
|
+
authorizationCode: String!
|
|
104
|
+
}
|
|
105
|
+
|
|
93
106
|
type User {
|
|
94
107
|
_id: ID!
|
|
95
108
|
created: DateTime!
|
|
@@ -139,6 +152,7 @@ export default [
|
|
|
139
152
|
): [Enrollment!]!
|
|
140
153
|
allowedActions: [RoleAction!]!
|
|
141
154
|
tokens: [Token!]!
|
|
155
|
+
oAuthAccounts: [OAuthAccount!]!
|
|
142
156
|
}
|
|
143
157
|
`,
|
|
144
158
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../src/schema/types/user.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../src/schema/types/user.ts"],"names":[],"mappings":"AAAA,eAAe;IACb,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2Jb;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"main": "lib/api-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/api-index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@apollo/server": "^4.
|
|
43
|
+
"@apollo/server": "^4.7.1",
|
|
44
44
|
"cookie": "^0.5.0",
|
|
45
45
|
"graphql": "^16.6.0"
|
|
46
46
|
},
|
|
@@ -48,29 +48,29 @@
|
|
|
48
48
|
"express": "^4.18.2"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@metamask/eth-sig-util": "^5.0
|
|
52
|
-
"@unchainedshop/core": "^2.
|
|
53
|
-
"@unchainedshop/events": "^2.
|
|
54
|
-
"@unchainedshop/logger": "^2.
|
|
55
|
-
"@unchainedshop/roles": "^2.
|
|
56
|
-
"@unchainedshop/utils": "^2.
|
|
51
|
+
"@metamask/eth-sig-util": "^5.1.0",
|
|
52
|
+
"@unchainedshop/core": "^2.2.0",
|
|
53
|
+
"@unchainedshop/events": "^2.2.0",
|
|
54
|
+
"@unchainedshop/logger": "^2.2.0",
|
|
55
|
+
"@unchainedshop/roles": "^2.2.0",
|
|
56
|
+
"@unchainedshop/utils": "^2.2.0",
|
|
57
57
|
"accounting": "0.4.1",
|
|
58
58
|
"dataloader": "^2.2.2",
|
|
59
|
-
"graphql-scalars": "^1.
|
|
59
|
+
"graphql-scalars": "^1.21.3",
|
|
60
60
|
"graphql-upload": "^16.0.2",
|
|
61
61
|
"locale": "0.1.0",
|
|
62
62
|
"lodash.isnumber": "3.0.3",
|
|
63
63
|
"lru-cache": "^7.14.1"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@types/graphql-upload": "^
|
|
66
|
+
"@types/graphql-upload": "^16.0.0",
|
|
67
67
|
"@types/locale": "^0.1.1",
|
|
68
|
-
"@types/node": "^18.
|
|
69
|
-
"@unchainedshop/types": "^2.
|
|
68
|
+
"@types/node": "^18.16.5",
|
|
69
|
+
"@unchainedshop/types": "^2.2.0",
|
|
70
70
|
"express": "^4.18.2",
|
|
71
71
|
"graphql": "^16.6.0",
|
|
72
|
-
"jest": "^29.
|
|
73
|
-
"ts-jest": "^29.0
|
|
72
|
+
"jest": "^29.5.0",
|
|
73
|
+
"ts-jest": "^29.1.0",
|
|
74
74
|
"typescript": "^4.9.5"
|
|
75
75
|
}
|
|
76
76
|
}
|
package/src/acl.ts
CHANGED
|
@@ -38,7 +38,7 @@ const checkAction = async (context, action, args = emptyArray, options: any = em
|
|
|
38
38
|
action,
|
|
39
39
|
key,
|
|
40
40
|
message: `The user "${
|
|
41
|
-
context.userId || ''
|
|
41
|
+
context.userId || 'anonymous'
|
|
42
42
|
}" has no permission to perform the action "${action}"${keyText}`,
|
|
43
43
|
});
|
|
44
44
|
};
|
package/src/errors.ts
CHANGED
|
@@ -234,10 +234,7 @@ export const TwoFactorAlreadySetError = createError('TwoFactorAlreadySet', '2FA
|
|
|
234
234
|
|
|
235
235
|
export const TwoFactorNotSetError = createError('TwoFactorNotSet', '2FA not set for user');
|
|
236
236
|
|
|
237
|
-
export const InvalidCredentialsError = createError(
|
|
238
|
-
'InvalidCredentials',
|
|
239
|
-
'Incorrect credential provided',
|
|
240
|
-
);
|
|
237
|
+
export const InvalidCredentialsError = createError('InvalidCredentials', 'Invalid credentials provided');
|
|
241
238
|
|
|
242
239
|
export const InvalidResetTokenError = createError('InvalidResetTokenError', 'Token validation failed');
|
|
243
240
|
|
package/src/loaders/index.ts
CHANGED
|
@@ -11,6 +11,30 @@ import { ProductStatus } from '@unchainedshop/core-products';
|
|
|
11
11
|
|
|
12
12
|
const { Locale } = localePkg;
|
|
13
13
|
|
|
14
|
+
function getLocaleStrings(localeObj) {
|
|
15
|
+
return [localeObj.normalized, localeObj.language, systemLocale.normalized, systemLocale.language];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function findMatchingText(texts, localeStrings) {
|
|
19
|
+
return localeStrings.reduce((acc, localeString) => {
|
|
20
|
+
if (acc) return acc;
|
|
21
|
+
return texts.find((p) => p.locale === localeString);
|
|
22
|
+
}, null);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getFilteredQueries({ queries, texts, filterFn }) {
|
|
26
|
+
return queries.map(({ locale, ...queryParams }) => {
|
|
27
|
+
const localeObj = new Locale(locale);
|
|
28
|
+
|
|
29
|
+
const filteredTexts = texts.filter(filterFn(queryParams));
|
|
30
|
+
if (!filteredTexts.length) return null;
|
|
31
|
+
|
|
32
|
+
const localeStrings = getLocaleStrings(localeObj);
|
|
33
|
+
const filterText = findMatchingText(filteredTexts, localeStrings);
|
|
34
|
+
return filterText || filteredTexts[0];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
14
38
|
export default async (
|
|
15
39
|
req: IncomingMessage,
|
|
16
40
|
res: OutgoingMessage,
|
|
@@ -47,20 +71,12 @@ export default async (
|
|
|
47
71
|
},
|
|
48
72
|
);
|
|
49
73
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const assortmentTexts = texts.filter((text) => text.assortmentId === assortmentId);
|
|
55
|
-
if (!assortmentTexts.length) return null;
|
|
56
|
-
const localeStrings = [localeObj.normalized, localeObj.language, ...systemLocaleStrings];
|
|
74
|
+
const filterFn =
|
|
75
|
+
({ assortmentId }) =>
|
|
76
|
+
(text) =>
|
|
77
|
+
text.assortmentId === assortmentId;
|
|
57
78
|
|
|
58
|
-
|
|
59
|
-
if (acc) return acc;
|
|
60
|
-
return assortmentTexts.find((p) => p.locale === localeString);
|
|
61
|
-
}, null);
|
|
62
|
-
return assortmentText || assortmentTexts[0];
|
|
63
|
-
});
|
|
79
|
+
return getFilteredQueries({ queries, texts, filterFn });
|
|
64
80
|
},
|
|
65
81
|
),
|
|
66
82
|
|
|
@@ -95,26 +111,16 @@ export default async (
|
|
|
95
111
|
},
|
|
96
112
|
);
|
|
97
113
|
|
|
98
|
-
const
|
|
114
|
+
const filterFn =
|
|
115
|
+
({ filterId, filterOptionValue }) =>
|
|
116
|
+
(text) =>
|
|
117
|
+
text.filterId === filterId && text.filterOptionValue === filterOptionValue;
|
|
99
118
|
|
|
100
|
-
return
|
|
101
|
-
const localeObj = new Locale(locale);
|
|
102
|
-
const filterTexts = texts.filter(
|
|
103
|
-
(text) => text.filterId === filterId && text.filterOptionValue === filterOptionValue,
|
|
104
|
-
);
|
|
105
|
-
if (!filterTexts.length) return null;
|
|
106
|
-
const localeStrings = [localeObj.normalized, localeObj.language, ...systemLocaleStrings];
|
|
107
|
-
|
|
108
|
-
const filterText = localeStrings.reduce<FilterText>((acc, localeString) => {
|
|
109
|
-
if (acc) return acc;
|
|
110
|
-
return filterTexts.find((p) => p.locale === localeString);
|
|
111
|
-
}, null);
|
|
112
|
-
return filterText || filterTexts[0];
|
|
113
|
-
});
|
|
119
|
+
return getFilteredQueries({ queries, texts, filterFn });
|
|
114
120
|
}),
|
|
115
121
|
|
|
116
122
|
productLoader: new DataLoader<{ productId: string }, Product>(async (queries) => {
|
|
117
|
-
const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))];
|
|
123
|
+
const productIds = [...new Set(queries.map((q) => q.productId).filter(Boolean))]; // you don't need lodash, _.unique my ass
|
|
118
124
|
|
|
119
125
|
const products = await unchainedAPI.modules.products.findProducts({
|
|
120
126
|
productIds,
|
|
@@ -144,20 +150,12 @@ export default async (
|
|
|
144
150
|
},
|
|
145
151
|
);
|
|
146
152
|
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const productTexts = texts.filter((text) => text.productId === productId);
|
|
152
|
-
if (!productTexts.length) return null;
|
|
153
|
-
const localeStrings = [localeObj.normalized, localeObj.language, ...systemLocaleStrings];
|
|
153
|
+
const filterFn =
|
|
154
|
+
({ productId }) =>
|
|
155
|
+
(text) =>
|
|
156
|
+
text.productId === productId;
|
|
154
157
|
|
|
155
|
-
|
|
156
|
-
if (acc) return acc;
|
|
157
|
-
return productTexts.find((p) => p.locale === localeString);
|
|
158
|
-
}, null);
|
|
159
|
-
return productText || productTexts[0];
|
|
160
|
-
});
|
|
158
|
+
return getFilteredQueries({ queries, texts, filterFn });
|
|
161
159
|
},
|
|
162
160
|
),
|
|
163
161
|
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
3
|
+
import { AuthOperationFailedError } from '../../../errors.js';
|
|
4
|
+
|
|
5
|
+
export default async function linkOAuthAccount(
|
|
6
|
+
root: Root,
|
|
7
|
+
{
|
|
8
|
+
provider,
|
|
9
|
+
redirectUrl,
|
|
10
|
+
authorizationCode,
|
|
11
|
+
}: { provider: string; redirectUrl: string; authorizationCode: string },
|
|
12
|
+
context: Context,
|
|
13
|
+
) {
|
|
14
|
+
const { userId, user } = context;
|
|
15
|
+
|
|
16
|
+
log(`mutation linkOAuthAccount ${user.username}`, {
|
|
17
|
+
userId,
|
|
18
|
+
});
|
|
19
|
+
try {
|
|
20
|
+
const { modules } = context;
|
|
21
|
+
|
|
22
|
+
const authorizationToken = await modules.accounts.oAuth2.getAuthorizationToken(
|
|
23
|
+
provider,
|
|
24
|
+
authorizationCode,
|
|
25
|
+
redirectUrl,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (!authorizationToken) throw new Error('Unable to authorize user');
|
|
29
|
+
|
|
30
|
+
const { id, ...data } = await modules.accounts.oAuth2.getAccountData(provider, authorizationToken);
|
|
31
|
+
|
|
32
|
+
await modules.users.updateUser(
|
|
33
|
+
{ _id: userId },
|
|
34
|
+
{
|
|
35
|
+
$push: {
|
|
36
|
+
[`services.oauth.${provider}`]: {
|
|
37
|
+
id,
|
|
38
|
+
authorizationToken,
|
|
39
|
+
authorizationCode,
|
|
40
|
+
data,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{ upsert: true },
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return true;
|
|
48
|
+
} catch (e) {
|
|
49
|
+
throw new AuthOperationFailedError({});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Context } from '@unchainedshop/types/api.js';
|
|
2
|
+
import { log } from '@unchainedshop/logger';
|
|
3
|
+
import {
|
|
4
|
+
AuthOperationFailedError,
|
|
5
|
+
EmailAlreadyExistsError,
|
|
6
|
+
UsernameAlreadyExistsError,
|
|
7
|
+
UsernameOrEmailRequiredError,
|
|
8
|
+
} from '../../../errors.js';
|
|
9
|
+
|
|
10
|
+
const loginWithOAuth = async (
|
|
11
|
+
_,
|
|
12
|
+
{
|
|
13
|
+
provider,
|
|
14
|
+
authorizationCode,
|
|
15
|
+
redirectUrl,
|
|
16
|
+
}: { provider: string; authorizationCode: string; redirectUrl: string },
|
|
17
|
+
context: Context,
|
|
18
|
+
): Promise<any | null> => {
|
|
19
|
+
log(`mutation loginWithOAuth ${provider} ${authorizationCode}`);
|
|
20
|
+
try {
|
|
21
|
+
return context.modules.accounts.loginWithService(
|
|
22
|
+
{
|
|
23
|
+
service: 'oauth2',
|
|
24
|
+
authorizationCode,
|
|
25
|
+
provider,
|
|
26
|
+
redirectUrl,
|
|
27
|
+
},
|
|
28
|
+
context,
|
|
29
|
+
);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (e.code === 'EmailAlreadyExists') throw new EmailAlreadyExistsError({});
|
|
32
|
+
else if (e.code === 'UsernameAlreadyExists') throw new UsernameAlreadyExistsError({});
|
|
33
|
+
else if (e.code === 'UsernameOrEmailRequired') throw new UsernameOrEmailRequiredError({});
|
|
34
|
+
else throw new AuthOperationFailedError({});
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default loginWithOAuth;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { log } from '@unchainedshop/logger';
|
|
2
|
+
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
3
|
+
|
|
4
|
+
export default async function unlinkOAuthAccount(
|
|
5
|
+
root: Root,
|
|
6
|
+
{ provider, oAuthAccountId }: { provider: string; oAuthAccountId: string },
|
|
7
|
+
context: Context,
|
|
8
|
+
) {
|
|
9
|
+
const { modules, userId } = context;
|
|
10
|
+
|
|
11
|
+
log(`mutation unlinkOAuthAccount ${provider} ${oAuthAccountId}`, {
|
|
12
|
+
userId,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
await modules.users.updateUser(
|
|
16
|
+
{ _id: userId },
|
|
17
|
+
{
|
|
18
|
+
$pull: {
|
|
19
|
+
[`services.oauth.${provider}`]: { id: oAuthAccountId },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{ upsert: true },
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return modules.users.findUserById(userId);
|
|
26
|
+
}
|
|
@@ -157,6 +157,9 @@ import prepareUserAvatarUpload from './users/prepareUserAvatarUpload.js';
|
|
|
157
157
|
import rejectOrder from './orders/rejectOrder.js';
|
|
158
158
|
import removePushSubscription from './users/removePushSubscription.js';
|
|
159
159
|
import addPushSubscription from './users/addPushSubscription.js';
|
|
160
|
+
import loginWithOAuth from './accounts/loginWithOAuth.js';
|
|
161
|
+
import linkOAuthAccount from './accounts/linkOAuthAccount.js';
|
|
162
|
+
import unlinkOAuthAccount from './accounts/unlinkOAuthAccount.js';
|
|
160
163
|
|
|
161
164
|
export default {
|
|
162
165
|
logout,
|
|
@@ -171,9 +174,12 @@ export default {
|
|
|
171
174
|
addWeb3Address: acl(actions.updateUser)(addWeb3Address),
|
|
172
175
|
removeWeb3Address: acl(actions.updateUser)(removeWeb3Address),
|
|
173
176
|
verifyWeb3Address: acl(actions.updateUser)(verifyWeb3Address),
|
|
177
|
+
linkOAuthAccount: acl(actions.updateUser)(linkOAuthAccount),
|
|
178
|
+
unlinkOAuthAccount: acl(actions.updateUser)(unlinkOAuthAccount),
|
|
174
179
|
verifyEmail,
|
|
175
180
|
loginWithPassword,
|
|
176
181
|
loginWithWebAuthn,
|
|
182
|
+
loginWithOAuth,
|
|
177
183
|
impersonate: acl(actions.impersonate)(impersonate),
|
|
178
184
|
buildSecretTOTPAuthURL: acl(actions.authTwoFactor)(buildSecretTOTPAuthURL),
|
|
179
185
|
enableTOTP: acl(actions.authTwoFactor)(enableTOTP),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Context, Root } from '@unchainedshop/types/api.js';
|
|
2
2
|
import { log } from '@unchainedshop/logger';
|
|
3
|
+
import { IOAuth2Adapter } from '@unchainedshop/types/accounts.js';
|
|
3
4
|
|
|
4
5
|
export default function shopInfo(
|
|
5
6
|
root: Root,
|
|
@@ -10,16 +11,20 @@ export default function shopInfo(
|
|
|
10
11
|
externalLinks: Array<string>;
|
|
11
12
|
adminUiConfig?: Record<string, any>;
|
|
12
13
|
vapidPublicKey?: string;
|
|
14
|
+
oAuthProviders?: () => Promise<Array<IOAuth2Adapter>>;
|
|
13
15
|
} {
|
|
14
16
|
const { adminUiConfig } = context;
|
|
15
17
|
log('query shopInfo', { userId: context.userId });
|
|
18
|
+
|
|
16
19
|
return {
|
|
17
20
|
version: context.version,
|
|
18
21
|
externalLinks: JSON.parse(process.env.EXTERNAL_LINKS || '[]'),
|
|
19
22
|
adminUiConfig: {
|
|
20
23
|
customProperties: adminUiConfig?.customProperties ?? [],
|
|
21
24
|
},
|
|
22
|
-
|
|
25
|
+
async oAuthProviders() {
|
|
26
|
+
return context.modules.accounts.oAuth2.getProviders();
|
|
27
|
+
},
|
|
23
28
|
vapidPublicKey: process.env?.PUSH_NOTIFICATION_PUBLIC_KEY,
|
|
24
29
|
};
|
|
25
30
|
}
|
|
@@ -67,6 +67,8 @@ import { Event } from './event-types.js';
|
|
|
67
67
|
import { Media } from './media-types.js';
|
|
68
68
|
import { Token } from './token-types.js';
|
|
69
69
|
import { Web3Address } from './web3-address.js';
|
|
70
|
+
import { OAuthAccount } from './oauth-account.js';
|
|
71
|
+
import { OAuthProvider } from './oauth-provider.js';
|
|
70
72
|
|
|
71
73
|
const types = {
|
|
72
74
|
Assortment,
|
|
@@ -138,6 +140,8 @@ const types = {
|
|
|
138
140
|
Event,
|
|
139
141
|
Media,
|
|
140
142
|
Web3Address,
|
|
143
|
+
OAuthAccount,
|
|
144
|
+
OAuthProvider,
|
|
141
145
|
};
|
|
142
146
|
|
|
143
147
|
export default types;
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
Web3Address,
|
|
16
16
|
WebAuthnCredentials,
|
|
17
17
|
PushSubscription,
|
|
18
|
+
OAuthAccount,
|
|
18
19
|
} from '@unchainedshop/types/user.js';
|
|
19
20
|
import type { Locale } from 'locale';
|
|
20
21
|
import { TokenSurrogate } from '@unchainedshop/types/warehousing.js';
|
|
@@ -80,6 +81,7 @@ export interface UserHelperTypes {
|
|
|
80
81
|
tags: HelperType<any, Array<string>>;
|
|
81
82
|
username: HelperType<any, string>;
|
|
82
83
|
pushSubscriptions: HelperType<any, Array<PushSubscription>>;
|
|
84
|
+
oAuthAccounts: HelperType<any, Array<OAuthAccount>>;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
const {
|
|
@@ -215,7 +217,6 @@ export const User: UserHelperTypes = {
|
|
|
215
217
|
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
216
218
|
return user.services?.web3 || [];
|
|
217
219
|
},
|
|
218
|
-
|
|
219
220
|
quotations: async (user, params, context) => {
|
|
220
221
|
await checkAction(context, viewUserQuotations, [user, params]);
|
|
221
222
|
return context.modules.quotations.findQuotations({
|
|
@@ -232,4 +233,13 @@ export const User: UserHelperTypes = {
|
|
|
232
233
|
endpoint,
|
|
233
234
|
}));
|
|
234
235
|
},
|
|
236
|
+
oAuthAccounts: async (user, params, context) => {
|
|
237
|
+
await checkAction(context, viewUserPrivateInfos, [user, params]);
|
|
238
|
+
return Object.entries(user.services?.oauth || {}).flatMap(([provider, accounts]) => {
|
|
239
|
+
return (accounts as any).map((providerData) => ({
|
|
240
|
+
provider,
|
|
241
|
+
...(providerData as any),
|
|
242
|
+
}));
|
|
243
|
+
});
|
|
244
|
+
},
|
|
235
245
|
};
|
package/src/schema/mutation.ts
CHANGED
|
@@ -17,6 +17,15 @@ export default [
|
|
|
17
17
|
"""
|
|
18
18
|
loginWithWebAuthn(webAuthnPublicKeyCredentials: JSON!): LoginMethodResponse
|
|
19
19
|
|
|
20
|
+
"""
|
|
21
|
+
Log the user with OAuth2 service provider
|
|
22
|
+
"""
|
|
23
|
+
loginWithOAuth(
|
|
24
|
+
provider: String!
|
|
25
|
+
authorizationCode: String!
|
|
26
|
+
redirectUrl: String!
|
|
27
|
+
): LoginMethodResponse
|
|
28
|
+
|
|
20
29
|
"""
|
|
21
30
|
Web3
|
|
22
31
|
"""
|
|
@@ -24,6 +33,12 @@ export default [
|
|
|
24
33
|
verifyWeb3Address(address: String!, hash: String!): User!
|
|
25
34
|
removeWeb3Address(address: String!): User!
|
|
26
35
|
|
|
36
|
+
"""
|
|
37
|
+
OAuth2
|
|
38
|
+
"""
|
|
39
|
+
linkOAuthAccount(provider: String!, authorizationCode: String!, redirectUrl: String!): User!
|
|
40
|
+
unlinkOAuthAccount(provider: String!, oAuthAccountId: ID!): User!
|
|
41
|
+
|
|
27
42
|
"""
|
|
28
43
|
Create a new user.
|
|
29
44
|
"""
|
package/src/schema/types/shop.ts
CHANGED
package/src/schema/types/user.ts
CHANGED
|
@@ -90,6 +90,19 @@ export default [
|
|
|
90
90
|
nonce: Int
|
|
91
91
|
verified: Boolean!
|
|
92
92
|
}
|
|
93
|
+
|
|
94
|
+
type OAuthProvider {
|
|
95
|
+
_id: String!
|
|
96
|
+
clientId: String!
|
|
97
|
+
scopes: [String!]!
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
type OAuthAccount {
|
|
101
|
+
_id: ID!
|
|
102
|
+
provider: OAuthProvider!
|
|
103
|
+
authorizationCode: String!
|
|
104
|
+
}
|
|
105
|
+
|
|
93
106
|
type User {
|
|
94
107
|
_id: ID!
|
|
95
108
|
created: DateTime!
|
|
@@ -139,6 +152,7 @@ export default [
|
|
|
139
152
|
): [Enrollment!]!
|
|
140
153
|
allowedActions: [RoleAction!]!
|
|
141
154
|
tokens: [Token!]!
|
|
155
|
+
oAuthAccounts: [OAuthAccount!]!
|
|
142
156
|
}
|
|
143
157
|
`,
|
|
144
158
|
];
|