@interop/was-react 0.11.1 → 0.13.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/README.md +23 -25
- package/dist/auth/loginFlow.d.ts +8 -5
- package/dist/auth/loginFlow.d.ts.map +1 -1
- package/dist/auth/loginFlow.js +46 -16
- package/dist/auth/loginFlow.js.map +1 -1
- package/dist/auth/loginRequest.d.ts +27 -81
- package/dist/auth/loginRequest.d.ts.map +1 -1
- package/dist/auth/loginRequest.js +94 -41
- package/dist/auth/loginRequest.js.map +1 -1
- package/dist/auth/verifyResponse.d.ts +3 -3
- package/dist/auth/verifyResponse.d.ts.map +1 -1
- package/dist/auth/verifyResponse.js +16 -13
- package/dist/auth/verifyResponse.js.map +1 -1
- package/dist/auth/walletRequestTypes.d.ts +8 -6
- package/dist/auth/walletRequestTypes.d.ts.map +1 -1
- package/dist/config.d.ts +19 -13
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -0
- package/dist/config.js.map +1 -1
- package/dist/dev/provisionDevGrants.d.ts.map +1 -1
- package/dist/dev/provisionDevGrants.js +7 -12
- package/dist/dev/provisionDevGrants.js.map +1 -1
- package/dist/grants.d.ts +0 -14
- package/dist/grants.d.ts.map +1 -1
- package/dist/grants.js +0 -13
- package/dist/grants.js.map +1 -1
- package/dist/identity/seedCredential.d.ts +39 -38
- package/dist/identity/seedCredential.d.ts.map +1 -1
- package/dist/identity/seedCredential.js +79 -77
- package/dist/identity/seedCredential.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/react/documentApp.d.ts +6 -6
- package/dist/react/documentApp.d.ts.map +1 -1
- package/dist/react/documentApp.js +7 -6
- package/dist/react/documentApp.js.map +1 -1
- package/dist/react/hooks.d.ts +1 -1
- package/dist/react/hooks.js +1 -1
- package/dist/session/authStore.d.ts +1 -1
- package/dist/session/authStore.js +6 -6
- package/dist/session/authStore.js.map +1 -1
- package/dist/storage/adopt.d.ts +3 -3
- package/dist/storage/adopt.js +5 -5
- package/dist/storage/entityStore.d.ts +1 -1
- package/dist/storage/localStore.d.ts +2 -2
- package/dist/storage/localStore.js +2 -2
- package/dist/storage/storageManager.d.ts +8 -3
- package/dist/storage/storageManager.d.ts.map +1 -1
- package/dist/storage/storageManager.js +19 -12
- package/dist/storage/storageManager.js.map +1 -1
- package/dist/storage/wasRemoteStore.d.ts +1 -1
- package/dist/storage/wasRemoteStore.d.ts.map +1 -1
- package/dist/storage/wasRemoteStore.js +8 -8
- package/dist/storage/wasRemoteStore.js.map +1 -1
- package/dist/sync/index.d.ts +2 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +2 -2
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/lww.d.ts +4 -4
- package/dist/sync/lww.js +7 -7
- package/dist/sync/lwwConflictHandler.d.ts +4 -4
- package/dist/sync/lwwConflictHandler.js +1 -1
- package/dist/sync/types.d.ts +28 -45
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/types.js +17 -35
- package/dist/sync/types.js.map +1 -1
- package/dist/sync/wasSyncPort.d.ts +14 -31
- package/dist/sync/wasSyncPort.d.ts.map +1 -1
- package/dist/sync/wasSyncPort.js +27 -169
- package/dist/sync/wasSyncPort.js.map +1 -1
- package/package.json +3 -3
package/dist/grants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAiBtD
|
|
1
|
+
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;A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;IACxC,CAAC;IACD,IAAI,SAA6B,CAAA;IACjC,IAAI,OAA2B,CAAA;IAC/B,MAAM,cAAc,GAA0B,EAAE,CAAA;IAEhD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAA;QAC9D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QAC9B,CAAC;aAAM,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CACb,6BAA6B,SAAS,SAAS,MAAM,CAAC,SAAS,IAAI,CACpE,CAAA;QACH,CAAC;QACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC1B,CAAC;aAAM,IAAI,OAAO,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,4BAA4B,OAAO,SAAS,MAAM,CAAC,OAAO,IAAI,CAC/D,CAAA;QACH,CAAC;QACD,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAA;IAC5C,CAAC;IAED,OAAO;QACL,SAAS,EAAE,SAAmB;QAC9B,OAAO,EAAE,OAAiB;QAC1B,cAAc;KACf,CAAA;AACH,CAAC"}
|
|
@@ -2,11 +2,10 @@ import type { IVerifiableCredential, IVerifiablePresentation } from '@interop/da
|
|
|
2
2
|
import { type IdentityAgents } from './agents.js';
|
|
3
3
|
import type { DocumentLoader } from './documentLoader.js';
|
|
4
4
|
/**
|
|
5
|
-
* The marker type every app key carries
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* foreign app key at store time.
|
|
5
|
+
* The marker type every app key carries, mapped to one stable IRI for every
|
|
6
|
+
* app by the hosted App Connect context. It makes "presents as an app key" a
|
|
7
|
+
* term check rather than a shape heuristic, which is what lets the wallet
|
|
8
|
+
* refuse a foreign app key at store time.
|
|
10
9
|
*
|
|
11
10
|
* It is a self-declaration, not evidence: the `type` array of a planted
|
|
12
11
|
* credential is attacker-controlled like the rest of it. The marker makes the
|
|
@@ -15,14 +14,9 @@ import type { DocumentLoader } from './documentLoader.js';
|
|
|
15
14
|
*/
|
|
16
15
|
export declare const APP_KEY_CREDENTIAL_TYPE = "AppKeyCredential";
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
19
|
-
* vocabulary namespace its inline-context terms are minted under (e.g.
|
|
20
|
-
* `credentialType: 'MyAppKey'`, `vocabBase: 'urn:my-app:vocab#'`).
|
|
17
|
+
* The credential's fixed two-entry `type` array, in this order.
|
|
21
18
|
*/
|
|
22
|
-
export
|
|
23
|
-
credentialType: string;
|
|
24
|
-
vocabBase: string;
|
|
25
|
-
}
|
|
19
|
+
export declare const APP_KEY_TYPE_ARRAY: readonly string[];
|
|
26
20
|
/**
|
|
27
21
|
* A parsed and structurally validated seed credential.
|
|
28
22
|
*/
|
|
@@ -51,59 +45,66 @@ export declare function base64urlToBytes(text: string): Uint8Array;
|
|
|
51
45
|
* @param options {object}
|
|
52
46
|
* @param options.seed {Uint8Array} the 32-byte master seed
|
|
53
47
|
* @param options.origin {string} this app's web origin (anti-phishing bind)
|
|
48
|
+
* @param options.appUrl {string} this app's canonical URL, in its
|
|
49
|
+
* serialized form (see `serializedAppUrl`); identifies the application among
|
|
50
|
+
* the applications on its origin
|
|
54
51
|
* @param options.appName {string} human-readable app name, shown by the
|
|
55
52
|
* wallet on the credential (`name`/`description`)
|
|
56
|
-
* @param options.config {SeedCredentialConfig} credential type + vocab
|
|
57
53
|
* @param options.documentLoader {DocumentLoader}
|
|
58
54
|
* @returns {Promise<IVerifiableCredential>}
|
|
59
55
|
*/
|
|
60
|
-
export declare function issueSeedCredential({ seed, origin,
|
|
56
|
+
export declare function issueSeedCredential({ seed, origin, appUrl, appName, documentLoader }: {
|
|
61
57
|
seed: Uint8Array;
|
|
62
58
|
origin: string;
|
|
59
|
+
appUrl: string;
|
|
63
60
|
appName: string;
|
|
64
|
-
config: SeedCredentialConfig;
|
|
65
61
|
documentLoader: DocumentLoader;
|
|
66
62
|
}): Promise<IVerifiableCredential>;
|
|
67
63
|
/**
|
|
68
|
-
* Parses
|
|
69
|
-
* `AppKeyCredential` marker type, the
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
64
|
+
* Parses an app-key credential and enforces the App Connect spec's six parse
|
|
65
|
+
* checks, in order: the `AppKeyCredential` marker type, the `appUrl` claim
|
|
66
|
+
* matching what this request sent (exact string), self-issue (issuer ===
|
|
67
|
+
* subject id), the origin binding (exact string, against this app's own live
|
|
68
|
+
* origin -- the same value it sent as the request `domain`), a well-formed
|
|
69
|
+
* 32-byte base64url-no-pad seed, and -- the strongest check -- that the DID
|
|
70
|
+
* derived from the embedded seed IS the credential's subject/issuer DID. (The
|
|
71
|
+
* cryptographic proof on the credential is verified separately at the
|
|
72
|
+
* presentation level.)
|
|
74
73
|
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* since the seed-to-DID binding below is the boundary either way.
|
|
74
|
+
* These duplicate checks the wallet already made; that is the point. They are
|
|
75
|
+
* defense in depth over an origin binding and an identity binding this app is
|
|
76
|
+
* fully able to check itself.
|
|
79
77
|
*
|
|
80
78
|
* @param options {object}
|
|
81
79
|
* @param options.credential {IVerifiableCredential}
|
|
82
|
-
* @param options.origin {string}
|
|
83
|
-
* @param options.
|
|
80
|
+
* @param options.origin {string} this app's own live browser origin
|
|
81
|
+
* @param options.appUrl {string} the serialized `appUrl` this request sent
|
|
84
82
|
* @returns {Promise<ParsedSeedCredential>}
|
|
85
83
|
*/
|
|
86
|
-
export declare function parseSeedCredential({ credential, origin,
|
|
84
|
+
export declare function parseSeedCredential({ credential, origin, appUrl }: {
|
|
87
85
|
credential: IVerifiableCredential;
|
|
88
86
|
origin: string;
|
|
89
|
-
|
|
87
|
+
appUrl: string;
|
|
90
88
|
}): Promise<ParsedSeedCredential>;
|
|
91
89
|
/**
|
|
92
|
-
* Finds the
|
|
93
|
-
* wallet returned none (the
|
|
90
|
+
* Finds the app-key credential inside a wallet response VP, or `null` when the
|
|
91
|
+
* wallet returned none (the wallet-unsupported signal).
|
|
94
92
|
*
|
|
95
|
-
* Matched on the
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
93
|
+
* Matched on the `credentialSubject.appUrl` claim ALONE: per the App Connect
|
|
94
|
+
* spec's response-verification step 3, the `AppKeyCredential` marker type must
|
|
95
|
+
* NOT be required here. Requiring it would make "the wallet returned a
|
|
96
|
+
* credential that is wrong" indistinguishable from "the wallet returned
|
|
97
|
+
* nothing" -- a returned credential missing the marker must surface as a parse
|
|
98
|
+
* error from {@link parseSeedCredential}, not as a `null` a caller would read
|
|
99
|
+
* as first run and answer by silently minting a second key.
|
|
99
100
|
*
|
|
100
101
|
* @param options {object}
|
|
101
102
|
* @param options.presentation {IVerifiablePresentation}
|
|
102
|
-
* @param options.
|
|
103
|
+
* @param options.appUrl {string} the serialized `appUrl` this request sent
|
|
103
104
|
* @returns {IVerifiableCredential | null}
|
|
104
105
|
*/
|
|
105
|
-
export declare function findSeedCredential({ presentation,
|
|
106
|
+
export declare function findSeedCredential({ presentation, appUrl }: {
|
|
106
107
|
presentation: IVerifiablePresentation;
|
|
107
|
-
|
|
108
|
+
appUrl: string;
|
|
108
109
|
}): IVerifiableCredential | null;
|
|
109
110
|
//# sourceMappingURL=seedCredential.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seedCredential.d.ts","sourceRoot":"","sources":["../../src/identity/seedCredential.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"seedCredential.d.ts","sourceRoot":"","sources":["../../src/identity/seedCredential.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,qBA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MAAM,EACP,EAAE;IACD,YAAY,EAAE,uBAAuB,CAAA;IACrC,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,qBAAqB,GAAG,IAAI,CAW/B"}
|
|
@@ -3,31 +3,36 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* The app-key credential: a self-issued VC holding the app's 32-byte master
|
|
6
|
-
* seed, stored in (and recovered from) the user's wallet.
|
|
7
|
-
*
|
|
6
|
+
* seed, stored in (and recovered from) the user's wallet.
|
|
7
|
+
*
|
|
8
|
+
* The credential's vocabulary is fixed and shared by every application: the
|
|
9
|
+
* `type` array is exactly `['VerifiableCredential', 'AppKeyCredential']`, and
|
|
10
|
+
* the `@context` is the VC 1.0 context plus the hosted App Connect context
|
|
11
|
+
* (`https://w3id.org/byoe/app-connect/v1`, resolved as a static context by the
|
|
12
|
+
* document loader, so verification still needs no fetch). Nothing in the
|
|
13
|
+
* credential is app-scoped.
|
|
8
14
|
*
|
|
9
15
|
* The credential is self-issued: `issuer === credentialSubject.id`, and both
|
|
10
16
|
* equal the did:key controller DERIVED FROM THE EMBEDDED SEED -- so possession
|
|
11
17
|
* of the credential is possession of the identity, and a parsed credential can
|
|
12
18
|
* be re-checked against its own seed. `credentialSubject.origin` binds the
|
|
13
19
|
* credential to this app's web origin (the anti-phishing guard checked at
|
|
14
|
-
* login)
|
|
15
|
-
*
|
|
16
|
-
*
|
|
20
|
+
* login), and `credentialSubject.appUrl` identifies WHICH application on that
|
|
21
|
+
* origin it belongs to: the app identity is scoped to the triple (user,
|
|
22
|
+
* origin, `appUrl`).
|
|
17
23
|
*/
|
|
18
24
|
import { base64urlnopad } from '@scure/base';
|
|
19
25
|
import * as vc from '@interop/vc';
|
|
20
26
|
import { Ed25519Signature2020 } from '@interop/ed25519-signature';
|
|
21
|
-
import {
|
|
27
|
+
import { CONTEXT_URL_V1 } from 'byoe-context';
|
|
22
28
|
import { asArray } from '../jsonLd.js';
|
|
23
29
|
import { deriveIdentity } from './agents.js';
|
|
24
30
|
const VC_1_CONTEXT_URL = 'https://www.w3.org/2018/credentials/v1';
|
|
25
31
|
/**
|
|
26
|
-
* The marker type every app key carries
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* foreign app key at store time.
|
|
32
|
+
* The marker type every app key carries, mapped to one stable IRI for every
|
|
33
|
+
* app by the hosted App Connect context. It makes "presents as an app key" a
|
|
34
|
+
* term check rather than a shape heuristic, which is what lets the wallet
|
|
35
|
+
* refuse a foreign app key at store time.
|
|
31
36
|
*
|
|
32
37
|
* It is a self-declaration, not evidence: the `type` array of a planted
|
|
33
38
|
* credential is attacker-controlled like the rest of it. The marker makes the
|
|
@@ -36,30 +41,12 @@ const VC_1_CONTEXT_URL = 'https://www.w3.org/2018/credentials/v1';
|
|
|
36
41
|
*/
|
|
37
42
|
export const APP_KEY_CREDENTIAL_TYPE = 'AppKeyCredential';
|
|
38
43
|
/**
|
|
39
|
-
* The
|
|
40
|
-
* restated here.
|
|
41
|
-
*/
|
|
42
|
-
const BYOE_TERMS = CONTEXT_V1['@context'];
|
|
43
|
-
const APP_KEY_CREDENTIAL_TYPE_IRI = BYOE_TERMS.AppKeyCredential;
|
|
44
|
-
/**
|
|
45
|
-
* Builds the inline context object for the credential's terms, so it stays
|
|
46
|
-
* verifiable with no remote vocabulary fetch. The marker type and the `seed` /
|
|
47
|
-
* `origin` claims carry shared `https://w3id.org/byoe#` IRIs (imported from
|
|
48
|
-
* `byoe-context`) -- they mean the same thing for every app, so they do not
|
|
49
|
-
* belong under a per-app `vocabBase`, which keeps only the app's own type
|
|
50
|
-
* term.
|
|
44
|
+
* The credential's fixed two-entry `type` array, in this order.
|
|
51
45
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
[credentialType]: `${vocabBase}${credentialType}`,
|
|
57
|
-
seed: BYOE_TERMS.seed,
|
|
58
|
-
origin: BYOE_TERMS.origin,
|
|
59
|
-
name: BYOE_TERMS.name,
|
|
60
|
-
description: BYOE_TERMS.description
|
|
61
|
-
};
|
|
62
|
-
}
|
|
46
|
+
export const APP_KEY_TYPE_ARRAY = Object.freeze([
|
|
47
|
+
'VerifiableCredential',
|
|
48
|
+
APP_KEY_CREDENTIAL_TYPE
|
|
49
|
+
]);
|
|
63
50
|
/**
|
|
64
51
|
* Encodes bytes as base64url (no padding), browser- and Node-safe.
|
|
65
52
|
*/
|
|
@@ -79,29 +66,28 @@ export function base64urlToBytes(text) {
|
|
|
79
66
|
* @param options {object}
|
|
80
67
|
* @param options.seed {Uint8Array} the 32-byte master seed
|
|
81
68
|
* @param options.origin {string} this app's web origin (anti-phishing bind)
|
|
69
|
+
* @param options.appUrl {string} this app's canonical URL, in its
|
|
70
|
+
* serialized form (see `serializedAppUrl`); identifies the application among
|
|
71
|
+
* the applications on its origin
|
|
82
72
|
* @param options.appName {string} human-readable app name, shown by the
|
|
83
73
|
* wallet on the credential (`name`/`description`)
|
|
84
|
-
* @param options.config {SeedCredentialConfig} credential type + vocab
|
|
85
74
|
* @param options.documentLoader {DocumentLoader}
|
|
86
75
|
* @returns {Promise<IVerifiableCredential>}
|
|
87
76
|
*/
|
|
88
|
-
export async function issueSeedCredential({ seed, origin,
|
|
77
|
+
export async function issueSeedCredential({ seed, origin, appUrl, appName, documentLoader }) {
|
|
89
78
|
// `deriveIdentity` enforces the 32-byte seed rule.
|
|
90
79
|
const { controllerDid, keyAgent } = await deriveIdentity({ seed });
|
|
91
80
|
const credential = {
|
|
92
|
-
'@context': [VC_1_CONTEXT_URL,
|
|
81
|
+
'@context': [VC_1_CONTEXT_URL, CONTEXT_URL_V1],
|
|
93
82
|
id: `urn:uuid:${crypto.randomUUID()}`,
|
|
94
|
-
type: [
|
|
95
|
-
'VerifiableCredential',
|
|
96
|
-
APP_KEY_CREDENTIAL_TYPE,
|
|
97
|
-
config.credentialType
|
|
98
|
-
],
|
|
83
|
+
type: [...APP_KEY_TYPE_ARRAY],
|
|
99
84
|
name: `${appName} app key`,
|
|
100
85
|
description: `The ${appName} app keeps this key in your wallet so it can open your encrypted data on this and other devices.`,
|
|
101
86
|
issuer: controllerDid,
|
|
102
87
|
credentialSubject: {
|
|
103
88
|
id: controllerDid,
|
|
104
89
|
seed: bytesToBase64url(seed),
|
|
90
|
+
appUrl,
|
|
105
91
|
origin
|
|
106
92
|
}
|
|
107
93
|
};
|
|
@@ -113,79 +99,95 @@ export async function issueSeedCredential({ seed, origin, appName, config, docum
|
|
|
113
99
|
}));
|
|
114
100
|
}
|
|
115
101
|
/**
|
|
116
|
-
* Parses
|
|
117
|
-
* `AppKeyCredential` marker type, the
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
102
|
+
* Parses an app-key credential and enforces the App Connect spec's six parse
|
|
103
|
+
* checks, in order: the `AppKeyCredential` marker type, the `appUrl` claim
|
|
104
|
+
* matching what this request sent (exact string), self-issue (issuer ===
|
|
105
|
+
* subject id), the origin binding (exact string, against this app's own live
|
|
106
|
+
* origin -- the same value it sent as the request `domain`), a well-formed
|
|
107
|
+
* 32-byte base64url-no-pad seed, and -- the strongest check -- that the DID
|
|
108
|
+
* derived from the embedded seed IS the credential's subject/issuer DID. (The
|
|
109
|
+
* cryptographic proof on the credential is verified separately at the
|
|
110
|
+
* presentation level.)
|
|
122
111
|
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* since the seed-to-DID binding below is the boundary either way.
|
|
112
|
+
* These duplicate checks the wallet already made; that is the point. They are
|
|
113
|
+
* defense in depth over an origin binding and an identity binding this app is
|
|
114
|
+
* fully able to check itself.
|
|
127
115
|
*
|
|
128
116
|
* @param options {object}
|
|
129
117
|
* @param options.credential {IVerifiableCredential}
|
|
130
|
-
* @param options.origin {string}
|
|
131
|
-
* @param options.
|
|
118
|
+
* @param options.origin {string} this app's own live browser origin
|
|
119
|
+
* @param options.appUrl {string} the serialized `appUrl` this request sent
|
|
132
120
|
* @returns {Promise<ParsedSeedCredential>}
|
|
133
121
|
*/
|
|
134
|
-
export async function parseSeedCredential({ credential, origin,
|
|
135
|
-
const { credentialType } = config;
|
|
122
|
+
export async function parseSeedCredential({ credential, origin, appUrl }) {
|
|
136
123
|
const types = asArray(credential.type);
|
|
137
|
-
if (!types.includes(credentialType)) {
|
|
138
|
-
throw new Error(`Credential is not a ${credentialType} credential.`);
|
|
139
|
-
}
|
|
140
124
|
if (!types.includes(APP_KEY_CREDENTIAL_TYPE)) {
|
|
141
|
-
throw new Error(
|
|
125
|
+
throw new Error(`The app-key credential does not carry the ` +
|
|
142
126
|
`${APP_KEY_CREDENTIAL_TYPE} type.`);
|
|
143
127
|
}
|
|
128
|
+
const subject = credential.credentialSubject;
|
|
129
|
+
if (subject?.appUrl !== appUrl) {
|
|
130
|
+
throw new Error(`The app-key credential's appUrl "${subject?.appUrl ?? ''}" does not ` +
|
|
131
|
+
`match this app's appUrl "${appUrl}".`);
|
|
132
|
+
}
|
|
144
133
|
const issuer = typeof credential.issuer === 'string'
|
|
145
134
|
? credential.issuer
|
|
146
135
|
: credential.issuer?.id;
|
|
147
|
-
const subject = credential.credentialSubject;
|
|
148
136
|
if (!issuer || !subject?.id || issuer !== subject.id) {
|
|
149
|
-
throw new Error(
|
|
137
|
+
throw new Error('The app-key credential is not self-issued.');
|
|
150
138
|
}
|
|
151
139
|
if (subject.origin !== origin) {
|
|
152
|
-
throw new Error(
|
|
140
|
+
throw new Error(`The app-key credential's origin "${subject.origin ?? ''}" does not match this app's origin "${origin}".`);
|
|
153
141
|
}
|
|
154
142
|
if (typeof subject.seed !== 'string' || subject.seed.length === 0) {
|
|
155
|
-
throw new Error(
|
|
143
|
+
throw new Error('The app-key credential carries no seed.');
|
|
144
|
+
}
|
|
145
|
+
// Fail closed on anything that is not base64url-no-pad decoding to exactly
|
|
146
|
+
// 32 bytes -- never truncate or pad.
|
|
147
|
+
let seed;
|
|
148
|
+
try {
|
|
149
|
+
seed = base64urlToBytes(subject.seed);
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
throw new Error('The app-key seed is not valid base64url (no padding).', {
|
|
153
|
+
cause: err
|
|
154
|
+
});
|
|
156
155
|
}
|
|
157
|
-
const seed = base64urlToBytes(subject.seed);
|
|
158
156
|
if (seed.length !== 32) {
|
|
159
|
-
throw new Error(
|
|
157
|
+
throw new Error(`The app-key seed must decode to 32 bytes (got ${seed.length}).`);
|
|
160
158
|
}
|
|
161
159
|
// Derived once and handed back on the result: the same agents the caller
|
|
162
160
|
// would otherwise re-derive from this seed right after.
|
|
163
161
|
const identity = await deriveIdentity({ seed });
|
|
164
162
|
if (identity.controllerDid !== subject.id) {
|
|
165
|
-
throw new Error(
|
|
163
|
+
throw new Error('The app-key seed does not derive the credential subject DID.');
|
|
166
164
|
}
|
|
167
165
|
return { seed, controllerDid: identity.controllerDid, identity };
|
|
168
166
|
}
|
|
169
167
|
/**
|
|
170
|
-
* Finds the
|
|
171
|
-
* wallet returned none (the
|
|
168
|
+
* Finds the app-key credential inside a wallet response VP, or `null` when the
|
|
169
|
+
* wallet returned none (the wallet-unsupported signal).
|
|
172
170
|
*
|
|
173
|
-
* Matched on the
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
171
|
+
* Matched on the `credentialSubject.appUrl` claim ALONE: per the App Connect
|
|
172
|
+
* spec's response-verification step 3, the `AppKeyCredential` marker type must
|
|
173
|
+
* NOT be required here. Requiring it would make "the wallet returned a
|
|
174
|
+
* credential that is wrong" indistinguishable from "the wallet returned
|
|
175
|
+
* nothing" -- a returned credential missing the marker must surface as a parse
|
|
176
|
+
* error from {@link parseSeedCredential}, not as a `null` a caller would read
|
|
177
|
+
* as first run and answer by silently minting a second key.
|
|
177
178
|
*
|
|
178
179
|
* @param options {object}
|
|
179
180
|
* @param options.presentation {IVerifiablePresentation}
|
|
180
|
-
* @param options.
|
|
181
|
+
* @param options.appUrl {string} the serialized `appUrl` this request sent
|
|
181
182
|
* @returns {IVerifiableCredential | null}
|
|
182
183
|
*/
|
|
183
|
-
export function findSeedCredential({ presentation,
|
|
184
|
+
export function findSeedCredential({ presentation, appUrl }) {
|
|
184
185
|
const embedded = presentation
|
|
185
186
|
.verifiableCredential;
|
|
186
187
|
for (const entry of asArray(embedded)) {
|
|
187
|
-
const
|
|
188
|
-
|
|
188
|
+
const subject = entry
|
|
189
|
+
.credentialSubject;
|
|
190
|
+
if (subject?.appUrl === appUrl) {
|
|
189
191
|
return entry;
|
|
190
192
|
}
|
|
191
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seedCredential.js","sourceRoot":"","sources":["../../src/identity/seedCredential.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"seedCredential.js","sourceRoot":"","sources":["../../src/identity/seedCredential.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAKjE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,cAAc,EAAuB,MAAM,aAAa,CAAA;AAGjE,MAAM,gBAAgB,GAAG,wCAAwC,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAEzD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAsB,MAAM,CAAC,MAAM,CAAC;IACjE,sBAAsB;IACtB,uBAAuB;CACxB,CAAC,CAAA;AAgBF;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,OAAO,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACrC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SACX,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,iDAAiD,IAAI,CAAC,MAAM,IAAI,CACjE,CAAA;IACH,CAAC;IACD,yEAAyE;IACzE,wDAAwD;IACxD,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,IAAI,QAAQ,CAAC,aAAa,KAAK,OAAO,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAA;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAA;AAClE,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,YAAY,EACZ,MAAM,EAIP;IACC,MAAM,QAAQ,GAAI,YAAmD;SAClE,oBAAoB,CAAA;IACvB,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtC,MAAM,OAAO,GAAI,KAAsD;aACpE,iBAAiB,CAAA;QACpB,IAAI,OAAO,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;YAC/B,OAAO,KAA8B,CAAA;QACvC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,16 +15,16 @@ export { parseInvocationTarget, parseGrants, type ParsedGrants } from './grants.
|
|
|
15
15
|
export { deriveIdentity, DEFAULT_IDENTITY_HANDLE, type IdentityAgents } from './identity/agents.js';
|
|
16
16
|
export { createDocumentLoader, type DocumentLoader } from './identity/documentLoader.js';
|
|
17
17
|
export { createSeedStore, createDescriptorCache, type SeedStore } from './identity/seedStore.js';
|
|
18
|
-
export { APP_KEY_CREDENTIAL_TYPE, issueSeedCredential, parseSeedCredential, findSeedCredential, bytesToBase64url, base64urlToBytes, type
|
|
18
|
+
export { APP_KEY_CREDENTIAL_TYPE, APP_KEY_TYPE_ARRAY, issueSeedCredential, parseSeedCredential, findSeedCredential, bytesToBase64url, base64urlToBytes, type ParsedSeedCredential } from './identity/seedCredential.js';
|
|
19
19
|
export { persistAppSession, restoreAppSession, clearAppSession, isExpired, isNearExpiry, earliestExpiry, type AppSessionRecord, type RestoredAppSession } from './identity/appSession.js';
|
|
20
20
|
export { DEFAULT_MEDIATOR_BASE, loadChapi, chapiGet } from './auth/chapi.js';
|
|
21
|
-
export { RW_ACTIONS,
|
|
21
|
+
export { RW_ACTIONS, SHARED_ACTIONS, actionCeiling, newChallenge, buildAppConnectVpr, type GrantRequestCollection } from './auth/loginRequest.js';
|
|
22
22
|
export { verifyLoginPresentation, grantsOf, checkGrants, type CheckedGrants } from './auth/verifyResponse.js';
|
|
23
23
|
export { loginWithWallet, requestGrants, LoginCancelledError, WalletUnsupportedError, type LoginConfig, type LoginPhase, type LoginOutcome } from './auth/loginFlow.js';
|
|
24
24
|
export type { IVPRDetails, IVPRQuery, IDIDAuthenticationQuery, IAppConnectQuery, IAppConnectCapabilityQuery, ICapabilityQueryDetail, IVerifiableCredential, IVerifiablePresentation, IZcap } from './auth/walletRequestTypes.js';
|
|
25
25
|
export * from './sync/index.js';
|
|
26
26
|
export { LocalStore } from './storage/localStore.js';
|
|
27
|
-
export { setLocalStore, requireStore, hasStore, clearLocalStore, setRemoteStore, requireRemoteStore, hasRemoteStore, clearRemoteStore,
|
|
27
|
+
export { setLocalStore, requireStore, hasStore, clearLocalStore, setRemoteStore, requireRemoteStore, hasRemoteStore, clearRemoteStore, getWriterId } from './storage/storageManager.js';
|
|
28
28
|
export { createEntityStore, type EntityStore } from './storage/entityStore.js';
|
|
29
29
|
export { WasRemoteStore, remoteDescriptorSource, type DeclarationResult, type EqualityQueryPage } from './storage/wasRemoteStore.js';
|
|
30
30
|
export { SharedCollectionReader, SharedCollectionUnavailableError, SHARED_CHANGES_PAGE_SIZE, type SharedResource } from './storage/sharedCollectionReader.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AAGH,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EACnB,MAAM,aAAa,CAAA;AAGpB,OAAO,EACL,qBAAqB,EACrB,WAAW,EACX,KAAK,YAAY,EAClB,MAAM,aAAa,CAAA;AAIpB,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,KAAK,SAAS,EACf,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AAGH,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,K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BAAsB,EACtB,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -19,11 +19,11 @@ export { parseInvocationTarget, parseGrants } from './grants.js';
|
|
|
19
19
|
export { deriveIdentity, DEFAULT_IDENTITY_HANDLE } from './identity/agents.js';
|
|
20
20
|
export { createDocumentLoader } from './identity/documentLoader.js';
|
|
21
21
|
export { createSeedStore, createDescriptorCache } from './identity/seedStore.js';
|
|
22
|
-
export { APP_KEY_CREDENTIAL_TYPE, issueSeedCredential, parseSeedCredential, findSeedCredential, bytesToBase64url, base64urlToBytes } from './identity/seedCredential.js';
|
|
22
|
+
export { APP_KEY_CREDENTIAL_TYPE, APP_KEY_TYPE_ARRAY, issueSeedCredential, parseSeedCredential, findSeedCredential, bytesToBase64url, base64urlToBytes } from './identity/seedCredential.js';
|
|
23
23
|
export { persistAppSession, restoreAppSession, clearAppSession, isExpired, isNearExpiry, earliestExpiry } from './identity/appSession.js';
|
|
24
24
|
// Auth: CHAPI bridge, VPR construction, response verification, login flow.
|
|
25
25
|
export { DEFAULT_MEDIATOR_BASE, loadChapi, chapiGet } from './auth/chapi.js';
|
|
26
|
-
export { RW_ACTIONS,
|
|
26
|
+
export { RW_ACTIONS, SHARED_ACTIONS, actionCeiling, newChallenge, buildAppConnectVpr } from './auth/loginRequest.js';
|
|
27
27
|
export { verifyLoginPresentation, grantsOf, checkGrants } from './auth/verifyResponse.js';
|
|
28
28
|
export { loginWithWallet, requestGrants, LoginCancelledError, WalletUnsupportedError } from './auth/loginFlow.js';
|
|
29
29
|
// The collection-agnostic RxDB-WAS replication core.
|
|
@@ -32,7 +32,7 @@ export * from './sync/index.js';
|
|
|
32
32
|
// stores, the delegated remote store, sync status, rehydrate mechanism, and the
|
|
33
33
|
// replication controller.
|
|
34
34
|
export { LocalStore } from './storage/localStore.js';
|
|
35
|
-
export { setLocalStore, requireStore, hasStore, clearLocalStore, setRemoteStore, requireRemoteStore, hasRemoteStore, clearRemoteStore,
|
|
35
|
+
export { setLocalStore, requireStore, hasStore, clearLocalStore, setRemoteStore, requireRemoteStore, hasRemoteStore, clearRemoteStore, getWriterId } from './storage/storageManager.js';
|
|
36
36
|
export { createEntityStore } from './storage/entityStore.js';
|
|
37
37
|
export { WasRemoteStore, remoteDescriptorSource } from './storage/wasRemoteStore.js';
|
|
38
38
|
export { SharedCollectionReader, SharedCollectionUnavailableError, SHARED_CHANGES_PAGE_SIZE } from './storage/sharedCollectionReader.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AAEH,0BAA0B;AAC1B,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EAQ1B,MAAM,aAAa,CAAA;AAEpB,oCAAoC;AACpC,OAAO,EACL,qBAAqB,EACrB,WAAW,EAEZ,MAAM,aAAa,CAAA;AAEpB,8EAA8E;AAC9E,2CAA2C;AAC3C,OAAO,EACL,cAAc,EACd,uBAAuB,EAExB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,oBAAoB,EAErB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,eAAe,EACf,qBAAqB,EAEtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AAEH,0BAA0B;AAC1B,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,yB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EAAE,iBAAiB,EAAoB,MAAM,0BAA0B,CAAA;AAC9E,OAAO,EACL,cAAc,EACd,sBAAsB,EAGvB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,wBAAwB,EAEzB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAEjB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EACL,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AACzE,OAAO,EAAE,YAAY,EAAyB,MAAM,sBAAsB,CAAA;AAE1E,8EAA8E;AAC9E,OAAO,EACL,eAAe,EAIhB,MAAM,oBAAoB,CAAA;AAE3B,uCAAuC;AACvC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,aAAa,EAEb,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EAEvB,MAAM,kBAAkB,CAAA"}
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* The facade is a degenerate entity store: one collection (the app-named
|
|
14
14
|
* sandbox collection) holding one logical document under a fixed id. The
|
|
15
|
-
* stored row wraps the app's data (`{ id, updatedAt,
|
|
15
|
+
* stored row wraps the app's data (`{ id, updatedAt, writerId, data }`) so app
|
|
16
16
|
* fields can never collide with the LWW fields the sync layer requires, and
|
|
17
|
-
* the facade stamps `updatedAt`/`
|
|
17
|
+
* the facade stamps `updatedAt`/`writerId` on every write itself. Hydration
|
|
18
18
|
* goes through `LocalStore.hydrateSingleton`, which LWW-reconciles the
|
|
19
19
|
* duplicate envelope rows two devices can mint for the same logical document.
|
|
20
20
|
*
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
* outgrown one document should move to `createEntityStore`.
|
|
29
29
|
*/
|
|
30
30
|
import type { StoreRegistry, WasAppConfig, WasExpiryConfig, WasSyncConfig } from '../config.js';
|
|
31
|
-
import type { SeedCredentialConfig } from '../identity/seedCredential.js';
|
|
32
31
|
import type { SessionStatus } from '../session/authStore.js';
|
|
33
32
|
import type { SyncRollup } from '../storage/syncStatusStore.js';
|
|
34
33
|
/**
|
|
@@ -121,25 +120,26 @@ export interface DocumentApp<T extends object> {
|
|
|
121
120
|
* @param options {object}
|
|
122
121
|
* @param options.appName {string} human-readable name (consent reason lines)
|
|
123
122
|
* @param options.appOrigin {string} this app's own web origin
|
|
123
|
+
* @param options.appUrl {string} this app's canonical URL (absolute,
|
|
124
|
+
* fragment-less, same-origin with `appOrigin`)
|
|
124
125
|
* @param [options.mediatorBase] {string} CHAPI mediator base URL
|
|
125
126
|
* @param options.document {object} `collectionId` (the WAS sandbox
|
|
126
127
|
* collection id) and `initial` (the document value before the first write)
|
|
127
|
-
* @param options.credential {SeedCredentialConfig} seed-credential naming
|
|
128
128
|
* @param [options.dbName] {string} local database base name
|
|
129
129
|
* @param [options.storageKeyPrefix] {string} localStorage key prefix
|
|
130
130
|
* @param [options.sync] {WasSyncConfig} replication tuning
|
|
131
131
|
* @param [options.expiry] {WasExpiryConfig} near-expiry warning tuning
|
|
132
132
|
* @returns {DocumentApp<T>}
|
|
133
133
|
*/
|
|
134
|
-
export declare function defineDocumentApp<T extends object>({ appName, appOrigin, mediatorBase, document,
|
|
134
|
+
export declare function defineDocumentApp<T extends object>({ appName, appOrigin, appUrl, mediatorBase, document, dbName, storageKeyPrefix, sync, expiry }: {
|
|
135
135
|
appName: string;
|
|
136
136
|
appOrigin: string;
|
|
137
|
+
appUrl: string;
|
|
137
138
|
mediatorBase?: string;
|
|
138
139
|
document: {
|
|
139
140
|
collectionId: string;
|
|
140
141
|
initial: T;
|
|
141
142
|
};
|
|
142
|
-
credential: SeedCredentialConfig;
|
|
143
143
|
dbName?: string;
|
|
144
144
|
storageKeyPrefix?: string;
|
|
145
145
|
sync?: WasSyncConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentApp.d.ts","sourceRoot":"","sources":["../../src/react/documentApp.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACd,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"documentApp.d.ts","sourceRoot":"","sources":["../../src/react/documentApp.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACd,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAG5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAG/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,aAAa,CAAA;AAOjD;;GAEG;AACH,eAAO,MAAM,sBAAsB,oBAAoB,CAAA;AAavD;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,MAAM;IAC3C;;;OAGG;IACH,MAAM,EAAE,YAAY,CAAA;IACpB;;OAEG;IACH,QAAQ,EAAE,aAAa,CAAA;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM;QACpB;;;WAGG;QACH,GAAG,EAAE,CAAC,GAAG,SAAS,CAAA;QAClB;;;;;WAKG;QACH,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,OAAO,CA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