@kya-os/consent 0.2.0 → 0.2.2
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/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/cjs/bundle/inline.js +4 -4
- package/dist/cjs/bundle/inline.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-terms.js +4 -2
- package/dist/cjs/components/consent-terms.js.map +1 -1
- package/dist/cjs/components/mcp-consent.js +3 -2
- package/dist/cjs/components/mcp-consent.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 +23 -0
- package/dist/cjs/resolution/resolve-branding.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-terms.d.ts.map +1 -1
- package/dist/components/consent-terms.js +4 -2
- package/dist/components/consent-terms.js.map +1 -1
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +3 -2
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/consent.js +125 -110
- package/dist/consent.min.js +40 -36
- 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/resolution/resolve-branding.d.ts +11 -0
- package/dist/resolution/resolve-branding.d.ts.map +1 -1
- package/dist/resolution/resolve-branding.js +22 -0
- package/dist/resolution/resolve-branding.js.map +1 -1
- package/package.json +1 -1
package/dist/consent.js
CHANGED
|
@@ -1855,6 +1855,116 @@ ConsentPermissions = __decorateClass([
|
|
|
1855
1855
|
t3("consent-permissions")
|
|
1856
1856
|
], ConsentPermissions);
|
|
1857
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
|
+
|
|
1858
1968
|
// src/components/consent-terms.ts
|
|
1859
1969
|
var ConsentTerms = class extends i4 {
|
|
1860
1970
|
constructor() {
|
|
@@ -1894,9 +2004,10 @@ var ConsentTerms = class extends i4 {
|
|
|
1894
2004
|
);
|
|
1895
2005
|
}
|
|
1896
2006
|
renderLink(text, url) {
|
|
1897
|
-
|
|
2007
|
+
const href = sanitizeLinkUrl(url);
|
|
2008
|
+
if (href) {
|
|
1898
2009
|
return b2`<a
|
|
1899
|
-
href=${
|
|
2010
|
+
href=${href}
|
|
1900
2011
|
target="_blank"
|
|
1901
2012
|
rel="noopener noreferrer"
|
|
1902
2013
|
part="link"
|
|
@@ -3874,7 +3985,11 @@ var ConsentFooter = class extends i4 {
|
|
|
3874
3985
|
</svg>
|
|
3875
3986
|
${attribution}
|
|
3876
3987
|
</span>
|
|
3877
|
-
${this.howItWorksUrl ? b2`<a
|
|
3988
|
+
${sanitizeLinkUrl(this.howItWorksUrl) ? b2`<a
|
|
3989
|
+
href="${sanitizeLinkUrl(this.howItWorksUrl)}"
|
|
3990
|
+
target="_blank"
|
|
3991
|
+
rel="noopener"
|
|
3992
|
+
>
|
|
3878
3993
|
${CONSENT_COPY_TOKENS.attribution.howThisWorks}
|
|
3879
3994
|
</a>` : b2`<span>${CONSENT_COPY_TOKENS.attribution.howThisWorks}</span>`}
|
|
3880
3995
|
`;
|
|
@@ -3888,7 +4003,7 @@ ConsentFooter.styles = i`
|
|
|
3888
4003
|
gap: 16px;
|
|
3889
4004
|
padding-top: 12px;
|
|
3890
4005
|
font-size: 12px;
|
|
3891
|
-
color: var(--cs-text-tertiary, #
|
|
4006
|
+
color: var(--cs-text-tertiary, #64748b);
|
|
3892
4007
|
border-top: 1px solid var(--cs-surface-border, transparent);
|
|
3893
4008
|
}
|
|
3894
4009
|
|
|
@@ -3911,7 +4026,7 @@ ConsentFooter.styles = i`
|
|
|
3911
4026
|
}
|
|
3912
4027
|
|
|
3913
4028
|
a:hover {
|
|
3914
|
-
color: var(--cs-text-primary, #
|
|
4029
|
+
color: var(--cs-text-primary, #0f172a);
|
|
3915
4030
|
}
|
|
3916
4031
|
`;
|
|
3917
4032
|
__decorateClass([
|
|
@@ -4797,106 +4912,6 @@ function escapeHtml(value) {
|
|
|
4797
4912
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
4798
4913
|
}
|
|
4799
4914
|
|
|
4800
|
-
// src/constants/defaults.ts
|
|
4801
|
-
var DEFAULT_BRANDING = {
|
|
4802
|
-
primaryColor: DEFAULT_COLORS.PRIMARY,
|
|
4803
|
-
secondaryColor: DEFAULT_COLORS.SECONDARY,
|
|
4804
|
-
logoUrl: void 0,
|
|
4805
|
-
companyName: void 0
|
|
4806
|
-
};
|
|
4807
|
-
var DEFAULT_UI = {
|
|
4808
|
-
title: "Permission request",
|
|
4809
|
-
description: "It looks like you would like to use [AI Agent] to access resources on your behalf.",
|
|
4810
|
-
expirationText: "This delegation will expire in",
|
|
4811
|
-
cancelButtonText: "Cancel",
|
|
4812
|
-
submitButtonText: "Allow access",
|
|
4813
|
-
permissionsHeader: "The agent is requesting the following permissions:",
|
|
4814
|
-
autoClose: false,
|
|
4815
|
-
popupEnabled: false,
|
|
4816
|
-
theme: "auto"
|
|
4817
|
-
};
|
|
4818
|
-
var DEFAULT_TERMS = {
|
|
4819
|
-
text: "Terms and Conditions",
|
|
4820
|
-
url: void 0,
|
|
4821
|
-
version: void 0,
|
|
4822
|
-
required: true
|
|
4823
|
-
};
|
|
4824
|
-
var DEFAULT_SUCCESS = {
|
|
4825
|
-
title: "Access Granted",
|
|
4826
|
-
description: "The agent now has permission to act on your behalf.",
|
|
4827
|
-
showCredential: true,
|
|
4828
|
-
redirectUrl: void 0,
|
|
4829
|
-
redirectDelay: void 0,
|
|
4830
|
-
continueButtonText: "Close"
|
|
4831
|
-
};
|
|
4832
|
-
var DEFAULT_EXPIRATION_DAYS = 30;
|
|
4833
|
-
|
|
4834
|
-
// src/resolution/resolve-branding.ts
|
|
4835
|
-
function isValidHexColor(color) {
|
|
4836
|
-
if (!color) return false;
|
|
4837
|
-
return /^#[0-9A-Fa-f]{6}$/.test(color);
|
|
4838
|
-
}
|
|
4839
|
-
function sanitizeColor(color, defaultColor) {
|
|
4840
|
-
if (isValidHexColor(color)) {
|
|
4841
|
-
return color;
|
|
4842
|
-
}
|
|
4843
|
-
return defaultColor;
|
|
4844
|
-
}
|
|
4845
|
-
function isValidUrl(url) {
|
|
4846
|
-
if (!url) return false;
|
|
4847
|
-
try {
|
|
4848
|
-
const parsed = new URL(url);
|
|
4849
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
4850
|
-
} catch {
|
|
4851
|
-
return false;
|
|
4852
|
-
}
|
|
4853
|
-
}
|
|
4854
|
-
function sanitizeUrl(url) {
|
|
4855
|
-
if (isValidUrl(url)) {
|
|
4856
|
-
return url;
|
|
4857
|
-
}
|
|
4858
|
-
return void 0;
|
|
4859
|
-
}
|
|
4860
|
-
function hexToRgb(hex) {
|
|
4861
|
-
const cleanHex = hex.replace(/^#/, "");
|
|
4862
|
-
const r7 = parseInt(cleanHex.slice(0, 2), 16);
|
|
4863
|
-
const g2 = parseInt(cleanHex.slice(2, 4), 16);
|
|
4864
|
-
const b3 = parseInt(cleanHex.slice(4, 6), 16);
|
|
4865
|
-
return `${r7}, ${g2}, ${b3}`;
|
|
4866
|
-
}
|
|
4867
|
-
function generateBrandingCSSVars(branding) {
|
|
4868
|
-
return {
|
|
4869
|
-
"--consent-primary": branding.primaryColor,
|
|
4870
|
-
"--consent-secondary": branding.secondaryColor,
|
|
4871
|
-
"--consent-primary-rgb": hexToRgb(branding.primaryColor),
|
|
4872
|
-
"--consent-secondary-rgb": hexToRgb(branding.secondaryColor),
|
|
4873
|
-
...generateContrastCSSVariables(
|
|
4874
|
-
branding.primaryColor,
|
|
4875
|
-
branding.secondaryColor
|
|
4876
|
-
)
|
|
4877
|
-
};
|
|
4878
|
-
}
|
|
4879
|
-
function resolveConsentBranding(branding) {
|
|
4880
|
-
const primaryColor = sanitizeColor(
|
|
4881
|
-
branding?.primaryColor,
|
|
4882
|
-
DEFAULT_COLORS.PRIMARY
|
|
4883
|
-
);
|
|
4884
|
-
const secondaryColor = sanitizeColor(
|
|
4885
|
-
branding?.secondaryColor,
|
|
4886
|
-
DEFAULT_COLORS.SECONDARY
|
|
4887
|
-
);
|
|
4888
|
-
const logoUrl = sanitizeUrl(branding?.logoUrl);
|
|
4889
|
-
const companyName = branding?.companyName?.trim() || void 0;
|
|
4890
|
-
const cssVars = generateBrandingCSSVars({ primaryColor, secondaryColor });
|
|
4891
|
-
return {
|
|
4892
|
-
primaryColor,
|
|
4893
|
-
secondaryColor,
|
|
4894
|
-
logoUrl,
|
|
4895
|
-
companyName,
|
|
4896
|
-
cssVars
|
|
4897
|
-
};
|
|
4898
|
-
}
|
|
4899
|
-
|
|
4900
4915
|
// src/resolution/resolve-copy.ts
|
|
4901
4916
|
var AGENT_NAME_PLACEHOLDER = "[AI Agent]";
|
|
4902
4917
|
function substituteAgentName(text, agentName) {
|
|
@@ -5745,10 +5760,10 @@ var McpConsent = class extends i4 {
|
|
|
5745
5760
|
></consent-input>
|
|
5746
5761
|
</div>
|
|
5747
5762
|
|
|
5748
|
-
${creds?.showForgotPassword && creds.forgotPasswordUrl ? b2`
|
|
5763
|
+
${creds?.showForgotPassword && sanitizeLinkUrl(creds.forgotPasswordUrl) ? b2`
|
|
5749
5764
|
<p style="text-align: right; margin-bottom: 1rem;">
|
|
5750
5765
|
<a
|
|
5751
|
-
href=${creds.forgotPasswordUrl}
|
|
5766
|
+
href=${sanitizeLinkUrl(creds.forgotPasswordUrl)}
|
|
5752
5767
|
style="font-size: 0.75rem; color: var(--consent-link, var(--_primary));"
|
|
5753
5768
|
>
|
|
5754
5769
|
Forgot password?
|
|
@@ -6729,7 +6744,7 @@ McpConsent = __decorateClass([
|
|
|
6729
6744
|
t3("mcp-consent")
|
|
6730
6745
|
], McpConsent);
|
|
6731
6746
|
|
|
6732
|
-
// ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.
|
|
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
|
|
6733
6748
|
function bytesToBase64Url(bytes) {
|
|
6734
6749
|
let b642;
|
|
6735
6750
|
if (typeof Buffer !== "undefined") {
|
|
@@ -6764,14 +6779,14 @@ function base64UrlToBytesStrict(s4) {
|
|
|
6764
6779
|
return bytesToBase64Url(bytes) === s4 ? bytes : null;
|
|
6765
6780
|
}
|
|
6766
6781
|
|
|
6767
|
-
// ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.
|
|
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
|
|
6768
6783
|
var PASSKEY_COSE_ALGORITHMS = Object.freeze([
|
|
6769
6784
|
-8,
|
|
6770
6785
|
-7,
|
|
6771
6786
|
-257
|
|
6772
6787
|
]);
|
|
6773
6788
|
|
|
6774
|
-
// ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.
|
|
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
|
|
6775
6790
|
var PasskeyCeremonyError = class extends Error {
|
|
6776
6791
|
constructor(code, message, options) {
|
|
6777
6792
|
super(message, options);
|