Issue ๐ https://github.com/fedify-dev/fedify/issues/376
Remove deprecated APIs for Fedify 2.0 · Issue #376 · fedify-dev/fedify
Overview This issue tracks the removal of all deprecated APIs that need to be removed in Fedify 2.0.0 as part of the major version cleanup. APIs to Remove 1. Federation Configuration Remove documen...
github.com
Fedify 2.0์ ๋๋นํด ์ฌ์ฉํ์ง ์๋ API๋ค์ ์ ๋ฆฌํ๋ ์ด์๊ฐ ์ฌ๋ผ์๋ค. ํด๋น ์ด์๋ฅผ ํ์ธํด๋ณด๋ฉด ์์ ์ผํ API ๋ฆฌ์คํธ๊ฐ ์๋๋ฐ, ์ฒ์์๋ API๋ค์ ์ ๋ถ ๋ค ์์ ๊ณ PR์ ์ฌ๋ฆด๊น ํ์ง๋ง ๋ฉํ ๋์ ์กฐ์ธ์ ๋ฐ๋ผ API๋ฅผ ํ๋์ฉ ์ญ์ ํ๊ณ PR์ ์ฌ๋ฆฌ๊ธฐ๋ก ํ๋ค.
1. documentLoader property ์ญ์
documentLoader ์ญ์ PR ๐ https://github.com/fedify-dev/fedify/pull/393
fix: Remove documentLoader property from FederationOptions interface by crohasang · Pull Request #393 · fedify-dev/fedify
Summary Remove documentLoader property from FederationOptions interface (use documentLoaderFactory instead) Related Issue Implemented Remove deprecated APIs for Fedify 2.0 #376 Changes In fedif...
github.com
๋จผ์ , ‘FederationOptions’ interface์ ์๋ ‘documentLoader’ property๋ฅผ ์์ ๊ธฐ๋ก ํ๋ค. ํด๋น ์ธํฐํ์ด์ค์์๋ ์ด๋ฏธ ‘documentLoader’๋ฅผ ๋์ ํ๋ ‘documentLoaderFactory’๊ฐ ์ ์ธ๋์ด์์๋ค.
/**
* A custom JSON-LD document loader. By default, this uses the built-in
* cache-backed loader that fetches remote documents over HTTP(S).
* @deprecated Use {@link documentLoaderFactory} instead.
*/
documentLoader?: DocumentLoader;
documentLoader๋ ActivityPub ๊ฐ์ฒด๋ ๋ค๋ฅธ ๋ฐ์ดํฐ๋ฅผ ๋ํ๋ด๋ JSON-LD ๋ฌธ์๋ฅผ ์๊ฒฉ URL์์ ๊ฐ์ ธ์ค๋ ์ญํ ์ ํ๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก๋ ๋ด์ฅ๋ ์บ์ ๊ธฐ๋ฐ ๋ก๋๋ฅผ ์ฌ์ฉํ์ง๋ง, ์ฌ์ฉ์๊ฐ ์ง์ ๋ง๋ ์ปค์คํ ๋ก๋๋ฅผ ์ ๊ณตํ์ฌ ๋ฌธ์ ๋ก๋ฉ ๋ฐฉ์์ ๋ณ๊ฒฝํ ์ ์๋ค.
JSON-LD ๋ฌธ์๊ฐ ๋ญ์ง?
→ JSON-LD(JSON for Linked Data)๋ ๊ฐ๋จํ ๋งํด '์๋ฏธ๊ฐ ๋ถ์ฌ๋ JSON'์ด๋ค. ์ผ๋ฐ์ ์ธ JSON ๋ฐ์ดํฐ์ '์ด๊ฒ์ ์ฌ๋ ์ด๋ฆ์ด์ผ', '์ด๊ฒ์ ์ฃผ์์ผ' ์ ๊ฐ์ด ๋ฐ์ดํฐ์ ์๋ฏธ์ ๊ด๊ณ๋ฅผ ๋ช ํํ๊ฒ ์ค๋ช ํ๋ ์ ๋ณด๋ฅผ ์ถ๊ฐํ๋ ํ์ค ๋ฐฉ์
์์
{
"@context": "<https://schema.org/>",
"@type": "Person",
"name": "ํ๊ธธ๋",
"homepage": "[<https://example.com>](<https://example.com/>)",
"image": "<https://example.com/profile.jpg>"
}
- @context : "์ด ๋ฌธ์์์ ์ฌ์ฉํ๋ ์ฉ์ด๋ค์ https://schema.org์ ์ ์๋ ์๋ฏธ๋ฅผ ๋ฐ๋ฅผ ๊ฑฐ์ผ"๋ผ๊ณ ์ ์ธํ๋ ๊ฒ → schema.org๋ ์น์์ ์ฌ์ฉ๋๋ ๋ค์ํ ์ฉ์ด(์ฌ๋, ์ฅ์, ์ด๋ฒคํธ ๋ฑ)๋ฅผ ํ์คํํ ์ผ์ข ์ '์ดํ ์ฌ์ '
- @type: "Person": ์ด ๋ฐ์ดํฐ ๋ฉ์ด๋ฆฌ๋ '์ฌ๋(Person)'์ ๋ํ ์ ๋ณด๋ผ๊ณ ๋ช ํํ ์๋ ค์ค
์ด์ ์ปดํจํฐ๋ ์ด ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ณ ๋ค์๊ณผ ๊ฐ์ด ์ดํดํ๋ค.
"์, ์ด๊ฑด schema.org ํ์ค์ ์ ์๋ '์ฌ๋(Person)'์ ๋ํ ์ ๋ณด๊ตฌ๋. name์ ๊ทธ ์ฌ๋์ ์ด๋ฆ์ด๊ณ , homepage๋ ์น์ฌ์ดํธ๊ตฌ๋."
๊ทธ๋ฌ๋ฉด ์ documentLoader์์ documentLoaderFactory๋ก ๋ฐ๊พธ๋ ๊ฑธ๊น?
documentLoader๋ ์ ์ ์ธ ๊ฐ์ฒด์ธ ๋ฐ๋ฉด, documentLoaderFactory๋ ๋์ ์ธ ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ ํจ์
documentLoader
documentLoader๋ Federation ๊ฐ์ฒด๊ฐ ์ฒ์ ๋ง๋ค์ด์ง ๋ ๋จ ํ ๋ฒ ์์ฑ๋๋ ๊ณ ์ ๋ ๋ก๋ ๊ฐ์ฒด๋ค.
→ ํ๋ฒ ๋ง๋ค์ด์ง๋ฉด, ๋ชจ๋ JSON-LD ๋ฌธ์๋ฅผ ๊ฐ์ ธ์ค๋ ์์ฒญ์ ํญ์ ์ด ๋์ผํ ๋ก๋๋ฅผ ์ฌ์ฉํด์ผํ๋ค.
documentLoaderFactory
๊ทธ์ ๋นํด documentLoaderFactory๋ JSON-LD ๋ฌธ์๋ฅผ ๊ฐ์ ธ์์ผ ํ ํ์๊ฐ ์๊ธธ ๋๋ง๋ค, ๊ทธ ์ํฉ์ ๋ง๋ ‘DocumentLoader’ ๊ฐ์ฒด๋ฅผ ์ฆ์์์ ์์ฑํ๋ ๊ณต์ฅ(Factory) ์ญํ ์ ํ๋ ํจ์์ด๋ค.
1. JSON-LD ๋ฌธ์๋ฅผ ๊ฐ์ ธ์์ผ ํ๋ ์ํฉ์ด ๋ฐ์
2. Fedify๋ documentLoaderFactory ํจ์๋ฅผ ํธ์ถ
3. ํ์ฌ ์์ฒญ์ ๋ํ ์ ๋ณด(์: "์ด ์์ฒญ์ 'user-A'์ ๊ถํ์ผ๋ก ๋ณด๋ด๋ ๊ฑฐ์ผ")์ ๊ฐ์ ์ปจํ ์คํธ๋ฅผ Factory ํจ์์ ์ ๋ฌ ๊ฐ๋ฅ
4. Factory ํจ์๋ ์ด ์ปจํ ์คํธ๋ฅผ ๋ฐํ์ผ๋ก ์ธ์ฆ ์ ๋ณด๊ฐ ํฌํจ๋ ๋ง์ถคํ DocumentLoader ๊ฐ์ฒด๋ฅผ ์๋ก ์์ฑํ์ฌ ๋ฐํ
5. Fedify๋ ๋ฐฉ๊ธ ๋ง๋ค์ด์ง ์ด ๋ง์ถคํ ๋ก๋๋ฅผ ์ฌ์ฉํด ๋ฌธ์๋ฅผ ์์ ํ๊ฒ ๊ฐ์ ธ์ด
์ฆ, documentLoader๋ฅผ documentLoaderFactory๋ก ๋ฐ๊พผ ์ด์ ๋ ์ ์ ์ธ 'ํ๋์ ๋๊ตฌ'๋ฅผ ๊ณ์ ์ฌ์ฉํ๋ ๋ฐฉ์์์, ํ์ํ ๋๋ง๋ค ์ํฉ์ ๋ง๋ '๋ง์ถคํ ๋๊ตฌ'๋ฅผ ์ฆ์์์ ๋ง๋ค์ด ์ฌ์ฉํ๋ ํจ์ฌ ๋ ์ ์ฐํ๊ณ ๊ฐ๋ ฅํ ๋ฐฉ์์ผ๋ก ์ ํํ๊ธฐ ์ํด์์ด๋ค.
์ฝ๋ ๋ณ๊ฒฝ
๋จผ์ , fedify/src/federation/federation.ts์์ documentLoader ์์ฑ์ ์์ด๋ค.
๊ทธ๋ฆฌ๊ณ cli/src/inbox.tsx์์ createFederation์ documentLoader๋ฅผ ์ง์ ์ ๋ฌํ๋ ๋์ , getDocumentLoader() ํจ์๋ก ๋ก๋๋ฅผ ๋ฑ ํ๋ฒ ๋ง๋ค๊ณ ๊ณ์ ๋์ผํ ๋ก๋๋ฅผ ์ฌ์ฌ์ฉํ๊ฒ ๋ง๋ค์๋ค.

fedify/src/federation/middleware.ts์์๋ documentLoader๋ฅผ documentLoaderFactory ๋ฐฉ์์ผ๋ก ๋ณ๊ฒฝํ๋ฉด์, allowPrivateAddress์ userAgent ๊ฒ์ฌ ์ฝ๋๋ฅผ ์ ๊ฑฐํ๋ค. ์๋ํ๋ฉด, documentLoaderFactory์ ํตํด ํด๋น ์์ฑ๋ค์ ์ง์ ํ ์ ์๊ฒ ๋์๊ธฐ ๋๋ฌธ์ด๋ค.

๋ง์ง๋ง์ผ๋ก, fedify/src/federation/middleware.test.ts์์๋ ๋ณ๊ฒฝ๋ ๊ธฐ๋ฅ์ ๋ง์ถฐ ํ ์คํธ ์ฝ๋๋ฅผ documentLoaderFactory ๋ฐฉ์์ผ๋ก ์์ ํ๋ค.

๋ํ, ํ ์คํธ ๊ฐ์ ์ถฉ๋์ ๋ฐฉ์งํ๊ณ ์ญํ ์ ๋ช ํํ ํ๊ณ ์ ์ด์ ์๋ ํ๋๋ก ์ฌ์ฉํ๋ ํ ์คํธ์ฉ ๊ฐ์ง ์๋ฒ ์ฃผ์๋ฅผ ์ผ๋ฐ ๊ฐ์ฒด ์กฐํ์ฉ(/object)๊ณผ ์ธ์ฆ ํ์ธ์ฉ(/auth-check)์ผ๋ก ๋๋์ด ๋ถ๋ฆฌํ๋ค.

2. contextLoader property ์ญ์
contextLoader ์ญ์ PR ๐ https://github.com/fedify-dev/fedify/pull/393
fix: Remove documentLoader property from FederationOptions interface by crohasang · Pull Request #393 · fedify-dev/fedify
Summary Remove documentLoader property from FederationOptions interface (use documentLoaderFactory instead) Related Issue Implemented Remove deprecated APIs for Fedify 2.0 #376 Changes In fedif...
github.com
๊ทธ๋ฆฌ๊ณ ์ด์ contextLoader property๋ฅผ ์ญ์ ํด๋ณด์. ์์์ documentLoader๋ ActivityPub ๊ฐ์ฒด๋ ๋ค๋ฅธ ๋ฐ์ดํฐ๋ฅผ ๋ํ๋ด๋ JSON-LD ๋ฌธ์๋ฅผ ์๊ฒฉ URL์์ ๊ฐ์ ธ์ค๋ ์ญํ ์ ํ๋ค๋ผ๊ณ ํ๋๋ฐ, ๊ทธ๋ฌ๋ฉด contextLoader๋ ๋ฌด์์ผ๊น?
→ contextLoader๋ JSON-LD ๋ฌธ์์ ์๋ฏธ๋ฅผ ํด์ํ๋ ๋ฐ ํ์ํ @context๋ฅผ ๊ฐ์ ธ์ค๋ ์ญํ ์ ํ๋ค.
ActivityPub์์ ์ฌ์ฉํ๋ ๋ฐ์ดํฐ ํ์์ธ JSON-LD๋ @context๋ผ๋ ํ๋๋ฅผ ์ฌ์ฉํ๋ค. ์ด @context ํ๋์๋ ์ฃผ๋ก ‘์ดํ ์ฌ์ ’ ํ์ผ์
์์น๋ฅผ ๊ฐ๋ฆฌํค๋ URL์ด ๋ค์ด๊ฐ๋ค. ์ด ์ฌ์ ์ ์ฐธ์กฐํจ์ผ๋ก์จ, ์ปดํจํฐ๋ "์ด ๋ฌธ์์์ Person์ '์ฌ์ฉ์ ํ๋กํ'์, Note๋ '๊ฒ์๋ฌผ'์ ์๋ฏธํ๋ค"์ ๊ฐ์ด ๊ฐ ์ฉ์ด์ ์ ํํ ์๋ฏธ๋ฅผ ํด์ํ ์ ์๊ฒ ๋๋ค.
์ฝ๋ ๋ณ๊ฒฝ
๋จผ์ , fedify/src/federation/federation.ts์์ contextLoader ์์ฑ์ ์์ด๋ค.
๊ทธ๋ฆฌ๊ณ fedify/src/federation/middleware.ts์์๋ allowPrivateAddress ๊ฐ์ ๋ณด์ ์ต์ ์ ์ผฐ๋ค๋ฉด, documentLoaderFactory์ contextLoaderFactory๋ฅผ ์ฌ์ฉํ์ง ๋ชปํ๋๋ก ํ๋ ์ฝ๋๋ฅผ ์ถ๊ฐํ๋ค.

fedify/src/federation/middleware.test.ts์์๋ contextLoader๋ฅผ contextLoaderFactory๋ก ๊ต์ฒดํด์ฃผ์๋ค.

์ด๋ ๊ฒ documentLoader์ contextLoader, ๋ ๊ฐ์ API๋ฅผ ์ ๋ฆฌํ๋ค. ์ด๋ฒ ์์ ์ ํตํด documentLoader์ contextLoader๊ฐ Fedify์์ ๋ฌด์จ ์ญํ ์ ํ๋์ง ์ ์ ์์๋ค. ์ด Loader๋ค์ Factory ํจ์๋ค๋ก ๋์ฒดํจ์ผ๋ก์จ ๋จ์ผ ๋ก๋ ๋ฐฉ์์์ ๋ฒ์ด๋ ์ํฉ์ ๋ง๋ ๋ง์ถคํ ๋ก๋๋ฅผ ๋์ ์ผ๋ก ์์ฑํ๋ ์ ์ฐํ ๊ตฌ์กฐ๋ฅผ ๊ฐ์ถ ์ ์๊ฒ ๋์๋ค.
์์ ์ธ๊ธํ๋ ์ด์๋ก ๋ค์ ๋์๊ฐ๋ณด๋ฉด Loader๋ค ์ด์ธ์๋ CreateFederationOptions, fetchDocumentLoader ๋ฑ ์ ๋ฆฌํด์ผ๋ API๊ฐ ์ฌ๋ฌ๊ฐ ์กด์ฌํ๋ค. ์ด API๋ค์ ์ญ์ ํ๋ ์์ ์ ์์ผ๋ก๋ ๊ณ์ ํ๋ค๋ฉด Fedify๊ฐ ์ด๋ป๊ฒ ๋์๊ฐ๋์ง ๋ ๊น๊ฒ ์ดํดํ ์ ์์ ๊ฒ ๊ฐ๋ค.