@vtex/api 6.50.0-beta.2 → 6.50.1-beta

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.
@@ -3,4 +3,4 @@ import { SchemaDirectiveVisitor } from 'graphql-tools';
3
3
  export declare class Auth extends SchemaDirectiveVisitor {
4
4
  visitFieldDefinition(field: GraphQLField<any, any>): void;
5
5
  }
6
- export declare const authDirectiveTypeDefs = "\nenum Scope {\n PUBLIC\n PRIVATE\n}\n\ndirective @auth(\n scope: Scope\n productCode: String\n resourceCode: String\n) on FIELD_DEFINITION\n";
6
+ export declare const authDirectiveTypeDefs = "\n\nenum IOAuthScope {\n PUBLIC\n PRIVATE\n}\n\ndirective @auth(\n scope: IOAuthScope\n productCode: String\n resourceCode: String\n) on FIELD_DEFINITION\n";
@@ -8,11 +8,6 @@ const apollo_server_errors_1 = require("apollo-server-errors");
8
8
  const axios_1 = __importDefault(require("axios"));
9
9
  const graphql_1 = require("graphql");
10
10
  const graphql_tools_1 = require("graphql-tools");
11
- var Scope;
12
- (function (Scope) {
13
- Scope["PUBLIC"] = "PUBLIC";
14
- Scope["PRIVATE"] = "PRIVATE";
15
- })(Scope || (Scope = {}));
16
11
  async function parseIdToken(authToken, vtexIdToken) {
17
12
  const url = `vtexid.vtex.com.br/api/vtexid/pub/authenticated/user?authToken=${vtexIdToken}`;
18
13
  const req = await axios_1.default.request({
@@ -55,8 +50,11 @@ async function auth(ctx, authArgs) {
55
50
  }
56
51
  }
57
52
  function parseArgs(authArgs) {
53
+ if (authArgs.scope == 'PUBLIC') {
54
+ return authArgs;
55
+ }
58
56
  if (!authArgs.productCode || !authArgs.resourceCode) {
59
- throw new apollo_server_errors_1.UserInputError('Invalid auth schema directive args. Usage: @auth(scope: Scope, productCode: String, resourceCode: String).');
57
+ throw new apollo_server_errors_1.UserInputError('Invalid auth schema directive args. Usage: @auth(scope: IOAuthScope, productCode: String, resourceCode: String).');
60
58
  }
61
59
  return authArgs;
62
60
  }
@@ -65,7 +63,7 @@ class Auth extends graphql_tools_1.SchemaDirectiveVisitor {
65
63
  const { resolve = graphql_1.defaultFieldResolver } = field;
66
64
  field.resolve = async (root, args, ctx, info) => {
67
65
  const authArgs = parseArgs(this.args);
68
- if (!authArgs.scope || authArgs.scope == Scope.PRIVATE) {
66
+ if (!authArgs.scope || authArgs.scope == 'PRIVATE') {
69
67
  await auth(ctx, authArgs);
70
68
  }
71
69
  return resolve(root, args, ctx, info);
@@ -74,13 +72,14 @@ class Auth extends graphql_tools_1.SchemaDirectiveVisitor {
74
72
  }
75
73
  exports.Auth = Auth;
76
74
  exports.authDirectiveTypeDefs = `
77
- enum Scope {
75
+
76
+ enum IOAuthScope {
78
77
  PUBLIC
79
78
  PRIVATE
80
79
  }
81
80
 
82
81
  directive @auth(
83
- scope: Scope
82
+ scope: IOAuthScope
84
83
  productCode: String
85
84
  resourceCode: String
86
85
  ) on FIELD_DEFINITION
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtex/api",
3
- "version": "6.50.0-beta.2",
3
+ "version": "6.50.1-beta",
4
4
  "description": "VTEX I/O API client",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -55,7 +55,7 @@
55
55
  "agentkeepalive": "^4.0.2",
56
56
  "apollo-server-errors": "^2.2.1",
57
57
  "archiver": "^3.0.0",
58
- "axios": "^1.8.4",
58
+ "axios": "^0.30.1",
59
59
  "axios-retry": "^3.1.2",
60
60
  "bluebird": "^3.5.4",
61
61
  "chalk": "^2.4.2",