@learncard/partner-connect 0.5.2 → 0.6.1
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 +395 -83
- package/dist/index.d.ts +257 -25
- package/dist/partner-connect.esm.js +3294 -431
- package/dist/partner-connect.esm.js.map +1 -1
- package/dist/partner-connect.js +3295 -430
- package/dist/partner-connect.js.map +1 -1
- package/dist/partner-connect.mjs +3294 -431
- package/dist/partner-connect.mjs.map +1 -1
- package/package.json +3 -2
- package/src/docs-snippets.test.ts +79 -0
- package/src/index.ts +496 -33
- package/src/mock-host.ts +2447 -523
- package/src/mock-mode.test.ts +1337 -7
- package/src/origin-resolution.test.ts +229 -0
- package/src/types.ts +130 -11
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { InlineTemplateValidationError, CapturedAppManifest, InlineCredentialTemplate, ConsentRequest } from '@learncard/partner-connect-core';
|
|
2
|
+
export { CapturedAppManifest, CapturedConsentRecord, CapturedTemplateRecord, CompiledInlineTemplate, ConsentRequest, InlineCredentialTemplate, InlineTemplateValidationError, PersonalField, RawInlineCredentialTemplate, SimpleInlineCredentialTemplate, VariableManifest, WalletCategory, decodeManifestFromUrl } from '@learncard/partner-connect-core';
|
|
3
|
+
import { SendCredentialEvent as SendCredentialEvent$1, AppEvent as AppEvent$1, AppEventResponse as AppEventResponse$1 } from '@learncard/types';
|
|
4
|
+
export { CheckCredentialEvent } from '@learncard/types';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* LearnCard Partner Connect SDK - Type Definitions
|
|
6
8
|
*/
|
|
7
9
|
|
|
10
|
+
interface PreviewCompiledTemplateResult {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
errors: InlineTemplateValidationError[];
|
|
13
|
+
compiled?: Record<string, unknown>;
|
|
14
|
+
rendered?: Record<string, unknown>;
|
|
15
|
+
}
|
|
8
16
|
/**
|
|
9
17
|
* Configuration options for initializing the SDK
|
|
10
18
|
*/
|
|
@@ -102,15 +110,17 @@ interface PartnerConnectOptions {
|
|
|
102
110
|
* identically (real host) once embedded, with no code changes.
|
|
103
111
|
*
|
|
104
112
|
* - `'auto'` **(default)**: mock only when **no LearnCard host is present
|
|
105
|
-
* AND the app is running
|
|
106
|
-
* `
|
|
107
|
-
*
|
|
108
|
-
*
|
|
113
|
+
* AND the app is running in local dev** (`localhost`, `127.0.0.1`,
|
|
114
|
+
* `[::1]`, `*.localhost`, `*.local`) **or an AI app builder's editor
|
|
115
|
+
* preview** (Lovable, Bolt, v0, Replit). This covers local dev, local
|
|
116
|
+
* Storybook, and building in those tools, but deliberately never
|
|
117
|
+
* fabricates identity or consent on a published or deploy-preview
|
|
118
|
+
* origin. Each mocked call
|
|
109
119
|
* surfaces a labeled toast plus a console log so it's clear the host
|
|
110
120
|
* is simulated.
|
|
111
121
|
* - `'standalone'`: mock whenever **no LearnCard host is present**, on
|
|
112
|
-
* any origin — including remote deploy previews (Netlify,
|
|
113
|
-
*
|
|
122
|
+
* any origin — including remote deploy previews (Netlify, Vercel, …)
|
|
123
|
+
* — and use the real host when embedded in LearnCard. The
|
|
114
124
|
* one-flag setting for apps that must demo standalone anywhere. Only
|
|
115
125
|
* choose it when a user opening your app's URL directly should see
|
|
116
126
|
* simulated data.
|
|
@@ -170,6 +180,19 @@ interface MockHostOptions {
|
|
|
170
180
|
* @default true
|
|
171
181
|
*/
|
|
172
182
|
persist?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Show the mock-mode "Publish to LearnCard" nudge once the captured app
|
|
185
|
+
* manifest becomes publishable.
|
|
186
|
+
*
|
|
187
|
+
* @default true
|
|
188
|
+
*/
|
|
189
|
+
publishPrompt?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* LearnCard origin used to build the App Store submission URL.
|
|
192
|
+
*
|
|
193
|
+
* @default 'https://learncard.app'
|
|
194
|
+
*/
|
|
195
|
+
publishOrigin?: string;
|
|
173
196
|
/**
|
|
174
197
|
* The fake DID returned by `requestIdentity()` (and used as the mock
|
|
175
198
|
* user's identity) while in mock mode.
|
|
@@ -185,6 +208,12 @@ interface MockHostOptions {
|
|
|
185
208
|
* @default 'lc-mock'
|
|
186
209
|
*/
|
|
187
210
|
namespace?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Distinguishes your app from other apps served on the same origin
|
|
213
|
+
* (e.g. multiple projects on localhost:4321). Defaults to a fingerprint
|
|
214
|
+
* of the initial document.title.
|
|
215
|
+
*/
|
|
216
|
+
appId?: string;
|
|
188
217
|
/**
|
|
189
218
|
* Seed the mock user's identity. Superseded per-field over the legacy
|
|
190
219
|
* `did` option. Extra fields are returned as-is from `requestIdentity()`.
|
|
@@ -232,6 +261,15 @@ interface MockCredentialSeed {
|
|
|
232
261
|
/** Claim status. @default 'claimed' */
|
|
233
262
|
status?: 'pending' | 'claimed' | 'revoked';
|
|
234
263
|
}
|
|
264
|
+
/** Public manifest snapshot getter, available only while mock mode is active. */
|
|
265
|
+
interface CapturedManifestReadable {
|
|
266
|
+
getCapturedManifest(): CapturedAppManifest | undefined;
|
|
267
|
+
getPublishUrl(): string | undefined;
|
|
268
|
+
/** Start fresh for the current practice app; no-op outside mock mode. */
|
|
269
|
+
resetPracticeMode(): void;
|
|
270
|
+
getActiveHostOrigin(): string | null;
|
|
271
|
+
getPublishOrigin(): string | null;
|
|
272
|
+
}
|
|
235
273
|
/**
|
|
236
274
|
* Identity information returned from REQUEST_IDENTITY
|
|
237
275
|
*/
|
|
@@ -263,6 +301,50 @@ interface TemplateCredentialInput {
|
|
|
263
301
|
*/
|
|
264
302
|
preventDuplicateClaim?: boolean;
|
|
265
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Inline credential template input for sendCredential.
|
|
306
|
+
*
|
|
307
|
+
* This sends the full template definition to LearnCard at runtime, with no
|
|
308
|
+
* pre-configured host template required.
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* await learnCard.sendCredential({
|
|
313
|
+
* alias: 'course-complete',
|
|
314
|
+
* template: {
|
|
315
|
+
* name: 'Completed {{courseName}}',
|
|
316
|
+
* description: 'Awarded for finishing {{courseName}}.',
|
|
317
|
+
* achievementType: 'Course',
|
|
318
|
+
* criteria: { narrative: 'Finished all modules' }
|
|
319
|
+
* },
|
|
320
|
+
* templateData: { courseName: 'Intro to Baking' }
|
|
321
|
+
* });
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
interface InlineTemplateCredentialInput {
|
|
325
|
+
/** App-scoped alias used for duplicate checks and inline template versioning. */
|
|
326
|
+
alias: string;
|
|
327
|
+
/** Inline credential template definition compiled by LearnCard at issuance time. */
|
|
328
|
+
template: InlineCredentialTemplate;
|
|
329
|
+
/** Runtime values for the template variables. */
|
|
330
|
+
templateData?: Record<string, unknown>;
|
|
331
|
+
/**
|
|
332
|
+
* If true, the host will return an existing credential (if present) instead of issuing a duplicate.
|
|
333
|
+
*/
|
|
334
|
+
preventDuplicateClaim?: boolean;
|
|
335
|
+
}
|
|
336
|
+
/** Inline `send-credential` app event for zero-config issuance. */
|
|
337
|
+
interface InlineTemplateSendCredentialEvent {
|
|
338
|
+
type: 'send-credential';
|
|
339
|
+
alias: string;
|
|
340
|
+
template: InlineCredentialTemplate;
|
|
341
|
+
templateData?: Record<string, unknown>;
|
|
342
|
+
preventDuplicateClaim?: boolean;
|
|
343
|
+
}
|
|
344
|
+
type SendCredentialEvent = SendCredentialEvent$1 | InlineTemplateSendCredentialEvent;
|
|
345
|
+
type AppEvent = AppEvent$1 | InlineTemplateSendCredentialEvent;
|
|
346
|
+
type AppEventResponse = AppEventResponse$1;
|
|
347
|
+
type SendCredentialInput = unknown | TemplateCredentialInput | InlineTemplateCredentialInput;
|
|
266
348
|
/**
|
|
267
349
|
* Response from template-based credential issuance
|
|
268
350
|
*/
|
|
@@ -279,6 +361,8 @@ interface TemplateCredentialResponse {
|
|
|
279
361
|
status?: 'pending' | 'claimed' | 'revoked';
|
|
280
362
|
/** The date the credential was received (when preventDuplicateClaim is true) */
|
|
281
363
|
receivedDate?: string;
|
|
364
|
+
/** Version number for inline templates sharing the same alias. */
|
|
365
|
+
templateVersion?: number;
|
|
282
366
|
[key: string]: unknown;
|
|
283
367
|
}
|
|
284
368
|
/**
|
|
@@ -336,6 +420,7 @@ interface RequestConsentPayload {
|
|
|
336
420
|
* to use the contract configured for the current app listing.
|
|
337
421
|
*/
|
|
338
422
|
contractUri?: string;
|
|
423
|
+
scopes?: ConsentRequest;
|
|
339
424
|
redirect?: boolean;
|
|
340
425
|
}
|
|
341
426
|
/**
|
|
@@ -639,7 +724,7 @@ interface GetCountersResponse {
|
|
|
639
724
|
/**
|
|
640
725
|
* Error codes that can be returned by the LearnCard host
|
|
641
726
|
*/
|
|
642
|
-
type ErrorCode = 'LC_TIMEOUT' | 'LC_NOT_EMBEDDED' | 'LC_UNAUTHENTICATED' | 'CREDENTIAL_NOT_FOUND' | 'USER_REJECTED' | 'UNAUTHORIZED' | 'TEMPLATE_NOT_FOUND' | 'BOOST_NOT_FOUND' | 'INSUFFICIENT_PERMISSIONS' | string;
|
|
727
|
+
type ErrorCode = 'LC_TIMEOUT' | 'LC_NOT_EMBEDDED' | 'LC_UNAUTHENTICATED' | 'CREDENTIAL_NOT_FOUND' | 'USER_REJECTED' | 'UNAUTHORIZED' | 'TEMPLATE_INVALID' | 'TEMPLATE_DATA_INVALID' | 'TEMPLATE_NOT_FOUND' | 'BOOST_NOT_FOUND' | 'INSUFFICIENT_PERMISSIONS' | string;
|
|
643
728
|
/**
|
|
644
729
|
* Error object returned when a request fails.
|
|
645
730
|
*
|
|
@@ -738,6 +823,14 @@ interface PendingRequest {
|
|
|
738
823
|
* ```
|
|
739
824
|
*/
|
|
740
825
|
|
|
826
|
+
/**
|
|
827
|
+
* Compile and optionally render an inline credential template entirely offline.
|
|
828
|
+
*
|
|
829
|
+
* `compiled` contains the canonical OBv3 credential object with `{{variables}}`
|
|
830
|
+
* preserved. If `templateData` is provided and valid, `rendered` contains the
|
|
831
|
+
* same object with those variables substituted.
|
|
832
|
+
*/
|
|
833
|
+
declare const previewCompiledTemplate: (template: InlineCredentialTemplate, templateData?: Record<string, unknown>) => PreviewCompiledTemplateResult;
|
|
741
834
|
/**
|
|
742
835
|
* Detect whether the current page is running inside an embedded iframe.
|
|
743
836
|
*
|
|
@@ -790,6 +883,14 @@ declare class PartnerConnect {
|
|
|
790
883
|
private syncCompleteCallbacks;
|
|
791
884
|
private syncStatusPollId;
|
|
792
885
|
private mockHost;
|
|
886
|
+
/** Internal, non-public context handed to every {@link MockHost} we build. */
|
|
887
|
+
private mockHostContext;
|
|
888
|
+
/**
|
|
889
|
+
* Memoized override-derived publish origin. `undefined` means "not looked
|
|
890
|
+
* up yet"; `null` means "looked up, no usable override". Caching keeps the
|
|
891
|
+
* warning for an invalid value to a single log per instance.
|
|
892
|
+
*/
|
|
893
|
+
private pinnedPublishOrigin;
|
|
793
894
|
private embedded;
|
|
794
895
|
private warnedNoHost;
|
|
795
896
|
private hostProbeTimeout;
|
|
@@ -798,6 +899,31 @@ declare class PartnerConnect {
|
|
|
798
899
|
/** Pending probe decision; requests queue behind it when set. */
|
|
799
900
|
private activation;
|
|
800
901
|
constructor(options?: PartnerConnectOptions);
|
|
902
|
+
private resolveMockOptions;
|
|
903
|
+
/**
|
|
904
|
+
* Resolve the LearnCard origin that App Store publish links point at:
|
|
905
|
+
* 1. `?lc_publish_override=` (query param, then this tab's stored value).
|
|
906
|
+
* 2. `?lc_host_override=` (query param, then stored) when it names one
|
|
907
|
+
* concrete http(s) origin — testing against a host implies publishing
|
|
908
|
+
* to it.
|
|
909
|
+
* 3. The first concrete configured `hostOrigin`.
|
|
910
|
+
* 4. `DEFAULT_PUBLISH_ORIGIN`.
|
|
911
|
+
*
|
|
912
|
+
* `mockOptions.publishOrigin` outranks all of these and is applied by
|
|
913
|
+
* {@link resolveMockOptions} before this runs.
|
|
914
|
+
*/
|
|
915
|
+
private resolvePublishOrigin;
|
|
916
|
+
private readPinnedPublishOrigin;
|
|
917
|
+
/**
|
|
918
|
+
* Unlike `lc_host_override`, this is not a security boundary — it only
|
|
919
|
+
* decides which LearnCard origin publish links target — so any parseable
|
|
920
|
+
* http(s) origin is accepted rather than being whitelist-checked.
|
|
921
|
+
*/
|
|
922
|
+
private readPublishOverride;
|
|
923
|
+
private readHostOverrideForPublish;
|
|
924
|
+
private static normalizePublishOrigin;
|
|
925
|
+
private static readSessionValue;
|
|
926
|
+
private inferPublishOrigin;
|
|
801
927
|
/**
|
|
802
928
|
* Decide whether this instance talks to a real host, simulates one, or
|
|
803
929
|
* fails fast — the resolution of the `mock` option against the runtime
|
|
@@ -805,6 +931,14 @@ declare class PartnerConnect {
|
|
|
805
931
|
*/
|
|
806
932
|
private configureMockActivation;
|
|
807
933
|
private isLocalDevContext;
|
|
934
|
+
/**
|
|
935
|
+
* Whether the app is running inside an AI app builder's preview (Lovable,
|
|
936
|
+
* Bolt, v0, Replit): either on a preview-only host, or framed by the
|
|
937
|
+
* builder's editor. Firefox hides ancestor origins, so the referrer of an
|
|
938
|
+
* embedded document stands in for the parent origin there.
|
|
939
|
+
*/
|
|
940
|
+
private isAppBuilderContext;
|
|
941
|
+
private readReferrerOrigin;
|
|
808
942
|
private classifyParent;
|
|
809
943
|
private matchesConfiguredOrigin;
|
|
810
944
|
/**
|
|
@@ -830,6 +964,53 @@ declare class PartnerConnect {
|
|
|
830
964
|
* instead of talking to a real host over `postMessage`.
|
|
831
965
|
*/
|
|
832
966
|
isMocked(): boolean;
|
|
967
|
+
/**
|
|
968
|
+
* Read the app manifest captured by standalone mock mode.
|
|
969
|
+
*
|
|
970
|
+
* Returns `undefined` when this instance is talking to a real host, or when
|
|
971
|
+
* mock mode has not captured anything yet.
|
|
972
|
+
*
|
|
973
|
+
* @example
|
|
974
|
+
* ```typescript
|
|
975
|
+
* const manifest = learnCard.getCapturedManifest();
|
|
976
|
+
* if (manifest) {
|
|
977
|
+
* console.log(manifest.permissions, manifest.templates);
|
|
978
|
+
* }
|
|
979
|
+
* ```
|
|
980
|
+
*/
|
|
981
|
+
getCapturedManifest(): CapturedAppManifest | undefined;
|
|
982
|
+
/**
|
|
983
|
+
* Build the LearnCard App Store submission URL for the current captured manifest.
|
|
984
|
+
*
|
|
985
|
+
* Returns `undefined` unless mock mode is active and the SDK has captured at
|
|
986
|
+
* least one manifest interaction. The publish prompt still uses a higher
|
|
987
|
+
* threshold (at least 1 inline template or at least 2 distinct permissions)
|
|
988
|
+
* before it auto-nudges the developer.
|
|
989
|
+
*
|
|
990
|
+
* @example
|
|
991
|
+
* ```typescript
|
|
992
|
+
* const publishUrl = learnCard.getPublishUrl();
|
|
993
|
+
* if (publishUrl) {
|
|
994
|
+
* window.open(publishUrl, '_blank', 'noopener');
|
|
995
|
+
* }
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
getPublishUrl(): string | undefined;
|
|
999
|
+
/** Clears this app's practice captures, credentials and counters. No-op outside mock mode. */
|
|
1000
|
+
resetPracticeMode(): void;
|
|
1001
|
+
/**
|
|
1002
|
+
* Returns the currently active real-host origin, or `null` while standalone
|
|
1003
|
+
* mock mode is active.
|
|
1004
|
+
*/
|
|
1005
|
+
getActiveHostOrigin(): string | null;
|
|
1006
|
+
/**
|
|
1007
|
+
* Returns the LearnCard origin used to build App Store publish URLs.
|
|
1008
|
+
*
|
|
1009
|
+
* Point this at a local or staging LearnCard with
|
|
1010
|
+
* `?lc_publish_override=<origin>`; see {@link resolvePublishOrigin} for
|
|
1011
|
+
* the full precedence order.
|
|
1012
|
+
*/
|
|
1013
|
+
getPublishOrigin(): string | null;
|
|
833
1014
|
/**
|
|
834
1015
|
* Configure the active host origin using the following hierarchy:
|
|
835
1016
|
* 1. `window.location.ancestorOrigins[0]` (when supported) — the browser's
|
|
@@ -845,6 +1026,8 @@ declare class PartnerConnect {
|
|
|
845
1026
|
* continue to use the same active origin.
|
|
846
1027
|
*/
|
|
847
1028
|
private static readonly SESSION_STORAGE_KEY;
|
|
1029
|
+
/** Persisted so the parameter only has to be typed once per tab. */
|
|
1030
|
+
private static readonly PUBLISH_SESSION_STORAGE_KEY;
|
|
848
1031
|
/**
|
|
849
1032
|
* Read `window.location.ancestorOrigins[0]` without throwing if the
|
|
850
1033
|
* property is unavailable (Firefox) or the list is empty (top-level
|
|
@@ -853,6 +1036,7 @@ declare class PartnerConnect {
|
|
|
853
1036
|
private readAncestorOrigin;
|
|
854
1037
|
private configureActiveOrigin;
|
|
855
1038
|
private persistOverride;
|
|
1039
|
+
private persistPublishOverride;
|
|
856
1040
|
private isOriginNativeApp;
|
|
857
1041
|
/**
|
|
858
1042
|
* Internal placeholder substituted in for `*` so that `new URL(...)` can
|
|
@@ -928,12 +1112,48 @@ declare class PartnerConnect {
|
|
|
928
1112
|
* ```
|
|
929
1113
|
*/
|
|
930
1114
|
requestIdentity(): Promise<IdentityResponse>;
|
|
1115
|
+
/**
|
|
1116
|
+
* Validate an inline credential template entirely offline.
|
|
1117
|
+
*
|
|
1118
|
+
* This performs the same local checks that {@link sendCredential} runs for
|
|
1119
|
+
* inline templates before posting any message to LearnCard.
|
|
1120
|
+
*
|
|
1121
|
+
* @param template - Inline credential template to validate
|
|
1122
|
+
* @param templateData - Optional runtime variable values to validate against the compiled manifest
|
|
1123
|
+
* @returns Validation status plus path-based errors suitable for UI display
|
|
1124
|
+
*
|
|
1125
|
+
* @example
|
|
1126
|
+
* ```typescript
|
|
1127
|
+
* const result = learnCard.validateCredentialTemplate(
|
|
1128
|
+
* {
|
|
1129
|
+
* name: 'Completed {{courseName}}',
|
|
1130
|
+
* description: 'Awarded for finishing {{courseName}}.',
|
|
1131
|
+
* achievementType: 'Course',
|
|
1132
|
+
* criteria: { narrative: 'Finished all modules' }
|
|
1133
|
+
* },
|
|
1134
|
+
* { courseName: 'Intro to Baking' }
|
|
1135
|
+
* );
|
|
1136
|
+
*
|
|
1137
|
+
* if (!result.valid) {
|
|
1138
|
+
* console.error(result.errors.map(error => `${error.path}: ${error.message}`).join('\n'));
|
|
1139
|
+
* }
|
|
1140
|
+
* ```
|
|
1141
|
+
*/
|
|
1142
|
+
validateCredentialTemplate(template: InlineCredentialTemplate, templateData?: Record<string, unknown>): {
|
|
1143
|
+
valid: boolean;
|
|
1144
|
+
errors: InlineTemplateValidationError[];
|
|
1145
|
+
};
|
|
1146
|
+
/**
|
|
1147
|
+
* Compile and optionally render an inline credential template entirely offline.
|
|
1148
|
+
*/
|
|
1149
|
+
previewCompiledTemplate(template: InlineCredentialTemplate, templateData?: Record<string, unknown>): PreviewCompiledTemplateResult;
|
|
931
1150
|
/**
|
|
932
1151
|
* Send a credential to the user's LearnCard wallet
|
|
933
1152
|
*
|
|
934
1153
|
* Supports two modes:
|
|
935
1154
|
* 1. **Raw credential**: Pass a full verifiable credential object
|
|
936
1155
|
* 2. **Template-based**: Pass `{ templateAlias, templateData }` to issue from a pre-configured boost template
|
|
1156
|
+
* 3. **Inline template**: Pass `{ alias, template, templateData }` to issue from a zero-config inline template
|
|
937
1157
|
*
|
|
938
1158
|
* @param input - Either a verifiable credential or a template-based input
|
|
939
1159
|
* @returns Promise resolving to credential response
|
|
@@ -956,8 +1176,22 @@ declare class PartnerConnect {
|
|
|
956
1176
|
* });
|
|
957
1177
|
* console.log('Credential URI:', response.credentialUri);
|
|
958
1178
|
* ```
|
|
1179
|
+
*
|
|
1180
|
+
* @example Inline template (zero-config)
|
|
1181
|
+
* ```typescript
|
|
1182
|
+
* await learnCard.sendCredential({
|
|
1183
|
+
* alias: 'course-complete',
|
|
1184
|
+
* template: {
|
|
1185
|
+
* name: 'Completed {{courseName}}',
|
|
1186
|
+
* description: 'Awarded for finishing {{courseName}}.',
|
|
1187
|
+
* achievementType: 'Course',
|
|
1188
|
+
* criteria: { narrative: 'Finished all modules' }
|
|
1189
|
+
* },
|
|
1190
|
+
* templateData: { courseName: 'Intro to Baking' }
|
|
1191
|
+
* });
|
|
1192
|
+
* ```
|
|
959
1193
|
*/
|
|
960
|
-
sendCredential(input:
|
|
1194
|
+
sendCredential(input: SendCredentialInput): Promise<SendCredentialResponse | TemplateCredentialResponse>;
|
|
961
1195
|
/**
|
|
962
1196
|
* Check whether the current user already has a credential from a given boost template.
|
|
963
1197
|
* This is a silent, non-interactive status check for installed app integrations.
|
|
@@ -1073,9 +1307,12 @@ declare class PartnerConnect {
|
|
|
1073
1307
|
*/
|
|
1074
1308
|
askCredentialSpecific(credentialId: string): Promise<CredentialSpecificResponse>;
|
|
1075
1309
|
/**
|
|
1076
|
-
* Request user consent for permissions
|
|
1310
|
+
* Request user consent for permissions.
|
|
1077
1311
|
*
|
|
1078
|
-
*
|
|
1312
|
+
* Pass either a pre-created consent contract URI, or a declarative consent
|
|
1313
|
+
* request and let LearnCard resolve or create the backing contract.
|
|
1314
|
+
*
|
|
1315
|
+
* @param requestOrContractUri - Consent scope request or explicit contract URI
|
|
1079
1316
|
* @param options - Additional options including redirect behavior
|
|
1080
1317
|
* @returns Promise resolving to consent response
|
|
1081
1318
|
*
|
|
@@ -1083,21 +1320,16 @@ declare class PartnerConnect {
|
|
|
1083
1320
|
* ```typescript
|
|
1084
1321
|
* // With explicit contract URI (for external/non-app store integrations)
|
|
1085
1322
|
* const response = await learnCard.requestConsent('lc:network:network.learncard.com/trpc:contract:abc123');
|
|
1086
|
-
* if (response.granted) {
|
|
1087
|
-
* console.log('User granted consent');
|
|
1088
|
-
* }
|
|
1089
1323
|
*
|
|
1090
|
-
* //
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1093
|
-
*
|
|
1094
|
-
*
|
|
1095
|
-
* }
|
|
1096
|
-
*
|
|
1097
|
-
* // With redirect - redirects to contract's redirectUrl with VP in URL params
|
|
1098
|
-
* const response = await learnCard.requestConsent(undefined, { redirect: true });
|
|
1324
|
+
* // Declarative scopes (LearnCard upserts the contract automatically)
|
|
1325
|
+
* const { granted } = await learnCard.requestConsent({
|
|
1326
|
+
* read: { credentialCategories: ['Achievement', 'Skill'], personalFields: ['name'] },
|
|
1327
|
+
* write: { credentialCategories: ['Achievement'] },
|
|
1328
|
+
* reason: 'Personalize your training plan',
|
|
1329
|
+
* });
|
|
1099
1330
|
* ```
|
|
1100
1331
|
*/
|
|
1332
|
+
requestConsent(request: ConsentRequest, options?: RequestConsentOptions): Promise<ConsentResponse>;
|
|
1101
1333
|
requestConsent(contractUri?: string, options?: RequestConsentOptions): Promise<ConsentResponse>;
|
|
1102
1334
|
/**
|
|
1103
1335
|
* Initiate a template-based credential issuance flow
|
|
@@ -1243,4 +1475,4 @@ declare class PartnerConnect {
|
|
|
1243
1475
|
*/
|
|
1244
1476
|
declare function createPartnerConnect(options?: PartnerConnectOptions): PartnerConnect;
|
|
1245
1477
|
|
|
1246
|
-
export { AppNotificationInput, AppNotificationResponse, CheckCredentialInput, CheckCredentialResponse, CheckIssuanceStatusInput, ConsentResponse, CredentialSearchResponse, CredentialSpecificResponse, ErrorCode, GetCounterResponse, GetCountersResponse, GetTemplateRecipientsInput, IdentityResponse, IncrementCounterResponse, LearnCardError, LearnerContextCacheStatus, LearnerContextRawData, LearnerContextResponse, LearnerContextTimingBreakdown, MockCredentialSeed, MockHostOptions, MockIdentitySeed, PartnerConnect, PartnerConnectError, PartnerConnectOptions, PendingRequest, PostMessageRequest, PostMessageResponse, RequestConsentOptions, RequestConsentPayload, RequestLearnerContextOptions, SendAiSessionCredentialInput, SendAiSessionCredentialResponse, SendCredentialResponse, SummaryCredentialData, SummaryCredentialKeyword, SummaryCredentialNextStep, SummaryCredentialReflection, SummaryCredentialSkill, SyncProgress, SyncStatus, TemplateCredentialInput, TemplateCredentialResponse, TemplateIssuanceStatusResponse, TemplateIssueResponse, TemplateRecipientRecord, TemplateRecipientsResponse, VPRQuery, VerifiablePresentationRequest, createPartnerConnect, createPartnerConnect as default, isEmbedded };
|
|
1478
|
+
export { AppEvent, AppEventResponse, AppNotificationInput, AppNotificationResponse, CapturedManifestReadable, CheckCredentialInput, CheckCredentialResponse, CheckIssuanceStatusInput, ConsentResponse, CredentialSearchResponse, CredentialSpecificResponse, ErrorCode, GetCounterResponse, GetCountersResponse, GetTemplateRecipientsInput, IdentityResponse, IncrementCounterResponse, InlineTemplateCredentialInput, InlineTemplateSendCredentialEvent, LearnCardError, LearnerContextCacheStatus, LearnerContextRawData, LearnerContextResponse, LearnerContextTimingBreakdown, MockCredentialSeed, MockHostOptions, MockIdentitySeed, PartnerConnect, PartnerConnectError, PartnerConnectOptions, PendingRequest, PostMessageRequest, PostMessageResponse, PreviewCompiledTemplateResult, RequestConsentOptions, RequestConsentPayload, RequestLearnerContextOptions, SendAiSessionCredentialInput, SendAiSessionCredentialResponse, SendCredentialEvent, SendCredentialInput, SendCredentialResponse, SummaryCredentialData, SummaryCredentialKeyword, SummaryCredentialNextStep, SummaryCredentialReflection, SummaryCredentialSkill, SyncProgress, SyncStatus, TemplateCredentialInput, TemplateCredentialResponse, TemplateIssuanceStatusResponse, TemplateIssueResponse, TemplateRecipientRecord, TemplateRecipientsResponse, VPRQuery, VerifiablePresentationRequest, createPartnerConnect, createPartnerConnect as default, isEmbedded, previewCompiledTemplate };
|