@textrp/briij-js-sdk 44.0.0 → 44.1.0

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 CHANGED
@@ -1,3 +1,20 @@
1
+ Changes in [44.1.0] (Unreleased - Briij JavaScript SDK)
2
+ ==================================================================================================
3
+ ## BREAKING CHANGES
4
+
5
+ - **XRPL DID/Credential Flow**:
6
+ - Added client-signed DID/Credential binding helpers:
7
+ - `configureXrplClientSignedBinding`
8
+ - `runClientSignedDidCredentialBinding`
9
+ - These helpers target server endpoints:
10
+ - `/_matrix/client/v3/did/prepare`
11
+ - `/_matrix/client/v3/did/finalize`
12
+ - `/_matrix/client/v3/credential/prepare`
13
+ - `/_matrix/client/v3/credential/finalize`
14
+ - Wallet adapters used with this flow must return both transaction hash and signed blob (`txBlob` or `signedTxBlob`) so the SDK can finalize with `tx_blob + tx_hash`.
15
+
16
+ ---
17
+
1
18
  Changes in [44.0.0] (Unreleased - Briij JavaScript SDK)
2
19
  ==================================================================================================
3
20
  BREAKING CHANGES
package/README.md CHANGED
@@ -199,6 +199,54 @@ await client.completeXrplAuth({
199
199
 
200
200
  There is a full Node example at `examples/node/xrpl-login-recovery.js`.
201
201
 
202
+ ## XRPL client-signed DID/Credential binding
203
+
204
+ For TextRP-Briij homeservers using the client-signed DID/Credential flow, use:
205
+
206
+ - `configureXrplClientSignedBinding(...)`
207
+ - `runClientSignedDidCredentialBinding(e2eePubkeyCommitment)`
208
+
209
+ This sequence calls:
210
+
211
+ 1. `POST /_matrix/client/v3/did/prepare`
212
+ 2. wallet signs/submits the unsigned DIDSet payload
213
+ 3. `POST /_matrix/client/v3/did/finalize` with `tx_blob` + `tx_hash`
214
+ 4. `POST /_matrix/client/v3/credential/prepare`
215
+ 5. wallet signs/submits the unsigned CredentialCreate payload
216
+ 6. `POST /_matrix/client/v3/credential/finalize` with `tx_blob` + `tx_hash`
217
+
218
+ Example:
219
+
220
+ ```typescript
221
+ import {
222
+ configureXrplClientSignedBinding,
223
+ runClientSignedDidCredentialBinding,
224
+ } from "@textrp/briij-js-sdk";
225
+
226
+ configureXrplClientSignedBinding({
227
+ homeserverBaseUrl: "http://localhost:8008",
228
+ accessToken: "<matrix_access_token>",
229
+ network: "xrpl",
230
+ wallet: {
231
+ getAddress: async () => "r...",
232
+ signAndSubmit: async (tx) => {
233
+ // wallet implementation must return:
234
+ // - hash: transaction hash
235
+ // - txBlob or signedTxBlob: signed tx blob string
236
+ return { hash: "ABC...", txBlob: "{...signed tx json...}" };
237
+ },
238
+ },
239
+ });
240
+
241
+ await runClientSignedDidCredentialBinding("e2ee-commitment-value");
242
+ ```
243
+
244
+ Important:
245
+
246
+ - The SDK does not hold wallet seeds.
247
+ - The wallet adapter must return the signed blob (`txBlob` or `signedTxBlob`) in addition to `hash`, otherwise finalize endpoints will fail.
248
+ - The `homeserverBaseUrl` and `accessToken` should come from the active Matrix session after login.
249
+
202
250
  ## Authenticated media
203
251
 
204
252
  Servers supporting [MSC3916](https://github.com/matrix-org/matrix-spec-proposals/pull/3916) (spec 1.11) will require clients, like
package/lib/briij.d.ts CHANGED
@@ -33,6 +33,7 @@ export { type CredentialCreateRequest, type CredentialCreateResponse, type Crede
33
33
  export * from "./auth/wallet.ts";
34
34
  export * from "./auth/zkpE2EE.ts";
35
35
  export * from "./xrpl/identity.ts";
36
+ export * from "./xrpl/clientSignedBinding.ts";
36
37
  export * from "./xrpl/trust.ts";
37
38
  export * from "./xrpl/verification.ts";
38
39
  export * from "./wallet-recovery.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"briij.d.ts","sourceRoot":"","sources":["../src/briij.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OA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,EAAE,MAAM,EACd,IAAI,EAAE,iBAAiB,EACvB,iBAAiB,UAAO,GACzB,WAAW,CAEb"}
package/lib/briij.js CHANGED
@@ -50,6 +50,7 @@ export { loadDidCredentialMetadata, requestCredentialCreate, storeDidCredentialM
50
50
  export * from "./auth/wallet.js";
51
51
  export * from "./auth/zkpE2EE.js";
52
52
  export * from "./xrpl/identity.js";
53
+ export * from "./xrpl/clientSignedBinding.js";
53
54
  export * from "./xrpl/trust.js";
54
55
  export * from "./xrpl/verification.js";
55
56
  export * from "./wallet-recovery.js";
package/lib/briij.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"briij.js","names":["MemoryCryptoStore","MemoryStore","BriijScheduler","BriijClient","RoomWidgetClient","loadDidCredentialMetadata","requestCredentialCreate","storeDidCredentialMetadata","verifyCredential","_ContentHelpers","ContentHelpers","_SecretStorage","SecretStorage","createNewBriijCall","CallEvent","GroupCall","GroupCallEvent","GroupCallIntent","GroupCallState","GroupCallType","GroupCallStatsReportEvent","SyncState","SetPresence","SlidingSyncEvent","MediaHandlerEvent","CallFeedEvent","StatsReport","Relations","RelationsEvent","TypedEventEmitter","LocalStorageErrors","localStorageErrorsEventsEmitter","IdentityProviderBrand","SSOAction","LocationAssetType","DebugLogger","cryptoStoreFactory","setCryptoStoreFactory","fac","amendClientOpts","opts","_opts$store","_opts$scheduler","_opts$cryptoStore","store","localStorage","globalThis","scheduler","cryptoStore","createClient","createRoomWidgetClient","widgetApi","capabilities","roomId","sendContentLoaded","arguments","length","undefined"],"sources":["../src/briij.ts"],"sourcesContent":["/*\nCopyright 2015-2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type WidgetApi } from \"matrix-widget-api\";\n\nimport { MemoryCryptoStore } from \"./crypto/store/memory-crypto-store.ts\";\nimport { MemoryStore } from \"./store/memory.ts\";\nimport { BriijScheduler } from \"./scheduler.ts\";\nimport { BriijClient, type ICreateClientOpts } from \"./client.ts\";\nimport { RoomWidgetClient, type ICapabilities } from \"./embedded.ts\";\nimport { type CryptoStore } from \"./crypto/store/base.ts\";\n\nexport * from \"./client.ts\";\nexport * from \"./serverCapabilities.ts\";\nexport * from \"./embedded.ts\";\nexport * from \"./http-api/index.ts\";\nexport * from \"./autodiscovery.ts\";\nexport * from \"./sync-accumulator.ts\";\nexport * from \"./errors.ts\";\nexport * from \"./base64.ts\";\nexport * from \"./models/beacon.ts\";\nexport * from \"./models/event.ts\";\nexport * from \"./models/room.ts\";\nexport * from \"./models/event-timeline.ts\";\nexport * from \"./models/event-timeline-set.ts\";\nexport * from \"./models/poll.ts\";\nexport * from \"./models/room-member.ts\";\nexport * from \"./models/room-state.ts\";\nexport * from \"./models/thread.ts\";\nexport * from \"./models/typed-event-emitter.ts\";\nexport * from \"./models/user.ts\";\nexport * from \"./models/device.ts\";\nexport * from \"./models/search-result.ts\";\nexport * from \"./oidc/index.ts\";\nexport * from \"./scheduler.ts\";\nexport * from \"./filter.ts\";\nexport * from \"./timeline-window.ts\";\nexport * from \"./interactive-auth.ts\";\nexport * from \"./auth/did.ts\";\nexport {\n type CredentialCreateRequest,\n type CredentialCreateResponse,\n type CredentialVerifyResponse,\n loadDidCredentialMetadata,\n requestCredentialCreate,\n storeDidCredentialMetadata,\n verifyCredential,\n} from \"./auth/credential.ts\";\nexport * from \"./auth/wallet.ts\";\nexport * from \"./auth/zkpE2EE.ts\";\nexport * from \"./xrpl/identity.ts\";\nexport * from \"./xrpl/trust.ts\";\nexport * from \"./xrpl/verification.ts\";\nexport * from \"./wallet-recovery.ts\";\nexport * from \"./version-support.ts\";\nexport * from \"./service-types.ts\";\nexport * from \"./store/memory.ts\";\nexport * from \"./store/indexeddb.ts\";\nexport * from \"./crypto/store/memory-crypto-store.ts\";\nexport * from \"./crypto/store/localStorage-crypto-store.ts\";\nexport * from \"./crypto/store/indexeddb-crypto-store.ts\";\nexport type { OutgoingRoomKeyRequest } from \"./crypto/store/base.ts\";\nexport * from \"./content-repo.ts\";\nexport type * from \"./@types/common.ts\";\nexport type * from \"./@types/uia.ts\";\nexport * from \"./@types/event.ts\";\nexport * from \"./@types/PushRules.ts\";\nexport * from \"./@types/partials.ts\";\nexport * from \"./@types/requests.ts\";\nexport * from \"./@types/search.ts\";\nexport * from \"./@types/beacon.ts\";\nexport * from \"./@types/topic.ts\";\nexport * from \"./@types/location.ts\";\nexport * from \"./@types/threepids.ts\";\nexport * from \"./@types/auth.ts\";\nexport * from \"./@types/synapse.ts\";\nexport * from \"./@types/polls.ts\";\nexport type * from \"./@types/local_notifications.ts\";\nexport type * from \"./@types/registration.ts\";\nexport * from \"./@types/read_receipts.ts\";\nexport * from \"./@types/crypto.ts\";\nexport * from \"./@types/extensible_events.ts\";\nexport * from \"./@types/IIdentityServerProvider.ts\";\nexport * from \"./@types/membership.ts\";\nexport * from \"./models/room-summary.ts\";\nexport * from \"./models/event-status.ts\";\nexport * from \"./models/profile-keys.ts\";\nexport * from \"./models/related-relations.ts\";\nexport type { RoomSummary } from \"./client.ts\";\nexport * as ContentHelpers from \"./content-helpers.ts\";\nexport * as SecretStorage from \"./secret-storage.ts\";\nexport { createNewBriijCall, CallEvent } from \"./webrtc/call.ts\";\nexport type { BriijCall } from \"./webrtc/call.ts\";\nexport {\n GroupCall,\n GroupCallEvent,\n GroupCallIntent,\n GroupCallState,\n GroupCallType,\n GroupCallStatsReportEvent,\n} from \"./webrtc/groupCall.ts\";\n\nexport { SyncState, SetPresence } from \"./sync.ts\";\nexport type { ISyncStateData as SyncStateData } from \"./sync.ts\";\nexport { SlidingSyncEvent } from \"./sliding-sync.ts\";\nexport { MediaHandlerEvent } from \"./webrtc/mediaHandler.ts\";\nexport { CallFeedEvent } from \"./webrtc/callFeed.ts\";\nexport { StatsReport } from \"./webrtc/stats/statsReport.ts\";\nexport { Relations, RelationsEvent } from \"./models/relations.ts\";\nexport { TypedEventEmitter } from \"./models/typed-event-emitter.ts\";\nexport { LocalStorageErrors, localStorageErrorsEventsEmitter } from \"./store/local-storage-events-emitter.ts\";\nexport { IdentityProviderBrand, SSOAction } from \"./@types/auth.ts\";\nexport type { ISSOFlow as SSOFlow, LoginFlow } from \"./@types/auth.ts\";\nexport type { IHierarchyRelation as HierarchyRelation, IHierarchyRoom as HierarchyRoom } from \"./@types/spaces.ts\";\nexport { LocationAssetType } from \"./@types/location.ts\";\nexport { DebugLogger } from \"./logger.ts\";\n\nlet cryptoStoreFactory = (): CryptoStore => new MemoryCryptoStore();\n\n/**\n * Configure a different factory to be used for creating crypto stores\n *\n * @param fac - a function which will return a new `CryptoStore`\n */\nexport function setCryptoStoreFactory(fac: () => CryptoStore): void {\n cryptoStoreFactory = fac;\n}\n\nfunction amendClientOpts(opts: ICreateClientOpts): ICreateClientOpts {\n opts.store =\n opts.store ??\n new MemoryStore({\n localStorage: globalThis.localStorage,\n });\n opts.scheduler = opts.scheduler ?? new BriijScheduler();\n opts.cryptoStore = opts.cryptoStore ?? cryptoStoreFactory();\n\n return opts;\n}\n\n/**\n * Construct a Briij client. Similar to {@link BriijClient}\n * except that the 'request', 'store' and 'scheduler' dependencies are satisfied.\n * @param opts - The configuration options for this client. These configuration\n * options will be passed directly to {@link BriijClient}.\n *\n * @returns A new Briij client.\n * @see {@link BriijClient} for the full list of options for\n * `opts`.\n */\nexport function createClient(opts: ICreateClientOpts): BriijClient {\n return new BriijClient(amendClientOpts(opts));\n}\n\n/**\n * Construct a Briij client that works in a widget.\n * This client has a subset of features compared to a full client.\n * It uses the widget-api to communicate with matrix. (widget \\<-\\> client \\<-\\> homeserver)\n * @returns A new Briij client with a subset of features.\n * @param opts - The configuration options for this client. These configuration\n * options will be passed directly to {@link BriijClient}.\n * @param widgetApi - The widget api to use for communication.\n * @param capabilities - The capabilities the widget client will request.\n * @param roomId - The room id the widget is associated with.\n * @param sendContentLoaded - Whether to send a content loaded widget action immediately after initial setup.\n * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),\n * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.\n */\nexport function createRoomWidgetClient(\n widgetApi: WidgetApi,\n capabilities: ICapabilities,\n roomId: string,\n opts: ICreateClientOpts,\n sendContentLoaded = true,\n): BriijClient {\n return new RoomWidgetClient(widgetApi, capabilities, roomId, amendClientOpts(opts), sendContentLoaded);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,iBAAiB,QAAQ,uCAAuC;AACzE,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,WAAW,QAAgC,aAAa;AACjE,SAASC,gBAAgB,QAA4B,eAAe;AAGpE,cAAc,aAAa;AAC3B,cAAc,yBAAyB;AACvC,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,oBAAoB;AAClC,cAAc,uBAAuB;AACrC,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,kBAAkB;AAChC,cAAc,4BAA4B;AAC1C,cAAc,gCAAgC;AAC9C,cAAc,kBAAkB;AAChC,cAAc,yBAAyB;AACvC,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,iCAAiC;AAC/C,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,2BAA2B;AACzC,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,SAII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OAAO,SAASU,sBAAsBA,CAClCC,SAAoB,EACpBC,YAA2B,EAC3BC,MAAc,EACdb,IAAuB,EAEZ;EAAA,IADXc,iBAAiB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAExB,OAAO,IAAInD,gBAAgB,CAAC+C,SAAS,EAAEC,YAAY,EAAEC,MAAM,EAAEd,eAAe,CAACC,IAAI,CAAC,EAAEc,iBAAiB,CAAC;AAC1G","ignoreList":[]}
1
+ {"version":3,"file":"briij.js","names":["MemoryCryptoStore","MemoryStore","BriijScheduler","BriijClient","RoomWidgetClient","loadDidCredentialMetadata","requestCredentialCreate","storeDidCredentialMetadata","verifyCredential","_ContentHelpers","ContentHelpers","_SecretStorage","SecretStorage","createNewBriijCall","CallEvent","GroupCall","GroupCallEvent","GroupCallIntent","GroupCallState","GroupCallType","GroupCallStatsReportEvent","SyncState","SetPresence","SlidingSyncEvent","MediaHandlerEvent","CallFeedEvent","StatsReport","Relations","RelationsEvent","TypedEventEmitter","LocalStorageErrors","localStorageErrorsEventsEmitter","IdentityProviderBrand","SSOAction","LocationAssetType","DebugLogger","cryptoStoreFactory","setCryptoStoreFactory","fac","amendClientOpts","opts","_opts$store","_opts$scheduler","_opts$cryptoStore","store","localStorage","globalThis","scheduler","cryptoStore","createClient","createRoomWidgetClient","widgetApi","capabilities","roomId","sendContentLoaded","arguments","length","undefined"],"sources":["../src/briij.ts"],"sourcesContent":["/*\nCopyright 2015-2022 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { type WidgetApi } from \"matrix-widget-api\";\n\nimport { MemoryCryptoStore } from \"./crypto/store/memory-crypto-store.ts\";\nimport { MemoryStore } from \"./store/memory.ts\";\nimport { BriijScheduler } from \"./scheduler.ts\";\nimport { BriijClient, type ICreateClientOpts } from \"./client.ts\";\nimport { RoomWidgetClient, type ICapabilities } from \"./embedded.ts\";\nimport { type CryptoStore } from \"./crypto/store/base.ts\";\n\nexport * from \"./client.ts\";\nexport * from \"./serverCapabilities.ts\";\nexport * from \"./embedded.ts\";\nexport * from \"./http-api/index.ts\";\nexport * from \"./autodiscovery.ts\";\nexport * from \"./sync-accumulator.ts\";\nexport * from \"./errors.ts\";\nexport * from \"./base64.ts\";\nexport * from \"./models/beacon.ts\";\nexport * from \"./models/event.ts\";\nexport * from \"./models/room.ts\";\nexport * from \"./models/event-timeline.ts\";\nexport * from \"./models/event-timeline-set.ts\";\nexport * from \"./models/poll.ts\";\nexport * from \"./models/room-member.ts\";\nexport * from \"./models/room-state.ts\";\nexport * from \"./models/thread.ts\";\nexport * from \"./models/typed-event-emitter.ts\";\nexport * from \"./models/user.ts\";\nexport * from \"./models/device.ts\";\nexport * from \"./models/search-result.ts\";\nexport * from \"./oidc/index.ts\";\nexport * from \"./scheduler.ts\";\nexport * from \"./filter.ts\";\nexport * from \"./timeline-window.ts\";\nexport * from \"./interactive-auth.ts\";\nexport * from \"./auth/did.ts\";\nexport {\n type CredentialCreateRequest,\n type CredentialCreateResponse,\n type CredentialVerifyResponse,\n loadDidCredentialMetadata,\n requestCredentialCreate,\n storeDidCredentialMetadata,\n verifyCredential,\n} from \"./auth/credential.ts\";\nexport * from \"./auth/wallet.ts\";\nexport * from \"./auth/zkpE2EE.ts\";\nexport * from \"./xrpl/identity.ts\";\nexport * from \"./xrpl/clientSignedBinding.ts\";\nexport * from \"./xrpl/trust.ts\";\nexport * from \"./xrpl/verification.ts\";\nexport * from \"./wallet-recovery.ts\";\nexport * from \"./version-support.ts\";\nexport * from \"./service-types.ts\";\nexport * from \"./store/memory.ts\";\nexport * from \"./store/indexeddb.ts\";\nexport * from \"./crypto/store/memory-crypto-store.ts\";\nexport * from \"./crypto/store/localStorage-crypto-store.ts\";\nexport * from \"./crypto/store/indexeddb-crypto-store.ts\";\nexport type { OutgoingRoomKeyRequest } from \"./crypto/store/base.ts\";\nexport * from \"./content-repo.ts\";\nexport type * from \"./@types/common.ts\";\nexport type * from \"./@types/uia.ts\";\nexport * from \"./@types/event.ts\";\nexport * from \"./@types/PushRules.ts\";\nexport * from \"./@types/partials.ts\";\nexport * from \"./@types/requests.ts\";\nexport * from \"./@types/search.ts\";\nexport * from \"./@types/beacon.ts\";\nexport * from \"./@types/topic.ts\";\nexport * from \"./@types/location.ts\";\nexport * from \"./@types/threepids.ts\";\nexport * from \"./@types/auth.ts\";\nexport * from \"./@types/synapse.ts\";\nexport * from \"./@types/polls.ts\";\nexport type * from \"./@types/local_notifications.ts\";\nexport type * from \"./@types/registration.ts\";\nexport * from \"./@types/read_receipts.ts\";\nexport * from \"./@types/crypto.ts\";\nexport * from \"./@types/extensible_events.ts\";\nexport * from \"./@types/IIdentityServerProvider.ts\";\nexport * from \"./@types/membership.ts\";\nexport * from \"./models/room-summary.ts\";\nexport * from \"./models/event-status.ts\";\nexport * from \"./models/profile-keys.ts\";\nexport * from \"./models/related-relations.ts\";\nexport type { RoomSummary } from \"./client.ts\";\nexport * as ContentHelpers from \"./content-helpers.ts\";\nexport * as SecretStorage from \"./secret-storage.ts\";\nexport { createNewBriijCall, CallEvent } from \"./webrtc/call.ts\";\nexport type { BriijCall } from \"./webrtc/call.ts\";\nexport {\n GroupCall,\n GroupCallEvent,\n GroupCallIntent,\n GroupCallState,\n GroupCallType,\n GroupCallStatsReportEvent,\n} from \"./webrtc/groupCall.ts\";\n\nexport { SyncState, SetPresence } from \"./sync.ts\";\nexport type { ISyncStateData as SyncStateData } from \"./sync.ts\";\nexport { SlidingSyncEvent } from \"./sliding-sync.ts\";\nexport { MediaHandlerEvent } from \"./webrtc/mediaHandler.ts\";\nexport { CallFeedEvent } from \"./webrtc/callFeed.ts\";\nexport { StatsReport } from \"./webrtc/stats/statsReport.ts\";\nexport { Relations, RelationsEvent } from \"./models/relations.ts\";\nexport { TypedEventEmitter } from \"./models/typed-event-emitter.ts\";\nexport { LocalStorageErrors, localStorageErrorsEventsEmitter } from \"./store/local-storage-events-emitter.ts\";\nexport { IdentityProviderBrand, SSOAction } from \"./@types/auth.ts\";\nexport type { ISSOFlow as SSOFlow, LoginFlow } from \"./@types/auth.ts\";\nexport type { IHierarchyRelation as HierarchyRelation, IHierarchyRoom as HierarchyRoom } from \"./@types/spaces.ts\";\nexport { LocationAssetType } from \"./@types/location.ts\";\nexport { DebugLogger } from \"./logger.ts\";\n\nlet cryptoStoreFactory = (): CryptoStore => new MemoryCryptoStore();\n\n/**\n * Configure a different factory to be used for creating crypto stores\n *\n * @param fac - a function which will return a new `CryptoStore`\n */\nexport function setCryptoStoreFactory(fac: () => CryptoStore): void {\n cryptoStoreFactory = fac;\n}\n\nfunction amendClientOpts(opts: ICreateClientOpts): ICreateClientOpts {\n opts.store =\n opts.store ??\n new MemoryStore({\n localStorage: globalThis.localStorage,\n });\n opts.scheduler = opts.scheduler ?? new BriijScheduler();\n opts.cryptoStore = opts.cryptoStore ?? cryptoStoreFactory();\n\n return opts;\n}\n\n/**\n * Construct a Briij client. Similar to {@link BriijClient}\n * except that the 'request', 'store' and 'scheduler' dependencies are satisfied.\n * @param opts - The configuration options for this client. These configuration\n * options will be passed directly to {@link BriijClient}.\n *\n * @returns A new Briij client.\n * @see {@link BriijClient} for the full list of options for\n * `opts`.\n */\nexport function createClient(opts: ICreateClientOpts): BriijClient {\n return new BriijClient(amendClientOpts(opts));\n}\n\n/**\n * Construct a Briij client that works in a widget.\n * This client has a subset of features compared to a full client.\n * It uses the widget-api to communicate with matrix. (widget \\<-\\> client \\<-\\> homeserver)\n * @returns A new Briij client with a subset of features.\n * @param opts - The configuration options for this client. These configuration\n * options will be passed directly to {@link BriijClient}.\n * @param widgetApi - The widget api to use for communication.\n * @param capabilities - The capabilities the widget client will request.\n * @param roomId - The room id the widget is associated with.\n * @param sendContentLoaded - Whether to send a content loaded widget action immediately after initial setup.\n * Set to `false` if the widget uses `waitForIFrameLoad=true` (in this case the client does not expect a content loaded action at all),\n * or if the the widget wants to send the `ContentLoaded` action at a later point in time after the initial setup.\n */\nexport function createRoomWidgetClient(\n widgetApi: WidgetApi,\n capabilities: ICapabilities,\n roomId: string,\n opts: ICreateClientOpts,\n sendContentLoaded = true,\n): BriijClient {\n return new RoomWidgetClient(widgetApi, capabilities, roomId, amendClientOpts(opts), sendContentLoaded);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,iBAAiB,QAAQ,uCAAuC;AACzE,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,cAAc,QAAQ,gBAAgB;AAC/C,SAASC,WAAW,QAAgC,aAAa;AACjE,SAASC,gBAAgB,QAA4B,eAAe;AAGpE,cAAc,aAAa;AAC3B,cAAc,yBAAyB;AACvC,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,oBAAoB;AAClC,cAAc,uBAAuB;AACrC,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,kBAAkB;AAChC,cAAc,4BAA4B;AAC1C,cAAc,gCAAgC;AAC9C,cAAc,kBAAkB;AAChC,cAAc,yBAAyB;AACvC,cAAc,wBAAwB;AACtC,cAAc,oBAAoB;AAClC,cAAc,iCAAiC;AAC/C,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,2BAA2B;AACzC,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,SAIIC,yBAAyB,EACzBC,uB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,OAAO,SAASU,sBAAsBA,CAClCC,SAAoB,EACpBC,YAA2B,EAC3BC,MAAc,EACdb,IAAuB,EAEZ;EAAA,IADXc,iBAAiB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAExB,OAAO,IAAInD,gBAAgB,CAAC+C,SAAS,EAAEC,YAAY,EAAEC,MAAM,EAAEd,eAAe,CAACC,IAAI,CAAC,EAAEc,iBAAiB,CAAC;AAC1G","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ export interface XrplClientSignedWalletAdapter {
2
+ getAddress(): Promise<string>;
3
+ signAndSubmit(tx: Record<string, unknown>): Promise<{
4
+ hash: string;
5
+ txBlob?: string;
6
+ signedTxBlob?: string;
7
+ }>;
8
+ }
9
+ export interface XrplClientSignedBindingConfig {
10
+ homeserverBaseUrl: string;
11
+ accessToken: string;
12
+ wallet: XrplClientSignedWalletAdapter;
13
+ network?: "xrpl" | "xahau";
14
+ }
15
+ export interface XrplClientSignedBindingResult {
16
+ did: Record<string, unknown>;
17
+ credential: Record<string, unknown>;
18
+ }
19
+ export declare function configureXrplClientSignedBinding(config: Partial<XrplClientSignedBindingConfig>): void;
20
+ export declare function runClientSignedDidCredentialBinding(e2eePubkeyCommitment: string): Promise<XrplClientSignedBindingResult>;
21
+ //# sourceMappingURL=clientSignedBinding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientSignedBinding.d.ts","sourceRoot":"","sources":["../../src/xrpl/clientSignedBinding.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,6BAA6B;IAC1C,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9B,aAAa,CAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;QAChD,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,YAAY,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC,CAAC;CACN;AAED,MAAM,WAAW,6BAA6B;IAC1C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,6BAA6B,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,6BAA6B;IAC1C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAID,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,OAAO,CAAC,6BAA6B,CAAC,GAAG,IAAI,CAKrG;AAED,wBAAsB,mCAAmC,CACrD,oBAAoB,EAAE,MAAM,GAC7B,OAAO,CAAC,6BAA6B,CAAC,CAwDxC"}
@@ -0,0 +1,112 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ /*
6
+ Copyright 2026 The Matrix.org Foundation C.I.C.
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+ */
20
+
21
+ import { logger } from "../logger.js";
22
+ var bindingConfig = {};
23
+ export function configureXrplClientSignedBinding(config) {
24
+ bindingConfig = _objectSpread(_objectSpread({}, bindingConfig), config);
25
+ }
26
+ export function runClientSignedDidCredentialBinding(_x) {
27
+ return _runClientSignedDidCredentialBinding.apply(this, arguments);
28
+ }
29
+ function _runClientSignedDidCredentialBinding() {
30
+ _runClientSignedDidCredentialBinding = _asyncToGenerator(function* (e2eePubkeyCommitment) {
31
+ var _bindingConfig$networ, _didSignResult$txBlob, _credentialSignResult;
32
+ var {
33
+ homeserverBaseUrl,
34
+ accessToken,
35
+ wallet
36
+ } = bindingConfig;
37
+ var network = (_bindingConfig$networ = bindingConfig.network) !== null && _bindingConfig$networ !== void 0 ? _bindingConfig$networ : "xrpl";
38
+ if (!homeserverBaseUrl || !accessToken || !wallet) {
39
+ throw new Error("XRPL client-signed binding is not configured");
40
+ }
41
+ var xrplAddress = yield wallet.getAddress();
42
+ var didPrepare = yield postJson(homeserverBaseUrl, accessToken, "/_matrix/client/v3/did/prepare", {
43
+ xrpl_address: xrplAddress,
44
+ network,
45
+ e2ee_pubkey_commitment: e2eePubkeyCommitment
46
+ });
47
+ var didSignResult = yield wallet.signAndSubmit(asObject(didPrepare.unsigned_tx, "did unsigned_tx"));
48
+ var didTxBlob = (_didSignResult$txBlob = didSignResult.txBlob) !== null && _didSignResult$txBlob !== void 0 ? _didSignResult$txBlob : didSignResult.signedTxBlob;
49
+ if (!didTxBlob) {
50
+ throw new Error("Wallet adapter must return txBlob/signedTxBlob for DID finalize");
51
+ }
52
+ var didFinalize = yield postJson(homeserverBaseUrl, accessToken, "/_matrix/client/v3/did/finalize", {
53
+ xrpl_address: xrplAddress,
54
+ network,
55
+ session: didPrepare.session,
56
+ tx_blob: didTxBlob,
57
+ tx_hash: didSignResult.hash
58
+ });
59
+ var credentialPrepare = yield postJson(homeserverBaseUrl, accessToken, "/_matrix/client/v3/credential/prepare", {
60
+ xrpl_address: xrplAddress,
61
+ network,
62
+ e2ee_pubkey_commitment: e2eePubkeyCommitment
63
+ });
64
+ var credentialSignResult = yield wallet.signAndSubmit(asObject(credentialPrepare.unsigned_tx, "credential unsigned_tx"));
65
+ var credentialTxBlob = (_credentialSignResult = credentialSignResult.txBlob) !== null && _credentialSignResult !== void 0 ? _credentialSignResult : credentialSignResult.signedTxBlob;
66
+ if (!credentialTxBlob) {
67
+ throw new Error("Wallet adapter must return txBlob/signedTxBlob for credential finalize");
68
+ }
69
+ var credentialFinalize = yield postJson(homeserverBaseUrl, accessToken, "/_matrix/client/v3/credential/finalize", {
70
+ xrpl_address: xrplAddress,
71
+ network,
72
+ session: credentialPrepare.session,
73
+ tx_blob: credentialTxBlob,
74
+ tx_hash: credentialSignResult.hash
75
+ });
76
+ logger.info("Completed client-signed DID/Credential binding for %s", xrplAddress);
77
+ return {
78
+ did: didFinalize,
79
+ credential: credentialFinalize
80
+ };
81
+ });
82
+ return _runClientSignedDidCredentialBinding.apply(this, arguments);
83
+ }
84
+ function asObject(value, name) {
85
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
86
+ throw new Error("Invalid ".concat(name, " payload from homeserver"));
87
+ }
88
+ return value;
89
+ }
90
+ function postJson(_x2, _x3, _x4, _x5) {
91
+ return _postJson.apply(this, arguments);
92
+ }
93
+ function _postJson() {
94
+ _postJson = _asyncToGenerator(function* (homeserverBaseUrl, accessToken, path, body) {
95
+ var response = yield fetch("".concat(homeserverBaseUrl.replace(/\/+$/, "")).concat(path), {
96
+ method: "POST",
97
+ headers: {
98
+ Authorization: "Bearer ".concat(accessToken),
99
+ "Content-Type": "application/json"
100
+ },
101
+ body: JSON.stringify(body)
102
+ });
103
+ var payload = yield response.json().catch(() => ({}));
104
+ if (!response.ok) {
105
+ var message = typeof payload.error === "string" ? payload.error : "HTTP ".concat(response.status);
106
+ throw new Error("XRPL client-signed request failed (".concat(path, "): ").concat(message));
107
+ }
108
+ return payload;
109
+ });
110
+ return _postJson.apply(this, arguments);
111
+ }
112
+ //# sourceMappingURL=clientSignedBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientSignedBinding.js","names":["logger","bindingConfig","configureXrplClientSignedBinding","config","_objectSpread","runClientSignedDidCredentialBinding","_x","_runClientSignedDidCredentialBinding","apply","arguments","_asyncToGenerator","e2eePubkeyCommitment","_bindingConfig$networ","_didSignResult$txBlob","_credentialSignResult","homeserverBaseUrl","accessToken","wallet","network","Error","xrplAddress","getAddress","didPrepare","postJson","xrpl_address","e2ee_pubkey_commitment","didSignResult","signAndSubmit","asObject","unsigned_tx","didTxBlob","txBlob","signedTxBlob","didFinalize","session","tx_blob","tx_hash","hash","credentialPrepare","credentialSignResult","credentialTxBlob","credentialFinalize","info","did","credential","value","name","Array","isArray","concat","_x2","_x3","_x4","_x5","_postJson","path","body","response","fetch","replace","method","headers","Authorization","JSON","stringify","payload","json","catch","ok","message","error","status"],"sources":["../../src/xrpl/clientSignedBinding.ts"],"sourcesContent":["/*\nCopyright 2026 The Matrix.org Foundation C.I.C.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\nimport { logger } from \"../logger.ts\";\n\nexport interface XrplClientSignedWalletAdapter {\n getAddress(): Promise<string>;\n signAndSubmit(tx: Record<string, unknown>): Promise<{\n hash: string;\n txBlob?: string;\n signedTxBlob?: string;\n }>;\n}\n\nexport interface XrplClientSignedBindingConfig {\n homeserverBaseUrl: string;\n accessToken: string;\n wallet: XrplClientSignedWalletAdapter;\n network?: \"xrpl\" | \"xahau\";\n}\n\nexport interface XrplClientSignedBindingResult {\n did: Record<string, unknown>;\n credential: Record<string, unknown>;\n}\n\nlet bindingConfig: Partial<XrplClientSignedBindingConfig> = {};\n\nexport function configureXrplClientSignedBinding(config: Partial<XrplClientSignedBindingConfig>): void {\n bindingConfig = {\n ...bindingConfig,\n ...config,\n };\n}\n\nexport async function runClientSignedDidCredentialBinding(\n e2eePubkeyCommitment: string,\n): Promise<XrplClientSignedBindingResult> {\n const { homeserverBaseUrl, accessToken, wallet } = bindingConfig;\n const network = bindingConfig.network ?? \"xrpl\";\n if (!homeserverBaseUrl || !accessToken || !wallet) {\n throw new Error(\"XRPL client-signed binding is not configured\");\n }\n\n const xrplAddress = await wallet.getAddress();\n const didPrepare = await postJson(homeserverBaseUrl, accessToken, \"/_matrix/client/v3/did/prepare\", {\n xrpl_address: xrplAddress,\n network,\n e2ee_pubkey_commitment: e2eePubkeyCommitment,\n });\n const didSignResult = await wallet.signAndSubmit(asObject(didPrepare.unsigned_tx, \"did unsigned_tx\"));\n const didTxBlob = didSignResult.txBlob ?? didSignResult.signedTxBlob;\n if (!didTxBlob) {\n throw new Error(\"Wallet adapter must return txBlob/signedTxBlob for DID finalize\");\n }\n const didFinalize = await postJson(homeserverBaseUrl, accessToken, \"/_matrix/client/v3/did/finalize\", {\n xrpl_address: xrplAddress,\n network,\n session: didPrepare.session,\n tx_blob: didTxBlob,\n tx_hash: didSignResult.hash,\n });\n\n const credentialPrepare = await postJson(homeserverBaseUrl, accessToken, \"/_matrix/client/v3/credential/prepare\", {\n xrpl_address: xrplAddress,\n network,\n e2ee_pubkey_commitment: e2eePubkeyCommitment,\n });\n const credentialSignResult = await wallet.signAndSubmit(\n asObject(credentialPrepare.unsigned_tx, \"credential unsigned_tx\"),\n );\n const credentialTxBlob = credentialSignResult.txBlob ?? credentialSignResult.signedTxBlob;\n if (!credentialTxBlob) {\n throw new Error(\"Wallet adapter must return txBlob/signedTxBlob for credential finalize\");\n }\n const credentialFinalize = await postJson(\n homeserverBaseUrl,\n accessToken,\n \"/_matrix/client/v3/credential/finalize\",\n {\n xrpl_address: xrplAddress,\n network,\n session: credentialPrepare.session,\n tx_blob: credentialTxBlob,\n tx_hash: credentialSignResult.hash,\n },\n );\n\n logger.info(\"Completed client-signed DID/Credential binding for %s\", xrplAddress);\n return {\n did: didFinalize,\n credential: credentialFinalize,\n };\n}\n\nfunction asObject(value: unknown, name: string): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Error(`Invalid ${name} payload from homeserver`);\n }\n return value as Record<string, unknown>;\n}\n\nasync function postJson(\n homeserverBaseUrl: string,\n accessToken: string,\n path: string,\n body: Record<string, unknown>,\n): Promise<Record<string, unknown>> {\n const response = await fetch(`${homeserverBaseUrl.replace(/\\/+$/, \"\")}${path}`, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(body),\n });\n const payload = (await response.json().catch(() => ({}))) as Record<string, unknown>;\n if (!response.ok) {\n const message = typeof payload.error === \"string\" ? payload.error : `HTTP ${response.status}`;\n throw new Error(`XRPL client-signed request failed (${path}): ${message}`);\n }\n return payload;\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,QAAQ,cAAc;AAuBrC,IAAIC,aAAqD,GAAG,CAAC,CAAC;AAE9D,OAAO,SAASC,gCAAgCA,CAACC,MAA8C,EAAQ;EACnGF,aAAa,GAAAG,aAAA,CAAAA,aAAA,KACNH,aAAa,GACbE,MAAM,CACZ;AACL;AAEA,gBAAsBE,mCAAmCA,CAAAC,EAAA;EAAA,OAAAC,oCAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AA0DxD,SAAAF,qCAAA;EAAAA,oCAAA,GAAAG,iBAAA,C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AAA;AAAA,SAAA6C,UAAA;EAAAA,SAAA,GAAA5C,iBAAA,CAAvB,WACIK,iBAAyB,EACzBC,WAAmB,EACnBuC,IAAY,EACZC,IAA6B,EACG;IAChC,IAAMC,QAAQ,SAASC,KAAK,IAAAT,MAAA,CAAIlC,iBAAiB,CAAC4C,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAAV,MAAA,CAAGM,IAAI,GAAI;MAC5EK,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE;QACLC,aAAa,YAAAb,MAAA,CAAYjC,WAAW,CAAE;QACtC,cAAc,EAAE;MACpB,CAAC;MACDwC,IAAI,EAAEO,IAAI,CAACC,SAAS,CAACR,IAAI;IAC7B,CAAC,CAAC;IACF,IAAMS,OAAO,SAAUR,QAAQ,CAACS,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAA6B;IACpF,IAAI,CAACV,QAAQ,CAACW,EAAE,EAAE;MACd,IAAMC,OAAO,GAAG,OAAOJ,OAAO,CAACK,KAAK,KAAK,QAAQ,GAAGL,OAAO,CAACK,KAAK,WAAArB,MAAA,CAAWQ,QAAQ,CAACc,MAAM,CAAE;MAC7F,MAAM,IAAIpD,KAAK,uCAAA8B,MAAA,CAAuCM,IAAI,SAAAN,MAAA,CAAMoB,OAAO,CAAE,CAAC;IAC9E;IACA,OAAOJ,OAAO;EAClB,CAAC;EAAA,OAAAX,SAAA,CAAA9C,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textrp/briij-js-sdk",
3
- "version": "44.0.0",
3
+ "version": "44.1.0",
4
4
  "description": "Briij Client-Server SDK for JavaScript and TypeScript",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
package/src/briij.ts CHANGED
@@ -62,6 +62,7 @@ export {
62
62
  export * from "./auth/wallet.ts";
63
63
  export * from "./auth/zkpE2EE.ts";
64
64
  export * from "./xrpl/identity.ts";
65
+ export * from "./xrpl/clientSignedBinding.ts";
65
66
  export * from "./xrpl/trust.ts";
66
67
  export * from "./xrpl/verification.ts";
67
68
  export * from "./wallet-recovery.ts";
@@ -0,0 +1,136 @@
1
+ /*
2
+ Copyright 2026 The Matrix.org Foundation C.I.C.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ import { logger } from "../logger.ts";
18
+
19
+ export interface XrplClientSignedWalletAdapter {
20
+ getAddress(): Promise<string>;
21
+ signAndSubmit(tx: Record<string, unknown>): Promise<{
22
+ hash: string;
23
+ txBlob?: string;
24
+ signedTxBlob?: string;
25
+ }>;
26
+ }
27
+
28
+ export interface XrplClientSignedBindingConfig {
29
+ homeserverBaseUrl: string;
30
+ accessToken: string;
31
+ wallet: XrplClientSignedWalletAdapter;
32
+ network?: "xrpl" | "xahau";
33
+ }
34
+
35
+ export interface XrplClientSignedBindingResult {
36
+ did: Record<string, unknown>;
37
+ credential: Record<string, unknown>;
38
+ }
39
+
40
+ let bindingConfig: Partial<XrplClientSignedBindingConfig> = {};
41
+
42
+ export function configureXrplClientSignedBinding(config: Partial<XrplClientSignedBindingConfig>): void {
43
+ bindingConfig = {
44
+ ...bindingConfig,
45
+ ...config,
46
+ };
47
+ }
48
+
49
+ export async function runClientSignedDidCredentialBinding(
50
+ e2eePubkeyCommitment: string,
51
+ ): Promise<XrplClientSignedBindingResult> {
52
+ const { homeserverBaseUrl, accessToken, wallet } = bindingConfig;
53
+ const network = bindingConfig.network ?? "xrpl";
54
+ if (!homeserverBaseUrl || !accessToken || !wallet) {
55
+ throw new Error("XRPL client-signed binding is not configured");
56
+ }
57
+
58
+ const xrplAddress = await wallet.getAddress();
59
+ const didPrepare = await postJson(homeserverBaseUrl, accessToken, "/_matrix/client/v3/did/prepare", {
60
+ xrpl_address: xrplAddress,
61
+ network,
62
+ e2ee_pubkey_commitment: e2eePubkeyCommitment,
63
+ });
64
+ const didSignResult = await wallet.signAndSubmit(asObject(didPrepare.unsigned_tx, "did unsigned_tx"));
65
+ const didTxBlob = didSignResult.txBlob ?? didSignResult.signedTxBlob;
66
+ if (!didTxBlob) {
67
+ throw new Error("Wallet adapter must return txBlob/signedTxBlob for DID finalize");
68
+ }
69
+ const didFinalize = await postJson(homeserverBaseUrl, accessToken, "/_matrix/client/v3/did/finalize", {
70
+ xrpl_address: xrplAddress,
71
+ network,
72
+ session: didPrepare.session,
73
+ tx_blob: didTxBlob,
74
+ tx_hash: didSignResult.hash,
75
+ });
76
+
77
+ const credentialPrepare = await postJson(homeserverBaseUrl, accessToken, "/_matrix/client/v3/credential/prepare", {
78
+ xrpl_address: xrplAddress,
79
+ network,
80
+ e2ee_pubkey_commitment: e2eePubkeyCommitment,
81
+ });
82
+ const credentialSignResult = await wallet.signAndSubmit(
83
+ asObject(credentialPrepare.unsigned_tx, "credential unsigned_tx"),
84
+ );
85
+ const credentialTxBlob = credentialSignResult.txBlob ?? credentialSignResult.signedTxBlob;
86
+ if (!credentialTxBlob) {
87
+ throw new Error("Wallet adapter must return txBlob/signedTxBlob for credential finalize");
88
+ }
89
+ const credentialFinalize = await postJson(
90
+ homeserverBaseUrl,
91
+ accessToken,
92
+ "/_matrix/client/v3/credential/finalize",
93
+ {
94
+ xrpl_address: xrplAddress,
95
+ network,
96
+ session: credentialPrepare.session,
97
+ tx_blob: credentialTxBlob,
98
+ tx_hash: credentialSignResult.hash,
99
+ },
100
+ );
101
+
102
+ logger.info("Completed client-signed DID/Credential binding for %s", xrplAddress);
103
+ return {
104
+ did: didFinalize,
105
+ credential: credentialFinalize,
106
+ };
107
+ }
108
+
109
+ function asObject(value: unknown, name: string): Record<string, unknown> {
110
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
111
+ throw new Error(`Invalid ${name} payload from homeserver`);
112
+ }
113
+ return value as Record<string, unknown>;
114
+ }
115
+
116
+ async function postJson(
117
+ homeserverBaseUrl: string,
118
+ accessToken: string,
119
+ path: string,
120
+ body: Record<string, unknown>,
121
+ ): Promise<Record<string, unknown>> {
122
+ const response = await fetch(`${homeserverBaseUrl.replace(/\/+$/, "")}${path}`, {
123
+ method: "POST",
124
+ headers: {
125
+ Authorization: `Bearer ${accessToken}`,
126
+ "Content-Type": "application/json",
127
+ },
128
+ body: JSON.stringify(body),
129
+ });
130
+ const payload = (await response.json().catch(() => ({}))) as Record<string, unknown>;
131
+ if (!response.ok) {
132
+ const message = typeof payload.error === "string" ? payload.error : `HTTP ${response.status}`;
133
+ throw new Error(`XRPL client-signed request failed (${path}): ${message}`);
134
+ }
135
+ return payload;
136
+ }