matrix-js-sdk 41.1.0 → 41.2.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 +9 -0
- package/lib/@types/requests.d.ts +3 -1
- package/lib/@types/requests.d.ts.map +1 -1
- package/lib/@types/requests.js.map +1 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +12 -7
- package/lib/client.js.map +1 -1
- package/lib/common-crypto/CryptoBackend.d.ts +6 -1
- package/lib/common-crypto/CryptoBackend.d.ts.map +1 -1
- package/lib/common-crypto/CryptoBackend.js.map +1 -1
- package/lib/crypto-api/index.d.ts +0 -7
- package/lib/crypto-api/index.d.ts.map +1 -1
- package/lib/crypto-api/index.js.map +1 -1
- package/lib/matrix.d.ts +1 -0
- package/lib/matrix.d.ts.map +1 -1
- package/lib/matrix.js +1 -0
- package/lib/matrix.js.map +1 -1
- package/lib/rendezvous/MSC4108SignInWithQR.d.ts.map +1 -1
- package/lib/rendezvous/MSC4108SignInWithQR.js +5 -5
- package/lib/rendezvous/MSC4108SignInWithQR.js.map +1 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts +3 -3
- package/lib/rendezvous/channels/MSC4108SecureChannel.d.ts.map +1 -1
- package/lib/rendezvous/channels/MSC4108SecureChannel.js +2 -2
- package/lib/rendezvous/channels/MSC4108SecureChannel.js.map +1 -1
- package/lib/rust-crypto/index.d.ts.map +1 -1
- package/lib/rust-crypto/index.js +13 -1
- package/lib/rust-crypto/index.js.map +1 -1
- package/lib/rust-crypto/rust-crypto.d.ts +3 -3
- package/lib/rust-crypto/rust-crypto.d.ts.map +1 -1
- package/lib/rust-crypto/rust-crypto.js +306 -281
- package/lib/rust-crypto/rust-crypto.js.map +1 -1
- package/package.json +3 -3
- package/src/@types/requests.ts +3 -1
- package/src/client.ts +10 -6
- package/src/common-crypto/CryptoBackend.ts +13 -1
- package/src/crypto-api/index.ts +0 -14
- package/src/matrix.ts +1 -0
- package/src/rendezvous/MSC4108SignInWithQR.ts +6 -6
- package/src/rendezvous/channels/MSC4108SecureChannel.ts +5 -5
- package/src/rust-crypto/index.ts +17 -1
- package/src/rust-crypto/rust-crypto.ts +70 -46
package/lib/matrix.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.js","names":["MemoryCryptoStore","MemoryStore","MatrixScheduler","MatrixClient","RoomWidgetClient","_ContentHelpers","ContentHelpers","_SecretStorage","SecretStorage","createNewMatrixCall","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/matrix.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 { MatrixScheduler } from \"./scheduler.ts\";\nimport { MatrixClient, 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 \"./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/polls.ts\";\nexport type * from \"./@types/local_notifications.ts\";\nexport type * from \"./@types/registration.ts\";\nexport * from \"./@types/read_receipts.ts\";\nexport type * from \"./@types/crypto.ts\";\nexport * from \"./@types/extensible_events.ts\";\nexport type * 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 { createNewMatrixCall, CallEvent } from \"./webrtc/call.ts\";\nexport type { MatrixCall } 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 MatrixScheduler();\n opts.cryptoStore = opts.cryptoStore ?? cryptoStoreFactory();\n\n return opts;\n}\n\n/**\n * Construct a Matrix Client. Similar to {@link MatrixClient}\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 MatrixClient}.\n *\n * @returns A new matrix client.\n * @see {@link MatrixClient} for the full list of options for\n * `opts`.\n */\nexport function createClient(opts: ICreateClientOpts): MatrixClient {\n return new MatrixClient(amendClientOpts(opts));\n}\n\n/**\n * Construct a Matrix 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 matrix 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 MatrixClient}.\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): MatrixClient {\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,QA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xDkC,IAAI,CAACQ,WAAW,IAAAL,iBAAA,GAAGH,IAAI,CAACQ,WAAW,cAAAL,iBAAA,cAAAA,iBAAA,GAAIP,kBAAkB,CAAC,CAAC;EAE3D,OAAOI,IAAI;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASS,YAAYA,CAACT,IAAuB,EAAgB;EAChE,OAAO,IAAIjC,YAAY,CAACgC,eAAe,CAACC,IAAI,CAAC,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASU,sBAAsBA,CAClCC,SAAoB,EACpBC,YAA2B,EAC3BC,MAAc,EACdb,IAAuB,EAEX;EAAA,IADZc,iBAAiB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAExB,OAAO,IAAI/C,gBAAgB,CAAC2C,SAAS,EAAEC,YAAY,EAAEC,MAAM,EAAEd,eAAe,CAACC,IAAI,CAAC,EAAEc,iBAAiB,CAAC;AAC1G","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"matrix.js","names":["MemoryCryptoStore","MemoryStore","MatrixScheduler","MatrixClient","RoomWidgetClient","RoomStickyEventsEvent","_ContentHelpers","ContentHelpers","_SecretStorage","SecretStorage","createNewMatrixCall","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/matrix.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 { MatrixScheduler } from \"./scheduler.ts\";\nimport { MatrixClient, 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 \"./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/polls.ts\";\nexport type * from \"./@types/local_notifications.ts\";\nexport type * from \"./@types/registration.ts\";\nexport * from \"./@types/read_receipts.ts\";\nexport type * from \"./@types/crypto.ts\";\nexport * from \"./@types/extensible_events.ts\";\nexport type * 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 StickyMatrixEvent, RoomStickyEventsEvent } from \"./models/room-sticky-events.ts\";\nexport type { RoomSummary } from \"./client.ts\";\nexport * as ContentHelpers from \"./content-helpers.ts\";\nexport * as SecretStorage from \"./secret-storage.ts\";\nexport { createNewMatrixCall, CallEvent } from \"./webrtc/call.ts\";\nexport type { MatrixCall } 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 MatrixScheduler();\n opts.cryptoStore = opts.cryptoStore ?? cryptoStoreFactory();\n\n return opts;\n}\n\n/**\n * Construct a Matrix Client. Similar to {@link MatrixClient}\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 MatrixClient}.\n *\n * @returns A new matrix client.\n * @see {@link MatrixClient} for the full list of options for\n * `opts`.\n */\nexport function createClient(opts: ICreateClientOpts): MatrixClient {\n return new MatrixClient(amendClientOpts(opts));\n}\n\n/**\n * Construct a Matrix 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 matrix 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 MatrixClient}.\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): MatrixClient {\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,eAAe,QAAQ,gBAAgB;AAChD,SAASC,YAAY,QAAgC,aAAa;AAClE,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;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AIhD,gBAAgB,CAAC4C,SAAS,EAAEC,YAAY,EAAEC,MAAM,EAAEd,eAAe,CAACC,IAAI,CAAC,EAAEc,iBAAiB,CAAC;AAC1G","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MSC4108SignInWithQR.d.ts","sourceRoot":"","sources":["../../src/rendezvous/MSC4108SignInWithQR.ts"],"names":[],"mappings":"AAkBA,OAAO,EACH,6BAA6B,EAC7B,oBAAoB,EAEpB,KAAK,yBAAyB,EACjC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAI/E,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;GAIG;AACH,oBAAY,WAAW;IACnB,SAAS,sBAAsB;IAC/B,QAAQ,qBAAqB;IAC7B,OAAO,oBAAoB;IAC3B,OAAO,oBAAoB;IAC3B,OAAO,oBAAoB;IAC3B,gBAAgB,8BAA8B;IAC9C,QAAQ,qBAAqB;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,WAAW,CAAC;CACrB;AA8CD,UAAU,cAAe,SAAQ,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC/G,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC;CAC7B;AAED;;;;GAIG;AACH,qBAAa,mBAAmB;IAmBxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,yBAAyB;IArBhD,OAAO,CAAC,QAAQ,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"MSC4108SignInWithQR.d.ts","sour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AA,EAC/B,SAAS,CAAC,EAAE,yBAAyB,YAAA;IAKhD;;OAEG;IACH,IAAW,IAAI,IAAI,UAAU,GAAG,SAAS,CAExC;IAED;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAY1C;;OAEG;IACH,IAAW,gBAAgB,IAAI,OAAO,CAErC;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED;;;;;OAKG;IACU,kBAAkB,IAAI,OAAO,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA8DnE;;;;OAIG;IACU,wBAAwB,IAAI,OAAO,CAAC;QAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IAiEF;;;OAGG;IACU,YAAY,IAAI,OAAO,CAAC;QAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;YAyFlE,OAAO;YAIP,IAAI;IAIlB;;OAEG;IACU,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC;IAU1D;;;OAGG;IACU,MAAM,CAAC,MAAM,EAAE,oBAAoB,GAAG,6BAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhG;;OAEG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC"}
|
|
@@ -18,7 +18,7 @@ See the License for the specific language governing permissions and
|
|
|
18
18
|
limitations under the License.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { QrCodeIntent } from "@matrix-org/matrix-sdk-crypto-wasm";
|
|
22
22
|
import { ClientRendezvousFailureReason, MSC4108FailureReason, RendezvousError } from "./index.js";
|
|
23
23
|
import { logger } from "../logger.js";
|
|
24
24
|
import { MatrixError } from "../http-api/index.js";
|
|
@@ -77,7 +77,7 @@ export class MSC4108SignInWithQR {
|
|
|
77
77
|
_defineProperty(this, "ourIntent", void 0);
|
|
78
78
|
_defineProperty(this, "_code", void 0);
|
|
79
79
|
_defineProperty(this, "expectingNewDeviceId", void 0);
|
|
80
|
-
this.ourIntent = client ?
|
|
80
|
+
this.ourIntent = client ? QrCodeIntent.Reciprocate : QrCodeIntent.Login;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
@@ -96,9 +96,9 @@ export class MSC4108SignInWithQR {
|
|
|
96
96
|
if (_this._code) {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
|
-
if (_this.ourIntent ===
|
|
99
|
+
if (_this.ourIntent === QrCodeIntent.Reciprocate && _this.client) {
|
|
100
100
|
_this._code = yield _this.channel.generateCode(_this.ourIntent, _this.client.getDomain());
|
|
101
|
-
} else if (_this.ourIntent ===
|
|
101
|
+
} else if (_this.ourIntent === QrCodeIntent.Login) {
|
|
102
102
|
_this._code = yield _this.channel.generateCode(_this.ourIntent);
|
|
103
103
|
}
|
|
104
104
|
})();
|
|
@@ -108,7 +108,7 @@ export class MSC4108SignInWithQR {
|
|
|
108
108
|
* Returns true if the device is the already logged in device reciprocating a new login on the other side of the channel.
|
|
109
109
|
*/
|
|
110
110
|
get isExistingDevice() {
|
|
111
|
-
return this.ourIntent ===
|
|
111
|
+
return this.ourIntent === QrCodeIntent.Reciprocate;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MSC4108SignInWithQR.js","names":["QrCodeMode","ClientRendezvousFailureReason","MSC4108FailureReason","RendezvousError","logger","MatrixError","sleep","OAuthGrantType","PayloadType","isDeviceAuthorizationGrantProtocolPayload","payload","protocol","MSC4108SignInWithQR","checkCode","_this$channel","channel","getCheckCode","constructor","didScanCode","client","onFailure","_defineProperty","ourIntent","Reciprocate","Login","code","_code","generateCode","_this","_asyncToGenerator","getDomain","isExistingDevice","isNewDevice","negotiateProtocols","_this2","info","concat","connect","_oidcClientConfig","oidcClientConfig","getAuthMetadata","e","error","grant_types_supported","includes","DeviceAuthorization","send","type","Protocols","protocols","homeserver","Failure","reason","UnsupportedProtocol","receive","UnexpectedMessageReceived","serverName","deviceAuthorizationGrant","_this3","Error","Protocol","device_authorization_grant","dag","device_id","expectingNewDeviceId","verification_uri","verificationUri","verification_uri_complete","verificationUriComplete","deviceAlreadyExists","_this3$client","getDevice","err","httpStatus","DeviceAlreadyExists","shareSecrets","_this4","Success","Secrets","secrets","ProtocolAccepted","Declined","UserDeclined","timeout","Date","now","_this4$client","device","secretsBundle","getCrypto","exportSecretsBundle","cancelled","UserCancelled","_objectSpread","DeviceNotFound","_this5","secureReceive","_this6","secureSend","declineLoginOnExistingDevice","_this7","cancel","_this8","_this8$onFailure","call","close","_this9"],"sources":["../../src/rendezvous/MSC4108SignInWithQR.ts"],"sourcesContent":["/*\nCopyright 2024 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 { QrCodeMode } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n ClientRendezvousFailureReason,\n MSC4108FailureReason,\n RendezvousError,\n type RendezvousFailureListener,\n} from \"./index.ts\";\nimport { type MatrixClient } from \"../client.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type MSC4108SecureChannel } from \"./channels/MSC4108SecureChannel.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { sleep } from \"../utils.ts\";\nimport { OAuthGrantType, type OidcClientConfig } from \"../oidc/index.ts\";\nimport { type CryptoApi } from \"../crypto-api/index.ts\";\n\n/**\n * Enum representing the payload types transmissible over [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * secure channels.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport enum PayloadType {\n Protocols = \"m.login.protocols\",\n Protocol = \"m.login.protocol\",\n Failure = \"m.login.failure\",\n Success = \"m.login.success\",\n Secrets = \"m.login.secrets\",\n ProtocolAccepted = \"m.login.protocol_accepted\",\n Declined = \"m.login.declined\",\n}\n\n/**\n * Type representing the base payload format for [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * messages sent over the secure channel.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport interface MSC4108Payload {\n type: PayloadType;\n}\n\ninterface ProtocolsPayload extends MSC4108Payload {\n type: PayloadType.Protocols;\n protocols: string[];\n homeserver: string;\n}\n\ninterface ProtocolPayload extends MSC4108Payload {\n type: PayloadType.Protocol;\n protocol: Exclude<string, \"device_authorization_grant\">;\n device_id: string;\n}\n\ninterface DeviceAuthorizationGrantProtocolPayload extends ProtocolPayload {\n protocol: \"device_authorization_grant\";\n device_authorization_grant: {\n verification_uri: string;\n verification_uri_complete?: string;\n };\n}\n\nfunction isDeviceAuthorizationGrantProtocolPayload(\n payload: ProtocolPayload,\n): payload is DeviceAuthorizationGrantProtocolPayload {\n return payload.protocol === \"device_authorization_grant\";\n}\n\ninterface FailurePayload extends MSC4108Payload {\n type: PayloadType.Failure;\n reason: MSC4108FailureReason;\n homeserver?: string;\n}\n\ninterface DeclinedPayload extends MSC4108Payload {\n type: PayloadType.Declined;\n}\n\ninterface SuccessPayload extends MSC4108Payload {\n type: PayloadType.Success;\n}\n\ninterface AcceptedPayload extends MSC4108Payload {\n type: PayloadType.ProtocolAccepted;\n}\n\ninterface SecretsPayload extends MSC4108Payload, Awaited<ReturnType<NonNullable<CryptoApi[\"exportSecretsBundle\"]>>> {\n type: PayloadType.Secrets;\n}\n\n/**\n * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * sign in with QR + OIDC flow.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport class MSC4108SignInWithQR {\n private readonly ourIntent: QrCodeMode;\n private _code?: Uint8Array;\n private expectingNewDeviceId?: string;\n\n /**\n * Returns the check code for the secure channel or undefined if not generated yet.\n */\n public get checkCode(): string | undefined {\n return this.channel?.getCheckCode();\n }\n\n /**\n * @param channel - The secure channel used for communication\n * @param client - The Matrix client in used on the device already logged in\n * @param didScanCode - Whether this side of the channel scanned the QR code from the other party\n * @param onFailure - Callback for when the rendezvous fails\n */\n public constructor(\n private readonly channel: MSC4108SecureChannel,\n private readonly didScanCode: boolean,\n private readonly client?: MatrixClient,\n public onFailure?: RendezvousFailureListener,\n ) {\n this.ourIntent = client ? QrCodeMode.Reciprocate : QrCodeMode.Login;\n }\n\n /**\n * Returns the code representing the rendezvous suitable for rendering in a QR code or undefined if not generated yet.\n */\n public get code(): Uint8Array | undefined {\n return this._code;\n }\n\n /**\n * Generate the code including doing partial set up of the channel where required.\n */\n public async generateCode(): Promise<void> {\n if (this._code) {\n return;\n }\n\n if (this.ourIntent === QrCodeMode.Reciprocate && this.client) {\n this._code = await this.channel.generateCode(this.ourIntent, this.client.getDomain()!);\n } else if (this.ourIntent === QrCodeMode.Login) {\n this._code = await this.channel.generateCode(this.ourIntent);\n }\n }\n\n /**\n * Returns true if the device is the already logged in device reciprocating a new login on the other side of the channel.\n */\n public get isExistingDevice(): boolean {\n return this.ourIntent === QrCodeMode.Reciprocate;\n }\n\n /**\n * Returns true if the device is the new device logging in being reciprocated by the device on the other side of the channel.\n */\n public get isNewDevice(): boolean {\n return !this.isExistingDevice;\n }\n\n /**\n * The first step in the OIDC QR login process.\n * To be called after the QR code has been rendered or scanned.\n * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.\n * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.\n */\n public async negotiateProtocols(): Promise<{ serverName?: string }> {\n logger.info(`negotiateProtocols(isNewDevice=${this.isNewDevice} didScanCode=${this.didScanCode})`);\n await this.channel.connect();\n\n if (this.didScanCode) {\n // Secure Channel step 6 completed, we trust the channel\n\n if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set\n } else {\n // MSC4108-Flow: NewScanned -send protocols message\n let oidcClientConfig: OidcClientConfig | undefined;\n try {\n oidcClientConfig = await this.client!.getAuthMetadata();\n } catch (e) {\n logger.error(\"Failed to discover OIDC metadata\", e);\n }\n\n if (oidcClientConfig?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n await this.send<ProtocolsPayload>({\n type: PayloadType.Protocols,\n protocols: [\"device_authorization_grant\"],\n homeserver: this.client!.getDomain()!,\n });\n } else {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Device code grant unsupported\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n } else if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - wait for protocols message\n logger.info(\"Waiting for protocols message\");\n const payload = await this.receive<ProtocolsPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocols) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n return { serverName: payload.homeserver };\n } else {\n // MSC4108-Flow: NewScanned - nothing to do\n }\n return {};\n }\n\n /**\n * The second & third step in the OIDC QR login process.\n * To be called after `negotiateProtocols` for the existing device.\n * To be called after OIDC negotiation for the new device. (Currently unsupported)\n */\n public async deviceAuthorizationGrant(): Promise<{\n verificationUri?: string;\n userCode?: string;\n }> {\n if (this.isNewDevice) {\n throw new Error(\"New device flows around OIDC are not yet implemented\");\n } else {\n // The user needs to do step 7 for the out-of-band confirmation\n // but, first we receive the protocol chosen by the other device so that\n // the confirmation_uri is ready to go\n logger.info(\"Waiting for protocol message\");\n const payload = await this.receive<ProtocolPayload | DeviceAuthorizationGrantProtocolPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocol) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n if (isDeviceAuthorizationGrantProtocolPayload(payload)) {\n const { device_authorization_grant: dag, device_id: expectingNewDeviceId } = payload;\n const { verification_uri: verificationUri, verification_uri_complete: verificationUriComplete } = dag;\n\n let deviceAlreadyExists = true;\n try {\n await this.client?.getDevice(expectingNewDeviceId);\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n deviceAlreadyExists = false;\n }\n }\n\n if (deviceAlreadyExists) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceAlreadyExists,\n });\n throw new RendezvousError(\n \"Specified device ID already exists\",\n MSC4108FailureReason.DeviceAlreadyExists,\n );\n }\n\n this.expectingNewDeviceId = expectingNewDeviceId;\n\n return { verificationUri: verificationUriComplete ?? verificationUri };\n }\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Received a request for an unsupported protocol\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n\n /**\n * The fifth (and final) step in the OIDC QR login process.\n * To be called after the new device has completed authentication.\n */\n public async shareSecrets(): Promise<{ secrets?: Omit<SecretsPayload, \"type\"> }> {\n if (this.isNewDevice) {\n await this.send<SuccessPayload>({\n type: PayloadType.Success,\n });\n // then wait for secrets\n logger.info(\"Waiting for secrets message\");\n const payload = await this.receive<SecretsPayload>();\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Secrets) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n return { secrets: payload };\n // then done?\n } else {\n if (!this.expectingNewDeviceId) {\n throw new Error(\"No new device ID expected\");\n }\n await this.send<AcceptedPayload>({\n type: PayloadType.ProtocolAccepted,\n });\n\n logger.info(\"Waiting for outcome message\");\n const payload = await this.receive<SuccessPayload | DeclinedPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type === PayloadType.Declined) {\n throw new RendezvousError(\"User declined\", ClientRendezvousFailureReason.UserDeclined);\n }\n\n if (payload?.type !== PayloadType.Success) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\"Unexpected message\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n const timeout = Date.now() + 10000; // wait up to 10 seconds\n do {\n // is the device visible via the Homeserver?\n try {\n const device = await this.client?.getDevice(this.expectingNewDeviceId);\n\n if (device) {\n // if so, return the secrets\n const secretsBundle = await this.client!.getCrypto()!.exportSecretsBundle!();\n if (this.channel.cancelled) {\n throw new RendezvousError(\"User cancelled\", MSC4108FailureReason.UserCancelled);\n }\n // send secrets\n await this.send<SecretsPayload>({\n type: PayloadType.Secrets,\n ...secretsBundle,\n });\n return { secrets: secretsBundle };\n // let the other side close the rendezvous session\n }\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n // not found, so keep waiting until timeout\n } else {\n throw err;\n }\n }\n await sleep(1000);\n } while (Date.now() < timeout);\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceNotFound,\n });\n throw new RendezvousError(\"New device not found\", MSC4108FailureReason.DeviceNotFound);\n }\n }\n\n private async receive<T extends MSC4108Payload>(): Promise<T | FailurePayload | undefined> {\n return (await this.channel.secureReceive()) as T | undefined;\n }\n\n private async send<T extends MSC4108Payload>(payload: T): Promise<void> {\n await this.channel.secureSend(payload);\n }\n\n /**\n * Decline the login on the existing device.\n */\n public async declineLoginOnExistingDevice(): Promise<void> {\n if (!this.isExistingDevice) {\n throw new Error(\"Can only decline login on existing device\");\n }\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UserCancelled,\n });\n }\n\n /**\n * Cancels the rendezvous session.\n * @param reason the reason for the cancellation\n */\n public async cancel(reason: MSC4108FailureReason | ClientRendezvousFailureReason): Promise<void> {\n this.onFailure?.(reason);\n await this.channel.cancel(reason);\n }\n\n /**\n * Closes the rendezvous session.\n */\n public async close(): Promise<void> {\n await this.channel.close();\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,oCAAoC;AAE/D,SACIC,6BAA6B,EAC7BC,oBAAoB,EACpBC,eAAe,QAEZ,YAAY;AAEnB,SAASC,MAAM,QAAQ,cAAc;AAErC,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,cAAc,QAA+B,kBAAkB;AAGxE;AACA;AACA;AACA;AACA;AACA,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;;AAUvB;AACA;AACA;AACA;AACA;;AAyBA,SAASC,yCAAyCA,CAC9CC,OAAwB,EAC0B;EAClD,OAAOA,OAAO,CAACC,QAAQ,KAAK,4BAA4B;AAC5D;AAwBA;AACA;AACA;AACA;AACA;AACA,OAAO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AA,OAAAlE,iBAAA;MACvF,aAAckE,MAAI,CAAChF,OAAO,CAACiF,aAAa,CAAC,CAAC;IAAmB;EACjE;EAEclD,IAAIA,CAA2BpC,OAAU,EAAiB;IAAA,IAAAuF,MAAA;IAAA,OAAApE,iBAAA;MACpE,MAAMoE,MAAI,CAAClF,OAAO,CAACmF,UAAU,CAACxF,OAAO,CAAC;IAAC;EAC3C;;EAEA;AACJ;AACA;EACiByF,4BAA4BA,CAAA,EAAkB;IAAA,IAAAC,MAAA;IAAA,OAAAvE,iBAAA;MACvD,IAAI,CAACuE,MAAI,CAACrE,gBAAgB,EAAE;QACxB,MAAM,IAAI4B,KAAK,CAAC,2CAA2C,CAAC;MAChE;MACA,MAAMyC,MAAI,CAACtD,IAAI,CAAiB;QAC5BC,IAAI,EAAEvC,WAAW,CAAC2C,OAAO;QACzBC,MAAM,EAAElD,oBAAoB,CAAC0F;MACjC,CAAC,CAAC;IAAC;EACP;;EAEA;AACJ;AACA;AACA;EACiBS,MAAMA,CAACjD,MAA4D,EAAiB;IAAA,IAAAkD,MAAA;IAAA,OAAAzE,iBAAA;MAAA,IAAA0E,gBAAA;MAC7F,CAAAA,gBAAA,GAAAD,MAAI,CAAClF,SAAS,cAAAmF,gBAAA,eAAdA,gBAAA,CAAAC,IAAA,CAAAF,MAAI,EAAalD,MAAM,CAAC;MACxB,MAAMkD,MAAI,CAACvF,OAAO,CAACsF,MAAM,CAACjD,MAAM,CAAC;IAAC;EACtC;;EAEA;AACJ;AACA;EACiBqD,KAAKA,CAAA,EAAkB;IAAA,IAAAC,MAAA;IAAA,OAAA7E,iBAAA;MAChC,MAAM6E,MAAI,CAAC3F,OAAO,CAAC0F,KAAK,CAAC,CAAC;IAAC;EAC/B;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MSC4108SignInWithQR.js","names":["QrCodeIntent","ClientRendezvousFailureReason","MSC4108FailureReason","RendezvousError","logger","MatrixError","sleep","OAuthGrantType","PayloadType","isDeviceAuthorizationGrantProtocolPayload","payload","protocol","MSC4108SignInWithQR","checkCode","_this$channel","channel","getCheckCode","constructor","didScanCode","client","onFailure","_defineProperty","ourIntent","Reciprocate","Login","code","_code","generateCode","_this","_asyncToGenerator","getDomain","isExistingDevice","isNewDevice","negotiateProtocols","_this2","info","concat","connect","_oidcClientConfig","oidcClientConfig","getAuthMetadata","e","error","grant_types_supported","includes","DeviceAuthorization","send","type","Protocols","protocols","homeserver","Failure","reason","UnsupportedProtocol","receive","UnexpectedMessageReceived","serverName","deviceAuthorizationGrant","_this3","Error","Protocol","device_authorization_grant","dag","device_id","expectingNewDeviceId","verification_uri","verificationUri","verification_uri_complete","verificationUriComplete","deviceAlreadyExists","_this3$client","getDevice","err","httpStatus","DeviceAlreadyExists","shareSecrets","_this4","Success","Secrets","secrets","ProtocolAccepted","Declined","UserDeclined","timeout","Date","now","_this4$client","device","secretsBundle","getCrypto","exportSecretsBundle","cancelled","UserCancelled","_objectSpread","DeviceNotFound","_this5","secureReceive","_this6","secureSend","declineLoginOnExistingDevice","_this7","cancel","_this8","_this8$onFailure","call","close","_this9"],"sources":["../../src/rendezvous/MSC4108SignInWithQR.ts"],"sourcesContent":["/*\nCopyright 2024 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 { QrCodeIntent } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n ClientRendezvousFailureReason,\n MSC4108FailureReason,\n RendezvousError,\n type RendezvousFailureListener,\n} from \"./index.ts\";\nimport { type MatrixClient } from \"../client.ts\";\nimport { logger } from \"../logger.ts\";\nimport { type MSC4108SecureChannel } from \"./channels/MSC4108SecureChannel.ts\";\nimport { MatrixError } from \"../http-api/index.ts\";\nimport { sleep } from \"../utils.ts\";\nimport { OAuthGrantType, type OidcClientConfig } from \"../oidc/index.ts\";\nimport { type CryptoApi } from \"../crypto-api/index.ts\";\n\n/**\n * Enum representing the payload types transmissible over [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * secure channels.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport enum PayloadType {\n Protocols = \"m.login.protocols\",\n Protocol = \"m.login.protocol\",\n Failure = \"m.login.failure\",\n Success = \"m.login.success\",\n Secrets = \"m.login.secrets\",\n ProtocolAccepted = \"m.login.protocol_accepted\",\n Declined = \"m.login.declined\",\n}\n\n/**\n * Type representing the base payload format for [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * messages sent over the secure channel.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport interface MSC4108Payload {\n type: PayloadType;\n}\n\ninterface ProtocolsPayload extends MSC4108Payload {\n type: PayloadType.Protocols;\n protocols: string[];\n homeserver: string;\n}\n\ninterface ProtocolPayload extends MSC4108Payload {\n type: PayloadType.Protocol;\n protocol: Exclude<string, \"device_authorization_grant\">;\n device_id: string;\n}\n\ninterface DeviceAuthorizationGrantProtocolPayload extends ProtocolPayload {\n protocol: \"device_authorization_grant\";\n device_authorization_grant: {\n verification_uri: string;\n verification_uri_complete?: string;\n };\n}\n\nfunction isDeviceAuthorizationGrantProtocolPayload(\n payload: ProtocolPayload,\n): payload is DeviceAuthorizationGrantProtocolPayload {\n return payload.protocol === \"device_authorization_grant\";\n}\n\ninterface FailurePayload extends MSC4108Payload {\n type: PayloadType.Failure;\n reason: MSC4108FailureReason;\n homeserver?: string;\n}\n\ninterface DeclinedPayload extends MSC4108Payload {\n type: PayloadType.Declined;\n}\n\ninterface SuccessPayload extends MSC4108Payload {\n type: PayloadType.Success;\n}\n\ninterface AcceptedPayload extends MSC4108Payload {\n type: PayloadType.ProtocolAccepted;\n}\n\ninterface SecretsPayload extends MSC4108Payload, Awaited<ReturnType<NonNullable<CryptoApi[\"exportSecretsBundle\"]>>> {\n type: PayloadType.Secrets;\n}\n\n/**\n * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * sign in with QR + OIDC flow.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n */\nexport class MSC4108SignInWithQR {\n private readonly ourIntent: QrCodeIntent;\n private _code?: Uint8Array;\n private expectingNewDeviceId?: string;\n\n /**\n * Returns the check code for the secure channel or undefined if not generated yet.\n */\n public get checkCode(): string | undefined {\n return this.channel?.getCheckCode();\n }\n\n /**\n * @param channel - The secure channel used for communication\n * @param client - The Matrix client in used on the device already logged in\n * @param didScanCode - Whether this side of the channel scanned the QR code from the other party\n * @param onFailure - Callback for when the rendezvous fails\n */\n public constructor(\n private readonly channel: MSC4108SecureChannel,\n private readonly didScanCode: boolean,\n private readonly client?: MatrixClient,\n public onFailure?: RendezvousFailureListener,\n ) {\n this.ourIntent = client ? QrCodeIntent.Reciprocate : QrCodeIntent.Login;\n }\n\n /**\n * Returns the code representing the rendezvous suitable for rendering in a QR code or undefined if not generated yet.\n */\n public get code(): Uint8Array | undefined {\n return this._code;\n }\n\n /**\n * Generate the code including doing partial set up of the channel where required.\n */\n public async generateCode(): Promise<void> {\n if (this._code) {\n return;\n }\n\n if (this.ourIntent === QrCodeIntent.Reciprocate && this.client) {\n this._code = await this.channel.generateCode(this.ourIntent, this.client.getDomain()!);\n } else if (this.ourIntent === QrCodeIntent.Login) {\n this._code = await this.channel.generateCode(this.ourIntent);\n }\n }\n\n /**\n * Returns true if the device is the already logged in device reciprocating a new login on the other side of the channel.\n */\n public get isExistingDevice(): boolean {\n return this.ourIntent === QrCodeIntent.Reciprocate;\n }\n\n /**\n * Returns true if the device is the new device logging in being reciprocated by the device on the other side of the channel.\n */\n public get isNewDevice(): boolean {\n return !this.isExistingDevice;\n }\n\n /**\n * The first step in the OIDC QR login process.\n * To be called after the QR code has been rendered or scanned.\n * The scanning device has to discover the homeserver details, if they scanned the code then they already have it.\n * If the new device is the one rendering the QR code then it has to wait be sent the homeserver details via the rendezvous channel.\n */\n public async negotiateProtocols(): Promise<{ serverName?: string }> {\n logger.info(`negotiateProtocols(isNewDevice=${this.isNewDevice} didScanCode=${this.didScanCode})`);\n await this.channel.connect();\n\n if (this.didScanCode) {\n // Secure Channel step 6 completed, we trust the channel\n\n if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - take homeserver from QR code which should already be set\n } else {\n // MSC4108-Flow: NewScanned -send protocols message\n let oidcClientConfig: OidcClientConfig | undefined;\n try {\n oidcClientConfig = await this.client!.getAuthMetadata();\n } catch (e) {\n logger.error(\"Failed to discover OIDC metadata\", e);\n }\n\n if (oidcClientConfig?.grant_types_supported.includes(OAuthGrantType.DeviceAuthorization)) {\n await this.send<ProtocolsPayload>({\n type: PayloadType.Protocols,\n protocols: [\"device_authorization_grant\"],\n homeserver: this.client!.getDomain()!,\n });\n } else {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Device code grant unsupported\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n } else if (this.isNewDevice) {\n // MSC4108-Flow: ExistingScanned - wait for protocols message\n logger.info(\"Waiting for protocols message\");\n const payload = await this.receive<ProtocolsPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocols) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n return { serverName: payload.homeserver };\n } else {\n // MSC4108-Flow: NewScanned - nothing to do\n }\n return {};\n }\n\n /**\n * The second & third step in the OIDC QR login process.\n * To be called after `negotiateProtocols` for the existing device.\n * To be called after OIDC negotiation for the new device. (Currently unsupported)\n */\n public async deviceAuthorizationGrant(): Promise<{\n verificationUri?: string;\n userCode?: string;\n }> {\n if (this.isNewDevice) {\n throw new Error(\"New device flows around OIDC are not yet implemented\");\n } else {\n // The user needs to do step 7 for the out-of-band confirmation\n // but, first we receive the protocol chosen by the other device so that\n // the confirmation_uri is ready to go\n logger.info(\"Waiting for protocol message\");\n const payload = await this.receive<ProtocolPayload | DeviceAuthorizationGrantProtocolPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Protocol) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n\n if (isDeviceAuthorizationGrantProtocolPayload(payload)) {\n const { device_authorization_grant: dag, device_id: expectingNewDeviceId } = payload;\n const { verification_uri: verificationUri, verification_uri_complete: verificationUriComplete } = dag;\n\n let deviceAlreadyExists = true;\n try {\n await this.client?.getDevice(expectingNewDeviceId);\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n deviceAlreadyExists = false;\n }\n }\n\n if (deviceAlreadyExists) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceAlreadyExists,\n });\n throw new RendezvousError(\n \"Specified device ID already exists\",\n MSC4108FailureReason.DeviceAlreadyExists,\n );\n }\n\n this.expectingNewDeviceId = expectingNewDeviceId;\n\n return { verificationUri: verificationUriComplete ?? verificationUri };\n }\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnsupportedProtocol,\n });\n throw new RendezvousError(\n \"Received a request for an unsupported protocol\",\n MSC4108FailureReason.UnsupportedProtocol,\n );\n }\n }\n\n /**\n * The fifth (and final) step in the OIDC QR login process.\n * To be called after the new device has completed authentication.\n */\n public async shareSecrets(): Promise<{ secrets?: Omit<SecretsPayload, \"type\"> }> {\n if (this.isNewDevice) {\n await this.send<SuccessPayload>({\n type: PayloadType.Success,\n });\n // then wait for secrets\n logger.info(\"Waiting for secrets message\");\n const payload = await this.receive<SecretsPayload>();\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type !== PayloadType.Secrets) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\n \"Unexpected message received\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n return { secrets: payload };\n // then done?\n } else {\n if (!this.expectingNewDeviceId) {\n throw new Error(\"No new device ID expected\");\n }\n await this.send<AcceptedPayload>({\n type: PayloadType.ProtocolAccepted,\n });\n\n logger.info(\"Waiting for outcome message\");\n const payload = await this.receive<SuccessPayload | DeclinedPayload>();\n\n if (payload?.type === PayloadType.Failure) {\n throw new RendezvousError(\"Failed\", payload.reason);\n }\n\n if (payload?.type === PayloadType.Declined) {\n throw new RendezvousError(\"User declined\", ClientRendezvousFailureReason.UserDeclined);\n }\n\n if (payload?.type !== PayloadType.Success) {\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UnexpectedMessageReceived,\n });\n throw new RendezvousError(\"Unexpected message\", MSC4108FailureReason.UnexpectedMessageReceived);\n }\n\n const timeout = Date.now() + 10000; // wait up to 10 seconds\n do {\n // is the device visible via the Homeserver?\n try {\n const device = await this.client?.getDevice(this.expectingNewDeviceId);\n\n if (device) {\n // if so, return the secrets\n const secretsBundle = await this.client!.getCrypto()!.exportSecretsBundle!();\n if (this.channel.cancelled) {\n throw new RendezvousError(\"User cancelled\", MSC4108FailureReason.UserCancelled);\n }\n // send secrets\n await this.send<SecretsPayload>({\n type: PayloadType.Secrets,\n ...secretsBundle,\n });\n return { secrets: secretsBundle };\n // let the other side close the rendezvous session\n }\n } catch (err: MatrixError | unknown) {\n if (err instanceof MatrixError && err.httpStatus === 404) {\n // not found, so keep waiting until timeout\n } else {\n throw err;\n }\n }\n await sleep(1000);\n } while (Date.now() < timeout);\n\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.DeviceNotFound,\n });\n throw new RendezvousError(\"New device not found\", MSC4108FailureReason.DeviceNotFound);\n }\n }\n\n private async receive<T extends MSC4108Payload>(): Promise<T | FailurePayload | undefined> {\n return (await this.channel.secureReceive()) as T | undefined;\n }\n\n private async send<T extends MSC4108Payload>(payload: T): Promise<void> {\n await this.channel.secureSend(payload);\n }\n\n /**\n * Decline the login on the existing device.\n */\n public async declineLoginOnExistingDevice(): Promise<void> {\n if (!this.isExistingDevice) {\n throw new Error(\"Can only decline login on existing device\");\n }\n await this.send<FailurePayload>({\n type: PayloadType.Failure,\n reason: MSC4108FailureReason.UserCancelled,\n });\n }\n\n /**\n * Cancels the rendezvous session.\n * @param reason the reason for the cancellation\n */\n public async cancel(reason: MSC4108FailureReason | ClientRendezvousFailureReason): Promise<void> {\n this.onFailure?.(reason);\n await this.channel.cancel(reason);\n }\n\n /**\n * Closes the rendezvous session.\n */\n public async close(): Promise<void> {\n await this.channel.close();\n }\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,oCAAoC;AAEjE,SACIC,6BAA6B,EAC7BC,oBAAoB,EACpBC,eAAe,QAEZ,YAAY;AAEnB,SAASC,MAAM,QAAQ,cAAc;AAErC,SAASC,WAAW,QAAQ,sBAAsB;AAClD,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,cAAc,QAA+B,kBAAkB;AAGxE;AACA;AACA;AACA;AACA;AACA,WAAYC,WAAW,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,W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A;MAChC,MAAM6E,MAAI,CAAC3F,OAAO,CAAC0F,KAAK,CAAC,CAAC;IAAC;EAC/B;AACJ","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Curve25519PublicKey,
|
|
1
|
+
import { type Curve25519PublicKey, QrCodeIntent } from "@matrix-org/matrix-sdk-crypto-wasm";
|
|
2
2
|
import { ClientRendezvousFailureReason, MSC4108FailureReason, type MSC4108Payload, type RendezvousFailureListener } from "../index.ts";
|
|
3
3
|
import { type MSC4108RendezvousSession } from "../transports/MSC4108RendezvousSession.ts";
|
|
4
4
|
/**
|
|
@@ -20,8 +20,8 @@ export declare class MSC4108SecureChannel {
|
|
|
20
20
|
* @param mode the mode to generate the QR code in, either `Login` or `Reciprocate`.
|
|
21
21
|
* @param serverName the name of the homeserver to connect to, as defined by server discovery in the spec, required for `Reciprocate` mode.
|
|
22
22
|
*/
|
|
23
|
-
generateCode(mode:
|
|
24
|
-
generateCode(mode:
|
|
23
|
+
generateCode(mode: QrCodeIntent.Login): Promise<Uint8Array>;
|
|
24
|
+
generateCode(mode: QrCodeIntent.Reciprocate, serverName: string): Promise<Uint8Array>;
|
|
25
25
|
/**
|
|
26
26
|
* Returns the check code for the secure channel or undefined if not generated yet.
|
|
27
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MSC4108SecureChannel.d.ts","sourceRoot":"","sources":["../../../src/rendezvous/channels/MSC4108SecureChannel.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,mBAAmB,EAIxB,
|
|
1
|
+
{"version":3,"file":"MSC4108SecureChannel.d.ts","sourceRoot":"","sources":["../../../src/rendezvous/channels/MSC4108SecureChannel.ts"],"names":[],"mappings":"AAgBA,OAAO,EACH,KAAK,mBAAmB,EAIxB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACH,6BAA6B,EAC7B,oBAAoB,EACpB,KAAK,cAAc,EAEnB,KAAK,yBAAyB,EAC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
|
16
16
|
limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import { Ecies, QrCodeData,
|
|
19
|
+
import { Ecies, QrCodeData, QrCodeIntent } from "@matrix-org/matrix-sdk-crypto-wasm";
|
|
20
20
|
import { ClientRendezvousFailureReason, MSC4108FailureReason, RendezvousError } from "../index.js";
|
|
21
21
|
import { logger } from "../../logger.js";
|
|
22
22
|
|
|
@@ -52,7 +52,7 @@ export class MSC4108SecureChannel {
|
|
|
52
52
|
if (!url) {
|
|
53
53
|
throw new Error("No rendezvous session URL");
|
|
54
54
|
}
|
|
55
|
-
return new QrCodeData(_this.secureChannel.public_key(), url, mode ===
|
|
55
|
+
return new QrCodeData(_this.secureChannel.public_key(), url, mode === QrCodeIntent.Reciprocate ? serverName : undefined).toBytes();
|
|
56
56
|
})();
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MSC4108SecureChannel.js","names":["Ecies","QrCodeData","QrCodeMode","ClientRendezvousFailureReason","MSC4108FailureReason","RendezvousError","logger","MSC4108SecureChannel","constructor","rendezvousSession","theirPublicKey","onFailure","_defineProperty","secureChannel","generateCode","mode","serverName","_this","_asyncToGenerator","url","Error","public_key","Reciprocate","undefined","toBytes","getCheckCode","_this$establishedChan","x","establishedChannel","check_code","Array","from","as_bytes","map","b","concat","join","connect","_this2","connected","result","establish_outbound_channel","channel","info","send","initial_message","ciphertext","receive","UnexpectedMessageReceived","candidateLoginOkMessage","decrypt","InsecureChannelDetected","loginInitiateMessage","message","candidateLoginInitiateMessage","establish_inbound_channel","loginOkMessage","encrypt","_this3","plaintext","_this4","secureSend","payload","_this5","stringifiedPayload","JSON","stringify","debug","type","secureReceive","_this6","json","parse","close","_this7","cancel","reason","_this8","_this8$onFailure","call","cancelled"],"sources":["../../../src/rendezvous/channels/MSC4108SecureChannel.ts"],"sourcesContent":["/*\nCopyright 2024 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 {\n type Curve25519PublicKey,\n Ecies,\n type EstablishedEcies,\n QrCodeData,\n QrCodeMode,\n} from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n ClientRendezvousFailureReason,\n MSC4108FailureReason,\n type MSC4108Payload,\n RendezvousError,\n type RendezvousFailureListener,\n} from \"../index.ts\";\nimport { type MSC4108RendezvousSession } from \"../transports/MSC4108RendezvousSession.ts\";\nimport { logger } from \"../../logger.ts\";\n\n/**\n * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * secure rendezvous session protocol.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n * Imports @matrix-org/matrix-sdk-crypto-wasm so should be async-imported to avoid bundling the WASM into the main bundle.\n */\nexport class MSC4108SecureChannel {\n private readonly secureChannel: Ecies;\n private establishedChannel?: EstablishedEcies;\n private connected = false;\n\n public constructor(\n private rendezvousSession: MSC4108RendezvousSession,\n private theirPublicKey?: Curve25519PublicKey,\n public onFailure?: RendezvousFailureListener,\n ) {\n this.secureChannel = new Ecies();\n }\n\n /**\n * Generate a QR code for the current session.\n * @param mode the mode to generate the QR code in, either `Login` or `Reciprocate`.\n * @param serverName the name of the homeserver to connect to, as defined by server discovery in the spec, required for `Reciprocate` mode.\n */\n public async generateCode(mode: QrCodeMode.Login): Promise<Uint8Array>;\n public async generateCode(mode: QrCodeMode.Reciprocate, serverName: string): Promise<Uint8Array>;\n public async generateCode(mode: QrCodeMode, serverName?: string): Promise<Uint8Array> {\n const { url } = this.rendezvousSession;\n\n if (!url) {\n throw new Error(\"No rendezvous session URL\");\n }\n\n return new QrCodeData(\n this.secureChannel.public_key(),\n url,\n mode === QrCodeMode.Reciprocate ? serverName : undefined,\n ).toBytes();\n }\n\n /**\n * Returns the check code for the secure channel or undefined if not generated yet.\n */\n public getCheckCode(): string | undefined {\n const x = this.establishedChannel?.check_code();\n\n if (!x) {\n return undefined;\n }\n return Array.from(x.as_bytes())\n .map((b) => `${b % 10}`)\n .join(\"\");\n }\n\n /**\n * Connects and establishes a secure channel with the other device.\n */\n public async connect(): Promise<void> {\n if (this.connected) {\n throw new Error(\"Channel already connected\");\n }\n\n if (this.theirPublicKey) {\n // We are the scanning device\n const result = this.secureChannel.establish_outbound_channel(\n this.theirPublicKey,\n \"MATRIX_QR_CODE_LOGIN_INITIATE\",\n );\n this.establishedChannel = result.channel;\n\n /*\n Secure Channel step 4. Device S sends the initial message\n\n Nonce := 0\n SH := ECDH(Ss, Gp)\n EncKey := HKDF_SHA256(SH, \"MATRIX_QR_CODE_LOGIN|\" || Gp || \"|\" || Sp, 0, 32)\n TaggedCiphertext := ChaCha20Poly1305_Encrypt(EncKey, Nonce, \"MATRIX_QR_CODE_LOGIN_INITIATE\")\n Nonce := Nonce + 2\n LoginInitiateMessage := UnpaddedBase64(TaggedCiphertext) || \"|\" || UnpaddedBase64(Sp)\n */\n {\n logger.info(\"Sending LoginInitiateMessage\");\n await this.rendezvousSession.send(result.initial_message);\n }\n\n /*\n Secure Channel step 6. Verification by Device S\n\n Nonce_G := 1\n (TaggedCiphertext, Sp) := Unpack(Message)\n Plaintext := ChaCha20Poly1305_Decrypt(EncKey, Nonce_G, TaggedCiphertext)\n Nonce_G := Nonce_G + 2\n\n unless Plaintext == \"MATRIX_QR_CODE_LOGIN_OK\":\n FAIL\n */\n {\n logger.info(\"Waiting for LoginOkMessage\");\n const ciphertext = await this.rendezvousSession.receive();\n\n if (!ciphertext) {\n throw new RendezvousError(\n \"No response from other device\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n const candidateLoginOkMessage = await this.decrypt(ciphertext);\n\n if (candidateLoginOkMessage !== \"MATRIX_QR_CODE_LOGIN_OK\") {\n throw new RendezvousError(\n \"Invalid response from other device\",\n ClientRendezvousFailureReason.InsecureChannelDetected,\n );\n }\n\n // Step 6 is now complete. We trust the channel\n }\n } else {\n /*\n Secure Channel step 5. Device G confirms\n\n Nonce_S := 0\n (TaggedCiphertext, Sp) := Unpack(LoginInitiateMessage)\n SH := ECDH(Gs, Sp)\n EncKey := HKDF_SHA256(SH, \"MATRIX_QR_CODE_LOGIN|\" || Gp || \"|\" || Sp, 0, 32)\n Plaintext := ChaCha20Poly1305_Decrypt(EncKey, Nonce_S, TaggedCiphertext)\n Nonce_S := Nonce_S + 2\n */\n // wait for the other side to send us their public key\n logger.info(\"Waiting for LoginInitiateMessage\");\n const loginInitiateMessage = await this.rendezvousSession.receive();\n if (!loginInitiateMessage) {\n throw new Error(\"No response from other device\");\n }\n\n const { channel, message: candidateLoginInitiateMessage } =\n this.secureChannel.establish_inbound_channel(loginInitiateMessage);\n this.establishedChannel = channel;\n\n if (candidateLoginInitiateMessage !== \"MATRIX_QR_CODE_LOGIN_INITIATE\") {\n throw new RendezvousError(\n \"Invalid response from other device\",\n ClientRendezvousFailureReason.InsecureChannelDetected,\n );\n }\n logger.info(\"LoginInitiateMessage received\");\n\n logger.info(\"Sending LoginOkMessage\");\n const loginOkMessage = await this.encrypt(\"MATRIX_QR_CODE_LOGIN_OK\");\n await this.rendezvousSession.send(loginOkMessage);\n\n // Step 5 is complete. We don't yet trust the channel\n\n // next step will be for the user to confirm the check code on the other device\n }\n\n this.connected = true;\n }\n\n private async decrypt(ciphertext: string): Promise<string> {\n if (!this.establishedChannel) {\n throw new Error(\"Channel closed\");\n }\n\n return this.establishedChannel.decrypt(ciphertext);\n }\n\n private async encrypt(plaintext: string): Promise<string> {\n if (!this.establishedChannel) {\n throw new Error(\"Channel closed\");\n }\n\n return this.establishedChannel.encrypt(plaintext);\n }\n\n /**\n * Sends a payload securely to the other device.\n * @param payload the payload to encrypt and send\n */\n public async secureSend<T extends MSC4108Payload>(payload: T): Promise<void> {\n if (!this.connected) {\n throw new Error(\"Channel closed\");\n }\n\n const stringifiedPayload = JSON.stringify(payload);\n logger.debug(`=> {\"type\": ${JSON.stringify(payload.type)}, ...}`);\n\n await this.rendezvousSession.send(await this.encrypt(stringifiedPayload));\n }\n\n /**\n * Receives an encrypted payload from the other device and decrypts it.\n */\n public async secureReceive<T extends MSC4108Payload>(): Promise<Partial<T> | undefined> {\n if (!this.establishedChannel) {\n throw new Error(\"Channel closed\");\n }\n\n const ciphertext = await this.rendezvousSession.receive();\n if (!ciphertext) {\n return undefined;\n }\n const plaintext = await this.decrypt(ciphertext);\n const json = JSON.parse(plaintext);\n\n logger.debug(`<= {\"type\": ${JSON.stringify(json.type)}, ...}`);\n return json as Partial<T> | undefined;\n }\n\n /**\n * Closes the secure channel.\n */\n public async close(): Promise<void> {\n await this.rendezvousSession.close();\n }\n\n /**\n * Cancels the secure channel.\n * @param reason the reason for the cancellation\n */\n public async cancel(reason: MSC4108FailureReason | ClientRendezvousFailureReason): Promise<void> {\n try {\n await this.rendezvousSession.cancel(reason);\n this.onFailure?.(reason);\n } finally {\n await this.close();\n }\n }\n\n /**\n * Returns whether the rendezvous session has been cancelled.\n */\n public get cancelled(): boolean {\n return this.rendezvousSession.cancelled;\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEIA,KAAK,EAELC,UAAU,EACVC,UAAU,QACP,oCAAoC;AAE3C,SACIC,6BAA6B,EAC7BC,oBAAoB,EAEpBC,eAAe,QAEZ,aAAa;AAEpB,SAASC,MAAM,QAAQ,iBAAiB;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAKvBC,WAAWA,CACNC,iBAA2C,EAC3CC,cAAoC,EACrCC,SAAqC,EAC9C;IAAA,KAHUF,iBAA2C,GA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AA;QACA,MAAMD,MAAI,CAACpE,iBAAiB,CAACkE,MAAM,CAACC,MAAM,CAAC;QAC3C,CAAAE,gBAAA,GAAAD,MAAI,CAAClE,SAAS,cAAAmE,gBAAA,eAAdA,gBAAA,CAAAC,IAAA,CAAAF,MAAI,EAAaD,MAAM,CAAC;MAC5B,CAAC,SAAS;QACN,MAAMC,MAAI,CAACJ,KAAK,CAAC,CAAC;MACtB;IAAC;EACL;;EAEA;AACJ;AACA;EACI,IAAWO,SAASA,CAAA,EAAY;IAC5B,OAAO,IAAI,CAACvE,iBAAiB,CAACuE,SAAS;EAC3C;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MSC4108SecureChannel.js","names":["Ecies","QrCodeData","QrCodeIntent","ClientRendezvousFailureReason","MSC4108FailureReason","RendezvousError","logger","MSC4108SecureChannel","constructor","rendezvousSession","theirPublicKey","onFailure","_defineProperty","secureChannel","generateCode","mode","serverName","_this","_asyncToGenerator","url","Error","public_key","Reciprocate","undefined","toBytes","getCheckCode","_this$establishedChan","x","establishedChannel","check_code","Array","from","as_bytes","map","b","concat","join","connect","_this2","connected","result","establish_outbound_channel","channel","info","send","initial_message","ciphertext","receive","UnexpectedMessageReceived","candidateLoginOkMessage","decrypt","InsecureChannelDetected","loginInitiateMessage","message","candidateLoginInitiateMessage","establish_inbound_channel","loginOkMessage","encrypt","_this3","plaintext","_this4","secureSend","payload","_this5","stringifiedPayload","JSON","stringify","debug","type","secureReceive","_this6","json","parse","close","_this7","cancel","reason","_this8","_this8$onFailure","call","cancelled"],"sources":["../../../src/rendezvous/channels/MSC4108SecureChannel.ts"],"sourcesContent":["/*\nCopyright 2024 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 {\n type Curve25519PublicKey,\n Ecies,\n type EstablishedEcies,\n QrCodeData,\n QrCodeIntent,\n} from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport {\n ClientRendezvousFailureReason,\n MSC4108FailureReason,\n type MSC4108Payload,\n RendezvousError,\n type RendezvousFailureListener,\n} from \"../index.ts\";\nimport { type MSC4108RendezvousSession } from \"../transports/MSC4108RendezvousSession.ts\";\nimport { logger } from \"../../logger.ts\";\n\n/**\n * Prototype of the unstable [MSC4108](https://github.com/matrix-org/matrix-spec-proposals/pull/4108)\n * secure rendezvous session protocol.\n * @experimental Note that this is UNSTABLE and may have breaking changes without notice.\n * Imports @matrix-org/matrix-sdk-crypto-wasm so should be async-imported to avoid bundling the WASM into the main bundle.\n */\nexport class MSC4108SecureChannel {\n private readonly secureChannel: Ecies;\n private establishedChannel?: EstablishedEcies;\n private connected = false;\n\n public constructor(\n private rendezvousSession: MSC4108RendezvousSession,\n private theirPublicKey?: Curve25519PublicKey,\n public onFailure?: RendezvousFailureListener,\n ) {\n this.secureChannel = new Ecies();\n }\n\n /**\n * Generate a QR code for the current session.\n * @param mode the mode to generate the QR code in, either `Login` or `Reciprocate`.\n * @param serverName the name of the homeserver to connect to, as defined by server discovery in the spec, required for `Reciprocate` mode.\n */\n public async generateCode(mode: QrCodeIntent.Login): Promise<Uint8Array>;\n public async generateCode(mode: QrCodeIntent.Reciprocate, serverName: string): Promise<Uint8Array>;\n public async generateCode(mode: QrCodeIntent, serverName?: string): Promise<Uint8Array> {\n const { url } = this.rendezvousSession;\n\n if (!url) {\n throw new Error(\"No rendezvous session URL\");\n }\n\n return new QrCodeData(\n this.secureChannel.public_key(),\n url,\n mode === QrCodeIntent.Reciprocate ? serverName : undefined,\n ).toBytes();\n }\n\n /**\n * Returns the check code for the secure channel or undefined if not generated yet.\n */\n public getCheckCode(): string | undefined {\n const x = this.establishedChannel?.check_code();\n\n if (!x) {\n return undefined;\n }\n return Array.from(x.as_bytes())\n .map((b) => `${b % 10}`)\n .join(\"\");\n }\n\n /**\n * Connects and establishes a secure channel with the other device.\n */\n public async connect(): Promise<void> {\n if (this.connected) {\n throw new Error(\"Channel already connected\");\n }\n\n if (this.theirPublicKey) {\n // We are the scanning device\n const result = this.secureChannel.establish_outbound_channel(\n this.theirPublicKey,\n \"MATRIX_QR_CODE_LOGIN_INITIATE\",\n );\n this.establishedChannel = result.channel;\n\n /*\n Secure Channel step 4. Device S sends the initial message\n\n Nonce := 0\n SH := ECDH(Ss, Gp)\n EncKey := HKDF_SHA256(SH, \"MATRIX_QR_CODE_LOGIN|\" || Gp || \"|\" || Sp, 0, 32)\n TaggedCiphertext := ChaCha20Poly1305_Encrypt(EncKey, Nonce, \"MATRIX_QR_CODE_LOGIN_INITIATE\")\n Nonce := Nonce + 2\n LoginInitiateMessage := UnpaddedBase64(TaggedCiphertext) || \"|\" || UnpaddedBase64(Sp)\n */\n {\n logger.info(\"Sending LoginInitiateMessage\");\n await this.rendezvousSession.send(result.initial_message);\n }\n\n /*\n Secure Channel step 6. Verification by Device S\n\n Nonce_G := 1\n (TaggedCiphertext, Sp) := Unpack(Message)\n Plaintext := ChaCha20Poly1305_Decrypt(EncKey, Nonce_G, TaggedCiphertext)\n Nonce_G := Nonce_G + 2\n\n unless Plaintext == \"MATRIX_QR_CODE_LOGIN_OK\":\n FAIL\n */\n {\n logger.info(\"Waiting for LoginOkMessage\");\n const ciphertext = await this.rendezvousSession.receive();\n\n if (!ciphertext) {\n throw new RendezvousError(\n \"No response from other device\",\n MSC4108FailureReason.UnexpectedMessageReceived,\n );\n }\n const candidateLoginOkMessage = await this.decrypt(ciphertext);\n\n if (candidateLoginOkMessage !== \"MATRIX_QR_CODE_LOGIN_OK\") {\n throw new RendezvousError(\n \"Invalid response from other device\",\n ClientRendezvousFailureReason.InsecureChannelDetected,\n );\n }\n\n // Step 6 is now complete. We trust the channel\n }\n } else {\n /*\n Secure Channel step 5. Device G confirms\n\n Nonce_S := 0\n (TaggedCiphertext, Sp) := Unpack(LoginInitiateMessage)\n SH := ECDH(Gs, Sp)\n EncKey := HKDF_SHA256(SH, \"MATRIX_QR_CODE_LOGIN|\" || Gp || \"|\" || Sp, 0, 32)\n Plaintext := ChaCha20Poly1305_Decrypt(EncKey, Nonce_S, TaggedCiphertext)\n Nonce_S := Nonce_S + 2\n */\n // wait for the other side to send us their public key\n logger.info(\"Waiting for LoginInitiateMessage\");\n const loginInitiateMessage = await this.rendezvousSession.receive();\n if (!loginInitiateMessage) {\n throw new Error(\"No response from other device\");\n }\n\n const { channel, message: candidateLoginInitiateMessage } =\n this.secureChannel.establish_inbound_channel(loginInitiateMessage);\n this.establishedChannel = channel;\n\n if (candidateLoginInitiateMessage !== \"MATRIX_QR_CODE_LOGIN_INITIATE\") {\n throw new RendezvousError(\n \"Invalid response from other device\",\n ClientRendezvousFailureReason.InsecureChannelDetected,\n );\n }\n logger.info(\"LoginInitiateMessage received\");\n\n logger.info(\"Sending LoginOkMessage\");\n const loginOkMessage = await this.encrypt(\"MATRIX_QR_CODE_LOGIN_OK\");\n await this.rendezvousSession.send(loginOkMessage);\n\n // Step 5 is complete. We don't yet trust the channel\n\n // next step will be for the user to confirm the check code on the other device\n }\n\n this.connected = true;\n }\n\n private async decrypt(ciphertext: string): Promise<string> {\n if (!this.establishedChannel) {\n throw new Error(\"Channel closed\");\n }\n\n return this.establishedChannel.decrypt(ciphertext);\n }\n\n private async encrypt(plaintext: string): Promise<string> {\n if (!this.establishedChannel) {\n throw new Error(\"Channel closed\");\n }\n\n return this.establishedChannel.encrypt(plaintext);\n }\n\n /**\n * Sends a payload securely to the other device.\n * @param payload the payload to encrypt and send\n */\n public async secureSend<T extends MSC4108Payload>(payload: T): Promise<void> {\n if (!this.connected) {\n throw new Error(\"Channel closed\");\n }\n\n const stringifiedPayload = JSON.stringify(payload);\n logger.debug(`=> {\"type\": ${JSON.stringify(payload.type)}, ...}`);\n\n await this.rendezvousSession.send(await this.encrypt(stringifiedPayload));\n }\n\n /**\n * Receives an encrypted payload from the other device and decrypts it.\n */\n public async secureReceive<T extends MSC4108Payload>(): Promise<Partial<T> | undefined> {\n if (!this.establishedChannel) {\n throw new Error(\"Channel closed\");\n }\n\n const ciphertext = await this.rendezvousSession.receive();\n if (!ciphertext) {\n return undefined;\n }\n const plaintext = await this.decrypt(ciphertext);\n const json = JSON.parse(plaintext);\n\n logger.debug(`<= {\"type\": ${JSON.stringify(json.type)}, ...}`);\n return json as Partial<T> | undefined;\n }\n\n /**\n * Closes the secure channel.\n */\n public async close(): Promise<void> {\n await this.rendezvousSession.close();\n }\n\n /**\n * Cancels the secure channel.\n * @param reason the reason for the cancellation\n */\n public async cancel(reason: MSC4108FailureReason | ClientRendezvousFailureReason): Promise<void> {\n try {\n await this.rendezvousSession.cancel(reason);\n this.onFailure?.(reason);\n } finally {\n await this.close();\n }\n }\n\n /**\n * Returns whether the rendezvous session has been cancelled.\n */\n public get cancelled(): boolean {\n return this.rendezvousSession.cancelled;\n }\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEIA,KAAK,EAELC,UAAU,EACVC,YAAY,QACT,oCAAoC;AAE3C,SACIC,6BAA6B,EAC7BC,oBAAoB,EAEpBC,eAAe,QAEZ,aAAa;AAEpB,SAASC,MAAM,QAAQ,iBAAiB;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAAC;EAKvBC,WAAWA,CACNC,iBAA2C,EAC3CC,cAAoC,EACrCC,SAAqC,EAC9C;IAAA,KAHUF,iBAA2C,GAA3CA,iBAA2C;IAAA,KAC3CC,cAAoC,GAApCA,cAAoC;IAAA,KACrCC,SAAqC,GAArCA,SAAqC;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,oBAL5B,KAAK;IAOrB,IAAI,CAACC,a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CAAAF,MAAI,EAAaD,MAAM,CAAC;MAC5B,CAAC,SAAS;QACN,MAAMC,MAAI,CAACJ,KAAK,CAAC,CAAC;MACtB;IAAC;EACL;;EAEA;AACJ;AACA;EACI,IAAWO,SAASA,CAAA,EAAY;IAC5B,OAAO,IAAI,CAACvE,iBAAiB,CAACuE,SAAS;EAC3C;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/index.ts"],"names":[],"mappings":"AAmBA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAA2C,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,yBAAyB,CAAC;AAM3E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACvC,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,IAAI,EAAE,aAAa,CAAC,SAAS,GAAG;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IAEpD,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IAEf,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IAEjB,+CAA+C;IAC/C,aAAa,EAAE,uBAAuB,CAAC;IAEvC,oDAAoD;IACpD,eAAe,EAAE,eAAe,CAAC;IAEjC;;;OAGG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IAEtB,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAEhC,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,+BAA+B,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE5E;;OAEG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACxC,GAAG,OAAO,CAAC,UAAU,CAAC,CA4CtB"}
|
package/lib/rust-crypto/index.js
CHANGED
|
@@ -20,7 +20,7 @@ limitations under the License.
|
|
|
20
20
|
|
|
21
21
|
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
|
|
22
22
|
import { StoreHandle } from "@matrix-org/matrix-sdk-crypto-wasm";
|
|
23
|
-
import { RustCrypto } from "./rust-crypto.js";
|
|
23
|
+
import { MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE, RustCrypto } from "./rust-crypto.js";
|
|
24
24
|
import { MigrationState } from "../crypto/store/base.js";
|
|
25
25
|
import { migrateFromLegacyCrypto, migrateLegacyLocalTrustIfNeeded, migrateRoomSettingsFromLegacyCrypto } from "./libolm_migration.js";
|
|
26
26
|
/**
|
|
@@ -142,6 +142,18 @@ function _initOlmMachine() {
|
|
|
142
142
|
yield legacyCryptoStore.setMigrationState(MigrationState.INITIAL_OWN_KEY_QUERY_DONE);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
|
|
146
|
+
// If we have any recently-joined rooms, see if we have a pending key bundle for them.
|
|
147
|
+
for (var pendingDetails of yield olmMachine.getAllRoomsPendingKeyBundles()) {
|
|
148
|
+
var roomId = pendingDetails.roomId.toString();
|
|
149
|
+
if (Date.now() - pendingDetails.inviteAcceptedAtMillis <= MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE) {
|
|
150
|
+
logger.info("Checking for pending key bundle for recently-joined room ".concat(roomId, " (joined ").concat(new Date(pendingDetails.inviteAcceptedAtMillis).toISOString(), ")"));
|
|
151
|
+
yield rustCrypto.maybeAcceptKeyBundle(roomId, pendingDetails.inviterId.toString());
|
|
152
|
+
} else {
|
|
153
|
+
logger.info("Clearing pending-key-bundle flag for room ".concat(roomId, " (too old: joined ").concat(new Date(pendingDetails.inviteAcceptedAtMillis).toISOString(), ")"));
|
|
154
|
+
yield olmMachine.clearRoomPendingKeyBundle(new RustSdkCryptoJs.RoomId(roomId));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
145
157
|
return rustCrypto;
|
|
146
158
|
});
|
|
147
159
|
return _initOlmMachine.apply(this, arguments);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RustSdkCryptoJs","StoreHandle","RustCrypto","MigrationState","migrateFromLegacyCrypto","migrateLegacyLocalTrustIfNeeded","migrateRoomSettingsFromLegacyCrypto","initRustCrypto","_x","_initRustCrypto","apply","arguments","_asyncToGenerator","args","logger","debug","initAsync","storeHandle","storePrefix","storeKey","openWithKey","open","storePassphrase","legacyCryptoStore","_objectSpread","legacyStore","rustCrypto","initOlmMachine","http","userId","deviceId","secretStorage","cryptoCallbacks","enableEncryptedStateEvents","free","_x2","_x3","_x4","_x5","_x6","_x7","_x8","_x9","_x0","_initOlmMachine","olmMachine","OlmMachine","initFromStore","UserId","DeviceId","roomKeyRequestsEnabled","registerRoomKeyUpdatedCallback","sessions","onRoomKeysUpdated","registerRoomKeysWithheldCallback","withheld","onRoomKeysWithheld","registerUserIdentityUpdatedCallback","onUserIdentityUpdated","registerDevicesUpdatedCallback","userIds","onDevicesUpdated","checkSecrets","registerReceiveSecretCallback","name","_value","outgoingRequests","containsData","migrationState","getMigrationState","INITIAL_OWN_KEY_QUERY_DONE","initialKeyQueryDone","userHasCrossSigningKeys","e","error","setMigrationState"],"sources":["../../src/rust-crypto/index.ts"],"sourcesContent":["/*\nCopyright 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 * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\nimport { StoreHandle } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { RustCrypto } from \"./rust-crypto.ts\";\nimport { type IHttpOpts, type MatrixHttpApi } from \"../http-api/index.ts\";\nimport { type ServerSideSecretStorage } from \"../secret-storage.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { type CryptoStore, MigrationState } from \"../crypto/store/base.ts\";\nimport {\n migrateFromLegacyCrypto,\n migrateLegacyLocalTrustIfNeeded,\n migrateRoomSettingsFromLegacyCrypto,\n} from \"./libolm_migration.ts\";\nimport { type CryptoCallbacks } from \"../crypto-api/index.ts\";\n\n/**\n * Create a new `RustCrypto` implementation\n *\n * @param args - Parameter object\n * @internal\n */\nexport async function initRustCrypto(args: {\n /** A `Logger` instance that will be used for debug output. */\n logger: Logger;\n\n /**\n * Low-level HTTP interface: used to make outgoing requests required by the rust SDK.\n * We expect it to set the access token, etc.\n */\n http: MatrixHttpApi<IHttpOpts & { onlyData: true }>;\n\n /** The local user's User ID. */\n userId: string;\n\n /** The local user's Device ID. */\n deviceId: string;\n\n /** Interface to server-side secret storage. */\n secretStorage: ServerSideSecretStorage;\n\n /** Crypto callbacks provided by the application. */\n cryptoCallbacks: CryptoCallbacks;\n\n /**\n * The prefix to use on the indexeddbs created by rust-crypto.\n * If `null`, a memory store will be used.\n */\n storePrefix: string | null;\n\n /**\n * A passphrase to use to encrypt the indexeddb created by rust-crypto.\n *\n * Ignored if `storePrefix` is null, or `storeKey` is set. If neither this nor `storeKey` is set\n * (and `storePrefix` is not null), the indexeddb will be unencrypted.\n */\n storePassphrase?: string;\n\n /**\n * A key to use to encrypt the indexeddb created by rust-crypto.\n *\n * Ignored if `storePrefix` is null. Otherwise, if it is set, it must be a 32-byte cryptographic key, which\n * will be used to encrypt the indexeddb. See also `storePassphrase`.\n */\n storeKey?: Uint8Array;\n\n /** If defined, we will check if any data needs migrating from this store to the rust store. */\n legacyCryptoStore?: CryptoStore;\n\n /** The pickle key for `legacyCryptoStore` */\n legacyPickleKey?: string;\n\n /**\n * A callback which will receive progress updates on migration from `legacyCryptoStore`.\n *\n * Called with (-1, -1) to mark the end of migration.\n */\n legacyMigrationProgressListener?: (progress: number, total: number) => void;\n\n /**\n * Whether to enable support for encrypting state events.\n */\n enableEncryptedStateEvents?: boolean;\n}): Promise<RustCrypto> {\n const { logger } = args;\n\n // initialise the rust matrix-sdk-crypto-wasm, if it hasn't already been done\n logger.debug(\"Initialising Rust crypto-sdk WASM artifact\");\n await RustSdkCryptoJs.initAsync();\n\n logger.debug(\"Opening Rust CryptoStore\");\n let storeHandle;\n if (args.storePrefix) {\n if (args.storeKey) {\n storeHandle = await StoreHandle.openWithKey(args.storePrefix, args.storeKey, logger);\n } else {\n storeHandle = await StoreHandle.open(args.storePrefix, args.storePassphrase, logger);\n }\n } else {\n storeHandle = await StoreHandle.open(null, null, logger);\n }\n\n if (args.legacyCryptoStore) {\n // We have a legacy crypto store, which we may need to migrate from.\n await migrateFromLegacyCrypto({\n legacyStore: args.legacyCryptoStore,\n storeHandle,\n ...args,\n });\n }\n\n const rustCrypto = await initOlmMachine(\n logger,\n args.http,\n args.userId,\n args.deviceId,\n args.secretStorage,\n args.cryptoCallbacks,\n storeHandle,\n args.legacyCryptoStore,\n args.enableEncryptedStateEvents,\n );\n\n storeHandle.free();\n\n logger.debug(\"Completed rust crypto-sdk setup\");\n return rustCrypto;\n}\n\nasync function initOlmMachine(\n logger: Logger,\n http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n userId: string,\n deviceId: string,\n secretStorage: ServerSideSecretStorage,\n cryptoCallbacks: CryptoCallbacks,\n storeHandle: StoreHandle,\n legacyCryptoStore?: CryptoStore,\n enableEncryptedStateEvents?: boolean,\n): Promise<RustCrypto> {\n logger.debug(\"Init OlmMachine\");\n\n const olmMachine = await RustSdkCryptoJs.OlmMachine.initFromStore(\n new RustSdkCryptoJs.UserId(userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n storeHandle,\n logger,\n );\n\n // A final migration step, now that we have an OlmMachine.\n if (legacyCryptoStore) {\n await migrateRoomSettingsFromLegacyCrypto({\n logger,\n legacyStore: legacyCryptoStore,\n olmMachine,\n });\n }\n\n // Disable room key requests, per https://github.com/vector-im/element-web/issues/26524.\n olmMachine.roomKeyRequestsEnabled = false;\n\n const rustCrypto = new RustCrypto(\n logger,\n olmMachine,\n http,\n userId,\n deviceId,\n secretStorage,\n cryptoCallbacks,\n enableEncryptedStateEvents,\n );\n\n await olmMachine.registerRoomKeyUpdatedCallback((sessions: RustSdkCryptoJs.RoomKeyInfo[]) =>\n rustCrypto.onRoomKeysUpdated(sessions),\n );\n await olmMachine.registerRoomKeysWithheldCallback((withheld: RustSdkCryptoJs.RoomKeyWithheldInfo[]) =>\n rustCrypto.onRoomKeysWithheld(withheld),\n );\n await olmMachine.registerUserIdentityUpdatedCallback((userId: RustSdkCryptoJs.UserId) =>\n rustCrypto.onUserIdentityUpdated(userId),\n );\n await olmMachine.registerDevicesUpdatedCallback((userIds: string[]) => rustCrypto.onDevicesUpdated(userIds));\n\n // Check if there are any key backup secrets pending processing. There may be multiple secrets to process if several devices have gossiped them.\n // The `registerReceiveSecretCallback` function will only be triggered for new secrets. If the client is restarted before processing them, the secrets will need to be manually handled.\n rustCrypto.checkSecrets(\"m.megolm_backup.v1\");\n\n // Register a callback to be notified when a new secret is received, as for now only the key backup secret is supported (the cross signing secrets are handled automatically by the OlmMachine)\n await olmMachine.registerReceiveSecretCallback((name: string, _value: string) =>\n // Instead of directly checking the secret value, we poll the inbox to get all values for that secret type.\n // Once we have all the values, we can safely clear the secret inbox.\n rustCrypto.checkSecrets(name),\n );\n\n // Tell the OlmMachine to think about its outgoing requests before we hand control back to the application.\n //\n // This is primarily a fudge to get it to correctly populate the `users_for_key_query` list, so that future\n // calls to getIdentity (etc) block until the key queries are performed.\n //\n // Note that we don't actually need to *make* any requests here; it is sufficient to tell the Rust side to think\n // about them.\n //\n // XXX: find a less hacky way to do this.\n await olmMachine.outgoingRequests();\n\n if (legacyCryptoStore && (await legacyCryptoStore.containsData())) {\n const migrationState = await legacyCryptoStore.getMigrationState();\n if (migrationState < MigrationState.INITIAL_OWN_KEY_QUERY_DONE) {\n logger.debug(`Performing initial key query after migration`);\n // We need to do an initial keys query so that the rust stack can properly update trust of\n // the user device and identity from the migrated private keys.\n // If not done, there is a short period where the own device/identity trust will be undefined after migration.\n let initialKeyQueryDone = false;\n while (!initialKeyQueryDone) {\n try {\n await rustCrypto.userHasCrossSigningKeys(userId);\n initialKeyQueryDone = true;\n } catch (e) {\n // If the initial key query fails, we retry until it succeeds.\n logger.error(\"Failed to check for cross-signing keys after migration, retrying\", e);\n }\n }\n\n // If the private master cross-signing key was not cached in the legacy store, the rust session\n // will not be able to establish the trust of the user identity.\n // That means that after migration the session could revert to unverified.\n // In order to avoid asking the users to re-verify their sessions, we need to migrate the legacy local trust\n // (if the legacy session was already verified) to the new session.\n await migrateLegacyLocalTrustIfNeeded({ legacyCryptoStore, rustCrypto, logger });\n\n await legacyCryptoStore.setMigrationState(MigrationState.INITIAL_OWN_KEY_QUERY_DONE);\n }\n }\n\n return rustCrypto;\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,eAAe,MAAM,oCAAoC;AACrE,SAASC,WA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,CAAC,EAAE;YACR;YACA3D,MAAM,CAAC4D,KAAK,CAAC,kEAAkE,EAAED,CAAC,CAAC;UACvF;QACJ;;QAEA;QACA;QACA;QACA;QACA;QACA,MAAMpE,+BAA+B,CAAC;UAAEkB,iBAAiB;UAAEG,UAAU;UAAEZ;QAAO,CAAC,CAAC;QAEhF,MAAMS,iBAAiB,CAACoD,iBAAiB,CAACxE,cAAc,CAACmE,0BAA0B,CAAC;MACxF;IACJ;IAEA,OAAO5C,UAAU;EACrB,CAAC;EAAA,OAAAkB,eAAA,CAAAlC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["RustSdkCryptoJs","StoreHandle","MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE","RustCrypto","MigrationState","migrateFromLegacyCrypto","migrateLegacyLocalTrustIfNeeded","migrateRoomSettingsFromLegacyCrypto","initRustCrypto","_x","_initRustCrypto","apply","arguments","_asyncToGenerator","args","logger","debug","initAsync","storeHandle","storePrefix","storeKey","openWithKey","open","storePassphrase","legacyCryptoStore","_objectSpread","legacyStore","rustCrypto","initOlmMachine","http","userId","deviceId","secretStorage","cryptoCallbacks","enableEncryptedStateEvents","free","_x2","_x3","_x4","_x5","_x6","_x7","_x8","_x9","_x0","_initOlmMachine","olmMachine","OlmMachine","initFromStore","UserId","DeviceId","roomKeyRequestsEnabled","registerRoomKeyUpdatedCallback","sessions","onRoomKeysUpdated","registerRoomKeysWithheldCallback","withheld","onRoomKeysWithheld","registerUserIdentityUpdatedCallback","onUserIdentityUpdated","registerDevicesUpdatedCallback","userIds","onDevicesUpdated","checkSecrets","registerReceiveSecretCallback","name","_value","outgoingRequests","containsData","migrationState","getMigrationState","INITIAL_OWN_KEY_QUERY_DONE","initialKeyQueryDone","userHasCrossSigningKeys","e","error","setMigrationState","pendingDetails","getAllRoomsPendingKeyBundles","roomId","toString","Date","now","inviteAcceptedAtMillis","info","concat","toISOString","maybeAcceptKeyBundle","inviterId","clearRoomPendingKeyBundle","RoomId"],"sources":["../../src/rust-crypto/index.ts"],"sourcesContent":["/*\nCopyright 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 * as RustSdkCryptoJs from \"@matrix-org/matrix-sdk-crypto-wasm\";\nimport { StoreHandle } from \"@matrix-org/matrix-sdk-crypto-wasm\";\n\nimport { MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE, RustCrypto } from \"./rust-crypto.ts\";\nimport { type IHttpOpts, type MatrixHttpApi } from \"../http-api/index.ts\";\nimport { type ServerSideSecretStorage } from \"../secret-storage.ts\";\nimport { type Logger } from \"../logger.ts\";\nimport { type CryptoStore, MigrationState } from \"../crypto/store/base.ts\";\nimport {\n migrateFromLegacyCrypto,\n migrateLegacyLocalTrustIfNeeded,\n migrateRoomSettingsFromLegacyCrypto,\n} from \"./libolm_migration.ts\";\nimport { type CryptoCallbacks } from \"../crypto-api/index.ts\";\n\n/**\n * Create a new `RustCrypto` implementation\n *\n * @param args - Parameter object\n * @internal\n */\nexport async function initRustCrypto(args: {\n /** A `Logger` instance that will be used for debug output. */\n logger: Logger;\n\n /**\n * Low-level HTTP interface: used to make outgoing requests required by the rust SDK.\n * We expect it to set the access token, etc.\n */\n http: MatrixHttpApi<IHttpOpts & { onlyData: true }>;\n\n /** The local user's User ID. */\n userId: string;\n\n /** The local user's Device ID. */\n deviceId: string;\n\n /** Interface to server-side secret storage. */\n secretStorage: ServerSideSecretStorage;\n\n /** Crypto callbacks provided by the application. */\n cryptoCallbacks: CryptoCallbacks;\n\n /**\n * The prefix to use on the indexeddbs created by rust-crypto.\n * If `null`, a memory store will be used.\n */\n storePrefix: string | null;\n\n /**\n * A passphrase to use to encrypt the indexeddb created by rust-crypto.\n *\n * Ignored if `storePrefix` is null, or `storeKey` is set. If neither this nor `storeKey` is set\n * (and `storePrefix` is not null), the indexeddb will be unencrypted.\n */\n storePassphrase?: string;\n\n /**\n * A key to use to encrypt the indexeddb created by rust-crypto.\n *\n * Ignored if `storePrefix` is null. Otherwise, if it is set, it must be a 32-byte cryptographic key, which\n * will be used to encrypt the indexeddb. See also `storePassphrase`.\n */\n storeKey?: Uint8Array;\n\n /** If defined, we will check if any data needs migrating from this store to the rust store. */\n legacyCryptoStore?: CryptoStore;\n\n /** The pickle key for `legacyCryptoStore` */\n legacyPickleKey?: string;\n\n /**\n * A callback which will receive progress updates on migration from `legacyCryptoStore`.\n *\n * Called with (-1, -1) to mark the end of migration.\n */\n legacyMigrationProgressListener?: (progress: number, total: number) => void;\n\n /**\n * Whether to enable support for encrypting state events.\n */\n enableEncryptedStateEvents?: boolean;\n}): Promise<RustCrypto> {\n const { logger } = args;\n\n // initialise the rust matrix-sdk-crypto-wasm, if it hasn't already been done\n logger.debug(\"Initialising Rust crypto-sdk WASM artifact\");\n await RustSdkCryptoJs.initAsync();\n\n logger.debug(\"Opening Rust CryptoStore\");\n let storeHandle;\n if (args.storePrefix) {\n if (args.storeKey) {\n storeHandle = await StoreHandle.openWithKey(args.storePrefix, args.storeKey, logger);\n } else {\n storeHandle = await StoreHandle.open(args.storePrefix, args.storePassphrase, logger);\n }\n } else {\n storeHandle = await StoreHandle.open(null, null, logger);\n }\n\n if (args.legacyCryptoStore) {\n // We have a legacy crypto store, which we may need to migrate from.\n await migrateFromLegacyCrypto({\n legacyStore: args.legacyCryptoStore,\n storeHandle,\n ...args,\n });\n }\n\n const rustCrypto = await initOlmMachine(\n logger,\n args.http,\n args.userId,\n args.deviceId,\n args.secretStorage,\n args.cryptoCallbacks,\n storeHandle,\n args.legacyCryptoStore,\n args.enableEncryptedStateEvents,\n );\n\n storeHandle.free();\n\n logger.debug(\"Completed rust crypto-sdk setup\");\n return rustCrypto;\n}\n\nasync function initOlmMachine(\n logger: Logger,\n http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,\n userId: string,\n deviceId: string,\n secretStorage: ServerSideSecretStorage,\n cryptoCallbacks: CryptoCallbacks,\n storeHandle: StoreHandle,\n legacyCryptoStore?: CryptoStore,\n enableEncryptedStateEvents?: boolean,\n): Promise<RustCrypto> {\n logger.debug(\"Init OlmMachine\");\n\n const olmMachine = await RustSdkCryptoJs.OlmMachine.initFromStore(\n new RustSdkCryptoJs.UserId(userId),\n new RustSdkCryptoJs.DeviceId(deviceId),\n storeHandle,\n logger,\n );\n\n // A final migration step, now that we have an OlmMachine.\n if (legacyCryptoStore) {\n await migrateRoomSettingsFromLegacyCrypto({\n logger,\n legacyStore: legacyCryptoStore,\n olmMachine,\n });\n }\n\n // Disable room key requests, per https://github.com/vector-im/element-web/issues/26524.\n olmMachine.roomKeyRequestsEnabled = false;\n\n const rustCrypto = new RustCrypto(\n logger,\n olmMachine,\n http,\n userId,\n deviceId,\n secretStorage,\n cryptoCallbacks,\n enableEncryptedStateEvents,\n );\n\n await olmMachine.registerRoomKeyUpdatedCallback((sessions: RustSdkCryptoJs.RoomKeyInfo[]) =>\n rustCrypto.onRoomKeysUpdated(sessions),\n );\n await olmMachine.registerRoomKeysWithheldCallback((withheld: RustSdkCryptoJs.RoomKeyWithheldInfo[]) =>\n rustCrypto.onRoomKeysWithheld(withheld),\n );\n await olmMachine.registerUserIdentityUpdatedCallback((userId: RustSdkCryptoJs.UserId) =>\n rustCrypto.onUserIdentityUpdated(userId),\n );\n await olmMachine.registerDevicesUpdatedCallback((userIds: string[]) => rustCrypto.onDevicesUpdated(userIds));\n\n // Check if there are any key backup secrets pending processing. There may be multiple secrets to process if several devices have gossiped them.\n // The `registerReceiveSecretCallback` function will only be triggered for new secrets. If the client is restarted before processing them, the secrets will need to be manually handled.\n rustCrypto.checkSecrets(\"m.megolm_backup.v1\");\n\n // Register a callback to be notified when a new secret is received, as for now only the key backup secret is supported (the cross signing secrets are handled automatically by the OlmMachine)\n await olmMachine.registerReceiveSecretCallback((name: string, _value: string) =>\n // Instead of directly checking the secret value, we poll the inbox to get all values for that secret type.\n // Once we have all the values, we can safely clear the secret inbox.\n rustCrypto.checkSecrets(name),\n );\n\n // Tell the OlmMachine to think about its outgoing requests before we hand control back to the application.\n //\n // This is primarily a fudge to get it to correctly populate the `users_for_key_query` list, so that future\n // calls to getIdentity (etc) block until the key queries are performed.\n //\n // Note that we don't actually need to *make* any requests here; it is sufficient to tell the Rust side to think\n // about them.\n //\n // XXX: find a less hacky way to do this.\n await olmMachine.outgoingRequests();\n\n if (legacyCryptoStore && (await legacyCryptoStore.containsData())) {\n const migrationState = await legacyCryptoStore.getMigrationState();\n if (migrationState < MigrationState.INITIAL_OWN_KEY_QUERY_DONE) {\n logger.debug(`Performing initial key query after migration`);\n // We need to do an initial keys query so that the rust stack can properly update trust of\n // the user device and identity from the migrated private keys.\n // If not done, there is a short period where the own device/identity trust will be undefined after migration.\n let initialKeyQueryDone = false;\n while (!initialKeyQueryDone) {\n try {\n await rustCrypto.userHasCrossSigningKeys(userId);\n initialKeyQueryDone = true;\n } catch (e) {\n // If the initial key query fails, we retry until it succeeds.\n logger.error(\"Failed to check for cross-signing keys after migration, retrying\", e);\n }\n }\n\n // If the private master cross-signing key was not cached in the legacy store, the rust session\n // will not be able to establish the trust of the user identity.\n // That means that after migration the session could revert to unverified.\n // In order to avoid asking the users to re-verify their sessions, we need to migrate the legacy local trust\n // (if the legacy session was already verified) to the new session.\n await migrateLegacyLocalTrustIfNeeded({ legacyCryptoStore, rustCrypto, logger });\n\n await legacyCryptoStore.setMigrationState(MigrationState.INITIAL_OWN_KEY_QUERY_DONE);\n }\n }\n\n // If we have any recently-joined rooms, see if we have a pending key bundle for them.\n for (const pendingDetails of await olmMachine.getAllRoomsPendingKeyBundles()) {\n const roomId = pendingDetails.roomId.toString();\n if (Date.now() - pendingDetails.inviteAcceptedAtMillis <= MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE) {\n logger.info(\n `Checking for pending key bundle for recently-joined room ${roomId} (joined ${new Date(pendingDetails.inviteAcceptedAtMillis).toISOString()})`,\n );\n await rustCrypto.maybeAcceptKeyBundle(roomId, pendingDetails.inviterId.toString());\n } else {\n logger.info(\n `Clearing pending-key-bundle flag for room ${roomId} (too old: joined ${new Date(pendingDetails.inviteAcceptedAtMillis).toISOString()})`,\n );\n await olmMachine.clearRoomPendingKeyBundle(new RustSdkCryptoJs.RoomId(roomId));\n }\n }\n\n return rustCrypto;\n}\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,eAAe,MAAM,oCAAoC;AACrE,SAASC,WAAW,QAAQ,oCAAoC;AAEhE,SAASC,uCAAuC,EAAEC,UAAU,QAAQ,kBAAkB;AAItF,SAA2BC,cAAc,QAAQ,yBAAyB;AAC1E,SACIC,uBAAuB,EACvBC,+BAA+B,EAC/BC,mCAAmC,QAChC,uBAAuB;AAG9B;AACA;AACA;AACA;AACA;AACA;AACA,gBAAsBC,cAAcA,CAAAC,EAAA;EAAA,OAAAC,eAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAyGnC,SAAAF,gBAAA;EAAAA,eAAA,GAAAG,iBAAA,CAzGM,WAA8BC,IA6DpC,EAAuB;IACpB,IAAM;MAAEC;IAAO,CAAC,GAAGD,IAAI;;IAEvB;IACAC,MAAM,CAACC,KAAK,CAAC,4CAA4C,CAAC;IAC1D,MAAMhB,eAAe,CAACiB,SAAS,CAAC,CAAC;IAEjCF,MAAM,CAACC,KAAK,CAAC,0BAA0B,CAAC;IACxC,IAAIE,WAAW;IACf,IAAIJ,IAAI,CAACK,WAAW,EAAE;MAClB,IAAIL,IAAI,CAACM,QAAQ,EAAE;QACfF,WAAW,SA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G,WAAW,CAAC,CAAC,MAC/I,CAAC;QACD,MAAM3D,UAAU,CAAC4D,oBAAoB,CAACR,MAAM,EAAEF,cAAc,CAACW,SAAS,CAACR,QAAQ,CAAC,CAAC,CAAC;MACtF,CAAC,MAAM;QACHjE,MAAM,CAACqE,IAAI,8CAAAC,MAAA,CACsCN,MAAM,wBAAAM,MAAA,CAAqB,IAAIJ,IAAI,CAACJ,cAAc,CAACM,sBAAsB,CAAC,CAACG,WAAW,CAAC,CAAC,MACzI,CAAC;QACD,MAAMxC,UAAU,CAAC2C,yBAAyB,CAAC,IAAIzF,eAAe,CAAC0F,MAAM,CAACX,MAAM,CAAC,CAAC;MAClF;IACJ;IAEA,OAAOpD,UAAU;EACrB,CAAC;EAAA,OAAAkB,eAAA,CAAAlC,KAAA,OAAAC,SAAA;AAAA","ignoreList":[]}
|
|
@@ -13,6 +13,8 @@ import { type DeviceMap } from "../models/device.ts";
|
|
|
13
13
|
import { type ServerSideSecretStorage } from "../secret-storage.ts";
|
|
14
14
|
import { TypedEventEmitter } from "../models/typed-event-emitter.ts";
|
|
15
15
|
import { type UIAuthCallback } from "../interactive-auth.ts";
|
|
16
|
+
/** The maximum time, in milliseconds, since we accepted an invite, that we should accept a key bundle. */
|
|
17
|
+
export declare const MAX_INVITE_ACCEPTANCE_MS_FOR_KEY_BUNDLE: number;
|
|
16
18
|
/**
|
|
17
19
|
* An implementation of {@link CryptoBackend} using the Rust matrix-sdk-crypto.
|
|
18
20
|
*
|
|
@@ -46,8 +48,6 @@ export declare class RustCrypto extends TypedEventEmitter<RustCryptoEvents, Cryp
|
|
|
46
48
|
private stopped;
|
|
47
49
|
/** mapping of roomId → encryptor class */
|
|
48
50
|
private roomEncryptors;
|
|
49
|
-
/** mapping of room ID -> inviter ID for rooms pending MSC4268 key bundles */
|
|
50
|
-
private readonly roomsPendingKeyBundles;
|
|
51
51
|
private eventDecryptor;
|
|
52
52
|
private keyClaimManager;
|
|
53
53
|
private outgoingRequestProcessor;
|
|
@@ -106,7 +106,7 @@ export declare class RustCrypto extends TypedEventEmitter<RustCryptoEvents, Cryp
|
|
|
106
106
|
/**
|
|
107
107
|
* Implementation of {@link CryptoBackend.markRoomAsPendingKeyBundle}.
|
|
108
108
|
*/
|
|
109
|
-
markRoomAsPendingKeyBundle(roomId: string, inviter: string): void
|
|
109
|
+
markRoomAsPendingKeyBundle(roomId: string, inviter: string): Promise<void>;
|
|
110
110
|
globalBlacklistUnverifiedDevices: boolean;
|
|
111
111
|
/**
|
|
112
112
|
* Implementation of {@link CryptoApi#getVersion}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rust-crypto.d.ts","sourceRoot":"","sources":["../../src/rust-crypto/rust-crypto.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,eAAe,MAAM,oCAAoC,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC9G,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,KAAK,WAAW,EAAoB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAU,MAAM,sBAAsB,CAAC;AAKlF,OAAO,EAEH,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EA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