@textrp/briij-js-sdk 41.0.1 → 42.0.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 +14 -1
- package/LICENSE +177 -177
- package/README.md +14 -3
- package/lib/@types/AESEncryptedSecretStoragePayload.js.map +1 -1
- package/lib/@types/IIdentityServerProvider.js.map +1 -1
- package/lib/@types/PushRules.js +14 -14
- package/lib/@types/PushRules.js.map +1 -1
- package/lib/@types/another-json.d.js.map +1 -1
- package/lib/@types/auth.d.ts +19 -1
- package/lib/@types/auth.d.ts.map +1 -1
- package/lib/@types/auth.js +55 -54
- package/lib/@types/auth.js.map +1 -1
- package/lib/@types/beacon.js +100 -100
- package/lib/@types/beacon.js.map +1 -1
- package/lib/@types/common.js.map +1 -1
- package/lib/@types/crypto.js.map +1 -1
- package/lib/@types/event.d.ts +27 -0
- package/lib/@types/event.d.ts.map +1 -1
- package/lib/@types/event.js +105 -102
- package/lib/@types/event.js.map +1 -1
- package/lib/@types/events.js.map +1 -1
- package/lib/@types/extensible_events.js +53 -53
- package/lib/@types/extensible_events.js.map +1 -1
- package/lib/@types/local_notifications.js.map +1 -1
- package/lib/@types/location.js +41 -41
- package/lib/@types/location.js.map +1 -1
- package/lib/@types/matrix-sdk-crypto-wasm.d.js.map +1 -1
- package/lib/@types/media.js.map +1 -1
- package/lib/@types/membership.js +39 -39
- package/lib/@types/membership.js.map +1 -1
- package/lib/@types/partials.js +25 -25
- package/lib/@types/partials.js.map +1 -1
- package/lib/@types/polls.js +46 -46
- package/lib/@types/polls.js.map +1 -1
- package/lib/@types/read_receipts.js +14 -14
- package/lib/@types/read_receipts.js.map +1 -1
- package/lib/@types/registration.js.map +1 -1
- package/lib/@types/search.js +14 -14
- package/lib/@types/search.js.map +1 -1
- package/lib/@types/signed.js.map +1 -1
- package/lib/@types/spaces.js.map +1 -1
- package/lib/@types/state_events.js.map +1 -1
- package/lib/@types/synapse.js.map +1 -1
- package/lib/@types/sync.js +18 -18
- package/lib/@types/sync.js.map +1 -1
- package/lib/@types/threepids.js +14 -14
- package/lib/@types/threepids.js.map +1 -1
- package/lib/@types/topic.js +47 -47
- package/lib/@types/topic.js.map +1 -1
- package/lib/@types/uia.js.map +1 -1
- package/lib/NamespacedValue.js +20 -20
- package/lib/NamespacedValue.js.map +1 -1
- package/lib/ReEmitter.js +16 -16
- package/lib/ReEmitter.js.map +1 -1
- package/lib/base64.js +32 -32
- package/lib/base64.js.map +1 -1
- package/lib/briij.d.ts +3 -0
- package/lib/briij.d.ts.map +1 -1
- package/lib/briij.js +3 -0
- package/lib/briij.js.map +1 -1
- package/lib/client.d.ts +18 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +166 -103
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/key-passphrase.js +19 -19
- package/lib/common-crypto/key-passphrase.js.map +1 -1
- package/lib/content-helpers.js +57 -57
- package/lib/content-helpers.js.map +1 -1
- package/lib/content-repo.js +36 -36
- package/lib/content-repo.js.map +1 -1
- package/lib/crypto/store/base.js +69 -69
- package/lib/crypto/store/base.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store-backend.js +58 -58
- package/lib/crypto/store/indexeddb-crypto-store-backend.js.map +1 -1
- package/lib/crypto/store/indexeddb-crypto-store.js +193 -193
- package/lib/crypto/store/indexeddb-crypto-store.js.map +1 -1
- package/lib/crypto/store/localStorage-crypto-store.js +72 -72
- package/lib/crypto/store/localStorage-crypto-store.js.map +1 -1
- package/lib/crypto/store/memory-crypto-store.js +74 -74
- package/lib/crypto/store/memory-crypto-store.js.map +1 -1
- package/lib/crypto-api/CryptoEventHandlerMap.js.map +1 -1
- package/lib/crypto-api/key-passphrase.js +22 -22
- package/lib/crypto-api/key-passphrase.js.map +1 -1
- package/lib/crypto-api/keybackup.js.map +1 -1
- package/lib/crypto-api/recovery-key.js +20 -20
- package/lib/crypto-api/recovery-key.js.map +1 -1
- package/lib/digest.js +21 -21
- package/lib/digest.js.map +1 -1
- package/lib/extensible_events_v1/ExtensibleEvent.js +39 -39
- package/lib/extensible_events_v1/ExtensibleEvent.js.map +1 -1
- package/lib/extensible_events_v1/InvalidEventError.js +16 -16
- package/lib/extensible_events_v1/InvalidEventError.js.map +1 -1
- package/lib/extensible_events_v1/MessageEvent.js +39 -39
- package/lib/extensible_events_v1/MessageEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollEndEvent.js +29 -29
- package/lib/extensible_events_v1/PollEndEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollResponseEvent.js +39 -39
- package/lib/extensible_events_v1/PollResponseEvent.js.map +1 -1
- package/lib/extensible_events_v1/PollStartEvent.js +52 -52
- package/lib/extensible_events_v1/PollStartEvent.js.map +1 -1
- package/lib/extensible_events_v1/utilities.js +22 -22
- package/lib/extensible_events_v1/utilities.js.map +1 -1
- package/lib/feature.js +16 -16
- package/lib/feature.js.map +1 -1
- package/lib/http-api/method.js +14 -14
- package/lib/http-api/method.js.map +1 -1
- package/lib/http-api/prefix.js +26 -26
- package/lib/http-api/prefix.js.map +1 -1
- package/lib/indexeddb-helpers.js +21 -21
- package/lib/indexeddb-helpers.js.map +1 -1
- package/lib/indexeddb-worker.js +18 -18
- package/lib/indexeddb-worker.js.map +1 -1
- package/lib/matrixrtc/IKeyTransport.js +17 -17
- package/lib/matrixrtc/IKeyTransport.js.map +1 -1
- package/lib/matrixrtc/IMembershipManager.js +27 -27
- package/lib/matrixrtc/IMembershipManager.js.map +1 -1
- package/lib/matrixrtc/LivekitTransport.js +19 -19
- package/lib/matrixrtc/LivekitTransport.js.map +1 -1
- package/lib/matrixrtc/index.js +14 -14
- package/lib/matrixrtc/index.js.map +1 -1
- package/lib/matrixrtc/utils.js +27 -27
- package/lib/matrixrtc/utils.js.map +1 -1
- package/lib/models/ToDeviceMessage.js.map +1 -1
- package/lib/models/device.js +24 -24
- package/lib/models/device.js.map +1 -1
- package/lib/models/event-status.js +17 -17
- package/lib/models/event-status.js.map +1 -1
- package/lib/models/invites-ignorer-types.js +25 -25
- package/lib/models/invites-ignorer-types.js.map +1 -1
- package/lib/models/profile-keys.js +26 -26
- package/lib/models/profile-keys.js.map +1 -1
- package/lib/models/room-summary.js +26 -26
- package/lib/models/room-summary.js.map +1 -1
- package/lib/models/search-result.js +22 -22
- package/lib/models/search-result.js.map +1 -1
- package/lib/models/typed-event-emitter.js +122 -122
- package/lib/models/typed-event-emitter.js.map +1 -1
- package/lib/oidc/authorize.js +76 -76
- package/lib/oidc/authorize.js.map +1 -1
- package/lib/oidc/error.js +17 -17
- package/lib/oidc/error.js.map +1 -1
- package/lib/oidc/index.js +17 -17
- package/lib/oidc/index.js.map +1 -1
- package/lib/oidc/register.js +41 -41
- package/lib/oidc/register.js.map +1 -1
- package/lib/oidc/tokenRefresher.js +51 -51
- package/lib/oidc/tokenRefresher.js.map +1 -1
- package/lib/oidc/validate.js +59 -59
- package/lib/oidc/validate.js.map +1 -1
- package/lib/randomstring.js +35 -35
- package/lib/randomstring.js.map +1 -1
- package/lib/realtime-callbacks.js +39 -39
- package/lib/realtime-callbacks.js.map +1 -1
- package/lib/receipt-accumulator.js +44 -44
- package/lib/receipt-accumulator.js.map +1 -1
- package/lib/rendezvous/RendezvousChannel.js.map +1 -1
- package/lib/rendezvous/RendezvousCode.js.map +1 -1
- package/lib/rendezvous/RendezvousError.js +14 -14
- package/lib/rendezvous/RendezvousError.js.map +1 -1
- package/lib/rendezvous/RendezvousFailureReason.js +14 -14
- package/lib/rendezvous/RendezvousFailureReason.js.map +1 -1
- package/lib/rendezvous/RendezvousIntent.js +14 -14
- package/lib/rendezvous/RendezvousIntent.js.map +1 -1
- package/lib/rendezvous/RendezvousTransport.js.map +1 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +63 -63
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/lib/rendezvous/channels/index.js +14 -14
- package/lib/rendezvous/channels/index.js.map +1 -1
- package/lib/rendezvous/index.js +14 -14
- package/lib/rendezvous/index.js.map +1 -1
- package/lib/rendezvous/transports/index.js +14 -14
- package/lib/rendezvous/transports/index.js.map +1 -1
- package/lib/rust-crypto/CrossSigningIdentity.js +29 -29
- package/lib/rust-crypto/CrossSigningIdentity.js.map +1 -1
- package/lib/rust-crypto/OutgoingRequestsManager.js +37 -37
- package/lib/rust-crypto/OutgoingRequestsManager.js.map +1 -1
- package/lib/rust-crypto/device-converter.js +30 -30
- package/lib/rust-crypto/device-converter.js.map +1 -1
- package/lib/rust-crypto/secret-storage.js +30 -30
- package/lib/rust-crypto/secret-storage.js.map +1 -1
- package/lib/service-types.js +14 -14
- package/lib/service-types.js.map +1 -1
- package/lib/store/local-storage-events-emitter.js +21 -21
- package/lib/store/local-storage-events-emitter.js.map +1 -1
- package/lib/sync-accumulator.js +50 -50
- package/lib/sync-accumulator.js.map +1 -1
- package/lib/thread-utils.js +20 -20
- package/lib/thread-utils.js.map +1 -1
- package/lib/types.js +34 -34
- package/lib/types.js.map +1 -1
- package/lib/utils/decryptAESSecretStorageItem.js +22 -22
- package/lib/utils/decryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/encryptAESSecretStorageItem.js +26 -26
- package/lib/utils/encryptAESSecretStorageItem.js.map +1 -1
- package/lib/utils/internal/deriveKeys.js +21 -21
- package/lib/utils/internal/deriveKeys.js.map +1 -1
- package/lib/utils/roomVersion.js +26 -26
- package/lib/utils/roomVersion.js.map +1 -1
- package/lib/version-support.js +26 -26
- package/lib/version-support.js.map +1 -1
- package/lib/webrtc/audioContext.js +24 -24
- package/lib/webrtc/audioContext.js.map +1 -1
- package/lib/webrtc/callEventTypes.js.map +1 -1
- package/lib/webrtc/stats/callFeedStatsReporter.js +14 -14
- package/lib/webrtc/stats/callFeedStatsReporter.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportGatherer.js +14 -14
- package/lib/webrtc/stats/callStatsReportGatherer.js.map +1 -1
- package/lib/webrtc/stats/callStatsReportSummary.js.map +1 -1
- package/lib/webrtc/stats/connectionStats.js +14 -14
- package/lib/webrtc/stats/connectionStats.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsBuilder.js +14 -14
- package/lib/webrtc/stats/connectionStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/connectionStatsReportBuilder.js +14 -14
- package/lib/webrtc/stats/connectionStatsReportBuilder.js.map +1 -1
- package/lib/webrtc/stats/groupCallStats.js +14 -14
- package/lib/webrtc/stats/groupCallStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaSsrcHandler.js +14 -14
- package/lib/webrtc/stats/media/mediaSsrcHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackHandler.js +14 -14
- package/lib/webrtc/stats/media/mediaTrackHandler.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStats.js +27 -27
- package/lib/webrtc/stats/media/mediaTrackStats.js.map +1 -1
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js +20 -20
- package/lib/webrtc/stats/media/mediaTrackStatsHandler.js.map +1 -1
- package/lib/webrtc/stats/statsReport.js +14 -14
- package/lib/webrtc/stats/statsReport.js.map +1 -1
- package/lib/webrtc/stats/statsReportEmitter.js +14 -14
- package/lib/webrtc/stats/statsReportEmitter.js.map +1 -1
- package/lib/webrtc/stats/trackStatsBuilder.js +4 -4
- package/lib/webrtc/stats/trackStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/transportStats.js.map +1 -1
- package/lib/webrtc/stats/transportStatsBuilder.js.map +1 -1
- package/lib/webrtc/stats/valueFormatter.js +11 -11
- package/lib/webrtc/stats/valueFormatter.js.map +1 -1
- package/lib/xrpl/identity.d.ts +28 -0
- package/lib/xrpl/identity.d.ts.map +1 -0
- package/lib/xrpl/identity.js +213 -0
- package/lib/xrpl/identity.js.map +1 -0
- package/lib/xrpl/trust.d.ts +8 -0
- package/lib/xrpl/trust.d.ts.map +1 -0
- package/lib/xrpl/trust.js +61 -0
- package/lib/xrpl/trust.js.map +1 -0
- package/lib/xrpl/verification.d.ts +26 -0
- package/lib/xrpl/verification.d.ts.map +1 -0
- package/lib/xrpl/verification.js +295 -0
- package/lib/xrpl/verification.js.map +1 -0
- package/package.json +128 -129
- package/src/@types/AESEncryptedSecretStoragePayload.ts +29 -29
- package/src/@types/IIdentityServerProvider.ts +24 -24
- package/src/@types/PushRules.ts +208 -208
- package/src/@types/another-json.d.ts +19 -19
- package/src/@types/auth.ts +280 -258
- package/src/@types/beacon.ts +140 -140
- package/src/@types/common.ts +24 -24
- package/src/@types/crypto.ts +71 -71
- package/src/@types/event.ts +476 -449
- package/src/@types/events.ts +119 -119
- package/src/@types/extensible_events.ts +147 -147
- package/src/@types/local_notifications.ts +19 -19
- package/src/@types/location.ts +92 -92
- package/src/@types/matrix-sdk-crypto-wasm.d.ts +39 -39
- package/src/@types/media.ts +245 -245
- package/src/@types/membership.ts +57 -57
- package/src/@types/partials.ts +103 -103
- package/src/@types/polls.ts +120 -120
- package/src/@types/read_receipts.ts +61 -61
- package/src/@types/registration.ts +102 -102
- package/src/@types/search.ts +119 -119
- package/src/@types/signed.ts +25 -25
- package/src/@types/spaces.ts +37 -37
- package/src/@types/state_events.ts +153 -153
- package/src/@types/synapse.ts +40 -40
- package/src/@types/sync.ts +27 -27
- package/src/@types/threepids.ts +29 -29
- package/src/@types/topic.ts +69 -69
- package/src/@types/uia.ts +24 -24
- package/src/NamespacedValue.ts +121 -121
- package/src/ReEmitter.ts +93 -93
- package/src/base64.ts +86 -86
- package/src/briij.ts +3 -0
- package/src/client.ts +90 -10
- package/src/common-crypto/README.md +4 -4
- package/src/common-crypto/key-passphrase.ts +43 -43
- package/src/content-helpers.ts +298 -298
- package/src/content-repo.ts +122 -122
- package/src/crypto/store/base.ts +388 -388
- package/src/crypto/store/indexeddb-crypto-store-backend.ts +655 -655
- package/src/crypto/store/indexeddb-crypto-store.ts +555 -555
- package/src/crypto/store/localStorage-crypto-store.ts +409 -409
- package/src/crypto/store/memory-crypto-store.ts +326 -326
- package/src/crypto-api/CryptoEventHandlerMap.ts +42 -42
- package/src/crypto-api/key-passphrase.ts +58 -58
- package/src/crypto-api/keybackup.ts +114 -114
- package/src/crypto-api/recovery-key.ts +69 -69
- package/src/digest.ts +34 -34
- package/src/extensible_events_v1/ExtensibleEvent.ts +58 -58
- package/src/extensible_events_v1/InvalidEventError.ts +24 -24
- package/src/extensible_events_v1/MessageEvent.ts +143 -143
- package/src/extensible_events_v1/PollEndEvent.ts +97 -97
- package/src/extensible_events_v1/PollResponseEvent.ts +148 -148
- package/src/extensible_events_v1/PollStartEvent.ts +207 -207
- package/src/extensible_events_v1/utilities.ts +35 -35
- package/src/feature.ts +88 -88
- package/src/http-api/method.ts +25 -25
- package/src/http-api/prefix.ts +48 -48
- package/src/indexeddb-helpers.ts +50 -50
- package/src/indexeddb-worker.ts +24 -24
- package/src/matrixrtc/IKeyTransport.ts +63 -63
- package/src/matrixrtc/IMembershipManager.ts +120 -120
- package/src/matrixrtc/LivekitTransport.ts +46 -46
- package/src/matrixrtc/index.ts +24 -24
- package/src/matrixrtc/utils.ts +71 -71
- package/src/models/ToDeviceMessage.ts +38 -38
- package/src/models/device.ts +85 -85
- package/src/models/event-status.ts +39 -39
- package/src/models/invites-ignorer-types.ts +58 -58
- package/src/models/profile-keys.ts +33 -33
- package/src/models/room-summary.ts +78 -78
- package/src/models/search-result.ts +57 -57
- package/src/models/typed-event-emitter.ts +246 -246
- package/src/oidc/authorize.ts +279 -279
- package/src/oidc/error.ts +33 -33
- package/src/oidc/index.ts +33 -33
- package/src/oidc/register.ts +163 -163
- package/src/oidc/tokenRefresher.ts +184 -184
- package/src/oidc/validate.ts +265 -265
- package/src/randomstring.ts +103 -103
- package/src/realtime-callbacks.ts +191 -191
- package/src/receipt-accumulator.ts +189 -189
- package/src/rendezvous/RendezvousChannel.ts +48 -48
- package/src/rendezvous/RendezvousCode.ts +25 -25
- package/src/rendezvous/RendezvousError.ts +26 -26
- package/src/rendezvous/RendezvousFailureReason.ts +49 -49
- package/src/rendezvous/RendezvousIntent.ts +20 -20
- package/src/rendezvous/RendezvousTransport.ts +58 -58
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +270 -270
- package/src/rendezvous/channels/index.ts +17 -17
- package/src/rendezvous/index.ts +25 -25
- package/src/rendezvous/transports/index.ts +17 -17
- package/src/rust-crypto/CrossSigningIdentity.ts +195 -195
- package/src/rust-crypto/OutgoingRequestsManager.ts +170 -170
- package/src/rust-crypto/device-converter.ts +128 -128
- package/src/rust-crypto/secret-storage.ts +60 -60
- package/src/service-types.ts +20 -20
- package/src/store/local-storage-events-emitter.ts +46 -46
- package/src/sync-accumulator.ts +779 -779
- package/src/thread-utils.ts +31 -31
- package/src/types.ts +59 -59
- package/src/utils/decryptAESSecretStorageItem.ts +54 -54
- package/src/utils/encryptAESSecretStorageItem.ts +73 -73
- package/src/utils/internal/deriveKeys.ts +63 -63
- package/src/utils/roomVersion.ts +35 -35
- package/src/version-support.ts +50 -50
- package/src/webrtc/audioContext.ts +44 -44
- package/src/webrtc/callEventTypes.ts +101 -101
- package/src/webrtc/stats/callFeedStatsReporter.ts +91 -91
- package/src/webrtc/stats/callStatsReportGatherer.ts +219 -219
- package/src/webrtc/stats/callStatsReportSummary.ts +30 -30
- package/src/webrtc/stats/connectionStats.ts +47 -47
- package/src/webrtc/stats/connectionStatsBuilder.ts +28 -28
- package/src/webrtc/stats/connectionStatsReportBuilder.ts +140 -140
- package/src/webrtc/stats/groupCallStats.ts +93 -93
- package/src/webrtc/stats/media/mediaSsrcHandler.ts +57 -57
- package/src/webrtc/stats/media/mediaTrackHandler.ts +70 -70
- package/src/webrtc/stats/media/mediaTrackStats.ts +176 -176
- package/src/webrtc/stats/media/mediaTrackStatsHandler.ts +90 -90
- package/src/webrtc/stats/statsReport.ts +133 -133
- package/src/webrtc/stats/statsReportEmitter.ts +49 -49
- package/src/webrtc/stats/trackStatsBuilder.ts +207 -207
- package/src/webrtc/stats/transportStats.ts +26 -26
- package/src/webrtc/stats/transportStatsBuilder.ts +48 -48
- package/src/webrtc/stats/valueFormatter.ts +27 -27
- package/src/xrpl/identity.ts +245 -0
- package/src/xrpl/trust.ts +64 -0
- package/src/xrpl/verification.ts +284 -0
|
@@ -0,0 +1,213 @@
|
|
|
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 { Client as XrplClient, NFTokenMintFlags } from "xrpl";
|
|
22
|
+
import { sha256 } from "../digest.js";
|
|
23
|
+
import { logger } from "../logger.js";
|
|
24
|
+
var XRPL_IDENTITY_ACCOUNT_DATA_TYPE = "io.textrp.xrpl.identity_nft";
|
|
25
|
+
var DEFAULT_XRPL_NETWORK = "testnet";
|
|
26
|
+
var DEFAULT_XRPL_TESTNET_WS = "wss://s.altnet.rippletest.net:51233";
|
|
27
|
+
var DEFAULT_XRPL_MAINNET_WS = "wss://s1.ripple.com";
|
|
28
|
+
var mintingConfig = {};
|
|
29
|
+
export function configureXrplIdentityMinting(config) {
|
|
30
|
+
mintingConfig = _objectSpread(_objectSpread({}, mintingConfig), config);
|
|
31
|
+
}
|
|
32
|
+
export function setXamanWalletForXrplIdentity(xamanWallet) {
|
|
33
|
+
mintingConfig = _objectSpread(_objectSpread({}, mintingConfig), {}, {
|
|
34
|
+
xamanWallet
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function mintSoulboundIdentityNFT(_x) {
|
|
38
|
+
return _mintSoulboundIdentityNFT.apply(this, arguments);
|
|
39
|
+
}
|
|
40
|
+
function _mintSoulboundIdentityNFT() {
|
|
41
|
+
_mintSoulboundIdentityNFT = _asyncToGenerator(function* (matrixUserId) {
|
|
42
|
+
var {
|
|
43
|
+
homeserverBaseUrl,
|
|
44
|
+
accessToken,
|
|
45
|
+
xamanWallet
|
|
46
|
+
} = mintingConfig;
|
|
47
|
+
if (!homeserverBaseUrl || !accessToken || !xamanWallet) {
|
|
48
|
+
logger.warn("Skipping XRPL identity mint for %s: missing homeserver auth and/or Xaman wallet adapter", matrixUserId);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
var existing = yield getIdentityAccountData(homeserverBaseUrl, accessToken, matrixUserId);
|
|
52
|
+
if (existing !== null && existing !== void 0 && existing.nftTokenId && existing.xrplAddress) {
|
|
53
|
+
return _objectSpread(_objectSpread({}, existing), {}, {
|
|
54
|
+
minted: false
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
var xrplAddress = yield xamanWallet.getAddress();
|
|
58
|
+
var ipfsUri = yield buildIpfsUri(matrixUserId, xrplAddress);
|
|
59
|
+
var encodedUri = toHex(ipfsUri);
|
|
60
|
+
var xrplClient = new XrplClient(resolveXrplWebSocketUrl());
|
|
61
|
+
yield xrplClient.connect();
|
|
62
|
+
try {
|
|
63
|
+
var _extractNftTokenId, _txResult$result;
|
|
64
|
+
var mintTransaction = {
|
|
65
|
+
TransactionType: "NFTokenMint",
|
|
66
|
+
Account: xrplAddress,
|
|
67
|
+
NFTokenTaxon: 0,
|
|
68
|
+
URI: encodedUri,
|
|
69
|
+
Flags: NFTokenMintFlags.tfMutable | NFTokenMintFlags.tfBurnable
|
|
70
|
+
};
|
|
71
|
+
var autofilled = yield xrplClient.autofill(mintTransaction);
|
|
72
|
+
var {
|
|
73
|
+
hash: txHash
|
|
74
|
+
} = yield xamanWallet.signAndSubmit(autofilled);
|
|
75
|
+
var txResult = yield xrplClient.request({
|
|
76
|
+
command: "tx",
|
|
77
|
+
transaction: txHash
|
|
78
|
+
});
|
|
79
|
+
var nftTokenId = (_extractNftTokenId = extractNftTokenId((_txResult$result = txResult.result) === null || _txResult$result === void 0 ? void 0 : _txResult$result.meta)) !== null && _extractNftTokenId !== void 0 ? _extractNftTokenId : yield findAccountNftByUri(xrplClient, xrplAddress, encodedUri);
|
|
80
|
+
if (!nftTokenId) {
|
|
81
|
+
throw new Error("Unable to resolve NFTokenID for transaction ".concat(txHash));
|
|
82
|
+
}
|
|
83
|
+
var accountData = {
|
|
84
|
+
nftTokenId,
|
|
85
|
+
xrplAddress,
|
|
86
|
+
ipfsUri,
|
|
87
|
+
txHash,
|
|
88
|
+
mintedAt: new Date().toISOString()
|
|
89
|
+
};
|
|
90
|
+
yield setIdentityAccountData(homeserverBaseUrl, accessToken, matrixUserId, accountData);
|
|
91
|
+
return _objectSpread(_objectSpread({}, accountData), {}, {
|
|
92
|
+
minted: true
|
|
93
|
+
});
|
|
94
|
+
} finally {
|
|
95
|
+
yield xrplClient.disconnect().catch(() => undefined);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return _mintSoulboundIdentityNFT.apply(this, arguments);
|
|
99
|
+
}
|
|
100
|
+
function buildIpfsUri(_x2, _x3) {
|
|
101
|
+
return _buildIpfsUri.apply(this, arguments);
|
|
102
|
+
}
|
|
103
|
+
function _buildIpfsUri() {
|
|
104
|
+
_buildIpfsUri = _asyncToGenerator(function* (matrixUserId, xrplAddress) {
|
|
105
|
+
if (mintingConfig.ipfsUriFactory) {
|
|
106
|
+
return yield mintingConfig.ipfsUriFactory(matrixUserId, xrplAddress);
|
|
107
|
+
}
|
|
108
|
+
var payload = JSON.stringify({
|
|
109
|
+
matrixUserId,
|
|
110
|
+
xrplAddress
|
|
111
|
+
});
|
|
112
|
+
var digest = yield sha256(payload);
|
|
113
|
+
return "ipfs://textrp-briij/".concat(toHex(digest).slice(0, 46));
|
|
114
|
+
});
|
|
115
|
+
return _buildIpfsUri.apply(this, arguments);
|
|
116
|
+
}
|
|
117
|
+
function resolveXrplWebSocketUrl() {
|
|
118
|
+
var _mintingConfig$networ;
|
|
119
|
+
if (mintingConfig.websocketUrl) return mintingConfig.websocketUrl;
|
|
120
|
+
var network = (_mintingConfig$networ = mintingConfig.network) !== null && _mintingConfig$networ !== void 0 ? _mintingConfig$networ : DEFAULT_XRPL_NETWORK;
|
|
121
|
+
return network === "mainnet" ? DEFAULT_XRPL_MAINNET_WS : DEFAULT_XRPL_TESTNET_WS;
|
|
122
|
+
}
|
|
123
|
+
function accountDataUrl(baseUrl, matrixUserId) {
|
|
124
|
+
var trimmedBaseUrl = baseUrl.replace(/\/+$/, "");
|
|
125
|
+
return "".concat(trimmedBaseUrl, "/_matrix/client/v3/user/").concat(encodeURIComponent(matrixUserId), "/account_data/").concat(encodeURIComponent(XRPL_IDENTITY_ACCOUNT_DATA_TYPE));
|
|
126
|
+
}
|
|
127
|
+
function getIdentityAccountData(_x4, _x5, _x6) {
|
|
128
|
+
return _getIdentityAccountData.apply(this, arguments);
|
|
129
|
+
}
|
|
130
|
+
function _getIdentityAccountData() {
|
|
131
|
+
_getIdentityAccountData = _asyncToGenerator(function* (homeserverBaseUrl, accessToken, matrixUserId) {
|
|
132
|
+
var response = yield fetch(accountDataUrl(homeserverBaseUrl, matrixUserId), {
|
|
133
|
+
method: "GET",
|
|
134
|
+
headers: {
|
|
135
|
+
Authorization: "Bearer ".concat(accessToken),
|
|
136
|
+
"Content-Type": "application/json"
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
if (response.status === 404) return null;
|
|
140
|
+
if (!response.ok) {
|
|
141
|
+
throw new Error("Failed to read XRPL identity account_data: HTTP ".concat(response.status));
|
|
142
|
+
}
|
|
143
|
+
return yield response.json();
|
|
144
|
+
});
|
|
145
|
+
return _getIdentityAccountData.apply(this, arguments);
|
|
146
|
+
}
|
|
147
|
+
function setIdentityAccountData(_x7, _x8, _x9, _x0) {
|
|
148
|
+
return _setIdentityAccountData.apply(this, arguments);
|
|
149
|
+
}
|
|
150
|
+
function _setIdentityAccountData() {
|
|
151
|
+
_setIdentityAccountData = _asyncToGenerator(function* (homeserverBaseUrl, accessToken, matrixUserId, payload) {
|
|
152
|
+
var response = yield fetch(accountDataUrl(homeserverBaseUrl, matrixUserId), {
|
|
153
|
+
method: "PUT",
|
|
154
|
+
headers: {
|
|
155
|
+
Authorization: "Bearer ".concat(accessToken),
|
|
156
|
+
"Content-Type": "application/json"
|
|
157
|
+
},
|
|
158
|
+
body: JSON.stringify(payload)
|
|
159
|
+
});
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
throw new Error("Failed to persist XRPL identity account_data: HTTP ".concat(response.status));
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return _setIdentityAccountData.apply(this, arguments);
|
|
165
|
+
}
|
|
166
|
+
function findAccountNftByUri(_x1, _x10, _x11) {
|
|
167
|
+
return _findAccountNftByUri.apply(this, arguments);
|
|
168
|
+
}
|
|
169
|
+
function _findAccountNftByUri() {
|
|
170
|
+
_findAccountNftByUri = _asyncToGenerator(function* (xrplClient, xrplAddress, encodedUri) {
|
|
171
|
+
var _response$result, _nft$NFTokenID;
|
|
172
|
+
var response = yield xrplClient.request({
|
|
173
|
+
command: "account_nfts",
|
|
174
|
+
account: xrplAddress
|
|
175
|
+
});
|
|
176
|
+
var targetUri = encodedUri.toUpperCase();
|
|
177
|
+
var nft = (_response$result = response.result) === null || _response$result === void 0 || (_response$result = _response$result.account_nfts) === null || _response$result === void 0 ? void 0 : _response$result.find(candidate => {
|
|
178
|
+
var _candidate$URI;
|
|
179
|
+
return ((_candidate$URI = candidate.URI) === null || _candidate$URI === void 0 ? void 0 : _candidate$URI.toUpperCase()) === targetUri;
|
|
180
|
+
});
|
|
181
|
+
return (_nft$NFTokenID = nft === null || nft === void 0 ? void 0 : nft.NFTokenID) !== null && _nft$NFTokenID !== void 0 ? _nft$NFTokenID : null;
|
|
182
|
+
});
|
|
183
|
+
return _findAccountNftByUri.apply(this, arguments);
|
|
184
|
+
}
|
|
185
|
+
function extractNftTokenId(meta) {
|
|
186
|
+
var _AffectedNodes;
|
|
187
|
+
if (!meta || typeof meta !== "object") return null;
|
|
188
|
+
var affectedNodes = (_AffectedNodes = meta.AffectedNodes) !== null && _AffectedNodes !== void 0 ? _AffectedNodes : [];
|
|
189
|
+
for (var nodeWrapper of affectedNodes) {
|
|
190
|
+
var _tokensContainer$NFTo;
|
|
191
|
+
if (!nodeWrapper || typeof nodeWrapper !== "object") continue;
|
|
192
|
+
var [nodeValue] = Object.values(nodeWrapper);
|
|
193
|
+
if (!nodeValue || typeof nodeValue !== "object") continue;
|
|
194
|
+
var newFields = nodeValue.NewFields;
|
|
195
|
+
var finalFields = nodeValue.FinalFields;
|
|
196
|
+
var tokensContainer = [newFields, finalFields].find(container => {
|
|
197
|
+
if (!container || typeof container !== "object") return false;
|
|
198
|
+
return Array.isArray(container.NFTokens);
|
|
199
|
+
});
|
|
200
|
+
var nftokens = (_tokensContainer$NFTo = tokensContainer === null || tokensContainer === void 0 ? void 0 : tokensContainer.NFTokens) !== null && _tokensContainer$NFTo !== void 0 ? _tokensContainer$NFTo : [];
|
|
201
|
+
for (var tokenEntry of nftokens) {
|
|
202
|
+
if (!tokenEntry || typeof tokenEntry !== "object") continue;
|
|
203
|
+
var token = tokenEntry.NFToken;
|
|
204
|
+
if (token !== null && token !== void 0 && token.NFTokenID) return token.NFTokenID;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
function toHex(input) {
|
|
210
|
+
var bytes = typeof input === "string" ? new TextEncoder().encode(input) : input;
|
|
211
|
+
return Array.from(bytes).map(value => value.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","names":["Client","XrplClient","NFTokenMintFlags","sha256","logger","XRPL_IDENTITY_ACCOUNT_DATA_TYPE","DEFAULT_XRPL_NETWORK","DEFAULT_XRPL_TESTNET_WS","DEFAULT_XRPL_MAINNET_WS","mintingConfig","configureXrplIdentityMinting","config","_objectSpread","setXamanWalletForXrplIdentity","xamanWallet","mintSoulboundIdentityNFT","_x","_mintSoulboundIdentityNFT","apply","arguments","_asyncToGenerator","matrixUserId","homeserverBaseUrl","accessToken","warn","existing","getIdentityAccountData","nftTokenId","xrplAddress","minted","getAddress","ipfsUri","buildIpfsUri","encodedUri","toHex","xrplClient","resolveXrplWebSocketUrl","connect","_extractNftTokenId","_txResult$result","mintTransaction","TransactionType","Account","NFTokenTaxon","URI","Flags","tfMutable","tfBurnable","autofilled","autofill","hash","txHash","signAndSubmit","txResult","request","command","transaction","extractNftTokenId","result","meta","findAccountNftByUri","Error","concat","accountData","mintedAt","Date","toISOString","setIdentityAccountData","disconnect","catch","undefined","_x2","_x3","_buildIpfsUri","ipfsUriFactory","payload","JSON","stringify","digest","slice","_mintingConfig$networ","websocketUrl","network","accountDataUrl","baseUrl","trimmedBaseUrl","replace","encodeURIComponent","_x4","_x5","_x6","_getIdentityAccountData","response","fetch","method","headers","Authorization","status","ok","json","_x7","_x8","_x9","_x0","_setIdentityAccountData","body","_x1","_x10","_x11","_findAccountNftByUri","_response$result","_nft$NFTokenID","account","targetUri","toUpperCase","nft","account_nfts","find","candidate","_candidate$URI","NFTokenID","_AffectedNodes","affectedNodes","AffectedNodes","nodeWrapper","_tokensContainer$NFTo","nodeValue","Object","values","newFields","NewFields","finalFields","FinalFields","tokensContainer","container","Array","isArray","NFTokens","nftokens","tokenEntry","token","NFToken","input","bytes","TextEncoder","encode","from","map","value","toString","padStart","join"],"sources":["../../src/xrpl/identity.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 { Client as XrplClient, NFTokenMintFlags, type NFTokenMint } from \"xrpl\";\n\nimport { sha256 } from \"../digest.ts\";\nimport { logger } from \"../logger.ts\";\n\nconst XRPL_IDENTITY_ACCOUNT_DATA_TYPE = \"io.textrp.xrpl.identity_nft\";\nconst DEFAULT_XRPL_NETWORK = \"testnet\";\nconst DEFAULT_XRPL_TESTNET_WS = \"wss://s.altnet.rippletest.net:51233\";\nconst DEFAULT_XRPL_MAINNET_WS = \"wss://s1.ripple.com\";\n\nexport interface XrplIdentityAccountData {\n nftTokenId: string;\n xrplAddress: string;\n ipfsUri: string;\n txHash: string;\n mintedAt: string;\n}\n\nexport interface XamanWalletAdapter {\n getAddress(): Promise<string>;\n signAndSubmit(tx: Record<string, unknown>): Promise<{ hash: string }>;\n}\n\nexport interface XrplIdentityMintingConfig {\n homeserverBaseUrl: string;\n accessToken: string;\n websocketUrl?: string;\n network?: \"mainnet\" | \"testnet\";\n xamanWallet: XamanWalletAdapter;\n ipfsUriFactory?: (matrixUserId: string, xrplAddress: string) => Promise<string> | string;\n}\n\nexport interface XrplIdentityMintResult extends XrplIdentityAccountData {\n minted: boolean;\n}\n\nlet mintingConfig: Partial<XrplIdentityMintingConfig> = {};\n\nexport function configureXrplIdentityMinting(config: Partial<XrplIdentityMintingConfig>): void {\n mintingConfig = {\n ...mintingConfig,\n ...config,\n };\n}\n\nexport function setXamanWalletForXrplIdentity(xamanWallet: XamanWalletAdapter): void {\n mintingConfig = {\n ...mintingConfig,\n xamanWallet,\n };\n}\n\nexport async function mintSoulboundIdentityNFT(matrixUserId: string): Promise<XrplIdentityMintResult | null> {\n const { homeserverBaseUrl, accessToken, xamanWallet } = mintingConfig;\n if (!homeserverBaseUrl || !accessToken || !xamanWallet) {\n logger.warn(\n \"Skipping XRPL identity mint for %s: missing homeserver auth and/or Xaman wallet adapter\",\n matrixUserId,\n );\n return null;\n }\n\n const existing = await getIdentityAccountData(homeserverBaseUrl, accessToken, matrixUserId);\n if (existing?.nftTokenId && existing.xrplAddress) {\n return {\n ...existing,\n minted: false,\n };\n }\n\n const xrplAddress = await xamanWallet.getAddress();\n const ipfsUri = await buildIpfsUri(matrixUserId, xrplAddress);\n const encodedUri = toHex(ipfsUri);\n\n const xrplClient = new XrplClient(resolveXrplWebSocketUrl());\n await xrplClient.connect();\n\n try {\n const mintTransaction: NFTokenMint = {\n TransactionType: \"NFTokenMint\",\n Account: xrplAddress,\n NFTokenTaxon: 0,\n URI: encodedUri,\n Flags: NFTokenMintFlags.tfMutable | NFTokenMintFlags.tfBurnable,\n };\n\n const autofilled = await xrplClient.autofill(mintTransaction);\n const { hash: txHash } = await xamanWallet.signAndSubmit(autofilled as unknown as Record<string, unknown>);\n const txResult = await xrplClient.request({\n command: \"tx\",\n transaction: txHash,\n });\n\n const nftTokenId =\n extractNftTokenId(txResult.result?.meta) ??\n (await findAccountNftByUri(xrplClient, xrplAddress, encodedUri));\n if (!nftTokenId) {\n throw new Error(`Unable to resolve NFTokenID for transaction ${txHash}`);\n }\n\n const accountData: XrplIdentityAccountData = {\n nftTokenId,\n xrplAddress,\n ipfsUri,\n txHash,\n mintedAt: new Date().toISOString(),\n };\n\n await setIdentityAccountData(homeserverBaseUrl, accessToken, matrixUserId, accountData);\n\n return {\n ...accountData,\n minted: true,\n };\n } finally {\n await xrplClient.disconnect().catch(() => undefined);\n }\n}\n\nasync function buildIpfsUri(matrixUserId: string, xrplAddress: string): Promise<string> {\n if (mintingConfig.ipfsUriFactory) {\n return await mintingConfig.ipfsUriFactory(matrixUserId, xrplAddress);\n }\n\n const payload = JSON.stringify({ matrixUserId, xrplAddress });\n const digest = await sha256(payload);\n return `ipfs://textrp-briij/${toHex(digest).slice(0, 46)}`;\n}\n\nfunction resolveXrplWebSocketUrl(): string {\n if (mintingConfig.websocketUrl) return mintingConfig.websocketUrl;\n const network = mintingConfig.network ?? DEFAULT_XRPL_NETWORK;\n return network === \"mainnet\" ? DEFAULT_XRPL_MAINNET_WS : DEFAULT_XRPL_TESTNET_WS;\n}\n\nfunction accountDataUrl(baseUrl: string, matrixUserId: string): string {\n const trimmedBaseUrl = baseUrl.replace(/\\/+$/, \"\");\n return `${trimmedBaseUrl}/_matrix/client/v3/user/${encodeURIComponent(matrixUserId)}/account_data/${encodeURIComponent(XRPL_IDENTITY_ACCOUNT_DATA_TYPE)}`;\n}\n\nasync function getIdentityAccountData(\n homeserverBaseUrl: string,\n accessToken: string,\n matrixUserId: string,\n): Promise<XrplIdentityAccountData | null> {\n const response = await fetch(accountDataUrl(homeserverBaseUrl, matrixUserId), {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (response.status === 404) return null;\n if (!response.ok) {\n throw new Error(`Failed to read XRPL identity account_data: HTTP ${response.status}`);\n }\n\n return (await response.json()) as XrplIdentityAccountData;\n}\n\nasync function setIdentityAccountData(\n homeserverBaseUrl: string,\n accessToken: string,\n matrixUserId: string,\n payload: XrplIdentityAccountData,\n): Promise<void> {\n const response = await fetch(accountDataUrl(homeserverBaseUrl, matrixUserId), {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n });\n\n if (!response.ok) {\n throw new Error(`Failed to persist XRPL identity account_data: HTTP ${response.status}`);\n }\n}\n\nasync function findAccountNftByUri(xrplClient: XrplClient, xrplAddress: string, encodedUri: string): Promise<string | null> {\n const response = await xrplClient.request({\n command: \"account_nfts\",\n account: xrplAddress,\n });\n\n const targetUri = encodedUri.toUpperCase();\n const nft = response.result?.account_nfts?.find((candidate: { URI?: string }) => {\n return candidate.URI?.toUpperCase() === targetUri;\n }) as { NFTokenID?: string } | undefined;\n\n return nft?.NFTokenID ?? null;\n}\n\nfunction extractNftTokenId(meta: unknown): string | null {\n if (!meta || typeof meta !== \"object\") return null;\n const affectedNodes = (meta as { AffectedNodes?: unknown[] }).AffectedNodes ?? [];\n\n for (const nodeWrapper of affectedNodes) {\n if (!nodeWrapper || typeof nodeWrapper !== \"object\") continue;\n const [nodeValue] = Object.values(nodeWrapper as Record<string, unknown>);\n if (!nodeValue || typeof nodeValue !== \"object\") continue;\n\n const newFields = (nodeValue as { NewFields?: unknown }).NewFields;\n const finalFields = (nodeValue as { FinalFields?: unknown }).FinalFields;\n const tokensContainer = [newFields, finalFields].find((container) => {\n if (!container || typeof container !== \"object\") return false;\n return Array.isArray((container as { NFTokens?: unknown[] }).NFTokens);\n }) as { NFTokens?: unknown[] } | undefined;\n\n const nftokens = tokensContainer?.NFTokens ?? [];\n for (const tokenEntry of nftokens) {\n if (!tokenEntry || typeof tokenEntry !== \"object\") continue;\n const token = (tokenEntry as { NFToken?: { NFTokenID?: string } }).NFToken;\n if (token?.NFTokenID) return token.NFTokenID;\n }\n }\n\n return null;\n}\n\nfunction toHex(input: string | Uint8Array): string {\n const bytes = typeof input === \"string\" ? new TextEncoder().encode(input) : input;\n return Array.from(bytes)\n .map((value) => value.toString(16).padStart(2, \"0\"))\n .join(\"\")\n .toUpperCase();\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,IAAIC,UAAU,EAAEC,gBAAgB,QAA0B,MAAM;AAE/E,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,MAAM,QAAQ,cAAc;AAErC,IAAMC,+BAA+B,GAAG,6BAA6B;AACrE,IAAMC,oBAAoB,GAAG,SAAS;AACtC,IAAMC,uBAAuB,GAAG,qCAAqC;AACrE,IAAMC,uBAAuB,GAAG,qBAAqB;AA4BrD,IAAIC,aAAiD,GAAG,CAAC,CAAC;AAE1D,OAAO,SAASC,4BAA4BA,CAACC,MAA0C,EAAQ;EAC3FF,aAAa,GAAAG,aAAA,CAAAA,aAAA,KACNH,aAAa,GACbE,MAAM,CACZ;AACL;AAEA,OAAO,SAASE,6BAA6BA,CAACC,WAA+B,EAAQ;EACjFL,aAAa,GAAAG,aAAA,CAAAA,aAAA,KACNH,aAAa;IAChBK;EAAW,EACd;AACL;AAEA,gBAAsBC,wBAAwBA,CAAAC,EAAA;EAAA,OAAAC,yBAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAiE7C,SAAAF,0BAAA;EAAAA,yBAAA,GAAAG,iBAAA,CAjEM,WAAwCC,YAAoB,EAA0C;IACzG,IAAM;MAAEC,iBAAiB;MAAEC,WAAW;MAAET;IAAY,CAAC,GAAGL,aAAa;IACrE,IAAI,CAACa,iBAAiB,IAAI,CAACC,WAAW,IAAI,CAACT,WAAW,EAAE;MACpDV,MAAM,CAACoB,IAAI,CACP,yFAAyF,EACzFH,YACJ,CAAC;MACD,OAAO,IAAI;IACf;IAEA,IAAMI,QAAQ,SAASC,sBAAsB,CAACJ,iBAAiB,EAAEC,WAAW,EAAEF,YAAY,CAAC;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AI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE,OAAO,KAAK;MAC7D,OAAOC,KAAK,CAACC,OAAO,CAAEF,SAAS,CAA8BG,QAAQ,CAAC;IAC1E,CAAC,CAAyC;IAE1C,IAAMC,QAAQ,IAAAb,qBAAA,GAAGQ,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEI,QAAQ,cAAAZ,qBAAA,cAAAA,qBAAA,GAAI,EAAE;IAChD,KAAK,IAAMc,UAAU,IAAID,QAAQ,EAAE;MAC/B,IAAI,CAACC,UAAU,IAAI,OAAOA,UAAU,KAAK,QAAQ,EAAE;MACnD,IAAMC,KAAK,GAAID,UAAU,CAA0CE,OAAO;MAC1E,IAAID,KAAK,aAALA,KAAK,eAALA,KAAK,CAAEpB,SAAS,EAAE,OAAOoB,KAAK,CAACpB,SAAS;IAChD;EACJ;EAEA,OAAO,IAAI;AACf;AAEA,SAAStF,KAAKA,CAAC4G,KAA0B,EAAU;EAC/C,IAAMC,KAAK,GAAG,OAAOD,KAAK,KAAK,QAAQ,GAAG,IAAIE,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,KAAK,CAAC,GAAGA,KAAK;EACjF,OAAOP,KAAK,CAACW,IAAI,CAACH,KAAK,CAAC,CACnBI,GAAG,CAAEC,KAAK,IAAKA,KAAK,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CACnDC,IAAI,CAAC,EAAE,CAAC,CACRrC,WAAW,CAAC,CAAC;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface XrplTrustConfig {
|
|
2
|
+
homeserverBaseUrl: string;
|
|
3
|
+
accessToken: string;
|
|
4
|
+
trustPath?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function configureXrplTrust(config: Partial<XrplTrustConfig>): void;
|
|
7
|
+
export declare function getTrustScore(payer: string, payee: string): Promise<number>;
|
|
8
|
+
//# sourceMappingURL=trust.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.d.ts","sourceRoot":"","sources":["../../src/xrpl/trust.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,eAAe;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAID,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI,CAKzE;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BjF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
var DEFAULT_TRUST_PATH = "/_matrix/client/v3/org.textrp.xrpl/trust";
|
|
22
|
+
var xrplTrustConfig = {};
|
|
23
|
+
export function configureXrplTrust(config) {
|
|
24
|
+
xrplTrustConfig = _objectSpread(_objectSpread({}, xrplTrustConfig), config);
|
|
25
|
+
}
|
|
26
|
+
export function getTrustScore(_x, _x2) {
|
|
27
|
+
return _getTrustScore.apply(this, arguments);
|
|
28
|
+
}
|
|
29
|
+
function _getTrustScore() {
|
|
30
|
+
_getTrustScore = _asyncToGenerator(function* (payer, payee) {
|
|
31
|
+
var _xrplTrustConfig$trus;
|
|
32
|
+
var homeserverBaseUrl = xrplTrustConfig.homeserverBaseUrl;
|
|
33
|
+
var accessToken = xrplTrustConfig.accessToken;
|
|
34
|
+
if (!homeserverBaseUrl || !accessToken) {
|
|
35
|
+
throw new Error("XRPL trust config is incomplete");
|
|
36
|
+
}
|
|
37
|
+
var trimmedBaseUrl = homeserverBaseUrl.replace(/\/+$/, "");
|
|
38
|
+
var trustPath = (_xrplTrustConfig$trus = xrplTrustConfig.trustPath) !== null && _xrplTrustConfig$trus !== void 0 ? _xrplTrustConfig$trus : DEFAULT_TRUST_PATH;
|
|
39
|
+
var query = new URLSearchParams({
|
|
40
|
+
payer,
|
|
41
|
+
payee
|
|
42
|
+
});
|
|
43
|
+
var response = yield fetch("".concat(trimmedBaseUrl).concat(trustPath, "?").concat(query.toString()), {
|
|
44
|
+
method: "GET",
|
|
45
|
+
headers: {
|
|
46
|
+
Authorization: "Bearer ".concat(accessToken),
|
|
47
|
+
"Content-Type": "application/json"
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error("Failed to fetch trust score: HTTP ".concat(response.status));
|
|
52
|
+
}
|
|
53
|
+
var payload = yield response.json();
|
|
54
|
+
if (typeof payload.score === "number") {
|
|
55
|
+
return payload.score;
|
|
56
|
+
}
|
|
57
|
+
return payload.trusted ? 1 : 0;
|
|
58
|
+
});
|
|
59
|
+
return _getTrustScore.apply(this, arguments);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=trust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust.js","names":["DEFAULT_TRUST_PATH","xrplTrustConfig","configureXrplTrust","config","_objectSpread","getTrustScore","_x","_x2","_getTrustScore","apply","arguments","_asyncToGenerator","payer","payee","_xrplTrustConfig$trus","homeserverBaseUrl","accessToken","Error","trimmedBaseUrl","replace","trustPath","query","URLSearchParams","response","fetch","concat","toString","method","headers","Authorization","ok","status","payload","json","score","trusted"],"sources":["../../src/xrpl/trust.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\nconst DEFAULT_TRUST_PATH = \"/_matrix/client/v3/org.textrp.xrpl/trust\";\n\nexport interface XrplTrustConfig {\n homeserverBaseUrl: string;\n accessToken: string;\n trustPath?: string;\n}\n\nlet xrplTrustConfig: Partial<XrplTrustConfig> = {};\n\nexport function configureXrplTrust(config: Partial<XrplTrustConfig>): void {\n xrplTrustConfig = {\n ...xrplTrustConfig,\n ...config,\n };\n}\n\nexport async function getTrustScore(payer: string, payee: string): Promise<number> {\n const homeserverBaseUrl = xrplTrustConfig.homeserverBaseUrl;\n const accessToken = xrplTrustConfig.accessToken;\n if (!homeserverBaseUrl || !accessToken) {\n throw new Error(\"XRPL trust config is incomplete\");\n }\n\n const trimmedBaseUrl = homeserverBaseUrl.replace(/\\/+$/, \"\");\n const trustPath = xrplTrustConfig.trustPath ?? DEFAULT_TRUST_PATH;\n const query = new URLSearchParams({\n payer,\n payee,\n });\n const response = await fetch(`${trimmedBaseUrl}${trustPath}?${query.toString()}`, {\n method: \"GET\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n });\n\n if (!response.ok) {\n throw new Error(`Failed to fetch trust score: HTTP ${response.status}`);\n }\n\n const payload = (await response.json()) as { score?: number; trusted?: boolean };\n if (typeof payload.score === \"number\") {\n return payload.score;\n }\n return payload.trusted ? 1 : 0;\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMA,kBAAkB,GAAG,0CAA0C;AAQrE,IAAIC,eAAyC,GAAG,CAAC,CAAC;AAElD,OAAO,SAASC,kBAAkBA,CAACC,MAAgC,EAAQ;EACvEF,eAAe,GAAAG,aAAA,CAAAA,aAAA,KACRH,eAAe,GACfE,MAAM,CACZ;AACL;AAEA,gBAAsBE,aAAaA,CAAAC,EAAA,EAAAC,GAAA;EAAA,OAAAC,cAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AA8BlC,SAAAF,eAAA;EAAAA,cAAA,GAAAG,iBAAA,CA9BM,WAA6BC,KAAa,EAAEC,KAAa,EAAmB;IAAA,IAAAC,qBAAA;IAC/E,IAAMC,iBAAiB,GAAGd,eAAe,CAACc,iBAAiB;IAC3D,IAAMC,WAAW,GAAGf,eAAe,CAACe,WAAW;IAC/C,IAAI,CAACD,iBAAiB,IAAI,CAACC,WAAW,EAAE;MACpC,MAAM,IAAIC,KAAK,CAAC,iCAAiC,CAAC;IACtD;IAEA,IAAMC,cAAc,GAAGH,iBAAiB,CAACI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IAC5D,IAAMC,SAAS,IAAAN,qBAAA,GAAGb,eAAe,CAACmB,SAAS,cAAAN,qBAAA,cAAAA,qBAAA,GAAId,kBAAkB;IACjE,IAAMqB,KAAK,GAAG,IAAIC,eAAe,CAAC;MAC9BV,KAAK;MACLC;IACJ,CAAC,CAAC;IACF,IAAMU,QAAQ,SAASC,KAAK,IAAAC,MAAA,CAAIP,cAAc,EAAAO,MAAA,CAAGL,SAAS,OAAAK,MAAA,CAAIJ,KAAK,CAACK,QAAQ,CAAC,CAAC,GAAI;MAC9EC,MAAM,EAAE,KAAK;MACbC,OAAO,EAAE;QACLC,aAAa,YAAAJ,MAAA,CAAYT,WAAW,CAAE;QACtC,cAAc,EAAE;MACpB;IACJ,CAAC,CAAC;IAEF,IAAI,CAACO,QAAQ,CAACO,EAAE,EAAE;MACd,MAAM,IAAIb,KAAK,sCAAAQ,MAAA,CAAsCF,QAAQ,CAACQ,MAAM,CAAE,CAAC;IAC3E;IAEA,IAAMC,OAAO,SAAUT,QAAQ,CAACU,IAAI,CAAC,CAA2C;IAChF,IAAI,OAAOD,OAAO,CAACE,KAAK,KAAK,QAAQ,EAAE;MACnC,OAAOF,OAAO,CAACE,KAAK;IACxB;IACA,OAAOF,OAAO,CAACG,OAAO,GAAG,CAAC,GAAG,CAAC;EAClC,CAAC;EAAA,OAAA3B,cAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EventType } from "../@types/event.ts";
|
|
2
|
+
import type { BriijClient } from "../client.ts";
|
|
3
|
+
import { type XamanWalletAdapter } from "./identity.ts";
|
|
4
|
+
export declare const XRPL_VERIFY_REQUEST_EVENT: EventType.UserVerifyRequest;
|
|
5
|
+
export declare const XRPL_VERIFY_ACCEPT_EVENT: EventType.UserVerifyAccept;
|
|
6
|
+
export declare const XRPL_VERIFIED_EVENT: EventType.UserVerified;
|
|
7
|
+
export interface XrplVerificationConfig {
|
|
8
|
+
matrixClient: Pick<BriijClient, "sendEvent" | "getUserId" | "getAccessToken"> & {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
};
|
|
11
|
+
xamanWallet: XamanWalletAdapter;
|
|
12
|
+
verificationRoomId?: string;
|
|
13
|
+
resolveVerificationRoomId?: (counterpartyXrplAddress: string) => Promise<string> | string;
|
|
14
|
+
pinJsonToIpfs?: (payload: Record<string, unknown>) => Promise<string>;
|
|
15
|
+
pinataJwt?: string;
|
|
16
|
+
websocketUrl?: string;
|
|
17
|
+
network?: "mainnet" | "testnet";
|
|
18
|
+
}
|
|
19
|
+
export interface XrplVerificationTxResult {
|
|
20
|
+
txHash: string;
|
|
21
|
+
credentialTypeHex: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function configureXrplVerification(config: Partial<XrplVerificationConfig>): void;
|
|
24
|
+
export declare function requestVerification(targetXrplAddress: string): Promise<XrplVerificationTxResult>;
|
|
25
|
+
export declare function acceptVerification(issuerXrplAddress: string): Promise<XrplVerificationTxResult>;
|
|
26
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../src/xrpl/verification.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,KAAK,kBAAkB,EAAgC,MAAM,eAAe,CAAC;AAEtF,eAAO,MAAM,yBAAyB,EAAE,SAAS,CAAC,iBAA+C,CAAC;AAClG,eAAO,MAAM,wBAAwB,EAAE,SAAS,CAAC,gBAA6C,CAAC;AAC/F,eAAO,MAAM,mBAAmB,EAAE,SAAS,CAAC,YAAqC,CAAC;AASlF,MAAM,WAAW,sBAAsB;IACnC,YAAY,E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