@learncard/init 2.4.3 → 2.4.5

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.
@@ -0,0 +1,93 @@
1
+ import { generateLearnCard } from '@learncard/core';
2
+ import { DynamicLoaderPlugin } from '@learncard/dynamic-loader-plugin';
3
+ import { CryptoPlugin } from '@learncard/crypto-plugin';
4
+ import { DidMethod, getDidKitPlugin } from '@learncard/didkit-plugin';
5
+ import { getDidKeyPlugin } from '@learncard/didkey-plugin';
6
+ import { getEncryptionPlugin } from '@learncard/encryption-plugin';
7
+ import { getVCPlugin } from '@learncard/vc-plugin';
8
+ import { getVCTemplatesPlugin } from '@learncard/vc-templates-plugin';
9
+ import { getLearnCloudPlugin } from '@learncard/learn-cloud-plugin';
10
+ import { expirationPlugin } from '@learncard/expiration-plugin';
11
+ import { getEthereumPlugin } from '@learncard/ethereum-plugin';
12
+
13
+ import { getVpqrPlugin } from '@learncard/vpqr-plugin';
14
+ import { getCHAPIPlugin } from '@learncard/chapi-plugin';
15
+ import { getLearnCardPlugin } from '@learncard/learn-card-plugin';
16
+ import { getOpenID4VCPlugin } from '@learncard/openid4vc-plugin';
17
+ import { getSdJwtVcPlugin } from '@learncard/sd-jwt-vc-plugin';
18
+
19
+ import { LearnCardFromSeed } from '../types/LearnCard';
20
+ import { defaultEthereumArgs } from '../defaults';
21
+
22
+ /**
23
+ * Generates a LearnCard Wallet from a 64 character seed string
24
+ *
25
+ * @group Init Functions
26
+ */
27
+ export const learnCardFromSeed = async ({
28
+ seed,
29
+
30
+ cloud: {
31
+ url = 'https://cloud.learncard.com/trpc',
32
+ unencryptedFields = [],
33
+ unencryptedCustomFields = [],
34
+ automaticallyAssociateDids = true,
35
+ } = {},
36
+ didkit,
37
+ allowRemoteContexts = false,
38
+ ethereumConfig = defaultEthereumArgs,
39
+ openid4vc,
40
+ debug,
41
+ }: LearnCardFromSeed['args']): Promise<LearnCardFromSeed['returnValue']> => {
42
+ const dynamicLc = await (await generateLearnCard({ debug })).addPlugin(DynamicLoaderPlugin);
43
+
44
+ const cryptoLc = await dynamicLc.addPlugin(CryptoPlugin);
45
+
46
+ const getDidkit = async (): Promise<typeof getDidKitPlugin> => {
47
+ if (didkit === 'node') {
48
+ const mod = await import('@learncard/didkit-plugin-node');
49
+ return mod.getDidKitPlugin as typeof getDidKitPlugin;
50
+ }
51
+ return getDidKitPlugin;
52
+ };
53
+
54
+ const didkitLc = await cryptoLc.addPlugin(
55
+ await (
56
+ await getDidkit()
57
+ )(didkit === 'node' ? undefined : didkit, allowRemoteContexts)
58
+ );
59
+
60
+ const didkeyLc = await didkitLc.addPlugin(
61
+ await getDidKeyPlugin<DidMethod>(didkitLc, seed, 'key')
62
+ );
63
+
64
+ const encryptionLc = await didkeyLc.addPlugin(await getEncryptionPlugin(didkeyLc));
65
+
66
+ const vcLc = await encryptionLc.addPlugin(getVCPlugin(encryptionLc));
67
+
68
+ const templateLc = await vcLc.addPlugin(getVCTemplatesPlugin());
69
+
70
+ const cloudLc = await templateLc.addPlugin(
71
+ await getLearnCloudPlugin(
72
+ templateLc,
73
+ url,
74
+ unencryptedFields,
75
+ unencryptedCustomFields,
76
+ automaticallyAssociateDids
77
+ )
78
+ );
79
+
80
+ const expirationLc = await cloudLc.addPlugin(expirationPlugin(cloudLc));
81
+
82
+ const ethLc = await expirationLc.addPlugin(getEthereumPlugin(expirationLc, ethereumConfig));
83
+
84
+ const vpqrLc = await ethLc.addPlugin(getVpqrPlugin(ethLc));
85
+
86
+ const chapiLc = await vpqrLc.addPlugin(await getCHAPIPlugin());
87
+
88
+ const sdJwtVcLc = await chapiLc.addPlugin(getSdJwtVcPlugin(chapiLc));
89
+
90
+ const lcLc = await sdJwtVcLc.addPlugin(getLearnCardPlugin(sdJwtVcLc));
91
+
92
+ return lcLc.addPlugin(getOpenID4VCPlugin(lcLc, openid4vc));
93
+ };
@@ -0,0 +1,69 @@
1
+ import { generateLearnCard } from '@learncard/core';
2
+ import { DynamicLoaderPlugin } from '@learncard/dynamic-loader-plugin';
3
+ import { CryptoPlugin } from '@learncard/crypto-plugin';
4
+ import { getDidKitPlugin } from '@learncard/didkit-plugin';
5
+ import { getVCPlugin } from '@learncard/vc-plugin';
6
+ import { getVCTemplatesPlugin } from '@learncard/vc-templates-plugin';
7
+ import { expirationPlugin } from '@learncard/expiration-plugin';
8
+ import { getVpqrPlugin } from '@learncard/vpqr-plugin';
9
+ import { getCHAPIPlugin } from '@learncard/chapi-plugin';
10
+ import { getVerifyBoostPlugin, getLearnCardNetworkPlugin } from '@learncard/network-plugin';
11
+ import { getLearnCardPlugin } from '@learncard/learn-card-plugin';
12
+
13
+ import { NetworkLearnCardFromApiKey } from '../types/LearnCard';
14
+
15
+ /**
16
+ * Generates a Network LearnCard Wallet from an API key (no local seed required)
17
+ *
18
+ * @group Init Functions
19
+ */
20
+ export const networkLearnCardFromApiKey = async ({
21
+ apiKey,
22
+ network: _network,
23
+ trustedBoostRegistry = 'https://raw.githubusercontent.com/learningeconomy/registries/main/learncard/trusted-app-registry.json',
24
+ guardianApprovalGetter,
25
+ extraHeaders,
26
+ didkit,
27
+ allowRemoteContexts = false,
28
+ debug,
29
+ }: NetworkLearnCardFromApiKey['args']): Promise<NetworkLearnCardFromApiKey['returnValue']> => {
30
+ const network = typeof _network === 'boolean' ? 'https://network.learncard.com/trpc' : _network;
31
+
32
+ const dynamicLc = await (await generateLearnCard({ debug })).addPlugin(DynamicLoaderPlugin);
33
+
34
+ const cryptoLc = await dynamicLc.addPlugin(CryptoPlugin);
35
+
36
+ const getDidkit = async (): Promise<typeof getDidKitPlugin> => {
37
+ if (didkit === 'node') {
38
+ const mod = await import('@learncard/didkit-plugin-node');
39
+ return mod.getDidKitPlugin as typeof getDidKitPlugin;
40
+ }
41
+ return getDidKitPlugin;
42
+ };
43
+
44
+ const didkitLc = await cryptoLc.addPlugin(
45
+ await (
46
+ await getDidkit()
47
+ )(didkit === 'node' ? undefined : didkit, allowRemoteContexts)
48
+ );
49
+
50
+ const vcLc = await didkitLc.addPlugin(getVCPlugin(didkitLc));
51
+
52
+ const templateLc = await vcLc.addPlugin(getVCTemplatesPlugin());
53
+
54
+ const expirationLc = await templateLc.addPlugin(expirationPlugin(templateLc));
55
+
56
+ const vpqrLc = await expirationLc.addPlugin(getVpqrPlugin(expirationLc));
57
+
58
+ const chapiLc = await vpqrLc.addPlugin(await getCHAPIPlugin());
59
+
60
+ const boostVerificationLc = await chapiLc.addPlugin(
61
+ await getVerifyBoostPlugin(chapiLc, trustedBoostRegistry)
62
+ );
63
+
64
+ const lcLc = await boostVerificationLc.addPlugin(getLearnCardPlugin(boostVerificationLc));
65
+
66
+ return lcLc.addPlugin(
67
+ await getLearnCardNetworkPlugin(lcLc, network, apiKey, { guardianApprovalGetter, extraHeaders })
68
+ );
69
+ };
@@ -0,0 +1,108 @@
1
+ import { generateLearnCard } from '@learncard/core';
2
+ import { DynamicLoaderPlugin } from '@learncard/dynamic-loader-plugin';
3
+ import { CryptoPlugin } from '@learncard/crypto-plugin';
4
+ import { DidMethod, getDidKitPlugin } from '@learncard/didkit-plugin';
5
+ import { getDidKeyPlugin } from '@learncard/didkey-plugin';
6
+ import { getEncryptionPlugin } from '@learncard/encryption-plugin';
7
+ import { getVCPlugin } from '@learncard/vc-plugin';
8
+ import { getVCTemplatesPlugin } from '@learncard/vc-templates-plugin';
9
+ import { getLearnCloudPlugin } from '@learncard/learn-cloud-plugin';
10
+ import { expirationPlugin } from '@learncard/expiration-plugin';
11
+ import { getEthereumPlugin } from '@learncard/ethereum-plugin';
12
+
13
+ import { getVpqrPlugin } from '@learncard/vpqr-plugin';
14
+ import { getCHAPIPlugin } from '@learncard/chapi-plugin';
15
+ import { getVerifyBoostPlugin, getLearnCardNetworkPlugin } from '@learncard/network-plugin';
16
+ import { getLearnCardPlugin } from '@learncard/learn-card-plugin';
17
+ import { getOpenID4VCPlugin } from '@learncard/openid4vc-plugin';
18
+ import { getSdJwtVcPlugin } from '@learncard/sd-jwt-vc-plugin';
19
+
20
+ import { NetworkLearnCardFromSeed } from '../types/LearnCard';
21
+ import { defaultEthereumArgs } from '../defaults';
22
+
23
+ /**
24
+ * Generates a Network LearnCard Wallet from a 64 character seed string
25
+ *
26
+ * @group Init Functions
27
+ */
28
+ export const networkLearnCardFromSeed = async ({
29
+ seed,
30
+ network: _network,
31
+ trustedBoostRegistry = 'https://raw.githubusercontent.com/learningeconomy/registries/main/learncard/trusted-app-registry.json',
32
+ guardianApprovalGetter,
33
+ extraHeaders,
34
+
35
+ cloud: {
36
+ url = 'https://cloud.learncard.com/trpc',
37
+ unencryptedFields = [],
38
+ unencryptedCustomFields = [],
39
+ automaticallyAssociateDids = true,
40
+ } = {},
41
+ didkit,
42
+ allowRemoteContexts = false,
43
+ ethereumConfig = defaultEthereumArgs,
44
+ openid4vc,
45
+ debug,
46
+ }: NetworkLearnCardFromSeed['args']): Promise<NetworkLearnCardFromSeed['returnValue']> => {
47
+ const network = typeof _network === 'boolean' ? 'https://network.learncard.com/trpc' : _network;
48
+
49
+ const dynamicLc = await (await generateLearnCard({ debug })).addPlugin(DynamicLoaderPlugin);
50
+
51
+ const cryptoLc = await dynamicLc.addPlugin(CryptoPlugin);
52
+
53
+ const getDidkit = async (): Promise<typeof getDidKitPlugin> => {
54
+ if (didkit === 'node') {
55
+ const mod = await import('@learncard/didkit-plugin-node');
56
+ return mod.getDidKitPlugin as typeof getDidKitPlugin;
57
+ }
58
+ return getDidKitPlugin;
59
+ };
60
+
61
+ const didkitLc = await cryptoLc.addPlugin(
62
+ await (
63
+ await getDidkit()
64
+ )(didkit === 'node' ? undefined : didkit, allowRemoteContexts)
65
+ );
66
+
67
+ const didkeyLc = await didkitLc.addPlugin(
68
+ await getDidKeyPlugin<DidMethod>(didkitLc, seed, 'key')
69
+ );
70
+
71
+ const encryptionLc = await didkeyLc.addPlugin(await getEncryptionPlugin(didkeyLc));
72
+
73
+ const vcLc = await encryptionLc.addPlugin(getVCPlugin(encryptionLc));
74
+
75
+ const templateLc = await vcLc.addPlugin(getVCTemplatesPlugin());
76
+
77
+ const cloudLc = await templateLc.addPlugin(
78
+ await getLearnCloudPlugin(
79
+ templateLc,
80
+ url,
81
+ unencryptedFields,
82
+ unencryptedCustomFields,
83
+ automaticallyAssociateDids
84
+ )
85
+ );
86
+
87
+ const expirationLc = await cloudLc.addPlugin(expirationPlugin(cloudLc));
88
+
89
+ const ethLc = await expirationLc.addPlugin(getEthereumPlugin(expirationLc, ethereumConfig));
90
+
91
+ const vpqrLc = await ethLc.addPlugin(getVpqrPlugin(ethLc));
92
+
93
+ const chapiLc = await vpqrLc.addPlugin(await getCHAPIPlugin());
94
+
95
+ const boostVerificationLc = await chapiLc.addPlugin(
96
+ await getVerifyBoostPlugin(chapiLc, trustedBoostRegistry)
97
+ );
98
+
99
+ const sdJwtVcLc = await boostVerificationLc.addPlugin(getSdJwtVcPlugin(boostVerificationLc));
100
+
101
+ const lcLc = await sdJwtVcLc.addPlugin(getLearnCardPlugin(sdJwtVcLc));
102
+
103
+ const networkLc = await lcLc.addPlugin(
104
+ await getLearnCardNetworkPlugin(lcLc, network, { guardianApprovalGetter, extraHeaders })
105
+ );
106
+
107
+ return networkLc.addPlugin(getOpenID4VCPlugin(networkLc, openid4vc));
108
+ };
@@ -0,0 +1,244 @@
1
+ import { LearnCard } from '@learncard/core';
2
+ import { InitInput } from '@learncard/types';
3
+
4
+ import { CryptoPluginType } from '@learncard/crypto-plugin';
5
+ import { DIDKitPlugin, DidMethod } from '@learncard/didkit-plugin';
6
+ import { DidKeyPlugin } from '@learncard/didkey-plugin';
7
+ import { DynamicLoaderPluginType } from '@learncard/dynamic-loader-plugin';
8
+ import { VCPlugin } from '@learncard/vc-plugin';
9
+ import { VCTemplatePlugin } from '@learncard/vc-templates-plugin';
10
+ import { LearnCloudPlugin } from '@learncard/learn-cloud-plugin';
11
+ import { ExpirationPlugin } from '@learncard/expiration-plugin';
12
+ import { EthereumPlugin, EthereumConfig } from '@learncard/ethereum-plugin';
13
+ import { VpqrPlugin } from '@learncard/vpqr-plugin';
14
+ import { CHAPIPlugin } from '@learncard/chapi-plugin';
15
+ import { VCAPIPlugin } from '@learncard/vc-api-plugin';
16
+ import { LearnCardPlugin } from '@learncard/learn-card-plugin';
17
+ import { VerifyBoostPlugin, LearnCardNetworkPlugin } from '@learncard/network-plugin';
18
+ import { DidWebPlugin } from '@learncard/did-web-plugin';
19
+ import { EncryptionPluginType } from '@learncard/encryption-plugin';
20
+ import { OpenID4VCPlugin, OpenID4VCPluginConfig } from '@learncard/openid4vc-plugin';
21
+ import { SdJwtVcPlugin } from '@learncard/sd-jwt-vc-plugin';
22
+
23
+ import { InitFunction, GenericInitFunction } from './helpers';
24
+
25
+ export type GuardianApprovalGetter = () => string | undefined | Promise<string | undefined>;
26
+
27
+ /** @group LearnCard */
28
+ export type LearnCardConfig = {
29
+ cloud?: {
30
+ url?: string;
31
+ unencryptedFields?: string[];
32
+ unencryptedCustomFields?: string[];
33
+ automaticallyAssociateDids?: boolean;
34
+ };
35
+ didkit: InitInput | Promise<InitInput> | 'node';
36
+ allowRemoteContexts?: boolean;
37
+ ethereumConfig: EthereumConfig;
38
+ /**
39
+ * Optional configuration for the OpenID4VC holder plugin
40
+ * (OID4VCI + OID4VP + SIOPv2). The plugin is wired automatically
41
+ * into seed-based wallet shapes; this hook lets hosts customise
42
+ * the network policy (e.g., a trust-pinned fetch, a custom DID
43
+ * resolver for verifying Request Objects, X.509 trust roots).
44
+ * Omitting this works for the common case.
45
+ */
46
+ openid4vc?: OpenID4VCPluginConfig;
47
+ debug?: typeof console.log;
48
+ };
49
+
50
+ /** @group Init Functions */
51
+ export type EmptyLearnCard = InitFunction<
52
+ {},
53
+ 'didkit' | 'debug' | 'allowRemoteContexts',
54
+ LearnCard<
55
+ [
56
+ DynamicLoaderPluginType,
57
+ CryptoPluginType,
58
+ DIDKitPlugin,
59
+ ExpirationPlugin,
60
+ VCTemplatePlugin,
61
+ CHAPIPlugin,
62
+ LearnCardPlugin
63
+ ]
64
+ >
65
+ >;
66
+
67
+ /** @group Init Functions */
68
+ export type LearnCardFromSeed = InitFunction<
69
+ { seed: string },
70
+ keyof LearnCardConfig,
71
+ LearnCard<
72
+ [
73
+ DynamicLoaderPluginType,
74
+ CryptoPluginType,
75
+ DIDKitPlugin,
76
+ DidKeyPlugin<DidMethod>,
77
+ EncryptionPluginType,
78
+ VCPlugin,
79
+ VCTemplatePlugin,
80
+ LearnCloudPlugin,
81
+ ExpirationPlugin,
82
+ EthereumPlugin,
83
+ VpqrPlugin,
84
+ CHAPIPlugin,
85
+ SdJwtVcPlugin,
86
+ LearnCardPlugin,
87
+ OpenID4VCPlugin
88
+ ]
89
+ >
90
+ >;
91
+
92
+ /** @group Init Functions */
93
+ export type NetworkLearnCardFromSeed = InitFunction<
94
+ {
95
+ seed: string;
96
+ network: true | string;
97
+ trustedBoostRegistry?: string;
98
+ guardianApprovalGetter?: GuardianApprovalGetter;
99
+ extraHeaders?: Record<string, string>;
100
+ },
101
+ keyof LearnCardConfig,
102
+ LearnCard<
103
+ [
104
+ DynamicLoaderPluginType,
105
+ CryptoPluginType,
106
+ DIDKitPlugin,
107
+ DidKeyPlugin<DidMethod>,
108
+ EncryptionPluginType,
109
+ VCPlugin,
110
+ VCTemplatePlugin,
111
+ LearnCloudPlugin,
112
+ ExpirationPlugin,
113
+ EthereumPlugin,
114
+ VpqrPlugin,
115
+ CHAPIPlugin,
116
+ VerifyBoostPlugin,
117
+ SdJwtVcPlugin,
118
+ LearnCardPlugin,
119
+ LearnCardNetworkPlugin,
120
+ OpenID4VCPlugin
121
+ ]
122
+ >
123
+ >;
124
+
125
+ /** @group Init Functions */
126
+ export type NetworkLearnCardFromApiKey = InitFunction<
127
+ {
128
+ apiKey: string;
129
+ network: true | string;
130
+ trustedBoostRegistry?: string;
131
+ guardianApprovalGetter?: GuardianApprovalGetter;
132
+ extraHeaders?: Record<string, string>;
133
+ },
134
+ 'didkit' | 'allowRemoteContexts' | 'debug',
135
+ LearnCard<
136
+ [
137
+ DynamicLoaderPluginType,
138
+ CryptoPluginType,
139
+ DIDKitPlugin,
140
+ VCPlugin,
141
+ VCTemplatePlugin,
142
+ ExpirationPlugin,
143
+ VpqrPlugin,
144
+ CHAPIPlugin,
145
+ VerifyBoostPlugin,
146
+ LearnCardPlugin,
147
+ LearnCardNetworkPlugin
148
+ ]
149
+ >
150
+ >;
151
+
152
+ /** @group Init Functions */
153
+ export type DidWebLearnCardFromSeed = InitFunction<
154
+ { seed: string; didWeb: string; trustedBoostRegistry?: string },
155
+ keyof LearnCardConfig,
156
+ LearnCard<
157
+ [
158
+ DynamicLoaderPluginType,
159
+ CryptoPluginType,
160
+ DIDKitPlugin,
161
+ DidKeyPlugin<DidMethod>,
162
+ EncryptionPluginType,
163
+ VCPlugin,
164
+ VCTemplatePlugin,
165
+ LearnCloudPlugin,
166
+ ExpirationPlugin,
167
+ EthereumPlugin,
168
+ VpqrPlugin,
169
+ CHAPIPlugin,
170
+ SdJwtVcPlugin,
171
+ LearnCardPlugin,
172
+ DidWebPlugin,
173
+ OpenID4VCPlugin
174
+ ]
175
+ >
176
+ >;
177
+
178
+ /** @group Init Functions */
179
+ export type DidWebNetworkLearnCardFromSeed = InitFunction<
180
+ {
181
+ seed: string;
182
+ network: true | string;
183
+ didWeb: string;
184
+ trustedBoostRegistry?: string;
185
+ guardianApprovalGetter?: GuardianApprovalGetter;
186
+ extraHeaders?: Record<string, string>;
187
+ },
188
+ keyof LearnCardConfig,
189
+ LearnCard<
190
+ [
191
+ DynamicLoaderPluginType,
192
+ CryptoPluginType,
193
+ DIDKitPlugin,
194
+ DidKeyPlugin<DidMethod>,
195
+ EncryptionPluginType,
196
+ VCPlugin,
197
+ VCTemplatePlugin,
198
+ LearnCloudPlugin,
199
+ ExpirationPlugin,
200
+ EthereumPlugin,
201
+ VpqrPlugin,
202
+ CHAPIPlugin,
203
+ VerifyBoostPlugin,
204
+ SdJwtVcPlugin,
205
+ LearnCardPlugin,
206
+ DidWebPlugin,
207
+ LearnCardNetworkPlugin,
208
+ OpenID4VCPlugin
209
+ ]
210
+ >
211
+ >;
212
+
213
+ /** @group Init Functions */
214
+ export type LearnCardFromVcApi = InitFunction<
215
+ { vcApi: true | string; did?: string },
216
+ 'debug',
217
+ LearnCard<
218
+ [
219
+ CryptoPluginType,
220
+ VCAPIPlugin,
221
+ ExpirationPlugin,
222
+ VCTemplatePlugin,
223
+ CHAPIPlugin,
224
+ LearnCardPlugin
225
+ ]
226
+ >
227
+ >;
228
+
229
+ /** @group Init Functions */
230
+ export type CustomLearnCard = InitFunction<{ custom: true }, 'debug', LearnCard<[]>>;
231
+
232
+ /** @group Init Functions */
233
+ export type InitLearnCard = GenericInitFunction<
234
+ [
235
+ EmptyLearnCard,
236
+ LearnCardFromSeed,
237
+ NetworkLearnCardFromSeed,
238
+ DidWebLearnCardFromSeed,
239
+ DidWebNetworkLearnCardFromSeed,
240
+ LearnCardFromVcApi,
241
+ CustomLearnCard,
242
+ NetworkLearnCardFromApiKey
243
+ ]
244
+ >;
@@ -0,0 +1,6 @@
1
+ declare module '@learncard/didkit-plugin-node' {
2
+ export const getDidKitPlugin: (
3
+ input?: unknown,
4
+ allowRemoteContexts?: boolean
5
+ ) => Promise<import('@learncard/didkit-plugin').DIDKitPlugin>;
6
+ }
@@ -0,0 +1,17 @@
1
+ import { LearnCardConfig } from './LearnCard';
2
+ import { LearnCard } from '@learncard/core';
3
+
4
+ export type InitFunction<
5
+ Args extends Record<string, any> = Record<string, any>,
6
+ Config extends keyof LearnCardConfig | undefined = keyof LearnCardConfig,
7
+ ReturnValue extends LearnCard<any, any> = LearnCard<any, any>
8
+ > = {
9
+ args: Args &
10
+ (undefined extends Config ? {} : Partial<Pick<LearnCardConfig, NonNullable<Config>>>);
11
+ returnValue: ReturnValue;
12
+ };
13
+
14
+ export type GenericInitFunction<InitFunctions extends InitFunction<any, any, any>[]> = {
15
+ args: InitFunctions[number]['args'];
16
+ returnValue: Promise<InitFunctions[number]['returnValue']>;
17
+ };
package/dist/node-esm.mjs DELETED
@@ -1,32 +0,0 @@
1
- // Node ESM entrypoint (resolved via the `node.import` export condition).
2
- //
3
- // Node consumers are deliberately routed to the CommonJS bundle (`index.cjs`,
4
- // which switches between the dev / minified prod CJS builds via NODE_ENV).
5
- // We load it with `createRequire` rather than a static `import ... from
6
- // './index.cjs'`.
7
- //
8
- // Why: a static ESM import of a CJS file is the one shape that breaks bundlers.
9
- // When a bundler (e.g. Vite/Astro SSR) transforms this module — which it does
10
- // for symlinked workspace deps — it follows the static import into `index.cjs`
11
- // and tries to transform that CommonJS file as ESM, throwing
12
- // `module is not defined`. `createRequire` keeps the CJS loading opaque to the
13
- // bundler's ESM transform and hands it to Node's native CommonJS loader, where
14
- // `module` / `require` are defined. Runtime behavior for Node consumers is
15
- // unchanged (same CJS bundle, same didkit backend); bundler-transformed
16
- // symlinked consumers no longer need `ssr.external` / `optimizeDeps` guards.
17
- import { createRequire } from 'node:module';
18
-
19
- const require = createRequire(import.meta.url);
20
- const init = require('./index.cjs');
21
-
22
- export const customLearnCard = init.customLearnCard;
23
- export const didWebLearnCardFromSeed = init.didWebLearnCardFromSeed;
24
- export const didWebNetworkLearnCardFromSeed = init.didWebNetworkLearnCardFromSeed;
25
- export const emptyLearnCard = init.emptyLearnCard;
26
- export const initLearnCard = init.initLearnCard;
27
- export const learnCardFromApiUrl = init.learnCardFromApiUrl;
28
- export const learnCardFromSeed = init.learnCardFromSeed;
29
- export const networkLearnCardFromApiKey = init.networkLearnCardFromApiKey;
30
- export const networkLearnCardFromSeed = init.networkLearnCardFromSeed;
31
-
32
- export default init;