{"version":3,"file":"identity-import.mjs","names":[],"sources":["../../../src/internal/oauth/identity-import.ts"],"sourcesContent":["import {\n  OAuthCredentialSnapshot,\n  OAuthExternalIdentity,\n  OAuthModuleId,\n  type OAuthUnavailable,\n} from \"@yielded/auth/OAuth\";\nimport * as Context from \"effect/Context\";\nimport type * as Effect from \"effect/Effect\";\nimport * as Schema from \"effect/Schema\";\n\n/** Use the exact provider key, issuer and durable subject emitted by the configured adapter. */\nexport const IdentityImport = Schema.Struct({\n  moduleId: OAuthModuleId,\n  subjectId: OAuthCredentialSnapshot.fields.revision.fields.subjectId,\n  ...OAuthExternalIdentity.fields,\n});\n\nexport type IdentityImport = typeof IdentityImport.Type;\n\nexport const ImportedIdentity = Schema.Struct({\n  credentialId: OAuthCredentialSnapshot.fields.credentialId,\n  credentialRevision: OAuthCredentialSnapshot.fields.credentialRevision,\n});\n\nexport type ImportedIdentity = typeof ImportedIdentity.Type;\n\n/** Trusted migration authority, supplied by composed persistence for OAuth sign-in.\n * Import only ownership established by the previous provider, never an email match\n * or unverified request. The subject must already exist and be active.\n *\n * Atomically creates ownership, login and shared authority and advances subject\n * securityRevision. An exact active import is idempotent and keeps its IDs and\n * revisions; another owner/module or inconsistent/inactive rows fail closed with\n * OAuthUnavailable. No provider grant, session or account is issued. A lost commit\n * acknowledgement can be retried with the same input. Each call owns its commit;\n * ambient transactions and commit scopes are rejected.\n */\nexport class IdentityImports extends Context.Service<\n  IdentityImports,\n  {\n    readonly importIdentity: (\n      input: IdentityImport,\n    ) => Effect.Effect<ImportedIdentity, OAuthUnavailable>;\n  }\n>()(\"@yielded/auth-persistence/OAuthIdentityImports\") {}\n"],"mappings":";;;;;AAWA,MAAa,iBAAiB,OAAO,OAAO;CAC1C,UAAU;CACV,WAAW,wBAAwB,OAAO,SAAS,OAAO;CAC1D,GAAG,sBAAsB;AAC3B,CAAC;AAID,MAAa,mBAAmB,OAAO,OAAO;CAC5C,cAAc,wBAAwB,OAAO;CAC7C,oBAAoB,wBAAwB,OAAO;AACrD,CAAC;;;;;;;;;;;;AAeD,IAAa,kBAAb,cAAqC,QAAQ,QAO3C,CAAC,CAAC,gDAAgD,CAAC,CAAC,CAAC"}