31 lines
966 B
JavaScript
31 lines
966 B
JavaScript
import { Resolver, InMemoryResolveCache } from "@as4-411/resolver";
|
|
import { InMemoryDirectoryStore } from "@as4-411/storage";
|
|
|
|
const store = new InMemoryDirectoryStore();
|
|
store.addTenant({ id: "t1", name: "Example Tenant" });
|
|
store.addParticipant({ id: "p1", tenantId: "t1", name: "Example Participant" });
|
|
store.addIdentifier({
|
|
id: "i1",
|
|
participantId: "p1",
|
|
identifier_type: "as4.partyId",
|
|
value: "0088:123456789",
|
|
priority: 1,
|
|
});
|
|
store.addEndpoint({
|
|
id: "e1",
|
|
participantId: "p1",
|
|
protocol: "as4",
|
|
address: "https://example.com/as4",
|
|
profile: "peppol-as4",
|
|
priority: 1,
|
|
status: "active",
|
|
});
|
|
|
|
const resolver = new Resolver({ store, cache: new InMemoryResolveCache() });
|
|
const result = await resolver.resolve({
|
|
identifiers: [{ type: "as4.partyId", value: "0088:123456789" }],
|
|
tenant: "t1",
|
|
});
|
|
console.log("Sidecar resolve OK. Directives:", result.directives.length);
|
|
console.log("Target URL:", result.directives[0]?.target_address);
|