@kya-os/consent 0.1.50 → 0.2.1
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 +72 -9
- package/dist/bundle/browser.d.ts +18 -0
- package/dist/bundle/browser.d.ts.map +1 -0
- package/dist/bundle/browser.js +18 -0
- package/dist/bundle/browser.js.map +1 -0
- package/dist/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +4 -4
- package/dist/bundle/inline.js.map +1 -1
- package/dist/bundle/shell.d.ts +2 -0
- package/dist/bundle/shell.d.ts.map +1 -1
- package/dist/bundle/shell.js +16 -43
- package/dist/bundle/shell.js.map +1 -1
- package/dist/cjs/bundle/inline.js +4 -4
- package/dist/cjs/bundle/inline.js.map +1 -1
- package/dist/cjs/bundle/shell.js +16 -43
- package/dist/cjs/bundle/shell.js.map +1 -1
- package/dist/cjs/components/consent-agent-header.js +73 -16
- package/dist/cjs/components/consent-agent-header.js.map +1 -1
- package/dist/cjs/components/consent-button.js +15 -12
- package/dist/cjs/components/consent-button.js.map +1 -1
- package/dist/cjs/components/consent-capabilities-screen.js +11 -5
- package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
- package/dist/cjs/components/consent-checkbox.js +19 -15
- package/dist/cjs/components/consent-checkbox.js.map +1 -1
- package/dist/cjs/components/consent-footer.js +9 -4
- package/dist/cjs/components/consent-footer.js.map +1 -1
- package/dist/cjs/components/consent-permissions.js +16 -15
- package/dist/cjs/components/consent-permissions.js.map +1 -1
- package/dist/cjs/components/consent-shell.js +34 -16
- package/dist/cjs/components/consent-shell.js.map +1 -1
- package/dist/cjs/components/consent-terms.js +29 -23
- package/dist/cjs/components/consent-terms.js.map +1 -1
- package/dist/cjs/components/mcp-consent.js +221 -44
- package/dist/cjs/components/mcp-consent.js.map +1 -1
- package/dist/cjs/constants/auth-modes.js +1 -1
- package/dist/cjs/constants/auth-modes.js.map +1 -1
- package/dist/cjs/constants/colors.js +5 -0
- package/dist/cjs/constants/colors.js.map +1 -1
- package/dist/cjs/copy/tokens.js +39 -0
- package/dist/cjs/copy/tokens.js.map +1 -1
- package/dist/cjs/mcp-app/inline.js +2 -2
- package/dist/cjs/mcp-app/inline.js.map +1 -1
- package/dist/cjs/resolution/resolve-branding.js +26 -1
- package/dist/cjs/resolution/resolve-branding.js.map +1 -1
- package/dist/cjs/schemas/branding.schemas.js +3 -0
- package/dist/cjs/schemas/branding.schemas.js.map +1 -1
- package/dist/cjs/schemas/capabilities.schemas.js +48 -3
- package/dist/cjs/schemas/capabilities.schemas.js.map +1 -1
- package/dist/cjs/schemas/modes.schemas.js +1 -0
- package/dist/cjs/schemas/modes.schemas.js.map +1 -1
- package/dist/cjs/styles/contrast.js +100 -0
- package/dist/cjs/styles/contrast.js.map +1 -0
- package/dist/cjs/styles/css-variables.js +36 -1
- package/dist/cjs/styles/css-variables.js.map +1 -1
- package/dist/cjs/styles/index.js +1 -0
- package/dist/cjs/styles/index.js.map +1 -1
- package/dist/cjs/styles/stylesheet.js +10 -5
- package/dist/cjs/styles/stylesheet.js.map +1 -1
- package/dist/cjs/templates/index.js +1 -0
- package/dist/cjs/templates/index.js.map +1 -1
- package/dist/cjs/templates/modes/credentials.template.js +9 -7
- package/dist/cjs/templates/modes/credentials.template.js.map +1 -1
- package/dist/cjs/templates/modes/index.js +3 -1
- package/dist/cjs/templates/modes/index.js.map +1 -1
- package/dist/cjs/templates/modes/passkey.template.js +178 -0
- package/dist/cjs/templates/modes/passkey.template.js.map +1 -0
- package/dist/cjs/templates/modes/success.template.js +2 -7
- package/dist/cjs/templates/modes/success.template.js.map +1 -1
- package/dist/cjs/templates/registry.js +1 -0
- package/dist/cjs/templates/registry.js.map +1 -1
- package/dist/cjs/types/capabilities.types.js +27 -2
- package/dist/cjs/types/capabilities.types.js.map +1 -1
- package/dist/cjs/types/modes.types.js +8 -1
- package/dist/cjs/types/modes.types.js.map +1 -1
- package/dist/components/consent-agent-header.d.ts +16 -3
- package/dist/components/consent-agent-header.d.ts.map +1 -1
- package/dist/components/consent-agent-header.js +73 -16
- package/dist/components/consent-agent-header.js.map +1 -1
- package/dist/components/consent-button.d.ts +5 -4
- package/dist/components/consent-button.d.ts.map +1 -1
- package/dist/components/consent-button.js +17 -14
- package/dist/components/consent-button.js.map +1 -1
- package/dist/components/consent-capabilities-screen.d.ts +1 -1
- package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
- package/dist/components/consent-capabilities-screen.js +11 -5
- package/dist/components/consent-capabilities-screen.js.map +1 -1
- package/dist/components/consent-checkbox.d.ts +4 -2
- package/dist/components/consent-checkbox.d.ts.map +1 -1
- package/dist/components/consent-checkbox.js +21 -17
- package/dist/components/consent-checkbox.js.map +1 -1
- package/dist/components/consent-footer.d.ts.map +1 -1
- package/dist/components/consent-footer.js +9 -4
- package/dist/components/consent-footer.js.map +1 -1
- package/dist/components/consent-passkey.d.ts +128 -0
- package/dist/components/consent-passkey.d.ts.map +1 -0
- package/dist/components/consent-passkey.js +408 -0
- package/dist/components/consent-passkey.js.map +1 -0
- package/dist/components/consent-permissions.d.ts +4 -3
- package/dist/components/consent-permissions.d.ts.map +1 -1
- package/dist/components/consent-permissions.js +18 -17
- package/dist/components/consent-permissions.js.map +1 -1
- package/dist/components/consent-shell.d.ts +2 -2
- package/dist/components/consent-shell.d.ts.map +1 -1
- package/dist/components/consent-shell.js +36 -18
- package/dist/components/consent-shell.js.map +1 -1
- package/dist/components/consent-terms.d.ts +4 -2
- package/dist/components/consent-terms.d.ts.map +1 -1
- package/dist/components/consent-terms.js +31 -25
- package/dist/components/consent-terms.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +9 -1
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +221 -44
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/consent.js +1143 -220
- package/dist/consent.min.js +462 -221
- package/dist/constants/auth-modes.js +1 -1
- package/dist/constants/auth-modes.js.map +1 -1
- package/dist/constants/colors.d.ts +5 -0
- package/dist/constants/colors.d.ts.map +1 -1
- package/dist/constants/colors.js +5 -0
- package/dist/constants/colors.js.map +1 -1
- package/dist/copy/tokens.d.ts +39 -0
- package/dist/copy/tokens.d.ts.map +1 -1
- package/dist/copy/tokens.js +39 -0
- package/dist/copy/tokens.js.map +1 -1
- package/dist/mcp-app/inline.d.ts.map +1 -1
- package/dist/mcp-app/inline.js +2 -2
- package/dist/mcp-app/inline.js.map +1 -1
- package/dist/passkey/index.d.ts +19 -0
- package/dist/passkey/index.d.ts.map +1 -0
- package/dist/passkey/index.js +18 -0
- package/dist/passkey/index.js.map +1 -0
- package/dist/passkey/react.d.ts +34 -0
- package/dist/passkey/react.d.ts.map +1 -0
- package/dist/passkey/react.js +39 -0
- package/dist/passkey/react.js.map +1 -0
- package/dist/resolution/resolve-branding.d.ts +11 -0
- package/dist/resolution/resolve-branding.d.ts.map +1 -1
- package/dist/resolution/resolve-branding.js +25 -1
- package/dist/resolution/resolve-branding.js.map +1 -1
- package/dist/schemas/api.schemas.d.ts +49 -8
- package/dist/schemas/api.schemas.d.ts.map +1 -1
- package/dist/schemas/branding.schemas.d.ts +24 -0
- package/dist/schemas/branding.schemas.d.ts.map +1 -1
- package/dist/schemas/branding.schemas.js +3 -0
- package/dist/schemas/branding.schemas.js.map +1 -1
- package/dist/schemas/capabilities.schemas.d.ts +38 -4
- package/dist/schemas/capabilities.schemas.d.ts.map +1 -1
- package/dist/schemas/capabilities.schemas.js +47 -2
- package/dist/schemas/capabilities.schemas.js.map +1 -1
- package/dist/schemas/config.schemas.d.ts +82 -12
- package/dist/schemas/config.schemas.d.ts.map +1 -1
- package/dist/schemas/modes.schemas.d.ts +8 -0
- package/dist/schemas/modes.schemas.d.ts.map +1 -1
- package/dist/schemas/modes.schemas.js +1 -0
- package/dist/schemas/modes.schemas.js.map +1 -1
- package/dist/styles/contrast.d.ts +33 -0
- package/dist/styles/contrast.d.ts.map +1 -0
- package/dist/styles/contrast.js +92 -0
- package/dist/styles/contrast.js.map +1 -0
- package/dist/styles/css-variables.d.ts +20 -0
- package/dist/styles/css-variables.d.ts.map +1 -1
- package/dist/styles/css-variables.js +35 -1
- package/dist/styles/css-variables.js.map +1 -1
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.d.ts.map +1 -1
- package/dist/styles/index.js +1 -0
- package/dist/styles/index.js.map +1 -1
- package/dist/styles/stylesheet.d.ts +1 -1
- package/dist/styles/stylesheet.d.ts.map +1 -1
- package/dist/styles/stylesheet.js +10 -5
- package/dist/styles/stylesheet.js.map +1 -1
- package/dist/templates/index.d.ts +1 -0
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +1 -0
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/modes/credentials.template.d.ts.map +1 -1
- package/dist/templates/modes/credentials.template.js +9 -7
- package/dist/templates/modes/credentials.template.js.map +1 -1
- package/dist/templates/modes/index.d.ts +1 -0
- package/dist/templates/modes/index.d.ts.map +1 -1
- package/dist/templates/modes/index.js +1 -0
- package/dist/templates/modes/index.js.map +1 -1
- package/dist/templates/modes/passkey.template.d.ts +62 -0
- package/dist/templates/modes/passkey.template.d.ts.map +1 -0
- package/dist/templates/modes/passkey.template.js +174 -0
- package/dist/templates/modes/passkey.template.js.map +1 -0
- package/dist/templates/modes/success.template.d.ts.map +1 -1
- package/dist/templates/modes/success.template.js +2 -7
- package/dist/templates/modes/success.template.js.map +1 -1
- package/dist/templates/registry.d.ts.map +1 -1
- package/dist/templates/registry.js +3 -2
- package/dist/templates/registry.js.map +1 -1
- package/dist/types/branding.types.d.ts +6 -0
- package/dist/types/branding.types.d.ts.map +1 -1
- package/dist/types/capabilities.types.d.ts +44 -7
- package/dist/types/capabilities.types.d.ts.map +1 -1
- package/dist/types/capabilities.types.js +26 -2
- package/dist/types/capabilities.types.js.map +1 -1
- package/dist/types/modes.types.d.ts +28 -1
- package/dist/types/modes.types.d.ts.map +1 -1
- package/dist/types/modes.types.js +7 -0
- package/dist/types/modes.types.js.map +1 -1
- package/dist/types/page.types.d.ts +7 -1
- package/dist/types/page.types.d.ts.map +1 -1
- package/package.json +26 -3
package/dist/consent.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
4
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
5
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
6
|
for (var i6 = decorators.length - 1, decorator; i6 >= 0; i6--)
|
|
@@ -8,6 +9,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
8
9
|
if (kind && result) __defProp(target, key, result);
|
|
9
10
|
return result;
|
|
10
11
|
};
|
|
12
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
13
|
|
|
12
14
|
// ../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.js
|
|
13
15
|
var t = globalThis;
|
|
@@ -670,7 +672,9 @@ ConsentButton.styles = i`
|
|
|
670
672
|
font-weight: 500;
|
|
671
673
|
font-family: inherit;
|
|
672
674
|
cursor: pointer;
|
|
673
|
-
transition:
|
|
675
|
+
transition:
|
|
676
|
+
opacity 0.15s ease,
|
|
677
|
+
background-color 0.15s ease;
|
|
674
678
|
border: none;
|
|
675
679
|
width: 100%;
|
|
676
680
|
display: inline-flex;
|
|
@@ -680,23 +684,23 @@ ConsentButton.styles = i`
|
|
|
680
684
|
}
|
|
681
685
|
|
|
682
686
|
/* Primary variant */
|
|
683
|
-
:host([variant=
|
|
687
|
+
:host([variant="primary"]) button {
|
|
684
688
|
background-color: var(--consent-primary, #2563eb);
|
|
685
|
-
color: white;
|
|
689
|
+
color: var(--consent-on-primary, white);
|
|
686
690
|
}
|
|
687
691
|
|
|
688
|
-
:host([variant=
|
|
692
|
+
:host([variant="primary"]) button:hover:not(:disabled) {
|
|
689
693
|
opacity: 0.9;
|
|
690
694
|
}
|
|
691
695
|
|
|
692
696
|
/* Secondary variant */
|
|
693
|
-
:host([variant=
|
|
697
|
+
:host([variant="secondary"]) button {
|
|
694
698
|
background-color: transparent;
|
|
695
699
|
color: #374151;
|
|
696
700
|
border: 1px solid #d1d5db;
|
|
697
701
|
}
|
|
698
702
|
|
|
699
|
-
:host([variant=
|
|
703
|
+
:host([variant="secondary"]) button:hover:not(:disabled) {
|
|
700
704
|
background-color: #f9fafb;
|
|
701
705
|
}
|
|
702
706
|
|
|
@@ -820,7 +824,7 @@ ConsentCheckbox.styles = i`
|
|
|
820
824
|
}
|
|
821
825
|
|
|
822
826
|
/* Custom checkbox styling - matches Checkpoint exactly */
|
|
823
|
-
input[type=
|
|
827
|
+
input[type="checkbox"] {
|
|
824
828
|
/* Reset */
|
|
825
829
|
appearance: none;
|
|
826
830
|
-webkit-appearance: none;
|
|
@@ -842,39 +846,41 @@ ConsentCheckbox.styles = i`
|
|
|
842
846
|
/* Interaction */
|
|
843
847
|
cursor: pointer;
|
|
844
848
|
position: relative;
|
|
845
|
-
transition:
|
|
849
|
+
transition:
|
|
850
|
+
background-color 0.15s ease,
|
|
851
|
+
border-color 0.15s ease;
|
|
846
852
|
}
|
|
847
853
|
|
|
848
|
-
input[type=
|
|
854
|
+
input[type="checkbox"]:hover:not(:disabled) {
|
|
849
855
|
border-color: var(--consent-primary, #2563eb);
|
|
850
856
|
}
|
|
851
857
|
|
|
852
|
-
input[type=
|
|
858
|
+
input[type="checkbox"]:focus-visible {
|
|
853
859
|
outline: 2px solid var(--consent-primary, #2563eb);
|
|
854
860
|
outline-offset: 2px;
|
|
855
861
|
}
|
|
856
862
|
|
|
857
863
|
/* Checked state */
|
|
858
|
-
input[type=
|
|
864
|
+
input[type="checkbox"]:checked {
|
|
859
865
|
background-color: var(--consent-primary, #2563eb);
|
|
860
866
|
border-color: var(--consent-primary, #2563eb);
|
|
861
867
|
}
|
|
862
868
|
|
|
863
869
|
/* Checkmark */
|
|
864
|
-
input[type=
|
|
865
|
-
content:
|
|
870
|
+
input[type="checkbox"]:checked::after {
|
|
871
|
+
content: "";
|
|
866
872
|
position: absolute;
|
|
867
873
|
left: 4px;
|
|
868
874
|
top: 1px;
|
|
869
875
|
width: 5px;
|
|
870
876
|
height: 9px;
|
|
871
|
-
border: solid white;
|
|
877
|
+
border: solid var(--consent-on-primary, white);
|
|
872
878
|
border-width: 0 2px 2px 0;
|
|
873
879
|
transform: rotate(45deg);
|
|
874
880
|
}
|
|
875
881
|
|
|
876
882
|
/* Disabled */
|
|
877
|
-
input[type=
|
|
883
|
+
input[type="checkbox"]:disabled {
|
|
878
884
|
cursor: not-allowed;
|
|
879
885
|
opacity: 0.5;
|
|
880
886
|
}
|
|
@@ -886,7 +892,7 @@ ConsentCheckbox.styles = i`
|
|
|
886
892
|
|
|
887
893
|
/* Links in label */
|
|
888
894
|
::slotted(a) {
|
|
889
|
-
color: var(--consent-primary, #2563eb);
|
|
895
|
+
color: var(--consent-link, var(--consent-primary, #2563eb));
|
|
890
896
|
text-decoration: underline;
|
|
891
897
|
}
|
|
892
898
|
|
|
@@ -1181,7 +1187,130 @@ ConsentInput = __decorateClass([
|
|
|
1181
1187
|
t3("consent-input")
|
|
1182
1188
|
], ConsentInput);
|
|
1183
1189
|
|
|
1190
|
+
// src/constants/colors.ts
|
|
1191
|
+
var DEFAULT_COLORS = {
|
|
1192
|
+
/** Primary brand color - Tailwind blue-600 */
|
|
1193
|
+
PRIMARY: "#2563EB",
|
|
1194
|
+
/** Secondary/accent color - Tailwind blue-100 */
|
|
1195
|
+
SECONDARY: "#DBEAFE",
|
|
1196
|
+
/**
|
|
1197
|
+
* Text on a secondary fill (the scope badges), kept wherever it reaches
|
|
1198
|
+
* WCAG AA on the brand's secondary color.
|
|
1199
|
+
*/
|
|
1200
|
+
ON_SECONDARY: "#0E2249",
|
|
1201
|
+
/** Background color */
|
|
1202
|
+
BACKGROUND: "#F9FAFB",
|
|
1203
|
+
/** Text colors */
|
|
1204
|
+
TEXT_PRIMARY: "#111827",
|
|
1205
|
+
TEXT_SECONDARY: "#6B7280",
|
|
1206
|
+
TEXT_MUTED: "#9CA3AF",
|
|
1207
|
+
/** Border colors */
|
|
1208
|
+
BORDER: "#E5E7EB",
|
|
1209
|
+
BORDER_DARK: "#D1D5DB",
|
|
1210
|
+
/** Success color - Tailwind green-600 */
|
|
1211
|
+
SUCCESS: "#16A34A",
|
|
1212
|
+
/** Error color - Tailwind red-600 */
|
|
1213
|
+
ERROR: "#DC2626",
|
|
1214
|
+
/** Warning color - Tailwind amber-500 */
|
|
1215
|
+
WARNING: "#F59E0B"
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1218
|
+
// src/styles/contrast.ts
|
|
1219
|
+
var AA_TEXT_CONTRAST = 4.5;
|
|
1220
|
+
var WHITE = "#FFFFFF";
|
|
1221
|
+
var BLACK = "#000000";
|
|
1222
|
+
var HEX_COLOR = /^#[0-9A-Fa-f]{6}$/;
|
|
1223
|
+
function isHexColor(value) {
|
|
1224
|
+
return typeof value === "string" && HEX_COLOR.test(value);
|
|
1225
|
+
}
|
|
1226
|
+
function channels(hex) {
|
|
1227
|
+
if (!isHexColor(hex)) {
|
|
1228
|
+
throw new RangeError(
|
|
1229
|
+
`Expected a #rrggbb color, got ${JSON.stringify(hex)}`
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
return [1, 3, 5].map((at) => parseInt(hex.slice(at, at + 2), 16));
|
|
1233
|
+
}
|
|
1234
|
+
function toHex(rgb) {
|
|
1235
|
+
return `#${rgb.map((c4) => c4.toString(16).padStart(2, "0")).join("")}`.toUpperCase();
|
|
1236
|
+
}
|
|
1237
|
+
function linear(value) {
|
|
1238
|
+
const c4 = value / 255;
|
|
1239
|
+
return c4 <= 0.03928 ? c4 / 12.92 : ((c4 + 0.055) / 1.055) ** 2.4;
|
|
1240
|
+
}
|
|
1241
|
+
function relativeLuminance(hex) {
|
|
1242
|
+
const [r7, g2, b3] = channels(hex);
|
|
1243
|
+
return 0.2126 * linear(r7) + 0.7152 * linear(g2) + 0.0722 * linear(b3);
|
|
1244
|
+
}
|
|
1245
|
+
function contrastRatio(a3, b3) {
|
|
1246
|
+
const la = relativeLuminance(a3);
|
|
1247
|
+
const lb = relativeLuminance(b3);
|
|
1248
|
+
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
|
|
1249
|
+
}
|
|
1250
|
+
function readableTextOn(background, preferred) {
|
|
1251
|
+
if (preferred !== void 0 && contrastRatio(preferred, background) >= AA_TEXT_CONTRAST) {
|
|
1252
|
+
return preferred;
|
|
1253
|
+
}
|
|
1254
|
+
return contrastRatio(BLACK, background) >= contrastRatio(WHITE, background) ? BLACK : WHITE;
|
|
1255
|
+
}
|
|
1256
|
+
function readableTextColor(color, surface = WHITE) {
|
|
1257
|
+
if (contrastRatio(color, surface) >= AA_TEXT_CONTRAST) return color;
|
|
1258
|
+
const [r7, g2, b3] = channels(color);
|
|
1259
|
+
const [tr, tg, tb] = channels(readableTextOn(surface));
|
|
1260
|
+
const toward = (c4, target, amount) => {
|
|
1261
|
+
const exact = c4 + (target - c4) * amount;
|
|
1262
|
+
return target > c4 ? Math.ceil(exact) : Math.floor(exact);
|
|
1263
|
+
};
|
|
1264
|
+
const mix = (amount) => toHex([
|
|
1265
|
+
toward(r7, tr, amount),
|
|
1266
|
+
toward(g2, tg, amount),
|
|
1267
|
+
toward(b3, tb, amount)
|
|
1268
|
+
]);
|
|
1269
|
+
let low = 0;
|
|
1270
|
+
let high = 1;
|
|
1271
|
+
for (let step = 0; step < 16; step++) {
|
|
1272
|
+
const middle = (low + high) / 2;
|
|
1273
|
+
if (contrastRatio(mix(middle), surface) >= AA_TEXT_CONTRAST) high = middle;
|
|
1274
|
+
else low = middle;
|
|
1275
|
+
}
|
|
1276
|
+
return mix(high);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
// src/styles/css-variables.ts
|
|
1280
|
+
var CSS_VAR_NAMES = {
|
|
1281
|
+
PRIMARY: "--consent-primary",
|
|
1282
|
+
SECONDARY: "--consent-secondary",
|
|
1283
|
+
PRIMARY_RGB: "--consent-primary-rgb",
|
|
1284
|
+
SECONDARY_RGB: "--consent-secondary-rgb",
|
|
1285
|
+
ON_PRIMARY: "--consent-on-primary",
|
|
1286
|
+
ON_SECONDARY: "--consent-on-secondary",
|
|
1287
|
+
LINK: "--consent-link",
|
|
1288
|
+
BACKGROUND: "--consent-background",
|
|
1289
|
+
TEXT_PRIMARY: "--consent-text-primary",
|
|
1290
|
+
TEXT_SECONDARY: "--consent-text-secondary",
|
|
1291
|
+
BORDER: "--consent-border"
|
|
1292
|
+
};
|
|
1293
|
+
function generateContrastCSSVariables(primary, secondary) {
|
|
1294
|
+
return {
|
|
1295
|
+
...isHexColor(primary) && {
|
|
1296
|
+
"--consent-on-primary": readableTextOn(primary),
|
|
1297
|
+
"--consent-link": readableTextColor(primary)
|
|
1298
|
+
},
|
|
1299
|
+
...isHexColor(secondary) && {
|
|
1300
|
+
"--consent-on-secondary": readableTextOn(
|
|
1301
|
+
secondary,
|
|
1302
|
+
DEFAULT_COLORS.ON_SECONDARY
|
|
1303
|
+
)
|
|
1304
|
+
}
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1184
1308
|
// src/components/consent-shell.ts
|
|
1309
|
+
var CONTRAST_VARS = [
|
|
1310
|
+
CSS_VAR_NAMES.ON_PRIMARY,
|
|
1311
|
+
CSS_VAR_NAMES.ON_SECONDARY,
|
|
1312
|
+
CSS_VAR_NAMES.LINK
|
|
1313
|
+
];
|
|
1185
1314
|
var ConsentShell = class extends i4 {
|
|
1186
1315
|
constructor() {
|
|
1187
1316
|
super(...arguments);
|
|
@@ -1224,6 +1353,15 @@ var ConsentShell = class extends i4 {
|
|
|
1224
1353
|
if (changedProperties.has("primaryColor") || changedProperties.has("secondaryColor")) {
|
|
1225
1354
|
this.style.setProperty("--consent-primary", this.primaryColor);
|
|
1226
1355
|
this.style.setProperty("--consent-secondary", this.secondaryColor);
|
|
1356
|
+
const derived = generateContrastCSSVariables(
|
|
1357
|
+
this.primaryColor,
|
|
1358
|
+
this.secondaryColor
|
|
1359
|
+
);
|
|
1360
|
+
for (const name of CONTRAST_VARS) {
|
|
1361
|
+
const value = derived[name];
|
|
1362
|
+
if (value) this.style.setProperty(name, value);
|
|
1363
|
+
else this.style.removeProperty(name);
|
|
1364
|
+
}
|
|
1227
1365
|
}
|
|
1228
1366
|
}
|
|
1229
1367
|
render() {
|
|
@@ -1250,8 +1388,9 @@ ConsentShell.styles = i`
|
|
|
1250
1388
|
:host {
|
|
1251
1389
|
display: block;
|
|
1252
1390
|
/* System font stack with font smoothing for crisp text */
|
|
1253
|
-
font-family:
|
|
1254
|
-
|
|
1391
|
+
font-family:
|
|
1392
|
+
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
|
|
1393
|
+
Arial, sans-serif;
|
|
1255
1394
|
-webkit-font-smoothing: antialiased;
|
|
1256
1395
|
-moz-osx-font-smoothing: grayscale;
|
|
1257
1396
|
/* Allow customization via CSS variables */
|
|
@@ -1577,7 +1716,7 @@ ConsentPermissions.styles = i`
|
|
|
1577
1716
|
.icon-check svg {
|
|
1578
1717
|
width: 0.75rem;
|
|
1579
1718
|
height: 0.75rem;
|
|
1580
|
-
color: white;
|
|
1719
|
+
color: var(--consent-on-primary, white);
|
|
1581
1720
|
}
|
|
1582
1721
|
|
|
1583
1722
|
.icon-bullet {
|
|
@@ -1645,13 +1784,13 @@ ConsentPermissions.styles = i`
|
|
|
1645
1784
|
}
|
|
1646
1785
|
|
|
1647
1786
|
.checkbox:checked::after {
|
|
1648
|
-
content:
|
|
1787
|
+
content: "";
|
|
1649
1788
|
position: absolute;
|
|
1650
1789
|
left: 4px;
|
|
1651
1790
|
top: 1px;
|
|
1652
1791
|
width: 5px;
|
|
1653
1792
|
height: 9px;
|
|
1654
|
-
border: solid white;
|
|
1793
|
+
border: solid var(--consent-on-primary, white);
|
|
1655
1794
|
border-width: 0 2px 2px 0;
|
|
1656
1795
|
transform: rotate(45deg);
|
|
1657
1796
|
}
|
|
@@ -1683,7 +1822,10 @@ __decorateClass([
|
|
|
1683
1822
|
try {
|
|
1684
1823
|
const parsed = JSON.parse(value);
|
|
1685
1824
|
if (!Array.isArray(parsed)) {
|
|
1686
|
-
console.warn(
|
|
1825
|
+
console.warn(
|
|
1826
|
+
"[consent-permissions] Expected array, got:",
|
|
1827
|
+
typeof parsed
|
|
1828
|
+
);
|
|
1687
1829
|
return [];
|
|
1688
1830
|
}
|
|
1689
1831
|
return parsed;
|
|
@@ -1713,6 +1855,116 @@ ConsentPermissions = __decorateClass([
|
|
|
1713
1855
|
t3("consent-permissions")
|
|
1714
1856
|
], ConsentPermissions);
|
|
1715
1857
|
|
|
1858
|
+
// src/constants/defaults.ts
|
|
1859
|
+
var DEFAULT_BRANDING = {
|
|
1860
|
+
primaryColor: DEFAULT_COLORS.PRIMARY,
|
|
1861
|
+
secondaryColor: DEFAULT_COLORS.SECONDARY,
|
|
1862
|
+
logoUrl: void 0,
|
|
1863
|
+
companyName: void 0
|
|
1864
|
+
};
|
|
1865
|
+
var DEFAULT_UI = {
|
|
1866
|
+
title: "Permission request",
|
|
1867
|
+
description: "It looks like you would like to use [AI Agent] to access resources on your behalf.",
|
|
1868
|
+
expirationText: "This delegation will expire in",
|
|
1869
|
+
cancelButtonText: "Cancel",
|
|
1870
|
+
submitButtonText: "Allow access",
|
|
1871
|
+
permissionsHeader: "The agent is requesting the following permissions:",
|
|
1872
|
+
autoClose: false,
|
|
1873
|
+
popupEnabled: false,
|
|
1874
|
+
theme: "auto"
|
|
1875
|
+
};
|
|
1876
|
+
var DEFAULT_TERMS = {
|
|
1877
|
+
text: "Terms and Conditions",
|
|
1878
|
+
url: void 0,
|
|
1879
|
+
version: void 0,
|
|
1880
|
+
required: true
|
|
1881
|
+
};
|
|
1882
|
+
var DEFAULT_SUCCESS = {
|
|
1883
|
+
title: "Access Granted",
|
|
1884
|
+
description: "The agent now has permission to act on your behalf.",
|
|
1885
|
+
showCredential: true,
|
|
1886
|
+
redirectUrl: void 0,
|
|
1887
|
+
redirectDelay: void 0,
|
|
1888
|
+
continueButtonText: "Close"
|
|
1889
|
+
};
|
|
1890
|
+
var DEFAULT_EXPIRATION_DAYS = 30;
|
|
1891
|
+
|
|
1892
|
+
// src/resolution/resolve-branding.ts
|
|
1893
|
+
function isValidHexColor(color) {
|
|
1894
|
+
if (!color) return false;
|
|
1895
|
+
return /^#[0-9A-Fa-f]{6}$/.test(color);
|
|
1896
|
+
}
|
|
1897
|
+
function sanitizeColor(color, defaultColor) {
|
|
1898
|
+
if (isValidHexColor(color)) {
|
|
1899
|
+
return color;
|
|
1900
|
+
}
|
|
1901
|
+
return defaultColor;
|
|
1902
|
+
}
|
|
1903
|
+
function isValidUrl(url) {
|
|
1904
|
+
if (!url) return false;
|
|
1905
|
+
try {
|
|
1906
|
+
const parsed = new URL(url);
|
|
1907
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
1908
|
+
} catch {
|
|
1909
|
+
return false;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
function sanitizeUrl(url) {
|
|
1913
|
+
if (isValidUrl(url)) {
|
|
1914
|
+
return url;
|
|
1915
|
+
}
|
|
1916
|
+
return void 0;
|
|
1917
|
+
}
|
|
1918
|
+
function sanitizeLinkUrl(url) {
|
|
1919
|
+
if (!url) return void 0;
|
|
1920
|
+
const base = globalThis.location?.href ?? "https://link.invalid/";
|
|
1921
|
+
try {
|
|
1922
|
+
const { protocol } = new URL(url, base);
|
|
1923
|
+
return protocol === "http:" || protocol === "https:" ? url : void 0;
|
|
1924
|
+
} catch {
|
|
1925
|
+
return void 0;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
function hexToRgb(hex) {
|
|
1929
|
+
const cleanHex = hex.replace(/^#/, "");
|
|
1930
|
+
const r7 = parseInt(cleanHex.slice(0, 2), 16);
|
|
1931
|
+
const g2 = parseInt(cleanHex.slice(2, 4), 16);
|
|
1932
|
+
const b3 = parseInt(cleanHex.slice(4, 6), 16);
|
|
1933
|
+
return `${r7}, ${g2}, ${b3}`;
|
|
1934
|
+
}
|
|
1935
|
+
function generateBrandingCSSVars(branding) {
|
|
1936
|
+
return {
|
|
1937
|
+
"--consent-primary": branding.primaryColor,
|
|
1938
|
+
"--consent-secondary": branding.secondaryColor,
|
|
1939
|
+
"--consent-primary-rgb": hexToRgb(branding.primaryColor),
|
|
1940
|
+
"--consent-secondary-rgb": hexToRgb(branding.secondaryColor),
|
|
1941
|
+
...generateContrastCSSVariables(
|
|
1942
|
+
branding.primaryColor,
|
|
1943
|
+
branding.secondaryColor
|
|
1944
|
+
)
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
function resolveConsentBranding(branding) {
|
|
1948
|
+
const primaryColor = sanitizeColor(
|
|
1949
|
+
branding?.primaryColor,
|
|
1950
|
+
DEFAULT_COLORS.PRIMARY
|
|
1951
|
+
);
|
|
1952
|
+
const secondaryColor = sanitizeColor(
|
|
1953
|
+
branding?.secondaryColor,
|
|
1954
|
+
DEFAULT_COLORS.SECONDARY
|
|
1955
|
+
);
|
|
1956
|
+
const logoUrl = sanitizeUrl(branding?.logoUrl);
|
|
1957
|
+
const companyName = branding?.companyName?.trim() || void 0;
|
|
1958
|
+
const cssVars = generateBrandingCSSVars({ primaryColor, secondaryColor });
|
|
1959
|
+
return {
|
|
1960
|
+
primaryColor,
|
|
1961
|
+
secondaryColor,
|
|
1962
|
+
logoUrl,
|
|
1963
|
+
companyName,
|
|
1964
|
+
cssVars
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1716
1968
|
// src/components/consent-terms.ts
|
|
1717
1969
|
var ConsentTerms = class extends i4 {
|
|
1718
1970
|
constructor() {
|
|
@@ -1752,9 +2004,10 @@ var ConsentTerms = class extends i4 {
|
|
|
1752
2004
|
);
|
|
1753
2005
|
}
|
|
1754
2006
|
renderLink(text, url) {
|
|
1755
|
-
|
|
2007
|
+
const href = sanitizeLinkUrl(url);
|
|
2008
|
+
if (href) {
|
|
1756
2009
|
return b2`<a
|
|
1757
|
-
href=${
|
|
2010
|
+
href=${href}
|
|
1758
2011
|
target="_blank"
|
|
1759
2012
|
rel="noopener noreferrer"
|
|
1760
2013
|
part="link"
|
|
@@ -1814,7 +2067,7 @@ ConsentTerms.styles = i`
|
|
|
1814
2067
|
}
|
|
1815
2068
|
|
|
1816
2069
|
/* Custom checkbox styling - matches Checkpoint exactly */
|
|
1817
|
-
input[type=
|
|
2070
|
+
input[type="checkbox"] {
|
|
1818
2071
|
appearance: none;
|
|
1819
2072
|
-webkit-appearance: none;
|
|
1820
2073
|
margin: 0;
|
|
@@ -1835,39 +2088,41 @@ ConsentTerms.styles = i`
|
|
|
1835
2088
|
/* Interaction */
|
|
1836
2089
|
cursor: pointer;
|
|
1837
2090
|
position: relative;
|
|
1838
|
-
transition:
|
|
2091
|
+
transition:
|
|
2092
|
+
background-color 0.15s ease,
|
|
2093
|
+
border-color 0.15s ease;
|
|
1839
2094
|
}
|
|
1840
2095
|
|
|
1841
|
-
input[type=
|
|
2096
|
+
input[type="checkbox"]:hover:not(:disabled) {
|
|
1842
2097
|
border-color: var(--_primary);
|
|
1843
2098
|
}
|
|
1844
2099
|
|
|
1845
|
-
input[type=
|
|
2100
|
+
input[type="checkbox"]:focus-visible {
|
|
1846
2101
|
outline: 2px solid var(--_primary);
|
|
1847
2102
|
outline-offset: 2px;
|
|
1848
2103
|
}
|
|
1849
2104
|
|
|
1850
2105
|
/* Checked state */
|
|
1851
|
-
input[type=
|
|
2106
|
+
input[type="checkbox"]:checked {
|
|
1852
2107
|
background-color: var(--_primary);
|
|
1853
2108
|
border-color: var(--_primary);
|
|
1854
2109
|
}
|
|
1855
2110
|
|
|
1856
2111
|
/* Checkmark */
|
|
1857
|
-
input[type=
|
|
1858
|
-
content:
|
|
2112
|
+
input[type="checkbox"]:checked::after {
|
|
2113
|
+
content: "";
|
|
1859
2114
|
position: absolute;
|
|
1860
2115
|
left: 4px;
|
|
1861
2116
|
top: 1px;
|
|
1862
2117
|
width: 5px;
|
|
1863
2118
|
height: 9px;
|
|
1864
|
-
border: solid white;
|
|
2119
|
+
border: solid var(--consent-on-primary, white);
|
|
1865
2120
|
border-width: 0 2px 2px 0;
|
|
1866
2121
|
transform: rotate(45deg);
|
|
1867
2122
|
}
|
|
1868
2123
|
|
|
1869
2124
|
/* Disabled */
|
|
1870
|
-
input[type=
|
|
2125
|
+
input[type="checkbox"]:disabled {
|
|
1871
2126
|
cursor: not-allowed;
|
|
1872
2127
|
opacity: 0.5;
|
|
1873
2128
|
}
|
|
@@ -1879,7 +2134,7 @@ ConsentTerms.styles = i`
|
|
|
1879
2134
|
|
|
1880
2135
|
/* Links */
|
|
1881
2136
|
a {
|
|
1882
|
-
color: var(--_primary);
|
|
2137
|
+
color: var(--consent-link, var(--_primary));
|
|
1883
2138
|
text-decoration: underline;
|
|
1884
2139
|
text-underline-offset: 2px;
|
|
1885
2140
|
}
|
|
@@ -2630,7 +2885,8 @@ var CONSENT_COPY_TOKENS = {
|
|
|
2630
2885
|
* `{Verb}` → operator verb, default "use".
|
|
2631
2886
|
* `{Org}` → organization display name (serif italic at render time).
|
|
2632
2887
|
*/
|
|
2633
|
-
template: "{Agent} would like to {Verb} at {Org} for you."
|
|
2888
|
+
template: "{Agent} would like to {Verb} at {Org} for you.",
|
|
2889
|
+
fallbackTemplate: "{Agent} is requesting permission at {Org}."
|
|
2634
2890
|
},
|
|
2635
2891
|
subhead: {
|
|
2636
2892
|
/** `{Agent}` → agent display name. */
|
|
@@ -2639,6 +2895,12 @@ var CONSENT_COPY_TOKENS = {
|
|
|
2639
2895
|
agentTile: {
|
|
2640
2896
|
verifiedPill: "Verified",
|
|
2641
2897
|
unverifiedPill: "UNVERIFIED",
|
|
2898
|
+
/**
|
|
2899
|
+
* Read by screen readers before the domain in a domain-bound agent's
|
|
2900
|
+
* pill, which shows only the domain. Never "Verified": a domain binding
|
|
2901
|
+
* names the client, it does not verify it.
|
|
2902
|
+
*/
|
|
2903
|
+
domainPillPrefix: "Identified by",
|
|
2642
2904
|
/** `{Vendor}` → vendor name. `{Surface}` → surface label. */
|
|
2643
2905
|
metaTemplate: "Made by {Vendor} \xB7 Asking from your {Surface} \xB7 {Connected}",
|
|
2644
2906
|
connectedJustNow: "Connected just now",
|
|
@@ -2694,6 +2956,38 @@ var CONSENT_COPY_TOKENS = {
|
|
|
2694
2956
|
/** Dark theme. */
|
|
2695
2957
|
securedBy: "Secured by Checkpoint",
|
|
2696
2958
|
howThisWorks: "How does this work?"
|
|
2959
|
+
},
|
|
2960
|
+
/**
|
|
2961
|
+
* `consent-passkey` defaults. `PasskeyConfig.instructions`, `buttonText`
|
|
2962
|
+
* and `unsupportedText` override these for both ceremonies.
|
|
2963
|
+
*/
|
|
2964
|
+
passkey: {
|
|
2965
|
+
register: {
|
|
2966
|
+
title: "Create a passkey",
|
|
2967
|
+
instructions: "Your device asks for your fingerprint, face or screen lock. The passkey stays on this device.",
|
|
2968
|
+
button: "Create a passkey",
|
|
2969
|
+
done: "Passkey created"
|
|
2970
|
+
},
|
|
2971
|
+
authenticate: {
|
|
2972
|
+
title: "Use your passkey",
|
|
2973
|
+
instructions: "Confirm with your fingerprint, face or screen lock to approve this request.",
|
|
2974
|
+
button: "Use your passkey",
|
|
2975
|
+
done: "Passkey confirmed"
|
|
2976
|
+
},
|
|
2977
|
+
checking: "Checking this device for passkey support",
|
|
2978
|
+
waiting: "Waiting for your device",
|
|
2979
|
+
unsupportedTitle: "This device can't use a passkey",
|
|
2980
|
+
unsupportedText: "This request needs a passkey, and this browser can't create or use one. Open the link on a device with a screen lock and a current browser.",
|
|
2981
|
+
compatibilityInfo: "Passkeys work in current versions of Chrome, Edge, Firefox and Safari on a device with a screen lock.",
|
|
2982
|
+
/** Keyed by `PasskeyCeremonyError.code` from `@kya-os/id/wallet/passkey`. */
|
|
2983
|
+
errors: {
|
|
2984
|
+
not_allowed: "The passkey request was cancelled or timed out, or no passkey matched. Try again.",
|
|
2985
|
+
invalid_state: "This device already holds a passkey for this account. Use that passkey instead.",
|
|
2986
|
+
not_supported: "This browser or device can't complete a user-verified passkey check.",
|
|
2987
|
+
security: "Passkeys can't be used on this page.",
|
|
2988
|
+
aborted: "The passkey request was interrupted. Try again.",
|
|
2989
|
+
unknown: "The passkey check failed. Try again."
|
|
2990
|
+
}
|
|
2697
2991
|
}
|
|
2698
2992
|
};
|
|
2699
2993
|
function formatToken(template, values) {
|
|
@@ -2703,6 +2997,20 @@ function formatToken(template, values) {
|
|
|
2703
2997
|
});
|
|
2704
2998
|
}
|
|
2705
2999
|
|
|
3000
|
+
// src/types/capabilities.types.ts
|
|
3001
|
+
var AGENT_VERIFICATIONS = [
|
|
3002
|
+
"verified",
|
|
3003
|
+
"domain",
|
|
3004
|
+
"unverified"
|
|
3005
|
+
];
|
|
3006
|
+
function agentVerification(agent) {
|
|
3007
|
+
const stated = agent.verification;
|
|
3008
|
+
if (stated !== void 0 && AGENT_VERIFICATIONS.includes(stated)) {
|
|
3009
|
+
return stated === "domain" && !agent.domain?.trim() ? "unverified" : stated;
|
|
3010
|
+
}
|
|
3011
|
+
return agent.verified === true ? "verified" : "unverified";
|
|
3012
|
+
}
|
|
3013
|
+
|
|
2706
3014
|
// src/components/consent-agent-header.ts
|
|
2707
3015
|
var ConsentAgentHeader = class extends i4 {
|
|
2708
3016
|
constructor() {
|
|
@@ -2710,6 +3018,7 @@ var ConsentAgentHeader = class extends i4 {
|
|
|
2710
3018
|
this.agentName = "";
|
|
2711
3019
|
this.vendor = "";
|
|
2712
3020
|
this.surfaceLabel = "";
|
|
3021
|
+
this.domain = "";
|
|
2713
3022
|
this.verified = false;
|
|
2714
3023
|
this.logoUrl = "";
|
|
2715
3024
|
this.connectedAt = "";
|
|
@@ -2740,10 +3049,25 @@ var ConsentAgentHeader = class extends i4 {
|
|
|
2740
3049
|
Connected: this.renderConnectedFragment()
|
|
2741
3050
|
});
|
|
2742
3051
|
}
|
|
3052
|
+
renderPill() {
|
|
3053
|
+
const tokens = CONSENT_COPY_TOKENS.agentTile;
|
|
3054
|
+
const state = agentVerification({
|
|
3055
|
+
verification: this.verification,
|
|
3056
|
+
verified: this.verified,
|
|
3057
|
+
domain: this.domain
|
|
3058
|
+
});
|
|
3059
|
+
if (state === "domain") {
|
|
3060
|
+
return b2`<span class="pill domain" part="pill"
|
|
3061
|
+
><span class="visually-hidden">${tokens.domainPillPrefix} </span
|
|
3062
|
+
>${this.domain.trim()}</span
|
|
3063
|
+
>`;
|
|
3064
|
+
}
|
|
3065
|
+
return b2`<span class="pill ${state}" part="pill">
|
|
3066
|
+
${state === "verified" ? tokens.verifiedPill : tokens.unverifiedPill}
|
|
3067
|
+
</span>`;
|
|
3068
|
+
}
|
|
2743
3069
|
render() {
|
|
2744
3070
|
const initial = (this.agentName || "?").trim().charAt(0).toUpperCase();
|
|
2745
|
-
const verifiedLabel = this.verified ? CONSENT_COPY_TOKENS.agentTile.verifiedPill : CONSENT_COPY_TOKENS.agentTile.unverifiedPill;
|
|
2746
|
-
const verifiedClass = this.verified ? "verified" : "unverified";
|
|
2747
3071
|
return b2`
|
|
2748
3072
|
<div class="tile" part="tile">
|
|
2749
3073
|
<div class="logo" aria-hidden="true">
|
|
@@ -2752,9 +3076,7 @@ var ConsentAgentHeader = class extends i4 {
|
|
|
2752
3076
|
<div class="body">
|
|
2753
3077
|
<div class="row-name">
|
|
2754
3078
|
<span class="name">${this.agentName || A}</span>
|
|
2755
|
-
|
|
2756
|
-
${verifiedLabel}
|
|
2757
|
-
</span>
|
|
3079
|
+
${this.renderPill()}
|
|
2758
3080
|
</div>
|
|
2759
3081
|
<div class="meta">${this.renderMeta()}</div>
|
|
2760
3082
|
</div>
|
|
@@ -2785,7 +3107,7 @@ ConsentAgentHeader.styles = i`
|
|
|
2785
3107
|
height: 44px;
|
|
2786
3108
|
border-radius: 12px;
|
|
2787
3109
|
flex-shrink: 0;
|
|
2788
|
-
background: var(--cs-agent-tile-bg, #
|
|
3110
|
+
background: var(--cs-agent-tile-bg, #ffffff);
|
|
2789
3111
|
display: flex;
|
|
2790
3112
|
align-items: center;
|
|
2791
3113
|
justify-content: center;
|
|
@@ -2804,7 +3126,7 @@ ConsentAgentHeader.styles = i`
|
|
|
2804
3126
|
width: 100%;
|
|
2805
3127
|
height: 100%;
|
|
2806
3128
|
background: transparent;
|
|
2807
|
-
color: var(--cs-agent-tile-text, #
|
|
3129
|
+
color: var(--cs-agent-tile-text, #0f172a);
|
|
2808
3130
|
display: flex;
|
|
2809
3131
|
align-items: center;
|
|
2810
3132
|
justify-content: center;
|
|
@@ -2829,7 +3151,7 @@ ConsentAgentHeader.styles = i`
|
|
|
2829
3151
|
.name {
|
|
2830
3152
|
font-size: 16px;
|
|
2831
3153
|
font-weight: 600;
|
|
2832
|
-
color: var(--cs-text-primary, #
|
|
3154
|
+
color: var(--cs-text-primary, #0f172a);
|
|
2833
3155
|
letter-spacing: -0.01em;
|
|
2834
3156
|
}
|
|
2835
3157
|
|
|
@@ -2845,19 +3167,52 @@ ConsentAgentHeader.styles = i`
|
|
|
2845
3167
|
}
|
|
2846
3168
|
|
|
2847
3169
|
.pill.verified {
|
|
2848
|
-
background: var(--cs-pill-verified-bg, #
|
|
3170
|
+
background: var(--cs-pill-verified-bg, #dcfce7);
|
|
2849
3171
|
color: var(--cs-pill-verified-text, #166534);
|
|
2850
3172
|
}
|
|
2851
3173
|
|
|
2852
3174
|
.pill.unverified {
|
|
2853
|
-
background: var(--cs-pill-unverified-bg, #
|
|
3175
|
+
background: var(--cs-pill-unverified-bg, #f1f5f9);
|
|
2854
3176
|
color: var(--cs-pill-unverified-text, #475569);
|
|
2855
3177
|
letter-spacing: 0.08em;
|
|
2856
3178
|
}
|
|
2857
3179
|
|
|
3180
|
+
/*
|
|
3181
|
+
* Domain-bound: a tint and an outline from the brand primary, with the
|
|
3182
|
+
* theme's own text color, so the domain reads in light and dark
|
|
3183
|
+
* whatever the brand color is.
|
|
3184
|
+
*/
|
|
3185
|
+
.pill.domain {
|
|
3186
|
+
background: var(
|
|
3187
|
+
--cs-pill-domain-bg,
|
|
3188
|
+
color-mix(in srgb, var(--consent-primary, #2563eb) 14%, transparent)
|
|
3189
|
+
);
|
|
3190
|
+
box-shadow: inset 0 0 0 1px
|
|
3191
|
+
var(
|
|
3192
|
+
--cs-pill-domain-border,
|
|
3193
|
+
color-mix(in srgb, var(--consent-primary, #2563eb) 40%, transparent)
|
|
3194
|
+
);
|
|
3195
|
+
color: var(--cs-pill-domain-text, var(--cs-text-primary, #0f172a));
|
|
3196
|
+
font-weight: 500;
|
|
3197
|
+
letter-spacing: 0;
|
|
3198
|
+
overflow-wrap: anywhere;
|
|
3199
|
+
}
|
|
3200
|
+
|
|
3201
|
+
.visually-hidden {
|
|
3202
|
+
position: absolute;
|
|
3203
|
+
width: 1px;
|
|
3204
|
+
height: 1px;
|
|
3205
|
+
margin: -1px;
|
|
3206
|
+
padding: 0;
|
|
3207
|
+
overflow: hidden;
|
|
3208
|
+
clip: rect(0, 0, 0, 0);
|
|
3209
|
+
white-space: nowrap;
|
|
3210
|
+
border: 0;
|
|
3211
|
+
}
|
|
3212
|
+
|
|
2858
3213
|
.meta {
|
|
2859
3214
|
font-size: 12px;
|
|
2860
|
-
color: var(--cs-text-tertiary, #
|
|
3215
|
+
color: var(--cs-text-tertiary, #64748b);
|
|
2861
3216
|
line-height: 1.5;
|
|
2862
3217
|
}
|
|
2863
3218
|
`;
|
|
@@ -2870,6 +3225,12 @@ __decorateClass([
|
|
|
2870
3225
|
__decorateClass([
|
|
2871
3226
|
n4({ type: String })
|
|
2872
3227
|
], ConsentAgentHeader.prototype, "surfaceLabel", 2);
|
|
3228
|
+
__decorateClass([
|
|
3229
|
+
n4({ type: String })
|
|
3230
|
+
], ConsentAgentHeader.prototype, "verification", 2);
|
|
3231
|
+
__decorateClass([
|
|
3232
|
+
n4({ type: String })
|
|
3233
|
+
], ConsentAgentHeader.prototype, "domain", 2);
|
|
2873
3234
|
__decorateClass([
|
|
2874
3235
|
n4({ type: Boolean })
|
|
2875
3236
|
], ConsentAgentHeader.prototype, "verified", 2);
|
|
@@ -3624,7 +3985,11 @@ var ConsentFooter = class extends i4 {
|
|
|
3624
3985
|
</svg>
|
|
3625
3986
|
${attribution}
|
|
3626
3987
|
</span>
|
|
3627
|
-
${this.howItWorksUrl ? b2`<a
|
|
3988
|
+
${sanitizeLinkUrl(this.howItWorksUrl) ? b2`<a
|
|
3989
|
+
href="${sanitizeLinkUrl(this.howItWorksUrl)}"
|
|
3990
|
+
target="_blank"
|
|
3991
|
+
rel="noopener"
|
|
3992
|
+
>
|
|
3628
3993
|
${CONSENT_COPY_TOKENS.attribution.howThisWorks}
|
|
3629
3994
|
</a>` : b2`<span>${CONSENT_COPY_TOKENS.attribution.howThisWorks}</span>`}
|
|
3630
3995
|
`;
|
|
@@ -3638,7 +4003,7 @@ ConsentFooter.styles = i`
|
|
|
3638
4003
|
gap: 16px;
|
|
3639
4004
|
padding-top: 12px;
|
|
3640
4005
|
font-size: 12px;
|
|
3641
|
-
color: var(--cs-text-tertiary, #
|
|
4006
|
+
color: var(--cs-text-tertiary, #64748b);
|
|
3642
4007
|
border-top: 1px solid var(--cs-surface-border, transparent);
|
|
3643
4008
|
}
|
|
3644
4009
|
|
|
@@ -3661,7 +4026,7 @@ ConsentFooter.styles = i`
|
|
|
3661
4026
|
}
|
|
3662
4027
|
|
|
3663
4028
|
a:hover {
|
|
3664
|
-
color: var(--cs-text-primary, #
|
|
4029
|
+
color: var(--cs-text-primary, #0f172a);
|
|
3665
4030
|
}
|
|
3666
4031
|
`;
|
|
3667
4032
|
__decorateClass([
|
|
@@ -4091,6 +4456,7 @@ var AUTH_MODES = {
|
|
|
4091
4456
|
/** Identity verification (future) - Auth → Consent → Success (3 screens) */
|
|
4092
4457
|
IDV: "idv"
|
|
4093
4458
|
};
|
|
4459
|
+
var PASSKEY_CEREMONIES = ["register", "authenticate"];
|
|
4094
4460
|
var PROVIDER_TYPES = {
|
|
4095
4461
|
/** Consent-only - no authentication, just clickwrap agreement */
|
|
4096
4462
|
NONE: "none",
|
|
@@ -4156,7 +4522,7 @@ var ConsentCapabilitiesScreen = class extends i4 {
|
|
|
4156
4522
|
super(...arguments);
|
|
4157
4523
|
this.capabilities = [];
|
|
4158
4524
|
this.orgName = "";
|
|
4159
|
-
this.headlineVerb = "
|
|
4525
|
+
this.headlineVerb = "";
|
|
4160
4526
|
this.revocationPath = "Account \u2192 Connected Agents";
|
|
4161
4527
|
this.inactivityDays = 90;
|
|
4162
4528
|
this.fixedExpiry = false;
|
|
@@ -4269,13 +4635,17 @@ var ConsentCapabilitiesScreen = class extends i4 {
|
|
|
4269
4635
|
}
|
|
4270
4636
|
}
|
|
4271
4637
|
renderHeadline() {
|
|
4272
|
-
const agentName = this.agentMetadata?.name || "
|
|
4638
|
+
const agentName = this.agentMetadata?.name?.trim() || "An assistant";
|
|
4273
4639
|
const tokens = CONSENT_COPY_TOKENS;
|
|
4274
|
-
const
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4640
|
+
const verb = this.headlineVerb.trim();
|
|
4641
|
+
const raw = formatToken(
|
|
4642
|
+
verb && verb !== "use" ? tokens.headline.template : tokens.headline.fallbackTemplate,
|
|
4643
|
+
{
|
|
4644
|
+
Agent: "@@AGENT@@",
|
|
4645
|
+
Verb: verb,
|
|
4646
|
+
Org: "@@ORG@@"
|
|
4647
|
+
}
|
|
4648
|
+
);
|
|
4279
4649
|
const escaped = escapeHtml(raw);
|
|
4280
4650
|
const withSerifEntities = escaped.replace("@@AGENT@@", `<em>${escapeHtml(agentName)}</em>`).replace(
|
|
4281
4651
|
"@@ORG@@",
|
|
@@ -4314,13 +4684,15 @@ var ConsentCapabilitiesScreen = class extends i4 {
|
|
|
4314
4684
|
>
|
|
4315
4685
|
${this.renderHeadline()}
|
|
4316
4686
|
<p class="subhead" part="subhead">${subhead}</p>
|
|
4687
|
+
<slot name="recovery"></slot>
|
|
4317
4688
|
<slot name="identity"></slot>
|
|
4318
4689
|
${this.agentMetadata ? b2`<consent-agent-header
|
|
4319
4690
|
part="agent"
|
|
4320
4691
|
agentName="${this.agentMetadata.name}"
|
|
4321
4692
|
vendor="${this.agentMetadata.vendor || ""}"
|
|
4322
4693
|
surfaceLabel="${this.agentMetadata.surfaceLabel || ""}"
|
|
4323
|
-
|
|
4694
|
+
verification="${agentVerification(this.agentMetadata)}"
|
|
4695
|
+
domain="${this.agentMetadata.domain || ""}"
|
|
4324
4696
|
logoUrl="${this.agentMetadata.logoUrl || ""}"
|
|
4325
4697
|
connectedAt="${this.agentMetadata.connectedAt || ""}"
|
|
4326
4698
|
></consent-agent-header>` : A}
|
|
@@ -4540,125 +4912,6 @@ function escapeHtml(value) {
|
|
|
4540
4912
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4541
4913
|
}
|
|
4542
4914
|
|
|
4543
|
-
// src/constants/colors.ts
|
|
4544
|
-
var DEFAULT_COLORS = {
|
|
4545
|
-
/** Primary brand color - Tailwind blue-600 */
|
|
4546
|
-
PRIMARY: "#2563EB",
|
|
4547
|
-
/** Secondary/accent color - Tailwind blue-100 */
|
|
4548
|
-
SECONDARY: "#DBEAFE",
|
|
4549
|
-
/** Background color */
|
|
4550
|
-
BACKGROUND: "#F9FAFB",
|
|
4551
|
-
/** Text colors */
|
|
4552
|
-
TEXT_PRIMARY: "#111827",
|
|
4553
|
-
TEXT_SECONDARY: "#6B7280",
|
|
4554
|
-
TEXT_MUTED: "#9CA3AF",
|
|
4555
|
-
/** Border colors */
|
|
4556
|
-
BORDER: "#E5E7EB",
|
|
4557
|
-
BORDER_DARK: "#D1D5DB",
|
|
4558
|
-
/** Success color - Tailwind green-600 */
|
|
4559
|
-
SUCCESS: "#16A34A",
|
|
4560
|
-
/** Error color - Tailwind red-600 */
|
|
4561
|
-
ERROR: "#DC2626",
|
|
4562
|
-
/** Warning color - Tailwind amber-500 */
|
|
4563
|
-
WARNING: "#F59E0B"
|
|
4564
|
-
};
|
|
4565
|
-
|
|
4566
|
-
// src/constants/defaults.ts
|
|
4567
|
-
var DEFAULT_BRANDING = {
|
|
4568
|
-
primaryColor: DEFAULT_COLORS.PRIMARY,
|
|
4569
|
-
secondaryColor: DEFAULT_COLORS.SECONDARY,
|
|
4570
|
-
logoUrl: void 0,
|
|
4571
|
-
companyName: void 0
|
|
4572
|
-
};
|
|
4573
|
-
var DEFAULT_UI = {
|
|
4574
|
-
title: "Permission request",
|
|
4575
|
-
description: "It looks like you would like to use [AI Agent] to access resources on your behalf.",
|
|
4576
|
-
expirationText: "This delegation will expire in",
|
|
4577
|
-
cancelButtonText: "Cancel",
|
|
4578
|
-
submitButtonText: "Allow access",
|
|
4579
|
-
permissionsHeader: "The agent is requesting the following permissions:",
|
|
4580
|
-
autoClose: false,
|
|
4581
|
-
popupEnabled: false,
|
|
4582
|
-
theme: "auto"
|
|
4583
|
-
};
|
|
4584
|
-
var DEFAULT_TERMS = {
|
|
4585
|
-
text: "Terms and Conditions",
|
|
4586
|
-
url: void 0,
|
|
4587
|
-
version: void 0,
|
|
4588
|
-
required: true
|
|
4589
|
-
};
|
|
4590
|
-
var DEFAULT_SUCCESS = {
|
|
4591
|
-
title: "Access Granted",
|
|
4592
|
-
description: "The agent now has permission to act on your behalf.",
|
|
4593
|
-
showCredential: true,
|
|
4594
|
-
redirectUrl: void 0,
|
|
4595
|
-
redirectDelay: void 0,
|
|
4596
|
-
continueButtonText: "Close"
|
|
4597
|
-
};
|
|
4598
|
-
var DEFAULT_EXPIRATION_DAYS = 30;
|
|
4599
|
-
|
|
4600
|
-
// src/resolution/resolve-branding.ts
|
|
4601
|
-
function isValidHexColor(color) {
|
|
4602
|
-
if (!color) return false;
|
|
4603
|
-
return /^#[0-9A-Fa-f]{6}$/.test(color);
|
|
4604
|
-
}
|
|
4605
|
-
function sanitizeColor(color, defaultColor) {
|
|
4606
|
-
if (isValidHexColor(color)) {
|
|
4607
|
-
return color;
|
|
4608
|
-
}
|
|
4609
|
-
return defaultColor;
|
|
4610
|
-
}
|
|
4611
|
-
function isValidUrl(url) {
|
|
4612
|
-
if (!url) return false;
|
|
4613
|
-
try {
|
|
4614
|
-
const parsed = new URL(url);
|
|
4615
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
4616
|
-
} catch {
|
|
4617
|
-
return false;
|
|
4618
|
-
}
|
|
4619
|
-
}
|
|
4620
|
-
function sanitizeUrl(url) {
|
|
4621
|
-
if (isValidUrl(url)) {
|
|
4622
|
-
return url;
|
|
4623
|
-
}
|
|
4624
|
-
return void 0;
|
|
4625
|
-
}
|
|
4626
|
-
function hexToRgb(hex) {
|
|
4627
|
-
const cleanHex = hex.replace(/^#/, "");
|
|
4628
|
-
const r7 = parseInt(cleanHex.slice(0, 2), 16);
|
|
4629
|
-
const g2 = parseInt(cleanHex.slice(2, 4), 16);
|
|
4630
|
-
const b3 = parseInt(cleanHex.slice(4, 6), 16);
|
|
4631
|
-
return `${r7}, ${g2}, ${b3}`;
|
|
4632
|
-
}
|
|
4633
|
-
function generateBrandingCSSVars(branding) {
|
|
4634
|
-
return {
|
|
4635
|
-
"--consent-primary": branding.primaryColor,
|
|
4636
|
-
"--consent-secondary": branding.secondaryColor,
|
|
4637
|
-
"--consent-primary-rgb": hexToRgb(branding.primaryColor),
|
|
4638
|
-
"--consent-secondary-rgb": hexToRgb(branding.secondaryColor)
|
|
4639
|
-
};
|
|
4640
|
-
}
|
|
4641
|
-
function resolveConsentBranding(branding) {
|
|
4642
|
-
const primaryColor = sanitizeColor(
|
|
4643
|
-
branding?.primaryColor,
|
|
4644
|
-
DEFAULT_COLORS.PRIMARY
|
|
4645
|
-
);
|
|
4646
|
-
const secondaryColor = sanitizeColor(
|
|
4647
|
-
branding?.secondaryColor,
|
|
4648
|
-
DEFAULT_COLORS.SECONDARY
|
|
4649
|
-
);
|
|
4650
|
-
const logoUrl = sanitizeUrl(branding?.logoUrl);
|
|
4651
|
-
const companyName = branding?.companyName?.trim() || void 0;
|
|
4652
|
-
const cssVars = generateBrandingCSSVars({ primaryColor, secondaryColor });
|
|
4653
|
-
return {
|
|
4654
|
-
primaryColor,
|
|
4655
|
-
secondaryColor,
|
|
4656
|
-
logoUrl,
|
|
4657
|
-
companyName,
|
|
4658
|
-
cssVars
|
|
4659
|
-
};
|
|
4660
|
-
}
|
|
4661
|
-
|
|
4662
4915
|
// src/resolution/resolve-copy.ts
|
|
4663
4916
|
var AGENT_NAME_PLACEHOLDER = "[AI Agent]";
|
|
4664
4917
|
function substituteAgentName(text, agentName) {
|
|
@@ -4902,9 +5155,10 @@ var McpConsent = class extends i4 {
|
|
|
4902
5155
|
this.credentialProviderUserId = "";
|
|
4903
5156
|
this.oauthUrl = "";
|
|
4904
5157
|
this.nativeScopeSelection = false;
|
|
5158
|
+
this.requestExpiresAt = 0;
|
|
4905
5159
|
this.capabilities = [];
|
|
4906
5160
|
this.orgName = "";
|
|
4907
|
-
this.headlineVerb = "
|
|
5161
|
+
this.headlineVerb = "";
|
|
4908
5162
|
this.revocationPath = "Account \u2192 Connected Agents";
|
|
4909
5163
|
this.inactivityDays = 90;
|
|
4910
5164
|
this.consentTheme = "light";
|
|
@@ -4919,6 +5173,13 @@ var McpConsent = class extends i4 {
|
|
|
4919
5173
|
this.resendCooldown = 0;
|
|
4920
5174
|
this.selectedScopes = [];
|
|
4921
5175
|
this.closeFailed = false;
|
|
5176
|
+
this.restartApprovalPage = () => {
|
|
5177
|
+
if (!this.approvalRecovery?.reload || !this.anchorSid || typeof window === "undefined")
|
|
5178
|
+
return;
|
|
5179
|
+
const target = new URL("/consent", window.location.origin);
|
|
5180
|
+
target.searchParams.set("sid", this.anchorSid);
|
|
5181
|
+
window.location.assign(target.toString());
|
|
5182
|
+
};
|
|
4922
5183
|
this.onCapabilitiesAllow = (event) => {
|
|
4923
5184
|
if (this.loading) return;
|
|
4924
5185
|
const selection = resolveCapabilitySelection(
|
|
@@ -4969,6 +5230,7 @@ var McpConsent = class extends i4 {
|
|
|
4969
5230
|
this.currentMode = this.mode ?? determineAuthMode(this.config) ?? AUTH_MODES.CONSENT_ONLY;
|
|
4970
5231
|
this.selectedScopes = [...this.scopes];
|
|
4971
5232
|
this.readIdentityAssertionFromLocation();
|
|
5233
|
+
this.scheduleRequestExpiry();
|
|
4972
5234
|
}
|
|
4973
5235
|
/**
|
|
4974
5236
|
* Read the grant-bound signed identity assertion the worker delivers via
|
|
@@ -5002,12 +5264,15 @@ var McpConsent = class extends i4 {
|
|
|
5002
5264
|
}
|
|
5003
5265
|
disconnectedCallback() {
|
|
5004
5266
|
super.disconnectedCallback();
|
|
5267
|
+
clearTimeout(this.requestExpiryTimer);
|
|
5005
5268
|
if (this.resendCooldownInterval !== void 0) {
|
|
5006
5269
|
clearInterval(this.resendCooldownInterval);
|
|
5007
5270
|
this.resendCooldownInterval = void 0;
|
|
5008
5271
|
}
|
|
5009
5272
|
}
|
|
5010
5273
|
updated(changedProperties) {
|
|
5274
|
+
if (changedProperties.has("requestExpiresAt") || changedProperties.has("nativeScopeSelection"))
|
|
5275
|
+
this.scheduleRequestExpiry();
|
|
5011
5276
|
if (changedProperties.has("config") || changedProperties.has("agentName")) {
|
|
5012
5277
|
this.resolved = resolveConsentConfig(this.config, this.agentName);
|
|
5013
5278
|
}
|
|
@@ -5018,14 +5283,11 @@ var McpConsent = class extends i4 {
|
|
|
5018
5283
|
this.selectedScopes = [...this.scopes];
|
|
5019
5284
|
}
|
|
5020
5285
|
if (this.resolved) {
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
"--consent-secondary",
|
|
5027
|
-
this.resolved.branding.secondaryColor
|
|
5028
|
-
);
|
|
5286
|
+
for (const [name, value] of Object.entries(
|
|
5287
|
+
this.resolved.branding.cssVars
|
|
5288
|
+
)) {
|
|
5289
|
+
if (value) this.style.setProperty(name, value);
|
|
5290
|
+
}
|
|
5029
5291
|
}
|
|
5030
5292
|
}
|
|
5031
5293
|
// === FORM SUBMISSION ===
|
|
@@ -5079,6 +5341,9 @@ var McpConsent = class extends i4 {
|
|
|
5079
5341
|
*/
|
|
5080
5342
|
async handleApprove(e8) {
|
|
5081
5343
|
e8?.preventDefault();
|
|
5344
|
+
if (this.nativeScopeSelection && this.requestExpiresAt > 0 && Date.now() >= this.requestExpiresAt)
|
|
5345
|
+
this.setApprovalRecovery("kyaos/pickup-expired");
|
|
5346
|
+
if (this.approvalRecovery) return;
|
|
5082
5347
|
if (this.loading) {
|
|
5083
5348
|
return;
|
|
5084
5349
|
}
|
|
@@ -5096,6 +5361,7 @@ var McpConsent = class extends i4 {
|
|
|
5096
5361
|
}
|
|
5097
5362
|
this.loading = true;
|
|
5098
5363
|
this.error = void 0;
|
|
5364
|
+
let credentialsRejected = false;
|
|
5099
5365
|
try {
|
|
5100
5366
|
const formData = new FormData();
|
|
5101
5367
|
formData.append("tool", this.tool);
|
|
@@ -5152,17 +5418,35 @@ var McpConsent = class extends i4 {
|
|
|
5152
5418
|
Object.entries(this.formData).forEach(([key, value]) => {
|
|
5153
5419
|
formData.append(key, value);
|
|
5154
5420
|
});
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5421
|
+
let response;
|
|
5422
|
+
try {
|
|
5423
|
+
response = await fetch(`${this.serverUrl}/consent/approve`, {
|
|
5424
|
+
method: "POST",
|
|
5425
|
+
body: formData
|
|
5426
|
+
});
|
|
5427
|
+
} catch (error) {
|
|
5428
|
+
if (this.nativeScopeSelection)
|
|
5429
|
+
this.setApprovalRecovery("kyaos/consent-network-interrupted");
|
|
5430
|
+
throw error;
|
|
5431
|
+
}
|
|
5159
5432
|
if (!response.ok) {
|
|
5160
|
-
const errorData = await response.json().catch(() =>
|
|
5433
|
+
const errorData = await response.json().catch(() => null);
|
|
5434
|
+
const data = errorData && typeof errorData === "object" ? errorData : {};
|
|
5435
|
+
if (this.nativeScopeSelection) {
|
|
5436
|
+
const code = typeof data.error_code === "string" ? data.error_code : void 0;
|
|
5437
|
+
credentialsRejected = this.currentMode === AUTH_MODES.CREDENTIALS && response.status === 401 && code === "kyaos/credentials-not-accepted";
|
|
5438
|
+
if (!credentialsRejected)
|
|
5439
|
+
this.setApprovalRecovery(
|
|
5440
|
+
code ?? (response.status === 410 ? "kyaos/pickup-expired" : "kyaos/consent-request-unavailable")
|
|
5441
|
+
);
|
|
5442
|
+
}
|
|
5161
5443
|
throw new Error(
|
|
5162
|
-
|
|
5444
|
+
credentialsRejected ? "Those credentials were not accepted. Please check them and try again." : typeof data.error === "string" ? data.error : typeof data.message === "string" ? data.message : "Approval failed"
|
|
5163
5445
|
);
|
|
5164
5446
|
}
|
|
5165
5447
|
const result = await response.json();
|
|
5448
|
+
if (this.nativeScopeSelection && (!result || result.success !== true || typeof result.delegation_id !== "string" || !result.delegation_id))
|
|
5449
|
+
throw new Error("Invalid approval response");
|
|
5166
5450
|
if (result.redirectUrl) {
|
|
5167
5451
|
this.dispatchEvent(
|
|
5168
5452
|
new CustomEvent("mcp-consent:approve", {
|
|
@@ -5187,10 +5471,13 @@ var McpConsent = class extends i4 {
|
|
|
5187
5471
|
})
|
|
5188
5472
|
);
|
|
5189
5473
|
} catch (e9) {
|
|
5190
|
-
this.
|
|
5474
|
+
if (this.nativeScopeSelection && !credentialsRejected && !this.approvalRecovery)
|
|
5475
|
+
this.setApprovalRecovery("kyaos/consent-request-unavailable");
|
|
5476
|
+
const message = this.approvalRecoveryMessage() ?? (e9 instanceof Error ? e9.message : "Unknown error");
|
|
5477
|
+
this.error = message;
|
|
5191
5478
|
this.dispatchEvent(
|
|
5192
5479
|
new CustomEvent("mcp-consent:error", {
|
|
5193
|
-
detail: { error:
|
|
5480
|
+
detail: { error: message },
|
|
5194
5481
|
bubbles: true,
|
|
5195
5482
|
composed: true
|
|
5196
5483
|
})
|
|
@@ -5250,6 +5537,7 @@ var McpConsent = class extends i4 {
|
|
|
5250
5537
|
<section class="agent-key" aria-label="Agent key">
|
|
5251
5538
|
<p><strong>Agent key</strong></p>
|
|
5252
5539
|
<p>This permission is bound to this key.</p>
|
|
5540
|
+
<p>The agent provider has not been verified.</p>
|
|
5253
5541
|
<code>${this.agentDid}</code>
|
|
5254
5542
|
</section>
|
|
5255
5543
|
`;
|
|
@@ -5325,9 +5613,60 @@ var McpConsent = class extends i4 {
|
|
|
5325
5613
|
</div>
|
|
5326
5614
|
`;
|
|
5327
5615
|
}
|
|
5616
|
+
approvalRecoveryMessage() {
|
|
5617
|
+
return this.approvalRecovery?.message;
|
|
5618
|
+
}
|
|
5619
|
+
setApprovalRecovery(code) {
|
|
5620
|
+
const expired = code === "kyaos/pickup-expired";
|
|
5621
|
+
const invalidForm = code === "kyaos/consent-form-invalid";
|
|
5622
|
+
const mismatch = code === "kyaos/session-mismatch";
|
|
5623
|
+
const missing = code === "kyaos/consent-request-not-found";
|
|
5624
|
+
const network = code === "kyaos/consent-network-interrupted";
|
|
5625
|
+
this.approvalRecovery = {
|
|
5626
|
+
code: expired || invalidForm || mismatch || missing || network ? code : "kyaos/consent-request-unavailable",
|
|
5627
|
+
title: expired ? "This approval request has expired" : invalidForm ? "We couldn't verify this approval page" : mismatch ? "This sign-in could not be verified" : missing ? "This approval request is no longer available" : network ? "The connection was interrupted" : "We couldn't check this approval request",
|
|
5628
|
+
message: expired || missing || mismatch ? "Return to your assistant for a new approval link, then review the permissions again." : invalidForm ? "Reload and sign in again, then review the permissions. This submission did not approve access." : network ? "We couldn't confirm whether approval completed. Return to your assistant to check the request before trying again." : "Return to your assistant to check this request before trying again.",
|
|
5629
|
+
// Only a server-confirmed valid pinned anchor permits a GET restart.
|
|
5630
|
+
reload: invalidForm
|
|
5631
|
+
};
|
|
5632
|
+
}
|
|
5633
|
+
scheduleRequestExpiry() {
|
|
5634
|
+
clearTimeout(this.requestExpiryTimer);
|
|
5635
|
+
if (!this.nativeScopeSelection || !Number.isSafeInteger(this.requestExpiresAt) || this.requestExpiresAt <= 0)
|
|
5636
|
+
return;
|
|
5637
|
+
const remaining = this.requestExpiresAt - Date.now();
|
|
5638
|
+
if (remaining <= 0) {
|
|
5639
|
+
if (this.step !== "success")
|
|
5640
|
+
this.setApprovalRecovery("kyaos/pickup-expired");
|
|
5641
|
+
} else {
|
|
5642
|
+
this.requestExpiryTimer = setTimeout(
|
|
5643
|
+
() => {
|
|
5644
|
+
if (this.step !== "success")
|
|
5645
|
+
this.setApprovalRecovery("kyaos/pickup-expired");
|
|
5646
|
+
},
|
|
5647
|
+
Math.min(remaining, 2147483647)
|
|
5648
|
+
);
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5328
5651
|
renderError() {
|
|
5652
|
+
if (this.approvalRecovery)
|
|
5653
|
+
return b2` <section
|
|
5654
|
+
class="error-message"
|
|
5655
|
+
role="alert"
|
|
5656
|
+
aria-live="assertive"
|
|
5657
|
+
aria-atomic="true"
|
|
5658
|
+
>
|
|
5659
|
+
<h2>${this.approvalRecovery.title}</h2>
|
|
5660
|
+
<p>${this.approvalRecovery.message}</p>
|
|
5661
|
+
${this.approvalRecovery.reload ? b2`<consent-button
|
|
5662
|
+
variant="secondary"
|
|
5663
|
+
@click=${this.restartApprovalPage}
|
|
5664
|
+
>Reload and sign in again</consent-button
|
|
5665
|
+
>` : A}
|
|
5666
|
+
<p><small>Reference: ${this.approvalRecovery.code}</small></p>
|
|
5667
|
+
</section>`;
|
|
5329
5668
|
if (!this.error) return A;
|
|
5330
|
-
return b2`<div class="error-message">${this.error}</div>`;
|
|
5669
|
+
return b2`<div class="error-message" role="alert">${this.error}</div>`;
|
|
5331
5670
|
}
|
|
5332
5671
|
/**
|
|
5333
5672
|
* Whether the user's identity has already been established, either via a
|
|
@@ -5353,7 +5692,7 @@ var McpConsent = class extends i4 {
|
|
|
5353
5692
|
<consent-button
|
|
5354
5693
|
variant="primary"
|
|
5355
5694
|
?loading=${this.loading}
|
|
5356
|
-
?disabled=${this.currentMode === AUTH_MODES.CONSENT_ONLY && this.resolved?.terms.required && !this.termsAccepted}
|
|
5695
|
+
?disabled=${!!this.approvalRecovery || this.currentMode === AUTH_MODES.CONSENT_ONLY && this.resolved?.terms.required && !this.termsAccepted}
|
|
5357
5696
|
@click=${this.handleApprove}
|
|
5358
5697
|
>
|
|
5359
5698
|
${submitText ?? this.resolved?.ui.submitButtonText ?? "Allow access"}
|
|
@@ -5421,11 +5760,11 @@ var McpConsent = class extends i4 {
|
|
|
5421
5760
|
></consent-input>
|
|
5422
5761
|
</div>
|
|
5423
5762
|
|
|
5424
|
-
${creds?.showForgotPassword && creds.forgotPasswordUrl ? b2`
|
|
5763
|
+
${creds?.showForgotPassword && sanitizeLinkUrl(creds.forgotPasswordUrl) ? b2`
|
|
5425
5764
|
<p style="text-align: right; margin-bottom: 1rem;">
|
|
5426
5765
|
<a
|
|
5427
|
-
href=${creds.forgotPasswordUrl}
|
|
5428
|
-
style="font-size: 0.75rem; color: var(--_primary);"
|
|
5766
|
+
href=${sanitizeLinkUrl(creds.forgotPasswordUrl)}
|
|
5767
|
+
style="font-size: 0.75rem; color: var(--consent-link, var(--_primary));"
|
|
5429
5768
|
>
|
|
5430
5769
|
Forgot password?
|
|
5431
5770
|
</a>
|
|
@@ -5465,14 +5804,13 @@ var McpConsent = class extends i4 {
|
|
|
5465
5804
|
>
|
|
5466
5805
|
<div slot="content">
|
|
5467
5806
|
${this.renderError()} ${this.renderAgentInfo()}
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
></consent-oauth-button>
|
|
5807
|
+
${this.approvalRecovery ? A : b2`<consent-oauth-button
|
|
5808
|
+
provider=${provider}
|
|
5809
|
+
provider-name=${providerName}
|
|
5810
|
+
url=${oauthButtonUrl}
|
|
5811
|
+
button-text=${oauth?.buttonText ?? `Continue with ${providerName}`}
|
|
5812
|
+
full-width
|
|
5813
|
+
></consent-oauth-button>`}
|
|
5476
5814
|
</div>
|
|
5477
5815
|
${this.renderFooter({ allowSubmit: this.hasEstablishedIdentity })}
|
|
5478
5816
|
</consent-shell>
|
|
@@ -5733,17 +6071,6 @@ var McpConsent = class extends i4 {
|
|
|
5733
6071
|
const credentials = shouldSelectAllCapabilities(this.currentMode);
|
|
5734
6072
|
const allSelected = this.requiresAllCapabilities;
|
|
5735
6073
|
return b2`
|
|
5736
|
-
${error ? b2`<div
|
|
5737
|
-
role="alert"
|
|
5738
|
-
style="
|
|
5739
|
-
color: var(--cs-text-danger, #b91c1c);
|
|
5740
|
-
margin: 0 auto 12px;
|
|
5741
|
-
max-width: 560px;
|
|
5742
|
-
font-size: 13px;
|
|
5743
|
-
"
|
|
5744
|
-
>
|
|
5745
|
-
${error}
|
|
5746
|
-
</div>` : A}
|
|
5747
6074
|
<consent-capabilities-screen
|
|
5748
6075
|
.capabilities=${flatCapabilities}
|
|
5749
6076
|
.agentMetadata=${this.agentMetadata}
|
|
@@ -5759,11 +6086,21 @@ var McpConsent = class extends i4 {
|
|
|
5759
6086
|
how-it-works-url="${this.howItWorksUrl}"
|
|
5760
6087
|
?loading=${this.loading}
|
|
5761
6088
|
?all-selected=${allSelected}
|
|
6089
|
+
?disabled=${!!this.approvalRecovery}
|
|
5762
6090
|
?require-all=${allSelected}
|
|
5763
|
-
?allow-disabled=${!projection.ok || credentials && !areCredentialsComplete(this.formData)}
|
|
6091
|
+
?allow-disabled=${!!this.approvalRecovery || !projection.ok || credentials && !areCredentialsComplete(this.formData)}
|
|
5764
6092
|
@capabilities-allow=${this.onCapabilitiesAllow}
|
|
5765
6093
|
@capabilities-deny=${this.handleDeny}
|
|
5766
6094
|
>
|
|
6095
|
+
${error || this.approvalRecovery ? b2`<div slot="recovery">
|
|
6096
|
+
${this.renderError()}${!this.error && !this.approvalRecovery && error ? b2`<div class="error-message" role="alert">${error}</div>` : A}
|
|
6097
|
+
</div>` : A}
|
|
6098
|
+
${this.nativeScopeSelection && (!this.approvalRecovery || this.approvalRecovery.reload) && Number.isSafeInteger(this.requestExpiresAt) && this.requestExpiresAt > 0 ? b2`<p slot="details">
|
|
6099
|
+
Approval request expires at
|
|
6100
|
+
<time datetime=${new Date(this.requestExpiresAt).toISOString()}
|
|
6101
|
+
>${new Date(this.requestExpiresAt).toLocaleString()}</time
|
|
6102
|
+
>.
|
|
6103
|
+
</p>` : A}
|
|
5767
6104
|
${this.nativeScopeSelection && this.agentDid ? b2`<div slot="agent-key">${this.renderNativeAgentKey()}</div>` : A}
|
|
5768
6105
|
${allSelected ? b2`<div slot="auth">
|
|
5769
6106
|
<p>
|
|
@@ -5902,6 +6239,19 @@ McpConsent.styles = i`
|
|
|
5902
6239
|
font-size: 0.875rem;
|
|
5903
6240
|
}
|
|
5904
6241
|
|
|
6242
|
+
.error-message h2 {
|
|
6243
|
+
font: inherit;
|
|
6244
|
+
font-weight: 650;
|
|
6245
|
+
margin: 0 0 0.5rem;
|
|
6246
|
+
}
|
|
6247
|
+
.error-message p {
|
|
6248
|
+
margin: 0.5rem 0;
|
|
6249
|
+
line-height: 1.5;
|
|
6250
|
+
}
|
|
6251
|
+
.error-message small {
|
|
6252
|
+
overflow-wrap: anywhere;
|
|
6253
|
+
}
|
|
6254
|
+
|
|
5905
6255
|
/* Form fields */
|
|
5906
6256
|
.form-fields {
|
|
5907
6257
|
display: flex;
|
|
@@ -6074,7 +6424,7 @@ McpConsent.styles = i`
|
|
|
6074
6424
|
|
|
6075
6425
|
.permission-badge {
|
|
6076
6426
|
background: var(--_secondary);
|
|
6077
|
-
color: #0e2249;
|
|
6427
|
+
color: var(--consent-on-secondary, #0e2249);
|
|
6078
6428
|
font-family:
|
|
6079
6429
|
"Geist",
|
|
6080
6430
|
-apple-system,
|
|
@@ -6157,7 +6507,7 @@ McpConsent.styles = i`
|
|
|
6157
6507
|
.otp-resend button {
|
|
6158
6508
|
background: none;
|
|
6159
6509
|
border: none;
|
|
6160
|
-
color: var(--_primary);
|
|
6510
|
+
color: var(--consent-link, var(--_primary));
|
|
6161
6511
|
cursor: pointer;
|
|
6162
6512
|
text-decoration: underline;
|
|
6163
6513
|
}
|
|
@@ -6257,6 +6607,12 @@ __decorateClass([
|
|
|
6257
6607
|
__decorateClass([
|
|
6258
6608
|
n4({ type: Boolean, attribute: "native-scope-selection" })
|
|
6259
6609
|
], McpConsent.prototype, "nativeScopeSelection", 2);
|
|
6610
|
+
__decorateClass([
|
|
6611
|
+
n4({ type: Number, attribute: "request-expires-at" })
|
|
6612
|
+
], McpConsent.prototype, "requestExpiresAt", 2);
|
|
6613
|
+
__decorateClass([
|
|
6614
|
+
r5()
|
|
6615
|
+
], McpConsent.prototype, "approvalRecovery", 2);
|
|
6260
6616
|
__decorateClass([
|
|
6261
6617
|
n4({
|
|
6262
6618
|
type: Array,
|
|
@@ -6387,6 +6743,572 @@ __decorateClass([
|
|
|
6387
6743
|
McpConsent = __decorateClass([
|
|
6388
6744
|
t3("mcp-consent")
|
|
6389
6745
|
], McpConsent);
|
|
6746
|
+
|
|
6747
|
+
// ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.0_86a9bc07372aea147cc0a0db8a7984f5/node_modules/@kya-os/id/dist/base64url.js
|
|
6748
|
+
function bytesToBase64Url(bytes) {
|
|
6749
|
+
let b642;
|
|
6750
|
+
if (typeof Buffer !== "undefined") {
|
|
6751
|
+
b642 = Buffer.from(bytes).toString("base64");
|
|
6752
|
+
} else {
|
|
6753
|
+
let bin = "";
|
|
6754
|
+
for (let i6 = 0; i6 < bytes.length; i6++)
|
|
6755
|
+
bin += String.fromCharCode(bytes[i6]);
|
|
6756
|
+
b642 = btoa(bin);
|
|
6757
|
+
}
|
|
6758
|
+
return b642.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
6759
|
+
}
|
|
6760
|
+
function base64UrlToBytes(b64url) {
|
|
6761
|
+
const pad = b64url.length % 4;
|
|
6762
|
+
const padded = pad === 2 ? `${b64url}==` : pad === 3 ? `${b64url}=` : pad === 1 ? "" : b64url;
|
|
6763
|
+
const b642 = padded.replace(/-/g, "+").replace(/_/g, "/");
|
|
6764
|
+
if (typeof Buffer !== "undefined") {
|
|
6765
|
+
return new Uint8Array(Buffer.from(b642, "base64"));
|
|
6766
|
+
}
|
|
6767
|
+
const bin = atob(b642);
|
|
6768
|
+
const out = new Uint8Array(bin.length);
|
|
6769
|
+
for (let i6 = 0; i6 < bin.length; i6++)
|
|
6770
|
+
out[i6] = bin.charCodeAt(i6);
|
|
6771
|
+
return out;
|
|
6772
|
+
}
|
|
6773
|
+
function base64UrlToBytesStrict(s4) {
|
|
6774
|
+
if (typeof s4 !== "string")
|
|
6775
|
+
return null;
|
|
6776
|
+
if (!/^[A-Za-z0-9_-]*$/.test(s4) || s4.length % 4 === 1)
|
|
6777
|
+
return null;
|
|
6778
|
+
const bytes = base64UrlToBytes(s4);
|
|
6779
|
+
return bytesToBase64Url(bytes) === s4 ? bytes : null;
|
|
6780
|
+
}
|
|
6781
|
+
|
|
6782
|
+
// ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.0_86a9bc07372aea147cc0a0db8a7984f5/node_modules/@kya-os/id/dist/passkey/types.js
|
|
6783
|
+
var PASSKEY_COSE_ALGORITHMS = Object.freeze([
|
|
6784
|
+
-8,
|
|
6785
|
+
-7,
|
|
6786
|
+
-257
|
|
6787
|
+
]);
|
|
6788
|
+
|
|
6789
|
+
// ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.0_86a9bc07372aea147cc0a0db8a7984f5/node_modules/@kya-os/id/dist/wallet/passkey.js
|
|
6790
|
+
var PasskeyCeremonyError = class extends Error {
|
|
6791
|
+
constructor(code, message, options) {
|
|
6792
|
+
super(message, options);
|
|
6793
|
+
__publicField(this, "code");
|
|
6794
|
+
this.name = "PasskeyCeremonyError";
|
|
6795
|
+
this.code = code;
|
|
6796
|
+
}
|
|
6797
|
+
};
|
|
6798
|
+
async function isPasskeySupported() {
|
|
6799
|
+
if (typeof window === "undefined")
|
|
6800
|
+
return false;
|
|
6801
|
+
if (window.isSecureContext === false)
|
|
6802
|
+
return false;
|
|
6803
|
+
if (typeof PublicKeyCredential === "undefined")
|
|
6804
|
+
return false;
|
|
6805
|
+
return credentialsContainer() !== null;
|
|
6806
|
+
}
|
|
6807
|
+
async function createPasskey(o8) {
|
|
6808
|
+
const json = {
|
|
6809
|
+
rp: { id: o8.rpId, name: o8.rpName },
|
|
6810
|
+
user: { id: o8.user.id, name: o8.user.name, displayName: o8.user.displayName },
|
|
6811
|
+
challenge: o8.challenge,
|
|
6812
|
+
pubKeyCredParams: PASSKEY_COSE_ALGORITHMS.map((alg) => ({
|
|
6813
|
+
type: "public-key",
|
|
6814
|
+
alg
|
|
6815
|
+
})),
|
|
6816
|
+
excludeCredentials: (o8.excludeCredentialIds ?? []).map((id) => ({
|
|
6817
|
+
id,
|
|
6818
|
+
type: "public-key"
|
|
6819
|
+
})),
|
|
6820
|
+
authenticatorSelection: {
|
|
6821
|
+
residentKey: "required",
|
|
6822
|
+
requireResidentKey: true,
|
|
6823
|
+
userVerification: "required"
|
|
6824
|
+
},
|
|
6825
|
+
attestation: "none",
|
|
6826
|
+
...o8.timeoutMs === void 0 ? {} : { timeout: o8.timeoutMs }
|
|
6827
|
+
};
|
|
6828
|
+
const manual = {
|
|
6829
|
+
...json,
|
|
6830
|
+
user: { ...json.user, id: toBuffer(json.user.id, "user.id") },
|
|
6831
|
+
challenge: toBuffer(json.challenge, "challenge"),
|
|
6832
|
+
excludeCredentials: json.excludeCredentials.map((c4) => ({
|
|
6833
|
+
...c4,
|
|
6834
|
+
id: toBuffer(c4.id, "excludeCredentialIds[]")
|
|
6835
|
+
}))
|
|
6836
|
+
};
|
|
6837
|
+
const container = requireCredentialsContainer();
|
|
6838
|
+
let credential;
|
|
6839
|
+
try {
|
|
6840
|
+
const parsers = jsonParsers();
|
|
6841
|
+
const publicKey = typeof parsers.parseCreationOptionsFromJSON === "function" ? parsers.parseCreationOptionsFromJSON(json) : manual;
|
|
6842
|
+
credential = await container.create({ publicKey });
|
|
6843
|
+
} catch (err) {
|
|
6844
|
+
throw toCeremonyError(err);
|
|
6845
|
+
}
|
|
6846
|
+
if (!credential) {
|
|
6847
|
+
throw new PasskeyCeremonyError("unknown", "navigator.credentials.create() resolved with no credential");
|
|
6848
|
+
}
|
|
6849
|
+
return registrationToJSON(credential);
|
|
6850
|
+
}
|
|
6851
|
+
async function getPasskeyAssertion(o8) {
|
|
6852
|
+
const json = {
|
|
6853
|
+
challenge: o8.challenge,
|
|
6854
|
+
rpId: o8.rpId,
|
|
6855
|
+
allowCredentials: (o8.allowCredentialIds ?? []).map((id) => ({
|
|
6856
|
+
id,
|
|
6857
|
+
type: "public-key"
|
|
6858
|
+
})),
|
|
6859
|
+
userVerification: "required",
|
|
6860
|
+
...o8.timeoutMs === void 0 ? {} : { timeout: o8.timeoutMs }
|
|
6861
|
+
};
|
|
6862
|
+
const manual = {
|
|
6863
|
+
...json,
|
|
6864
|
+
challenge: toBuffer(json.challenge, "challenge"),
|
|
6865
|
+
allowCredentials: json.allowCredentials.map((c4) => ({
|
|
6866
|
+
...c4,
|
|
6867
|
+
id: toBuffer(c4.id, "allowCredentialIds[]")
|
|
6868
|
+
}))
|
|
6869
|
+
};
|
|
6870
|
+
const container = requireCredentialsContainer();
|
|
6871
|
+
let credential;
|
|
6872
|
+
try {
|
|
6873
|
+
const parsers = jsonParsers();
|
|
6874
|
+
const publicKey = typeof parsers.parseRequestOptionsFromJSON === "function" ? parsers.parseRequestOptionsFromJSON(json) : manual;
|
|
6875
|
+
credential = await container.get({ publicKey });
|
|
6876
|
+
} catch (err) {
|
|
6877
|
+
throw toCeremonyError(err);
|
|
6878
|
+
}
|
|
6879
|
+
if (!credential) {
|
|
6880
|
+
throw new PasskeyCeremonyError("unknown", "navigator.credentials.get() resolved with no credential");
|
|
6881
|
+
}
|
|
6882
|
+
return assertionToJSON(credential);
|
|
6883
|
+
}
|
|
6884
|
+
var CODE_BY_DOM_NAME = {
|
|
6885
|
+
NotAllowedError: "not_allowed",
|
|
6886
|
+
InvalidStateError: "invalid_state",
|
|
6887
|
+
NotSupportedError: "not_supported",
|
|
6888
|
+
// Raised when the authenticator cannot meet a requirement (user
|
|
6889
|
+
// verification, discoverable credential): the same outcome for the caller.
|
|
6890
|
+
ConstraintError: "not_supported",
|
|
6891
|
+
SecurityError: "security",
|
|
6892
|
+
AbortError: "aborted"
|
|
6893
|
+
};
|
|
6894
|
+
var MESSAGE_BY_CODE = {
|
|
6895
|
+
not_allowed: "The passkey ceremony was cancelled, timed out, or found no matching passkey",
|
|
6896
|
+
invalid_state: "This authenticator already holds a passkey for this account",
|
|
6897
|
+
not_supported: "This browser or authenticator cannot create or use a user-verified passkey",
|
|
6898
|
+
security: "The passkey RP ID is not valid for this page's origin",
|
|
6899
|
+
aborted: "The passkey ceremony was aborted",
|
|
6900
|
+
unknown: "The passkey ceremony failed"
|
|
6901
|
+
};
|
|
6902
|
+
function toCeremonyError(err) {
|
|
6903
|
+
const name = typeof err === "object" && err !== null && "name" in err ? String(err.name) : "";
|
|
6904
|
+
const code = CODE_BY_DOM_NAME[name] ?? "unknown";
|
|
6905
|
+
return new PasskeyCeremonyError(code, MESSAGE_BY_CODE[code], { cause: err });
|
|
6906
|
+
}
|
|
6907
|
+
function credentialsContainer() {
|
|
6908
|
+
const container = typeof navigator === "undefined" ? void 0 : navigator.credentials;
|
|
6909
|
+
if (!container || typeof container.create !== "function" || typeof container.get !== "function") {
|
|
6910
|
+
return null;
|
|
6911
|
+
}
|
|
6912
|
+
return container;
|
|
6913
|
+
}
|
|
6914
|
+
function requireCredentialsContainer() {
|
|
6915
|
+
const container = typeof PublicKeyCredential === "undefined" ? null : credentialsContainer();
|
|
6916
|
+
if (!container) {
|
|
6917
|
+
throw new PasskeyCeremonyError("not_supported", "WebAuthn is not available in this runtime");
|
|
6918
|
+
}
|
|
6919
|
+
return container;
|
|
6920
|
+
}
|
|
6921
|
+
function jsonParsers() {
|
|
6922
|
+
return PublicKeyCredential;
|
|
6923
|
+
}
|
|
6924
|
+
function toBuffer(value, field) {
|
|
6925
|
+
const bytes = base64UrlToBytesStrict(value);
|
|
6926
|
+
if (!bytes) {
|
|
6927
|
+
throw new TypeError(`passkey option ${field} must be base64url without padding`);
|
|
6928
|
+
}
|
|
6929
|
+
const out = new ArrayBuffer(bytes.length);
|
|
6930
|
+
new Uint8Array(out).set(bytes);
|
|
6931
|
+
return out;
|
|
6932
|
+
}
|
|
6933
|
+
function b64(buffer) {
|
|
6934
|
+
return bytesToBase64Url(ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer));
|
|
6935
|
+
}
|
|
6936
|
+
function attachment(credential) {
|
|
6937
|
+
const value = credential.authenticatorAttachment;
|
|
6938
|
+
return value === "platform" || value === "cross-platform" ? { authenticatorAttachment: value } : {};
|
|
6939
|
+
}
|
|
6940
|
+
function extensionResults(credential) {
|
|
6941
|
+
return typeof credential.getClientExtensionResults === "function" ? credential.getClientExtensionResults() : {};
|
|
6942
|
+
}
|
|
6943
|
+
function registrationToJSON(credential) {
|
|
6944
|
+
if (typeof credential.toJSON === "function") {
|
|
6945
|
+
return credential.toJSON();
|
|
6946
|
+
}
|
|
6947
|
+
const response = credential.response;
|
|
6948
|
+
const transports = response.getTransports?.();
|
|
6949
|
+
const publicKeyAlgorithm = response.getPublicKeyAlgorithm?.();
|
|
6950
|
+
const publicKey = response.getPublicKey?.();
|
|
6951
|
+
const authenticatorData = response.getAuthenticatorData?.();
|
|
6952
|
+
return {
|
|
6953
|
+
id: credential.id,
|
|
6954
|
+
rawId: b64(credential.rawId),
|
|
6955
|
+
type: "public-key",
|
|
6956
|
+
response: {
|
|
6957
|
+
clientDataJSON: b64(response.clientDataJSON),
|
|
6958
|
+
attestationObject: b64(response.attestationObject),
|
|
6959
|
+
...Array.isArray(transports) ? { transports: [...transports] } : {},
|
|
6960
|
+
...typeof publicKeyAlgorithm === "number" ? { publicKeyAlgorithm } : {},
|
|
6961
|
+
...publicKey ? { publicKey: b64(publicKey) } : {},
|
|
6962
|
+
...authenticatorData ? { authenticatorData: b64(authenticatorData) } : {}
|
|
6963
|
+
},
|
|
6964
|
+
clientExtensionResults: extensionResults(credential),
|
|
6965
|
+
...attachment(credential)
|
|
6966
|
+
};
|
|
6967
|
+
}
|
|
6968
|
+
function assertionToJSON(credential) {
|
|
6969
|
+
if (typeof credential.toJSON === "function") {
|
|
6970
|
+
return credential.toJSON();
|
|
6971
|
+
}
|
|
6972
|
+
const response = credential.response;
|
|
6973
|
+
return {
|
|
6974
|
+
id: credential.id,
|
|
6975
|
+
rawId: b64(credential.rawId),
|
|
6976
|
+
type: "public-key",
|
|
6977
|
+
response: {
|
|
6978
|
+
clientDataJSON: b64(response.clientDataJSON),
|
|
6979
|
+
authenticatorData: b64(response.authenticatorData),
|
|
6980
|
+
signature: b64(response.signature),
|
|
6981
|
+
...response.userHandle ? { userHandle: b64(response.userHandle) } : {}
|
|
6982
|
+
},
|
|
6983
|
+
clientExtensionResults: extensionResults(credential),
|
|
6984
|
+
...attachment(credential)
|
|
6985
|
+
};
|
|
6986
|
+
}
|
|
6987
|
+
|
|
6988
|
+
// src/components/consent-passkey.ts
|
|
6989
|
+
var CONSENT_PASSKEY_EVENTS = {
|
|
6990
|
+
/** The ceremony succeeded. Detail: {@link ConsentPasskeyCompleteDetail}. */
|
|
6991
|
+
complete: "consent-passkey:complete",
|
|
6992
|
+
/** The ceremony failed. Detail: {@link ConsentPasskeyErrorDetail}. */
|
|
6993
|
+
error: "consent-passkey:error",
|
|
6994
|
+
/** This browser can't run a ceremony. Detail: {@link ConsentPasskeyUnsupportedDetail}. */
|
|
6995
|
+
unsupported: "consent-passkey:unsupported"
|
|
6996
|
+
};
|
|
6997
|
+
var ERROR_COPY = CONSENT_COPY_TOKENS.passkey.errors;
|
|
6998
|
+
var ConsentPasskey = class extends i4 {
|
|
6999
|
+
constructor() {
|
|
7000
|
+
super(...arguments);
|
|
7001
|
+
this.disabled = false;
|
|
7002
|
+
this.supportResult = null;
|
|
7003
|
+
this.phase = "checking";
|
|
7004
|
+
/** Bumped on every start and every new step, so a stale result is dropped. */
|
|
7005
|
+
this.run = 0;
|
|
7006
|
+
}
|
|
7007
|
+
/**
|
|
7008
|
+
* Whether this browser can run a passkey ceremony: `null` until the
|
|
7009
|
+
* support check answers, then `true` or `false`. It is set before
|
|
7010
|
+
* `consent-passkey:unsupported` fires. That event fires as the element
|
|
7011
|
+
* connects, so a host that attaches listeners later (a React effect, a
|
|
7012
|
+
* late script) reads this instead.
|
|
7013
|
+
*/
|
|
7014
|
+
get supported() {
|
|
7015
|
+
return this.supportResult;
|
|
7016
|
+
}
|
|
7017
|
+
connectedCallback() {
|
|
7018
|
+
super.connectedCallback();
|
|
7019
|
+
this.supportCheck ?? (this.supportCheck = this.checkSupport());
|
|
7020
|
+
}
|
|
7021
|
+
willUpdate(changed) {
|
|
7022
|
+
if (changed.has("options") || changed.has("ceremony")) {
|
|
7023
|
+
this.run++;
|
|
7024
|
+
this.errorCode = void 0;
|
|
7025
|
+
if (this.phase === "running" || this.phase === "done") {
|
|
7026
|
+
this.phase = "ready";
|
|
7027
|
+
}
|
|
7028
|
+
}
|
|
7029
|
+
}
|
|
7030
|
+
async checkSupport() {
|
|
7031
|
+
let supported = false;
|
|
7032
|
+
try {
|
|
7033
|
+
supported = await isPasskeySupported();
|
|
7034
|
+
} catch {
|
|
7035
|
+
supported = false;
|
|
7036
|
+
}
|
|
7037
|
+
this.supportResult = supported;
|
|
7038
|
+
if (supported) {
|
|
7039
|
+
if (this.phase === "checking") this.phase = "ready";
|
|
7040
|
+
return;
|
|
7041
|
+
}
|
|
7042
|
+
this.phase = "unsupported";
|
|
7043
|
+
this.emit(
|
|
7044
|
+
CONSENT_PASSKEY_EVENTS.unsupported,
|
|
7045
|
+
{ ceremony: this.validCeremony() }
|
|
7046
|
+
);
|
|
7047
|
+
}
|
|
7048
|
+
validCeremony() {
|
|
7049
|
+
const value = this.ceremony;
|
|
7050
|
+
return PASSKEY_CEREMONIES.find((ceremony) => ceremony === value);
|
|
7051
|
+
}
|
|
7052
|
+
canStart() {
|
|
7053
|
+
return this.phase === "ready" && !this.disabled && this.validCeremony() !== void 0 && typeof this.options === "object" && this.options !== null;
|
|
7054
|
+
}
|
|
7055
|
+
/** The button's click handler: the only path that starts a ceremony. */
|
|
7056
|
+
async handleClick() {
|
|
7057
|
+
const ceremony = this.validCeremony();
|
|
7058
|
+
const options = this.options;
|
|
7059
|
+
if (!this.canStart() || ceremony === void 0 || !options) return;
|
|
7060
|
+
const run = ++this.run;
|
|
7061
|
+
this.phase = "running";
|
|
7062
|
+
this.errorCode = void 0;
|
|
7063
|
+
let detail;
|
|
7064
|
+
try {
|
|
7065
|
+
detail = ceremony === "register" ? {
|
|
7066
|
+
ceremony,
|
|
7067
|
+
response: await createPasskey(options)
|
|
7068
|
+
} : {
|
|
7069
|
+
ceremony,
|
|
7070
|
+
response: await getPasskeyAssertion(options)
|
|
7071
|
+
};
|
|
7072
|
+
} catch (error) {
|
|
7073
|
+
if (run !== this.run) return;
|
|
7074
|
+
const failure = toErrorDetail(error);
|
|
7075
|
+
this.phase = "ready";
|
|
7076
|
+
this.errorCode = failure.code;
|
|
7077
|
+
this.emit(
|
|
7078
|
+
CONSENT_PASSKEY_EVENTS.error,
|
|
7079
|
+
failure
|
|
7080
|
+
);
|
|
7081
|
+
return;
|
|
7082
|
+
}
|
|
7083
|
+
if (run !== this.run) return;
|
|
7084
|
+
this.phase = "done";
|
|
7085
|
+
this.emit(
|
|
7086
|
+
CONSENT_PASSKEY_EVENTS.complete,
|
|
7087
|
+
detail
|
|
7088
|
+
);
|
|
7089
|
+
}
|
|
7090
|
+
emit(name, detail) {
|
|
7091
|
+
this.dispatchEvent(
|
|
7092
|
+
new CustomEvent(name, { detail, bubbles: true, composed: true })
|
|
7093
|
+
);
|
|
7094
|
+
}
|
|
7095
|
+
render() {
|
|
7096
|
+
const copy = CONSENT_COPY_TOKENS.passkey;
|
|
7097
|
+
const ceremonyCopy = copy[this.validCeremony() ?? "authenticate"];
|
|
7098
|
+
const showCompatibility = this.config?.showCompatibilityInfo !== false;
|
|
7099
|
+
if (this.phase === "unsupported") {
|
|
7100
|
+
return b2`
|
|
7101
|
+
<div class="container" part="container">
|
|
7102
|
+
<div class="heading">
|
|
7103
|
+
${renderIcon()}
|
|
7104
|
+
<div>
|
|
7105
|
+
<p class="title" part="title">${copy.unsupportedTitle}</p>
|
|
7106
|
+
<p class="instructions" part="instructions">
|
|
7107
|
+
${this.config?.unsupportedText || copy.unsupportedText}
|
|
7108
|
+
</p>
|
|
7109
|
+
</div>
|
|
7110
|
+
</div>
|
|
7111
|
+
${showCompatibility ? b2`<p class="compatibility" part="compatibility">
|
|
7112
|
+
${copy.compatibilityInfo}
|
|
7113
|
+
</p>` : A}
|
|
7114
|
+
</div>
|
|
7115
|
+
`;
|
|
7116
|
+
}
|
|
7117
|
+
const running = this.phase === "running";
|
|
7118
|
+
const done = this.phase === "done";
|
|
7119
|
+
const status = running ? copy.waiting : this.phase === "checking" ? copy.checking : done ? ceremonyCopy.done : "";
|
|
7120
|
+
const errorCode = this.errorCode;
|
|
7121
|
+
return b2`
|
|
7122
|
+
<div
|
|
7123
|
+
class="container"
|
|
7124
|
+
part="container"
|
|
7125
|
+
aria-busy=${running ? "true" : "false"}
|
|
7126
|
+
>
|
|
7127
|
+
<div class="heading">
|
|
7128
|
+
${renderIcon()}
|
|
7129
|
+
<div>
|
|
7130
|
+
<p class="title" part="title">${ceremonyCopy.title}</p>
|
|
7131
|
+
<p class="instructions" part="instructions">
|
|
7132
|
+
${this.config?.instructions || ceremonyCopy.instructions}
|
|
7133
|
+
</p>
|
|
7134
|
+
</div>
|
|
7135
|
+
</div>
|
|
7136
|
+
<button
|
|
7137
|
+
part="button"
|
|
7138
|
+
type="button"
|
|
7139
|
+
?disabled=${!this.canStart()}
|
|
7140
|
+
@click=${this.handleClick}
|
|
7141
|
+
>
|
|
7142
|
+
${this.config?.buttonText || ceremonyCopy.button}
|
|
7143
|
+
</button>
|
|
7144
|
+
<p class="status" part="status" role="status" aria-live="polite">
|
|
7145
|
+
${status}
|
|
7146
|
+
</p>
|
|
7147
|
+
${errorCode ? b2`<p class="error" part="error" role="alert">
|
|
7148
|
+
${ERROR_COPY[errorCode]}
|
|
7149
|
+
</p>` : A}
|
|
7150
|
+
${errorCode === "not_supported" && showCompatibility ? b2`<p class="compatibility" part="compatibility">
|
|
7151
|
+
${copy.compatibilityInfo}
|
|
7152
|
+
</p>` : A}
|
|
7153
|
+
</div>
|
|
7154
|
+
`;
|
|
7155
|
+
}
|
|
7156
|
+
};
|
|
7157
|
+
ConsentPasskey.styles = i`
|
|
7158
|
+
:host {
|
|
7159
|
+
display: block;
|
|
7160
|
+
color: var(--cs-text-primary, #0f172a);
|
|
7161
|
+
font-family: inherit;
|
|
7162
|
+
}
|
|
7163
|
+
|
|
7164
|
+
.container {
|
|
7165
|
+
display: flex;
|
|
7166
|
+
flex-direction: column;
|
|
7167
|
+
gap: 12px;
|
|
7168
|
+
padding: 16px;
|
|
7169
|
+
border-radius: 12px;
|
|
7170
|
+
border: 1px solid var(--cs-surface-border, rgba(15, 23, 42, 0.1));
|
|
7171
|
+
background: var(--cs-surface-card, #ffffff);
|
|
7172
|
+
}
|
|
7173
|
+
|
|
7174
|
+
.heading {
|
|
7175
|
+
display: flex;
|
|
7176
|
+
align-items: flex-start;
|
|
7177
|
+
gap: 12px;
|
|
7178
|
+
}
|
|
7179
|
+
|
|
7180
|
+
.icon {
|
|
7181
|
+
width: 36px;
|
|
7182
|
+
height: 36px;
|
|
7183
|
+
flex-shrink: 0;
|
|
7184
|
+
padding: 8px;
|
|
7185
|
+
box-sizing: border-box;
|
|
7186
|
+
border-radius: 10px;
|
|
7187
|
+
background: var(--cs-surface-inset, #f1ece2);
|
|
7188
|
+
color: var(--cs-text-secondary, #334155);
|
|
7189
|
+
}
|
|
7190
|
+
|
|
7191
|
+
.title {
|
|
7192
|
+
margin: 0;
|
|
7193
|
+
font-size: 15px;
|
|
7194
|
+
font-weight: 600;
|
|
7195
|
+
line-height: 1.4;
|
|
7196
|
+
}
|
|
7197
|
+
|
|
7198
|
+
.instructions {
|
|
7199
|
+
margin: 2px 0 0;
|
|
7200
|
+
font-size: 13.5px;
|
|
7201
|
+
line-height: 1.5;
|
|
7202
|
+
color: var(--cs-text-secondary, #334155);
|
|
7203
|
+
}
|
|
7204
|
+
|
|
7205
|
+
button {
|
|
7206
|
+
width: 100%;
|
|
7207
|
+
padding: 14px 18px;
|
|
7208
|
+
border: none;
|
|
7209
|
+
border-radius: 999px;
|
|
7210
|
+
min-height: var(--cs-action-min-height, 0px);
|
|
7211
|
+
background: var(--cs-surface-accent, #0f172a);
|
|
7212
|
+
color: var(--cs-surface-accent-text, #ffffff);
|
|
7213
|
+
font-size: var(--cs-action-font-size, 15px);
|
|
7214
|
+
font-weight: 500;
|
|
7215
|
+
font-family: inherit;
|
|
7216
|
+
cursor: pointer;
|
|
7217
|
+
transition: opacity 0.15s ease;
|
|
7218
|
+
}
|
|
7219
|
+
|
|
7220
|
+
button:hover:not(:disabled) {
|
|
7221
|
+
opacity: 0.92;
|
|
7222
|
+
}
|
|
7223
|
+
|
|
7224
|
+
button:disabled {
|
|
7225
|
+
opacity: 0.5;
|
|
7226
|
+
cursor: not-allowed;
|
|
7227
|
+
}
|
|
7228
|
+
|
|
7229
|
+
button:focus-visible {
|
|
7230
|
+
outline: 2px solid var(--cs-focus-ring, #0f172a);
|
|
7231
|
+
outline-offset: 3px;
|
|
7232
|
+
}
|
|
7233
|
+
|
|
7234
|
+
.status {
|
|
7235
|
+
margin: 0;
|
|
7236
|
+
min-height: 1em;
|
|
7237
|
+
font-size: 12.5px;
|
|
7238
|
+
color: var(--cs-text-tertiary, #64748b);
|
|
7239
|
+
}
|
|
7240
|
+
|
|
7241
|
+
.status:empty {
|
|
7242
|
+
display: none;
|
|
7243
|
+
}
|
|
7244
|
+
|
|
7245
|
+
.error {
|
|
7246
|
+
margin: 0;
|
|
7247
|
+
padding: 10px 12px;
|
|
7248
|
+
border-radius: 10px;
|
|
7249
|
+
background: var(--cs-chip-risk-bg, #fce7b6);
|
|
7250
|
+
color: var(--cs-chip-risk-text, #7a4f00);
|
|
7251
|
+
font-size: 13px;
|
|
7252
|
+
line-height: 1.45;
|
|
7253
|
+
}
|
|
7254
|
+
|
|
7255
|
+
.compatibility {
|
|
7256
|
+
margin: 0;
|
|
7257
|
+
font-size: 12.5px;
|
|
7258
|
+
line-height: 1.5;
|
|
7259
|
+
color: var(--cs-text-tertiary, #64748b);
|
|
7260
|
+
}
|
|
7261
|
+
`;
|
|
7262
|
+
__decorateClass([
|
|
7263
|
+
n4({ type: String, reflect: true })
|
|
7264
|
+
], ConsentPasskey.prototype, "ceremony", 2);
|
|
7265
|
+
__decorateClass([
|
|
7266
|
+
n4({ attribute: false })
|
|
7267
|
+
], ConsentPasskey.prototype, "options", 2);
|
|
7268
|
+
__decorateClass([
|
|
7269
|
+
n4({ attribute: false })
|
|
7270
|
+
], ConsentPasskey.prototype, "config", 2);
|
|
7271
|
+
__decorateClass([
|
|
7272
|
+
n4({ type: Boolean, reflect: true })
|
|
7273
|
+
], ConsentPasskey.prototype, "disabled", 2);
|
|
7274
|
+
__decorateClass([
|
|
7275
|
+
r5()
|
|
7276
|
+
], ConsentPasskey.prototype, "supportResult", 2);
|
|
7277
|
+
__decorateClass([
|
|
7278
|
+
r5()
|
|
7279
|
+
], ConsentPasskey.prototype, "phase", 2);
|
|
7280
|
+
__decorateClass([
|
|
7281
|
+
r5()
|
|
7282
|
+
], ConsentPasskey.prototype, "errorCode", 2);
|
|
7283
|
+
ConsentPasskey = __decorateClass([
|
|
7284
|
+
t3("consent-passkey")
|
|
7285
|
+
], ConsentPasskey);
|
|
7286
|
+
function toErrorDetail(error) {
|
|
7287
|
+
if (error instanceof PasskeyCeremonyError) {
|
|
7288
|
+
return { code: error.code, message: error.message };
|
|
7289
|
+
}
|
|
7290
|
+
return {
|
|
7291
|
+
code: "unknown",
|
|
7292
|
+
message: error instanceof Error ? error.message : String(error)
|
|
7293
|
+
};
|
|
7294
|
+
}
|
|
7295
|
+
function renderIcon() {
|
|
7296
|
+
return b2`
|
|
7297
|
+
<svg
|
|
7298
|
+
class="icon"
|
|
7299
|
+
viewBox="0 0 24 24"
|
|
7300
|
+
fill="none"
|
|
7301
|
+
stroke="currentColor"
|
|
7302
|
+
stroke-width="1.6"
|
|
7303
|
+
stroke-linecap="round"
|
|
7304
|
+
stroke-linejoin="round"
|
|
7305
|
+
aria-hidden="true"
|
|
7306
|
+
>
|
|
7307
|
+
<circle cx="8" cy="9" r="4" />
|
|
7308
|
+
<path d="M11 12.5 20 21.5M16.5 18l2-2M14.5 16l2-2" />
|
|
7309
|
+
</svg>
|
|
7310
|
+
`;
|
|
7311
|
+
}
|
|
6390
7312
|
export {
|
|
6391
7313
|
CONSENT_CAPABILITIES_FEATURES,
|
|
6392
7314
|
ConsentActionBar,
|
|
@@ -6400,6 +7322,7 @@ export {
|
|
|
6400
7322
|
ConsentInput,
|
|
6401
7323
|
ConsentOAuthButton,
|
|
6402
7324
|
ConsentOTPInput,
|
|
7325
|
+
ConsentPasskey,
|
|
6403
7326
|
ConsentPermissions,
|
|
6404
7327
|
ConsentRevocationNotice,
|
|
6405
7328
|
ConsentShell,
|