@takuhon/core 0.15.1 → 0.16.0
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/index.d.ts +36 -1
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3850,6 +3850,41 @@ interface CvDocument {
|
|
|
3850
3850
|
*/
|
|
3851
3851
|
declare function deriveCv(localized: LocalizedTakuhon): CvDocument;
|
|
3852
3852
|
|
|
3853
|
+
/**
|
|
3854
|
+
* Build a Gravatar avatar URL from an email address.
|
|
3855
|
+
*
|
|
3856
|
+
* Gravatar derives an avatar from the SHA-256 hash of a normalized email
|
|
3857
|
+
* (trimmed + lower-cased), served at `https://gravatar.com/avatar/{hash}`. This
|
|
3858
|
+
* helper assembles that URL so a non-GitHub owner can set an avatar from just an
|
|
3859
|
+
* email — no upload required — alongside the existing "paste a URL" and "upload
|
|
3860
|
+
* an image" paths.
|
|
3861
|
+
*
|
|
3862
|
+
* It is a pure, deterministic transform (no IO, no time, no randomness), the
|
|
3863
|
+
* same style as the other core transforms. The email itself is never stored:
|
|
3864
|
+
* only the returned URL is meant to be saved into `profile.avatar.url`.
|
|
3865
|
+
*/
|
|
3866
|
+
/** Options for {@link gravatarUrl}. Each maps to a Gravatar query parameter. */
|
|
3867
|
+
interface GravatarOptions {
|
|
3868
|
+
/** Pixel size, 1–2048 (`?s=`). */
|
|
3869
|
+
size?: number;
|
|
3870
|
+
/**
|
|
3871
|
+
* Default image when the email has no Gravatar (`?d=`): a keyword
|
|
3872
|
+
* (`mp` / `identicon` / `monsterid` / `wavatar` / `retro` / `robohash` /
|
|
3873
|
+
* `blank`), the literal `404`, or an image URL.
|
|
3874
|
+
*/
|
|
3875
|
+
defaultImage?: string;
|
|
3876
|
+
}
|
|
3877
|
+
/**
|
|
3878
|
+
* Build the Gravatar avatar URL for `email`. The email is trimmed + lower-cased,
|
|
3879
|
+
* SHA-256 hashed, and assembled into `https://gravatar.com/avatar/{hash}` with
|
|
3880
|
+
* any {@link GravatarOptions} appended as query parameters.
|
|
3881
|
+
*
|
|
3882
|
+
* Pure and total: a blank or whitespace-only email still yields a deterministic
|
|
3883
|
+
* URL (callers guard against empty input). The result fits well within the
|
|
3884
|
+
* 2048-character limit on `avatar.url`.
|
|
3885
|
+
*/
|
|
3886
|
+
declare function gravatarUrl(email: string, options?: GravatarOptions): string;
|
|
3887
|
+
|
|
3853
3888
|
/**
|
|
3854
3889
|
* MCP (Model Context Protocol) projection of a profile.
|
|
3855
3890
|
*
|
|
@@ -4059,4 +4094,4 @@ declare function stripImageMetadata(bytes: Uint8Array, mime: AcceptedImageMime):
|
|
|
4059
4094
|
*/
|
|
4060
4095
|
declare const SCHEMA_VERSION = "0.5.0";
|
|
4061
4096
|
|
|
4062
|
-
export { ACCEPTED_IMAGE_MIME_TYPES, type AcceptedImageMime, type ActivitySettings, type ActivitySnapshot, type ActivityStorage, type Address, type AssetOptions, type AssetRecord, type Avatar, type Career, type Certification, type CodingTime, ConflictError, type Contact, type ContentLicense, type ContentLicenseAttribution, type ContributionCalendar, type ContributionDay, type Course, type CvDocument, type CvHeader, type CvSection, type CvSectionKind, DARK_PALETTE, type Education, type ExportOptions, type ExportedTakuhon, type Honor, IMAGE_EXTENSIONS, type ImageInfo, ImportError, type Iso3166Alpha2, type IsoDateTime, LIGHT_PALETTE, type Language, type LanguageBreakdown, type LanguageProficiency, type Link, type LinkBuiltin, type LinkCustom, type LinkType, type LocaleTag, type LocalizedAddress, type LocalizedAvatar, type LocalizedBody, type LocalizedCareer, type LocalizedCertification, type LocalizedCourse, type LocalizedEducation, type LocalizedHonor, type LocalizedLanguage, type LocalizedLink, type LocalizedLinkBuiltin, type LocalizedLinkCustom, type LocalizedMembership, type LocalizedPatent, type LocalizedProfile, type LocalizedProject, type LocalizedPublication, type LocalizedRecommendation, type LocalizedRecommendationAuthor, type LocalizedTakuhon, type LocalizedTestScore, type LocalizedTitle, type LocalizedVolunteering, MAX_IMAGE_BYTES, MAX_IMAGE_DIMENSION, MAX_IMAGE_FRAMES, MCP_PROFILE_SECTIONS, MCP_RESOURCES, MCP_TOOLS, type McpInputSchema, type McpProfileSection, McpRequestError, type McpResourceDefinition, type McpResourceResult, type McpToolDefinition, type McpToolResult, type Membership, type Meta, type MetaPrivacy, type Migration, MigrationError, type NormalizedTakuhon, NotFoundError, type Palette, type Patent, type PatentStatus, type Profile, type Project, type Publication, RANK_FULL_CODING_HOURS, RANK_FULL_CONTRIBUTIONS, RANK_TIER_THRESHOLDS, type RankInput, type RankTier, type RankTierLabel, type Recommendation, type RecommendationAuthor, type RenderActivitySvgOptions, SCHEMA_VERSION, SUPPORTED_SCHEMA_VERSIONS, type Schema, type Settings, type Skill, type Slug, StorageError, type Takuhon, type TakuhonAssetStorage, type TakuhonStorage, type TestScore, type ValidationError, type ValidationResult, type Volunteering, type YearMonth, applyPublicPrivacyFilter, computeLanguagePercentages, deriveCv, deriveRankTier, detectImageMime, executeMcpTool, exportTakuhon, formatCodingTime, generateJsonLd, generatePersonJsonLd, generateProfilePageJsonLd, importTakuhon, isActivitySnapshot, migrateTakuhon, migrations, normalize, readImageInfo, readMcpResource, renderActivitySvg, resolveLocale, schema, stripImageMetadata, validate };
|
|
4097
|
+
export { ACCEPTED_IMAGE_MIME_TYPES, type AcceptedImageMime, type ActivitySettings, type ActivitySnapshot, type ActivityStorage, type Address, type AssetOptions, type AssetRecord, type Avatar, type Career, type Certification, type CodingTime, ConflictError, type Contact, type ContentLicense, type ContentLicenseAttribution, type ContributionCalendar, type ContributionDay, type Course, type CvDocument, type CvHeader, type CvSection, type CvSectionKind, DARK_PALETTE, type Education, type ExportOptions, type ExportedTakuhon, type GravatarOptions, type Honor, IMAGE_EXTENSIONS, type ImageInfo, ImportError, type Iso3166Alpha2, type IsoDateTime, LIGHT_PALETTE, type Language, type LanguageBreakdown, type LanguageProficiency, type Link, type LinkBuiltin, type LinkCustom, type LinkType, type LocaleTag, type LocalizedAddress, type LocalizedAvatar, type LocalizedBody, type LocalizedCareer, type LocalizedCertification, type LocalizedCourse, type LocalizedEducation, type LocalizedHonor, type LocalizedLanguage, type LocalizedLink, type LocalizedLinkBuiltin, type LocalizedLinkCustom, type LocalizedMembership, type LocalizedPatent, type LocalizedProfile, type LocalizedProject, type LocalizedPublication, type LocalizedRecommendation, type LocalizedRecommendationAuthor, type LocalizedTakuhon, type LocalizedTestScore, type LocalizedTitle, type LocalizedVolunteering, MAX_IMAGE_BYTES, MAX_IMAGE_DIMENSION, MAX_IMAGE_FRAMES, MCP_PROFILE_SECTIONS, MCP_RESOURCES, MCP_TOOLS, type McpInputSchema, type McpProfileSection, McpRequestError, type McpResourceDefinition, type McpResourceResult, type McpToolDefinition, type McpToolResult, type Membership, type Meta, type MetaPrivacy, type Migration, MigrationError, type NormalizedTakuhon, NotFoundError, type Palette, type Patent, type PatentStatus, type Profile, type Project, type Publication, RANK_FULL_CODING_HOURS, RANK_FULL_CONTRIBUTIONS, RANK_TIER_THRESHOLDS, type RankInput, type RankTier, type RankTierLabel, type Recommendation, type RecommendationAuthor, type RenderActivitySvgOptions, SCHEMA_VERSION, SUPPORTED_SCHEMA_VERSIONS, type Schema, type Settings, type Skill, type Slug, StorageError, type Takuhon, type TakuhonAssetStorage, type TakuhonStorage, type TestScore, type ValidationError, type ValidationResult, type Volunteering, type YearMonth, applyPublicPrivacyFilter, computeLanguagePercentages, deriveCv, deriveRankTier, detectImageMime, executeMcpTool, exportTakuhon, formatCodingTime, generateJsonLd, generatePersonJsonLd, generateProfilePageJsonLd, gravatarUrl, importTakuhon, isActivitySnapshot, migrateTakuhon, migrations, normalize, readImageInfo, readMcpResource, renderActivitySvg, resolveLocale, schema, stripImageMetadata, validate };
|
package/dist/index.js
CHANGED
|
@@ -11606,6 +11606,163 @@ function deriveCv(localized) {
|
|
|
11606
11606
|
};
|
|
11607
11607
|
}
|
|
11608
11608
|
|
|
11609
|
+
// src/sha256.ts
|
|
11610
|
+
var K = new Uint32Array([
|
|
11611
|
+
1116352408,
|
|
11612
|
+
1899447441,
|
|
11613
|
+
3049323471,
|
|
11614
|
+
3921009573,
|
|
11615
|
+
961987163,
|
|
11616
|
+
1508970993,
|
|
11617
|
+
2453635748,
|
|
11618
|
+
2870763221,
|
|
11619
|
+
3624381080,
|
|
11620
|
+
310598401,
|
|
11621
|
+
607225278,
|
|
11622
|
+
1426881987,
|
|
11623
|
+
1925078388,
|
|
11624
|
+
2162078206,
|
|
11625
|
+
2614888103,
|
|
11626
|
+
3248222580,
|
|
11627
|
+
3835390401,
|
|
11628
|
+
4022224774,
|
|
11629
|
+
264347078,
|
|
11630
|
+
604807628,
|
|
11631
|
+
770255983,
|
|
11632
|
+
1249150122,
|
|
11633
|
+
1555081692,
|
|
11634
|
+
1996064986,
|
|
11635
|
+
2554220882,
|
|
11636
|
+
2821834349,
|
|
11637
|
+
2952996808,
|
|
11638
|
+
3210313671,
|
|
11639
|
+
3336571891,
|
|
11640
|
+
3584528711,
|
|
11641
|
+
113926993,
|
|
11642
|
+
338241895,
|
|
11643
|
+
666307205,
|
|
11644
|
+
773529912,
|
|
11645
|
+
1294757372,
|
|
11646
|
+
1396182291,
|
|
11647
|
+
1695183700,
|
|
11648
|
+
1986661051,
|
|
11649
|
+
2177026350,
|
|
11650
|
+
2456956037,
|
|
11651
|
+
2730485921,
|
|
11652
|
+
2820302411,
|
|
11653
|
+
3259730800,
|
|
11654
|
+
3345764771,
|
|
11655
|
+
3516065817,
|
|
11656
|
+
3600352804,
|
|
11657
|
+
4094571909,
|
|
11658
|
+
275423344,
|
|
11659
|
+
430227734,
|
|
11660
|
+
506948616,
|
|
11661
|
+
659060556,
|
|
11662
|
+
883997877,
|
|
11663
|
+
958139571,
|
|
11664
|
+
1322822218,
|
|
11665
|
+
1537002063,
|
|
11666
|
+
1747873779,
|
|
11667
|
+
1955562222,
|
|
11668
|
+
2024104815,
|
|
11669
|
+
2227730452,
|
|
11670
|
+
2361852424,
|
|
11671
|
+
2428436474,
|
|
11672
|
+
2756734187,
|
|
11673
|
+
3204031479,
|
|
11674
|
+
3329325298
|
|
11675
|
+
]);
|
|
11676
|
+
function rotr(x, n) {
|
|
11677
|
+
return x >>> n | x << 32 - n;
|
|
11678
|
+
}
|
|
11679
|
+
function hex8(x) {
|
|
11680
|
+
return (x >>> 0).toString(16).padStart(8, "0");
|
|
11681
|
+
}
|
|
11682
|
+
function sha256hex(bytes) {
|
|
11683
|
+
let h0 = 1779033703;
|
|
11684
|
+
let h1 = 3144134277;
|
|
11685
|
+
let h2 = 1013904242;
|
|
11686
|
+
let h3 = 2773480762;
|
|
11687
|
+
let h4 = 1359893119;
|
|
11688
|
+
let h5 = 2600822924;
|
|
11689
|
+
let h6 = 528734635;
|
|
11690
|
+
let h7 = 1541459225;
|
|
11691
|
+
const bitLen = bytes.length * 8;
|
|
11692
|
+
const withOne = bytes.length + 1;
|
|
11693
|
+
const padZeros = ((56 - withOne % 64) % 64 + 64) % 64;
|
|
11694
|
+
const totalLen = withOne + padZeros + 8;
|
|
11695
|
+
const msg = new Uint8Array(totalLen);
|
|
11696
|
+
msg.set(bytes);
|
|
11697
|
+
msg[bytes.length] = 128;
|
|
11698
|
+
const hi = Math.floor(bitLen / 4294967296);
|
|
11699
|
+
const lo = bitLen >>> 0;
|
|
11700
|
+
msg[totalLen - 8] = hi >>> 24 & 255;
|
|
11701
|
+
msg[totalLen - 7] = hi >>> 16 & 255;
|
|
11702
|
+
msg[totalLen - 6] = hi >>> 8 & 255;
|
|
11703
|
+
msg[totalLen - 5] = hi & 255;
|
|
11704
|
+
msg[totalLen - 4] = lo >>> 24 & 255;
|
|
11705
|
+
msg[totalLen - 3] = lo >>> 16 & 255;
|
|
11706
|
+
msg[totalLen - 2] = lo >>> 8 & 255;
|
|
11707
|
+
msg[totalLen - 1] = lo & 255;
|
|
11708
|
+
const w = new Uint32Array(64);
|
|
11709
|
+
for (let chunk = 0; chunk < totalLen; chunk += 64) {
|
|
11710
|
+
for (let i = 0; i < 16; i++) {
|
|
11711
|
+
const o = chunk + i * 4;
|
|
11712
|
+
w[i] = (msg[o] << 24 | msg[o + 1] << 16 | msg[o + 2] << 8 | msg[o + 3]) >>> 0;
|
|
11713
|
+
}
|
|
11714
|
+
for (let i = 16; i < 64; i++) {
|
|
11715
|
+
const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
|
|
11716
|
+
const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
|
|
11717
|
+
w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
|
|
11718
|
+
}
|
|
11719
|
+
let a = h0;
|
|
11720
|
+
let b = h1;
|
|
11721
|
+
let c = h2;
|
|
11722
|
+
let d = h3;
|
|
11723
|
+
let e = h4;
|
|
11724
|
+
let f = h5;
|
|
11725
|
+
let g = h6;
|
|
11726
|
+
let h = h7;
|
|
11727
|
+
for (let i = 0; i < 64; i++) {
|
|
11728
|
+
const big1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
11729
|
+
const ch = e & f ^ ~e & g;
|
|
11730
|
+
const t1 = h + big1 + ch + K[i] + w[i] >>> 0;
|
|
11731
|
+
const big0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
11732
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
11733
|
+
const t2 = big0 + maj >>> 0;
|
|
11734
|
+
h = g;
|
|
11735
|
+
g = f;
|
|
11736
|
+
f = e;
|
|
11737
|
+
e = d + t1 >>> 0;
|
|
11738
|
+
d = c;
|
|
11739
|
+
c = b;
|
|
11740
|
+
b = a;
|
|
11741
|
+
a = t1 + t2 >>> 0;
|
|
11742
|
+
}
|
|
11743
|
+
h0 = h0 + a >>> 0;
|
|
11744
|
+
h1 = h1 + b >>> 0;
|
|
11745
|
+
h2 = h2 + c >>> 0;
|
|
11746
|
+
h3 = h3 + d >>> 0;
|
|
11747
|
+
h4 = h4 + e >>> 0;
|
|
11748
|
+
h5 = h5 + f >>> 0;
|
|
11749
|
+
h6 = h6 + g >>> 0;
|
|
11750
|
+
h7 = h7 + h >>> 0;
|
|
11751
|
+
}
|
|
11752
|
+
return hex8(h0) + hex8(h1) + hex8(h2) + hex8(h3) + hex8(h4) + hex8(h5) + hex8(h6) + hex8(h7);
|
|
11753
|
+
}
|
|
11754
|
+
|
|
11755
|
+
// src/gravatar.ts
|
|
11756
|
+
var GRAVATAR_AVATAR_BASE = "https://gravatar.com/avatar/";
|
|
11757
|
+
function gravatarUrl(email, options) {
|
|
11758
|
+
const hash = sha256hex(new TextEncoder().encode(email.trim().toLowerCase()));
|
|
11759
|
+
const params = new URLSearchParams();
|
|
11760
|
+
if (options?.size !== void 0) params.set("s", String(options.size));
|
|
11761
|
+
if (options?.defaultImage !== void 0) params.set("d", options.defaultImage);
|
|
11762
|
+
const query = params.toString();
|
|
11763
|
+
return query ? `${GRAVATAR_AVATAR_BASE}${hash}?${query}` : `${GRAVATAR_AVATAR_BASE}${hash}`;
|
|
11764
|
+
}
|
|
11765
|
+
|
|
11609
11766
|
// src/mcp.ts
|
|
11610
11767
|
var MCP_PROFILE_SECTIONS = [
|
|
11611
11768
|
"profile",
|
|
@@ -12126,6 +12283,7 @@ export {
|
|
|
12126
12283
|
generateJsonLd,
|
|
12127
12284
|
generatePersonJsonLd,
|
|
12128
12285
|
generateProfilePageJsonLd,
|
|
12286
|
+
gravatarUrl,
|
|
12129
12287
|
importTakuhon,
|
|
12130
12288
|
isActivitySnapshot,
|
|
12131
12289
|
migrateTakuhon,
|