@tsg-dsp/tsg-sdk 0.0.0-stage → 0.20.1

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.
Files changed (190) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +273 -2
  3. package/dist/.generated/control-plane.d.ts +7882 -0
  4. package/dist/.generated/sso-bridge.d.ts +3062 -0
  5. package/dist/.generated/wallet.d.ts +6350 -0
  6. package/dist/auth/auth.provider.d.ts +45 -0
  7. package/dist/auth/auth.provider.d.ts.map +1 -0
  8. package/dist/auth/auth.provider.js +158 -0
  9. package/dist/auth/auth.provider.js.map +1 -0
  10. package/dist/auth/auth.types.d.ts +27 -0
  11. package/dist/auth/auth.types.d.ts.map +1 -0
  12. package/dist/auth/auth.types.js +2 -0
  13. package/dist/auth/auth.types.js.map +1 -0
  14. package/dist/auth/index.d.ts +3 -0
  15. package/dist/auth/index.d.ts.map +1 -0
  16. package/dist/auth/index.js +3 -0
  17. package/dist/auth/index.js.map +1 -0
  18. package/dist/browser.d.ts +1243 -0
  19. package/dist/browser.d.ts.map +1 -0
  20. package/dist/browser.js +215 -0
  21. package/dist/browser.js.map +1 -0
  22. package/dist/catalog/catalog.sdk.d.ts +149 -0
  23. package/dist/catalog/catalog.sdk.d.ts.map +1 -0
  24. package/dist/catalog/catalog.sdk.js +155 -0
  25. package/dist/catalog/catalog.sdk.js.map +1 -0
  26. package/dist/catalog/index.d.ts +2 -0
  27. package/dist/catalog/index.d.ts.map +1 -0
  28. package/dist/catalog/index.js +2 -0
  29. package/dist/catalog/index.js.map +1 -0
  30. package/dist/client.d.ts +43 -0
  31. package/dist/client.d.ts.map +1 -0
  32. package/dist/client.js +107 -0
  33. package/dist/client.js.map +1 -0
  34. package/dist/config/index.d.ts +2 -0
  35. package/dist/config/index.d.ts.map +1 -0
  36. package/dist/config/index.js +2 -0
  37. package/dist/config/index.js.map +1 -0
  38. package/dist/config/sdk.config.d.ts +81 -0
  39. package/dist/config/sdk.config.d.ts.map +1 -0
  40. package/dist/config/sdk.config.js +2 -0
  41. package/dist/config/sdk.config.js.map +1 -0
  42. package/dist/index.d.ts +17 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +24 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/metadata/index.d.ts +2 -0
  47. package/dist/metadata/index.d.ts.map +1 -0
  48. package/dist/metadata/index.js +2 -0
  49. package/dist/metadata/index.js.map +1 -0
  50. package/dist/metadata/metadata.sdk.d.ts +111 -0
  51. package/dist/metadata/metadata.sdk.d.ts.map +1 -0
  52. package/dist/metadata/metadata.sdk.js +142 -0
  53. package/dist/metadata/metadata.sdk.js.map +1 -0
  54. package/dist/negotiations/index.d.ts +2 -0
  55. package/dist/negotiations/index.d.ts.map +1 -0
  56. package/dist/negotiations/index.js +2 -0
  57. package/dist/negotiations/index.js.map +1 -0
  58. package/dist/negotiations/negotiations.sdk.d.ts +113 -0
  59. package/dist/negotiations/negotiations.sdk.d.ts.map +1 -0
  60. package/dist/negotiations/negotiations.sdk.js +146 -0
  61. package/dist/negotiations/negotiations.sdk.js.map +1 -0
  62. package/dist/requirements/index.d.ts +2 -0
  63. package/dist/requirements/index.d.ts.map +1 -0
  64. package/dist/requirements/index.js +2 -0
  65. package/dist/requirements/index.js.map +1 -0
  66. package/dist/requirements/requirements.sdk.d.ts +52 -0
  67. package/dist/requirements/requirements.sdk.d.ts.map +1 -0
  68. package/dist/requirements/requirements.sdk.js +123 -0
  69. package/dist/requirements/requirements.sdk.js.map +1 -0
  70. package/dist/sso/index.d.ts +3 -0
  71. package/dist/sso/index.d.ts.map +1 -0
  72. package/dist/sso/index.js +3 -0
  73. package/dist/sso/index.js.map +1 -0
  74. package/dist/sso/sso-management.sdk.d.ts +96 -0
  75. package/dist/sso/sso-management.sdk.d.ts.map +1 -0
  76. package/dist/sso/sso-management.sdk.js +152 -0
  77. package/dist/sso/sso-management.sdk.js.map +1 -0
  78. package/dist/sso/sso.sdk.d.ts +75 -0
  79. package/dist/sso/sso.sdk.d.ts.map +1 -0
  80. package/dist/sso/sso.sdk.js +147 -0
  81. package/dist/sso/sso.sdk.js.map +1 -0
  82. package/dist/transfers/index.d.ts +2 -0
  83. package/dist/transfers/index.d.ts.map +1 -0
  84. package/dist/transfers/index.js +2 -0
  85. package/dist/transfers/index.js.map +1 -0
  86. package/dist/transfers/transfers.sdk.d.ts +155 -0
  87. package/dist/transfers/transfers.sdk.d.ts.map +1 -0
  88. package/dist/transfers/transfers.sdk.js +186 -0
  89. package/dist/transfers/transfers.sdk.js.map +1 -0
  90. package/dist/tsg-sdk.d.ts +65 -0
  91. package/dist/tsg-sdk.d.ts.map +1 -0
  92. package/dist/tsg-sdk.js +128 -0
  93. package/dist/tsg-sdk.js.map +1 -0
  94. package/dist/utils/errors.d.ts +67 -0
  95. package/dist/utils/errors.d.ts.map +1 -0
  96. package/dist/utils/errors.js +79 -0
  97. package/dist/utils/errors.js.map +1 -0
  98. package/dist/utils/index.d.ts +4 -0
  99. package/dist/utils/index.d.ts.map +1 -0
  100. package/dist/utils/index.js +4 -0
  101. package/dist/utils/index.js.map +1 -0
  102. package/dist/utils/polling.d.ts +20 -0
  103. package/dist/utils/polling.d.ts.map +1 -0
  104. package/dist/utils/polling.js +35 -0
  105. package/dist/utils/polling.js.map +1 -0
  106. package/dist/utils/shape-validation.d.ts +59 -0
  107. package/dist/utils/shape-validation.d.ts.map +1 -0
  108. package/dist/utils/shape-validation.js +85 -0
  109. package/dist/utils/shape-validation.js.map +1 -0
  110. package/dist/utils/validate.d.ts +47 -0
  111. package/dist/utils/validate.d.ts.map +1 -0
  112. package/dist/utils/validate.js +68 -0
  113. package/dist/utils/validate.js.map +1 -0
  114. package/dist/vendor/common-dtos/abac.policy.d.ts +60 -0
  115. package/dist/vendor/common-dtos/abac.policy.js +2 -0
  116. package/dist/vendor/common-dtos/audit.types.d.ts +74 -0
  117. package/dist/vendor/common-dtos/audit.types.js +9 -0
  118. package/dist/vendor/common-dtos/credential-requirements.d.ts +19 -0
  119. package/dist/vendor/common-dtos/credential-requirements.dto.d.ts +47 -0
  120. package/dist/vendor/common-dtos/credential-requirements.dto.js +251 -0
  121. package/dist/vendor/common-dtos/credential-requirements.js +181 -0
  122. package/dist/vendor/common-dtos/dataplane.dto.d.ts +6 -0
  123. package/dist/vendor/common-dtos/dataplane.dto.js +29 -0
  124. package/dist/vendor/common-dtos/dcp.dto.d.ts +90 -0
  125. package/dist/vendor/common-dtos/dcp.dto.js +490 -0
  126. package/dist/vendor/common-dtos/dcql.dto.d.ts +89 -0
  127. package/dist/vendor/common-dtos/dcql.dto.js +450 -0
  128. package/dist/vendor/common-dtos/did.schemas.d.ts +40 -0
  129. package/dist/vendor/common-dtos/did.schemas.js +260 -0
  130. package/dist/vendor/common-dtos/index.d.ts +19 -0
  131. package/dist/vendor/common-dtos/index.js +19 -0
  132. package/dist/vendor/common-dtos/metadata.dto.d.ts +6 -0
  133. package/dist/vendor/common-dtos/metadata.dto.js +30 -0
  134. package/dist/vendor/common-dtos/negotiations.dto.d.ts +29 -0
  135. package/dist/vendor/common-dtos/negotiations.dto.js +205 -0
  136. package/dist/vendor/common-dtos/permissions.d.ts +237 -0
  137. package/dist/vendor/common-dtos/permissions.js +337 -0
  138. package/dist/vendor/common-dtos/presentation.request.dto.d.ts +9 -0
  139. package/dist/vendor/common-dtos/presentation.request.dto.js +55 -0
  140. package/dist/vendor/common-dtos/presentation.status.dto.d.ts +13 -0
  141. package/dist/vendor/common-dtos/presentation.status.dto.js +83 -0
  142. package/dist/vendor/common-dtos/presentationdefinition.dto.d.ts +75 -0
  143. package/dist/vendor/common-dtos/presentationdefinition.dto.js +448 -0
  144. package/dist/vendor/common-dtos/signatures.dto.d.ts +32 -0
  145. package/dist/vendor/common-dtos/signatures.dto.js +210 -0
  146. package/dist/vendor/common-dtos/transfer.dto.d.ts +17 -0
  147. package/dist/vendor/common-dtos/transfer.dto.js +102 -0
  148. package/dist/vendor/common-dtos/utils.swagger.d.ts +13 -0
  149. package/dist/vendor/common-dtos/utils.swagger.js +63 -0
  150. package/dist/vendor/control-plane-dtos/index.d.ts +5 -0
  151. package/dist/vendor/control-plane-dtos/index.js +5 -0
  152. package/dist/vendor/control-plane-dtos/registry/registry.dto.d.ts +5 -0
  153. package/dist/vendor/control-plane-dtos/registry/registry.dto.js +26 -0
  154. package/dist/vendor/control-plane-dtos/registry/registry.search.dto.d.ts +29 -0
  155. package/dist/vendor/control-plane-dtos/registry/registry.search.dto.js +127 -0
  156. package/dist/vendor/control-plane-dtos/ssi/verifiablePresentations.dto.d.ts +10 -0
  157. package/dist/vendor/control-plane-dtos/ssi/verifiablePresentations.dto.js +44 -0
  158. package/dist/vendor/control-plane-dtos/status/status.dto.d.ts +38 -0
  159. package/dist/vendor/control-plane-dtos/status/status.dto.js +173 -0
  160. package/dist/vendor/sso-bridge-dtos/clients.dto.d.ts +22 -0
  161. package/dist/vendor/sso-bridge-dtos/clients.dto.js +113 -0
  162. package/dist/vendor/sso-bridge-dtos/grants.d.ts +3 -0
  163. package/dist/vendor/sso-bridge-dtos/grants.js +2 -0
  164. package/dist/vendor/sso-bridge-dtos/index.d.ts +5 -0
  165. package/dist/vendor/sso-bridge-dtos/index.js +5 -0
  166. package/dist/vendor/sso-bridge-dtos/users.dto.d.ts +24 -0
  167. package/dist/vendor/sso-bridge-dtos/users.dto.js +90 -0
  168. package/dist/vendor/wallet-dtos/clients.dto.d.ts +22 -0
  169. package/dist/vendor/wallet-dtos/clients.dto.js +14 -0
  170. package/dist/vendor/wallet-dtos/credentials.dto.d.ts +32 -0
  171. package/dist/vendor/wallet-dtos/credentials.dto.js +47 -0
  172. package/dist/vendor/wallet-dtos/index.d.ts +7 -0
  173. package/dist/vendor/wallet-dtos/index.js +7 -0
  174. package/dist/vendor/wallet-dtos/issuance.dto.d.ts +238 -0
  175. package/dist/vendor/wallet-dtos/issuance.dto.js +1140 -0
  176. package/dist/vendor/wallet-dtos/scopes.dto.d.ts +25 -0
  177. package/dist/vendor/wallet-dtos/scopes.dto.js +152 -0
  178. package/dist/vendor/wallet-dtos/status.dto.d.ts +36 -0
  179. package/dist/vendor/wallet-dtos/status.dto.js +170 -0
  180. package/dist/vendor/wallet-dtos/utils/schema-converter.d.ts +14 -0
  181. package/dist/vendor/wallet-dtos/utils/schema-converter.js +43 -0
  182. package/dist/wallet/index.d.ts +2 -0
  183. package/dist/wallet/index.d.ts.map +1 -0
  184. package/dist/wallet/index.js +2 -0
  185. package/dist/wallet/index.js.map +1 -0
  186. package/dist/wallet/wallet.sdk.d.ts +285 -0
  187. package/dist/wallet/wallet.sdk.d.ts.map +1 -0
  188. package/dist/wallet/wallet.sdk.js +384 -0
  189. package/dist/wallet/wallet.sdk.js.map +1 -0
  190. package/package.json +78 -3
@@ -0,0 +1,113 @@
1
+ import { Agreement, AgreementDto, ContractNegotiation, ContractNegotiationDto, OfferDto } from "@tsg-dsp/common-dsp";
2
+ import { NegotiationDetailDto, NegotiationStatusDto } from "../vendor/common-dtos/index.js";
3
+ import type { ControlPlaneClient } from "../client.js";
4
+ import type { PollingOptions } from "../utils/polling.js";
5
+ /**
6
+ * Manage the full lifecycle of Dataspace Protocol contract negotiations.
7
+ *
8
+ * A contract negotiation follows the DSP state machine:
9
+ * `REQUESTED → OFFERED → AGREED → VERIFIED → FINALIZED` (or `TERMINATED`).
10
+ *
11
+ * This module provides methods to:
12
+ * - Initiate and terminate negotiations.
13
+ * - Poll for state transitions (e.g. wait until an agreement is reached).
14
+ * - Retrieve agreements and negotiation details.
15
+ * @example
16
+ * ```ts
17
+ * // Negotiate and wait for an agreement in one call
18
+ * const negotiation = await sdk.negotiations.negotiateAndWait(
19
+ * datasetId,
20
+ * participantId,
21
+ * remoteAddress,
22
+ * offer,
23
+ * );
24
+ * console.log(negotiation.agreementId);
25
+ * ```
26
+ */
27
+ export declare class NegotiationSdk {
28
+ private readonly client;
29
+ constructor(client: ControlPlaneClient);
30
+ /**
31
+ * List all negotiations known to the control plane.
32
+ * @returns An array of validated {@link NegotiationStatusDto} instances.
33
+ */
34
+ listNegotiations(): Promise<NegotiationStatusDto[]>;
35
+ /**
36
+ * Get the full details of a negotiation by its process ID.
37
+ * @param processId - The unique process ID of the negotiation.
38
+ * @returns A validated {@link NegotiationDetailDto}.
39
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.NOT_FOUND} if the negotiation does not exist.
40
+ */
41
+ getNegotiation(processId: string): Promise<NegotiationDetailDto>;
42
+ /**
43
+ * Get a contract agreement by its agreement ID.
44
+ * @param agreementId - The unique agreement ID.
45
+ * @param returnDto - When `true`, returns the raw {@link AgreementDto}.
46
+ * @returns The deserialized {@link Agreement} (or raw DTO).
47
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.NOT_FOUND} if the agreement does not exist.
48
+ */
49
+ getAgreement(agreementId: string, returnDto: true): Promise<AgreementDto>;
50
+ getAgreement(agreementId: string, returnDto?: false): Promise<Agreement>;
51
+ /**
52
+ * Get negotiations related to a specific dataset.
53
+ * @param datasetId - The dataset ID to filter on.
54
+ * @param remoteParty - Optional remote participant ID to further filter results.
55
+ * @returns An array of matching {@link NegotiationStatusDto} instances.
56
+ */
57
+ getNegotiationsForDataset(datasetId: string, remoteParty?: string): Promise<NegotiationStatusDto[]>;
58
+ /**
59
+ * Initiate a new contract negotiation for a dataset.
60
+ * @param datasetId - The ID of the dataset to negotiate for.
61
+ * @param participantId - The remote participant's ID (DID), used as audience.
62
+ * @param remoteAddress - The remote participant's DSP protocol endpoint.
63
+ * @param offer - The policy offer to include in the negotiation request.
64
+ * @param returnDto - When `true`, returns the raw {@link ContractNegotiationDto}.
65
+ * @returns The created {@link ContractNegotiation} (or raw DTO).
66
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.REQUEST_FAILED} if the request is rejected.
67
+ */
68
+ requestNegotiation(datasetId: string, participantId: string, remoteAddress: string, offer: OfferDto, returnDto: true): Promise<ContractNegotiationDto>;
69
+ requestNegotiation(datasetId: string, participantId: string, remoteAddress: string, offer: OfferDto, returnDto?: false): Promise<ContractNegotiation>;
70
+ /**
71
+ * Terminate an ongoing negotiation.
72
+ * @param processId - The negotiation process ID.
73
+ * @param code - Optional machine-readable termination reason code.
74
+ * @param reason - Optional human-readable termination reason.
75
+ * @returns The termination response.
76
+ */
77
+ terminateNegotiation(processId: string, code?: string, reason?: string): Promise<{
78
+ status?: string | undefined;
79
+ }>;
80
+ /**
81
+ * Poll until a negotiation reaches the given target state.
82
+ * @param processId - The negotiation process ID.
83
+ * @param targetState - The desired state (e.g. `"FINALIZED"`, `"AGREED"`).
84
+ * @param options - Polling interval and retry configuration.
85
+ * @returns The {@link NegotiationDetailDto} once the target state is reached.
86
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.POLLING_TIMEOUT} if the state is not reached within the configured retries.
87
+ */
88
+ waitForState(processId: string, targetState: NegotiationDetailDto["state"], options?: PollingOptions): Promise<NegotiationDetailDto>;
89
+ /**
90
+ * Poll until a negotiation reaches the `FINALIZED` state (agreement reached).
91
+ *
92
+ * Shorthand for `waitForState(processId, "FINALIZED", options)`.
93
+ * @param processId - The negotiation process ID.
94
+ * @param options - Polling interval and retry configuration.
95
+ * @returns The {@link NegotiationDetailDto} with `state === "FINALIZED"`.
96
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.POLLING_TIMEOUT} if the agreement is not reached in time.
97
+ */
98
+ waitForAgreement(processId: string, options?: PollingOptions): Promise<NegotiationDetailDto>;
99
+ /**
100
+ * Initiate a negotiation and wait for it to be finalized in one call.
101
+ *
102
+ * Combines {@link requestNegotiation} and {@link waitForAgreement}.
103
+ * @param datasetId - The ID of the dataset to negotiate for.
104
+ * @param participantId - The remote participant's ID (DID).
105
+ * @param remoteAddress - The remote participant's DSP protocol endpoint.
106
+ * @param offer - The policy offer to include.
107
+ * @param pollingOptions - Optional polling configuration.
108
+ * @returns The {@link NegotiationDetailDto} once the agreement is reached.
109
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.POLLING_TIMEOUT} if the agreement is not reached in time.
110
+ */
111
+ negotiateAndWait(datasetId: string, participantId: string, remoteAddress: string, offer: OfferDto, pollingOptions?: PollingOptions): Promise<NegotiationDetailDto>;
112
+ }
113
+ //# sourceMappingURL=negotiations.sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"negotiations.sdk.d.ts","sourceRoot":"","sources":["../../src/negotiations/negotiations.sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQ1D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,kBAAkB;IAEvD;;;OAGG;IACG,gBAAgB;IAKtB;;;;;OAKG;IACG,cAAc,CAAC,SAAS,EAAE,MAAM;IAUtC;;;;;;OAMG;IACG,YAAY,CAChB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,IAAI,GACd,OAAO,CAAC,YAAY,CAAC;IAClB,YAAY,CAChB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,KAAK,GAChB,OAAO,CAAC,SAAS,CAAC;IAWrB;;;;;OAKG;IACG,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM;IAUvE;;;;;;;;;OASG;IACG,kBAAkB,CACtB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,IAAI,GACd,OAAO,CAAC,sBAAsB,CAAC;IAC5B,kBAAkB,CACtB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,QAAQ,EACf,SAAS,CAAC,EAAE,KAAK,GAChB,OAAO,CAAC,mBAAmB,CAAC;IA2B/B;;;;;;OAMG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM;;;IAYjB;;;;;;;OAOG;IACG,YAAY,CAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,oBAAoB,CAAC,OAAO,CAAC,EAC1C,OAAO,CAAC,EAAE,cAAc;IAS1B;;;;;;;;OAQG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc;IAQlE;;;;;;;;;;;OAWG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,QAAQ,EACf,cAAc,CAAC,EAAE,cAAc;CAmBlC"}
@@ -0,0 +1,146 @@
1
+ import { NegotiationDetailDto, NegotiationStatusDto } from "../vendor/common-dtos/index.js";
2
+ import { SdkError, SdkErrorCode } from "../utils/errors.js";
3
+ import { pollUntil } from "../utils/polling.js";
4
+ import { validateJsonLD, validateResponse, validateResponseArray } from "../utils/validate.js";
5
+ /**
6
+ * Manage the full lifecycle of Dataspace Protocol contract negotiations.
7
+ *
8
+ * A contract negotiation follows the DSP state machine:
9
+ * `REQUESTED → OFFERED → AGREED → VERIFIED → FINALIZED` (or `TERMINATED`).
10
+ *
11
+ * This module provides methods to:
12
+ * - Initiate and terminate negotiations.
13
+ * - Poll for state transitions (e.g. wait until an agreement is reached).
14
+ * - Retrieve agreements and negotiation details.
15
+ * @example
16
+ * ```ts
17
+ * // Negotiate and wait for an agreement in one call
18
+ * const negotiation = await sdk.negotiations.negotiateAndWait(
19
+ * datasetId,
20
+ * participantId,
21
+ * remoteAddress,
22
+ * offer,
23
+ * );
24
+ * console.log(negotiation.agreementId);
25
+ * ```
26
+ */
27
+ export class NegotiationSdk {
28
+ client;
29
+ constructor(client) {
30
+ this.client = client;
31
+ }
32
+ /**
33
+ * List all negotiations known to the control plane.
34
+ * @returns An array of validated {@link NegotiationStatusDto} instances.
35
+ */
36
+ async listNegotiations() {
37
+ const { data } = await this.client.GET("/management/negotiations");
38
+ return validateResponseArray(NegotiationStatusDto, data ?? []);
39
+ }
40
+ /**
41
+ * Get the full details of a negotiation by its process ID.
42
+ * @param processId - The unique process ID of the negotiation.
43
+ * @returns A validated {@link NegotiationDetailDto}.
44
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.NOT_FOUND} if the negotiation does not exist.
45
+ */
46
+ async getNegotiation(processId) {
47
+ const { data } = await this.client.GET("/management/negotiations/{processId}", {
48
+ params: { path: { processId } }
49
+ });
50
+ return validateResponse(NegotiationDetailDto, data);
51
+ }
52
+ async getAgreement(agreementId, returnDto = false) {
53
+ const { data } = await this.client.GET("/management/agreements/{agreementId}", {
54
+ params: { path: { agreementId } }
55
+ });
56
+ return validateJsonLD(data, returnDto);
57
+ }
58
+ /**
59
+ * Get negotiations related to a specific dataset.
60
+ * @param datasetId - The dataset ID to filter on.
61
+ * @param remoteParty - Optional remote participant ID to further filter results.
62
+ * @returns An array of matching {@link NegotiationStatusDto} instances.
63
+ */
64
+ async getNegotiationsForDataset(datasetId, remoteParty) {
65
+ const { data } = await this.client.GET("/management/negotiations/dataset/{datasetId}", {
66
+ params: { path: { datasetId }, query: { remoteParty } }
67
+ });
68
+ return validateResponseArray(NegotiationStatusDto, data ?? []);
69
+ }
70
+ async requestNegotiation(datasetId, participantId, remoteAddress, offer, returnDto = false) {
71
+ const { data } = await this.client.POST("/management/negotiations/request", {
72
+ params: {
73
+ query: {
74
+ dataSet: datasetId,
75
+ address: remoteAddress,
76
+ audience: participantId
77
+ }
78
+ },
79
+ // OfferDto uses OrArray<string> for some fields while the OpenAPI schema
80
+ // uses plain string — cast at the boundary between canonical and generated types.
81
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
+ body: offer
83
+ });
84
+ return validateJsonLD(data, returnDto);
85
+ }
86
+ /**
87
+ * Terminate an ongoing negotiation.
88
+ * @param processId - The negotiation process ID.
89
+ * @param code - Optional machine-readable termination reason code.
90
+ * @param reason - Optional human-readable termination reason.
91
+ * @returns The termination response.
92
+ */
93
+ async terminateNegotiation(processId, code, reason) {
94
+ const { data } = await this.client.POST("/management/negotiations/{processId}/termination", {
95
+ params: { path: { processId } },
96
+ body: { code, reason }
97
+ });
98
+ return data;
99
+ }
100
+ /**
101
+ * Poll until a negotiation reaches the given target state.
102
+ * @param processId - The negotiation process ID.
103
+ * @param targetState - The desired state (e.g. `"FINALIZED"`, `"AGREED"`).
104
+ * @param options - Polling interval and retry configuration.
105
+ * @returns The {@link NegotiationDetailDto} once the target state is reached.
106
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.POLLING_TIMEOUT} if the state is not reached within the configured retries.
107
+ */
108
+ async waitForState(processId, targetState, options) {
109
+ return pollUntil(() => this.getNegotiation(processId), (negotiation) => negotiation.state === targetState, options);
110
+ }
111
+ /**
112
+ * Poll until a negotiation reaches the `FINALIZED` state (agreement reached).
113
+ *
114
+ * Shorthand for `waitForState(processId, "FINALIZED", options)`.
115
+ * @param processId - The negotiation process ID.
116
+ * @param options - Polling interval and retry configuration.
117
+ * @returns The {@link NegotiationDetailDto} with `state === "FINALIZED"`.
118
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.POLLING_TIMEOUT} if the agreement is not reached in time.
119
+ */
120
+ async waitForAgreement(processId, options) {
121
+ return pollUntil(() => this.getNegotiation(processId), (negotiation) => negotiation.state === "FINALIZED", options);
122
+ }
123
+ /**
124
+ * Initiate a negotiation and wait for it to be finalized in one call.
125
+ *
126
+ * Combines {@link requestNegotiation} and {@link waitForAgreement}.
127
+ * @param datasetId - The ID of the dataset to negotiate for.
128
+ * @param participantId - The remote participant's ID (DID).
129
+ * @param remoteAddress - The remote participant's DSP protocol endpoint.
130
+ * @param offer - The policy offer to include.
131
+ * @param pollingOptions - Optional polling configuration.
132
+ * @returns The {@link NegotiationDetailDto} once the agreement is reached.
133
+ * @throws Throws an {@link SdkError} with code {@link SdkErrorCode.POLLING_TIMEOUT} if the agreement is not reached in time.
134
+ */
135
+ async negotiateAndWait(datasetId, participantId, remoteAddress, offer, pollingOptions) {
136
+ const negotiation = await this.requestNegotiation(datasetId, participantId, remoteAddress, offer);
137
+ // A DSP ContractNegotiation has no `@id`; the local process id (used to poll
138
+ // this control plane) is the consumerPid.
139
+ const processId = negotiation.consumerPid;
140
+ if (!processId) {
141
+ throw new SdkError("Negotiation request returned no consumer process id", SdkErrorCode.REQUEST_FAILED);
142
+ }
143
+ return this.waitForAgreement(processId, pollingOptions);
144
+ }
145
+ }
146
+ //# sourceMappingURL=negotiations.sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"negotiations.sdk.js","sourceRoot":"","sources":["../../src/negotiations/negotiations.sdk.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;IAAG,CAAC;IAE3D;;;OAGG;IACH,KAAK,CAAC,gBAAgB;QACpB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC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AM,IAAI,CAAC,kBAAkB,CAC/C,SAAS,EACT,aAAa,EACb,aAAa,EACb,KAAK,CACN,CAAC;QACF,6EAA6E;QAC7E,0CAA0C;QAC1C,MAAM,SAAS,GAAG,WAAW,CAAC,WAAW,CAAC;QAC1C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,QAAQ,CAChB,qDAAqD,EACrD,YAAY,CAAC,cAAc,CAC5B,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export * from "./requirements.sdk.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/requirements/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./requirements.sdk.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/requirements/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { type CredentialMatchContext, type CredentialMatchResult, type CredentialRecord, type CredentialRequirement, type CredentialRequirementSet, type CredentialRequirementSetCreate } from "../vendor/common-dtos/index.js";
2
+ import type { ControlPlaneClient } from "../client.js";
3
+ export interface CatalogCredentialRequirement {
4
+ "@type": "tsg:CredentialRequirement";
5
+ "tsg:id": string;
6
+ "tsg:credentialType": string[];
7
+ }
8
+ export interface CatalogCredentialRequirementMetadata {
9
+ "tsg:requirementLogic": "all" | "any";
10
+ "tsg:credentialRequirement": CatalogCredentialRequirement[];
11
+ }
12
+ export interface RequirementSetListOptions {
13
+ id?: string;
14
+ page?: number;
15
+ perPage?: number;
16
+ order?: "ASC" | "DESC";
17
+ orderBy?: string;
18
+ }
19
+ export interface RequirementSetPage {
20
+ data: CredentialRequirementSet[];
21
+ total: number;
22
+ }
23
+ export declare class RequirementsSdk {
24
+ private readonly client;
25
+ constructor(client: ControlPlaneClient);
26
+ create(request: CredentialRequirementSetCreate): Promise<CredentialRequirementSet>;
27
+ list(options?: RequirementSetListOptions): Promise<RequirementSetPage>;
28
+ getLatest(id: string): Promise<CredentialRequirementSet>;
29
+ getRevision(id: string, revision: number): Promise<CredentialRequirementSet>;
30
+ archiveRevision(id: string, revision: number): Promise<void>;
31
+ lint(requirementSet: CredentialRequirementSet | CredentialRequirementSetCreate): string[];
32
+ presentationScope(requirementSet: Pick<CredentialRequirementSet, "id" | "revision" | "digest">): string;
33
+ odrlConstraint(requirementSet: Pick<CredentialRequirementSet, "id" | "revision" | "digest">): {
34
+ "@type": "Constraint";
35
+ leftOperand: string;
36
+ operator: string;
37
+ rightOperand: string;
38
+ };
39
+ /**
40
+ * Build a public, informational summary of an immutable RequirementSet.
41
+ *
42
+ * Consumers can use this metadata for wallet-readiness guidance without
43
+ * resolving the provider-local scope. The provider still verifies the
44
+ * complete immutable RequirementSet as the authoritative policy.
45
+ * @param requirementSet - Immutable requirements to summarize publicly.
46
+ * @returns Non-authoritative catalog metadata containing logic and types.
47
+ */
48
+ catalogMetadata(requirementSet: Pick<CredentialRequirementSet, "logic" | "requirements">): CatalogCredentialRequirementMetadata;
49
+ findCandidateCredentials(requirement: CredentialRequirement, credentials: CredentialRecord[], context?: CredentialMatchContext): CredentialRecord[];
50
+ matchCredentials(requirementSet: Pick<CredentialRequirementSet, "logic" | "requirements">, credentials: CredentialRecord[], context?: CredentialMatchContext): CredentialMatchResult;
51
+ }
52
+ //# sourceMappingURL=requirements.sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requirements.sdk.d.ts","sourceRoot":"","sources":["../../src/requirements/requirements.sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,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AwB,GAAG,8BAA8B,GACxE,MAAM,EAAE;IAIX,iBAAiB,CACf,cAAc,EAAE,IAAI,CAAC,wBAAwB,EAAE,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,GAC3E,MAAM;IAUT,cAAc,CACZ,cAAc,EAAE,IAAI,CAAC,wBAAwB,EAAE,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC;;;;;;IAU9E;;;;;;;;OAQG;IACH,eAAe,CACb,cAAc,EAAE,IAAI,CAAC,wBAAwB,EAAE,OAAO,GAAG,cAAc,CAAC,GACvE,oCAAoC;IAavC,wBAAwB,CACtB,WAAW,EAAE,qBAAqB,EAClC,WAAW,EAAE,gBAAgB,EAAE,EAC/B,OAAO,GAAE,sBAA2B,GACnC,gBAAgB,EAAE;IAIrB,gBAAgB,CACd,cAAc,EAAE,IAAI,CAAC,wBAAwB,EAAE,OAAO,GAAG,cAAc,CAAC,EACxE,WAAW,EAAE,gBAAgB,EAAE,EAC/B,OAAO,GAAE,sBAA2B,GACnC,qBAAqB;CAGzB"}
@@ -0,0 +1,123 @@
1
+ import { findCandidateCredentials, lintCredentialRequirementSet, matchCredentialRequirements } from "../vendor/common-dtos/index.js";
2
+ import { SdkError, SdkErrorCode } from "../utils/errors.js";
3
+ import { hasArray, hasNumber, hasString, isObject, requireObjectResponse } from "../utils/shape-validation.js";
4
+ export class RequirementsSdk {
5
+ client;
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
9
+ async create(request) {
10
+ const { data } = await this.client.POST("/management/credential-requirement-sets", { body: request });
11
+ if (!data) {
12
+ throw new SdkError("Requirement-set creation returned no response body", SdkErrorCode.REQUEST_FAILED);
13
+ }
14
+ return requirementSetResponse(data);
15
+ }
16
+ async list(options = {}) {
17
+ const { data } = await this.client.GET("/management/credential-requirement-sets", {
18
+ params: {
19
+ query: {
20
+ id: options.id,
21
+ page: options.page,
22
+ per_page: options.perPage,
23
+ order: options.order,
24
+ order_by: options.orderBy
25
+ }
26
+ }
27
+ });
28
+ return requirementSetPageResponse(data);
29
+ }
30
+ async getLatest(id) {
31
+ const { data } = await this.client.GET("/management/credential-requirement-sets/{id}/latest", { params: { path: { id } } });
32
+ return requirementSetResponse(data);
33
+ }
34
+ async getRevision(id, revision) {
35
+ const { data } = await this.client.GET("/management/credential-requirement-sets/{id}/revisions/{revision}", { params: { path: { id, revision } } });
36
+ if (!data) {
37
+ throw new SdkError(`Requirement set ${id} revision ${revision} was not returned`, SdkErrorCode.NOT_FOUND);
38
+ }
39
+ return requirementSetResponse(data);
40
+ }
41
+ async archiveRevision(id, revision) {
42
+ await this.client.DELETE("/management/credential-requirement-sets/{id}/revisions/{revision}", { params: { path: { id, revision } } });
43
+ }
44
+ lint(requirementSet) {
45
+ return lintCredentialRequirementSet(requirementSet);
46
+ }
47
+ presentationScope(requirementSet) {
48
+ if (!requirementSet.digest) {
49
+ throw new SdkError("A requirement-set digest is required before publication", SdkErrorCode.VALIDATION_FAILED);
50
+ }
51
+ return `tsg.req.${requirementSet.id}:${requirementSet.revision}`;
52
+ }
53
+ odrlConstraint(requirementSet) {
54
+ return {
55
+ "@type": "Constraint",
56
+ leftOperand: "tsg:presentationScope",
57
+ operator: "eq",
58
+ rightOperand: this.presentationScope(requirementSet)
59
+ };
60
+ }
61
+ /**
62
+ * Build a public, informational summary of an immutable RequirementSet.
63
+ *
64
+ * Consumers can use this metadata for wallet-readiness guidance without
65
+ * resolving the provider-local scope. The provider still verifies the
66
+ * complete immutable RequirementSet as the authoritative policy.
67
+ * @param requirementSet - Immutable requirements to summarize publicly.
68
+ * @returns Non-authoritative catalog metadata containing logic and types.
69
+ */
70
+ catalogMetadata(requirementSet) {
71
+ return {
72
+ "tsg:requirementLogic": requirementSet.logic,
73
+ "tsg:credentialRequirement": requirementSet.requirements.map((requirement) => ({
74
+ "@type": "tsg:CredentialRequirement",
75
+ "tsg:id": requirement.id,
76
+ "tsg:credentialType": [...requirement.credentialTypes]
77
+ }))
78
+ };
79
+ }
80
+ findCandidateCredentials(requirement, credentials, context = {}) {
81
+ return findCandidateCredentials(requirement, credentials, context);
82
+ }
83
+ matchCredentials(requirementSet, credentials, context = {}) {
84
+ return matchCredentialRequirements(requirementSet, credentials, context);
85
+ }
86
+ }
87
+ /**
88
+ * Validate a requirement-set API response.
89
+ * @param data - Untrusted response body.
90
+ * @returns The validated requirement set.
91
+ */
92
+ function requirementSetResponse(data) {
93
+ return requireObjectResponse(data, "CredentialRequirementSet", isRequirementSet);
94
+ }
95
+ /**
96
+ * Validate a paginated requirement-set API response.
97
+ * @param data - Untrusted response body.
98
+ * @returns The validated requirement-set page.
99
+ */
100
+ function requirementSetPageResponse(data) {
101
+ return requireObjectResponse(data, "CredentialRequirementSetPage", (value) => hasNumber(value, "total") &&
102
+ hasArray(value, "data") &&
103
+ value.data.every((item) => isObject(item) && isRequirementSet(item)));
104
+ }
105
+ /**
106
+ * Check the required shape of a requirement-set response.
107
+ * @param value - Candidate response object.
108
+ * @returns Whether the candidate has the required fields.
109
+ */
110
+ function isRequirementSet(value) {
111
+ return (hasString(value, "id") &&
112
+ hasNumber(value, "revision") &&
113
+ hasString(value, "digest") &&
114
+ (value.logic === "all" || value.logic === "any") &&
115
+ hasArray(value, "requirements") &&
116
+ isObject(value.profile) &&
117
+ hasString(value.profile, "id") &&
118
+ hasString(value.profile, "version") &&
119
+ isObject(value.presentationDefinition) &&
120
+ hasString(value.presentationDefinition, "id") &&
121
+ hasArray(value.presentationDefinition, "input_descriptors"));
122
+ }
123
+ //# sourceMappingURL=requirements.sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requirements.sdk.js","sourceRoot":"","sources":["../../src/requirements/requirements.sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,wBAAwB,EACxB,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,SAAS,EAC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C,KAAK,EAAE,QAAQ,CAAC;QAC1B,CAAC,KAAK,CAAC,KAAK,KAAK,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC;QAChD,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;QAC/B,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;QACvB,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;QAC9B,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC;QACnC,QAAQ,CAAC,KAAK,CAAC,sBAAsB,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC,sBAAsB,EAAE,IAAI,CAAC;QAC7C,QAAQ,CAAC,KAAK,CAAC,sBAAsB,EAAE,mBAAmB,CAAC,CAC5D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./sso.sdk.js";
2
+ export * from "./sso-management.sdk.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sso/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./sso.sdk.js";
2
+ export * from "./sso-management.sdk.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sso/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { ClientDto, type CreateClientDto, type CreateUserDto, type UpdateClientDto, type UpdateUserDto, UserDto } from "../vendor/sso-bridge-dtos/index.js";
2
+ import type { SsoBridgeClient } from "../client.js";
3
+ /**
4
+ * Pagination options for list endpoints in the SSO management API.
5
+ */
6
+ export interface PaginationOptions {
7
+ /** Page number (1-based). */
8
+ page?: number;
9
+ /** Number of items per page. */
10
+ perPage?: number;
11
+ /** Sort direction. */
12
+ order?: "ASC" | "DESC";
13
+ /** Field name to order results by. */
14
+ orderBy?: string;
15
+ }
16
+ /**
17
+ * Manage SSO Bridge users, OAuth clients, and permissions.
18
+ *
19
+ * Accessible via {@link SsoSdk.management}.
20
+ * @example
21
+ * ```ts
22
+ * const users = await sdk.sso.management.getUsers({ page: 1, perPage: 10 });
23
+ * const newClient = await sdk.sso.management.createClient({
24
+ * name: "my-app",
25
+ * redirectUris: ["http://localhost:3000/callback"],
26
+ * });
27
+ * ```
28
+ */
29
+ export declare class SsoManagementSdk {
30
+ private readonly client;
31
+ constructor(client: SsoBridgeClient);
32
+ /**
33
+ * List SSO users with optional pagination.
34
+ * @param options - Pagination and sorting options.
35
+ * @returns An array of validated {@link UserDto} instances.
36
+ */
37
+ getUsers(options?: PaginationOptions): Promise<UserDto[]>;
38
+ /**
39
+ * Create a new SSO user.
40
+ * @param user - The user details.
41
+ * @returns The created {@link UserDto}.
42
+ */
43
+ createUser(user: CreateUserDto): Promise<UserDto>;
44
+ /**
45
+ * Update an existing SSO user.
46
+ * @param id - The user ID.
47
+ * @param user - The fields to update.
48
+ * @returns The updated {@link UserDto}.
49
+ */
50
+ updateUser(id: string, user: UpdateUserDto): Promise<UserDto>;
51
+ /**
52
+ * Delete an SSO user.
53
+ * @param id - The user ID.
54
+ * @returns The deletion response.
55
+ */
56
+ deleteUser(id: string): Promise<never>;
57
+ /**
58
+ * Reset two-factor authentication for an SSO user.
59
+ *
60
+ * The user will need to re-enroll in 2FA on their next login.
61
+ * @param id - The user ID.
62
+ * @returns The reset response.
63
+ */
64
+ resetUser2FA(id: string): Promise<never>;
65
+ /**
66
+ * List OAuth clients with optional pagination.
67
+ * @param options - Pagination and sorting options.
68
+ * @returns An array of validated {@link ClientDto} instances.
69
+ */
70
+ getClients(options?: PaginationOptions): Promise<ClientDto[]>;
71
+ /**
72
+ * Register a new OAuth client.
73
+ * @param client - The client details including name and redirect URIs.
74
+ * @returns The created {@link ClientDto}.
75
+ */
76
+ createClient(client: CreateClientDto): Promise<ClientDto>;
77
+ /**
78
+ * Update an existing OAuth client.
79
+ * @param id - The client ID.
80
+ * @param client - The fields to update.
81
+ * @returns The updated {@link ClientDto}.
82
+ */
83
+ updateClient(id: string, client: UpdateClientDto): Promise<ClientDto>;
84
+ /**
85
+ * Delete an OAuth client.
86
+ * @param id - The client ID.
87
+ * @returns The deletion response.
88
+ */
89
+ deleteClient(id: string): Promise<never>;
90
+ /**
91
+ * Get all available permissions in the SSO system.
92
+ * @returns The permissions configuration.
93
+ */
94
+ getPermissions(): Promise<never>;
95
+ }
96
+ //# sourceMappingURL=sso-management.sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sso-management.sdk.d.ts","sourceRoot":"","sources":["../../src/sso/sso-management.sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,OAAO,EACR,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sBAAsB;IACtB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,eAAe;IAIpD;;;;OAIG;IACG,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB;IAc1C;;;;OAIG;IACG,UAAU,CAAC,IAAI,EAAE,aAAa;IAOpC;;;;;OAKG;IACG,UAAU,CAAC,EAAE,EAA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