@kya-os/consent 0.1.9 → 0.1.12

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.
@@ -66,4 +66,71 @@ export const AUTH_MODES = {
66
66
  /** Identity verification (future) - Auth → Consent → Success (3 screens) */
67
67
  IDV: "idv",
68
68
  };
69
+ // =============================================================================
70
+ // AUTH_MODE → CONSENT_PROVIDER_TYPE MAPPING (Single Source of Truth)
71
+ // =============================================================================
72
+ /**
73
+ * Consent Provider Types for delegation metadata
74
+ *
75
+ * These are the values stored in delegation metadata.provider_type
76
+ * and must match AgentShield's tool protection authorization.type values.
77
+ *
78
+ * IMPORTANT: This must stay in sync with @kya-os/contracts/tool-protection CONSENT_PROVIDER_TYPES
79
+ */
80
+ export const PROVIDER_TYPES = {
81
+ /** Consent-only - no authentication, just clickwrap agreement */
82
+ NONE: "none",
83
+ /** Password-based authentication (email/password, username/password) */
84
+ PASSWORD: "password",
85
+ /** OAuth2 provider authentication */
86
+ OAUTH2: "oauth2",
87
+ /** Email magic link authentication */
88
+ MAGIC_LINK: "magic_link",
89
+ /** One-time password (SMS/email code) */
90
+ OTP: "otp",
91
+ };
92
+ /**
93
+ * AUTH_MODE to PROVIDER_TYPE Mapping
94
+ *
95
+ * This is the CANONICAL mapping documented in the module header.
96
+ * It maps UI-level auth modes to API-level provider types.
97
+ *
98
+ * IMPORTANT: This mapping ensures type-safety between:
99
+ * - AUTH_MODES (what UI/flow to render)
100
+ * - PROVIDER_TYPES (what to send to AgentShield for authorization validation)
101
+ *
102
+ * The tool protection layer expects authorization.type to match these values.
103
+ */
104
+ export const AUTH_MODE_TO_PROVIDER_TYPE = {
105
+ [AUTH_MODES.CONSENT_ONLY]: PROVIDER_TYPES.NONE,
106
+ [AUTH_MODES.CREDENTIALS]: PROVIDER_TYPES.PASSWORD, // CRITICAL: 'password', NOT 'credential'
107
+ [AUTH_MODES.OAUTH]: PROVIDER_TYPES.OAUTH2,
108
+ [AUTH_MODES.MAGIC_LINK]: PROVIDER_TYPES.MAGIC_LINK,
109
+ [AUTH_MODES.OTP]: PROVIDER_TYPES.OTP,
110
+ // Future modes - default to NONE until implemented
111
+ [AUTH_MODES.QR_CODE]: PROVIDER_TYPES.NONE,
112
+ [AUTH_MODES.PASSKEY]: PROVIDER_TYPES.NONE,
113
+ [AUTH_MODES.IDV]: PROVIDER_TYPES.NONE,
114
+ };
115
+ /**
116
+ * Get the provider_type for a given auth mode
117
+ *
118
+ * This is the type-safe way to convert between UI auth modes
119
+ * and API provider types. Use this instead of hardcoding strings.
120
+ *
121
+ * @param mode - The auth mode (from AUTH_MODES)
122
+ * @returns The corresponding provider type for delegation metadata
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * import { AUTH_MODES, getProviderTypeForAuthMode } from '@kya-os/consent';
127
+ *
128
+ * const mode = AUTH_MODES.CREDENTIALS;
129
+ * const providerType = getProviderTypeForAuthMode(mode);
130
+ * // providerType === 'password' (NOT 'credential'!)
131
+ * ```
132
+ */
133
+ export function getProviderTypeForAuthMode(mode) {
134
+ return AUTH_MODE_TO_PROVIDER_TYPE[mode] ?? PROVIDER_TYPES.NONE;
135
+ }
69
136
  //# sourceMappingURL=modes.types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modes.types.js","sourceRoot":"","sources":["../../src/types/modes.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,4EAA4E;IAC5E,YAAY,EAAE,cAAc;IAE5B,8EAA8E;IAC9E,WAAW,EAAE,aAAa;IAE1B,2EAA2E;IAC3E,KAAK,EAAE,OAAO;IAEd,6EAA6E;IAC7E,UAAU,EAAE,YAAY;IAExB,yFAAyF;IACzF,GAAG,EAAE,KAAK;IAEV,sFAAsF;IACtF,OAAO,EAAE,SAAS;IAElB,sFAAsF;IACtF,OAAO,EAAE,SAAS;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AAE,cAAc,CAAC,GAAG;IACpC,mDAAmD;IACnD,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,IAAI;IACzC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,IAAI;IACzC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,IAAI;CACtC,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,0BAA0B,CAAC,IAAc;IACvD,OAAO,0BAA0B,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC;AACjE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kya-os/consent",
3
- "version": "0.1.9",
3
+ "version": "0.1.12",
4
4
  "description": "Canonical consent page types, styles, and utilities for MCP-I and AgentShield",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",