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AAY,cAAc,sBAA0C,IAAd,GAAkB,EACrL,oBAA+J,QAAzI,GAAqC,cAA5B,EAAY,aAAoD,WAArB,EAAY,OAAsB,EAAY,cAAc,2BAAgD,IAAf,GAAmB,EAC1L,UAAU,IAER,EAAkB,EAAY,cAAc,WAC5C,EAAQ,IACP,GAMP,OAJI,GACA,EAAM,MAAK,EAAI,OAAO,2BAA2B,IAErD,EAAM,MAAK,EAAI,OAAO,mBAAmB,IAClC,CACX,EAEJ,MAAM,kBAAoB,MAAM,iBAAiB,UACjD,kBAAkB,UAAY,SAAmB,GAC7C,OAAO,KAAK,MAAM,EACtB,EACA,MAAM,QAAQ,eAAe,WAAY,sBAAuB,CAC5D,GAAK,IAAU,CACP,sBAAkB,EAClB,gBAAY,EACZ,UAAW,IACJ,EAAQ,iBACX,WAAY,EAAQ","file":"/npm/@pothos/plugin-scope-auth@4.1.7/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/@pothos/plugin-scope-auth@4.1.7/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n    value: true\n});\nfunction _export(target, all) {\n    for(var name in all)Object.defineProperty(target, name, {\n        enumerable: true,\n        get: Object.getOwnPropertyDescriptor(all, name).get\n    });\n}\n_export(exports, {\n    get PothosScopeAuthPlugin () {\n        return PothosScopeAuthPlugin;\n    },\n    get RequestCache () {\n        return _requestcache.default;\n    },\n    get default () {\n        return _default;\n    }\n});\nrequire(\"./global-types.js\");\nrequire(\"./schema-builder.js\");\nrequire(\"./field-builders.js\");\nconst _core = /*#__PURE__*/ _interop_require_wildcard(require(\"@pothos/core\"));\nconst _istypeofhelper = require(\"./is-type-of-helper.js\");\nconst _requestcache = /*#__PURE__*/ _interop_require_default(require(\"./request-cache.js\"));\nconst _resolvehelper = require(\"./resolve-helper.js\");\nconst _steps = require(\"./steps.js\");\n_export_star(require(\"./errors.js\"), exports);\n_export_star(require(\"./types.js\"), exports);\nfunction _export_star(from, to) {\n    Object.keys(from).forEach(function(k) {\n        if (k !== \"default\" && !Object.prototype.hasOwnProperty.call(to, k)) {\n            Object.defineProperty(to, k, {\n                enumerable: true,\n                get: function() {\n                    return from[k];\n                }\n            });\n        }\n    });\n    return from;\n}\nfunction _interop_require_default(obj) {\n    return obj && obj.__esModule ? obj : {\n        default: obj\n    };\n}\nfunction _getRequireWildcardCache(nodeInterop) {\n    if (typeof WeakMap !== \"function\") return null;\n    var cacheBabelInterop = new WeakMap();\n    var cacheNodeInterop = new WeakMap();\n    return (_getRequireWildcardCache = function(nodeInterop) {\n        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;\n    })(nodeInterop);\n}\nfunction _interop_require_wildcard(obj, nodeInterop) {\n    if (!nodeInterop && obj && obj.__esModule) {\n        return obj;\n    }\n    if (obj === null || typeof obj !== \"object\" && typeof obj !== \"function\") {\n        return {\n            default: obj\n        };\n    }\n    var cache = _getRequireWildcardCache(nodeInterop);\n    if (cache && cache.has(obj)) {\n        return cache.get(obj);\n    }\n    var newObj = {\n        __proto__: null\n    };\n    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;\n    for(var key in obj){\n        if (key !== \"default\" && Object.prototype.hasOwnProperty.call(obj, key)) {\n            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;\n            if (desc && (desc.get || desc.set)) {\n                Object.defineProperty(newObj, key, desc);\n            } else {\n                newObj[key] = obj[key];\n            }\n        }\n    }\n    newObj.default = obj;\n    if (cache) {\n        cache.set(obj, newObj);\n    }\n    return newObj;\n}\nconst pluginName = 'scopeAuth';\nconst _default = pluginName;\nlet inResolveType = false;\nclass PothosScopeAuthPlugin extends _core.BasePlugin {\n    wrapResolve(resolver, fieldConfig) {\n        var _ref, _typeConfig_pothosOptions_runScopesOnType;\n        var _this_builder_options_scopeAuth, _this_builder_options_scopeAuth1;\n        if (this.options.disableScopeAuth) {\n            return resolver;\n        }\n        const typeConfig = this.buildCache.getTypeConfig(fieldConfig.parentType);\n        if (typeConfig.graphqlKind !== 'Object' && typeConfig.graphqlKind !== 'Interface') {\n            throw new _core.PothosSchemaError(`Got fields for ${fieldConfig.parentType} which is a ${typeConfig.graphqlKind} which cannot have fields`);\n        }\n        const authorizedOnSubscribe = !!((_this_builder_options_scopeAuth = this.builder.options.scopeAuth) === null || _this_builder_options_scopeAuth === void 0 ? void 0 : _this_builder_options_scopeAuth.authorizeOnSubscribe) && typeConfig.kind === 'Subscription';\n        const nonRoot = (typeConfig.graphqlKind === 'Interface' || typeConfig.graphqlKind === 'Object') && typeConfig.kind !== 'Query' && typeConfig.kind !== 'Mutation' && typeConfig.kind !== 'Subscription';\n        const runTypeScopesOnField = !nonRoot || !((_ref = (_typeConfig_pothosOptions_runScopesOnType = typeConfig.pothosOptions.runScopesOnType) !== null && _typeConfig_pothosOptions_runScopesOnType !== void 0 ? _typeConfig_pothosOptions_runScopesOnType : (_this_builder_options_scopeAuth1 = this.builder.options.scopeAuth) === null || _this_builder_options_scopeAuth1 === void 0 ? void 0 : _this_builder_options_scopeAuth1.runScopesOnType) !== null && _ref !== void 0 ? _ref : false);\n        const steps = this.createResolveSteps(fieldConfig, typeConfig, resolver, runTypeScopesOnField, authorizedOnSubscribe);\n        if (steps.length > 1) {\n            return (0, _resolvehelper.resolveHelper)(steps, this, fieldConfig);\n        }\n        return resolver;\n    }\n    wrapSubscribe(subscriber, fieldConfig) {\n        var _this_builder_options_scopeAuth;\n        if (this.options.disableScopeAuth) {\n            return subscriber;\n        }\n        const typeConfig = this.buildCache.getTypeConfig(fieldConfig.parentType);\n        if (typeConfig.graphqlKind !== 'Object' && typeConfig.graphqlKind !== 'Interface') {\n            throw new _core.PothosSchemaError(`Got fields for ${fieldConfig.parentType} which is a ${typeConfig.graphqlKind} which cannot have fields`);\n        }\n        if (!((_this_builder_options_scopeAuth = this.builder.options.scopeAuth) === null || _this_builder_options_scopeAuth === void 0 ? void 0 : _this_builder_options_scopeAuth.authorizeOnSubscribe) || typeConfig.kind !== 'Subscription') {\n            return subscriber;\n        }\n        const steps = this.createSubscribeSteps(fieldConfig, typeConfig, subscriber);\n        if (steps.length > 1) {\n            return (0, _resolvehelper.resolveHelper)(steps, this, fieldConfig);\n        }\n        return subscriber;\n    }\n    wrapResolveType(resolveType) {\n        return (...args)=>{\n            inResolveType = true;\n            try {\n                return resolveType(...args);\n            } finally{\n                inResolveType = false;\n            }\n        };\n    }\n    wrapIsTypeOf(isTypeOf, typeConfig) {\n        var _ref, _typeConfig_pothosOptions_runScopesOnType;\n        var _this_builder_options_scopeAuth;\n        if (this.options.disableScopeAuth) {\n            return isTypeOf;\n        }\n        const shouldRunTypeScopes = (_ref = (_typeConfig_pothosOptions_runScopesOnType = typeConfig.pothosOptions.runScopesOnType) !== null && _typeConfig_pothosOptions_runScopesOnType !== void 0 ? _typeConfig_pothosOptions_runScopesOnType : (_this_builder_options_scopeAuth = this.builder.options.scopeAuth) === null || _this_builder_options_scopeAuth === void 0 ? void 0 : _this_builder_options_scopeAuth.runScopesOnType) !== null && _ref !== void 0 ? _ref : false;\n        if (!shouldRunTypeScopes) {\n            return isTypeOf;\n        }\n        const steps = this.createStepsForType(typeConfig, {\n            forField: false\n        });\n        if (steps.length === 0) {\n            return isTypeOf;\n        }\n        const runSteps = (0, _istypeofhelper.isTypeOfHelper)(steps, this, isTypeOf);\n        return (source, context, info)=>{\n            if (inResolveType) {\n                var _ref;\n                return (_ref = isTypeOf === null || isTypeOf === void 0 ? void 0 : isTypeOf(source, context, info)) !== null && _ref !== void 0 ? _ref : false;\n            }\n            return runSteps(source, context, info);\n        };\n    }\n    createStepsForType(typeConfig, { skipTypeScopes, skipInterfaceScopes, forField }) {\n        const parentAuthScope = typeConfig.pothosOptions.authScopes;\n        const parentGrantScopes = typeConfig.pothosOptions.grantScopes;\n        const interfaceConfigs = typeConfig.kind === 'Object' || typeConfig.kind === 'Interface' ? typeConfig.interfaces.map((iface)=>this.buildCache.getTypeConfig(iface, 'Interface')) : [];\n        const steps = [];\n        if (parentAuthScope && !skipTypeScopes) {\n            steps.push((0, _steps.createTypeAuthScopesStep)(parentAuthScope, typeConfig.name));\n        }\n        if (!skipInterfaceScopes && !(typeConfig.kind === 'Object' && typeConfig.pothosOptions.skipInterfaceScopes)) {\n            for (const interfaceConfig of interfaceConfigs){\n                if (interfaceConfig.pothosOptions.authScopes) {\n                    steps.push((0, _steps.createTypeAuthScopesStep)(interfaceConfig.pothosOptions.authScopes, interfaceConfig.name));\n                }\n            }\n        }\n        if (parentGrantScopes) {\n            steps.push((0, _steps.createTypeGrantScopesStep)(parentGrantScopes, typeConfig.name, forField));\n        }\n        return steps;\n    }\n    createResolveSteps(fieldConfig, typeConfig, resolver, shouldRunTypeScopes, authorizedOnSubscribe) {\n        var _ref, _ref1;\n        const stepsForType = shouldRunTypeScopes && !authorizedOnSubscribe ? this.createStepsForType(typeConfig, {\n            skipTypeScopes: (_ref = (fieldConfig.graphqlKind === 'Interface' || fieldConfig.graphqlKind === 'Object') && fieldConfig.pothosOptions.skipTypeScopes) !== null && _ref !== void 0 ? _ref : false,\n            skipInterfaceScopes: (_ref1 = (fieldConfig.graphqlKind === 'Interface' || fieldConfig.kind === 'Object') && fieldConfig.pothosOptions.skipInterfaceScopes) !== null && _ref1 !== void 0 ? _ref1 : false,\n            forField: true\n        }) : [];\n        const fieldAuthScopes = fieldConfig.pothosOptions.authScopes;\n        const fieldGrantScopes = fieldConfig.pothosOptions.grantScopes;\n        const steps = [\n            ...stepsForType\n        ];\n        if (fieldAuthScopes && !authorizedOnSubscribe) {\n            steps.push((0, _steps.createFieldAuthScopesStep)(fieldAuthScopes));\n        }\n        steps.push((0, _steps.createResolveStep)(resolver));\n        if (fieldGrantScopes) {\n            steps.push((0, _steps.createFieldGrantScopesStep)(fieldGrantScopes));\n        }\n        return steps;\n    }\n    createSubscribeSteps(fieldConfig, typeConfig, subscriber) {\n        var _ref, _ref1;\n        const stepsForType = this.createStepsForType(typeConfig, {\n            skipTypeScopes: (_ref = (fieldConfig.graphqlKind === 'Interface' || fieldConfig.graphqlKind === 'Object') && fieldConfig.pothosOptions.skipTypeScopes) !== null && _ref !== void 0 ? _ref : false,\n            skipInterfaceScopes: (_ref1 = (fieldConfig.graphqlKind === 'Interface' || fieldConfig.kind === 'Object') && fieldConfig.pothosOptions.skipInterfaceScopes) !== null && _ref1 !== void 0 ? _ref1 : false,\n            forField: true\n        });\n        const fieldAuthScopes = fieldConfig.pothosOptions.authScopes;\n        const steps = [\n            ...stepsForType\n        ];\n        if (fieldAuthScopes) {\n            steps.push((0, _steps.createFieldAuthScopesStep)(fieldAuthScopes));\n        }\n        steps.push((0, _steps.createResolveStep)(subscriber));\n        return steps;\n    }\n}\nconst fieldBuilderProto = _core.RootFieldBuilder.prototype;\nfieldBuilderProto.authField = function authField(options) {\n    return this.field(options);\n};\n_core.default.registerPlugin(pluginName, PothosScopeAuthPlugin, {\n    v3: (options)=>({\n            scopeAuthOptions: undefined,\n            authScopes: undefined,\n            scopeAuth: {\n                ...options.scopeAuthOptions,\n                authScopes: options.authScopes\n            }\n        })\n});\n\n"]}