Skip to content

Commit b1cfb2d

Browse files
committed
feat: add licensing helper surface
1 parent c7265ca commit b1cfb2d

10 files changed

Lines changed: 1891 additions & 7 deletions

File tree

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "space-data-module-sdk",
3-
"version": "0.6.1",
3+
"version": "0.7.0",
44
"description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
55
"type": "module",
66
"types": "./src/index.d.ts",
@@ -25,6 +25,10 @@
2525
"./compliance": "./src/compliance/index.js",
2626
"./auth": "./src/auth/index.js",
2727
"./transport": "./src/transport/index.js",
28+
"./licensing": {
29+
"types": "./src/licensing/index.d.ts",
30+
"default": "./src/licensing/index.js"
31+
},
2832
"./compiler": "./src/compiler/index.js",
2933
"./compiler/emception": "./src/compiler/emception.js",
3034
"./bundle": "./src/bundle/index.js",
@@ -68,7 +72,7 @@
6872
"flatsql": "^0.4.0",
6973
"hd-wallet-wasm": "1.6.0",
7074
"sdn-emception": "1.0.0",
71-
"spacedatastandards.org": "git+https://github.com/DigitalArsenal/spacedatastandards.org.git#09af351a1"
75+
"spacedatastandards.org": "git+https://github.com/DigitalArsenal/spacedatastandards.org.git#c43c766bf4e8b18af125ed73b993e79c6ce20b24"
7276
},
7377
"devDependencies": {
7478
"express": "^4.21.2"

src/browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export * from "./manifest/browser.js";
22
export * from "./auth/index.js";
33
export * from "./transport/index.js";
4+
export * from "./licensing/index.js";
45
export * from "./bundle/index.js";
56
export * from "./capabilities.js";
67
export * from "./deployment/index.js";

src/index.d.ts

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,194 @@ export function inspectModule(source: Uint8Array | ArrayBuffer | WebAssembly.Mod
17831783
imports: WebAssembly.ModuleImportDescriptor[];
17841784
}>;
17851785

1786+
// --- Licensing ---
1787+
1788+
export class LicensingProtocolError extends Error {
1789+
code: string;
1790+
constructor(code: string, message: string);
1791+
}
1792+
1793+
export interface LicensingChallengeMessage {
1794+
messageType: string;
1795+
role: string;
1796+
reqId: string;
1797+
moduleId: string;
1798+
moduleVersion?: string;
1799+
requesterPeerId?: string;
1800+
requesterXpub?: string;
1801+
requesterSigningPublicKey?: Uint8Array;
1802+
requesterEphemeralPublicKey?: Uint8Array;
1803+
requestedDomain?: string;
1804+
requestedTimeoutMs?: number;
1805+
requestedAtMs?: number;
1806+
challengeNonce?: Uint8Array;
1807+
expiresAtMs?: number;
1808+
providerPeerId?: string;
1809+
errorCode?: string;
1810+
errorMessage?: string;
1811+
rawBytes: Uint8Array;
1812+
}
1813+
1814+
export interface LicensingProofMessage {
1815+
messageType: string;
1816+
reqId: string;
1817+
moduleId: string;
1818+
moduleVersion?: string;
1819+
requesterPeerId?: string;
1820+
requesterXpub?: string;
1821+
requestedDomain?: string;
1822+
requestedTimeoutMs: number;
1823+
requesterEphemeralPublicKey: Uint8Array;
1824+
challengeNonce: Uint8Array;
1825+
challengeExpiresAtMs: number;
1826+
providerPeerId?: string;
1827+
signature: Uint8Array;
1828+
requesterSigningPublicKey: Uint8Array;
1829+
timestampMs: number;
1830+
rejectionCode?: string;
1831+
rejectionMessage?: string;
1832+
rawBytes: Uint8Array;
1833+
}
1834+
1835+
export interface LicensingGrantModuleDescriptor {
1836+
cid: string;
1837+
contentHash: Uint8Array;
1838+
sizeBytes: number;
1839+
moduleId: string;
1840+
moduleVersion?: string;
1841+
requiredScope?: string;
1842+
keyId?: string;
1843+
allowedDomains: string[];
1844+
maxGrantTimeoutMs: number;
1845+
encrypted: boolean;
1846+
}
1847+
1848+
export interface LicensingWrappedContentKeyHeader {
1849+
version: number;
1850+
keyExchange: string;
1851+
symmetric: string;
1852+
keyDerivation: string;
1853+
ephemeralPublicKey: Uint8Array;
1854+
nonceStart: Uint8Array;
1855+
recipientKeyId: Uint8Array;
1856+
context?: string;
1857+
schemaHash: Uint8Array;
1858+
rootType?: string;
1859+
timestamp?: number;
1860+
}
1861+
1862+
export interface LicensingWrappedContentKey {
1863+
wrappingAlgorithm: string;
1864+
contentKeyId?: string;
1865+
contentKeyRole?: string;
1866+
contentKeyAlgorithm?: string;
1867+
contentKeyEncoding?: string;
1868+
keyBytes: Uint8Array;
1869+
contentKeyVersion?: number;
1870+
recipientKeyId?: string;
1871+
requesterEphemeralPublicKey: Uint8Array;
1872+
providerEphemeralPublicKey: Uint8Array;
1873+
hkdfSalt: Uint8Array;
1874+
iv: Uint8Array;
1875+
ciphertext: Uint8Array;
1876+
tag: Uint8Array;
1877+
expiresAtMs: number;
1878+
recipientPublicKey: Uint8Array;
1879+
ephemeralPublicKey: Uint8Array;
1880+
nonce: Uint8Array;
1881+
header: LicensingWrappedContentKeyHeader;
1882+
encryptedPayload: Uint8Array;
1883+
recipientKeyIdBytes: Uint8Array;
1884+
schemaHash: Uint8Array;
1885+
keyMaterialRootType?: string;
1886+
}
1887+
1888+
export interface LicensingGrantMessage {
1889+
messageType: string;
1890+
reqId: string;
1891+
moduleId: string;
1892+
moduleVersion?: string;
1893+
requesterPeerId?: string;
1894+
requesterXpub?: string;
1895+
requestedDomain?: string;
1896+
requestedTimeoutMs: number;
1897+
grantedDomain?: string;
1898+
grantedTimeoutMs: number;
1899+
expiresAtMs: number;
1900+
requiredScope?: string;
1901+
grantStatus?: string;
1902+
denialReason?: string;
1903+
capabilityToken: Uint8Array;
1904+
grantVerifierPublicKey: Uint8Array;
1905+
providerSignature: Uint8Array;
1906+
moduleDescriptor: LicensingGrantModuleDescriptor | null;
1907+
wrappedContentKey: LicensingWrappedContentKey | null;
1908+
rawBytes: Uint8Array;
1909+
}
1910+
1911+
export function encodeLicensingChallengeRequest(options: {
1912+
reqId: string;
1913+
moduleId: string;
1914+
moduleVersion?: string;
1915+
requesterPeerId: string;
1916+
requesterXpub?: string;
1917+
requesterSigningPublicKey: Uint8Array;
1918+
requesterEphemeralPublicKey: Uint8Array;
1919+
requesterDomain: string;
1920+
requestedTimeoutMs: number;
1921+
requestedAtMs: number;
1922+
providerPeerId: string;
1923+
}): Uint8Array;
1924+
1925+
export function decodeLicensingChallengeMessage(
1926+
bytes: Uint8Array | ArrayBuffer | ArrayBufferView,
1927+
): LicensingChallengeMessage;
1928+
1929+
export function encodeLicensingProof(options: {
1930+
reqId: string;
1931+
moduleId: string;
1932+
moduleVersion?: string;
1933+
requesterPeerId: string;
1934+
requesterXpub?: string;
1935+
requesterDomain: string;
1936+
requestedTimeoutMs: number;
1937+
requesterEphemeralPublicKey: Uint8Array;
1938+
challengeNonce: Uint8Array;
1939+
challengeExpiresAtMs: number;
1940+
providerPeerId: string;
1941+
signature: Uint8Array;
1942+
requesterSigningPublicKey: Uint8Array;
1943+
timestampMs: number;
1944+
}): Uint8Array;
1945+
1946+
export function decodeLicensingProofMessage(
1947+
bytes: Uint8Array | ArrayBuffer | ArrayBufferView,
1948+
): LicensingProofMessage;
1949+
1950+
export function decodeLicensingGrant(
1951+
bytes: Uint8Array | ArrayBuffer | ArrayBufferView,
1952+
): LicensingGrantMessage;
1953+
1954+
export function validateLicensingGrant(
1955+
grant: LicensingGrantMessage,
1956+
options?: {
1957+
reqId?: string;
1958+
moduleId?: string;
1959+
moduleVersion?: string;
1960+
expectedDomain?: string;
1961+
requestedTimeoutMs?: number;
1962+
grantVerifierPublicKeyLength?: number;
1963+
},
1964+
): LicensingGrantMessage;
1965+
1966+
export function extractGrantModuleDescriptor(
1967+
grant: LicensingGrantMessage,
1968+
): LicensingGrantModuleDescriptor;
1969+
1970+
export function extractWrappedContentKey(
1971+
grant: LicensingGrantMessage,
1972+
): LicensingWrappedContentKey;
1973+
17861974
// --- Runtime constants ---
17871975

17881976
export const DefaultManifestExports: {

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from "./manifest/index.js";
22
export * from "./compliance/index.js";
33
export * from "./auth/index.js";
44
export * from "./transport/index.js";
5+
export * from "./licensing/index.js";
56
export * from "./compiler/index.js";
67
export * from "./bundle/index.js";
78
export * from "./capabilities.js";

src/licensing/index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export { LicensingProtocolError } from "../index.js";
2+
export {
3+
decodeLicensingChallengeMessage,
4+
decodeLicensingGrant,
5+
decodeLicensingProofMessage,
6+
encodeLicensingChallengeRequest,
7+
encodeLicensingProof,
8+
extractGrantModuleDescriptor,
9+
extractWrappedContentKey,
10+
validateLicensingGrant,
11+
} from "../index.js";
12+
13+
export type {
14+
LicensingChallengeMessage,
15+
LicensingGrantMessage,
16+
LicensingGrantModuleDescriptor,
17+
LicensingProofMessage,
18+
LicensingWrappedContentKey,
19+
LicensingWrappedContentKeyHeader,
20+
} from "../index.js";

src/licensing/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export {
2+
LicensingProtocolError,
3+
decodeLicensingChallengeMessage,
4+
decodeLicensingGrant,
5+
decodeLicensingProofMessage,
6+
encodeLicensingChallengeRequest,
7+
encodeLicensingProof,
8+
extractGrantModuleDescriptor,
9+
extractWrappedContentKey,
10+
validateLicensingGrant,
11+
} from "./records.js";

0 commit comments

Comments
 (0)