@vtex/api 6.49.5-beta.0 → 6.50.0-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.
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.d.ts +1 -1
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Auth.js +15 -2
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Public.d.ts +6 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/Public.js +15 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.d.ts +2 -0
- package/lib/service/worker/runtime/graphql/schema/schemaDirectives/index.js +3 -0
- package/package.json +25 -3
|
@@ -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 = "\ndirective @auth(\n productCode: String\n resourceCode: String\n) on FIELD_DEFINITION\n";
|
|
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";
|
|
@@ -8,6 +8,11 @@ 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 = {}));
|
|
11
16
|
async function parseIdToken(authToken, vtexIdToken) {
|
|
12
17
|
const url = `vtexid.vtex.com.br/api/vtexid/pub/authenticated/user?authToken=${vtexIdToken}`;
|
|
13
18
|
const req = await axios_1.default.request({
|
|
@@ -51,7 +56,7 @@ async function auth(ctx, authArgs) {
|
|
|
51
56
|
}
|
|
52
57
|
function parseArgs(authArgs) {
|
|
53
58
|
if (!authArgs.productCode || !authArgs.resourceCode) {
|
|
54
|
-
throw new apollo_server_errors_1.UserInputError('Invalid auth schema directive args. Usage: @auth(productCode: String, resourceCode: String).');
|
|
59
|
+
throw new apollo_server_errors_1.UserInputError('Invalid auth schema directive args. Usage: @auth(scope: Scope, productCode: String, resourceCode: String).');
|
|
55
60
|
}
|
|
56
61
|
return authArgs;
|
|
57
62
|
}
|
|
@@ -60,14 +65,22 @@ class Auth extends graphql_tools_1.SchemaDirectiveVisitor {
|
|
|
60
65
|
const { resolve = graphql_1.defaultFieldResolver } = field;
|
|
61
66
|
field.resolve = async (root, args, ctx, info) => {
|
|
62
67
|
const authArgs = parseArgs(this.args);
|
|
63
|
-
|
|
68
|
+
if (!authArgs.scope || authArgs.scope == Scope.PRIVATE) {
|
|
69
|
+
await auth(ctx, authArgs);
|
|
70
|
+
}
|
|
64
71
|
return resolve(root, args, ctx, info);
|
|
65
72
|
};
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
75
|
exports.Auth = Auth;
|
|
69
76
|
exports.authDirectiveTypeDefs = `
|
|
77
|
+
enum Scope {
|
|
78
|
+
PUBLIC
|
|
79
|
+
PRIVATE
|
|
80
|
+
}
|
|
81
|
+
|
|
70
82
|
directive @auth(
|
|
83
|
+
scope: Scope
|
|
71
84
|
productCode: String
|
|
72
85
|
resourceCode: String
|
|
73
86
|
) on FIELD_DEFINITION
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GraphQLField } from "graphql";
|
|
2
|
+
import { SchemaDirectiveVisitor } from "graphql-tools";
|
|
3
|
+
export declare class Public extends SchemaDirectiveVisitor {
|
|
4
|
+
visitFieldDefinition(field: GraphQLField<any, any>): void;
|
|
5
|
+
}
|
|
6
|
+
export declare const publicDirectiveTypeDefs = "directive @public on FIELD_DEFINITION";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publicDirectiveTypeDefs = exports.Public = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const graphql_tools_1 = require("graphql-tools");
|
|
6
|
+
class Public extends graphql_tools_1.SchemaDirectiveVisitor {
|
|
7
|
+
visitFieldDefinition(field) {
|
|
8
|
+
const { resolve = graphql_1.defaultFieldResolver } = field;
|
|
9
|
+
field.resolve = async function (...args) {
|
|
10
|
+
return resolve.apply(this, args);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.Public = Public;
|
|
15
|
+
exports.publicDirectiveTypeDefs = `directive @public on FIELD_DEFINITION`;
|
|
@@ -2,6 +2,7 @@ import { Auth } from './Auth';
|
|
|
2
2
|
import { CacheControl } from './CacheControl';
|
|
3
3
|
import { Deprecated } from './Deprecated';
|
|
4
4
|
import { Metric } from './Metric';
|
|
5
|
+
import { Public } from './Public';
|
|
5
6
|
import { SanitizeDirective } from './Sanitize';
|
|
6
7
|
import { SettingsDirective } from './Settings';
|
|
7
8
|
import { SmartCacheDirective } from './SmartCacheDirective';
|
|
@@ -18,5 +19,6 @@ export declare const nativeSchemaDirectives: {
|
|
|
18
19
|
smartcache: typeof SmartCacheDirective;
|
|
19
20
|
translatableV2: typeof TranslatableV2;
|
|
20
21
|
translateTo: typeof TranslateTo;
|
|
22
|
+
public: typeof Public;
|
|
21
23
|
};
|
|
22
24
|
export declare const nativeSchemaDirectivesTypeDefs: string;
|
|
@@ -5,6 +5,7 @@ const Auth_1 = require("./Auth");
|
|
|
5
5
|
const CacheControl_1 = require("./CacheControl");
|
|
6
6
|
const Deprecated_1 = require("./Deprecated");
|
|
7
7
|
const Metric_1 = require("./Metric");
|
|
8
|
+
const Public_1 = require("./Public");
|
|
8
9
|
const Sanitize_1 = require("./Sanitize");
|
|
9
10
|
const Settings_1 = require("./Settings");
|
|
10
11
|
const SmartCacheDirective_1 = require("./SmartCacheDirective");
|
|
@@ -23,6 +24,7 @@ exports.nativeSchemaDirectives = {
|
|
|
23
24
|
smartcache: SmartCacheDirective_1.SmartCacheDirective,
|
|
24
25
|
translatableV2: TranslatableV2_1.TranslatableV2,
|
|
25
26
|
translateTo: TranslateTo_1.TranslateTo,
|
|
27
|
+
public: Public_1.Public
|
|
26
28
|
};
|
|
27
29
|
exports.nativeSchemaDirectivesTypeDefs = [
|
|
28
30
|
Auth_1.authDirectiveTypeDefs,
|
|
@@ -34,4 +36,5 @@ exports.nativeSchemaDirectivesTypeDefs = [
|
|
|
34
36
|
SmartCacheDirective_1.smartCacheDirectiveTypeDefs,
|
|
35
37
|
TranslatableV2_1.translatableV2DirectiveTypeDefs,
|
|
36
38
|
TranslateTo_1.translateToDirectiveTypeDefs,
|
|
39
|
+
Public_1.publicDirectiveTypeDefs
|
|
37
40
|
].join('\n\n');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex/api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.50.0-beta",
|
|
4
4
|
"description": "VTEX I/O API client",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@types/koa": "^2.11.0",
|
|
51
51
|
"@types/koa-compose": "^3.2.3",
|
|
52
|
-
"@vtex/diagnostics-nodejs": "0.1.0-beta.
|
|
52
|
+
"@vtex/diagnostics-nodejs": "0.1.0-beta.8",
|
|
53
53
|
"@vtex/node-error-report": "^0.0.3",
|
|
54
54
|
"@wry/equality": "^0.1.9",
|
|
55
55
|
"agentkeepalive": "^4.0.2",
|
|
@@ -124,5 +124,27 @@
|
|
|
124
124
|
"typemoq": "^2.1.0",
|
|
125
125
|
"typescript": "^4.4.4",
|
|
126
126
|
"typescript-json-schema": "^0.52.0"
|
|
127
|
-
}
|
|
127
|
+
},
|
|
128
|
+
"resolutions": {
|
|
129
|
+
"@opentelemetry/core": "1.30.1",
|
|
130
|
+
"@opentelemetry/exporter-metrics-otlp-grpc": "0.57.2",
|
|
131
|
+
"@opentelemetry/exporter-metrics-otlp-http": "0.57.2",
|
|
132
|
+
"@opentelemetry/exporter-logs-otlp-grpc": "0.57.2",
|
|
133
|
+
"@opentelemetry/exporter-logs-otlp-http": "0.57.2",
|
|
134
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "0.57.2",
|
|
135
|
+
"@opentelemetry/exporter-trace-otlp-http": "0.57.2",
|
|
136
|
+
"@opentelemetry/instrumentation": "0.57.2",
|
|
137
|
+
"@opentelemetry/instrumentation-http": "0.57.2",
|
|
138
|
+
"@opentelemetry/instrumentation-grpc": "0.57.2",
|
|
139
|
+
"@opentelemetry/instrumentation-net": "0.43.1",
|
|
140
|
+
"@opentelemetry/propagator-b3": "1.30.1",
|
|
141
|
+
"@opentelemetry/resource-detector-aws": "1.12.0",
|
|
142
|
+
"@opentelemetry/resources": "1.30.1",
|
|
143
|
+
"@opentelemetry/sdk-node": "0.57.2",
|
|
144
|
+
"@opentelemetry/sdk-logs": "0.57.2",
|
|
145
|
+
"@opentelemetry/sdk-metrics": "1.30.1",
|
|
146
|
+
"@opentelemetry/sdk-trace-base": "1.30.1",
|
|
147
|
+
"@opentelemetry/sdk-trace-node": "1.30.1"
|
|
148
|
+
},
|
|
149
|
+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
128
150
|
}
|