@textrp/briij-js-sdk 43.2.1 → 44.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -1
- package/README.md +66 -0
- package/lib/@types/auth.d.ts +38 -0
- package/lib/@types/auth.d.ts.map +1 -1
- package/lib/@types/auth.js.map +1 -1
- package/lib/@types/snarkjs.d.js +0 -0
- package/lib/@types/snarkjs.d.js.map +1 -0
- package/lib/auth/credential.d.ts +25 -0
- package/lib/auth/credential.d.ts.map +1 -0
- package/lib/auth/credential.js +48 -0
- package/lib/auth/credential.js.map +1 -0
- package/lib/auth/did.d.ts +22 -0
- package/lib/auth/did.d.ts.map +1 -0
- package/lib/auth/did.js +66 -0
- package/lib/auth/did.js.map +1 -0
- package/lib/auth/wallet.d.ts +22 -0
- package/lib/auth/wallet.d.ts.map +1 -0
- package/lib/auth/wallet.js +27 -0
- package/lib/auth/wallet.js.map +1 -0
- package/lib/auth/zkpE2EE.d.ts +22 -0
- package/lib/auth/zkpE2EE.d.ts.map +1 -0
- package/lib/auth/zkpE2EE.js +69 -0
- package/lib/auth/zkpE2EE.js.map +1 -0
- package/lib/briij.d.ts +5 -0
- package/lib/briij.d.ts.map +1 -1
- package/lib/briij.js +5 -0
- package/lib/briij.js.map +1 -1
- package/lib/client.d.ts +40 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +259 -113
- package/lib/client.js.map +1 -1
- package/lib/xrpl/clientSignedBinding.d.ts +21 -0
- package/lib/xrpl/clientSignedBinding.d.ts.map +1 -0
- package/lib/xrpl/clientSignedBinding.js +112 -0
- package/lib/xrpl/clientSignedBinding.js.map +1 -0
- package/package.json +3 -1
- package/src/@types/auth.ts +44 -0
- package/src/@types/snarkjs.d.ts +17 -0
- package/src/auth/credential.ts +63 -0
- package/src/auth/did.ts +89 -0
- package/src/auth/wallet.ts +50 -0
- package/src/auth/zkpE2EE.ts +88 -0
- package/src/briij.ts +13 -0
- package/src/client.ts +187 -0
- package/src/components/LoginStepper.tsx +50 -0
- package/src/xrpl/clientSignedBinding.ts +136 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
Changes in [
|
|
1
|
+
Changes in [44.1.0] (Unreleased - Briij JavaScript SDK)
|
|
2
|
+
==================================================================================================
|
|
3
|
+
## BREAKING CHANGES
|
|
4
|
+
|
|
5
|
+
- **XRPL DID/Credential Flow**:
|
|
6
|
+
- Added client-signed DID/Credential binding helpers:
|
|
7
|
+
- `configureXrplClientSignedBinding`
|
|
8
|
+
- `runClientSignedDidCredentialBinding`
|
|
9
|
+
- These helpers target server endpoints:
|
|
10
|
+
- `/_matrix/client/v3/did/prepare`
|
|
11
|
+
- `/_matrix/client/v3/did/finalize`
|
|
12
|
+
- `/_matrix/client/v3/credential/prepare`
|
|
13
|
+
- `/_matrix/client/v3/credential/finalize`
|
|
14
|
+
- Wallet adapters used with this flow must return both transaction hash and signed blob (`txBlob` or `signedTxBlob`) so the SDK can finalize with `tx_blob + tx_hash`.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
Changes in [44.0.0] (Unreleased - Briij JavaScript SDK)
|
|
2
19
|
==================================================================================================
|
|
3
20
|
BREAKING CHANGES
|
|
4
21
|
----------------
|
|
22
|
+
* **ZKP/DID Support**: Introduced experimental support for Zero-Knowledge Proof (ZKP) credential binding. Added a prototype Circom circuit for DID-bound wallet credentials (`circuits/e2ee_credential.circom`).
|
|
23
|
+
* **Modular Circuits**: SDK repository now includes a minimal `E2EECredentialBinding` circuit as a basis for ZKP-based identity and credential workflows.
|
|
24
|
+
* **DID Integration**: Laying groundwork for native Decentralized Identifier (DID) support, with initial code and constraints linking Matrix/Briij identities to XRPL wallet addresses.
|
|
25
|
+
* **Developer Preview**: These additions are for developer experimentation and will evolve; APIs for full ZKP-protected flows and DID key management are *not* yet considered stable.
|
|
26
|
+
---
|
|
27
|
+
Changes in [43.2.1]
|
|
5
28
|
* Added mCredits endpoints for native monetization
|
|
6
29
|
* Added Admin mCredits emdpoints for package creation/update
|
|
7
30
|
---
|
package/README.md
CHANGED
|
@@ -135,6 +135,24 @@ For wallet-backed encryption recovery, the SDK exports:
|
|
|
135
135
|
|
|
136
136
|
This is additive and does not alter core Olm/Megolm behavior.
|
|
137
137
|
|
|
138
|
+
## XRPL DID + Credential + optional ZKP login
|
|
139
|
+
|
|
140
|
+
The SDK now includes production-ready support for XRPL DID and credential login
|
|
141
|
+
orchestration against TextRP-Briij:
|
|
142
|
+
|
|
143
|
+
- DID-aware wallet login flow over `io.briij.login.xrpl`
|
|
144
|
+
- Credential create/verify helper methods
|
|
145
|
+
- Optional and free longevity mode (ZKP path) with fallback to baseline flow
|
|
146
|
+
- DID/E2EE metadata persistence for continuity workflows
|
|
147
|
+
|
|
148
|
+
The canonical architecture and rollout references are in TextRP-Briij docs:
|
|
149
|
+
|
|
150
|
+
- `docs/did-zkp-e2ee-plan.md`
|
|
151
|
+
- `docs/architecture/xrpl-sovereign-e2ee.md`
|
|
152
|
+
|
|
153
|
+
Repository link:
|
|
154
|
+
`https://github.com/xurgedigitallab/textrp-briij`
|
|
155
|
+
|
|
138
156
|
### Example: XRPL two-step login with wallet recovery envelope
|
|
139
157
|
|
|
140
158
|
```javascript
|
|
@@ -181,6 +199,54 @@ await client.completeXrplAuth({
|
|
|
181
199
|
|
|
182
200
|
There is a full Node example at `examples/node/xrpl-login-recovery.js`.
|
|
183
201
|
|
|
202
|
+
## XRPL client-signed DID/Credential binding
|
|
203
|
+
|
|
204
|
+
For TextRP-Briij homeservers using the client-signed DID/Credential flow, use:
|
|
205
|
+
|
|
206
|
+
- `configureXrplClientSignedBinding(...)`
|
|
207
|
+
- `runClientSignedDidCredentialBinding(e2eePubkeyCommitment)`
|
|
208
|
+
|
|
209
|
+
This sequence calls:
|
|
210
|
+
|
|
211
|
+
1. `POST /_matrix/client/v3/did/prepare`
|
|
212
|
+
2. wallet signs/submits the unsigned DIDSet payload
|
|
213
|
+
3. `POST /_matrix/client/v3/did/finalize` with `tx_blob` + `tx_hash`
|
|
214
|
+
4. `POST /_matrix/client/v3/credential/prepare`
|
|
215
|
+
5. wallet signs/submits the unsigned CredentialCreate payload
|
|
216
|
+
6. `POST /_matrix/client/v3/credential/finalize` with `tx_blob` + `tx_hash`
|
|
217
|
+
|
|
218
|
+
Example:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
import {
|
|
222
|
+
configureXrplClientSignedBinding,
|
|
223
|
+
runClientSignedDidCredentialBinding,
|
|
224
|
+
} from "@textrp/briij-js-sdk";
|
|
225
|
+
|
|
226
|
+
configureXrplClientSignedBinding({
|
|
227
|
+
homeserverBaseUrl: "http://localhost:8008",
|
|
228
|
+
accessToken: "<matrix_access_token>",
|
|
229
|
+
network: "xrpl",
|
|
230
|
+
wallet: {
|
|
231
|
+
getAddress: async () => "r...",
|
|
232
|
+
signAndSubmit: async (tx) => {
|
|
233
|
+
// wallet implementation must return:
|
|
234
|
+
// - hash: transaction hash
|
|
235
|
+
// - txBlob or signedTxBlob: signed tx blob string
|
|
236
|
+
return { hash: "ABC...", txBlob: "{...signed tx json...}" };
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
await runClientSignedDidCredentialBinding("e2ee-commitment-value");
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Important:
|
|
245
|
+
|
|
246
|
+
- The SDK does not hold wallet seeds.
|
|
247
|
+
- The wallet adapter must return the signed blob (`txBlob` or `signedTxBlob`) in addition to `hash`, otherwise finalize endpoints will fail.
|
|
248
|
+
- The `homeserverBaseUrl` and `accessToken` should come from the active Matrix session after login.
|
|
249
|
+
|
|
184
250
|
## Authenticated media
|
|
185
251
|
|
|
186
252
|
Servers supporting [MSC3916](https://github.com/matrix-org/matrix-spec-proposals/pull/3916) (spec 1.11) will require clients, like
|
package/lib/@types/auth.d.ts
CHANGED
|
@@ -218,6 +218,44 @@ export interface WalletIdentityAccountData {
|
|
|
218
218
|
public_key?: string | null;
|
|
219
219
|
network?: string | null;
|
|
220
220
|
key_type?: string | null;
|
|
221
|
+
did_uri?: string | null;
|
|
222
|
+
credential_id?: string | null;
|
|
223
|
+
e2ee_pubkey_commitment?: string | null;
|
|
224
|
+
}
|
|
225
|
+
interface DidVerificationMethod {
|
|
226
|
+
id: string;
|
|
227
|
+
type: string;
|
|
228
|
+
controller: string;
|
|
229
|
+
publicKeyMultibase?: string;
|
|
230
|
+
blockchainAccountId?: string;
|
|
231
|
+
}
|
|
232
|
+
export interface DidResolutionResult {
|
|
233
|
+
did_uri: string;
|
|
234
|
+
resolution_type?: string;
|
|
235
|
+
did_document: {
|
|
236
|
+
id: string;
|
|
237
|
+
verificationMethod: DidVerificationMethod[];
|
|
238
|
+
authentication: string[];
|
|
239
|
+
service?: Array<Record<string, string>>;
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
export interface CredentialCreateResult {
|
|
243
|
+
credential_id: string;
|
|
244
|
+
status: string;
|
|
245
|
+
}
|
|
246
|
+
export interface CredentialVerifyResult {
|
|
247
|
+
credential_id: string;
|
|
248
|
+
valid: boolean;
|
|
249
|
+
}
|
|
250
|
+
export interface ZkpVerifyResult {
|
|
251
|
+
valid: boolean;
|
|
252
|
+
verified_at?: number;
|
|
253
|
+
reason?: string;
|
|
254
|
+
}
|
|
255
|
+
export interface DidCredentialMetadata {
|
|
256
|
+
didUri: string;
|
|
257
|
+
credentialId: string;
|
|
258
|
+
issuedAt: number;
|
|
221
259
|
}
|
|
222
260
|
export interface XrplWalletLoginRequest extends Omit<LoginRequest, "type"> {
|
|
223
261
|
type: typeof XRPL_WALLET_LOGIN_TYPE;
|
package/lib/@types/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/@types/auth.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAu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E,MAAM,CAAC;IACvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACzB"}
|
package/lib/@types/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","names":["UnstableValue","XRPL_WALLET_LOGIN_TYPE","WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE","WALLET_IDENTITY_ACCOUNT_DATA_TYPE","OAUTH_AWARE_PREFERRED_FLOW_FIELD","DELEGATED_OIDC_COMPATIBILITY","IdentityProviderBrand","SSOAction"],"sources":["../../src/@types/auth.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 { UnstableValue } from \"../NamespacedValue.ts\";\nimport { type IClientWellKnown } from \"../client.ts\";\n\n// disable lint because these are wire responses\n/* eslint-disable camelcase */\n\n/**\n * Represents a response to the CSAPI `/refresh` endpoint.\n */\nexport interface IRefreshTokenResponse {\n access_token: string;\n expires_in_ms: number;\n refresh_token: string;\n}\n\n/* eslint-enable camelcase */\n\n/**\n * Response to GET login flows as per https://spec.matrix.org/v1.3/client-server-api/#get_matrixclientv3login\n */\nexport interface ILoginFlowsResponse {\n flows: LoginFlow[];\n}\n\nexport const XRPL_WALLET_LOGIN_TYPE = \"io.briij.login.xrpl\";\nexport const WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE = \"org.textrp.wallet.e2ee_recovery.v1\";\nexport const WALLET_IDENTITY_ACCOUNT_DATA_TYPE = \"org.textrp.wallet.identity\";\nexport type KnownXrplAlgorithm = \"secp256k1\" | \"ed25519\";\nexport type XrplAlgorithm = KnownXrplAlgorithm | (string & { __brand?: \"XrplAlgorithm\" });\n\nexport type LoginFlow = ISSOFlow | IPasswordFlow | IXrplWalletLoginFlow | ILoginFlow;\n\nexport interface ILoginFlow {\n type: string;\n}\n\nexport interface IPasswordFlow extends ILoginFlow {\n type: \"m.login.password\";\n}\n\nexport interface IXrplWalletLoginFlow extends ILoginFlow {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n}\n\nexport const OAUTH_AWARE_PREFERRED_FLOW_FIELD = new UnstableValue(\n \"oauth_aware_preferred\",\n \"org.matrix.msc3824.delegated_oidc_compatibility\",\n);\n\n/**\n * @alias\n * @deprecated use `OAUTH_AWARE_PREFERRED_FLOW_FIELD` instead.\n */\nexport const DELEGATED_OIDC_COMPATIBILITY = OAUTH_AWARE_PREFERRED_FLOW_FIELD;\n\n/**\n * Representation of SSO flow as per https://spec.matrix.org/v1.3/client-server-api/#client-login-via-sso\n */\nexport interface ISSOFlow extends ILoginFlow {\n type: \"m.login.sso\" | \"m.login.cas\";\n // eslint-disable-next-line camelcase\n identity_providers?: IIdentityProvider[];\n [OAUTH_AWARE_PREFERRED_FLOW_FIELD.name]?: boolean;\n [OAUTH_AWARE_PREFERRED_FLOW_FIELD.altName]?: boolean;\n}\n\nexport enum IdentityProviderBrand {\n Gitlab = \"gitlab\",\n Github = \"github\",\n Apple = \"apple\",\n Google = \"google\",\n Facebook = \"facebook\",\n Twitter = \"twitter\",\n}\n\nexport interface IIdentityProvider {\n id: string;\n name: string;\n icon?: string;\n brand?: IdentityProviderBrand | string;\n}\n\nexport enum SSOAction {\n /** The user intends to login to an existing account */\n LOGIN = \"login\",\n\n /** The user intends to register for a new account */\n REGISTER = \"register\",\n}\n\n/**\n * A client can identify a user using their Matrix ID.\n * This can either be the fully qualified Matrix user ID, or just the localpart of the user ID.\n * @see https://spec.matrix.org/v1.7/client-server-api/#matrix-user-id\n */\ntype UserLoginIdentifier = {\n type: \"m.id.user\";\n user: string;\n};\n\n/**\n * A client can identify a user using a 3PID associated with the user’s account on the homeserver,\n * where the 3PID was previously associated using the /account/3pid API.\n * See the 3PID Types Appendix for a list of Third-party ID media.\n * @see https://spec.matrix.org/v1.7/client-server-api/#third-party-id\n */\ntype ThirdPartyLoginIdentifier = {\n type: \"m.id.thirdparty\";\n medium: string;\n address: string;\n};\n\n/**\n * A client can identify a user using a phone number associated with the user’s account,\n * where the phone number was previously associated using the /account/3pid API.\n * The phone number can be passed in as entered by the user; the homeserver will be responsible for canonicalising it.\n * If the client wishes to canonicalise the phone number,\n * then it can use the m.id.thirdparty identifier type with a medium of msisdn instead.\n *\n * The country is the two-letter uppercase ISO-3166-1 alpha-2 country code that the number in phone should be parsed as if it were dialled from.\n *\n * @see https://spec.matrix.org/v1.7/client-server-api/#phone-number\n */\ntype PhoneLoginIdentifier = {\n type: \"m.id.phone\";\n country: string;\n phone: string;\n};\n\ntype SpecUserIdentifier = UserLoginIdentifier | ThirdPartyLoginIdentifier | PhoneLoginIdentifier;\n\n/**\n * User Identifiers usable for login & user-interactive authentication.\n *\n * Extensibly allows more than Matrix specified identifiers.\n */\nexport type UserIdentifier =\n | SpecUserIdentifier\n | { type: Exclude<string, SpecUserIdentifier[\"type\"]>; [key: string]: any };\n\n/**\n * Request body for POST /login request\n * @see https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv3login\n */\nexport interface LoginRequest {\n /**\n * The login type being used.\n */\n type: \"m.login.password\" | \"m.login.token\" | string;\n /**\n * ID of the client device.\n * If this does not correspond to a known client device, a new device will be created.\n * The given device ID must not be the same as a cross-signing key ID.\n * The server will auto-generate a device_id if this is not specified.\n */\n device_id?: string;\n /**\n * Identification information for a user\n */\n identifier?: UserIdentifier;\n /**\n * A display name to assign to the newly-created device.\n * Ignored if device_id corresponds to a known device.\n */\n initial_device_display_name?: string;\n /**\n * When logging in using a third-party identifier, the medium of the identifier.\n * Must be `email`.\n * @deprecated in favour of `identifier`.\n */\n medium?: \"email\";\n /**\n * Required when type is `m.login.password`. The user’s password.\n */\n password?: string;\n /**\n * If true, the client supports refresh tokens.\n */\n refresh_token?: boolean;\n /**\n * Required when type is `m.login.token`. Part of Token-based login.\n */\n token?: string;\n /**\n * The fully qualified user ID or just local part of the user ID, to log in.\n * @deprecated in favour of identifier.\n */\n user?: string;\n // Extensible\n [key: string]: any;\n}\n\n// Export for backwards compatibility\nexport type ILoginParams = LoginRequest;\n\nexport interface XrplWalletChallengePayload {\n session?: string;\n nonce: string;\n timestamp: number | string;\n message: string;\n public_key: string;\n algorithm?: XrplAlgorithm;\n}\n\nexport interface XrplAuthChallengeRequest extends Omit<LoginRequest, \"type\"> {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n address: string;\n network: string;\n preferred_localpart?: string;\n username?: string;\n display_name?: string;\n}\n\nexport interface XrplAuthChallengeResponse {\n session: string;\n challenge: string;\n}\n\nexport interface XrplAuthCompleteRequest extends Omit<LoginRequest, \"type\"> {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n session: string;\n address: string;\n signature: string;\n public_key?: string;\n network?: string;\n wallet_e2ee_recovery?: WalletE2eeRecoveryEnvelope;\n}\n\nexport interface WalletRecoveryWrap {\n alg: string;\n kdf: string;\n salt: string;\n nonce: string;\n ciphertext: string;\n aad?: string;\n params?: Record<string, unknown>;\n}\n\nexport interface WalletRecoveryPasswordWrap extends WalletRecoveryWrap {}\n\nexport interface WalletE2eeRecoveryEnvelope {\n envelope_version: number;\n chain_id: string;\n account_id: string;\n created_at_ms: number;\n key_id: string;\n wallet_wrap: WalletRecoveryWrap;\n password_wrap: WalletRecoveryPasswordWrap;\n}\n\nexport interface WalletIdentityAccountData {\n chain_id: string;\n account_id: string;\n public_key?: string | null;\n network?: string | null;\n key_type?: string | null;\n}\n\nexport interface XrplWalletLoginRequest extends Omit<LoginRequest, \"type\"> {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n address: string;\n signature: string;\n challenge: string | XrplWalletChallengePayload;\n network?: string;\n}\n\n/**\n * Response body for POST /login request\n * @see https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv3login\n */\nexport interface LoginResponse {\n /**\n * An access token for the account.\n * This access token can then be used to authorize other requests.\n */\n access_token: string;\n /**\n * ID of the logged-in device.\n * Will be the same as the corresponding parameter in the request, if one was specified.\n */\n device_id: string;\n /**\n * The fully-qualified Matrix ID for the account.\n */\n user_id: string;\n /**\n * The lifetime of the access token, in milliseconds.\n * Once the access token has expired a new access token can be obtained by using the provided refresh token.\n * If no refresh token is provided, the client will need to re-log in to obtain a new access token.\n * If not given, the client can assume that the access token will not expire.\n */\n expires_in_ms?: number;\n /**\n * A refresh token for the account.\n * This token can be used to obtain a new access token when it expires by calling the /refresh endpoint.\n */\n refresh_token?: string;\n /**\n * Optional client configuration provided by the server.\n * If present, clients SHOULD use the provided object to reconfigure themselves, optionally validating the URLs within.\n * This object takes the same form as the one returned from .well-known autodiscovery.\n */\n well_known?: IClientWellKnown;\n /**\n * The server_name of the homeserver on which the account has been registered.\n * @deprecated Clients should extract the server_name from user_id (by splitting at the first colon) if they require it.\n */\n home_server?: string;\n}\n\n/**\n * The result of a successful `m.login.token` issuance request as per https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv1loginget_token\n */\nexport interface LoginTokenPostResponse {\n /**\n * The token to use with `m.login.token` to authenticate.\n */\n login_token: string;\n /**\n * Expiration in milliseconds.\n */\n expires_in_ms: number;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,uBAAuB;;AAGrD;AACA;;AAEA;AACA;AACA;;AAOA;;AAEA;AACA;AACA;;AAKA,OAAO,IAAMC,sBAAsB,GAAG,qBAAqB;AAC3D,OAAO,IAAMC,sCAAsC,GAAG,oCAAoC;AAC1F,OAAO,IAAMC,iCAAiC,GAAG,4BAA4B;AAkB7E,OAAO,IAAMC,gCAAgC,GAAG,IAAIJ,aAAa,CAC7D,uBAAuB,EACvB,iDACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,IAAMK,4BAA4B,GAAGD,gCAAgC;;AAE5E;AACA;AACA;;AASA,WAAYE,qBAAqB,0BAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA;AAgBjC,WAAYC,SAAS,0BAATA,SAAS;EACjB;EADQA,SAAS;EAIjB;EAJQA,SAAS;EAAA,OAATA,SAAS;AAAA;;AAQrB;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAiDA;;AA0EA;AACA;AACA;AACA;;AAyCA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"auth.js","names":["UnstableValue","XRPL_WALLET_LOGIN_TYPE","WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE","WALLET_IDENTITY_ACCOUNT_DATA_TYPE","OAUTH_AWARE_PREFERRED_FLOW_FIELD","DELEGATED_OIDC_COMPATIBILITY","IdentityProviderBrand","SSOAction"],"sources":["../../src/@types/auth.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 { UnstableValue } from \"../NamespacedValue.ts\";\nimport { type IClientWellKnown } from \"../client.ts\";\n\n// disable lint because these are wire responses\n/* eslint-disable camelcase */\n\n/**\n * Represents a response to the CSAPI `/refresh` endpoint.\n */\nexport interface IRefreshTokenResponse {\n access_token: string;\n expires_in_ms: number;\n refresh_token: string;\n}\n\n/* eslint-enable camelcase */\n\n/**\n * Response to GET login flows as per https://spec.matrix.org/v1.3/client-server-api/#get_matrixclientv3login\n */\nexport interface ILoginFlowsResponse {\n flows: LoginFlow[];\n}\n\nexport const XRPL_WALLET_LOGIN_TYPE = \"io.briij.login.xrpl\";\nexport const WALLET_E2EE_RECOVERY_ACCOUNT_DATA_TYPE = \"org.textrp.wallet.e2ee_recovery.v1\";\nexport const WALLET_IDENTITY_ACCOUNT_DATA_TYPE = \"org.textrp.wallet.identity\";\nexport type KnownXrplAlgorithm = \"secp256k1\" | \"ed25519\";\nexport type XrplAlgorithm = KnownXrplAlgorithm | (string & { __brand?: \"XrplAlgorithm\" });\n\nexport type LoginFlow = ISSOFlow | IPasswordFlow | IXrplWalletLoginFlow | ILoginFlow;\n\nexport interface ILoginFlow {\n type: string;\n}\n\nexport interface IPasswordFlow extends ILoginFlow {\n type: \"m.login.password\";\n}\n\nexport interface IXrplWalletLoginFlow extends ILoginFlow {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n}\n\nexport const OAUTH_AWARE_PREFERRED_FLOW_FIELD = new UnstableValue(\n \"oauth_aware_preferred\",\n \"org.matrix.msc3824.delegated_oidc_compatibility\",\n);\n\n/**\n * @alias\n * @deprecated use `OAUTH_AWARE_PREFERRED_FLOW_FIELD` instead.\n */\nexport const DELEGATED_OIDC_COMPATIBILITY = OAUTH_AWARE_PREFERRED_FLOW_FIELD;\n\n/**\n * Representation of SSO flow as per https://spec.matrix.org/v1.3/client-server-api/#client-login-via-sso\n */\nexport interface ISSOFlow extends ILoginFlow {\n type: \"m.login.sso\" | \"m.login.cas\";\n // eslint-disable-next-line camelcase\n identity_providers?: IIdentityProvider[];\n [OAUTH_AWARE_PREFERRED_FLOW_FIELD.name]?: boolean;\n [OAUTH_AWARE_PREFERRED_FLOW_FIELD.altName]?: boolean;\n}\n\nexport enum IdentityProviderBrand {\n Gitlab = \"gitlab\",\n Github = \"github\",\n Apple = \"apple\",\n Google = \"google\",\n Facebook = \"facebook\",\n Twitter = \"twitter\",\n}\n\nexport interface IIdentityProvider {\n id: string;\n name: string;\n icon?: string;\n brand?: IdentityProviderBrand | string;\n}\n\nexport enum SSOAction {\n /** The user intends to login to an existing account */\n LOGIN = \"login\",\n\n /** The user intends to register for a new account */\n REGISTER = \"register\",\n}\n\n/**\n * A client can identify a user using their Matrix ID.\n * This can either be the fully qualified Matrix user ID, or just the localpart of the user ID.\n * @see https://spec.matrix.org/v1.7/client-server-api/#matrix-user-id\n */\ntype UserLoginIdentifier = {\n type: \"m.id.user\";\n user: string;\n};\n\n/**\n * A client can identify a user using a 3PID associated with the user’s account on the homeserver,\n * where the 3PID was previously associated using the /account/3pid API.\n * See the 3PID Types Appendix for a list of Third-party ID media.\n * @see https://spec.matrix.org/v1.7/client-server-api/#third-party-id\n */\ntype ThirdPartyLoginIdentifier = {\n type: \"m.id.thirdparty\";\n medium: string;\n address: string;\n};\n\n/**\n * A client can identify a user using a phone number associated with the user’s account,\n * where the phone number was previously associated using the /account/3pid API.\n * The phone number can be passed in as entered by the user; the homeserver will be responsible for canonicalising it.\n * If the client wishes to canonicalise the phone number,\n * then it can use the m.id.thirdparty identifier type with a medium of msisdn instead.\n *\n * The country is the two-letter uppercase ISO-3166-1 alpha-2 country code that the number in phone should be parsed as if it were dialled from.\n *\n * @see https://spec.matrix.org/v1.7/client-server-api/#phone-number\n */\ntype PhoneLoginIdentifier = {\n type: \"m.id.phone\";\n country: string;\n phone: string;\n};\n\ntype SpecUserIdentifier = UserLoginIdentifier | ThirdPartyLoginIdentifier | PhoneLoginIdentifier;\n\n/**\n * User Identifiers usable for login & user-interactive authentication.\n *\n * Extensibly allows more than Matrix specified identifiers.\n */\nexport type UserIdentifier =\n | SpecUserIdentifier\n | { type: Exclude<string, SpecUserIdentifier[\"type\"]>; [key: string]: any };\n\n/**\n * Request body for POST /login request\n * @see https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv3login\n */\nexport interface LoginRequest {\n /**\n * The login type being used.\n */\n type: \"m.login.password\" | \"m.login.token\" | string;\n /**\n * ID of the client device.\n * If this does not correspond to a known client device, a new device will be created.\n * The given device ID must not be the same as a cross-signing key ID.\n * The server will auto-generate a device_id if this is not specified.\n */\n device_id?: string;\n /**\n * Identification information for a user\n */\n identifier?: UserIdentifier;\n /**\n * A display name to assign to the newly-created device.\n * Ignored if device_id corresponds to a known device.\n */\n initial_device_display_name?: string;\n /**\n * When logging in using a third-party identifier, the medium of the identifier.\n * Must be `email`.\n * @deprecated in favour of `identifier`.\n */\n medium?: \"email\";\n /**\n * Required when type is `m.login.password`. The user’s password.\n */\n password?: string;\n /**\n * If true, the client supports refresh tokens.\n */\n refresh_token?: boolean;\n /**\n * Required when type is `m.login.token`. Part of Token-based login.\n */\n token?: string;\n /**\n * The fully qualified user ID or just local part of the user ID, to log in.\n * @deprecated in favour of identifier.\n */\n user?: string;\n // Extensible\n [key: string]: any;\n}\n\n// Export for backwards compatibility\nexport type ILoginParams = LoginRequest;\n\nexport interface XrplWalletChallengePayload {\n session?: string;\n nonce: string;\n timestamp: number | string;\n message: string;\n public_key: string;\n algorithm?: XrplAlgorithm;\n}\n\nexport interface XrplAuthChallengeRequest extends Omit<LoginRequest, \"type\"> {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n address: string;\n network: string;\n preferred_localpart?: string;\n username?: string;\n display_name?: string;\n}\n\nexport interface XrplAuthChallengeResponse {\n session: string;\n challenge: string;\n}\n\nexport interface XrplAuthCompleteRequest extends Omit<LoginRequest, \"type\"> {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n session: string;\n address: string;\n signature: string;\n public_key?: string;\n network?: string;\n wallet_e2ee_recovery?: WalletE2eeRecoveryEnvelope;\n}\n\nexport interface WalletRecoveryWrap {\n alg: string;\n kdf: string;\n salt: string;\n nonce: string;\n ciphertext: string;\n aad?: string;\n params?: Record<string, unknown>;\n}\n\nexport interface WalletRecoveryPasswordWrap extends WalletRecoveryWrap {}\n\nexport interface WalletE2eeRecoveryEnvelope {\n envelope_version: number;\n chain_id: string;\n account_id: string;\n created_at_ms: number;\n key_id: string;\n wallet_wrap: WalletRecoveryWrap;\n password_wrap: WalletRecoveryPasswordWrap;\n}\n\nexport interface WalletIdentityAccountData {\n chain_id: string;\n account_id: string;\n public_key?: string | null;\n network?: string | null;\n key_type?: string | null;\n did_uri?: string | null;\n credential_id?: string | null;\n e2ee_pubkey_commitment?: string | null;\n}\n\ninterface DidVerificationMethod {\n id: string;\n type: string;\n controller: string;\n publicKeyMultibase?: string;\n blockchainAccountId?: string;\n}\n\nexport interface DidResolutionResult {\n did_uri: string;\n resolution_type?: string;\n did_document: {\n id: string;\n verificationMethod: DidVerificationMethod[];\n authentication: string[];\n service?: Array<Record<string, string>>;\n };\n}\n\nexport interface CredentialCreateResult {\n credential_id: string;\n status: string;\n}\n\nexport interface CredentialVerifyResult {\n credential_id: string;\n valid: boolean;\n}\n\nexport interface ZkpVerifyResult {\n valid: boolean;\n verified_at?: number;\n reason?: string;\n}\n\nexport interface DidCredentialMetadata {\n didUri: string;\n credentialId: string;\n issuedAt: number;\n}\n\nexport interface XrplWalletLoginRequest extends Omit<LoginRequest, \"type\"> {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n address: string;\n signature: string;\n challenge: string | XrplWalletChallengePayload;\n network?: string;\n}\n\n/**\n * Response body for POST /login request\n * @see https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv3login\n */\nexport interface LoginResponse {\n /**\n * An access token for the account.\n * This access token can then be used to authorize other requests.\n */\n access_token: string;\n /**\n * ID of the logged-in device.\n * Will be the same as the corresponding parameter in the request, if one was specified.\n */\n device_id: string;\n /**\n * The fully-qualified Matrix ID for the account.\n */\n user_id: string;\n /**\n * The lifetime of the access token, in milliseconds.\n * Once the access token has expired a new access token can be obtained by using the provided refresh token.\n * If no refresh token is provided, the client will need to re-log in to obtain a new access token.\n * If not given, the client can assume that the access token will not expire.\n */\n expires_in_ms?: number;\n /**\n * A refresh token for the account.\n * This token can be used to obtain a new access token when it expires by calling the /refresh endpoint.\n */\n refresh_token?: string;\n /**\n * Optional client configuration provided by the server.\n * If present, clients SHOULD use the provided object to reconfigure themselves, optionally validating the URLs within.\n * This object takes the same form as the one returned from .well-known autodiscovery.\n */\n well_known?: IClientWellKnown;\n /**\n * The server_name of the homeserver on which the account has been registered.\n * @deprecated Clients should extract the server_name from user_id (by splitting at the first colon) if they require it.\n */\n home_server?: string;\n}\n\n/**\n * The result of a successful `m.login.token` issuance request as per https://spec.matrix.org/v1.7/client-server-api/#post_matrixclientv1loginget_token\n */\nexport interface LoginTokenPostResponse {\n /**\n * The token to use with `m.login.token` to authenticate.\n */\n login_token: string;\n /**\n * Expiration in milliseconds.\n */\n expires_in_ms: number;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,uBAAuB;;AAGrD;AACA;;AAEA;AACA;AACA;;AAOA;;AAEA;AACA;AACA;;AAKA,OAAO,IAAMC,sBAAsB,GAAG,qBAAqB;AAC3D,OAAO,IAAMC,sCAAsC,GAAG,oCAAoC;AAC1F,OAAO,IAAMC,iCAAiC,GAAG,4BAA4B;AAkB7E,OAAO,IAAMC,gCAAgC,GAAG,IAAIJ,aAAa,CAC7D,uBAAuB,EACvB,iDACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,IAAMK,4BAA4B,GAAGD,gCAAgC;;AAE5E;AACA;AACA;;AASA,WAAYE,qBAAqB,0BAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAArBA,qBAAqB;EAAA,OAArBA,qBAAqB;AAAA;AAgBjC,WAAYC,SAAS,0BAATA,SAAS;EACjB;EADQA,SAAS;EAIjB;EAJQA,SAAS;EAAA,OAATA,SAAS;AAAA;;AAQrB;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAiDA;;AAsHA;AACA;AACA;AACA;;AAyCA;AACA;AACA","ignoreList":[]}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snarkjs.d.js","names":[],"sources":["../../src/@types/snarkjs.d.ts"],"sourcesContent":["declare module \"snarkjs\" {\n export const groth16: {\n fullProve: (\n input: Record<string, string>,\n wasmPath: string,\n zkeyPath: string,\n ) => Promise<{\n proof: Record<string, unknown>;\n publicSignals: string[] | Record<string, string>;\n }>;\n verify: (\n verificationKey: Record<string, unknown>,\n publicSignals: string[] | Record<string, string>,\n proof: Record<string, unknown>,\n ) => Promise<boolean>;\n };\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface CredentialCreateRequest {
|
|
2
|
+
did_uri: string;
|
|
3
|
+
subject: string;
|
|
4
|
+
e2ee_pubkey_commitment: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CredentialCreateResponse {
|
|
7
|
+
credential_id: string;
|
|
8
|
+
status: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CredentialVerifyResponse {
|
|
11
|
+
credential_id: string;
|
|
12
|
+
valid: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface DidCredentialMetadata {
|
|
15
|
+
didUri: string;
|
|
16
|
+
credentialId: string;
|
|
17
|
+
issuedAt: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function requestCredentialCreate(requester: (path: string, method: "POST", body: CredentialCreateRequest) => Promise<CredentialCreateResponse>, payload: CredentialCreateRequest): Promise<CredentialCreateResponse>;
|
|
20
|
+
export declare function verifyCredential(requester: (path: string, method: "POST", body: {
|
|
21
|
+
credential_id: string;
|
|
22
|
+
}) => Promise<CredentialVerifyResponse>, credentialId: string): Promise<CredentialVerifyResponse>;
|
|
23
|
+
export declare function storeDidCredentialMetadata(userId: string, metadata: DidCredentialMetadata): void;
|
|
24
|
+
export declare function loadDidCredentialMetadata(userId: string): DidCredentialMetadata | null;
|
|
25
|
+
//# sourceMappingURL=credential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../../src/auth/credential.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAKD,wBAAsB,uBAAuB,CACzC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,KAAK,OAAO,CAAC,wBAAwB,CAAC,EAC7G,OAAO,EAAE,uBAAuB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAEnC;AAED,wBAAsB,gBAAgB,CAClC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,wBAAwB,CAAC,EAC/G,YAAY,EAAE,MAAM,GACrB,OAAO,CAAC,wBAAwB,CAAC,CAEnC;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAKhG;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAMtF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2026 Xurge Digital Lab
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var METADATA_KEY = "briij.did_credential_metadata";
|
|
13
|
+
var memoryMetadata = new Map();
|
|
14
|
+
export function requestCredentialCreate(_x, _x2) {
|
|
15
|
+
return _requestCredentialCreate.apply(this, arguments);
|
|
16
|
+
}
|
|
17
|
+
function _requestCredentialCreate() {
|
|
18
|
+
_requestCredentialCreate = _asyncToGenerator(function* (requester, payload) {
|
|
19
|
+
return requester("/credential/create", "POST", payload);
|
|
20
|
+
});
|
|
21
|
+
return _requestCredentialCreate.apply(this, arguments);
|
|
22
|
+
}
|
|
23
|
+
export function verifyCredential(_x3, _x4) {
|
|
24
|
+
return _verifyCredential.apply(this, arguments);
|
|
25
|
+
}
|
|
26
|
+
function _verifyCredential() {
|
|
27
|
+
_verifyCredential = _asyncToGenerator(function* (requester, credentialId) {
|
|
28
|
+
return requester("/credential/verify", "POST", {
|
|
29
|
+
credential_id: credentialId
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return _verifyCredential.apply(this, arguments);
|
|
33
|
+
}
|
|
34
|
+
export function storeDidCredentialMetadata(userId, metadata) {
|
|
35
|
+
memoryMetadata.set(userId, metadata);
|
|
36
|
+
if (globalThis.localStorage) {
|
|
37
|
+
globalThis.localStorage.setItem("".concat(METADATA_KEY, ":").concat(userId), JSON.stringify(metadata));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function loadDidCredentialMetadata(userId) {
|
|
41
|
+
var _globalThis$localStor;
|
|
42
|
+
var fromMemory = memoryMetadata.get(userId);
|
|
43
|
+
if (fromMemory) return fromMemory;
|
|
44
|
+
var raw = (_globalThis$localStor = globalThis.localStorage) === null || _globalThis$localStor === void 0 ? void 0 : _globalThis$localStor.getItem("".concat(METADATA_KEY, ":").concat(userId));
|
|
45
|
+
if (!raw) return null;
|
|
46
|
+
return JSON.parse(raw);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.js","names":["METADATA_KEY","memoryMetadata","Map","requestCredentialCreate","_x","_x2","_requestCredentialCreate","apply","arguments","_asyncToGenerator","requester","payload","verifyCredential","_x3","_x4","_verifyCredential","credentialId","credential_id","storeDidCredentialMetadata","userId","metadata","set","globalThis","localStorage","setItem","concat","JSON","stringify","loadDidCredentialMetadata","_globalThis$localStor","fromMemory","get","raw","getItem","parse"],"sources":["../../src/auth/credential.ts"],"sourcesContent":["/*\nCopyright 2026 Xurge Digital Lab\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*/\n\nexport interface CredentialCreateRequest {\n did_uri: string;\n subject: string;\n e2ee_pubkey_commitment: string;\n}\n\nexport interface CredentialCreateResponse {\n credential_id: string;\n status: string;\n}\n\nexport interface CredentialVerifyResponse {\n credential_id: string;\n valid: boolean;\n}\n\nexport interface DidCredentialMetadata {\n didUri: string;\n credentialId: string;\n issuedAt: number;\n}\n\nconst METADATA_KEY = \"briij.did_credential_metadata\";\nconst memoryMetadata = new Map<string, DidCredentialMetadata>();\n\nexport async function requestCredentialCreate(\n requester: (path: string, method: \"POST\", body: CredentialCreateRequest) => Promise<CredentialCreateResponse>,\n payload: CredentialCreateRequest,\n): Promise<CredentialCreateResponse> {\n return requester(\"/credential/create\", \"POST\", payload);\n}\n\nexport async function verifyCredential(\n requester: (path: string, method: \"POST\", body: { credential_id: string }) => Promise<CredentialVerifyResponse>,\n credentialId: string,\n): Promise<CredentialVerifyResponse> {\n return requester(\"/credential/verify\", \"POST\", { credential_id: credentialId });\n}\n\nexport function storeDidCredentialMetadata(userId: string, metadata: DidCredentialMetadata): void {\n memoryMetadata.set(userId, metadata);\n if (globalThis.localStorage) {\n globalThis.localStorage.setItem(`${METADATA_KEY}:${userId}`, JSON.stringify(metadata));\n }\n}\n\nexport function loadDidCredentialMetadata(userId: string): DidCredentialMetadata | null {\n const fromMemory = memoryMetadata.get(userId);\n if (fromMemory) return fromMemory;\n const raw = globalThis.localStorage?.getItem(`${METADATA_KEY}:${userId}`);\n if (!raw) return null;\n return JSON.parse(raw) as DidCredentialMetadata;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwBA,IAAMA,YAAY,GAAG,+BAA+B;AACpD,IAAMC,cAAc,GAAG,IAAIC,GAAG,CAAgC,CAAC;AAE/D,gBAAsBC,uBAAuBA,CAAAC,EAAA,EAAAC,GAAA;EAAA,OAAAC,wBAAA,CAAAC,KAAA,OAAAC,SAAA;AAAA;AAK5C,SAAAF,yBAAA;EAAAA,wBAAA,GAAAG,iBAAA,CALM,WACHC,SAA6G,EAC7GC,OAAgC,EACC;IACjC,OAAOD,SAAS,CAAC,oBAAoB,EAAE,MAAM,EAAEC,OAAO,CAAC;EAC3D,CAAC;EAAA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
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
controller: string;
|
|
5
|
+
publicKeyMultibase?: string;
|
|
6
|
+
blockchainAccountId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DidDocumentShape {
|
|
9
|
+
id: string;
|
|
10
|
+
verificationMethod: DidVerificationMethod[];
|
|
11
|
+
authentication: string[];
|
|
12
|
+
service?: Array<Record<string, string>>;
|
|
13
|
+
}
|
|
14
|
+
export interface DidResolutionResponse {
|
|
15
|
+
did_uri: string;
|
|
16
|
+
resolution_type?: string;
|
|
17
|
+
did_document: DidDocumentShape;
|
|
18
|
+
}
|
|
19
|
+
export declare function deriveXrplDid(address: string, network?: "testnet" | "mainnet"): string;
|
|
20
|
+
export declare function createMinimalDidDocument(didUri: string, e2eePubkeyCommitment: string): DidDocumentShape;
|
|
21
|
+
export declare function resolveDidViaHomeserver(requester: (path: string, method: "GET") => Promise<DidResolutionResponse>, account: string): Promise<DidResolutionResponse>;
|
|
22
|
+
//# sourceMappingURL=did.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../../src/auth/did.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,qBAAqB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB,EAAE,qBAAqB,EAAE,CAAC;IAC5C,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,gBAAgB,CAAC;CAClC;AAID,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,GAAG,SAAqB,GAAG,MAAM,CAKjG;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,GAAG,gBAAgB,CAyBvG;AAED,wBAAsB,uBAAuB,CACzC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,KAAK,OAAO,CAAC,qBAAqB,CAAC,EAC1E,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAgBhC"}
|
package/lib/auth/did.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2026 Xurge Digital Lab
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { Resolver } from "did-resolver";
|
|
13
|
+
var fallbackResolver = new Resolver({});
|
|
14
|
+
export function deriveXrplDid(address) {
|
|
15
|
+
var network = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "testnet";
|
|
16
|
+
if (!address || !address.startsWith("r")) {
|
|
17
|
+
throw new Error("Invalid XRPL address");
|
|
18
|
+
}
|
|
19
|
+
return "did:xrpl:".concat(network, ":").concat(address);
|
|
20
|
+
}
|
|
21
|
+
export function createMinimalDidDocument(didUri, e2eePubkeyCommitment) {
|
|
22
|
+
return {
|
|
23
|
+
id: didUri,
|
|
24
|
+
verificationMethod: [{
|
|
25
|
+
id: "".concat(didUri, "#owner"),
|
|
26
|
+
type: "EcdsaSecp256k1RecoveryMethod2020",
|
|
27
|
+
controller: didUri
|
|
28
|
+
}, {
|
|
29
|
+
id: "".concat(didUri, "#e2ee"),
|
|
30
|
+
type: "E2EEPublicKeyCommitment",
|
|
31
|
+
controller: didUri,
|
|
32
|
+
publicKeyMultibase: e2eePubkeyCommitment
|
|
33
|
+
}],
|
|
34
|
+
authentication: ["".concat(didUri, "#owner")],
|
|
35
|
+
service: [{
|
|
36
|
+
id: "".concat(didUri, "#did-resolution"),
|
|
37
|
+
type: "BriijDidResolution",
|
|
38
|
+
serviceEndpoint: "/_matrix/client/v3/did/resolve"
|
|
39
|
+
}]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function resolveDidViaHomeserver(_x, _x2) {
|
|
43
|
+
return _resolveDidViaHomeserver.apply(this, arguments);
|
|
44
|
+
}
|
|
45
|
+
function _resolveDidViaHomeserver() {
|
|
46
|
+
_resolveDidViaHomeserver = _asyncToGenerator(function* (requester, account) {
|
|
47
|
+
var _direct$did_document;
|
|
48
|
+
var direct = yield requester("/did/resolve?account=".concat(encodeURIComponent(account)), "GET");
|
|
49
|
+
if (direct !== null && direct !== void 0 && (_direct$did_document = direct.did_document) !== null && _direct$did_document !== void 0 && _direct$did_document.id) {
|
|
50
|
+
return direct;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Keep a resolver instance available for future DID-method plugins.
|
|
54
|
+
var fallback = yield fallbackResolver.resolve("did:xrpl:testnet:".concat(account));
|
|
55
|
+
if (fallback.didDocument) {
|
|
56
|
+
return {
|
|
57
|
+
did_uri: fallback.didDocument.id,
|
|
58
|
+
did_document: fallback.didDocument,
|
|
59
|
+
resolution_type: "resolver-fallback"
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
throw new Error("Failed to resolve DID document");
|
|
63
|
+
});
|
|
64
|
+
return _resolveDidViaHomeserver.apply(this, arguments);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=did.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did.js","names":["Resolver","fallbackResolver","deriveXrplDid","address","network","arguments","length","undefined","startsWith","Error","concat","createMinimalDidDocument","didUri","e2eePubkeyCommitment","id","verificationMethod","type","controller","publicKeyMultibase","authentication","service","serviceEndpoint","resolveDidViaHomeserver","_x","_x2","_resolveDidViaHomeserver","apply","_asyncToGenerator","requester","account","_direct$did_document","direct","encodeURIComponent","did_document","fallback","resolve","didDocument","did_uri","resolution_type"],"sources":["../../src/auth/did.ts"],"sourcesContent":["/*\nCopyright 2026 Xurge Digital Lab\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*/\n\nimport { Resolver } from \"did-resolver\";\n\nexport interface DidVerificationMethod {\n id: string;\n type: string;\n controller: string;\n publicKeyMultibase?: string;\n blockchainAccountId?: string;\n}\n\nexport interface DidDocumentShape {\n id: string;\n verificationMethod: DidVerificationMethod[];\n authentication: string[];\n service?: Array<Record<string, string>>;\n}\n\nexport interface DidResolutionResponse {\n did_uri: string;\n resolution_type?: string;\n did_document: DidDocumentShape;\n}\n\nconst fallbackResolver = new Resolver({});\n\nexport function deriveXrplDid(address: string, network: \"testnet\" | \"mainnet\" = \"testnet\"): string {\n if (!address || !address.startsWith(\"r\")) {\n throw new Error(\"Invalid XRPL address\");\n }\n return `did:xrpl:${network}:${address}`;\n}\n\nexport function createMinimalDidDocument(didUri: string, e2eePubkeyCommitment: string): DidDocumentShape {\n return {\n id: didUri,\n verificationMethod: [\n {\n id: `${didUri}#owner`,\n type: \"EcdsaSecp256k1RecoveryMethod2020\",\n controller: didUri,\n },\n {\n id: `${didUri}#e2ee`,\n type: \"E2EEPublicKeyCommitment\",\n controller: didUri,\n publicKeyMultibase: e2eePubkeyCommitment,\n },\n ],\n authentication: [`${didUri}#owner`],\n service: [\n {\n id: `${didUri}#did-resolution`,\n type: \"BriijDidResolution\",\n serviceEndpoint: \"/_matrix/client/v3/did/resolve\",\n },\n ],\n };\n}\n\nexport async function resolveDidViaHomeserver(\n requester: (path: string, method: \"GET\") => Promise<DidResolutionResponse>,\n account: string,\n): Promise<DidResolutionResponse> {\n const direct = await requester(`/did/resolve?account=${encodeURIComponent(account)}`, \"GET\");\n if (direct?.did_document?.id) {\n return direct;\n }\n\n // Keep a resolver instance available for future DID-method plugins.\n const fallback = await fallbackResolver.resolve(`did:xrpl:testnet:${account}`);\n if (fallback.didDocument) {\n return {\n did_uri: fallback.didDocument.id,\n did_document: fallback.didDocument as DidDocumentShape,\n resolution_type: \"resolver-fallback\",\n };\n }\n throw new Error(\"Failed to resolve DID document\");\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AAuBvC,IAAMC,gBAAgB,GAAG,IAAID,QAAQ,CAAC,CAAC,CAAC,CAAC;AAEzC,OAAO,SAASE,aAAaA,CAACC,OAAe,EAAsD;EAAA,IAApDC,OAA8B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,SAAS;EACrF,IAAI,CAACF,OAAO,IAAI,CAACA,OAAO,CAACK,UAAU,CAAC,GAAG,CAAC,EAAE;IACtC,MAAM,IAAIC,KAAK,CAAC,sBAAsB,CAAC;EAC3C;EACA,mBAAAC,MAAA,CAAmBN,OAAO,OAAAM,MAAA,CAAIP,OAAO;AACzC;AAEA,OAAO,SAASQ,wBAAwBA,CAACC,MAAc,EAAEC,oBAA4B,EAAoB;EACrG,OAAO;IACHC,EAAE,EAAEF,MAAM;IACVG,kBAAkB,EAAE,CAChB;MACID,EAAE,KAAAJ,MAAA,CAAKE,MAAM,WAAQ;MACrBI,IAAI,EAAE,kCAAkC;MACxCC,UAAU,EAAEL;IAChB,CAAC,EACD;MACIE,EAAE,KAAAJ,MAAA,CAAKE,MAAM,UAAO;MACpBI,IAAI,EAAE,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ts";
|
|
2
|
+
export interface WalletProofResult {
|
|
3
|
+
address: string;
|
|
4
|
+
signature: string;
|
|
5
|
+
publicKey?: string;
|
|
6
|
+
network?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface WalletLoginSubmission {
|
|
9
|
+
type: typeof XRPL_WALLET_LOGIN_TYPE;
|
|
10
|
+
address: string;
|
|
11
|
+
signature: string;
|
|
12
|
+
public_key?: string;
|
|
13
|
+
network: string;
|
|
14
|
+
session: string;
|
|
15
|
+
username?: string;
|
|
16
|
+
}
|
|
17
|
+
export type WalletProofProvider = (challenge: string, network: string) => Promise<WalletProofResult>;
|
|
18
|
+
/**
|
|
19
|
+
* Normalizes wallet proof payload to the login body used by the homeserver.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildWalletLoginSubmission(proof: WalletProofResult, session: string, network: string, username?: string): WalletLoginSubmission;
|
|
22
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/auth/wallet.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,WAAW,iBAAiB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,OAAO,sBAAsB,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAErG;;GAEG;AACH,wBAAgB,0BAA0B,CACtC,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,GAClB,qBAAqB,CAUvB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2026 Xurge Digital Lab
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { XRPL_WALLET_LOGIN_TYPE } from "../@types/auth.js";
|
|
12
|
+
/**
|
|
13
|
+
* Normalizes wallet proof payload to the login body used by the homeserver.
|
|
14
|
+
*/
|
|
15
|
+
export function buildWalletLoginSubmission(proof, session, network, username) {
|
|
16
|
+
var _proof$network;
|
|
17
|
+
return {
|
|
18
|
+
type: XRPL_WALLET_LOGIN_TYPE,
|
|
19
|
+
session,
|
|
20
|
+
address: proof.address,
|
|
21
|
+
signature: proof.signature,
|
|
22
|
+
public_key: proof.publicKey,
|
|
23
|
+
network: (_proof$network = proof.network) !== null && _proof$network !== void 0 ? _proof$network : network,
|
|
24
|
+
username
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","names":["XRPL_WALLET_LOGIN_TYPE","buildWalletLoginSubmission","proof","session","network","username","_proof$network","type","address","signature","public_key","publicKey"],"sources":["../../src/auth/wallet.ts"],"sourcesContent":["/*\nCopyright 2026 Xurge Digital Lab\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*/\n\nimport { XRPL_WALLET_LOGIN_TYPE } from \"../@types/auth.ts\";\n\nexport interface WalletProofResult {\n address: string;\n signature: string;\n publicKey?: string;\n network?: string;\n}\n\nexport interface WalletLoginSubmission {\n type: typeof XRPL_WALLET_LOGIN_TYPE;\n address: string;\n signature: string;\n public_key?: string;\n network: string;\n session: string;\n username?: string;\n}\n\nexport type WalletProofProvider = (challenge: string, network: string) => Promise<WalletProofResult>;\n\n/**\n * Normalizes wallet proof payload to the login body used by the homeserver.\n */\nexport function buildWalletLoginSubmission(\n proof: WalletProofResult,\n session: string,\n network: string,\n username?: string,\n): WalletLoginSubmission {\n return {\n type: XRPL_WALLET_LOGIN_TYPE,\n session,\n address: proof.address,\n signature: proof.signature,\n public_key: proof.publicKey,\n network: proof.network ?? network,\n username,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,sBAAsB,QAAQ,mBAAmB;AAqB1D;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CACtCC,KAAwB,EACxBC,OAAe,EACfC,OAAe,EACfC,QAAiB,EACI;EAAA,IAAAC,cAAA;EACrB,OAAO;IACHC,IAAI,EAAEP,sBAAsB;IAC5BG,OAAO;IACPK,OAAO,EAAEN,KAAK,CAACM,OAAO;IACtBC,SAAS,EAAEP,KAAK,CAACO,SAAS;IAC1BC,UAAU,EAAER,KAAK,CAACS,SAAS;IAC3BP,OAAO,GAAAE,cAAA,GAAEJ,KAAK,CAACE,OAAO,cAAAE,cAAA,cAAAA,cAAA,GAAIF,OAAO;IACjCC;EACJ,CAAC;AACL","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface E2eeZkInput {
|
|
2
|
+
didUri: string;
|
|
3
|
+
xrplAddress: string;
|
|
4
|
+
e2eePrivateKey: string;
|
|
5
|
+
credentialId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface E2eeZkProofPayload {
|
|
8
|
+
proof: Record<string, unknown>;
|
|
9
|
+
publicSignals: string[] | Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export interface E2eeZkGenerateOptions {
|
|
12
|
+
wasmPath: string;
|
|
13
|
+
zkeyPath: string;
|
|
14
|
+
fullProve?: (input: Record<string, string>, wasmPath: string, zkeyPath: string) => Promise<E2eeZkProofPayload>;
|
|
15
|
+
}
|
|
16
|
+
export interface E2eeZkVerifyOptions {
|
|
17
|
+
verificationKey: Record<string, unknown>;
|
|
18
|
+
verify?: (verificationKey: Record<string, unknown>, publicSignals: E2eeZkProofPayload["publicSignals"], proof: E2eeZkProofPayload["proof"]) => Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
export declare function generateE2eeZkProof(input: E2eeZkInput, options: E2eeZkGenerateOptions): Promise<E2eeZkProofPayload>;
|
|
21
|
+
export declare function verifyE2eeZkProof(payload: E2eeZkProofPayload, options: E2eeZkVerifyOptions): Promise<boolean>;
|
|
22
|
+
//# sourceMappingURL=zkpE2EE.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zkpE2EE.d.ts","sourceRoot":"","sources":["../../src/auth/zkpE2EE.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,qBAAqB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,CACR,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,KACf,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAChC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,CAAC,EAAE,CACL,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,aAAa,EAAE,kBAAkB,CAAC,eAAe,CAAC,EAClD,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,KACjC,OAAO,CAAC,OAAO,CAAC,CAAC;CACzB;AAYD,wBAAsB,mBAAmB,CACrC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,qBAAqB,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAmB7B;AAED,wBAAsB,iBAAiB,CACnC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,mBAAmB,GAC7B,OAAO,CAAC,OAAO,CAAC,CASlB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2026 Xurge Digital Lab
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*/
|
|
11
|
+
function sha256Hex(_x) {
|
|
12
|
+
return _sha256Hex.apply(this, arguments);
|
|
13
|
+
}
|
|
14
|
+
function _sha256Hex() {
|
|
15
|
+
_sha256Hex = _asyncToGenerator(function* (input) {
|
|
16
|
+
var _globalThis$crypto;
|
|
17
|
+
if (!((_globalThis$crypto = globalThis.crypto) !== null && _globalThis$crypto !== void 0 && _globalThis$crypto.subtle)) {
|
|
18
|
+
return input;
|
|
19
|
+
}
|
|
20
|
+
var digest = yield globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(input));
|
|
21
|
+
return Array.from(new Uint8Array(digest)).map(b => b.toString(16).padStart(2, "0")).join("");
|
|
22
|
+
});
|
|
23
|
+
return _sha256Hex.apply(this, arguments);
|
|
24
|
+
}
|
|
25
|
+
export function generateE2eeZkProof(_x2, _x3) {
|
|
26
|
+
return _generateE2eeZkProof.apply(this, arguments);
|
|
27
|
+
}
|
|
28
|
+
function _generateE2eeZkProof() {
|
|
29
|
+
_generateE2eeZkProof = _asyncToGenerator(function* (input, options) {
|
|
30
|
+
var _options$fullProve;
|
|
31
|
+
var fullProve = (_options$fullProve = options.fullProve) !== null && _options$fullProve !== void 0 ? _options$fullProve : (/*#__PURE__*/function () {
|
|
32
|
+
var _ref = _asyncToGenerator(function* (signals, wasmPath, zkeyPath) {
|
|
33
|
+
var snarkjs = yield import("snarkjs");
|
|
34
|
+
return snarkjs.groth16.fullProve(signals, wasmPath, zkeyPath);
|
|
35
|
+
});
|
|
36
|
+
return function (_x6, _x7, _x8) {
|
|
37
|
+
return _ref.apply(this, arguments);
|
|
38
|
+
};
|
|
39
|
+
}());
|
|
40
|
+
var e2eePrivateKeyHash = yield sha256Hex(input.e2eePrivateKey);
|
|
41
|
+
return fullProve({
|
|
42
|
+
did_uri: input.didUri,
|
|
43
|
+
xrpl_address: input.xrplAddress,
|
|
44
|
+
credential_id: input.credentialId,
|
|
45
|
+
e2ee_privkey_hash: e2eePrivateKeyHash
|
|
46
|
+
}, options.wasmPath, options.zkeyPath);
|
|
47
|
+
});
|
|
48
|
+
return _generateE2eeZkProof.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
export function verifyE2eeZkProof(_x4, _x5) {
|
|
51
|
+
return _verifyE2eeZkProof.apply(this, arguments);
|
|
52
|
+
}
|
|
53
|
+
function _verifyE2eeZkProof() {
|
|
54
|
+
_verifyE2eeZkProof = _asyncToGenerator(function* (payload, options) {
|
|
55
|
+
var _options$verify;
|
|
56
|
+
var verifier = (_options$verify = options.verify) !== null && _options$verify !== void 0 ? _options$verify : (/*#__PURE__*/function () {
|
|
57
|
+
var _ref2 = _asyncToGenerator(function* (verificationKey, publicSignals, proof) {
|
|
58
|
+
var snarkjs = yield import("snarkjs");
|
|
59
|
+
return snarkjs.groth16.verify(verificationKey, publicSignals, proof);
|
|
60
|
+
});
|
|
61
|
+
return function (_x9, _x0, _x1) {
|
|
62
|
+
return _ref2.apply(this, arguments);
|
|
63
|
+
};
|
|
64
|
+
}());
|
|
65
|
+
return verifier(options.verificationKey, payload.publicSignals, payload.proof);
|
|
66
|
+
});
|
|
67
|
+
return _verifyE2eeZkProof.apply(this, arguments);
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=zkpE2EE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zkpE2EE.js","names":["sha256Hex","_x","_sha256Hex","apply","arguments","_asyncToGenerator","input","_globalThis$crypto","globalThis","crypto","subtle","digest","TextEncoder","encode","Array","from","Uint8Array","map","b","toString","padStart","join","generateE2eeZkProof","_x2","_x3","_generateE2eeZkProof","options","_options$fullProve","fullProve","_ref","signals","wasmPath","zkeyPath","snarkjs","groth16","_x6","_x7","_x8","e2eePrivateKeyHash","e2eePrivateKey","did_uri","didUri","xrpl_address","xrplAddress","credential_id","credentialId","e2ee_privkey_hash","verifyE2eeZkProof","_x4","_x5","_verifyE2eeZkProof","payload","_options$verify","verifier","verify","_ref2","verificationKey","publicSignals","proof","_x9","_x0","_x1"],"sources":["../../src/auth/zkpE2EE.ts"],"sourcesContent":["/*\nCopyright 2026 Xurge Digital Lab\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*/\n\nexport interface E2eeZkInput {\n didUri: string;\n xrplAddress: string;\n e2eePrivateKey: string;\n credentialId: string;\n}\n\nexport interface E2eeZkProofPayload {\n proof: Record<string, unknown>;\n publicSignals: string[] | Record<string, string>;\n}\n\nexport interface E2eeZkGenerateOptions {\n wasmPath: string;\n zkeyPath: string;\n fullProve?: (\n input: Record<string, string>,\n wasmPath: string,\n zkeyPath: string,\n ) => Promise<E2eeZkProofPayload>;\n}\n\nexport interface E2eeZkVerifyOptions {\n verificationKey: Record<string, unknown>;\n verify?: (\n verificationKey: Record<string, unknown>,\n publicSignals: E2eeZkProofPayload[\"publicSignals\"],\n proof: E2eeZkProofPayload[\"proof\"],\n ) => Promise<boolean>;\n}\n\nasync function sha256Hex(input: string): Promise<string> {\n if (!globalThis.crypto?.subtle) {\n return input;\n }\n const digest = await globalThis.crypto.subtle.digest(\"SHA-256\", new TextEncoder().encode(input));\n return Array.from(new Uint8Array(digest))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\nexport async function generateE2eeZkProof(\n input: E2eeZkInput,\n options: E2eeZkGenerateOptions,\n): Promise<E2eeZkProofPayload> {\n const fullProve =\n options.fullProve ??\n (async (signals, wasmPath, zkeyPath) => {\n const snarkjs = await import(\"snarkjs\");\n return snarkjs.groth16.fullProve(signals, wasmPath, zkeyPath);\n });\n\n const e2eePrivateKeyHash = await sha256Hex(input.e2eePrivateKey);\n return fullProve(\n {\n did_uri: input.didUri,\n xrpl_address: input.xrplAddress,\n credential_id: input.credentialId,\n e2ee_privkey_hash: e2eePrivateKeyHash,\n },\n options.wasmPath,\n options.zkeyPath,\n );\n}\n\nexport async function verifyE2eeZkProof(\n payload: E2eeZkProofPayload,\n options: E2eeZkVerifyOptions,\n): Promise<boolean> {\n const verifier =\n options.verify ??\n (async (verificationKey, publicSignals, proof) => {\n const snarkjs = await import(\"snarkjs\");\n return snarkjs.groth16.verify(verificationKey, publicSignals, proof);\n });\n\n return verifier(options.verificationKey, payload.publicSignals, payload.proof);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARA,SAyCeA,SAASA,CAAAC,EAA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