@labdigital/commercetools-mock 2.12.0 → 2.12.1
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 +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ctMock.test.ts +18 -0
- package/src/ctMock.ts +4 -0
- package/src/oauth/server.ts +7 -0
- package/src/oauth/store.ts +8 -4
package/dist/index.cjs
CHANGED
|
@@ -1294,6 +1294,9 @@ var OAuth2Store = class {
|
|
|
1294
1294
|
constructor(validate = true) {
|
|
1295
1295
|
this.validate = validate;
|
|
1296
1296
|
}
|
|
1297
|
+
addToken(token) {
|
|
1298
|
+
this.tokens.push(token);
|
|
1299
|
+
}
|
|
1297
1300
|
getClientToken(clientId, clientSecret, scope) {
|
|
1298
1301
|
const token = {
|
|
1299
1302
|
access_token: (0, import_crypto.randomBytes)(16).toString("base64"),
|
|
@@ -1302,7 +1305,7 @@ var OAuth2Store = class {
|
|
|
1302
1305
|
scope: scope || "todo",
|
|
1303
1306
|
refresh_token: `my-project-${(0, import_crypto.randomBytes)(16).toString("base64")}`
|
|
1304
1307
|
};
|
|
1305
|
-
this.
|
|
1308
|
+
this.addToken(token);
|
|
1306
1309
|
return token;
|
|
1307
1310
|
}
|
|
1308
1311
|
getAnonymousToken(scope, anonymousId) {
|
|
@@ -1316,7 +1319,7 @@ var OAuth2Store = class {
|
|
|
1316
1319
|
scope: scope ? `${scope} anonymous_id:${anonymousId}` : `anonymous_id:${anonymousId}`,
|
|
1317
1320
|
refresh_token: `my-project-${(0, import_crypto.randomBytes)(16).toString("base64")}`
|
|
1318
1321
|
};
|
|
1319
|
-
this.
|
|
1322
|
+
this.addToken(token);
|
|
1320
1323
|
return token;
|
|
1321
1324
|
}
|
|
1322
1325
|
getCustomerToken(scope, customerId) {
|
|
@@ -1327,7 +1330,7 @@ var OAuth2Store = class {
|
|
|
1327
1330
|
scope: scope ? `${scope} customer_id:${customerId}` : `customer_id:${customerId}`,
|
|
1328
1331
|
refresh_token: `my-project-${(0, import_crypto.randomBytes)(16).toString("base64")}`
|
|
1329
1332
|
};
|
|
1330
|
-
this.
|
|
1333
|
+
this.addToken(token);
|
|
1331
1334
|
return token;
|
|
1332
1335
|
}
|
|
1333
1336
|
refreshToken(clientId, clientSecret, refreshToken) {
|
|
@@ -1339,7 +1342,7 @@ var OAuth2Store = class {
|
|
|
1339
1342
|
...existing,
|
|
1340
1343
|
access_token: (0, import_crypto.randomBytes)(16).toString("base64")
|
|
1341
1344
|
};
|
|
1342
|
-
this.
|
|
1345
|
+
this.addToken(token);
|
|
1343
1346
|
return {
|
|
1344
1347
|
access_token: token.access_token,
|
|
1345
1348
|
token_type: token.token_type,
|
|
@@ -7321,6 +7324,9 @@ var CommercetoolsMock = class {
|
|
|
7321
7324
|
this._storage
|
|
7322
7325
|
);
|
|
7323
7326
|
}
|
|
7327
|
+
authStore() {
|
|
7328
|
+
return this._oauth2.store;
|
|
7329
|
+
}
|
|
7324
7330
|
runServer(port = 3e3, options) {
|
|
7325
7331
|
const server = this.app.listen(port, () => {
|
|
7326
7332
|
console.info(`Mock server listening at http://localhost:${port}`);
|