@junobuild/ic-client 7.1.1 → 7.2.0-next-2026-02-10
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/actor.js +1 -1
- package/actor.js.map +3 -3
- package/actor.mjs +1 -1
- package/actor.mjs.map +3 -3
- package/declarations/console/console.did.d.ts +17 -11
- package/declarations/console/console.factory.certified.did.js +19 -7
- package/declarations/console/console.factory.did.js +19 -7
- package/declarations/console/console.factory.did.mjs +19 -7
- package/declarations/deprecated/console-0-3-3.did.d.ts +529 -0
- package/declarations/deprecated/console-0-3-3.factory.did.js +567 -0
- package/declarations/deprecated/observatory-0-4-0.did.d.ts +145 -0
- package/declarations/deprecated/observatory-0-4-0.factory.did.js +149 -0
- package/declarations/deprecated/satellite-0-1-6.did.d.ts +511 -0
- package/declarations/deprecated/satellite-0-1-6.factory.did.js +546 -0
- package/declarations/mission_control/mission_control.did.d.ts +3 -0
- package/declarations/mission_control/mission_control.factory.certified.did.js +6 -0
- package/declarations/mission_control/mission_control.factory.did.js +6 -0
- package/declarations/observatory/observatory.did.d.ts +7 -4
- package/declarations/observatory/observatory.factory.certified.did.js +14 -4
- package/declarations/observatory/observatory.factory.did.js +14 -4
- package/declarations/observatory/observatory.factory.did.mjs +14 -4
- package/declarations/orbiter/orbiter.did.d.ts +3 -0
- package/declarations/orbiter/orbiter.factory.certified.did.js +6 -0
- package/declarations/orbiter/orbiter.factory.did.js +6 -0
- package/declarations/orbiter/orbiter.factory.did.mjs +6 -0
- package/declarations/satellite/satellite.did.d.ts +77 -10
- package/declarations/satellite/satellite.factory.certified.did.js +78 -5
- package/declarations/satellite/satellite.factory.did.js +78 -5
- package/declarations/satellite/satellite.factory.did.mjs +78 -5
- package/declarations/sputnik/sputnik.did.d.ts +77 -10
- package/declarations/sputnik/sputnik.factory.certified.did.js +78 -5
- package/declarations/sputnik/sputnik.factory.did.js +78 -5
- package/dev/_constants.d.ts +1 -0
- package/dev/errors.d.ts +9 -0
- package/dev/identity.d.ts +43 -0
- package/dev/types/identity.d.ts +48 -0
- package/dev.d.ts +3 -0
- package/dev.js +2 -0
- package/dev.js.map +7 -0
- package/dev.mjs +4 -0
- package/dev.mjs.map +7 -0
- package/package.json +10 -4
|
@@ -75,6 +75,32 @@ export const idlFactory = ({IDL}) => {
|
|
|
75
75
|
Ok: Authentication,
|
|
76
76
|
Err: AuthenticationError
|
|
77
77
|
});
|
|
78
|
+
const OpenIdPrepareAutomationArgs = IDL.Record({
|
|
79
|
+
jwt: IDL.Text,
|
|
80
|
+
salt: IDL.Vec(IDL.Nat8)
|
|
81
|
+
});
|
|
82
|
+
const AuthenticateAutomationArgs = IDL.Variant({
|
|
83
|
+
OpenId: OpenIdPrepareAutomationArgs
|
|
84
|
+
});
|
|
85
|
+
const PrepareAutomationError = IDL.Variant({
|
|
86
|
+
JwtFindProvider: JwtFindProviderError,
|
|
87
|
+
InvalidController: IDL.Text,
|
|
88
|
+
GetCachedJwks: IDL.Null,
|
|
89
|
+
JwtVerify: JwtVerifyError,
|
|
90
|
+
GetOrFetchJwks: GetOrRefreshJwksError,
|
|
91
|
+
ControllerAlreadyExists: IDL.Null,
|
|
92
|
+
TooManyControllers: IDL.Text
|
|
93
|
+
});
|
|
94
|
+
const AuthenticationAutomationError = IDL.Variant({
|
|
95
|
+
PrepareAutomation: PrepareAutomationError,
|
|
96
|
+
RegisterController: IDL.Text,
|
|
97
|
+
SaveWorkflowMetadata: IDL.Text,
|
|
98
|
+
SaveUniqueJtiToken: IDL.Text
|
|
99
|
+
});
|
|
100
|
+
const AuthenticateAutomationResultResponse = IDL.Variant({
|
|
101
|
+
Ok: IDL.Null,
|
|
102
|
+
Err: AuthenticationAutomationError
|
|
103
|
+
});
|
|
78
104
|
const CommitBatch = IDL.Record({
|
|
79
105
|
batch_id: IDL.Nat,
|
|
80
106
|
headers: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
@@ -115,6 +141,10 @@ export const idlFactory = ({IDL}) => {
|
|
|
115
141
|
const DeleteControllersArgs = IDL.Record({
|
|
116
142
|
controllers: IDL.Vec(IDL.Principal)
|
|
117
143
|
});
|
|
144
|
+
const ControllerKind = IDL.Variant({
|
|
145
|
+
Emulator: IDL.Null,
|
|
146
|
+
Automation: IDL.Null
|
|
147
|
+
});
|
|
118
148
|
const ControllerScope = IDL.Variant({
|
|
119
149
|
Write: IDL.Null,
|
|
120
150
|
Admin: IDL.Null,
|
|
@@ -123,6 +153,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
123
153
|
const Controller = IDL.Record({
|
|
124
154
|
updated_at: IDL.Nat64,
|
|
125
155
|
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
156
|
+
kind: IDL.Opt(ControllerKind),
|
|
126
157
|
created_at: IDL.Nat64,
|
|
127
158
|
scope: ControllerScope,
|
|
128
159
|
expires_at: IDL.Opt(IDL.Nat64)
|
|
@@ -158,18 +189,21 @@ export const idlFactory = ({IDL}) => {
|
|
|
158
189
|
created_at: IDL.Nat64,
|
|
159
190
|
version: IDL.Opt(IDL.Nat64)
|
|
160
191
|
});
|
|
161
|
-
const
|
|
162
|
-
|
|
192
|
+
const OpenIdDelegationProvider = IDL.Variant({
|
|
193
|
+
GitHub: IDL.Null,
|
|
194
|
+
Google: IDL.Null
|
|
195
|
+
});
|
|
196
|
+
const OpenIdAuthProviderDelegationConfig = IDL.Record({
|
|
163
197
|
targets: IDL.Opt(IDL.Vec(IDL.Principal)),
|
|
164
198
|
max_time_to_live: IDL.Opt(IDL.Nat64)
|
|
165
199
|
});
|
|
166
|
-
const
|
|
167
|
-
delegation: IDL.Opt(
|
|
200
|
+
const OpenIdAuthProviderConfig = IDL.Record({
|
|
201
|
+
delegation: IDL.Opt(OpenIdAuthProviderDelegationConfig),
|
|
168
202
|
client_id: IDL.Text
|
|
169
203
|
});
|
|
170
204
|
const AuthenticationConfigOpenId = IDL.Record({
|
|
171
205
|
observatory_id: IDL.Opt(IDL.Principal),
|
|
172
|
-
providers: IDL.Vec(IDL.Tuple(
|
|
206
|
+
providers: IDL.Vec(IDL.Tuple(OpenIdDelegationProvider, OpenIdAuthProviderConfig))
|
|
173
207
|
});
|
|
174
208
|
const AuthenticationConfigInternetIdentity = IDL.Record({
|
|
175
209
|
derivation_origin: IDL.Opt(IDL.Text),
|
|
@@ -186,6 +220,33 @@ export const idlFactory = ({IDL}) => {
|
|
|
186
220
|
internet_identity: IDL.Opt(AuthenticationConfigInternetIdentity),
|
|
187
221
|
rules: IDL.Opt(AuthenticationRules)
|
|
188
222
|
});
|
|
223
|
+
const OpenIdAutomationProvider = IDL.Variant({GitHub: IDL.Null});
|
|
224
|
+
const AutomationScope = IDL.Variant({
|
|
225
|
+
Write: IDL.Null,
|
|
226
|
+
Submit: IDL.Null
|
|
227
|
+
});
|
|
228
|
+
const OpenIdAutomationProviderControllerConfig = IDL.Record({
|
|
229
|
+
scope: IDL.Opt(AutomationScope),
|
|
230
|
+
max_time_to_live: IDL.Opt(IDL.Nat64)
|
|
231
|
+
});
|
|
232
|
+
const RepositoryKey = IDL.Record({owner: IDL.Text, name: IDL.Text});
|
|
233
|
+
const OpenIdAutomationRepositoryConfig = IDL.Record({
|
|
234
|
+
branches: IDL.Opt(IDL.Vec(IDL.Text))
|
|
235
|
+
});
|
|
236
|
+
const OpenIdAutomationProviderConfig = IDL.Record({
|
|
237
|
+
controller: IDL.Opt(OpenIdAutomationProviderControllerConfig),
|
|
238
|
+
repositories: IDL.Vec(IDL.Tuple(RepositoryKey, OpenIdAutomationRepositoryConfig))
|
|
239
|
+
});
|
|
240
|
+
const AutomationConfigOpenId = IDL.Record({
|
|
241
|
+
observatory_id: IDL.Opt(IDL.Principal),
|
|
242
|
+
providers: IDL.Vec(IDL.Tuple(OpenIdAutomationProvider, OpenIdAutomationProviderConfig))
|
|
243
|
+
});
|
|
244
|
+
const AutomationConfig = IDL.Record({
|
|
245
|
+
updated_at: IDL.Opt(IDL.Nat64),
|
|
246
|
+
openid: IDL.Opt(AutomationConfigOpenId),
|
|
247
|
+
created_at: IDL.Opt(IDL.Nat64),
|
|
248
|
+
version: IDL.Opt(IDL.Nat64)
|
|
249
|
+
});
|
|
189
250
|
const ConfigMaxMemorySize = IDL.Record({
|
|
190
251
|
stable: IDL.Opt(IDL.Nat64),
|
|
191
252
|
heap: IDL.Opt(IDL.Nat64)
|
|
@@ -396,8 +457,13 @@ export const idlFactory = ({IDL}) => {
|
|
|
396
457
|
internet_identity: IDL.Opt(AuthenticationConfigInternetIdentity),
|
|
397
458
|
rules: IDL.Opt(AuthenticationRules)
|
|
398
459
|
});
|
|
460
|
+
const SetAutomationConfig = IDL.Record({
|
|
461
|
+
openid: IDL.Opt(AutomationConfigOpenId),
|
|
462
|
+
version: IDL.Opt(IDL.Nat64)
|
|
463
|
+
});
|
|
399
464
|
const SetController = IDL.Record({
|
|
400
465
|
metadata: IDL.Vec(IDL.Tuple(IDL.Text, IDL.Text)),
|
|
466
|
+
kind: IDL.Opt(ControllerKind),
|
|
401
467
|
scope: ControllerScope,
|
|
402
468
|
expires_at: IDL.Opt(IDL.Nat64)
|
|
403
469
|
});
|
|
@@ -443,6 +509,11 @@ export const idlFactory = ({IDL}) => {
|
|
|
443
509
|
|
|
444
510
|
return IDL.Service({
|
|
445
511
|
authenticate: IDL.Func([AuthenticationArgs], [AuthenticateResultResponse], []),
|
|
512
|
+
authenticate_automation: IDL.Func(
|
|
513
|
+
[AuthenticateAutomationArgs],
|
|
514
|
+
[AuthenticateAutomationResultResponse],
|
|
515
|
+
[]
|
|
516
|
+
),
|
|
446
517
|
commit_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
447
518
|
commit_proposal: IDL.Func([CommitProposal], [IDL.Null], []),
|
|
448
519
|
commit_proposal_asset_upload: IDL.Func([CommitBatch], [], []),
|
|
@@ -471,6 +542,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
471
542
|
deposit_cycles: IDL.Func([DepositCyclesArgs], [], []),
|
|
472
543
|
get_asset: IDL.Func([IDL.Text, IDL.Text], [IDL.Opt(AssetNoContent)], ['query']),
|
|
473
544
|
get_auth_config: IDL.Func([], [IDL.Opt(AuthenticationConfig)], ['query']),
|
|
545
|
+
get_automation_config: IDL.Func([], [IDL.Opt(AutomationConfig)], ['query']),
|
|
474
546
|
get_config: IDL.Func([], [Config], []),
|
|
475
547
|
get_db_config: IDL.Func([], [IDL.Opt(DbConfig)], ['query']),
|
|
476
548
|
get_delegation: IDL.Func([GetDelegationArgs], [GetDelegationResultResponse], ['query']),
|
|
@@ -512,6 +584,7 @@ export const idlFactory = ({IDL}) => {
|
|
|
512
584
|
reject_proposal: IDL.Func([CommitProposal], [IDL.Null], []),
|
|
513
585
|
set_asset_token: IDL.Func([IDL.Text, IDL.Text, IDL.Opt(IDL.Text)], [], []),
|
|
514
586
|
set_auth_config: IDL.Func([SetAuthenticationConfig], [AuthenticationConfig], []),
|
|
587
|
+
set_automation_config: IDL.Func([SetAutomationConfig], [AutomationConfig], []),
|
|
515
588
|
set_controllers: IDL.Func(
|
|
516
589
|
[SetControllersArgs],
|
|
517
590
|
[IDL.Vec(IDL.Tuple(IDL.Principal, Controller))],
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_DEV_DELEGATION_IDENTITY_EXPIRATION_IN_MS: number;
|
package/dev/errors.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class UnsafeDevIdentityNotBrowserError extends Error {
|
|
2
|
+
constructor();
|
|
3
|
+
}
|
|
4
|
+
export declare class UnsafeDevIdentityNotLocalhostError extends Error {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class UnsafeDevIdentityInvalidIdentifierError extends Error {
|
|
8
|
+
constructor(length: number);
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { DevIdentifier, DevIdentifierData, GenerateUnsafeIdentityParams, GenerateUnsafeIdentityResult, LoadDevIdentifiersParams } from './types/identity';
|
|
2
|
+
/**
|
|
3
|
+
* Load all development identifiers that have been used for authentication.
|
|
4
|
+
*
|
|
5
|
+
* Returns an array of tuples containing the identifier string and metadata (created/updated timestamps),
|
|
6
|
+
* sorted by most recently used first.
|
|
7
|
+
*
|
|
8
|
+
* @param params - Load parameters
|
|
9
|
+
* @param params.limit - Optional maximum number of identifiers to return
|
|
10
|
+
* @returns Promise resolving to array of [identifier, metadata] tuples sorted by updatedAt descending
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const recent = await loadDevIdentifiers({ limit: 5 });
|
|
14
|
+
* // Returns only the 5 most recently used identifiers
|
|
15
|
+
*/
|
|
16
|
+
export declare const loadDevIdentifiers: ({ limit }?: LoadDevIdentifiersParams) => Promise<[DevIdentifier, DevIdentifierData][]>;
|
|
17
|
+
/**
|
|
18
|
+
* Clear all stored development identifiers from IndexedDB.
|
|
19
|
+
* This removes the history of used identifiers but does not affect AuthClient's stored credentials.
|
|
20
|
+
*
|
|
21
|
+
* @returns Promise that resolves when identifiers are cleared
|
|
22
|
+
*/
|
|
23
|
+
export declare const clearDevIdentifiers: () => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Generate an identity for local development with the Internet Computer.
|
|
26
|
+
*
|
|
27
|
+
* ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
|
|
28
|
+
* ⚠️ UNSAFE - FOR LOCAL DEVELOPMENT ONLY ⚠️
|
|
29
|
+
* ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
|
|
30
|
+
*
|
|
31
|
+
* Returns the identity, session key, and delegation chain.
|
|
32
|
+
* Consumers must handle storage (e.g. for AuthClient compatibility).
|
|
33
|
+
*
|
|
34
|
+
* @param params - Generation parameters
|
|
35
|
+
* @param params.identifier - Unique identifier string for this dev identity (default: "dev")
|
|
36
|
+
* @param params.maxTimeToLiveInMilliseconds - Delegation expiration time in ms (default: 7 days)
|
|
37
|
+
*
|
|
38
|
+
* @returns Promise resolving to object containing identity, sessionKey, and delegationChain
|
|
39
|
+
*
|
|
40
|
+
* @throws {UnsafeDevIdentityNotBrowserError} If called outside browser environment
|
|
41
|
+
* @throws {UnsafeDevIdentityNotLocalhostError} If called outside localhost
|
|
42
|
+
**/
|
|
43
|
+
export declare const generateUnsafeDevIdentity: ({ identifier, maxTimeToLiveInMilliseconds }?: GenerateUnsafeIdentityParams) => Promise<GenerateUnsafeIdentityResult>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { DelegationChain, DelegationIdentity, ECDSAKeyIdentity } from '@icp-sdk/core/identity';
|
|
2
|
+
/**
|
|
3
|
+
* A unique string identifier for a development identity.
|
|
4
|
+
* e.g. "dev" or "david"
|
|
5
|
+
*/
|
|
6
|
+
export type DevIdentifier = string;
|
|
7
|
+
/**
|
|
8
|
+
* Timestamp in milliseconds since Unix epoch.
|
|
9
|
+
* Date objects cannot be persisted in IndexedDB, so we use numeric timestamps.
|
|
10
|
+
*/
|
|
11
|
+
export type DevIdentifierTimestamp = number;
|
|
12
|
+
/**
|
|
13
|
+
* Metadata about a development identifier's usage.
|
|
14
|
+
*/
|
|
15
|
+
export interface DevIdentifierData {
|
|
16
|
+
/** Timestamp when this identifier was first used */
|
|
17
|
+
createdAt: DevIdentifierTimestamp;
|
|
18
|
+
/** Timestamp when this identifier was last used */
|
|
19
|
+
updatedAt: DevIdentifierTimestamp;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parameters for generating an unsafe development identity.
|
|
23
|
+
*/
|
|
24
|
+
export interface GenerateUnsafeIdentityParams {
|
|
25
|
+
/** Unique identifier string for this dev identity (default: "dev") */
|
|
26
|
+
identifier?: DevIdentifier;
|
|
27
|
+
/** Delegation expiration time in milliseconds (default: 7 days) */
|
|
28
|
+
maxTimeToLiveInMilliseconds?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Result of generating an unsafe development identity.
|
|
32
|
+
* Contains all components needed for authentication and storage.
|
|
33
|
+
*/
|
|
34
|
+
export interface GenerateUnsafeIdentityResult {
|
|
35
|
+
/** The delegated identity for making IC calls */
|
|
36
|
+
identity: DelegationIdentity;
|
|
37
|
+
/** The session key (to be stored in IDB for AuthClient compatibility, key KEY_STORAGE_KEY) */
|
|
38
|
+
sessionKey: ECDSAKeyIdentity;
|
|
39
|
+
/** The delegation chain (to be store in IDB for AuthClient compatibility, key KEY_STORAGE_DELEGATION) */
|
|
40
|
+
delegationChain: DelegationChain;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Parameters for loading development identifiers.
|
|
44
|
+
*/
|
|
45
|
+
export interface LoadDevIdentifiersParams {
|
|
46
|
+
/** Optional maximum number of identifiers to return */
|
|
47
|
+
limit?: number;
|
|
48
|
+
}
|
package/dev.d.ts
ADDED
package/dev.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var o=class extends Error{constructor(){super("A dev identity can only be used in browser environments")}},s=class extends Error{constructor(){super("A dev identity must only be used on localhost (127.0.0.1 or localhost)")}},i=class extends Error{constructor(t){super(`Identifier must be 32 characters or less, got ${t}`)}};import{DelegationChain as w,DelegationIdentity as v,ECDSAKeyIdentity as E,Ed25519KeyIdentity as g}from"@icp-sdk/core/identity";import{clear as x,createStore as A,entries as _,update as h}from"idb-keyval";var I=A("juno-dev-identifiers","juno-dev-identifiers-store"),S=async({limit:e}={})=>(await _(I)).sort(([y,{updatedAt:a}],[l,{updatedAt:d}])=>d-a).slice(0,e),R=()=>x(I),K=async({identifier:e="dev",maxTimeToLiveInMilliseconds:t}={})=>{if(!(typeof window<"u"))throw new o;let{location:{hostname:a}}=window;if(!["127.0.0.1","localhost"].includes(a))throw new s;let l=()=>{if(e.length>32)throw new i(e.length);return new TextEncoder().encode(e.padEnd(32,"0"))},d=async()=>{let n=l(),r=g.generate(n),c=await E.generate({extractable:!1}),p=t??6048e5,f=await w.create(r,c.getPublicKey(),new Date(Date.now()+p));return{identity:v.fromDelegation(c,f),sessionKey:c,delegationChain:f}},u=async()=>{await h(e,n=>{let r=Date.now();return{createdAt:n?.createdAt??r,updatedAt:r}},I)},D=await d();return await u(),D};export{i as UnsafeDevIdentityInvalidIdentifierError,o as UnsafeDevIdentityNotBrowserError,s as UnsafeDevIdentityNotLocalhostError,R as clearDevIdentifiers,K as generateUnsafeDevIdentity,S as loadDevIdentifiers};
|
|
2
|
+
//# sourceMappingURL=dev.js.map
|
package/dev.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/dev/errors.ts", "src/dev/identity.ts"],
|
|
4
|
+
"sourcesContent": ["export class UnsafeDevIdentityNotBrowserError extends Error {\n constructor() {\n super('A dev identity can only be used in browser environments');\n }\n}\n\nexport class UnsafeDevIdentityNotLocalhostError extends Error {\n constructor() {\n super('A dev identity must only be used on localhost (127.0.0.1 or localhost)');\n }\n}\n\nexport class UnsafeDevIdentityInvalidIdentifierError extends Error {\n constructor(length: number) {\n super(`Identifier must be 32 characters or less, got ${length}`);\n }\n}\n", "import {\n DelegationChain,\n DelegationIdentity,\n ECDSAKeyIdentity,\n Ed25519KeyIdentity\n} from '@icp-sdk/core/identity';\nimport {clear, createStore, entries, update} from 'idb-keyval';\nimport {DEFAULT_DEV_DELEGATION_IDENTITY_EXPIRATION_IN_MS} from './_constants';\nimport {\n UnsafeDevIdentityInvalidIdentifierError,\n UnsafeDevIdentityNotBrowserError,\n UnsafeDevIdentityNotLocalhostError\n} from './errors';\nimport type {\n DevIdentifier,\n DevIdentifierData,\n GenerateUnsafeIdentityParams,\n GenerateUnsafeIdentityResult,\n LoadDevIdentifiersParams\n} from './types/identity';\n\nconst identifiersIdbStore = createStore('juno-dev-identifiers', 'juno-dev-identifiers-store');\n\n/**\n * Load all development identifiers that have been used for authentication.\n *\n * Returns an array of tuples containing the identifier string and metadata (created/updated timestamps),\n * sorted by most recently used first.\n *\n * @param params - Load parameters\n * @param params.limit - Optional maximum number of identifiers to return\n * @returns Promise resolving to array of [identifier, metadata] tuples sorted by updatedAt descending\n *\n * @example\n * const recent = await loadDevIdentifiers({ limit: 5 });\n * // Returns only the 5 most recently used identifiers\n */\nexport const loadDevIdentifiers = async ({limit}: LoadDevIdentifiersParams = {}): Promise<\n [DevIdentifier, DevIdentifierData][]\n> => {\n const identifiers = await entries<DevIdentifier, DevIdentifierData>(identifiersIdbStore);\n\n return identifiers.sort(([_, {updatedAt: a}], [__, {updatedAt: b}]) => b - a).slice(0, limit);\n};\n\n/**\n * Clear all stored development identifiers from IndexedDB.\n * This removes the history of used identifiers but does not affect AuthClient's stored credentials.\n *\n * @returns Promise that resolves when identifiers are cleared\n */\nexport const clearDevIdentifiers = () => clear(identifiersIdbStore);\n\n/**\n * Generate an identity for local development with the Internet Computer.\n *\n * \u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\n * \u26A0\uFE0F UNSAFE - FOR LOCAL DEVELOPMENT ONLY \u26A0\uFE0F\n * \u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\n *\n * Returns the identity, session key, and delegation chain.\n * Consumers must handle storage (e.g. for AuthClient compatibility).\n *\n * @param params - Generation parameters\n * @param params.identifier - Unique identifier string for this dev identity (default: \"dev\")\n * @param params.maxTimeToLiveInMilliseconds - Delegation expiration time in ms (default: 7 days)\n *\n * @returns Promise resolving to object containing identity, sessionKey, and delegationChain\n *\n * @throws {UnsafeDevIdentityNotBrowserError} If called outside browser environment\n * @throws {UnsafeDevIdentityNotLocalhostError} If called outside localhost\n **/\nexport const generateUnsafeDevIdentity = async ({\n identifier = 'dev',\n maxTimeToLiveInMilliseconds\n}: GenerateUnsafeIdentityParams = {}): Promise<GenerateUnsafeIdentityResult> => {\n const isBrowser = (): boolean => typeof window !== `undefined`;\n\n if (!isBrowser()) {\n throw new UnsafeDevIdentityNotBrowserError();\n }\n\n const {\n location: {hostname}\n } = window;\n\n if (!['127.0.0.1', 'localhost'].includes(hostname)) {\n throw new UnsafeDevIdentityNotLocalhostError();\n }\n\n const generateSeed = (): Uint8Array => {\n if (identifier.length > 32) {\n throw new UnsafeDevIdentityInvalidIdentifierError(identifier.length);\n }\n\n const encoder = new TextEncoder();\n return encoder.encode(identifier.padEnd(32, '0'));\n };\n\n const generate = async (): Promise<GenerateUnsafeIdentityResult> => {\n const seedBytes = generateSeed();\n\n const rootIdentity = Ed25519KeyIdentity.generate(seedBytes);\n const sessionKey = await ECDSAKeyIdentity.generate({\n extractable: false\n });\n\n const sessionLengthInMilliseconds =\n maxTimeToLiveInMilliseconds ?? DEFAULT_DEV_DELEGATION_IDENTITY_EXPIRATION_IN_MS;\n\n const chain = await DelegationChain.create(\n rootIdentity,\n sessionKey.getPublicKey(),\n new Date(Date.now() + sessionLengthInMilliseconds)\n );\n\n const delegatedIdentity = DelegationIdentity.fromDelegation(sessionKey, chain);\n\n return {\n identity: delegatedIdentity,\n sessionKey,\n delegationChain: chain\n };\n };\n\n const saveIdentifierUsage = async () => {\n await update(\n identifier,\n (value) => {\n const now = Date.now();\n\n return {\n createdAt: value?.createdAt ?? now,\n updatedAt: now\n };\n },\n identifiersIdbStore\n );\n };\n\n const result = await generate();\n\n await saveIdentifierUsage();\n\n return result;\n};\n"],
|
|
5
|
+
"mappings": "AAAO,IAAMA,EAAN,cAA+C,KAAM,CAC1D,aAAc,CACZ,MAAM,yDAAyD,CACjE,CACF,EAEaC,EAAN,cAAiD,KAAM,CAC5D,aAAc,CACZ,MAAM,wEAAwE,CAChF,CACF,EAEaC,EAAN,cAAsD,KAAM,CACjE,YAAYC,EAAgB,CAC1B,MAAM,iDAAiDA,CAAM,EAAE,CACjE,CACF,EChBA,OACE,mBAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,sBAAAC,MACK,yBACP,OAAQ,SAAAC,EAAO,eAAAC,EAAa,WAAAC,EAAS,UAAAC,MAAa,aAelD,IAAMC,EAAsBC,EAAY,uBAAwB,4BAA4B,EAgB/EC,EAAqB,MAAO,CAAC,MAAAC,CAAK,EAA8B,CAAC,KAGxD,MAAMC,EAA0CJ,CAAmB,GAEpE,KAAK,CAAC,CAACK,EAAG,CAAC,UAAW,CAAC,CAAC,EAAG,CAACC,EAAI,CAAC,UAAWC,CAAC,CAAC,IAAMA,EAAI,CAAC,EAAE,MAAM,EAAGJ,CAAK,EASjFK,EAAsB,IAAMC,EAAMT,CAAmB,EAqBrDU,EAA4B,MAAO,CAC9C,WAAAC,EAAa,MACb,4BAAAC,CACF,EAAkC,CAAC,IAA6C,CAG9E,GAAI,EAF6B,OAAO,OAAW,KAGjD,MAAM,IAAIC,EAGZ,GAAM,CACJ,SAAU,CAAC,SAAAC,CAAQ,CACrB,EAAI,OAEJ,GAAI,CAAC,CAAC,YAAa,WAAW,EAAE,SAASA,CAAQ,EAC/C,MAAM,IAAIC,EAGZ,IAAMC,EAAe,IAAkB,CACrC,GAAIL,EAAW,OAAS,GACtB,MAAM,IAAIM,EAAwCN,EAAW,MAAM,EAIrE,OADgB,IAAI,YAAY,EACjB,OAAOA,EAAW,OAAO,GAAI,GAAG,CAAC,CAClD,EAEMO,EAAW,SAAmD,CAClE,IAAMC,EAAYH,EAAa,EAEzBI,EAAeC,EAAmB,SAASF,CAAS,EACpDG,EAAa,MAAMC,EAAiB,SAAS,CACjD,YAAa,EACf,CAAC,EAEKC,EACJZ,GAA+B,OAE3Ba,EAAQ,MAAMC,EAAgB,OAClCN,EACAE,EAAW,aAAa,EACxB,IAAI,KAAK,KAAK,IAAI,EAAIE,CAA2B,CACnD,EAIA,MAAO,CACL,SAHwBG,EAAmB,eAAeL,EAAYG,CAAK,EAI3E,WAAAH,EACA,gBAAiBG,CACnB,CACF,EAEMG,EAAsB,SAAY,CACtC,MAAMC,EACJlB,EACCmB,GAAU,CACT,IAAMC,EAAM,KAAK,IAAI,EAErB,MAAO,CACL,UAAWD,GAAO,WAAaC,EAC/B,UAAWA,CACb,CACF,EACA/B,CACF,CACF,EAEMgC,EAAS,MAAMd,EAAS,EAE9B,aAAMU,EAAoB,EAEnBI,CACT",
|
|
6
|
+
"names": ["UnsafeDevIdentityNotBrowserError", "UnsafeDevIdentityNotLocalhostError", "UnsafeDevIdentityInvalidIdentifierError", "length", "DelegationChain", "DelegationIdentity", "ECDSAKeyIdentity", "Ed25519KeyIdentity", "clear", "createStore", "entries", "update", "identifiersIdbStore", "createStore", "loadDevIdentifiers", "limit", "entries", "_", "__", "b", "clearDevIdentifiers", "clear", "generateUnsafeDevIdentity", "identifier", "maxTimeToLiveInMilliseconds", "UnsafeDevIdentityNotBrowserError", "hostname", "UnsafeDevIdentityNotLocalhostError", "generateSeed", "UnsafeDevIdentityInvalidIdentifierError", "generate", "seedBytes", "rootIdentity", "Ed25519KeyIdentity", "sessionKey", "ECDSAKeyIdentity", "sessionLengthInMilliseconds", "chain", "DelegationChain", "DelegationIdentity", "saveIdentifierUsage", "update", "value", "now", "result"]
|
|
7
|
+
}
|
package/dev.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var o=class extends Error{constructor(){super("A dev identity can only be used in browser environments")}},s=class extends Error{constructor(){super("A dev identity must only be used on localhost (127.0.0.1 or localhost)")}},i=class extends Error{constructor(t){super(`Identifier must be 32 characters or less, got ${t}`)}};import{DelegationChain as w,DelegationIdentity as v,ECDSAKeyIdentity as E,Ed25519KeyIdentity as g}from"@icp-sdk/core/identity";import{clear as x,createStore as A,entries as _,update as h}from"idb-keyval";var I=A("juno-dev-identifiers","juno-dev-identifiers-store"),S=async({limit:e}={})=>(await _(I)).sort(([y,{updatedAt:a}],[l,{updatedAt:d}])=>d-a).slice(0,e),R=()=>x(I),K=async({identifier:e="dev",maxTimeToLiveInMilliseconds:t}={})=>{if(!(typeof window<"u"))throw new o;let{location:{hostname:a}}=window;if(!["127.0.0.1","localhost"].includes(a))throw new s;let l=()=>{if(e.length>32)throw new i(e.length);return new TextEncoder().encode(e.padEnd(32,"0"))},d=async()=>{let n=l(),r=g.generate(n),c=await E.generate({extractable:!1}),p=t??6048e5,f=await w.create(r,c.getPublicKey(),new Date(Date.now()+p));return{identity:v.fromDelegation(c,f),sessionKey:c,delegationChain:f}},u=async()=>{await h(e,n=>{let r=Date.now();return{createdAt:n?.createdAt??r,updatedAt:r}},I)},D=await d();return await u(),D};export{i as UnsafeDevIdentityInvalidIdentifierError,o as UnsafeDevIdentityNotBrowserError,s as UnsafeDevIdentityNotLocalhostError,R as clearDevIdentifiers,K as generateUnsafeDevIdentity,S as loadDevIdentifiers};
|
|
4
|
+
//# sourceMappingURL=dev.mjs.map
|
package/dev.mjs.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/dev/errors.ts", "src/dev/identity.ts"],
|
|
4
|
+
"sourcesContent": ["export class UnsafeDevIdentityNotBrowserError extends Error {\n constructor() {\n super('A dev identity can only be used in browser environments');\n }\n}\n\nexport class UnsafeDevIdentityNotLocalhostError extends Error {\n constructor() {\n super('A dev identity must only be used on localhost (127.0.0.1 or localhost)');\n }\n}\n\nexport class UnsafeDevIdentityInvalidIdentifierError extends Error {\n constructor(length: number) {\n super(`Identifier must be 32 characters or less, got ${length}`);\n }\n}\n", "import {\n DelegationChain,\n DelegationIdentity,\n ECDSAKeyIdentity,\n Ed25519KeyIdentity\n} from '@icp-sdk/core/identity';\nimport {clear, createStore, entries, update} from 'idb-keyval';\nimport {DEFAULT_DEV_DELEGATION_IDENTITY_EXPIRATION_IN_MS} from './_constants';\nimport {\n UnsafeDevIdentityInvalidIdentifierError,\n UnsafeDevIdentityNotBrowserError,\n UnsafeDevIdentityNotLocalhostError\n} from './errors';\nimport type {\n DevIdentifier,\n DevIdentifierData,\n GenerateUnsafeIdentityParams,\n GenerateUnsafeIdentityResult,\n LoadDevIdentifiersParams\n} from './types/identity';\n\nconst identifiersIdbStore = createStore('juno-dev-identifiers', 'juno-dev-identifiers-store');\n\n/**\n * Load all development identifiers that have been used for authentication.\n *\n * Returns an array of tuples containing the identifier string and metadata (created/updated timestamps),\n * sorted by most recently used first.\n *\n * @param params - Load parameters\n * @param params.limit - Optional maximum number of identifiers to return\n * @returns Promise resolving to array of [identifier, metadata] tuples sorted by updatedAt descending\n *\n * @example\n * const recent = await loadDevIdentifiers({ limit: 5 });\n * // Returns only the 5 most recently used identifiers\n */\nexport const loadDevIdentifiers = async ({limit}: LoadDevIdentifiersParams = {}): Promise<\n [DevIdentifier, DevIdentifierData][]\n> => {\n const identifiers = await entries<DevIdentifier, DevIdentifierData>(identifiersIdbStore);\n\n return identifiers.sort(([_, {updatedAt: a}], [__, {updatedAt: b}]) => b - a).slice(0, limit);\n};\n\n/**\n * Clear all stored development identifiers from IndexedDB.\n * This removes the history of used identifiers but does not affect AuthClient's stored credentials.\n *\n * @returns Promise that resolves when identifiers are cleared\n */\nexport const clearDevIdentifiers = () => clear(identifiersIdbStore);\n\n/**\n * Generate an identity for local development with the Internet Computer.\n *\n * \u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\n * \u26A0\uFE0F UNSAFE - FOR LOCAL DEVELOPMENT ONLY \u26A0\uFE0F\n * \u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\n *\n * Returns the identity, session key, and delegation chain.\n * Consumers must handle storage (e.g. for AuthClient compatibility).\n *\n * @param params - Generation parameters\n * @param params.identifier - Unique identifier string for this dev identity (default: \"dev\")\n * @param params.maxTimeToLiveInMilliseconds - Delegation expiration time in ms (default: 7 days)\n *\n * @returns Promise resolving to object containing identity, sessionKey, and delegationChain\n *\n * @throws {UnsafeDevIdentityNotBrowserError} If called outside browser environment\n * @throws {UnsafeDevIdentityNotLocalhostError} If called outside localhost\n **/\nexport const generateUnsafeDevIdentity = async ({\n identifier = 'dev',\n maxTimeToLiveInMilliseconds\n}: GenerateUnsafeIdentityParams = {}): Promise<GenerateUnsafeIdentityResult> => {\n const isBrowser = (): boolean => typeof window !== `undefined`;\n\n if (!isBrowser()) {\n throw new UnsafeDevIdentityNotBrowserError();\n }\n\n const {\n location: {hostname}\n } = window;\n\n if (!['127.0.0.1', 'localhost'].includes(hostname)) {\n throw new UnsafeDevIdentityNotLocalhostError();\n }\n\n const generateSeed = (): Uint8Array => {\n if (identifier.length > 32) {\n throw new UnsafeDevIdentityInvalidIdentifierError(identifier.length);\n }\n\n const encoder = new TextEncoder();\n return encoder.encode(identifier.padEnd(32, '0'));\n };\n\n const generate = async (): Promise<GenerateUnsafeIdentityResult> => {\n const seedBytes = generateSeed();\n\n const rootIdentity = Ed25519KeyIdentity.generate(seedBytes);\n const sessionKey = await ECDSAKeyIdentity.generate({\n extractable: false\n });\n\n const sessionLengthInMilliseconds =\n maxTimeToLiveInMilliseconds ?? DEFAULT_DEV_DELEGATION_IDENTITY_EXPIRATION_IN_MS;\n\n const chain = await DelegationChain.create(\n rootIdentity,\n sessionKey.getPublicKey(),\n new Date(Date.now() + sessionLengthInMilliseconds)\n );\n\n const delegatedIdentity = DelegationIdentity.fromDelegation(sessionKey, chain);\n\n return {\n identity: delegatedIdentity,\n sessionKey,\n delegationChain: chain\n };\n };\n\n const saveIdentifierUsage = async () => {\n await update(\n identifier,\n (value) => {\n const now = Date.now();\n\n return {\n createdAt: value?.createdAt ?? now,\n updatedAt: now\n };\n },\n identifiersIdbStore\n );\n };\n\n const result = await generate();\n\n await saveIdentifierUsage();\n\n return result;\n};\n"],
|
|
5
|
+
"mappings": ";;AAAO,IAAMA,EAAN,cAA+C,KAAM,CAC1D,aAAc,CACZ,MAAM,yDAAyD,CACjE,CACF,EAEaC,EAAN,cAAiD,KAAM,CAC5D,aAAc,CACZ,MAAM,wEAAwE,CAChF,CACF,EAEaC,EAAN,cAAsD,KAAM,CACjE,YAAYC,EAAgB,CAC1B,MAAM,iDAAiDA,CAAM,EAAE,CACjE,CACF,EChBA,OACE,mBAAAC,EACA,sBAAAC,EACA,oBAAAC,EACA,sBAAAC,MACK,yBACP,OAAQ,SAAAC,EAAO,eAAAC,EAAa,WAAAC,EAAS,UAAAC,MAAa,aAelD,IAAMC,EAAsBC,EAAY,uBAAwB,4BAA4B,EAgB/EC,EAAqB,MAAO,CAAC,MAAAC,CAAK,EAA8B,CAAC,KAGxD,MAAMC,EAA0CJ,CAAmB,GAEpE,KAAK,CAAC,CAACK,EAAG,CAAC,UAAW,CAAC,CAAC,EAAG,CAACC,EAAI,CAAC,UAAWC,CAAC,CAAC,IAAMA,EAAI,CAAC,EAAE,MAAM,EAAGJ,CAAK,EASjFK,EAAsB,IAAMC,EAAMT,CAAmB,EAqBrDU,EAA4B,MAAO,CAC9C,WAAAC,EAAa,MACb,4BAAAC,CACF,EAAkC,CAAC,IAA6C,CAG9E,GAAI,EAF6B,OAAO,OAAW,KAGjD,MAAM,IAAIC,EAGZ,GAAM,CACJ,SAAU,CAAC,SAAAC,CAAQ,CACrB,EAAI,OAEJ,GAAI,CAAC,CAAC,YAAa,WAAW,EAAE,SAASA,CAAQ,EAC/C,MAAM,IAAIC,EAGZ,IAAMC,EAAe,IAAkB,CACrC,GAAIL,EAAW,OAAS,GACtB,MAAM,IAAIM,EAAwCN,EAAW,MAAM,EAIrE,OADgB,IAAI,YAAY,EACjB,OAAOA,EAAW,OAAO,GAAI,GAAG,CAAC,CAClD,EAEMO,EAAW,SAAmD,CAClE,IAAMC,EAAYH,EAAa,EAEzBI,EAAeC,EAAmB,SAASF,CAAS,EACpDG,EAAa,MAAMC,EAAiB,SAAS,CACjD,YAAa,EACf,CAAC,EAEKC,EACJZ,GAA+B,OAE3Ba,EAAQ,MAAMC,EAAgB,OAClCN,EACAE,EAAW,aAAa,EACxB,IAAI,KAAK,KAAK,IAAI,EAAIE,CAA2B,CACnD,EAIA,MAAO,CACL,SAHwBG,EAAmB,eAAeL,EAAYG,CAAK,EAI3E,WAAAH,EACA,gBAAiBG,CACnB,CACF,EAEMG,EAAsB,SAAY,CACtC,MAAMC,EACJlB,EACCmB,GAAU,CACT,IAAMC,EAAM,KAAK,IAAI,EAErB,MAAO,CACL,UAAWD,GAAO,WAAaC,EAC/B,UAAWA,CACb,CACF,EACA/B,CACF,CACF,EAEMgC,EAAS,MAAMd,EAAS,EAE9B,aAAMU,EAAoB,EAEnBI,CACT",
|
|
6
|
+
"names": ["UnsafeDevIdentityNotBrowserError", "UnsafeDevIdentityNotLocalhostError", "UnsafeDevIdentityInvalidIdentifierError", "length", "DelegationChain", "DelegationIdentity", "ECDSAKeyIdentity", "Ed25519KeyIdentity", "clear", "createStore", "entries", "update", "identifiersIdbStore", "createStore", "loadDevIdentifiers", "limit", "entries", "_", "__", "b", "clearDevIdentifiers", "clear", "generateUnsafeDevIdentity", "identifier", "maxTimeToLiveInMilliseconds", "UnsafeDevIdentityNotBrowserError", "hostname", "UnsafeDevIdentityNotLocalhostError", "generateSeed", "UnsafeDevIdentityInvalidIdentifierError", "generate", "seedBytes", "rootIdentity", "Ed25519KeyIdentity", "sessionKey", "ECDSAKeyIdentity", "sessionLengthInMilliseconds", "chain", "DelegationChain", "DelegationIdentity", "saveIdentifierUsage", "update", "value", "now", "result"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junobuild/ic-client",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0-next-2026-02-10",
|
|
4
4
|
"description": "Agent and actor with generated bindings for Juno on the Internet Computer",
|
|
5
5
|
"author": "David Dal Busco (https://daviddalbusco.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"types": "./utils.d.ts",
|
|
29
29
|
"import": "./utils.js",
|
|
30
30
|
"require": "./utils.mjs"
|
|
31
|
+
},
|
|
32
|
+
"./dev": {
|
|
33
|
+
"types": "./dev.d.ts",
|
|
34
|
+
"import": "./dev.js",
|
|
35
|
+
"require": "./dev.mjs"
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"files": [
|
|
@@ -72,7 +77,8 @@
|
|
|
72
77
|
],
|
|
73
78
|
"homepage": "https://juno.build",
|
|
74
79
|
"peerDependencies": {
|
|
75
|
-
"@dfinity/utils": "
|
|
76
|
-
"@icp-sdk/core": "
|
|
80
|
+
"@dfinity/utils": "*",
|
|
81
|
+
"@icp-sdk/core": "*",
|
|
82
|
+
"idb-keyval": "*"
|
|
77
83
|
}
|
|
78
|
-
}
|
|
84
|
+
}
|