@seedprotocol/licensing 0.8.3 → 0.8.4-next.1913.g77fa9da
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/CHANGELOG.md +4 -0
- package/README.md +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/dist/offerInForce.d.ts +36 -0
- package/dist/offerInForce.d.ts.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented in this file.
|
|
4
4
|
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
- `offerInForce` and `licenseHistory`: which license offer is in force at a time, by the rule in ADR 0039.
|
|
8
|
+
|
|
5
9
|
## 0.8.3 (2026-11-23)
|
|
6
10
|
|
|
7
11
|
- New package: license terms, `termsHash`, SPDX parsing, the Creative Commons catalog, deeds and the license chooser.
|
package/README.md
CHANGED
|
@@ -47,6 +47,37 @@ catalog.byTermsHash(hash) // { module, terms } for a hash read from an offer
|
|
|
47
47
|
catalog.bySpdx('CC0-1.0')
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
## Offering a license onchain
|
|
51
|
+
|
|
52
|
+
A publisher offers a license by attesting a `licenseOffer` with a publish. The offer refers to the
|
|
53
|
+
item's Version and goes in the same transaction as its properties:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { ensureLicenseOfferSchema } from '@seedprotocol/publish'
|
|
57
|
+
|
|
58
|
+
await ensureLicenseOfferSchema(wallet) // once per chain, from any wallet that isn't a session key
|
|
59
|
+
const module = catalog.bySpdx('CC-BY-4.0')!
|
|
60
|
+
await item.publish({ licenseOffer: { termsHash: termsHash(module.toTerms()), spdx: module.spdx } })
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`getLicense` in `@seedprotocol/query` reads the license in force:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { getLicense, getLicenseHistory } from '@seedprotocol/query'
|
|
67
|
+
|
|
68
|
+
await getLicense({ seedUid }) // the newest Version, now
|
|
69
|
+
await getLicense({ seedUid, versionUid, asOf }) // a pinned Version at a time
|
|
70
|
+
// → { spdx, iri, termsHash, offerUid, legalTxId, sentence, revoked, since } | null
|
|
71
|
+
await getLicenseHistory(seedUid) // every change, oldest first
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
An offer governs content attested at or after it, never content published before it. A Version
|
|
75
|
+
read at a time is licensed by the newest offer attested at or before the newest attestation that
|
|
76
|
+
read shows, so an offer made without a publish governs nothing until the next one. A revoked offer
|
|
77
|
+
reads as All rights reserved from its revocation time. Only offers from the Seed's attester count.
|
|
78
|
+
`offerInForce` and `licenseHistory` apply the same rule to offers you have already read.
|
|
79
|
+
[ADR 0039](../../docs/adr/0039-license-offers-in-force-by-content-time.md) records the rule.
|
|
80
|
+
|
|
50
81
|
## SPDX and URLs
|
|
51
82
|
|
|
52
83
|
`parseSpdx(expression)` parses SPDX license expressions against the SPDX License List 3.29.0
|
package/dist/index.d.ts
CHANGED
|
@@ -16,4 +16,6 @@ export type { Domain, LicenseCatalog, LicenseModule } from './catalog/types.js';
|
|
|
16
16
|
export type { Chooser, ChooserQuestion } from './catalog/chooser.js';
|
|
17
17
|
export { validateTerms } from './validate.js';
|
|
18
18
|
export type { TermsValidationError, TermsValidationResult } from './validate.js';
|
|
19
|
+
export { licenseHistory, offerInForce } from './offerInForce.js';
|
|
20
|
+
export type { LicenseInForce, LicenseOfferRecord } from './offerInForce.js';
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,kB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region src/offerInForce.ts
|
|
203
|
+
function j(e) {
|
|
204
|
+
let t = [];
|
|
205
|
+
for (let n of e) t.push({
|
|
206
|
+
time: n.timeCreated,
|
|
207
|
+
offer: n,
|
|
208
|
+
revocation: !1
|
|
209
|
+
}), n.revocationTime > 0 && t.push({
|
|
210
|
+
time: n.revocationTime,
|
|
211
|
+
offer: n,
|
|
212
|
+
revocation: !0
|
|
213
|
+
});
|
|
214
|
+
return t.sort((e, t) => e.time - t.time || Number(e.revocation) - Number(t.revocation) || (e.offer.uid < t.offer.uid ? -1 : +(e.offer.uid > t.offer.uid)));
|
|
215
|
+
}
|
|
216
|
+
function M(e) {
|
|
217
|
+
let t = [];
|
|
218
|
+
for (let n of j(e)) {
|
|
219
|
+
let e = t.at(-1);
|
|
220
|
+
n.revocation ? e && e.offer === n.offer && !e.revoked && t.push({
|
|
221
|
+
offer: n.offer,
|
|
222
|
+
revoked: !0,
|
|
223
|
+
since: n.time
|
|
224
|
+
}) : t.push({
|
|
225
|
+
offer: n.offer,
|
|
226
|
+
revoked: !1,
|
|
227
|
+
since: n.time
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return t;
|
|
231
|
+
}
|
|
232
|
+
function N(e, t) {
|
|
233
|
+
if (!Number.isFinite(t)) throw RangeError(`time must be unix seconds, got ${t}`);
|
|
234
|
+
return M(e).filter((e) => e.since <= t).at(-1) ?? null;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
export { s as CanonicalJsonError, i as InvalidLicenseTermsError, n as SPDX_LIST_VERSION, o as TERMS_PROFILE, r as UnsupportedLocaleError, c as canonicalJson, A as createLicenseCatalog, k as fromUrl, u as isKnownSpdxId, M as licenseHistory, N as offerInForce, t as parseSpdx, x as renderDeed, S as summarySentence, l as termsHash, e as validateTerms };
|
|
203
238
|
|
|
204
239
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["validateTerms","parseSpdx","SPDX_LIST_VERSION","UnsupportedLocaleError","InvalidLicenseTermsError","catalogUrlTable","TERMS_PROFILE","CanonicalJsonError","canonicalJson","termsHash","EN_RULE_TEXT","EN_SEE_LEGAL_TEXT","enDisclaimer","location","sha256","EN_EXCEPTIONS_NOTE","EN_MORAL_RIGHTS_NOTE","EN_NONCOMMERCIAL_NOTE","RULE_IDS","SECTION_OF","deriveRules","fired","claimedPermissions","claimedProhibitions","claimedDuties","find","list","r","action","target","permit","terms","prohibit","claim","indexes","set","i","use","reproduce","distribute","derive","distributeAdaptation","commercialize","rule","duty","hasPermissions","noCommercial","noAdaptations","uncovered","id","assertLocale","locale","renderDeed","options","sections","rules","section","notCovered","deed","summarySentence","has","tail","CC_LICENSE","CC_ZERO","SPDX_PAGE","normalize","host","url","path","keepCase","table","catalogUrls","spdx","fromUrl","parsed","license","code","version","port","isKnownSpdxId","page","createLicenseCatalog","byId","bySpdx","byHash","module","modules","error","result","filter","m","hash"],"sources":["../src/deed/en.ts","../src/deed/rules.ts","../src/deed/renderDeed.ts","../src/deed/summarySentence.ts","../src/fromUrl.ts","../src/catalog/createLicenseCatalog.ts"],"sourcesContent":["import type { RuleId } from './rules'\n\n/** Deed template seed-deed/1.0.0, English. Draft copy, not yet reviewed by counsel. */\nexport const EN_RULE_TEXT: Record<RuleId, string> = {\n 'use-any-purpose': 'Use it for any purpose.',\n share: 'Share it: copy and redistribute it in any medium or format.',\n adapt: 'Adapt it: remix, transform and build on it, and share what you make.',\n 'commercial-use': 'Use it commercially.',\n attribution: 'Give credit: name the creator, link to the license and say if you changed it.',\n 'include-notice': 'Keep the copyright and license notices that come with it.',\n 'share-alike': 'Share adaptations under the same license.',\n 'no-conditions': \"Nothing. You don't need to give credit.\",\n noncommercial: 'Use it for commercial purposes.',\n 'no-derivatives': 'Share adapted versions. You may adapt it for your own use.',\n 'permission-required': \"Republish, share or adapt it without the rights holder's permission.\",\n 'lasts-copyright-term': 'The license lasts as long as the copyright does.',\n 'ends-on-breach': 'It ends if you break its terms. The legal text says how it can be restored.',\n irrevocable: \"The creator can't withdraw it from anything already shared under it.\",\n 'as-is': \"No warranties: it comes as is, and the creator doesn't promise to hold every right you might need.\",\n}\n\nexport const EN_SEE_LEGAL_TEXT = 'Further conditions apply; see the legal text.'\n\nexport const enDisclaimer = (location: string, sha256: string) =>\n `This summary is not the license; the legal text at ${location} (sha256 ${sha256}) governs.`\n\nexport const EN_EXCEPTIONS_NOTE = 'Exceptions and limitations to copyright, such as fair use, still apply.'\n\n/** Left out for a waiver such as CC0, which waives these rights too. */\nexport const EN_MORAL_RIGHTS_NOTE = 'Moral rights, privacy and publicity rights are not covered.'\n\nexport const EN_NONCOMMERCIAL_NOTE = 'What counts as non-commercial is defined by the legal text, not this summary.'\n","import type { Rule, SeedLicenseTerms } from '../terms'\n\nexport type DeedSection = 'youCan' | 'youMust' | 'youCannot' | 'whenTimeRunsOut' | 'creatorPromises'\n\nexport const RULE_IDS = [\n 'use-any-purpose',\n 'share',\n 'adapt',\n 'commercial-use',\n 'attribution',\n 'include-notice',\n 'share-alike',\n 'no-conditions',\n 'noncommercial',\n 'no-derivatives',\n 'permission-required',\n 'lasts-copyright-term',\n 'ends-on-breach',\n 'irrevocable',\n 'as-is',\n] as const\nexport type RuleId = (typeof RULE_IDS)[number]\n\nexport const SECTION_OF: Record<RuleId, DeedSection> = {\n 'use-any-purpose': 'youCan',\n share: 'youCan',\n adapt: 'youCan',\n 'commercial-use': 'youCan',\n attribution: 'youMust',\n 'include-notice': 'youMust',\n 'share-alike': 'youMust',\n 'no-conditions': 'youMust',\n noncommercial: 'youCannot',\n 'no-derivatives': 'youCannot',\n 'permission-required': 'youCannot',\n 'lasts-copyright-term': 'whenTimeRunsOut',\n 'ends-on-breach': 'whenTimeRunsOut',\n irrevocable: 'creatorPromises',\n 'as-is': 'creatorPromises',\n}\n\nexport type DerivedRules = {\n /** In vocabulary order. */\n rules: RuleId[]\n /** Sections holding a term no rule covers. */\n uncovered: DeedSection[]\n}\n\n/**\n * Which rules the terms trigger. Each rule claims the term elements it describes; a permission,\n * prohibition or duty that no rule claims, or any transition or post-term block, is reported as\n * uncovered so the deed points to the legal text instead of leaving it out. A rule with\n * constraints is never claimed: the 1.0.0 vocabulary has no sentences for constraints.\n */\nexport function deriveRules(terms: SeedLicenseTerms): DerivedRules {\n const fired = new Set<RuleId>()\n const claimedPermissions = new Set<number>()\n const claimedProhibitions = new Set<number>()\n const claimedDuties = new Set<number>()\n\n const find = (list: Rule[], action: string, target = 'work') =>\n list.findIndex((r) => r.action === action && (r.target ?? 'work') === target && !r.constraints?.length)\n const permit = (action: string, target?: string) => find(terms.permissions, action, target)\n const prohibit = (action: string, target?: string) => find(terms.prohibitions, action, target)\n const claim = (set: Set<number>, ...indexes: number[]) => indexes.forEach((i) => set.add(i))\n\n const use = permit('use')\n if (use >= 0) {\n fired.add('use-any-purpose')\n claim(claimedPermissions, use)\n }\n const reproduce = permit('reproduce')\n const distribute = permit('distribute')\n if (reproduce >= 0 && distribute >= 0) {\n fired.add('share')\n claim(claimedPermissions, reproduce, distribute)\n }\n const derive = permit('derive')\n const distributeAdaptation = permit('distribute', 'adaptation')\n if (derive >= 0 && distributeAdaptation >= 0) {\n fired.add('adapt')\n claim(claimedPermissions, derive, distributeAdaptation)\n }\n const commercialize = permit('commercialize')\n if (commercialize >= 0) {\n fired.add('commercial-use')\n claim(claimedPermissions, commercialize)\n }\n\n terms.duties.forEach((duty, i) => {\n const rule = ({ attribute: 'attribution', includeNotice: 'include-notice', shareAlike: 'share-alike' } as const)[\n duty.duty as 'attribute' | 'includeNotice' | 'shareAlike'\n ]\n // A share-alike duty naming another license needs the legal text.\n if (rule && !(duty.duty === 'shareAlike' && duty.license)) {\n fired.add(rule)\n claim(claimedDuties, i)\n }\n })\n\n const hasPermissions = terms.permissions.length > 0\n if (hasPermissions && terms.duties.length === 0) fired.add('no-conditions')\n\n const noCommercial = prohibit('commercialize')\n if (noCommercial >= 0) {\n fired.add('noncommercial')\n claim(claimedProhibitions, noCommercial)\n }\n const noAdaptations = prohibit('distribute', 'adaptation')\n if (noAdaptations >= 0) {\n fired.add('no-derivatives')\n claim(claimedProhibitions, noAdaptations)\n // Making an adaptation for yourself stays allowed; the no-derivatives sentence says so.\n if (derive >= 0) claim(claimedPermissions, derive)\n }\n if (!hasPermissions) fired.add('permission-required')\n\n if (hasPermissions) {\n if (terms.grant.duration === 'copyright-term') fired.add('lasts-copyright-term')\n if (terms.grant.revocableFor === 'breach-only') fired.add('ends-on-breach')\n fired.add('irrevocable')\n if (terms.grant.warranty === 'as-is') fired.add('as-is')\n }\n\n const uncovered = new Set<DeedSection>()\n if (terms.permissions.some((_, i) => !claimedPermissions.has(i))) uncovered.add('youCan')\n if (terms.duties.some((_, i) => !claimedDuties.has(i))) uncovered.add('youMust')\n if (terms.prohibitions.some((_, i) => !claimedProhibitions.has(i))) uncovered.add('youCannot')\n if (terms.transition || terms.postTerm || (hasPermissions && terms.grant.duration !== 'copyright-term')) uncovered.add('whenTimeRunsOut')\n if (hasPermissions && terms.grant.warranty !== 'as-is') uncovered.add('creatorPromises')\n\n return { rules: RULE_IDS.filter((id) => fired.has(id)), uncovered: [...uncovered] }\n}\n","import { UnsupportedLocaleError } from '../errors'\nimport type { SeedLicenseTerms } from '../terms'\nimport { EN_EXCEPTIONS_NOTE, EN_MORAL_RIGHTS_NOTE, EN_NONCOMMERCIAL_NOTE, EN_RULE_TEXT, EN_SEE_LEGAL_TEXT, enDisclaimer } from './en'\nimport { deriveRules, SECTION_OF, type DeedSection, type RuleId } from './rules'\n\nexport type DeedLine = { rule: RuleId | 'see-legal-text'; text: string }\n\nexport interface Deed {\n template: 'seed-deed/1.0.0'\n /** False until counsel reviews the sentence templates. */\n reviewed: false\n disclaimer: string\n youCan: DeedLine[]\n youMust: DeedLine[]\n youCannot: DeedLine[]\n whenTimeRunsOut: DeedLine[]\n creatorPromises: DeedLine[]\n notCovered: string[]\n stewardDeedUrl?: string\n}\n\nexport type RenderDeedOptions = {\n locale: 'en'\n /** Where the legal text is served; default `terms.legal.canonicalUrl`. */\n legalLocation?: string\n /** The steward's own deed, passed through for the UI to link. */\n stewardDeedUrl?: string\n}\n\nexport function assertLocale(locale: string): void {\n if (locale !== 'en') throw new UnsupportedLocaleError(locale)\n}\n\n/**\n * The plain-language summary of license terms, as data. Every line names the rule it came from;\n * a term no rule covers becomes one \"see the legal text\" line in its section.\n */\nexport function renderDeed(terms: SeedLicenseTerms, options: RenderDeedOptions): Deed {\n assertLocale(options.locale)\n const { rules, uncovered } = deriveRules(terms)\n const sections: Record<DeedSection, DeedLine[]> = {\n youCan: [],\n youMust: [],\n youCannot: [],\n whenTimeRunsOut: [],\n creatorPromises: [],\n }\n for (const rule of rules) sections[SECTION_OF[rule]].push({ rule, text: EN_RULE_TEXT[rule] })\n for (const section of uncovered) sections[section].push({ rule: 'see-legal-text', text: EN_SEE_LEGAL_TEXT })\n\n // A waiver: everything permitted, nothing owed, never withdrawn (CC0 1.0 §2 waives moral rights too).\n const waiver = terms.permissions.length > 0 && terms.duties.length === 0 && terms.grant.revocableFor === 'never'\n const notCovered: string[] = waiver ? [EN_EXCEPTIONS_NOTE] : [EN_EXCEPTIONS_NOTE, EN_MORAL_RIGHTS_NOTE]\n if (rules.includes('noncommercial')) notCovered.push(EN_NONCOMMERCIAL_NOTE)\n\n const deed: Deed = {\n template: 'seed-deed/1.0.0',\n reviewed: false,\n disclaimer: enDisclaimer(options.legalLocation ?? terms.legal.canonicalUrl, terms.legal.sha256),\n ...sections,\n notCovered,\n }\n if (options.stewardDeedUrl) deed.stewardDeedUrl = options.stewardDeedUrl\n return deed\n}\n","import type { SeedLicenseTerms } from '../terms'\nimport { assertLocale } from './renderDeed'\nimport { deriveRules } from './rules'\n\n/**\n * One sentence that says what others may do, built from the same rules as the deed. Terms with a\n * condition the rules don't cover end with \"Other conditions apply.\" rather than leaving it out.\n */\nexport function summarySentence(terms: SeedLicenseTerms, options: { locale: 'en' }): string {\n assertLocale(options.locale)\n const { rules, uncovered } = deriveRules(terms)\n const has = (rule: (typeof rules)[number]) => rules.includes(rule)\n const tail = uncovered.length > 0 ? ' Other conditions apply.' : ''\n\n if (has('permission-required')) return `Others need permission to republish this.${tail}`\n if (has('no-conditions') && has('use-any-purpose')) return `Anyone may use it for any purpose, with no conditions.${tail}`\n\n const verb = has('adapt') ? 'republish and adapt it' : has('no-derivatives') ? 'republish it unchanged' : 'republish it'\n const parts = [\n verb,\n has('commercial-use') ? ', including commercially,' : '',\n has('attribution') ? ' with credit' : '',\n has('share-alike') ? ', if they share adaptations under the same license' : '',\n has('noncommercial') ? ', but not commercially' : '',\n ]\n return `Anyone may ${parts.join('').replace(/,$/, '')}.${tail}`\n}\n","import { catalogUrlTable } from './catalog/cc/urls'\nimport { isKnownSpdxId } from './spdx/parse'\n\nconst CC_LICENSE = /^\\/licenses\\/(by|by-sa|by-nc|by-nc-sa|by-nd|by-nc-nd)\\/(\\d+\\.\\d+)(?:\\/([a-z]{2,3}))?(?:\\/(?:deed\\.[a-z-]+|legalcode(?:\\.[a-z-]+)?))?$/\nconst CC_ZERO = /^\\/publicdomain\\/zero\\/1\\.0(?:\\/(?:deed\\.[a-z-]+|legalcode(?:\\.[a-z-]+)?))?$/\nconst SPDX_PAGE = /^\\/licenses\\/([A-Za-z0-9.+-]+?)(?:\\.html|\\.json)?$/\n\n/** host without `www.`, then the path without a trailing slash, lowercased unless asked. */\nfunction normalize(url: URL, keepCase = false): { host: string; path: string } {\n const host = url.hostname.toLowerCase().replace(/^www\\./, '')\n const path = url.pathname.replace(/\\/+$/, '')\n return { host, path: keepCase ? path : path.toLowerCase() }\n}\n\nlet table: Map<string, string> | undefined\nfunction catalogUrls(): Map<string, string> {\n if (!table) {\n table = new Map()\n for (const [url, spdx] of catalogUrlTable()) {\n const { host, path } = normalize(new URL(url))\n table.set(host + path, spdx)\n }\n }\n return table\n}\n\n/**\n * The SPDX id a license URL names, or null. Reads Creative Commons license, deed and legal-code\n * URLs of any version and jurisdiction port, CC0, spdx.org license pages, and the catalog's own\n * URLs. An id is returned only when the SPDX list has it. Never throws.\n */\nexport function fromUrl(url: string): string | null {\n let parsed: URL\n try {\n parsed = new URL(url.trim())\n } catch {\n return null\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null\n const { host, path } = normalize(parsed)\n\n if (host === 'creativecommons.org') {\n const license = CC_LICENSE.exec(path)\n if (license) {\n const [, code, version, port] = license\n return isKnownSpdxId(`CC-${code}-${version}${port ? `-${port}` : ''}`) ?? null\n }\n if (CC_ZERO.test(path)) return 'CC0-1.0'\n }\n if (host === 'spdx.org') {\n const page = SPDX_PAGE.exec(normalize(parsed, true).path)\n if (page) return isKnownSpdxId(page[1]!) ?? null\n }\n return catalogUrls().get(host + path) ?? null\n}\n","import { termsHash } from '../hash'\nimport { validateTerms } from '../validate'\nimport type { LicenseCatalog, LicenseModule } from './types'\n\n/**\n * An index over the modules given. Throws on a duplicate id or SPDX id, and on a module whose terms\n * fail `validateTerms`, naming the module.\n */\nexport function createLicenseCatalog(modules: readonly LicenseModule<any>[]): LicenseCatalog {\n const byId = new Map<string, LicenseModule<any>>()\n const bySpdx = new Map<string, LicenseModule<any>>()\n const byHash = new Map<string, LicenseModule<any>>()\n\n for (const module of modules) {\n if (byId.has(module.id)) throw new Error(`Duplicate license module id ${module.id}`)\n if (bySpdx.has(module.spdx)) throw new Error(`Duplicate SPDX id ${module.spdx} (${module.id})`)\n byId.set(module.id, module)\n bySpdx.set(module.spdx, module)\n let terms: unknown\n try {\n terms = module.toTerms()\n } catch (error) {\n throw new Error(`License module ${module.id}: toTerms failed: ${(error as Error).message}`)\n }\n const result = validateTerms(terms)\n if (!result.ok) {\n throw new Error(`License module ${module.id} has invalid terms: ${result.errors.map((e) => `${e.path} ${e.message}`).join('; ')}`)\n }\n byHash.set(termsHash(result.terms), module)\n }\n\n return {\n list: (filter) => (filter?.domain ? modules.filter((m) => m.domains.includes(filter.domain!)) : [...modules]),\n get: (id) => byId.get(id),\n bySpdx: (spdx) => bySpdx.get(spdx),\n byTermsHash: (hash) => {\n const module = byHash.get(hash.toLowerCase())\n return module ? { module, terms: module.toTerms() } : undefined\n },\n }\n}\n"],"mappings":";;AAGA,IAAaU,IAAuC;CAClD,mBAAmB;CACnB,OAAO;CACP,OAAO;CACP,kBAAkB;CAClB,aAAa;CACb,kBAAkB;CAClB,eAAe;CACf,iBAAiB;CACjB,eAAe;CACf,kBAAkB;CAClB,uBAAuB;CACvB,wBAAwB;CACxB,kBAAkB;CAClB,aAAa;CACb,SAAS;AACX,GAEaC,IAAoB,iDAEpBC,KAAgB,GAAkB,MAC7C,sDAAsDC,EAAS,WAAWC,EAAO,aAEtEC,IAAqB,2EAGrBC,IAAuB,+DAEvBC,IAAwB,iFC3BxBC,IAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAGaC,IAA0C;CACrD,mBAAmB;CACnB,OAAO;CACP,OAAO;CACP,kBAAkB;CAClB,aAAa;CACb,kBAAkB;CAClB,eAAe;CACf,iBAAiB;CACjB,eAAe;CACf,kBAAkB;CAClB,uBAAuB;CACvB,wBAAwB;CACxB,kBAAkB;CAClB,aAAa;CACb,SAAS;AACX;AAeA,SAAgBC,EAAY,GAAuC;CACjE,IAAMC,oBAAQ,IAAI,IAAY,GACxBC,oBAAqB,IAAI,IAAY,GACrCC,oBAAsB,IAAI,IAAY,GACtCC,oBAAgB,IAAI,IAAY,GAEhCC,KAAQ,GAAc,GAAgB,IAAS,WACnDC,EAAK,WAAW,MAAMC,EAAE,WAAWC,MAAWD,EAAE,UAAU,YAAYE,KAAU,CAACF,EAAE,aAAa,MAAM,GAClGG,KAAU,GAAgB,MAAoBL,EAAKM,EAAM,aAAaH,GAAQC,CAAM,GACpFG,KAAY,GAAgB,MAAoBP,EAAKM,EAAM,cAAcH,GAAQC,CAAM,GACvFI,KAAS,GAAkB,GAAGC,MAAsBA,EAAQ,S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BAAS,IAAI,IAAgC;CAEnD,KAAK,IAAMC,KAAUC,GAAS;EAC5B,IAAIJ,EAAK,IAAIG,EAAO,EAAE,GAAG,MAAU,MAAM,+BAA+BA,EAAO,IAAI;EACnF,IAAIF,EAAO,IAAIE,EAAO,IAAI,GAAG,MAAU,MAAM,qBAAqBA,EAAO,KAAK,IAAIA,EAAO,GAAG,EAAE;EAE9F,AADAH,EAAK,IAAIG,EAAO,IAAIA,CAAM,GAC1BF,EAAO,IAAIE,EAAO,MAAMA,CAAM;EAC9B,IAAItD;EACJ,IAAI;GACF,IAAQsD,EAAO,QAAQ;EACzB,SAASE,GAAO;GACd,MAAU,MAAM,kBAAkBF,EAAO,GAAG,oBAAqBE,EAAgB,SAAS;EAC5F;EACA,IAAMC,IAASxF,EAAc+B,CAAK;EAClC,IAAI,CAACyD,EAAO,IACV,MAAU,MAAM,kBAAkBH,EAAO,GAAG,sBAAsBG,EAAO,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,GAAG,EAAE,SAAS,CAAC,CAAC,KAAK,IAAI,GAAG;EAEnI,EAAO,IAAI/E,EAAU+E,EAAO,KAAK,GAAGH,CAAM;CAC5C;CAEA,OAAO;EACL,OAAO,MAAYI,GAAQ,SAASH,EAAQ,QAAQ,MAAMI,EAAE,QAAQ,SAASD,EAAO,MAAO,CAAC,IAAI,CAAC,GAAGH,CAAO;EAC3G,MAAM,MAAOJ,EAAK,IAAIjC,CAAE;EACxB,SAAS,MAASkC,EAAO,IAAIX,CAAI;EACjC,cAAc,MAAS;GACrB,IAAMa,IAASD,EAAO,IAAIO,EAAK,YAAY,CAAC;GAC5C,OAAON,IAAS;IAAE;IAAQ,OAAOA,EAAO,QAAQ;GAAE,IAAI,KAAA;EACxD;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["validateTerms","parseSpdx","SPDX_LIST_VERSION","UnsupportedLocaleError","InvalidLicenseTermsError","catalogUrlTable","TERMS_PROFILE","CanonicalJsonError","canonicalJson","termsHash","EN_RULE_TEXT","EN_SEE_LEGAL_TEXT","enDisclaimer","location","sha256","EN_EXCEPTIONS_NOTE","EN_MORAL_RIGHTS_NOTE","EN_NONCOMMERCIAL_NOTE","RULE_IDS","SECTION_OF","deriveRules","fired","claimedPermissions","claimedProhibitions","claimedDuties","find","list","r","action","target","permit","terms","prohibit","claim","indexes","set","i","use","reproduce","distribute","derive","distributeAdaptation","commercialize","rule","duty","hasPermissions","noCommercial","noAdaptations","uncovered","id","assertLocale","locale","renderDeed","options","sections","rules","section","notCovered","deed","summarySentence","has","tail","CC_LICENSE","CC_ZERO","SPDX_PAGE","normalize","host","url","path","keepCase","table","catalogUrls","spdx","fromUrl","parsed","license","code","version","port","isKnownSpdxId","page","createLicenseCatalog","byId","bySpdx","byHash","module","modules","error","result","filter","m","hash","events","all","offer","offers","a","b","licenseHistory","history","event","current","offerInForce","time","entry"],"sources":["../src/deed/en.ts","../src/deed/rules.ts","../src/deed/renderDeed.ts","../src/deed/summarySentence.ts","../src/fromUrl.ts","../src/catalog/createLicenseCatalog.ts","../src/offerInForce.ts"],"sourcesContent":["import type { RuleId } from './rules'\n\n/** Deed template seed-deed/1.0.0, English. Draft copy, not yet reviewed by counsel. */\nexport const EN_RULE_TEXT: Record<RuleId, string> = {\n 'use-any-purpose': 'Use it for any purpose.',\n share: 'Share it: copy and redistribute it in any medium or format.',\n adapt: 'Adapt it: remix, transform and build on it, and share what you make.',\n 'commercial-use': 'Use it commercially.',\n attribution: 'Give credit: name the creator, link to the license and say if you changed it.',\n 'include-notice': 'Keep the copyright and license notices that come with it.',\n 'share-alike': 'Share adaptations under the same license.',\n 'no-conditions': \"Nothing. You don't need to give credit.\",\n noncommercial: 'Use it for commercial purposes.',\n 'no-derivatives': 'Share adapted versions. You may adapt it for your own use.',\n 'permission-required': \"Republish, share or adapt it without the rights holder's permission.\",\n 'lasts-copyright-term': 'The license lasts as long as the copyright does.',\n 'ends-on-breach': 'It ends if you break its terms. The legal text says how it can be restored.',\n irrevocable: \"The creator can't withdraw it from anything already shared under it.\",\n 'as-is': \"No warranties: it comes as is, and the creator doesn't promise to hold every right you might need.\",\n}\n\nexport const EN_SEE_LEGAL_TEXT = 'Further conditions apply; see the legal text.'\n\nexport const enDisclaimer = (location: string, sha256: string) =>\n `This summary is not the license; the legal text at ${location} (sha256 ${sha256}) governs.`\n\nexport const EN_EXCEPTIONS_NOTE = 'Exceptions and limitations to copyright, such as fair use, still apply.'\n\n/** Left out for a waiver such as CC0, which waives these rights too. */\nexport const EN_MORAL_RIGHTS_NOTE = 'Moral rights, privacy and publicity rights are not covered.'\n\nexport const EN_NONCOMMERCIAL_NOTE = 'What counts as non-commercial is defined by the legal text, not this summary.'\n","import type { Rule, SeedLicenseTerms } from '../terms'\n\nexport type DeedSection = 'youCan' | 'youMust' | 'youCannot' | 'whenTimeRunsOut' | 'creatorPromises'\n\nexport const RULE_IDS = [\n 'use-any-purpose',\n 'share',\n 'adapt',\n 'commercial-use',\n 'attribution',\n 'include-notice',\n 'share-alike',\n 'no-conditions',\n 'noncommercial',\n 'no-derivatives',\n 'permission-required',\n 'lasts-copyright-term',\n 'ends-on-breach',\n 'irrevocable',\n 'as-is',\n] as const\nexport type RuleId = (typeof RULE_IDS)[number]\n\nexport const SECTION_OF: Record<RuleId, DeedSection> = {\n 'use-any-purpose': 'youCan',\n share: 'youCan',\n adapt: 'youCan',\n 'commercial-use': 'youCan',\n attribution: 'youMust',\n 'include-notice': 'youMust',\n 'share-alike': 'youMust',\n 'no-conditions': 'youMust',\n noncommercial: 'youCannot',\n 'no-derivatives': 'youCannot',\n 'permission-required': 'youCannot',\n 'lasts-copyright-term': 'whenTimeRunsOut',\n 'ends-on-breach': 'whenTimeRunsOut',\n irrevocable: 'creatorPromises',\n 'as-is': 'creatorPromises',\n}\n\nexport type DerivedRules = {\n /** In vocabulary order. */\n rules: RuleId[]\n /** Sections holding a term no rule covers. */\n uncovered: DeedSection[]\n}\n\n/**\n * Which rules the terms trigger. Each rule claims the term elements it describes; a permission,\n * prohibition or duty that no rule claims, or any transition or post-term block, is reported as\n * uncovered so the deed points to the legal text instead of leaving it out. A rule with\n * constraints is never claimed: the 1.0.0 vocabulary has no sentences for constraints.\n */\nexport function deriveRules(terms: SeedLicenseTerms): DerivedRules {\n const fired = new Set<RuleId>()\n const claimedPermissions = new Set<number>()\n const claimedProhibitions = new Set<number>()\n const claimedDuties = new Set<number>()\n\n const find = (list: Rule[], action: string, target = 'work') =>\n list.findIndex((r) => r.action === action && (r.target ?? 'work') === target && !r.constraints?.length)\n const permit = (action: string, target?: string) => find(terms.permissions, action, target)\n const prohibit = (action: string, target?: string) => find(terms.prohibitions, action, target)\n const claim = (set: Set<number>, ...indexes: number[]) => indexes.forEach((i) => set.add(i))\n\n const use = permit('use')\n if (use >= 0) {\n fired.add('use-any-purpose')\n claim(claimedPermissions, use)\n }\n const reproduce = permit('reproduce')\n const distribute = permit('distribute')\n if (reproduce >= 0 && distribute >= 0) {\n fired.add('share')\n claim(claimedPermissions, reproduce, distribute)\n }\n const derive = permit('derive')\n const distributeAdaptation = permit('distribute', 'adaptation')\n if (derive >= 0 && distributeAdaptation >= 0) {\n fired.add('adapt')\n claim(claimedPermissions, derive, distributeAdaptation)\n }\n const commercialize = permit('commercialize')\n if (commercialize >= 0) {\n fired.add('commercial-use')\n claim(claimedPermissions, commercialize)\n }\n\n terms.duties.forEach((duty, i) => {\n const rule = ({ attribute: 'attribution', includeNotice: 'include-notice', shareAlike: 'share-alike' } as const)[\n duty.duty as 'attribute' | 'includeNotice' | 'shareAlike'\n ]\n // A share-alike duty naming another license needs the legal text.\n if (rule && !(duty.duty === 'shareAlike' && duty.license)) {\n fired.add(rule)\n claim(claimedDuties, i)\n }\n })\n\n const hasPermissions = terms.permissions.length > 0\n if (hasPermissions && terms.duties.length === 0) fired.add('no-conditions')\n\n const noCommercial = prohibit('commercialize')\n if (noCommercial >= 0) {\n fired.add('noncommercial')\n claim(claimedProhibitions, noCommercial)\n }\n const noAdaptations = prohibit('distribute', 'adaptation')\n if (noAdaptations >= 0) {\n fired.add('no-derivatives')\n claim(claimedProhibitions, noAdaptations)\n // Making an adaptation for yourself stays allowed; the no-derivatives sentence says so.\n if (derive >= 0) claim(claimedPermissions, derive)\n }\n if (!hasPermissions) fired.add('permission-required')\n\n if (hasPermissions) {\n if (terms.grant.duration === 'copyright-term') fired.add('lasts-copyright-term')\n if (terms.grant.revocableFor === 'breach-only') fired.add('ends-on-breach')\n fired.add('irrevocable')\n if (terms.grant.warranty === 'as-is') fired.add('as-is')\n }\n\n const uncovered = new Set<DeedSection>()\n if (terms.permissions.some((_, i) => !claimedPermissions.has(i))) uncovered.add('youCan')\n if (terms.duties.some((_, i) => !claimedDuties.has(i))) uncovered.add('youMust')\n if (terms.prohibitions.some((_, i) => !claimedProhibitions.has(i))) uncovered.add('youCannot')\n if (terms.transition || terms.postTerm || (hasPermissions && terms.grant.duration !== 'copyright-term')) uncovered.add('whenTimeRunsOut')\n if (hasPermissions && terms.grant.warranty !== 'as-is') uncovered.add('creatorPromises')\n\n return { rules: RULE_IDS.filter((id) => fired.has(id)), uncovered: [...uncovered] }\n}\n","import { UnsupportedLocaleError } from '../errors'\nimport type { SeedLicenseTerms } from '../terms'\nimport { EN_EXCEPTIONS_NOTE, EN_MORAL_RIGHTS_NOTE, EN_NONCOMMERCIAL_NOTE, EN_RULE_TEXT, EN_SEE_LEGAL_TEXT, enDisclaimer } from './en'\nimport { deriveRules, SECTION_OF, type DeedSection, type RuleId } from './rules'\n\nexport type DeedLine = { rule: RuleId | 'see-legal-text'; text: string }\n\nexport interface Deed {\n template: 'seed-deed/1.0.0'\n /** False until counsel reviews the sentence templates. */\n reviewed: false\n disclaimer: string\n youCan: DeedLine[]\n youMust: DeedLine[]\n youCannot: DeedLine[]\n whenTimeRunsOut: DeedLine[]\n creatorPromises: DeedLine[]\n notCovered: string[]\n stewardDeedUrl?: string\n}\n\nexport type RenderDeedOptions = {\n locale: 'en'\n /** Where the legal text is served; default `terms.legal.canonicalUrl`. */\n legalLocation?: string\n /** The steward's own deed, passed through for the UI to link. */\n stewardDeedUrl?: string\n}\n\nexport function assertLocale(locale: string): void {\n if (locale !== 'en') throw new UnsupportedLocaleError(locale)\n}\n\n/**\n * The plain-language summary of license terms, as data. Every line names the rule it came from;\n * a term no rule covers becomes one \"see the legal text\" line in its section.\n */\nexport function renderDeed(terms: SeedLicenseTerms, options: RenderDeedOptions): Deed {\n assertLocale(options.locale)\n const { rules, uncovered } = deriveRules(terms)\n const sections: Record<DeedSection, DeedLine[]> = {\n youCan: [],\n youMust: [],\n youCannot: [],\n whenTimeRunsOut: [],\n creatorPromises: [],\n }\n for (const rule of rules) sections[SECTION_OF[rule]].push({ rule, text: EN_RULE_TEXT[rule] })\n for (const section of uncovered) sections[section].push({ rule: 'see-legal-text', text: EN_SEE_LEGAL_TEXT })\n\n // A waiver: everything permitted, nothing owed, never withdrawn (CC0 1.0 §2 waives moral rights too).\n const waiver = terms.permissions.length > 0 && terms.duties.length === 0 && terms.grant.revocableFor === 'never'\n const notCovered: string[] = waiver ? [EN_EXCEPTIONS_NOTE] : [EN_EXCEPTIONS_NOTE, EN_MORAL_RIGHTS_NOTE]\n if (rules.includes('noncommercial')) notCovered.push(EN_NONCOMMERCIAL_NOTE)\n\n const deed: Deed = {\n template: 'seed-deed/1.0.0',\n reviewed: false,\n disclaimer: enDisclaimer(options.legalLocation ?? terms.legal.canonicalUrl, terms.legal.sha256),\n ...sections,\n notCovered,\n }\n if (options.stewardDeedUrl) deed.stewardDeedUrl = options.stewardDeedUrl\n return deed\n}\n","import type { SeedLicenseTerms } from '../terms'\nimport { assertLocale } from './renderDeed'\nimport { deriveRules } from './rules'\n\n/**\n * One sentence that says what others may do, built from the same rules as the deed. Terms with a\n * condition the rules don't cover end with \"Other conditions apply.\" rather than leaving it out.\n */\nexport function summarySentence(terms: SeedLicenseTerms, options: { locale: 'en' }): string {\n assertLocale(options.locale)\n const { rules, uncovered } = deriveRules(terms)\n const has = (rule: (typeof rules)[number]) => rules.includes(rule)\n const tail = uncovered.length > 0 ? ' Other conditions apply.' : ''\n\n if (has('permission-required')) return `Others need permission to republish this.${tail}`\n if (has('no-conditions') && has('use-any-purpose')) return `Anyone may use it for any purpose, with no conditions.${tail}`\n\n const verb = has('adapt') ? 'republish and adapt it' : has('no-derivatives') ? 'republish it unchanged' : 'republish it'\n const parts = [\n verb,\n has('commercial-use') ? ', including commercially,' : '',\n has('attribution') ? ' with credit' : '',\n has('share-alike') ? ', if they share adaptations under the same license' : '',\n has('noncommercial') ? ', but not commercially' : '',\n ]\n return `Anyone may ${parts.join('').replace(/,$/, '')}.${tail}`\n}\n","import { catalogUrlTable } from './catalog/cc/urls'\nimport { isKnownSpdxId } from './spdx/parse'\n\nconst CC_LICENSE = /^\\/licenses\\/(by|by-sa|by-nc|by-nc-sa|by-nd|by-nc-nd)\\/(\\d+\\.\\d+)(?:\\/([a-z]{2,3}))?(?:\\/(?:deed\\.[a-z-]+|legalcode(?:\\.[a-z-]+)?))?$/\nconst CC_ZERO = /^\\/publicdomain\\/zero\\/1\\.0(?:\\/(?:deed\\.[a-z-]+|legalcode(?:\\.[a-z-]+)?))?$/\nconst SPDX_PAGE = /^\\/licenses\\/([A-Za-z0-9.+-]+?)(?:\\.html|\\.json)?$/\n\n/** host without `www.`, then the path without a trailing slash, lowercased unless asked. */\nfunction normalize(url: URL, keepCase = false): { host: string; path: string } {\n const host = url.hostname.toLowerCase().replace(/^www\\./, '')\n const path = url.pathname.replace(/\\/+$/, '')\n return { host, path: keepCase ? path : path.toLowerCase() }\n}\n\nlet table: Map<string, string> | undefined\nfunction catalogUrls(): Map<string, string> {\n if (!table) {\n table = new Map()\n for (const [url, spdx] of catalogUrlTable()) {\n const { host, path } = normalize(new URL(url))\n table.set(host + path, spdx)\n }\n }\n return table\n}\n\n/**\n * The SPDX id a license URL names, or null. Reads Creative Commons license, deed and legal-code\n * URLs of any version and jurisdiction port, CC0, spdx.org license pages, and the catalog's own\n * URLs. An id is returned only when the SPDX list has it. Never throws.\n */\nexport function fromUrl(url: string): string | null {\n let parsed: URL\n try {\n parsed = new URL(url.trim())\n } catch {\n return null\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null\n const { host, path } = normalize(parsed)\n\n if (host === 'creativecommons.org') {\n const license = CC_LICENSE.exec(path)\n if (license) {\n const [, code, version, port] = license\n return isKnownSpdxId(`CC-${code}-${version}${port ? `-${port}` : ''}`) ?? null\n }\n if (CC_ZERO.test(path)) return 'CC0-1.0'\n }\n if (host === 'spdx.org') {\n const page = SPDX_PAGE.exec(normalize(parsed, true).path)\n if (page) return isKnownSpdxId(page[1]!) ?? null\n }\n return catalogUrls().get(host + path) ?? null\n}\n","import { termsHash } from '../hash'\nimport { validateTerms } from '../validate'\nimport type { LicenseCatalog, LicenseModule } from './types'\n\n/**\n * An index over the modules given. Throws on a duplicate id or SPDX id, and on a module whose terms\n * fail `validateTerms`, naming the module.\n */\nexport function createLicenseCatalog(modules: readonly LicenseModule<any>[]): LicenseCatalog {\n const byId = new Map<string, LicenseModule<any>>()\n const bySpdx = new Map<string, LicenseModule<any>>()\n const byHash = new Map<string, LicenseModule<any>>()\n\n for (const module of modules) {\n if (byId.has(module.id)) throw new Error(`Duplicate license module id ${module.id}`)\n if (bySpdx.has(module.spdx)) throw new Error(`Duplicate SPDX id ${module.spdx} (${module.id})`)\n byId.set(module.id, module)\n bySpdx.set(module.spdx, module)\n let terms: unknown\n try {\n terms = module.toTerms()\n } catch (error) {\n throw new Error(`License module ${module.id}: toTerms failed: ${(error as Error).message}`)\n }\n const result = validateTerms(terms)\n if (!result.ok) {\n throw new Error(`License module ${module.id} has invalid terms: ${result.errors.map((e) => `${e.path} ${e.message}`).join('; ')}`)\n }\n byHash.set(termsHash(result.terms), module)\n }\n\n return {\n list: (filter) => (filter?.domain ? modules.filter((m) => m.domains.includes(filter.domain!)) : [...modules]),\n get: (id) => byId.get(id),\n bySpdx: (spdx) => bySpdx.get(spdx),\n byTermsHash: (hash) => {\n const module = byHash.get(hash.toLowerCase())\n return module ? { module, terms: module.toTerms() } : undefined\n },\n }\n}\n","/**\n * A license offer as a reader sees it onchain (ADR 0039), without the chain: the caller has already\n * kept only offers on the Seed's Versions from the Seed's attester.\n */\nexport type LicenseOfferRecord = {\n uid: string\n /** Unix seconds. */\n timeCreated: number\n /** Unix seconds; 0 when not revoked. */\n revocationTime: number\n termsHash: string\n spdx: string\n /** Arweave transaction id of the legal text, when the offer names one. */\n legalTxId?: string\n}\n\n/** The license in force: `offer`, or reserved rights from `since` when `revoked`. */\nexport type LicenseInForce = {\n offer: LicenseOfferRecord\n /** The offer was revoked, which reads as reserved rights from its revocation time. */\n revoked: boolean\n /** Unix seconds: when this offer, or its revocation, took effect. */\n since: number\n}\n\ntype OfferEvent = { time: number; offer: LicenseOfferRecord; revocation: boolean }\n\n/**\n * Offers and revocations in the order they take effect. In one second an offer comes before a\n * revocation, and offers come by uid: the indexer gives no order within a block, and every\n * reader has to pick the same one.\n */\nfunction events(offers: readonly LicenseOfferRecord[]): OfferEvent[] {\n const all: OfferEvent[] = []\n for (const offer of offers) {\n all.push({ time: offer.timeCreated, offer, revocation: false })\n if (offer.revocationTime > 0) all.push({ time: offer.revocationTime, offer, revocation: true })\n }\n return all.sort(\n (a, b) =>\n a.time - b.time ||\n Number(a.revocation) - Number(b.revocation) ||\n (a.offer.uid < b.offer.uid ? -1 : a.offer.uid > b.offer.uid ? 1 : 0),\n )\n}\n\n/**\n * Every change of the license in force, oldest first. A revocation takes effect only while its\n * offer is in force: revoking an offer a later one already replaced changes nothing.\n */\nexport function licenseHistory(offers: readonly LicenseOfferRecord[]): LicenseInForce[] {\n const history: LicenseInForce[] = []\n for (const event of events(offers)) {\n const current = history.at(-1)\n if (event.revocation) {\n if (current && current.offer === event.offer && !current.revoked) {\n history.push({ offer: event.offer, revoked: true, since: event.time })\n }\n } else {\n history.push({ offer: event.offer, revoked: false, since: event.time })\n }\n }\n return history\n}\n\n/**\n * The license in force at `time` (unix seconds): the newest offer attested at or before it, read\n * as reserved rights from its revocation time if it was revoked by then. Null when no offer was\n * attested by then.\n * @throws RangeError when `time` isn't a finite number\n */\nexport function offerInForce(offers: readonly LicenseOfferRecord[], time: number): LicenseInForce | null {\n if (!Number.isFinite(time)) throw new RangeError(`time must be unix seconds, got ${time}`)\n return licenseHistory(offers).filter((entry) => entry.since <= time).at(-1) ?? null\n}\n"],"mappings":";;AAGA,IAAaU,IAAuC;CAClD,mBAAmB;CACnB,OAAO;CACP,OAAO;CACP,kBAAkB;CAClB,aAAa;CACb,kBAAkB;CAClB,eAAe;CACf,iBAAiB;CACjB,eAAe;CACf,kBAAkB;CAClB,uBAAuB;CACvB,wBAAwB;CACxB,kBAAkB;CAClB,aAAa;CACb,SAAS;AACX,GAEaC,IAAoB,iDAEpBC,KAAgB,GAAkB,MAC7C,sDAAsDC,EAAS,WAAWC,EAAO,aAEtEC,IAAqB,2EAGrBC,IAAuB,+DAEvBC,IAAwB,iFC3BxBC,IAAW;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GAGaC,IAA0C;CACrD,mBAAmB;CACnB,OAAO;CACP,OAAO;CACP,kBAAkB;CAClB,aAAa;CACb,kBAAkB;CAClB,eAAe;CACf,iBAAiB;CACjB,eAAe;CACf,kBAAkB;CAClB,uBAAuB;CACvB,wBAAwB;CACxB,kBAAkB;CAClB,aAAa;CACb,SAAS;AACX;AAeA,SAAgBC,EAAY,GAAuC;CACjE,IAAMC,oBAAQ,IAAI,IAAY,GACxBC,oBAAqB,IAAI,IAAY,GACrCC,oBAAsB,IAAI,IAAY,GACtCC,oBAAgB,IAAI,IAAY,GAEhCC,KAAQ,GAAc,GAAgB,IAAS,WACnDC,EAAK,WAAW,MAAMC,EAAE,WAAWC,MAAWD,EAAE,UAAU,YAAYE,KAAU,CAACF,EAAE,aAAa,MAAM,GAClGG,KAAU,GAAgB,MAAoBL,EAAKM,EAAM,a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,GAAqD;CACnE,IAAMC,IAAoB,CAAC;CAC3B,KAAK,IAAMC,KAASC,GAElB,AADAF,EAAI,KAAK;EAAE,MAAMC,EAAM;EAAa;EAAO,YAAY;CAAM,CAAC,GAC1DA,EAAM,iBAAiB,KAAGD,EAAI,KAAK;EAAE,MAAMC,EAAM;EAAgB;EAAO,YAAY;CAAK,CAAC;CAEhG,OAAOD,EAAI,MACR,GAAG,MACFG,EAAE,OAAOC,EAAE,QACX,OAAOD,EAAE,UAAU,IAAI,OAAOC,EAAE,UAAU,MACzCD,EAAE,MAAM,MAAMC,EAAE,MAAM,MAAM,KAAK,IAAE,MAAM,MAAMA,EAAE,MAAM,KAC5D;AACF;AAMA,SAAgBC,EAAe,GAAyD;CACtF,IAAMC,IAA4B,CAAC;CACnC,KAAK,IAAMC,KAASR,EAAOG,CAAM,GAAG;EAClC,IAAMM,IAAUF,EAAQ,GAAG,EAAE;EAC7B,AAAIC,EAAM,aACJC,KAAWA,EAAQ,UAAUD,EAAM,SAAS,CAACC,EAAQ,WACvDF,EAAQ,KAAK;GAAE,OAAOC,EAAM;GAAO,SAAS;GAAM,OAAOA,EAAM;EAAK,CAAC,IAGvED,EAAQ,KAAK;GAAE,OAAOC,EAAM;GAAO,SAAS;GAAO,OAAOA,EAAM;EAAK,CAAC;CAE1E;CACA,OAAOD;AACT;AAQA,SAAgBG,EAAa,GAAuC,GAAqC;CACvG,IAAI,CAAC,OAAO,SAASC,CAAI,GAAG,MAAU,WAAW,kCAAkCA,GAAM;CACzF,OAAOL,EAAeH,CAAM,CAAC,CAAC,QAAQ,MAAUS,EAAM,SAASD,CAAI,CAAC,CAAC,GAAG,EAAE,KAAK;AACjF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A license offer as a reader sees it onchain (ADR 0039), without the chain: the caller has already
|
|
3
|
+
* kept only offers on the Seed's Versions from the Seed's attester.
|
|
4
|
+
*/
|
|
5
|
+
export type LicenseOfferRecord = {
|
|
6
|
+
uid: string;
|
|
7
|
+
/** Unix seconds. */
|
|
8
|
+
timeCreated: number;
|
|
9
|
+
/** Unix seconds; 0 when not revoked. */
|
|
10
|
+
revocationTime: number;
|
|
11
|
+
termsHash: string;
|
|
12
|
+
spdx: string;
|
|
13
|
+
/** Arweave transaction id of the legal text, when the offer names one. */
|
|
14
|
+
legalTxId?: string;
|
|
15
|
+
};
|
|
16
|
+
/** The license in force: `offer`, or reserved rights from `since` when `revoked`. */
|
|
17
|
+
export type LicenseInForce = {
|
|
18
|
+
offer: LicenseOfferRecord;
|
|
19
|
+
/** The offer was revoked, which reads as reserved rights from its revocation time. */
|
|
20
|
+
revoked: boolean;
|
|
21
|
+
/** Unix seconds: when this offer, or its revocation, took effect. */
|
|
22
|
+
since: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Every change of the license in force, oldest first. A revocation takes effect only while its
|
|
26
|
+
* offer is in force: revoking an offer a later one already replaced changes nothing.
|
|
27
|
+
*/
|
|
28
|
+
export declare function licenseHistory(offers: readonly LicenseOfferRecord[]): LicenseInForce[];
|
|
29
|
+
/**
|
|
30
|
+
* The license in force at `time` (unix seconds): the newest offer attested at or before it, read
|
|
31
|
+
* as reserved rights from its revocation time if it was revoked by then. Null when no offer was
|
|
32
|
+
* attested by then.
|
|
33
|
+
* @throws RangeError when `time` isn't a finite number
|
|
34
|
+
*/
|
|
35
|
+
export declare function offerInForce(offers: readonly LicenseOfferRecord[], time: number): LicenseInForce | null;
|
|
36
|
+
//# sourceMappingURL=offerInForce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerInForce.d.ts","sourceRoot":"","sources":["../src/offerInForce.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,oBAAoB;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,qFAAqF;AACrF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,kBAAkB,CAAA;IACzB,sFAAsF;IACtF,OAAO,EAAE,OAAO,CAAA;IAChB,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAuBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,GAAG,cAAc,EAAE,CAatF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAGvG"}
|