@pippit-dev/cli 1.0.38 → 1.0.40
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 +84 -1
- package/checksums.txt +6 -6
- package/cmd/auth/auth.go +4 -3
- package/cmd/marketing.go +5 -4
- package/cmd/marketing_test.go +58 -0
- package/cmd/root.go +40 -14
- package/cmd/root_test.go +63 -0
- package/cmd/source_test.go +2 -3
- package/cmd/submit_run_test.go +20 -81
- package/cmd/update/update.go +36 -10
- package/cmd/update/update_test.go +73 -3
- package/dist/checksums.txt +6 -6
- package/dist/xyq-canvas-command-runtime.cjs +14 -14
- package/dist/xyq-canvas-command-runtime.cjs.LEGAL.txt +0 -206
- package/dist/xyq-canvas-command-runtime.cjs.sha256 +2 -2
- package/internal/adapter/adapter.go +73 -0
- package/internal/adapter/ppe.go +36 -0
- package/internal/adaptercli/commands.go +27 -0
- package/internal/adaptercli/commands_test.go +41 -0
- package/internal/auth/manager.go +25 -13
- package/internal/canvas/apply.go +3 -0
- package/internal/canvas/media_identity.go +300 -0
- package/internal/canvas/media_identity_test.go +160 -0
- package/internal/canvas/upload.go +30 -1
- package/internal/commandnames/names.go +9 -0
- package/internal/common/adapter_test.go +74 -0
- package/internal/common/client.go +37 -12
- package/internal/config/config.go +41 -0
- package/internal/config/config_test.go +41 -1
- package/internal/generate_video/generate_video.go +1 -0
- package/internal/generate_video/generate_video_test.go +25 -3
- package/internal/models/models.go +6 -2
- package/internal/models/models_test.go +7 -0
- package/package.json +2 -2
- package/scripts/canvas-command.js +4 -2
- package/skills/short-drama/SKILL.md +6 -3
- package/skills/short-drama/commands/download-result.md +9 -3
- package/skills/short-drama/commands/get-thread.md +2 -0
- package/skills/short-drama/commands/list-thread-file.md +12 -6
- package/skills/short-drama/commands/submit-run.md +3 -1
- package/skills/short-drama/examples/create-and-deliver.md +2 -2
- package/skills/short-drama/examples/reference-and-continue.md +20 -1
- package/skills/short-drama/workflows/creation.md +28 -14
- package/skills/short-drama/workflows/poll-and-deliver.md +27 -9
- package/skills/xyq-nest-skill/commands/canvas-assets.md +9 -1
|
@@ -304,212 +304,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
304
304
|
See the License for the specific language governing permissions and
|
|
305
305
|
limitations under the License.
|
|
306
306
|
|
|
307
|
-
===== @swc/helpers@0.5.6 =====
|
|
308
|
-
License metadata: Apache-2.0
|
|
309
|
-
|
|
310
|
-
--- LICENSE ---
|
|
311
|
-
Apache License
|
|
312
|
-
Version 2.0, January 2004
|
|
313
|
-
http://www.apache.org/licenses/
|
|
314
|
-
|
|
315
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
316
|
-
|
|
317
|
-
1. Definitions.
|
|
318
|
-
|
|
319
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
320
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
321
|
-
|
|
322
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
323
|
-
the copyright owner that is granting the License.
|
|
324
|
-
|
|
325
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
326
|
-
other entities that control, are controlled by, or are under common
|
|
327
|
-
control with that entity. For the purposes of this definition,
|
|
328
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
329
|
-
direction or management of such entity, whether by contract or
|
|
330
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
331
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
332
|
-
|
|
333
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
334
|
-
exercising permissions granted by this License.
|
|
335
|
-
|
|
336
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
337
|
-
including but not limited to software source code, documentation
|
|
338
|
-
source, and configuration files.
|
|
339
|
-
|
|
340
|
-
"Object" form shall mean any form resulting from mechanical
|
|
341
|
-
transformation or translation of a Source form, including but
|
|
342
|
-
not limited to compiled object code, generated documentation,
|
|
343
|
-
and conversions to other media types.
|
|
344
|
-
|
|
345
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
346
|
-
Object form, made available under the License, as indicated by a
|
|
347
|
-
copyright notice that is included in or attached to the work
|
|
348
|
-
(an example is provided in the Appendix below).
|
|
349
|
-
|
|
350
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
351
|
-
form, that is based on (or derived from) the Work and for which the
|
|
352
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
353
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
354
|
-
of this License, Derivative Works shall not include works that remain
|
|
355
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
356
|
-
the Work and Derivative Works thereof.
|
|
357
|
-
|
|
358
|
-
"Contribution" shall mean any work of authorship, including
|
|
359
|
-
the original version of the Work and any modifications or additions
|
|
360
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
361
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
362
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
363
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
364
|
-
means any form of electronic, verbal, or written communication sent
|
|
365
|
-
to the Licensor or its representatives, including but not limited to
|
|
366
|
-
communication on electronic mailing lists, source code control systems,
|
|
367
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
368
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
369
|
-
excluding communication that is conspicuously marked or otherwise
|
|
370
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
371
|
-
|
|
372
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
373
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
374
|
-
subsequently incorporated within the Work.
|
|
375
|
-
|
|
376
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
377
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
378
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
379
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
380
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
381
|
-
Work and such Derivative Works in Source or Object form.
|
|
382
|
-
|
|
383
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
384
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
385
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
386
|
-
(except as stated in this section) patent license to make, have made,
|
|
387
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
388
|
-
where such license applies only to those patent claims licensable
|
|
389
|
-
by such Contributor that are necessarily infringed by their
|
|
390
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
391
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
392
|
-
institute patent litigation against any entity (including a
|
|
393
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
394
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
395
|
-
or contributory patent infringement, then any patent licenses
|
|
396
|
-
granted to You under this License for that Work shall terminate
|
|
397
|
-
as of the date such litigation is filed.
|
|
398
|
-
|
|
399
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
400
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
401
|
-
modifications, and in Source or Object form, provided that You
|
|
402
|
-
meet the following conditions:
|
|
403
|
-
|
|
404
|
-
(a) You must give any other recipients of the Work or
|
|
405
|
-
Derivative Works a copy of this License; and
|
|
406
|
-
|
|
407
|
-
(b) You must cause any modified files to carry prominent notices
|
|
408
|
-
stating that You changed the files; and
|
|
409
|
-
|
|
410
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
411
|
-
that You distribute, all copyright, patent, trademark, and
|
|
412
|
-
attribution notices from the Source form of the Work,
|
|
413
|
-
excluding those notices that do not pertain to any part of
|
|
414
|
-
the Derivative Works; and
|
|
415
|
-
|
|
416
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
417
|
-
distribution, then any Derivative Works that You distribute must
|
|
418
|
-
include a readable copy of the attribution notices contained
|
|
419
|
-
within such NOTICE file, excluding those notices that do not
|
|
420
|
-
pertain to any part of the Derivative Works, in at least one
|
|
421
|
-
of the following places: within a NOTICE text file distributed
|
|
422
|
-
as part of the Derivative Works; within the Source form or
|
|
423
|
-
documentation, if provided along with the Derivative Works; or,
|
|
424
|
-
within a display generated by the Derivative Works, if and
|
|
425
|
-
wherever such third-party notices normally appear. The contents
|
|
426
|
-
of the NOTICE file are for informational purposes only and
|
|
427
|
-
do not modify the License. You may add Your own attribution
|
|
428
|
-
notices within Derivative Works that You distribute, alongside
|
|
429
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
430
|
-
that such additional attribution notices cannot be construed
|
|
431
|
-
as modifying the License.
|
|
432
|
-
|
|
433
|
-
You may add Your own copyright statement to Your modifications and
|
|
434
|
-
may provide additional or different license terms and conditions
|
|
435
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
436
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
437
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
438
|
-
the conditions stated in this License.
|
|
439
|
-
|
|
440
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
441
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
442
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
443
|
-
this License, without any additional terms or conditions.
|
|
444
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
445
|
-
the terms of any separate license agreement you may have executed
|
|
446
|
-
with Licensor regarding such Contributions.
|
|
447
|
-
|
|
448
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
449
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
450
|
-
except as required for reasonable and customary use in describing the
|
|
451
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
452
|
-
|
|
453
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
454
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
455
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
456
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
457
|
-
implied, including, without limitation, any warranties or conditions
|
|
458
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
459
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
460
|
-
appropriateness of using or redistributing the Work and assume any
|
|
461
|
-
risks associated with Your exercise of permissions under this License.
|
|
462
|
-
|
|
463
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
464
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
465
|
-
unless required by applicable law (such as deliberate and grossly
|
|
466
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
467
|
-
liable to You for damages, including any direct, indirect, special,
|
|
468
|
-
incidental, or consequential damages of any character arising as a
|
|
469
|
-
result of this License or out of the use or inability to use the
|
|
470
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
471
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
472
|
-
other commercial damages or losses), even if such Contributor
|
|
473
|
-
has been advised of the possibility of such damages.
|
|
474
|
-
|
|
475
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
476
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
477
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
478
|
-
or other liability obligations and/or rights consistent with this
|
|
479
|
-
License. However, in accepting such obligations, You may act only
|
|
480
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
481
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
482
|
-
defend, and hold each Contributor harmless for any liability
|
|
483
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
484
|
-
of your accepting any such warranty or additional liability.
|
|
485
|
-
|
|
486
|
-
END OF TERMS AND CONDITIONS
|
|
487
|
-
|
|
488
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
489
|
-
|
|
490
|
-
To apply the Apache License to your work, attach the following
|
|
491
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
492
|
-
replaced with your own identifying information. (Don't include
|
|
493
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
494
|
-
comment syntax for the file format. We also recommend that a
|
|
495
|
-
file or class name and description of purpose be included on the
|
|
496
|
-
same "printed page" as the copyright notice for easier
|
|
497
|
-
identification within third-party archives.
|
|
498
|
-
|
|
499
|
-
Copyright [yyyy] [name of copyright owner]
|
|
500
|
-
|
|
501
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
502
|
-
you may not use this file except in compliance with the License.
|
|
503
|
-
You may obtain a copy of the License at
|
|
504
|
-
|
|
505
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
506
|
-
|
|
507
|
-
Unless required by applicable law or agreed to in writing, software
|
|
508
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
509
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
510
|
-
See the License for the specific language governing permissions and
|
|
511
|
-
limitations under the License.
|
|
512
|
-
|
|
513
307
|
===== dagre@0.8.5 =====
|
|
514
308
|
License metadata: MIT
|
|
515
309
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
f258da52a41a6e5631c169037db8f6bfd34b06c96926e094d85cd6418e6fca31 xyq-canvas-command-runtime.cjs
|
|
2
|
+
3b97217c41dfb3c298185c80b1e70c2b469f552450e53d00fc1dcf7098740ffb xyq-canvas-command-runtime.cjs.LEGAL.txt
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Package adapter defines the CLI command and HTTP request policy interfaces.
|
|
2
|
+
// Different runtimes can implement them without depending on a specific platform or command framework.
|
|
3
|
+
package adapter
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"context"
|
|
7
|
+
"net/http"
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
type Adapter interface {
|
|
11
|
+
CLIAdapter
|
|
12
|
+
HTTPAdapter
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type CLIAdapter interface {
|
|
16
|
+
CLIOptions() CLIOptions
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type HTTPAdapter interface {
|
|
20
|
+
// Called only after the common client confirms the API origin matches. The client owns the request, so its path and authentication headers may be changed.
|
|
21
|
+
PrepareAPIRequest(context.Context, *http.Request) (AuthDecision, error)
|
|
22
|
+
// Wraps the HTTP transport. A nil next uses the standard default transport.
|
|
23
|
+
// Returning nil lets http.Client use its default transport.
|
|
24
|
+
WrapTransport(next http.RoundTripper) http.RoundTripper
|
|
25
|
+
// Removes sensitive request headers used by this implementation. The common client handles Authorization removal and origin checks.
|
|
26
|
+
StripSensitiveHeaders(*http.Request)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type CLIOptions struct {
|
|
30
|
+
// Whether to allow top-level business commands by default. Local authentication and self-update have separate switches.
|
|
31
|
+
DefaultAllowRootCommands bool
|
|
32
|
+
// When commands are denied by default, this allowlist enables them. Nil and empty slices both mean no commands are allowed.
|
|
33
|
+
AllowedRootCommands []string
|
|
34
|
+
LocalCredentialsEnabled bool
|
|
35
|
+
SelfUpdateEnabled bool
|
|
36
|
+
// An empty string keeps the common help text.
|
|
37
|
+
RootHelpOverride string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
type AuthDecision uint8
|
|
41
|
+
|
|
42
|
+
const (
|
|
43
|
+
UseDefaultAuth AuthDecision = iota
|
|
44
|
+
// AuthProvided means authentication material was attached, not that the server has authenticated the request.
|
|
45
|
+
AuthProvided
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
// Default allows all commands, local authentication, and self-update. HTTP requests use the client's default authentication and transport.
|
|
49
|
+
type Default struct{}
|
|
50
|
+
|
|
51
|
+
var _ Adapter = Default{}
|
|
52
|
+
|
|
53
|
+
func (Default) CLIOptions() CLIOptions {
|
|
54
|
+
return CLIOptions{DefaultAllowRootCommands: true, LocalCredentialsEnabled: true, SelfUpdateEnabled: true}
|
|
55
|
+
}
|
|
56
|
+
func (Default) PrepareAPIRequest(context.Context, *http.Request) (AuthDecision, error) {
|
|
57
|
+
return UseDefaultAuth, nil
|
|
58
|
+
}
|
|
59
|
+
func (Default) WrapTransport(next http.RoundTripper) http.RoundTripper { return next }
|
|
60
|
+
func (Default) StripSensitiveHeaders(*http.Request) {}
|
|
61
|
+
|
|
62
|
+
func OrDefault(value Adapter) Adapter {
|
|
63
|
+
if value == nil {
|
|
64
|
+
return Default{}
|
|
65
|
+
}
|
|
66
|
+
return value
|
|
67
|
+
}
|
|
68
|
+
func HTTPOrDefault(value HTTPAdapter) HTTPAdapter {
|
|
69
|
+
if value == nil {
|
|
70
|
+
return Default{}
|
|
71
|
+
}
|
|
72
|
+
return value
|
|
73
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package adapter
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"net/http"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// WithPPE applies runtime routing only to requests accepted by the common
|
|
9
|
+
// client's API-origin check, while preserving the supplied adapter's policies.
|
|
10
|
+
func WithPPE(policy HTTPAdapter, env string) HTTPAdapter {
|
|
11
|
+
policy = HTTPOrDefault(policy)
|
|
12
|
+
if env == "" {
|
|
13
|
+
return policy
|
|
14
|
+
}
|
|
15
|
+
return ppeAdapter{HTTPAdapter: policy, env: env}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ppeAdapter struct {
|
|
19
|
+
HTTPAdapter
|
|
20
|
+
env string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func (a ppeAdapter) PrepareAPIRequest(ctx context.Context, req *http.Request) (AuthDecision, error) {
|
|
24
|
+
decision, err := a.HTTPAdapter.PrepareAPIRequest(ctx, req)
|
|
25
|
+
if err == nil {
|
|
26
|
+
req.Header.Set("x-tt-env", a.env)
|
|
27
|
+
req.Header.Set("x-use-ppe", "1")
|
|
28
|
+
}
|
|
29
|
+
return decision, err
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func (a ppeAdapter) StripSensitiveHeaders(req *http.Request) {
|
|
33
|
+
a.HTTPAdapter.StripSensitiveHeaders(req)
|
|
34
|
+
req.Header.Del("x-tt-env")
|
|
35
|
+
req.Header.Del("x-use-ppe")
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Package adaptercli configures Cobra command availability and help text from CLIOptions.
|
|
2
|
+
package adaptercli
|
|
3
|
+
|
|
4
|
+
import (
|
|
5
|
+
"slices"
|
|
6
|
+
|
|
7
|
+
"github.com/Pippit-dev/pippit-cli/internal/adapter"
|
|
8
|
+
"github.com/Pippit-dev/pippit-cli/internal/commandnames"
|
|
9
|
+
"github.com/spf13/cobra"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
// Configure removes disallowed top-level commands and their aliases after registration.
|
|
13
|
+
// It retains allowed commands and all their subcommands, then applies the configured help text.
|
|
14
|
+
func Configure(root *cobra.Command, options adapter.CLIOptions) {
|
|
15
|
+
commands := append([]*cobra.Command(nil), root.Commands()...)
|
|
16
|
+
for _, child := range commands {
|
|
17
|
+
name := child.Name()
|
|
18
|
+
allowed := options.DefaultAllowRootCommands || slices.Contains(options.AllowedRootCommands, name)
|
|
19
|
+
if !allowed || (!options.LocalCredentialsEnabled && slices.Contains([]string{commandnames.Login, commandnames.Logout, commandnames.Status}, name)) ||
|
|
20
|
+
(!options.SelfUpdateEnabled && name == commandnames.Update) {
|
|
21
|
+
root.RemoveCommand(child)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if options.RootHelpOverride != "" {
|
|
25
|
+
root.Long = options.RootHelpOverride
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package adaptercli
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"slices"
|
|
5
|
+
"testing"
|
|
6
|
+
|
|
7
|
+
"github.com/Pippit-dev/pippit-cli/internal/adapter"
|
|
8
|
+
"github.com/spf13/cobra"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
func TestConfigureDefaultAllowRootCommands(t *testing.T) {
|
|
12
|
+
for _, tc := range []struct {
|
|
13
|
+
name string
|
|
14
|
+
defaultAllow bool
|
|
15
|
+
allowlist []string
|
|
16
|
+
want []string
|
|
17
|
+
}{
|
|
18
|
+
{name: "默认拒绝且 nil 白名单"},
|
|
19
|
+
{name: "默认拒绝且空白名单", allowlist: []string{}},
|
|
20
|
+
{name: "默认拒绝且有白名单", allowlist: []string{"canvas"}, want: []string{"canvas"}},
|
|
21
|
+
{name: "默认放行且 nil 白名单", defaultAllow: true, want: []string{"canvas", "future-command"}},
|
|
22
|
+
{name: "默认放行且空白名单", defaultAllow: true, allowlist: []string{}, want: []string{"canvas", "future-command"}},
|
|
23
|
+
{name: "默认放行且有白名单", defaultAllow: true, allowlist: []string{"canvas"}, want: []string{"canvas", "future-command"}},
|
|
24
|
+
} {
|
|
25
|
+
t.Run(tc.name, func(t *testing.T) {
|
|
26
|
+
root := &cobra.Command{Use: "tool"}
|
|
27
|
+
for _, name := range []string{"canvas", "future-command", "login", "logout", "status", "update"} {
|
|
28
|
+
root.AddCommand(&cobra.Command{Use: name})
|
|
29
|
+
}
|
|
30
|
+
Configure(root, adapter.CLIOptions{DefaultAllowRootCommands: tc.defaultAllow, AllowedRootCommands: tc.allowlist})
|
|
31
|
+
var got []string
|
|
32
|
+
for _, child := range root.Commands() {
|
|
33
|
+
got = append(got, child.Name())
|
|
34
|
+
}
|
|
35
|
+
slices.Sort(got)
|
|
36
|
+
if !slices.Equal(got, tc.want) {
|
|
37
|
+
t.Fatalf("命令范围异常: got=%v want=%v", got, tc.want)
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
}
|
package/internal/auth/manager.go
CHANGED
|
@@ -11,22 +11,29 @@ import (
|
|
|
11
11
|
"sync"
|
|
12
12
|
"time"
|
|
13
13
|
|
|
14
|
+
"github.com/Pippit-dev/pippit-cli/internal/adapter"
|
|
14
15
|
"github.com/Pippit-dev/pippit-cli/internal/config"
|
|
15
16
|
)
|
|
16
17
|
|
|
17
18
|
type Manager struct {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
localCredentialsEnabled bool
|
|
20
|
+
cfg *config.Config
|
|
21
|
+
store CredentialStore
|
|
22
|
+
authBaseURL *url.URL
|
|
23
|
+
random io.Reader
|
|
24
|
+
now func() time.Time
|
|
25
|
+
credentialMu sync.Mutex
|
|
26
|
+
cachedCredential *Credential
|
|
27
|
+
credentialCacheLoaded bool
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
type ManagerOption func(*Manager)
|
|
29
31
|
|
|
32
|
+
// WithCLIOptions sets whether local login is allowed at construction. Direct Login calls also check this setting.
|
|
33
|
+
func WithCLIOptions(options adapter.CLIOptions) ManagerOption {
|
|
34
|
+
return func(manager *Manager) { manager.localCredentialsEnabled = options.LocalCredentialsEnabled }
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
func WithCredentialStore(store CredentialStore) ManagerOption {
|
|
31
38
|
return func(manager *Manager) {
|
|
32
39
|
if store != nil {
|
|
@@ -41,11 +48,12 @@ func NewManager(cfg *config.Config, options ...ManagerOption) *Manager {
|
|
|
41
48
|
serviceName := config.DefaultAuthStoreServiceName
|
|
42
49
|
authBaseURL, _ := url.Parse(config.DefaultBaseURL)
|
|
43
50
|
manager := &Manager{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
localCredentialsEnabled: true,
|
|
52
|
+
cfg: cfg,
|
|
53
|
+
store: NewDefaultCredentialStore(serviceName),
|
|
54
|
+
authBaseURL: authBaseURL,
|
|
55
|
+
random: rand.Reader,
|
|
56
|
+
now: time.Now,
|
|
49
57
|
}
|
|
50
58
|
for _, option := range options {
|
|
51
59
|
if option != nil {
|
|
@@ -75,6 +83,10 @@ func (m *Manager) ResolveAccessKey(ctx context.Context) (string, error) {
|
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
func (m *Manager) Login(ctx context.Context, options LoginOptions) (*Credential, error) {
|
|
86
|
+
// When local credentials are disabled, reject direct calls before reading credentials or opening a browser, even if command filtering is bypassed.
|
|
87
|
+
if m != nil && !m.localCredentialsEnabled {
|
|
88
|
+
return nil, errors.New("当前 CLI 不支持本机网页登录或登录回调,请使用当前运行环境提供的认证方式")
|
|
89
|
+
}
|
|
78
90
|
if err := m.validate(); err != nil {
|
|
79
91
|
return nil, err
|
|
80
92
|
}
|
package/internal/canvas/apply.go
CHANGED
|
@@ -100,6 +100,9 @@ func Apply(ctx context.Context, opts ApplyOptions, runner *common.Runner) (*Appl
|
|
|
100
100
|
if err := validateApplyRequest(&request); err != nil {
|
|
101
101
|
return nil, err
|
|
102
102
|
}
|
|
103
|
+
if err := validateApplyMediaIdentities(ctx, request, runner); err != nil {
|
|
104
|
+
return nil, err
|
|
105
|
+
}
|
|
103
106
|
|
|
104
107
|
var envelope responseEnvelope
|
|
105
108
|
if err := client.SendRequest(ctx, pathWithProjectID(ApplyPath, projectID), request, &envelope); err != nil {
|