{"_id":"@dcsv-io/d2-auth-context-abstractions","_rev":"2-ba067ba241902ce60115dc621227010d","name":"@dcsv-io/d2-auth-context-abstractions","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.1":{"name":"@dcsv-io/d2-auth-context-abstractions","version":"0.1.1","_id":"@dcsv-io/d2-auth-context-abstractions@0.1.1","maintainers":[{"name":"dcsv-tristan","email":"tristan@dcsv.io"}],"dist":{"shasum":"c2476532ff7a609bf14341e21f7db904a0dafd45","tarball":"https://registry.npmjs.org/@dcsv-io/d2-auth-context-abstractions/-/d2-auth-context-abstractions-0.1.1.tgz","fileCount":43,"integrity":"sha512-FM/x15EumXXC1ZlJ3bm311puCmSvDti+M1GYJgslkAqzd83MnCx5qlxPSnLMRPzpw5OhKko/NwVoxAG1F31/cg==","signatures":[{"sig":"MEUCIBFIK1VZE3x7TwFJRXpmh9Jas6l1BLNSa1Jjs4rqR2QzAiEAlAE0bSRnFk9qiAQLqGrofnqe8DzfiebGJPNMS6eHqKQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":49727},"main":"./dist/index.js","type":"module","_from":"file:bundle/npm/dcsv-io-d2-auth-context-abstractions-0.1.1.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./enums/*":{"types":"./dist/enums/*.d.ts","import":"./dist/enums/*.js"},"./types/*":{"types":"./dist/types/*.d.ts","import":"./dist/types/*.js"}},"scripts":{"test":"vitest run","build":"tsc -b","prebuild":"node ../../scripts/run-ts-codegen.mjs src/auth-context-emit.ts","type-check:test":"tsc -p tsconfig.test.json"},"_npmUser":{"name":"dcsv-tristan","email":"tristan@dcsv.io"},"_resolved":"/home/runner/work/D2-Public/D2-Public/bundle/npm/dcsv-io-d2-auth-context-abstractions-0.1.1.tgz","_integrity":"sha512-FM/x15EumXXC1ZlJ3bm311puCmSvDti+M1GYJgslkAqzd83MnCx5qlxPSnLMRPzpw5OhKko/NwVoxAG1F31/cg==","_npmVersion":"11.16.0","description":"<!-- Copyright (c) DCSV. Licensed under the Apache License, Version 2.0. -->","directories":{},"_nodeVersion":"24.18.0","_hasShrinkwrap":false,"devDependencies":{"vitest":"4.0.18","typescript":"5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/d2-auth-context-abstractions_0.1.1_1784262805049_0.5571061053717306","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@dcsv-io/d2-auth-context-abstractions","version":"0.1.2","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./enums/*":{"types":"./dist/enums/*.d.ts","import":"./dist/enums/*.js"},"./types/*":{"types":"./dist/types/*.d.ts","import":"./dist/types/*.js"}},"devDependencies":{"typescript":"5.9.3","vitest":"4.0.18"},"scripts":{"prebuild":"node ../../scripts/run-ts-codegen.mjs src/auth-context-emit.ts","build":"tsc -b","test":"vitest run","type-check:test":"tsc -p tsconfig.test.json"},"_id":"@dcsv-io/d2-auth-context-abstractions@0.1.2","description":"<!-- Copyright (c) DCSV. Licensed under the Apache License, Version 2.0. -->","_integrity":"sha512-IBRUp8VXpiyGxivRwT+zF/50Z+OHBy+/vNXhXaiD3quvw1VOiVfFVZePWD3C5LjL760pZR7o1VEBi0VVDb3B9w==","_resolved":"/home/runner/work/D2-Public/D2-Public/bundle/npm/dcsv-io-d2-auth-context-abstractions-0.1.2.tgz","_from":"file:bundle/npm/dcsv-io-d2-auth-context-abstractions-0.1.2.tgz","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-IBRUp8VXpiyGxivRwT+zF/50Z+OHBy+/vNXhXaiD3quvw1VOiVfFVZePWD3C5LjL760pZR7o1VEBi0VVDb3B9w==","shasum":"ef2616861bc22ec21e1428f473fb4a5e1245f55a","tarball":"https://registry.npmjs.org/@dcsv-io/d2-auth-context-abstractions/-/d2-auth-context-abstractions-0.1.2.tgz","fileCount":43,"unpackedSize":49741,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCTasRguWj3ALkI7QAe7XcsZAkR7W4/9b1wnuMgj5iB9AIhALNq7kKCdorBliVPjuHgsmToA5FYAsU8lX9ZGDMrb5wx"}]},"_npmUser":{"name":"dcsv-tristan","email":"tristan@dcsv.io"},"directories":{},"maintainers":[{"name":"dcsv-tristan","email":"tristan@dcsv.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/d2-auth-context-abstractions_0.1.2_1784286787927_0.18130149601067624"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-17T04:33:24.934Z","modified":"2026-07-17T11:13:08.257Z","0.1.1":"2026-07-17T04:33:25.190Z","0.1.2":"2026-07-17T11:13:08.076Z"},"description":"<!-- Copyright (c) DCSV. Licensed under the Apache License, Version 2.0. -->","maintainers":[{"name":"dcsv-tristan","email":"tristan@dcsv.io"}],"readme":"<!--\nCopyright (c) DCSV. Licensed under the Apache License, Version 2.0.\n-->\n\n# @dcsv-io/d2-auth-context-abstractions\n\n`IAuthContext` interface + supporting enums/types. Emitted from\n`contracts/auth-context/IAuthContext.spec.json` (generated sources committed).\nMirrors `DcsvIo.D2.AuthContext.Abstractions` (.NET).\n\n## Install\n\n```bash\npnpm add @dcsv-io/d2-auth-context-abstractions\n```\n\n## Public API\n\nGenerated artifacts (committed to git):\n\n| Export                                                 | Source                                                   |\n| ------------------------------------------------------ | -------------------------------------------------------- |\n| `IAuthContext`                                         | `IAuthContext.g.ts`                                      |\n| `IAuthContextRedactPaths`                              | `IAuthContext.g.ts` (PII paths from spec `redact: true`) |\n| `OrgType` / `Role` / `ImpersonationKind` / `ActorKind` | `enums/*.g.ts`                                           |\n| `ActorEntry`                                           | `types/actor-entry.g.ts`                                 |\n\n## Codegen workflow\n\n`prebuild` runs the `auth-context-emit.ts` script before `tsc -b`, so\n`pnpm -r build` regenerates transparently. Force-regen via:\n\n```bash\npnpm --filter ts-codegen codegen --force\n```\n\n## Dependencies\n\nNone at the package level (interfaces only). The codegen runner\n(codegen tooling when present) is a build-time dependency, not a runtime one.\n\n## Usage example\n\n```ts\nimport type { IAuthContext } from \"@dcsv-io/d2-auth-context-abstractions\";\nimport {\n  OrgType,\n  IAuthContextRedactPaths,\n} from \"@dcsv-io/d2-auth-context-abstractions\";\nimport { setupLogger } from \"@dcsv-io/d2-logging\";\n\nconst log = setupLogger({\n  serviceName: \"edge\",\n  redactPaths: [IAuthContextRedactPaths],\n});\n\nfunction describe(ctx: IAuthContext): string {\n  return `${ctx.userId ?? \"anon\"} on ${ctx.orgId ?? \"no-org\"} (${\n    ctx.orgType ?? OrgType.Customer\n  })`;\n}\n```\n\n## Parity with .NET\n\nMirrors `DcsvIo.D2.AuthContext.Abstractions`:\n\n- `IAuthContext` — same property set, camelCased per TS conventions.\n- `OrgType` / `Role` / `ImpersonationKind` / `ActorKind` — same wire\n values (string-literal unions).\n- `ActorEntry` — same field shape.\n\nThe .NET-side codegen lives in `DcsvIo.D2.Context.SourceGen` (Roslyn\nincremental generator); the TS-side catalogs are committed generated sources.\nBoth consume the same `IAuthContext.spec.json`.\n\n## Nullability convention\n\nSpec-emitted property types use `T | null` rather than the more idiomatic\nTS `T?` / `T | undefined`. This mirrors the .NET side, where\n`Nullable<T>` carries an explicit `null` value; serializing the context\nenvelope across the language boundary preserves the `null` literal so\nboth sides round-trip the same shape. Optional-chaining and nullish-\ncoalescing handle either `null` or `undefined` at consumer call sites,\nso this convention is opaque to most callers — only matters when you're\nconstructing or destructuring an `IAuthContext` literal directly.\n\nNew domain code outside the codegen-emitted surface should use the\ndefault TS convention (`T?` / `T | undefined`) per the wider TS\ncodebase's nullability rule. The spec's `?` suffix on a type entry\n(e.g. `\"string?\"` in `IAuthContext.spec.json`) is what triggers the\n`| null` emission.\n\n## Edge cases\n\n- `IAuthContextRedactPaths` is empty when no spec entry carries\n `redact: true`. Hand-register additional paths via\n `markRedactedFields()` from `@dcsv-io/d2-logging` if needed.\n- Generated files (`*.g.ts`) are committed to git so consumers don't\n pay a generate-on-first-build penalty.\n- `pnpm exec eslint` ignores generated files — formatting drift is\n irrelevant for spec-derived output.\n","readmeFilename":"README.md"}