@estifanos-sh/convex-auth 0.0.1-preview.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/README.md +52 -0
- package/dist/_generated/component.d.ts +2981 -0
- package/dist/bin.js +7194 -0
- package/dist/browser/index.d.ts +22 -0
- package/dist/browser/index.js +61 -0
- package/dist/browser/locks.js +20 -0
- package/dist/browser/navigation.js +14 -0
- package/dist/browser/runtime.js +90 -0
- package/dist/browser/webauthn.js +99 -0
- package/dist/client/core/types.d.ts +615 -0
- package/dist/client/core/types.js +23 -0
- package/dist/client/errors.js +30 -0
- package/dist/client/factors/device.js +100 -0
- package/dist/client/factors/totp.js +111 -0
- package/dist/client/factors/webauthn.js +69 -0
- package/dist/client/index.d.ts +60 -0
- package/dist/client/index.js +976 -0
- package/dist/client/runtime/invite.js +50 -0
- package/dist/client/runtime/mutex.js +25 -0
- package/dist/client/runtime/proxy.js +75 -0
- package/dist/client/runtime/storage.js +65 -0
- package/dist/component/_generated/api.js +26 -0
- package/dist/component/_generated/component.d.ts +2981 -0
- package/dist/component/_generated/component.js +1 -0
- package/dist/component/_generated/dataModel.js +1 -0
- package/dist/component/_generated/server.js +74 -0
- package/dist/component/account.js +197 -0
- package/dist/component/connection/audit.js +152 -0
- package/dist/component/connection/cache.js +205 -0
- package/dist/component/connection/domain/verification.js +63 -0
- package/dist/component/connection/domain.js +108 -0
- package/dist/component/connection/saml/assertion.js +41 -0
- package/dist/component/connection/saml/request.js +61 -0
- package/dist/component/connection/scim/config.js +55 -0
- package/dist/component/connection/scim/identity.js +162 -0
- package/dist/component/connection/secret.js +65 -0
- package/dist/component/connection/webhook/delivery.js +396 -0
- package/dist/component/connection/webhook/endpoint.js +77 -0
- package/dist/component/connection.js +204 -0
- package/dist/component/convex.config.d.ts +7 -0
- package/dist/component/convex.config.js +15 -0
- package/dist/component/crons.js +27 -0
- package/dist/component/event.js +341 -0
- package/dist/component/factor/device.js +141 -0
- package/dist/component/factor/passkey.js +385 -0
- package/dist/component/factor/totp.js +253 -0
- package/dist/component/functions.js +3 -0
- package/dist/component/group/active.js +63 -0
- package/dist/component/group/invite.js +300 -0
- package/dist/component/group/member.js +188 -0
- package/dist/component/group.js +431 -0
- package/dist/component/http.js +9 -0
- package/dist/component/index.d.ts +5 -0
- package/dist/component/index.js +3 -0
- package/dist/component/limits.js +103 -0
- package/dist/component/maintenance.js +205 -0
- package/dist/component/migrations.js +277 -0
- package/dist/component/model.d.ts +384 -0
- package/dist/component/model.js +709 -0
- package/dist/component/modules.js +53 -0
- package/dist/component/oauth/client.js +196 -0
- package/dist/component/oauth/code.js +97 -0
- package/dist/component/oauth/refresh.js +230 -0
- package/dist/component/schema.d.ts +1530 -0
- package/dist/component/schema.js +401 -0
- package/dist/component/session.js +134 -0
- package/dist/component/token/pkce.js +121 -0
- package/dist/component/token/refresh.js +189 -0
- package/dist/component/token/verification.js +155 -0
- package/dist/component/user/email.js +147 -0
- package/dist/component/user/key.js +273 -0
- package/dist/component/user.js +173 -0
- package/dist/core/index.d.ts +531 -0
- package/dist/core/index.js +81 -0
- package/dist/expo/index.d.ts +43 -0
- package/dist/expo/index.js +131 -0
- package/dist/expo/webauthn.js +88 -0
- package/dist/node_modules/.pnpm/@opentelemetry_api-logs@0.214.0/node_modules/@opentelemetry/api-logs/build/src/NoopLogger.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_api-logs@0.214.0/node_modules/@opentelemetry/api-logs/build/src/api/logs.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_api-logs@0.214.0/node_modules/@opentelemetry/api-logs/build/src/index.d.ts +7 -0
- package/dist/node_modules/.pnpm/@opentelemetry_api-logs@0.214.0/node_modules/@opentelemetry/api-logs/build/src/types/AnyValue.d.ts +21 -0
- package/dist/node_modules/.pnpm/@opentelemetry_api-logs@0.214.0/node_modules/@opentelemetry/api-logs/build/src/types/LogRecord.d.ts +36 -0
- package/dist/node_modules/.pnpm/@opentelemetry_api-logs@0.214.0/node_modules/@opentelemetry/api-logs/build/src/types/Logger.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_api-logs@0.214.0/node_modules/@opentelemetry/api-logs/build/src/types/LoggerOptions.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_api-logs@0.214.0/node_modules/@opentelemetry/api-logs/build/src/types/LoggerProvider.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/baggage/propagation/W3CBaggagePropagator.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/baggage/utils.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/common/attributes.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/common/global-error-handler.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/common/logging-error-handler.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/common/time.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/common/types.d.ts +16 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/index.d.ts +13 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/propagation/composite.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/trace/TraceState.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/trace/W3CTraceContextPropagator.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/trace/rpc-metadata.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/trace/suppress-tracing.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_core@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/core/build/src/utils/configuration.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/LogRecordProcessor.d.ts +24 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/LoggerProvider.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/config/LoggerConfigurators.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/export/BatchLogRecordProcessorBase.d.ts +4 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/export/ConsoleLogRecordExporter.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/export/InMemoryLogRecordExporter.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/export/LogRecordExporter.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/export/ReadableLogRecord.d.ts +4 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/export/SdkLogRecord.d.ts +71 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/export/SimpleLogRecordProcessor.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/index.d.ts +11 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/platform/index.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/platform/node/export/BatchLogRecordProcessor.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/platform/node/index.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-logs@0.214.0_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-logs/build/src/types.d.ts +4 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/InstrumentDescriptor.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/MeterProvider.d.ts +4 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Drop.d.ts +4 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/ExponentialHistogram.d.ts +5 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Histogram.d.ts +5 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/LastValue.d.ts +5 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/Sum.d.ts +5 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/index.d.ts +6 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/aggregator/types.d.ts +53 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/AggregationSelector.d.ts +16 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/AggregationTemporality.d.ts +11 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/CardinalitySelector.d.ts +10 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/ConsoleMetricExporter.d.ts +4 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/InMemoryMetricExporter.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/MetricData.d.ts +148 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/MetricExporter.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/MetricProducer.d.ts +27 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/MetricReader.d.ts +138 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/export/PeriodicExportingMetricReader.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/index.d.ts +15 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/types.d.ts +10 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/utils.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/view/Aggregation.d.ts +4 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/view/AggregationOption.d.ts +41 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/view/AttributesProcessor.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/view/InstrumentSelector.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-metrics@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-metrics/build/src/view/View.d.ts +5 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/BasicTracerProvider.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/IdGenerator.d.ts +11 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/Sampler.d.ts +74 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/Span.d.ts +17 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/SpanProcessor.d.ts +43 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/TimedEvent.d.ts +19 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/export/BatchSpanProcessorBase.d.ts +6 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/export/ConsoleSpanExporter.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/export/InMemorySpanExporter.d.ts +3 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/export/NoopSpanProcessor.d.ts +4 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/export/ReadableSpan.d.ts +29 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/export/SimpleSpanProcessor.d.ts +5 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/export/SpanExporter.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/index.d.ts +18 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/platform/index.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/platform/node/export/BatchSpanProcessor.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/platform/node/index.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/sampler/AlwaysOffSampler.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/sampler/AlwaysOnSampler.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/sampler/ParentBasedSampler.d.ts +2 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/sampler/TraceIdRatioBasedSampler.d.ts +1 -0
- package/dist/node_modules/.pnpm/@opentelemetry_sdk-trace-base@2.6.1_@opentelemetry_api@1.9.1/node_modules/@opentelemetry/sdk-trace-base/build/src/types.d.ts +66 -0
- package/dist/otel.d.ts +73 -0
- package/dist/otel.js +82 -0
- package/dist/permissions/index.d.ts +81 -0
- package/dist/permissions/index.js +18 -0
- package/dist/providers/anonymous.d.ts +35 -0
- package/dist/providers/anonymous.js +40 -0
- package/dist/providers/apple.d.ts +61 -0
- package/dist/providers/apple.js +57 -0
- package/dist/providers/connection.d.ts +30 -0
- package/dist/providers/connection.js +33 -0
- package/dist/providers/credentials.d.ts +78 -0
- package/dist/providers/credentials.js +31 -0
- package/dist/providers/custom.d.ts +96 -0
- package/dist/providers/custom.js +108 -0
- package/dist/providers/device.d.ts +33 -0
- package/dist/providers/device.js +30 -0
- package/dist/providers/email.d.ts +45 -0
- package/dist/providers/email.js +52 -0
- package/dist/providers/github.d.ts +56 -0
- package/dist/providers/github.js +79 -0
- package/dist/providers/google.d.ts +56 -0
- package/dist/providers/google.js +59 -0
- package/dist/providers/index.d.ts +16 -0
- package/dist/providers/index.js +16 -0
- package/dist/providers/microsoft.d.ts +59 -0
- package/dist/providers/microsoft.js +98 -0
- package/dist/providers/password.d.ts +68 -0
- package/dist/providers/password.js +348 -0
- package/dist/providers/phone.d.ts +33 -0
- package/dist/providers/phone.js +35 -0
- package/dist/providers/redirect.d.ts +1 -0
- package/dist/providers/redirect.js +11 -0
- package/dist/providers/totp.d.ts +29 -0
- package/dist/providers/totp.js +29 -0
- package/dist/providers/webauthn/attestation.d.ts +42 -0
- package/dist/providers/webauthn/attestation.js +167 -0
- package/dist/providers/webauthn.d.ts +83 -0
- package/dist/providers/webauthn.js +57 -0
- package/dist/react/index.d.ts +55 -0
- package/dist/react/index.js +80 -0
- package/dist/server/auth.d.ts +443 -0
- package/dist/server/auth.js +178 -0
- package/dist/server/cache/context.js +94 -0
- package/dist/server/component/api.d.ts +14 -0
- package/dist/server/component/api.js +13 -0
- package/dist/server/component/context.d.ts +16 -0
- package/dist/server/component/context.js +1 -0
- package/dist/server/component/factor/db.js +71 -0
- package/dist/server/config.d.ts +3 -0
- package/dist/server/config.js +78 -0
- package/dist/server/connection/config.js +101 -0
- package/dist/server/connection/domain.d.ts +878 -0
- package/dist/server/connection/domain.js +1122 -0
- package/dist/server/connection/group/service.d.ts +25 -0
- package/dist/server/connection/group/service.js +250 -0
- package/dist/server/connection/http.js +1485 -0
- package/dist/server/connection/oidc.js +366 -0
- package/dist/server/connection/policy/domain.js +59 -0
- package/dist/server/connection/policy.d.ts +1 -0
- package/dist/server/connection/policy.js +163 -0
- package/dist/server/connection/profile.js +22 -0
- package/dist/server/connection/provision.js +182 -0
- package/dist/server/connection/saml/api.js +70 -0
- package/dist/server/connection/saml/binding/post.js +140 -0
- package/dist/server/connection/saml/binding/redirect.js +139 -0
- package/dist/server/connection/saml/binding/shared.js +18 -0
- package/dist/server/connection/saml/c14n.js +224 -0
- package/dist/server/connection/saml/constants.js +100 -0
- package/dist/server/connection/saml/crypto.js +170 -0
- package/dist/server/connection/saml/dom/select.js +299 -0
- package/dist/server/connection/saml/encoding.js +93 -0
- package/dist/server/connection/saml/encryption.js +34 -0
- package/dist/server/connection/saml/entity.js +24 -0
- package/dist/server/connection/saml/extractor.js +408 -0
- package/dist/server/connection/saml/flow.js +150 -0
- package/dist/server/connection/saml/identity/provider.js +66 -0
- package/dist/server/connection/saml/index.js +5 -0
- package/dist/server/connection/saml/metadata.js +294 -0
- package/dist/server/connection/saml/service/provider.js +117 -0
- package/dist/server/connection/saml/signature.js +214 -0
- package/dist/server/connection/saml/template.js +68 -0
- package/dist/server/connection/saml/types.js +1 -0
- package/dist/server/connection/saml/validator.js +32 -0
- package/dist/server/connection/saml/xml/builder.js +68 -0
- package/dist/server/connection/saml/xmldsig.js +598 -0
- package/dist/server/connection/saml/xmlenc.js +162 -0
- package/dist/server/connection/saml.d.ts +56 -0
- package/dist/server/connection/saml.js +762 -0
- package/dist/server/connection/scim.js +115 -0
- package/dist/server/connection/shared.js +74 -0
- package/dist/server/connection/webhook.js +163 -0
- package/dist/server/context.d.ts +137 -0
- package/dist/server/context.js +108 -0
- package/dist/server/contract.d.ts +48 -0
- package/dist/server/contract.js +107 -0
- package/dist/server/cookies.js +90 -0
- package/dist/server/core.js +163 -0
- package/dist/server/cors.d.ts +22 -0
- package/dist/server/cors.js +93 -0
- package/dist/server/crypto.js +43 -0
- package/dist/server/db.js +88 -0
- package/dist/server/device.js +140 -0
- package/dist/server/domains/access.js +29 -0
- package/dist/server/domains/account.d.ts +16 -0
- package/dist/server/domains/account.js +92 -0
- package/dist/server/domains/factor.d.ts +28 -0
- package/dist/server/domains/factor.js +115 -0
- package/dist/server/domains/group.js +87 -0
- package/dist/server/domains/invite.js +76 -0
- package/dist/server/domains/key.js +253 -0
- package/dist/server/domains/member.js +149 -0
- package/dist/server/domains/session.js +29 -0
- package/dist/server/domains/user.js +119 -0
- package/dist/server/env.d.ts +46 -0
- package/dist/server/env.js +96 -0
- package/dist/server/errors.js +38 -0
- package/dist/server/events.d.ts +880 -0
- package/dist/server/events.js +406 -0
- package/dist/server/facade.d.ts +83 -0
- package/dist/server/facade.js +124 -0
- package/dist/server/http.d.ts +125 -0
- package/dist/server/http.js +566 -0
- package/dist/server/identity/claims.js +58 -0
- package/dist/server/identity/convex.d.ts +15 -0
- package/dist/server/identity/convex.js +1 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/server/index.js +11 -0
- package/dist/server/keys.js +60 -0
- package/dist/server/limits.js +41 -0
- package/dist/server/log.js +28 -0
- package/dist/server/mcp.d.ts +19 -0
- package/dist/server/mcp.js +250 -0
- package/dist/server/mutations/account.js +47 -0
- package/dist/server/mutations/calls.js +16 -0
- package/dist/server/mutations/code.js +91 -0
- package/dist/server/mutations/credentials/signin.js +210 -0
- package/dist/server/mutations/invalidate.js +60 -0
- package/dist/server/mutations/oauth.js +251 -0
- package/dist/server/mutations/refresh.js +152 -0
- package/dist/server/mutations/register.js +93 -0
- package/dist/server/mutations/retrieve.js +66 -0
- package/dist/server/mutations/signature.js +36 -0
- package/dist/server/mutations/signin.js +81 -0
- package/dist/server/mutations/signout.js +61 -0
- package/dist/server/mutations/store/refs.js +15 -0
- package/dist/server/mutations/store.js +82 -0
- package/dist/server/mutations/verifier.js +25 -0
- package/dist/server/mutations/verify.js +199 -0
- package/dist/server/oauth/authorize.js +98 -0
- package/dist/server/oauth/client.d.ts +93 -0
- package/dist/server/oauth/client.js +115 -0
- package/dist/server/oauth/code.d.ts +63 -0
- package/dist/server/oauth/code.js +124 -0
- package/dist/server/oauth/domain.d.ts +23 -0
- package/dist/server/oauth/domain.js +1 -0
- package/dist/server/oauth/factory.js +46 -0
- package/dist/server/oauth/grant.js +46 -0
- package/dist/server/oauth/handlers.js +108 -0
- package/dist/server/oauth/manage.js +121 -0
- package/dist/server/oauth/normalize.js +27 -0
- package/dist/server/oauth/refresh.d.ts +71 -0
- package/dist/server/oauth/refresh.js +132 -0
- package/dist/server/oauth/register.js +147 -0
- package/dist/server/oauth/runtime.js +280 -0
- package/dist/server/oauth/token.js +355 -0
- package/dist/server/payloads.d.ts +16 -0
- package/dist/server/payloads.js +30 -0
- package/dist/server/preload.d.ts +249 -0
- package/dist/server/preload.js +673 -0
- package/dist/server/random.js +25 -0
- package/dist/server/redirects.js +85 -0
- package/dist/server/runtime.d.ts +845 -0
- package/dist/server/runtime.js +387 -0
- package/dist/server/secret.js +46 -0
- package/dist/server/services/factors.js +117 -0
- package/dist/server/services/providers.js +23 -0
- package/dist/server/services/resolve.js +17 -0
- package/dist/server/session/lifecycle.d.ts +23 -0
- package/dist/server/session/lifecycle.js +139 -0
- package/dist/server/signin/flow.js +359 -0
- package/dist/server/telemetry.js +68 -0
- package/dist/server/templates.js +91 -0
- package/dist/server/token/refresh.js +35 -0
- package/dist/server/tokens.js +164 -0
- package/dist/server/totp.js +282 -0
- package/dist/server/types.d.ts +1154 -0
- package/dist/server/types.js +1 -0
- package/dist/server/url.js +43 -0
- package/dist/server/user/account.js +325 -0
- package/dist/server/utils/bearer.js +24 -0
- package/dist/server/utils/cache.js +51 -0
- package/dist/server/utils/retry.js +3 -0
- package/dist/server/utils/span.js +59 -0
- package/dist/server/validators.d.ts +2061 -0
- package/dist/server/validators.js +320 -0
- package/dist/server/webauthn.js +699 -0
- package/dist/server/wellknown.d.ts +74 -0
- package/dist/server/wellknown.js +195 -0
- package/dist/shared/brand.d.ts +28 -0
- package/dist/shared/brand.js +13 -0
- package/dist/shared/codes.d.ts +99 -0
- package/dist/shared/codes.js +98 -0
- package/dist/shared/compare.js +23 -0
- package/dist/shared/errors.js +24 -0
- package/dist/shared/event/kinds.d.ts +188 -0
- package/dist/shared/event/kinds.js +103 -0
- package/dist/shared/fetch/guard.js +189 -0
- package/dist/shared/log.js +62 -0
- package/dist/shared/results.d.ts +58 -0
- package/dist/shared/retry.js +27 -0
- package/dist/shared/webauthn.js +9 -0
- package/dist/svelte/AuthLoading.svelte +13 -0
- package/dist/svelte/AuthLoading.svelte.d.ts +8 -0
- package/dist/svelte/SignedIn.svelte +14 -0
- package/dist/svelte/SignedIn.svelte.d.ts +8 -0
- package/dist/svelte/SignedOut.svelte +13 -0
- package/dist/svelte/SignedOut.svelte.d.ts +8 -0
- package/dist/svelte/context.svelte.d.ts +26 -0
- package/dist/svelte/context.svelte.js +61 -0
- package/dist/svelte/index.d.ts +5 -0
- package/dist/svelte/index.js +4 -0
- package/dist/test.d.ts +48 -0
- package/dist/test.js +54 -0
- package/package.json +247 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { AuthApiRefs } from "../client/core/types.js";
|
|
2
|
+
import "../client/index.js";
|
|
3
|
+
import { AuthMemberInspectResult, AuthProviderConfig, ConvexAuthConfig, Doc, Grant, HasDeviceProvider, HasTotpProvider, HasWebAuthnProvider, PermissionsConfig, RoleId } from "./types.js";
|
|
4
|
+
import { AuthContext, AuthContextConfig, OptionalAuthContext, UserDoc } from "./context.js";
|
|
5
|
+
import { AuthConfig, AuthContextFactory, AuthContextResolver, InferAuth, OptionalAuthContextFactory, OptionalAuthContextResolver } from "./facade.js";
|
|
6
|
+
import { McpToolDef } from "./mcp.js";
|
|
7
|
+
import { Auth } from "./runtime.js";
|
|
8
|
+
import { AuthExtendValidators, AuthValidators } from "./validators.js";
|
|
9
|
+
import { GenericValidator } from "convex/values";
|
|
10
|
+
import { HttpRouter } from "convex/server";
|
|
11
|
+
|
|
12
|
+
//#region src/server/auth.d.ts
|
|
13
|
+
/**
|
|
14
|
+
* `member.get`/`member.assert` result with `roleIds`/`grants` narrowed
|
|
15
|
+
* from `string[]` to the permission-typed literal unions.
|
|
16
|
+
*/
|
|
17
|
+
type MemberAccessResult<TPermissions extends PermissionsConfig | undefined> = Omit<AuthMemberInspectResult, "roleIds" | "grants"> & {
|
|
18
|
+
roleIds: RoleId<TPermissions>[];
|
|
19
|
+
grants: Grant<TPermissions>[];
|
|
20
|
+
};
|
|
21
|
+
type MemberResolutionResult<TPermissions extends PermissionsConfig | undefined> = MemberAccessResult<TPermissions> & {
|
|
22
|
+
matchedGroupId: string | null;
|
|
23
|
+
depth: number | null;
|
|
24
|
+
isDirect: boolean;
|
|
25
|
+
isInherited: boolean;
|
|
26
|
+
traversedGroupIds: string[];
|
|
27
|
+
};
|
|
28
|
+
type MemberApiWithPermissions<TPermissions extends PermissionsConfig | undefined> = Omit<ReturnType<typeof Auth>["auth"]["member"], "create" | "list" | "update" | "get" | "resolve" | "assert"> & {
|
|
29
|
+
create: (ctx: Parameters<ReturnType<typeof Auth>["auth"]["member"]["create"]>[0], args: {
|
|
30
|
+
data: {
|
|
31
|
+
groupId: string;
|
|
32
|
+
userId: string;
|
|
33
|
+
roleIds?: RoleId<TPermissions>[];
|
|
34
|
+
status?: string;
|
|
35
|
+
extend?: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
}) => Promise<string>;
|
|
38
|
+
list: (ctx: Parameters<ReturnType<typeof Auth>["auth"]["member"]["list"]>[0], opts?: {
|
|
39
|
+
where?: {
|
|
40
|
+
groupId?: string;
|
|
41
|
+
userId?: string;
|
|
42
|
+
status?: string;
|
|
43
|
+
};
|
|
44
|
+
paginationOpts?: {
|
|
45
|
+
numItems: number;
|
|
46
|
+
cursor: string | null;
|
|
47
|
+
};
|
|
48
|
+
orderBy?: "_creationTime" | "status";
|
|
49
|
+
order?: "asc" | "desc";
|
|
50
|
+
}) => Promise<{
|
|
51
|
+
page: Doc<"GroupMember">[];
|
|
52
|
+
isDone: boolean;
|
|
53
|
+
continueCursor: string;
|
|
54
|
+
splitCursor?: string | null;
|
|
55
|
+
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
56
|
+
}>;
|
|
57
|
+
update: (ctx: Parameters<ReturnType<typeof Auth>["auth"]["member"]["update"]>[0], args: {
|
|
58
|
+
id: string;
|
|
59
|
+
patch: Record<string, unknown> & {
|
|
60
|
+
roleIds?: RoleId<TPermissions>[];
|
|
61
|
+
};
|
|
62
|
+
}) => Promise<null>;
|
|
63
|
+
get: {
|
|
64
|
+
(ctx: Parameters<ReturnType<typeof Auth>["auth"]["member"]["get"]>[0], args: {
|
|
65
|
+
userId: string;
|
|
66
|
+
groupId: string;
|
|
67
|
+
}): Promise<MemberAccessResult<TPermissions>>;
|
|
68
|
+
(ctx: Parameters<ReturnType<typeof Auth>["auth"]["member"]["get"]>[0], args: {
|
|
69
|
+
userId: string;
|
|
70
|
+
groupIds: readonly string[];
|
|
71
|
+
}): Promise<MemberAccessResult<TPermissions>[]>;
|
|
72
|
+
};
|
|
73
|
+
resolve: (ctx: Parameters<ReturnType<typeof Auth>["auth"]["member"]["resolve"]>[0], args: {
|
|
74
|
+
userId: string;
|
|
75
|
+
groupId: string;
|
|
76
|
+
maxDepth?: number;
|
|
77
|
+
}) => Promise<MemberResolutionResult<TPermissions>>;
|
|
78
|
+
assert: (ctx: Parameters<ReturnType<typeof Auth>["auth"]["member"]["assert"]>[0], opts: {
|
|
79
|
+
userId: string;
|
|
80
|
+
groupId: string;
|
|
81
|
+
roleIds?: RoleId<TPermissions>[];
|
|
82
|
+
grants?: Grant<TPermissions>[];
|
|
83
|
+
}) => Promise<MemberAccessResult<TPermissions>>;
|
|
84
|
+
};
|
|
85
|
+
type RuntimeAuthApi = ReturnType<typeof Auth>["auth"];
|
|
86
|
+
/** App-facing account management. Provider credential internals remain on provider callback ctx. */
|
|
87
|
+
type PublicAccountApi = RuntimeAuthApi["accountManagement"];
|
|
88
|
+
/** App-facing OAuth administration and consent; wire-protocol helpers stay runtime-internal. */
|
|
89
|
+
type PublicOAuthApi = {
|
|
90
|
+
authorize: RuntimeAuthApi["oauth"]["authorize"];
|
|
91
|
+
client: Omit<RuntimeAuthApi["oauth"]["client"], "verify" | "verifyRegistrationToken">;
|
|
92
|
+
};
|
|
93
|
+
/** Audit event read/write surface for app-owned domain events. */
|
|
94
|
+
type PublicEventApi = RuntimeAuthApi["event"];
|
|
95
|
+
/**
|
|
96
|
+
* `request.mcp` with each tool's `scope` narrowed from `string` to the
|
|
97
|
+
* permission-typed grant union — a tool may only require a declared grant, so a
|
|
98
|
+
* typo or stale scope is a compile error.
|
|
99
|
+
*/
|
|
100
|
+
type RequestApiWithPermissions<TPermissions extends PermissionsConfig | undefined> = Omit<ReturnType<typeof Auth>["auth"]["request"], "mcp" | "router"> & {
|
|
101
|
+
mcp: <T extends Record<string, GenericValidator>>(http: HttpRouter, tools: { [K in keyof T]: McpToolDef<T[K], Grant<TPermissions>> }, opts?: {
|
|
102
|
+
name?: string;
|
|
103
|
+
version?: string;
|
|
104
|
+
}) => void;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The base auth API surface returned by {@link defineAuth}.
|
|
108
|
+
*
|
|
109
|
+
* Provides core namespaces — `signIn`, `signOut`, `user`, `session`,
|
|
110
|
+
* `member`, `invite`, `group`, `key`, and `request` — that are
|
|
111
|
+
* always available regardless of which providers are configured.
|
|
112
|
+
* Use this type when you want to describe code that only depends on the
|
|
113
|
+
* standard auth surface and should not assume group connection features exist.
|
|
114
|
+
*
|
|
115
|
+
* @typeParam TPermissions - The permissions config, used to narrow
|
|
116
|
+
* role IDs and grant strings on the `member` API.
|
|
117
|
+
*/
|
|
118
|
+
type AuthApiBase<TPermissions extends PermissionsConfig | undefined = undefined, TExtend extends AuthExtendValidators = {}> = {
|
|
119
|
+
/**
|
|
120
|
+
* Convex `returns:` validators for the auth read surface.
|
|
121
|
+
*
|
|
122
|
+
* Set these as a function's `returns:` so client-side `useQuery`
|
|
123
|
+
* inference flows end-to-end without hand-rolled validators or DTO
|
|
124
|
+
* mappers. The `extend` field of each document carries the shape
|
|
125
|
+
* supplied via `defineAuth({ extend: { ... } })`.
|
|
126
|
+
*
|
|
127
|
+
* Available validators:
|
|
128
|
+
* - `v.user` / `v.group` / `v.member` — single documents (extend-aware).
|
|
129
|
+
* - `v.invite` — a single group invite document.
|
|
130
|
+
* - `v.viewer` — `User | null`, for a current-user query.
|
|
131
|
+
* - `v.connection.*` — group connection admin facade results.
|
|
132
|
+
* - `v.list(item)` — wraps an item validator in Convex's
|
|
133
|
+
* `{ page, isDone, continueCursor }` pagination result shape.
|
|
134
|
+
*
|
|
135
|
+
* Compose these for richer reads — e.g. a current user plus their
|
|
136
|
+
* memberships and groups — using the existing `auth.user.viewer`,
|
|
137
|
+
* `auth.member.list`, and `auth.group.get` facade methods.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* export const viewer = authQuery({
|
|
142
|
+
* returns: auth.v.viewer,
|
|
143
|
+
* handler: (ctx) => ctx.auth.user.viewer(ctx),
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* export const groups = authQuery({
|
|
147
|
+
* returns: v.union(
|
|
148
|
+
* v.object({
|
|
149
|
+
* ...auth.v.user.fields,
|
|
150
|
+
* memberships: v.array(auth.v.member),
|
|
151
|
+
* groups: v.array(auth.v.group),
|
|
152
|
+
* }),
|
|
153
|
+
* v.null(),
|
|
154
|
+
* ),
|
|
155
|
+
* handler: async (ctx) => {
|
|
156
|
+
* const me = await ctx.auth.user.viewer(ctx);
|
|
157
|
+
* if (me === null) return null;
|
|
158
|
+
* const { page: memberships } = await ctx.auth.member.list(ctx, {
|
|
159
|
+
* where: { userId: me._id },
|
|
160
|
+
* paginationOpts: { cursor: null, numItems: 25 },
|
|
161
|
+
* });
|
|
162
|
+
* const groups = await ctx.auth.group.get(ctx, {
|
|
163
|
+
* ids: memberships.map((m) => m.groupId),
|
|
164
|
+
* });
|
|
165
|
+
* return { ...me, memberships, groups };
|
|
166
|
+
* },
|
|
167
|
+
* });
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
v: AuthValidators<TExtend>;
|
|
171
|
+
signIn: ReturnType<typeof Auth>["signIn"];
|
|
172
|
+
signOut: ReturnType<typeof Auth>["signOut"];
|
|
173
|
+
store: ReturnType<typeof Auth>["store"];
|
|
174
|
+
http: ReturnType<typeof Auth>["http"];
|
|
175
|
+
user: ReturnType<typeof Auth>["auth"]["user"];
|
|
176
|
+
session: ReturnType<typeof Auth>["auth"]["session"];
|
|
177
|
+
account: PublicAccountApi;
|
|
178
|
+
factor: RuntimeAuthApi["factor"];
|
|
179
|
+
group: ReturnType<typeof Auth>["auth"]["group"] & {
|
|
180
|
+
/** Current user's active-group selection (`get` / `update` / `reset`). */active: ReturnType<typeof Auth>["auth"]["active"];
|
|
181
|
+
};
|
|
182
|
+
member: MemberApiWithPermissions<TPermissions>;
|
|
183
|
+
invite: ReturnType<typeof Auth>["auth"]["invite"];
|
|
184
|
+
key: ReturnType<typeof Auth>["auth"]["key"];
|
|
185
|
+
provider: ReturnType<typeof Auth>["auth"]["provider"];
|
|
186
|
+
oauth: PublicOAuthApi;
|
|
187
|
+
event: PublicEventApi;
|
|
188
|
+
request: RequestApiWithPermissions<TPermissions>;
|
|
189
|
+
/**
|
|
190
|
+
* Build app-owned public RPCs for group Connection admin screens.
|
|
191
|
+
*
|
|
192
|
+
* This mirrors Convex component setup: start from the configured auth
|
|
193
|
+
* handle, then mount the Connection routes/functions from that handle.
|
|
194
|
+
*/
|
|
195
|
+
connection: PublicGroupConnectionApi;
|
|
196
|
+
/**
|
|
197
|
+
* Resolve the current request's auth context. Framework-agnostic — use
|
|
198
|
+
* this in custom wrappers, middleware, or anywhere you need the current
|
|
199
|
+
* `{ userId, user, groupId, role, grants }` object.
|
|
200
|
+
*
|
|
201
|
+
* This is the authorization-enrichment path. For native identity claims
|
|
202
|
+
* already present on the JWT, prefer `ctx.auth.getUserIdentity()`.
|
|
203
|
+
*
|
|
204
|
+
* Throws a structured `ConvexError` when unauthenticated by default.
|
|
205
|
+
* Use `auth.context.optional(ctx)` to get a null-shaped auth object instead.
|
|
206
|
+
*
|
|
207
|
+
* @param ctx - Convex query, mutation, or action context.
|
|
208
|
+
* @param config - Optional auth resolution config. Supports `require`,
|
|
209
|
+
* `active`, and `resolve`.
|
|
210
|
+
* @returns The current auth context.
|
|
211
|
+
*
|
|
212
|
+
* @example Direct usage in a handler
|
|
213
|
+
* ```ts
|
|
214
|
+
* const authContext = await auth.context(ctx);
|
|
215
|
+
* const { userId, grants } = authContext;
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @example Optional usage
|
|
219
|
+
* ```ts
|
|
220
|
+
* const authContext = await auth.context.optional(ctx);
|
|
221
|
+
* if (authContext.userId === null) {
|
|
222
|
+
* return null;
|
|
223
|
+
* }
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @example With resolve
|
|
227
|
+
* ```ts
|
|
228
|
+
* const authContext = await auth.context(ctx, {
|
|
229
|
+
* resolve: async (_ctx, user, state) => ({
|
|
230
|
+
* email: user.email,
|
|
231
|
+
* canWrite: state.grants.includes("posts.write"),
|
|
232
|
+
* }),
|
|
233
|
+
* });
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
context: AuthContextResolver & {
|
|
237
|
+
optional: OptionalAuthContextResolver;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Context enrichment for convex-helpers `customQuery` / `customMutation` /
|
|
241
|
+
* `customAction`.
|
|
242
|
+
*
|
|
243
|
+
* Resolves the current user's identity, active group, membership role,
|
|
244
|
+
* and grants, then attaches them to `ctx.auth`. Returns a `Customization`
|
|
245
|
+
* object compatible with convex-helpers' custom function builders.
|
|
246
|
+
*
|
|
247
|
+
* `ctx.auth` is the current request auth context.
|
|
248
|
+
* By default this throws when unauthenticated so handlers can assume
|
|
249
|
+
* `ctx.auth.userId` and `ctx.auth.user` exist.
|
|
250
|
+
*
|
|
251
|
+
* @returns A convex-helpers `Customization` object.
|
|
252
|
+
*
|
|
253
|
+
* @example One-time setup in `convex/functions.ts`
|
|
254
|
+
* ```ts
|
|
255
|
+
* import { query, mutation, action } from "./_generated/server";
|
|
256
|
+
* import { customQuery, customMutation, customAction } from "convex-helpers/server/customFunctions";
|
|
257
|
+
* import { auth } from "./auth";
|
|
258
|
+
*
|
|
259
|
+
* export const authQuery = customQuery(query, auth.ctx());
|
|
260
|
+
* export const authMutation = customMutation(mutation, auth.ctx());
|
|
261
|
+
* export const authAction = customAction(action, auth.ctx());
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* @example Per-function usage
|
|
265
|
+
* ```ts
|
|
266
|
+
* import { authQuery } from "./functions";
|
|
267
|
+
*
|
|
268
|
+
* export const list = authQuery({
|
|
269
|
+
* args: { workspaceId: v.string() },
|
|
270
|
+
* handler: async (ctx, args) => {
|
|
271
|
+
* const { userId, groupId, grants } = ctx.auth;
|
|
272
|
+
* // business logic
|
|
273
|
+
* },
|
|
274
|
+
* });
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
ctx: AuthContextFactory & {
|
|
278
|
+
optional: OptionalAuthContextFactory;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
type InternalConnectionApi = ReturnType<typeof Auth>["auth"]["connection"];
|
|
282
|
+
type PublicGroupConnectionApi = InternalConnectionApi["connection"] & {
|
|
283
|
+
signIn: (ctx: Parameters<InternalConnectionApi["oidc"]["signIn"]>[0], data: {
|
|
284
|
+
connectionId?: string;
|
|
285
|
+
email?: string;
|
|
286
|
+
domain?: string;
|
|
287
|
+
redirectTo?: string;
|
|
288
|
+
loginHint?: string;
|
|
289
|
+
}) => Promise<{
|
|
290
|
+
connectionId: string;
|
|
291
|
+
protocol: "oidc" | "saml";
|
|
292
|
+
providerId: string;
|
|
293
|
+
signInPath: string;
|
|
294
|
+
callbackPath: string;
|
|
295
|
+
redirectTo?: string;
|
|
296
|
+
}>;
|
|
297
|
+
metadata: InternalConnectionApi["saml"]["metadata"];
|
|
298
|
+
domain: {
|
|
299
|
+
list: InternalConnectionApi["domain"]["list"];
|
|
300
|
+
validate: InternalConnectionApi["domain"]["validate"];
|
|
301
|
+
status: InternalConnectionApi["domain"]["status"];
|
|
302
|
+
upsert: (ctx: Parameters<InternalConnectionApi["connection"]["create"]>[0], args: {
|
|
303
|
+
connectionId: string;
|
|
304
|
+
domains: Array<{
|
|
305
|
+
domain: string;
|
|
306
|
+
isPrimary?: boolean;
|
|
307
|
+
}>;
|
|
308
|
+
}) => Promise<{
|
|
309
|
+
connectionId: string;
|
|
310
|
+
domains: Array<{
|
|
311
|
+
domainId: string;
|
|
312
|
+
domain: string;
|
|
313
|
+
isPrimary: boolean;
|
|
314
|
+
verified: boolean;
|
|
315
|
+
verifiedAt: number | null;
|
|
316
|
+
}>;
|
|
317
|
+
}>;
|
|
318
|
+
verification: {
|
|
319
|
+
request: (ctx: Parameters<InternalConnectionApi["connection"]["create"]>[0], args: {
|
|
320
|
+
connectionId: string;
|
|
321
|
+
domain: string;
|
|
322
|
+
}) => Promise<{
|
|
323
|
+
connectionId: string;
|
|
324
|
+
domain: string;
|
|
325
|
+
requestedAt: number;
|
|
326
|
+
expiresAt: number;
|
|
327
|
+
challenge: {
|
|
328
|
+
recordType: "TXT";
|
|
329
|
+
recordName: string;
|
|
330
|
+
recordValue: string;
|
|
331
|
+
};
|
|
332
|
+
}>;
|
|
333
|
+
confirm: (ctx: Parameters<InternalConnectionApi["connection"]["create"]>[0], args: {
|
|
334
|
+
connectionId: string;
|
|
335
|
+
domain: string;
|
|
336
|
+
}) => Promise<{
|
|
337
|
+
connectionId: string;
|
|
338
|
+
domain: string;
|
|
339
|
+
verifiedAt?: number;
|
|
340
|
+
checks: Array<{
|
|
341
|
+
name: string;
|
|
342
|
+
ok: boolean;
|
|
343
|
+
message?: string;
|
|
344
|
+
}>;
|
|
345
|
+
}>;
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
oidc: Omit<InternalConnectionApi["oidc"], "signIn">;
|
|
349
|
+
saml: InternalConnectionApi["saml"];
|
|
350
|
+
policy: InternalConnectionApi["policy"];
|
|
351
|
+
audit: {
|
|
352
|
+
list: InternalConnectionApi["audit"]["list"];
|
|
353
|
+
};
|
|
354
|
+
webhook: {
|
|
355
|
+
endpoint: InternalConnectionApi["webhook"]["endpoint"];
|
|
356
|
+
delivery: {
|
|
357
|
+
list: InternalConnectionApi["webhook"]["delivery"]["list"];
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
scim: Omit<InternalConnectionApi["scim"], "getConfigByToken" | "identity">;
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Auth API returned by {@link defineAuth}.
|
|
364
|
+
*
|
|
365
|
+
* @typeParam TPermissions - The permissions config, forwarded to
|
|
366
|
+
* {@link AuthApiBase} for typed role IDs and grant strings.
|
|
367
|
+
*/
|
|
368
|
+
type AuthApi<TPermissions extends PermissionsConfig | undefined = undefined, TExtend extends AuthExtendValidators = {}> = AuthApiBase<TPermissions, TExtend>;
|
|
369
|
+
/**
|
|
370
|
+
* The return type of {@link defineAuth}.
|
|
371
|
+
*
|
|
372
|
+
* This lets application code keep a single `defineAuth()` call while getting
|
|
373
|
+
* the canonical auth namespaces, including the flat `auth.connection.*` admin
|
|
374
|
+
* facade for group connections.
|
|
375
|
+
*
|
|
376
|
+
* @typeParam P - The tuple of provider configs passed to `defineAuth`.
|
|
377
|
+
* @typeParam TPermissions - Optional permissions config for typed roles/grants.
|
|
378
|
+
*/
|
|
379
|
+
type ConvexAuthResult<P extends AuthProviderConfig[], TPermissions extends PermissionsConfig | undefined = undefined, TExtend extends AuthExtendValidators = {}> = AuthApi<TPermissions, TExtend>;
|
|
380
|
+
/**
|
|
381
|
+
* Infer the typed `AuthApiRefs` for the client SDK from a `defineAuth` call.
|
|
382
|
+
*
|
|
383
|
+
* Use this as the generic parameter for `client()` on the frontend:
|
|
384
|
+
*
|
|
385
|
+
* ```ts
|
|
386
|
+
* // convex/auth.ts
|
|
387
|
+
* export const auth = defineAuth(components.auth, { providers: [...] });
|
|
388
|
+
*
|
|
389
|
+
* // Frontend
|
|
390
|
+
* import type { auth } from "../convex/auth";
|
|
391
|
+
* import type { InferClientApi } from "@estifanos-sh/convex-auth/server";
|
|
392
|
+
* const c = client<InferClientApi<typeof auth>>({ convex, api: api.auth });
|
|
393
|
+
* ```
|
|
394
|
+
*
|
|
395
|
+
* @typeParam T - A ConvexAuthResult to extract the client API from.
|
|
396
|
+
*/
|
|
397
|
+
type InferClientApi<T> = T extends ConvexAuthResult<infer P> ? AuthApiRefs<HasWebAuthnProvider<P>, HasTotpProvider<P>, HasDeviceProvider<P>> : AuthApiRefs;
|
|
398
|
+
/**
|
|
399
|
+
* Define an auth API object.
|
|
400
|
+
*
|
|
401
|
+
* Connection admin RPCs are exposed by wrapping the `auth.connection.*`
|
|
402
|
+
* facade in your own `authMutation`/`authQuery` functions (authorize with
|
|
403
|
+
* `auth.member.assert`), the same pattern as every other namespace.
|
|
404
|
+
*
|
|
405
|
+
* @param component - The installed auth component reference from
|
|
406
|
+
* `components.auth` in your Convex app definition.
|
|
407
|
+
* @param config - Auth configuration including `providers` and optional
|
|
408
|
+
* `permissions`. All fields from {@link AuthConfig} are accepted
|
|
409
|
+
* except `component` (passed as the first argument).
|
|
410
|
+
* @returns A {@link ConvexAuthResult} — the full auth API surface
|
|
411
|
+
* ({@link AuthApiBase}) plus the `connection` group-admin facade.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```ts
|
|
415
|
+
* export const auth = defineAuth(components.auth, {
|
|
416
|
+
* providers: [password(), google()],
|
|
417
|
+
* permissions,
|
|
418
|
+
* });
|
|
419
|
+
* ```
|
|
420
|
+
*
|
|
421
|
+
* @see {@link AuthContextConfig}
|
|
422
|
+
*/
|
|
423
|
+
declare function defineAuth<P extends AuthProviderConfig[], TPermissions extends PermissionsConfig | undefined = undefined, TExtend extends AuthExtendValidators = {}>(component: ConvexAuthConfig<TExtend>["component"], config: Omit<AuthConfig<TExtend>, "providers" | "permissions"> & {
|
|
424
|
+
providers: P;
|
|
425
|
+
permissions?: TPermissions;
|
|
426
|
+
/**
|
|
427
|
+
* Validators for the `extend` field of each table. Drives both the
|
|
428
|
+
* inferred type of `auth.v.*` (so `viewer.extend.<field>` is typed)
|
|
429
|
+
* and runtime validation of consumer return shapes.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* defineAuth(components.auth, {
|
|
434
|
+
* providers: [password()],
|
|
435
|
+
* extend: { User: v.object({ stripeCustomerId: v.optional(v.string()) }) },
|
|
436
|
+
* });
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
extend?: TExtend;
|
|
440
|
+
}): ConvexAuthResult<P, TPermissions, TExtend>;
|
|
441
|
+
//#endregion
|
|
442
|
+
export { AuthApi, AuthApiBase, ConvexAuthResult, InferClientApi, defineAuth };
|
|
443
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { ErrorCode } from "../shared/codes.js";
|
|
2
|
+
import { createAuthContextFacade } from "./facade.js";
|
|
3
|
+
import { Auth } from "./runtime.js";
|
|
4
|
+
import { createAuthValidators } from "./validators.js";
|
|
5
|
+
import { ConvexError } from "convex/values";
|
|
6
|
+
|
|
7
|
+
//#region src/server/auth.ts
|
|
8
|
+
/**
|
|
9
|
+
* Define an auth API object.
|
|
10
|
+
*
|
|
11
|
+
* Connection admin RPCs are exposed by wrapping the `auth.connection.*`
|
|
12
|
+
* facade in your own `authMutation`/`authQuery` functions (authorize with
|
|
13
|
+
* `auth.member.assert`), the same pattern as every other namespace.
|
|
14
|
+
*
|
|
15
|
+
* @param component - The installed auth component reference from
|
|
16
|
+
* `components.auth` in your Convex app definition.
|
|
17
|
+
* @param config - Auth configuration including `providers` and optional
|
|
18
|
+
* `permissions`. All fields from {@link AuthConfig} are accepted
|
|
19
|
+
* except `component` (passed as the first argument).
|
|
20
|
+
* @returns A {@link ConvexAuthResult} — the full auth API surface
|
|
21
|
+
* ({@link AuthApiBase}) plus the `connection` group-admin facade.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* export const auth = defineAuth(components.auth, {
|
|
26
|
+
* providers: [password(), google()],
|
|
27
|
+
* permissions,
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see {@link AuthContextConfig}
|
|
32
|
+
*/
|
|
33
|
+
function defineAuth(component, config) {
|
|
34
|
+
const authResult = Auth({
|
|
35
|
+
...config,
|
|
36
|
+
component,
|
|
37
|
+
providers: [...config.providers]
|
|
38
|
+
});
|
|
39
|
+
const { domain: domainApi, scim: scimApi, connection: connectionApi, audit: auditApi, webhook: webhookApi, oidc: oidcApi, saml: samlApi, ...restConnection } = authResult.auth.connection;
|
|
40
|
+
const setGroupConnectionDomains = async (ctx, args) => {
|
|
41
|
+
const { connectionId } = args;
|
|
42
|
+
const domains = args.domains;
|
|
43
|
+
const connection = await connectionApi.get(ctx, { id: connectionId });
|
|
44
|
+
if (connection === null) throw new ConvexError({
|
|
45
|
+
code: ErrorCode.INVALID_PARAMETERS,
|
|
46
|
+
message: "Connection not found."
|
|
47
|
+
});
|
|
48
|
+
const normalized = domains.map((entry) => ({
|
|
49
|
+
...entry,
|
|
50
|
+
domain: entry.domain.trim().toLowerCase()
|
|
51
|
+
}));
|
|
52
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
53
|
+
for (const entry of normalized) {
|
|
54
|
+
if (entry.domain.length === 0) throw new ConvexError({
|
|
55
|
+
code: ErrorCode.INVALID_PARAMETERS,
|
|
56
|
+
message: "Domain must not be empty."
|
|
57
|
+
});
|
|
58
|
+
if (deduped.has(entry.domain)) throw new ConvexError({
|
|
59
|
+
code: ErrorCode.INVALID_PARAMETERS,
|
|
60
|
+
message: `Duplicate domain: ${entry.domain}`
|
|
61
|
+
});
|
|
62
|
+
deduped.set(entry.domain, entry);
|
|
63
|
+
}
|
|
64
|
+
const nextDomains = [...deduped.values()];
|
|
65
|
+
const primaryCount = nextDomains.filter((entry) => entry.isPrimary).length;
|
|
66
|
+
if (primaryCount > 1) throw new ConvexError({
|
|
67
|
+
code: ErrorCode.INVALID_PARAMETERS,
|
|
68
|
+
message: "Only one primary domain may be set."
|
|
69
|
+
});
|
|
70
|
+
if (nextDomains.length > 0 && primaryCount === 0) nextDomains[0] = {
|
|
71
|
+
...nextDomains[0],
|
|
72
|
+
isPrimary: true
|
|
73
|
+
};
|
|
74
|
+
const currentDomains = await domainApi.list(ctx, { connectionId });
|
|
75
|
+
const currentByDomain = new Map(currentDomains.map((entry) => [entry.domain.toLowerCase(), entry]));
|
|
76
|
+
for (const existing of currentDomains) if (!deduped.has(existing.domain.toLowerCase())) await domainApi.remove(ctx, { id: existing._id });
|
|
77
|
+
for (const nextDomain of nextDomains) {
|
|
78
|
+
const current = currentByDomain.get(nextDomain.domain);
|
|
79
|
+
if (current && current.isPrimary === Boolean(nextDomain.isPrimary)) continue;
|
|
80
|
+
if (current) await domainApi.remove(ctx, { id: current._id });
|
|
81
|
+
const domainId = await domainApi.create(ctx, {
|
|
82
|
+
connectionId: connection._id,
|
|
83
|
+
groupId: connection.groupId,
|
|
84
|
+
domain: nextDomain.domain,
|
|
85
|
+
isPrimary: Boolean(nextDomain.isPrimary)
|
|
86
|
+
});
|
|
87
|
+
if (current?.verifiedAt !== void 0) await ctx.runMutation(component.connection.domain.verify, {
|
|
88
|
+
id: domainId,
|
|
89
|
+
verifiedAt: current.verifiedAt
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
connectionId,
|
|
94
|
+
domains: (await domainApi.list(ctx, { connectionId })).map((domain) => ({
|
|
95
|
+
domainId: domain._id,
|
|
96
|
+
domain: domain.domain,
|
|
97
|
+
isPrimary: Boolean(domain.isPrimary),
|
|
98
|
+
verified: domain.verifiedAt !== void 0,
|
|
99
|
+
verifiedAt: domain.verifiedAt ?? null
|
|
100
|
+
}))
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const publicGroupConnection = {
|
|
104
|
+
...restConnection,
|
|
105
|
+
...connectionApi,
|
|
106
|
+
signIn: oidcApi.signIn,
|
|
107
|
+
metadata: samlApi.metadata,
|
|
108
|
+
oidc: { ...oidcApi },
|
|
109
|
+
saml: { ...samlApi },
|
|
110
|
+
domain: {
|
|
111
|
+
list: domainApi.list,
|
|
112
|
+
validate: domainApi.validate,
|
|
113
|
+
status: domainApi.status,
|
|
114
|
+
upsert: setGroupConnectionDomains,
|
|
115
|
+
verification: {
|
|
116
|
+
request: domainApi.verification.request,
|
|
117
|
+
confirm: domainApi.verification.confirm
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
policy: restConnection.policy,
|
|
121
|
+
audit: { list: auditApi.list },
|
|
122
|
+
webhook: {
|
|
123
|
+
endpoint: webhookApi.endpoint,
|
|
124
|
+
delivery: { list: webhookApi.delivery.list }
|
|
125
|
+
},
|
|
126
|
+
scim: {
|
|
127
|
+
upsert: scimApi.upsert,
|
|
128
|
+
get: scimApi.get,
|
|
129
|
+
status: scimApi.status,
|
|
130
|
+
validate: scimApi.validate
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const groupApi = {
|
|
134
|
+
...authResult.auth.group,
|
|
135
|
+
active: {
|
|
136
|
+
get: authResult.auth.active.get,
|
|
137
|
+
update: authResult.auth.active.update,
|
|
138
|
+
reset: authResult.auth.active.reset
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const accountApi = authResult.auth.accountManagement;
|
|
142
|
+
const oauthApi = {
|
|
143
|
+
authorize: authResult.auth.oauth.authorize,
|
|
144
|
+
client: {
|
|
145
|
+
create: authResult.auth.oauth.client.create,
|
|
146
|
+
get: authResult.auth.oauth.client.get,
|
|
147
|
+
list: authResult.auth.oauth.client.list,
|
|
148
|
+
update: authResult.auth.oauth.client.update,
|
|
149
|
+
revoke: authResult.auth.oauth.client.revoke
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const eventApi = authResult.auth.event;
|
|
153
|
+
return {
|
|
154
|
+
v: createAuthValidators(config.extend ?? {}),
|
|
155
|
+
signIn: authResult.signIn,
|
|
156
|
+
signOut: authResult.signOut,
|
|
157
|
+
store: authResult.store,
|
|
158
|
+
http: authResult.http,
|
|
159
|
+
user: authResult.auth.user,
|
|
160
|
+
session: authResult.auth.session,
|
|
161
|
+
account: accountApi,
|
|
162
|
+
factor: authResult.auth.factor,
|
|
163
|
+
group: groupApi,
|
|
164
|
+
member: authResult.auth.member,
|
|
165
|
+
invite: authResult.auth.invite,
|
|
166
|
+
key: authResult.auth.key,
|
|
167
|
+
provider: authResult.auth.provider,
|
|
168
|
+
oauth: oauthApi,
|
|
169
|
+
event: eventApi,
|
|
170
|
+
request: authResult.auth.request,
|
|
171
|
+
connection: publicGroupConnection,
|
|
172
|
+
...createAuthContextFacade(authResult.auth)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
export { defineAuth };
|
|
178
|
+
//# sourceMappingURL=auth.js.map
|