@campnetwork/origin 1.2.0-1 → 1.2.0-3
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 +231 -4
- package/dist/core.cjs +164 -86
- package/dist/core.d.ts +170 -6
- package/dist/core.esm.d.ts +170 -6
- package/dist/core.esm.js +173 -86
- package/dist/react/index.esm.d.ts +39 -4
- package/dist/react/index.esm.js +366 -72
- package/package.json +16 -1
|
@@ -299,6 +299,12 @@ declare class Origin {
|
|
|
299
299
|
claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
+
interface StorageAdapter {
|
|
303
|
+
getItem(key: string): Promise<string | null>;
|
|
304
|
+
setItem(key: string, value: string): Promise<void>;
|
|
305
|
+
removeItem(key: string): Promise<void>;
|
|
306
|
+
}
|
|
307
|
+
|
|
302
308
|
declare global {
|
|
303
309
|
interface Window {
|
|
304
310
|
ethereum?: any;
|
|
@@ -326,12 +332,14 @@ declare class Auth {
|
|
|
326
332
|
* @param {string} options.clientId The client ID.
|
|
327
333
|
* @param {string|object} options.redirectUri The redirect URI used for oauth. Leave empty if you want to use the current URL. If you want different redirect URIs for different socials, pass an object with the socials as keys and the redirect URIs as values.
|
|
328
334
|
* @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
|
|
335
|
+
* @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
|
|
329
336
|
* @throws {APIError} - Throws an error if the clientId is not provided.
|
|
330
337
|
*/
|
|
331
|
-
constructor({ clientId, redirectUri, environment, }: {
|
|
338
|
+
constructor({ clientId, redirectUri, environment, storage, }: {
|
|
332
339
|
clientId: string;
|
|
333
340
|
redirectUri: string | Record<string, string>;
|
|
334
341
|
environment?: "DEVELOPMENT" | "PRODUCTION";
|
|
342
|
+
storage?: StorageAdapter;
|
|
335
343
|
});
|
|
336
344
|
/**
|
|
337
345
|
* Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
|
|
@@ -394,6 +402,33 @@ declare class Auth {
|
|
|
394
402
|
message: string;
|
|
395
403
|
walletAddress: string;
|
|
396
404
|
}>;
|
|
405
|
+
/**
|
|
406
|
+
* Connect with a custom signer (for Node.js or custom wallet implementations).
|
|
407
|
+
* This method bypasses browser wallet interactions and uses the provided signer directly.
|
|
408
|
+
* @param {any} signer The signer instance (viem WalletClient, ethers Signer, or custom signer).
|
|
409
|
+
* @param {object} [options] Optional configuration.
|
|
410
|
+
* @param {string} [options.domain] The domain to use in SIWE message (defaults to 'localhost').
|
|
411
|
+
* @param {string} [options.uri] The URI to use in SIWE message (defaults to 'http://localhost').
|
|
412
|
+
* @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
|
|
413
|
+
* @throws {APIError} - Throws an error if authentication fails.
|
|
414
|
+
* @example
|
|
415
|
+
* // Using with ethers
|
|
416
|
+
* const signer = new ethers.Wallet(privateKey, provider);
|
|
417
|
+
* await auth.connectWithSigner(signer, { domain: 'myapp.com', uri: 'https://myapp.com' });
|
|
418
|
+
*
|
|
419
|
+
* // Using with viem
|
|
420
|
+
* const account = privateKeyToAccount('0x...');
|
|
421
|
+
* const client = createWalletClient({ account, chain: mainnet, transport: http() });
|
|
422
|
+
* await auth.connectWithSigner(client);
|
|
423
|
+
*/
|
|
424
|
+
connectWithSigner(signer: any, options?: {
|
|
425
|
+
domain?: string;
|
|
426
|
+
uri?: string;
|
|
427
|
+
}): Promise<{
|
|
428
|
+
success: boolean;
|
|
429
|
+
message: string;
|
|
430
|
+
walletAddress: string;
|
|
431
|
+
}>;
|
|
397
432
|
/**
|
|
398
433
|
* Get the user's linked social accounts.
|
|
399
434
|
* @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
|
|
@@ -407,19 +442,19 @@ declare class Auth {
|
|
|
407
442
|
/**
|
|
408
443
|
* Link the user's Twitter account.
|
|
409
444
|
* @returns {Promise<void>}
|
|
410
|
-
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
445
|
+
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
411
446
|
*/
|
|
412
447
|
linkTwitter(): Promise<void>;
|
|
413
448
|
/**
|
|
414
449
|
* Link the user's Discord account.
|
|
415
450
|
* @returns {Promise<void>}
|
|
416
|
-
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
451
|
+
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
417
452
|
*/
|
|
418
453
|
linkDiscord(): Promise<void>;
|
|
419
454
|
/**
|
|
420
455
|
* Link the user's Spotify account.
|
|
421
456
|
* @returns {Promise<void>}
|
|
422
|
-
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
457
|
+
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
423
458
|
*/
|
|
424
459
|
linkSpotify(): Promise<void>;
|
|
425
460
|
/**
|