@junobuild/core-peer 0.1.16 → 0.1.17

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.
@@ -3,7 +3,7 @@ import type { User } from './types/auth.types';
3
3
  import type { UserEnvironment } from './types/env.types';
4
4
  import type { Unsubscribe } from './types/subscription.types';
5
5
  export * from './providers/auth.providers';
6
- export { signIn, signOut, unsafeIdentity } from './services/auth.services';
6
+ export { getIdentityOnce, signIn, signOut, unsafeIdentity } from './services/auth.services';
7
7
  export * from './services/doc.services';
8
8
  export * from './services/factory.services';
9
9
  export * from './services/storage.services';
@@ -22,3 +22,16 @@ export declare const getIdentity: () => Identity | undefined;
22
22
  * @returns {Promise<Identity>} A promise that resolves to the identity of the user or an anonymous identity.
23
23
  */
24
24
  export declare const unsafeIdentity: () => Promise<Identity>;
25
+ /**
26
+ * Returns the current identity if the user is authenticated.
27
+ *
28
+ * ⚠️ Use this function imperatively only. Do **not** persist the identity in global state.
29
+ * It is intended for short-lived or one-time operations.
30
+ *
31
+ * Typical use case is to enable developers to implement custom features for the Internet Computer:
32
+ * - Passing the identity to temporarily create an actor or agent to call a canister
33
+ * - Signing a message or making a one-time authenticated call
34
+ *
35
+ * @returns The authenticated identity, or null if unavailable.
36
+ */
37
+ export declare const getIdentityOnce: () => Promise<Identity | null>;
@@ -113,15 +113,32 @@ export declare const getManyAssets: ({ satellite, ...rest }: {
113
113
  satellite?: SatelliteOptions;
114
114
  }) => Promise<(AssetNoContent | undefined)[]>;
115
115
  /**
116
- * Generates a download URL for a given asset.
116
+ * Returns a public URL for accessing a specific asset stored on a Satellite.
117
117
  *
118
- * @param {Object} params - The parameters for generating the download URL.
119
- * @param {Object} params.assetKey - The key details of the asset.
120
- * @param {string} params.assetKey.fullPath - The full path of the asset.
121
- * @param {string} params.assetKey.token - The access token for the asset.
122
- * @param {SatelliteOptions} [params.satellite] - The satellite options (required only in NodeJS environment).
118
+ * This URL can be used to:
119
+ * - Open the file directly in a browser
120
+ * - Embed the asset in HTML elements like `<img src="...">`, `<video src="...">`, or `<a href="...">`
121
+ * - Programmatically download or display the asset in your application
123
122
  *
124
- * @returns {string} The generated download URL.
123
+ * ### Example
124
+ * ```ts
125
+ * const url = downloadUrl({
126
+ * assetKey: {
127
+ * fullPath: '/images/logo.png',
128
+ * }
129
+ * });
130
+ *
131
+ * // Usage in an <img> tag
132
+ * <img src={url} alt="Logo" />
133
+ * ```
134
+ *
135
+ * @param {Object} params - Parameters for generating the URL.
136
+ * @param {Object} params.assetKey - Identifies the asset to generate the URL for.
137
+ * @param {string} params.assetKey.fullPath - The full path of the asset (e.g., `/folder/file.jpg`).
138
+ * @param {string} [params.assetKey.token] - Optional access token for accessing protected assets.
139
+ * @param {SatelliteOptions} [params.satellite] - Required only in Node.js environments to specify which Satellite to use.
140
+ *
141
+ * @returns {string} A full URL pointing to the asset.
125
142
  */
126
143
  export declare const downloadUrl: ({ assetKey: { fullPath, token }, satellite: satelliteOptions }: {
127
144
  assetKey: Pick<Asset, "fullPath" | "token">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@junobuild/core-peer",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "JavaScript core client for Juno minus DFINITY agent-js dependencies",
5
5
  "author": "David Dal Busco (https://daviddalbusco.com)",
6
6
  "license": "MIT",